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:
Mark Langen 2016-09-16 16:38:45 -06:00
parent 28c04e2009
commit 7feb237c06
2 changed files with 41 additions and 7 deletions

View file

@ -13,6 +13,9 @@ import javax.swing.JMenuItem;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
import mage.sets.avacynrestored.GuiseOfFire;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardRenderer;
/** /**
* *
@ -140,11 +143,15 @@ public class GUISizeHelper {
int otherZonesCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OTHER_ZONES_SIZE, 14); 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); otherZonesCardDimension = new Dimension(CARD_IMAGE_WIDTH * otherZonesCardSize / 42, CARD_IMAGE_HEIGHT * otherZonesCardSize / 42);
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false").equals("false")) {
otherZonesCardVerticalOffset = CardRenderer.getCardTopHeight(otherZonesCardDimension.width);
} else {
if (otherZonesCardSize > 29) { if (otherZonesCardSize > 29) {
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 8; otherZonesCardVerticalOffset = otherZonesCardDimension.height / 8;
} else { } else {
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 10; otherZonesCardVerticalOffset = otherZonesCardDimension.height / 10;
} }
}
int battlefieldCardMinSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_BATTLEFIELD_MIN_SIZE, 10); int battlefieldCardMinSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_BATTLEFIELD_MIN_SIZE, 10);
battlefieldCardMinDimension = new Dimension(CARD_IMAGE_WIDTH * battlefieldCardMinSize / 42, CARD_IMAGE_HEIGHT * battlefieldCardMinSize / 42); battlefieldCardMinDimension = new Dimension(CARD_IMAGE_WIDTH * battlefieldCardMinSize / 42, CARD_IMAGE_HEIGHT * battlefieldCardMinSize / 42);
@ -153,7 +160,11 @@ public class GUISizeHelper {
int editorCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_EDITOR_SIZE, 14); int editorCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_EDITOR_SIZE, 14);
editorCardDimension = new Dimension(CARD_IMAGE_WIDTH * editorCardSize / 42, CARD_IMAGE_HEIGHT * editorCardSize / 42); editorCardDimension = new Dimension(CARD_IMAGE_WIDTH * editorCardSize / 42, CARD_IMAGE_HEIGHT * editorCardSize / 42);
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; editorCardOffsetSize = 2 * PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OFFSET_SIZE, 14) - 10;
}
enlargedImageHeight = 25 * PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_ENLARGED_IMAGE_SIZE, 20); enlargedImageHeight = 25 * PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_ENLARGED_IMAGE_SIZE, 20);
} }

View file

@ -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 // Layout operation
// Calculate common layout metrics that will be used by several // Calculate common layout metrics that will be used by several
// of the operations in the template method. // of the operations in the template method.
@ -162,9 +168,26 @@ public abstract class CardRenderer {
CORNER_RADIUS_MIN, CORNER_RADIUS_MIN,
CORNER_RADIUS_FRAC * cardWidth); CORNER_RADIUS_FRAC * cardWidth);
borderWidth = (int) Math.max( borderWidth = getBorderWidth(cardWidth);
BORDER_WIDTH_MIN, }
BORDER_WIDTH_FRAC * 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 // The Draw Method