mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Fixed card stacking offset in Editor / Library / etc.
* Rather than respecting the spacing setting from Preferences, the spacing is now calculated from the card size if characteristic based rendering is enabled, since from the renderer we know exactly what spacing is actually needed.
This commit is contained in:
parent
28c04e2009
commit
7feb237c06
2 changed files with 41 additions and 7 deletions
|
@ -13,6 +13,9 @@ import javax.swing.JMenuItem;
|
|||
import javax.swing.JPopupMenu;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.sets.avacynrestored.GuiseOfFire;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.CardRenderer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -140,10 +143,14 @@ public class GUISizeHelper {
|
|||
|
||||
int otherZonesCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OTHER_ZONES_SIZE, 14);
|
||||
otherZonesCardDimension = new Dimension(CARD_IMAGE_WIDTH * otherZonesCardSize / 42, CARD_IMAGE_HEIGHT * otherZonesCardSize / 42);
|
||||
if (otherZonesCardSize > 29) {
|
||||
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 8;
|
||||
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false").equals("false")) {
|
||||
otherZonesCardVerticalOffset = CardRenderer.getCardTopHeight(otherZonesCardDimension.width);
|
||||
} else {
|
||||
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 10;
|
||||
if (otherZonesCardSize > 29) {
|
||||
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 8;
|
||||
} else {
|
||||
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 10;
|
||||
}
|
||||
}
|
||||
|
||||
int battlefieldCardMinSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_BATTLEFIELD_MIN_SIZE, 10);
|
||||
|
@ -153,7 +160,11 @@ public class GUISizeHelper {
|
|||
|
||||
int editorCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_EDITOR_SIZE, 14);
|
||||
editorCardDimension = new Dimension(CARD_IMAGE_WIDTH * editorCardSize / 42, CARD_IMAGE_HEIGHT * editorCardSize / 42);
|
||||
editorCardOffsetSize = 2 * PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OFFSET_SIZE, 14) - 10;
|
||||
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false").equals("false")) {
|
||||
editorCardOffsetSize = CardRenderer.getCardTopHeight(editorCardDimension.width);
|
||||
} else {
|
||||
editorCardOffsetSize = 2 * PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OFFSET_SIZE, 14) - 10;
|
||||
}
|
||||
|
||||
enlargedImageHeight = 25 * PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_ENLARGED_IMAGE_SIZE, 20);
|
||||
}
|
||||
|
|
|
@ -149,6 +149,12 @@ public abstract class CardRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private static int getBorderWidth(int cardWidth) {
|
||||
return (int) Math.max(
|
||||
BORDER_WIDTH_MIN,
|
||||
BORDER_WIDTH_FRAC * cardWidth);
|
||||
}
|
||||
|
||||
// Layout operation
|
||||
// Calculate common layout metrics that will be used by several
|
||||
// of the operations in the template method.
|
||||
|
@ -162,9 +168,26 @@ public abstract class CardRenderer {
|
|||
CORNER_RADIUS_MIN,
|
||||
CORNER_RADIUS_FRAC * cardWidth);
|
||||
|
||||
borderWidth = (int) Math.max(
|
||||
BORDER_WIDTH_MIN,
|
||||
BORDER_WIDTH_FRAC * cardWidth);
|
||||
borderWidth = getBorderWidth(cardWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* How far does a card have to be spaced down from
|
||||
* a rendered card to show it's entire name line?
|
||||
* This function is a bit of a hack, as different card faces need
|
||||
* slightly different spacing, but we need it in a static context
|
||||
* so that spacing is consistent in GY / deck views etc.
|
||||
* @return
|
||||
*/
|
||||
public static int getCardTopHeight(int cardWidth) {
|
||||
// Constants copied over from ModernCardRenderer and tweaked
|
||||
float BOX_HEIGHT_FRAC = 0.065f; // x cardHeight
|
||||
int BOX_HEIGHT_MIN = 16;
|
||||
int boxHeight = (int) Math.max(
|
||||
BOX_HEIGHT_MIN,
|
||||
BOX_HEIGHT_FRAC * cardWidth * 1.4f);
|
||||
int borderWidth = getBorderWidth(cardWidth);
|
||||
return 2*borderWidth + boxHeight;
|
||||
}
|
||||
|
||||
// The Draw Method
|
||||
|
|
Loading…
Reference in a new issue