Prevent being able to view information in detail pane for hidden cards

Prevent foil overlay appearing for hidden cards
This commit is contained in:
drdev
2014-10-15 03:23:19 +00:00
parent f2289584fc
commit 5be609c09e
7 changed files with 159 additions and 127 deletions

View File

@@ -31,6 +31,7 @@ import javax.swing.border.EmptyBorder;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import forge.card.CardDetailUtil; import forge.card.CardDetailUtil;
import forge.card.CardRarity;
import forge.card.CardDetailUtil.DetailColors; import forge.card.CardDetailUtil.DetailColors;
import forge.card.CardEdition; import forge.card.CardEdition;
import forge.game.card.Card; import forge.game.card.Card;
@@ -38,6 +39,7 @@ import forge.game.card.CardView;
import forge.game.card.CardView.CardStateView; import forge.game.card.CardView.CardStateView;
import forge.item.IPaperCard; import forge.item.IPaperCard;
import forge.item.InventoryItemFromSet; import forge.item.InventoryItemFromSet;
import forge.match.MatchUtil;
import forge.model.FModel; import forge.model.FModel;
import forge.toolbox.FHtmlViewer; import forge.toolbox.FHtmlViewer;
import forge.toolbox.FLabel; import forge.toolbox.FLabel;
@@ -69,33 +71,33 @@ public class CardDetailPanel extends SkinnedPanel {
public CardDetailPanel() { public CardDetailPanel() {
super(); super();
this.setLayout(null); setLayout(null);
this.setOpaque(false); setOpaque(false);
this.nameCostLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); nameCostLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
this.typeLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); typeLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
this.idLabel = new FLabel.Builder().fontAlign(SwingConstants.LEFT).tooltip("Card ID").build(); idLabel = new FLabel.Builder().fontAlign(SwingConstants.LEFT).tooltip("Card ID").build();
this.powerToughnessLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build(); powerToughnessLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
this.setInfoLabel = new JLabel(); setInfoLabel = new JLabel();
this.setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER); setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER);
final Font font = new Font("Dialog", 0, 14); final Font font = new Font("Dialog", 0, 14);
this.nameCostLabel.setFont(font); nameCostLabel.setFont(font);
this.typeLabel.setFont(font); typeLabel.setFont(font);
this.idLabel.setFont(font); idLabel.setFont(font);
this.powerToughnessLabel.setFont(font); powerToughnessLabel.setFont(font);
this.cdArea = new FHtmlViewer(); cdArea = new FHtmlViewer();
this.cdArea.setBorder(new EmptyBorder(2, 6, 2, 6)); cdArea.setBorder(new EmptyBorder(2, 6, 2, 6));
this.cdArea.setOpaque(false); cdArea.setOpaque(false);
this.scrArea = new FScrollPane(this.cdArea, false); scrArea = new FScrollPane(cdArea, false);
this.add(this.nameCostLabel); add(nameCostLabel);
this.add(this.typeLabel); add(typeLabel);
this.add(this.idLabel); add(idLabel);
this.add(this.powerToughnessLabel); add(powerToughnessLabel);
this.add(this.setInfoLabel); add(setInfoLabel);
this.add(this.scrArea); add(scrArea);
} }
@Override @Override
@@ -105,23 +107,23 @@ public class CardDetailPanel extends SkinnedPanel {
int x = insets; int x = insets;
int y = insets; int y = insets;
int lineWidth = getWidth() - 2 * insets; int lineWidth = getWidth() - 2 * insets;
int lineHeight = this.nameCostLabel.getPreferredSize().height; int lineHeight = nameCostLabel.getPreferredSize().height;
int dy = lineHeight + 1; int dy = lineHeight + 1;
this.nameCostLabel.setBounds(x, y, lineWidth, lineHeight); nameCostLabel.setBounds(x, y, lineWidth, lineHeight);
y += dy; y += dy;
this.typeLabel.setBounds(x, y, lineWidth, lineHeight); typeLabel.setBounds(x, y, lineWidth, lineHeight);
y += dy; y += dy;
this.idLabel.setBounds(x, y, this.idLabel.getAutoSizeWidth(), lineHeight); idLabel.setBounds(x, y, idLabel.getAutoSizeWidth(), lineHeight);
this.powerToughnessLabel.setBounds(x, y, lineWidth, lineHeight); powerToughnessLabel.setBounds(x, y, lineWidth, lineHeight);
//+1 to x,y so set info label right up against border and the baseline matches ID and P/T //+1 to x,y so set info label right up against border and the baseline matches ID and P/T
this.setInfoLabel.setBounds(x + lineWidth - setInfoWidth + 1, y + 1, setInfoWidth, lineHeight); setInfoLabel.setBounds(x + lineWidth - setInfoWidth + 1, y + 1, setInfoWidth, lineHeight);
y += dy; y += dy;
this.scrArea.setBounds(0, y, getWidth(), getHeight() - y); scrArea.setBounds(0, y, getWidth(), getHeight() - y);
} }
public final void setItem(final InventoryItemFromSet item) { public final void setItem(final InventoryItemFromSet item) {
@@ -130,7 +132,7 @@ public class CardDetailPanel extends SkinnedPanel {
powerToughnessLabel.setVisible(false); powerToughnessLabel.setVisible(false);
idLabel.setText(""); idLabel.setText("");
cdArea.setText(CardDetailUtil.getItemDescription(item)); cdArea.setText(CardDetailUtil.getItemDescription(item));
this.updateBorder(item instanceof IPaperCard ? Card.getCardForUi((IPaperCard)item).getView().getCurrentState() : null); updateBorder(item instanceof IPaperCard ? Card.getCardForUi((IPaperCard)item).getView().getCurrentState() : null, true);
String set = item.getEdition(); String set = item.getEdition();
setInfoLabel.setText(set); setInfoLabel.setText(set);
@@ -144,10 +146,10 @@ public class CardDetailPanel extends SkinnedPanel {
setInfoLabel.setToolTipText(edition.getName()); setInfoLabel.setToolTipText(edition.getName());
} }
this.setInfoLabel.setOpaque(true); setInfoLabel.setOpaque(true);
this.setInfoLabel.setBackground(Color.BLACK); setInfoLabel.setBackground(Color.BLACK);
this.setInfoLabel.setForeground(Color.WHITE); setInfoLabel.setForeground(Color.WHITE);
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE)); setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
} }
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@@ -159,56 +161,66 @@ public class CardDetailPanel extends SkinnedPanel {
} }
public final void setCard(final CardView card) { public final void setCard(final CardView card) {
this.setCard(card, false); setCard(card, false);
} }
public final void setCard(final CardView card, final boolean isInAltState) { public final void setCard(final CardView card, final boolean isInAltState) {
this.nameCostLabel.setText(""); nameCostLabel.setText("");
this.typeLabel.setVisible(true); typeLabel.setVisible(true);
this.typeLabel.setText(""); typeLabel.setText("");
this.powerToughnessLabel.setVisible(true); powerToughnessLabel.setVisible(true);
this.powerToughnessLabel.setText(""); powerToughnessLabel.setText("");
this.idLabel.setText(""); idLabel.setText("");
this.setInfoLabel.setText(""); setInfoLabel.setText("");
this.setInfoLabel.setToolTipText(""); setInfoLabel.setToolTipText("");
this.setInfoLabel.setOpaque(false); setInfoLabel.setOpaque(false);
this.setInfoLabel.setBorder(null); setInfoLabel.setBorder(null);
this.cdArea.setText(""); cdArea.setText("");
if (card == null) { if (card == null) {
this.updateBorder(null); updateBorder(null, false);
return; return;
} }
boolean canShow = MatchUtil.canCardBeShown(card);
final CardStateView state = card.getState(isInAltState); final CardStateView state = card.getState(isInAltState);
if (state.getManaCost().isNoCost()) { if (state.getManaCost().isNoCost() || !canShow) {
this.nameCostLabel.setText(CardDetailUtil.formatCardName(state)); nameCostLabel.setText(CardDetailUtil.formatCardName(state, canShow));
} else { }
else {
final String manaCost; final String manaCost;
if (card.isSplitCard() && card.getAlternateState() != null) { if (card.isSplitCard() && card.getAlternateState() != null) {
manaCost = card.getCurrentState().getManaCost() + " // " + card.getAlternateState().getManaCost(); manaCost = card.getCurrentState().getManaCost() + " // " + card.getAlternateState().getManaCost();
} else { } else {
manaCost = state.getManaCost().toString(); manaCost = state.getManaCost().toString();
} }
this.nameCostLabel.setText(FSkin.encodeSymbols(CardDetailUtil.formatCardName(state) + " - " + manaCost, true)); nameCostLabel.setText(FSkin.encodeSymbols(CardDetailUtil.formatCardName(state, canShow) + " - " + manaCost, true));
} }
this.typeLabel.setText(CardDetailUtil.formatCardType(state)); typeLabel.setText(CardDetailUtil.formatCardType(state, canShow));
String set = state.getSetCode(); String set = state.getSetCode();
this.setInfoLabel.setText(set); CardRarity rarity = state.getRarity();
if (!canShow) {
set = CardEdition.UNKNOWN.getCode();
rarity = CardRarity.Unknown;
}
setInfoLabel.setText(set);
if (null != set && !set.isEmpty()) { if (null != set && !set.isEmpty()) {
if (canShow) {
CardEdition edition = FModel.getMagicDb().getEditions().get(set); CardEdition edition = FModel.getMagicDb().getEditions().get(set);
if (null == edition) { if (null == edition) {
setInfoLabel.setToolTipText(state.getRarity().name()); setInfoLabel.setToolTipText(rarity.name());
} }
else { else {
setInfoLabel.setToolTipText(String.format("%s (%s)", edition.getName(), state.getRarity().name())); setInfoLabel.setToolTipText(String.format("%s (%s)", edition.getName(), rarity.name()));
}
} }
this.setInfoLabel.setOpaque(true); setInfoLabel.setOpaque(true);
Color backColor; Color backColor;
switch(state.getRarity()) { switch (rarity) {
case Uncommon: case Uncommon:
backColor = fromDetailColor(DetailColors.UNCOMMON); backColor = fromDetailColor(DetailColors.UNCOMMON);
break; break;
@@ -231,19 +243,19 @@ public class CardDetailPanel extends SkinnedPanel {
} }
Color foreColor = FSkin.getHighContrastColor(backColor); Color foreColor = FSkin.getHighContrastColor(backColor);
this.setInfoLabel.setBackground(backColor); setInfoLabel.setBackground(backColor);
this.setInfoLabel.setForeground(foreColor); setInfoLabel.setForeground(foreColor);
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(foreColor)); setInfoLabel.setBorder(BorderFactory.createLineBorder(foreColor));
} }
this.updateBorder(state); updateBorder(state, canShow);
this.powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(state)); powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(state, canShow));
this.idLabel.setText(CardDetailUtil.formatCardId(state)); idLabel.setText(CardDetailUtil.formatCardId(state));
// fill the card text // fill the card text
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state), true)); cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state, canShow), true));
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
@@ -255,39 +267,39 @@ public class CardDetailPanel extends SkinnedPanel {
/** @return FLabel */ /** @return FLabel */
public FLabel getNameCostLabel() { public FLabel getNameCostLabel() {
return this.nameCostLabel; return nameCostLabel;
} }
/** @return FLabel */ /** @return FLabel */
public FLabel getTypeLabel() { public FLabel getTypeLabel() {
return this.typeLabel; return typeLabel;
} }
/** @return FLabel */ /** @return FLabel */
public FLabel getPowerToughnessLabel() { public FLabel getPowerToughnessLabel() {
return this.powerToughnessLabel; return powerToughnessLabel;
} }
/** @return JLabel */ /** @return JLabel */
public JLabel getSetInfoLabel() { public JLabel getSetInfoLabel() {
return this.setInfoLabel; return setInfoLabel;
} }
/** @return FHtmlViewer */ /** @return FHtmlViewer */
public FHtmlViewer getCDArea() { public FHtmlViewer getCDArea() {
return this.cdArea; return cdArea;
} }
private void updateBorder(final CardStateView card) { private void updateBorder(final CardStateView card, final boolean canShow) {
// color info // color info
if (card == null) { if (card == null) {
this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
scrArea.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); scrArea.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
return; return;
} }
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card)); Color color = fromDetailColor(CardDetailUtil.getBorderColor(card, canShow));
this.setBorder(BorderFactory.createLineBorder(color, 2)); setBorder(BorderFactory.createLineBorder(color, 2));
scrArea.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, color)); scrArea.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, color));
} }

View File

@@ -196,7 +196,7 @@ public enum VStack implements IVDoc<CStack> {
}); });
} }
final DetailColors color = CardDetailUtil.getBorderColor(item.getSourceCard().getCurrentState()); final DetailColors color = CardDetailUtil.getBorderColor(item.getSourceCard().getCurrentState(), true);
setBackground(new Color(color.r, color.g, color.b)); setBackground(new Color(color.r, color.g, color.b));
setForeground(FSkin.getHighContrastColor(getBackground())); setForeground(FSkin.getHighContrastColor(getBackground()));
} }

View File

@@ -293,10 +293,13 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
return; return;
} }
displayIconOverlay(g); boolean canShow = MatchUtil.canCardBeShown(card);
displayIconOverlay(g, canShow);
if (canShow) {
drawFoilEffect(g, card, cardXOffset, cardYOffset, drawFoilEffect(g, card, cardXOffset, cardYOffset,
cardWidth, cardHeight, Math.round(cardWidth * BLACK_BORDER_SIZE)); cardWidth, cardHeight, Math.round(cardWidth * BLACK_BORDER_SIZE));
} }
}
public static void drawFoilEffect(final Graphics g, final CardView card2, final int x, final int y, final int width, final int height, final int borderSize) { public static void drawFoilEffect(final Graphics g, final CardView card2, final int x, final int y, final int width, final int height, final int borderSize) {
if (isPreferenceEnabled(FPref.UI_OVERLAY_FOIL_EFFECT)) { if (isPreferenceEnabled(FPref.UI_OVERLAY_FOIL_EFFECT)) {
@@ -367,8 +370,8 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
titleText.setVisible(isVisible); titleText.setVisible(isVisible);
} }
private void displayIconOverlay(final Graphics g) { private void displayIconOverlay(final Graphics g, final boolean canShow) {
if (showCardManaCostOverlay() && cardWidth < 200 && MatchUtil.canCardBeShown(card)) { if (canShow && showCardManaCostOverlay() && cardWidth < 200) {
final boolean showSplitMana = card.isSplitCard(); final boolean showSplitMana = card.isSplitCard();
if (!showSplitMana) { if (!showSplitMana) {
drawManaCost(g, card.getCurrentState().getManaCost(), 0); drawManaCost(g, card.getCurrentState().getManaCost(), 0);

View File

@@ -20,6 +20,7 @@ import forge.card.CardRenderer.CardStackPosition;
import forge.card.mana.ManaCost; import forge.card.mana.ManaCost;
import forge.game.card.CardView; import forge.game.card.CardView;
import forge.game.card.CardView.CardStateView; import forge.game.card.CardView.CardStateView;
import forge.match.MatchUtil;
import forge.screens.FScreen; import forge.screens.FScreen;
public class CardImageRenderer { public class CardImageRenderer {
@@ -68,8 +69,10 @@ public class CardImageRenderer {
w -= 2 * blackBorderThickness; w -= 2 * blackBorderThickness;
h -= 2 * blackBorderThickness; h -= 2 * blackBorderThickness;
boolean canShow = MatchUtil.canCardBeShown(card);
//determine colors for borders //determine colors for borders
final List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card.getCurrentState()); final List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card.getCurrentState(), canShow);
DetailColors borderColor = borderColors.get(0); DetailColors borderColor = borderColors.get(0);
Color color1 = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b); Color color1 = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b);
Color color2 = null; Color color2 = null;
@@ -133,7 +136,7 @@ public class CardImageRenderer {
} }
//draw type line //draw type line
drawTypeLine(g, card, headerColor1, headerColor2, x, y, w, typeBoxHeight); drawTypeLine(g, card, canShow, headerColor1, headerColor2, x, y, w, typeBoxHeight);
y += typeBoxHeight; y += typeBoxHeight;
//draw text box //draw text box
@@ -206,7 +209,7 @@ public class CardImageRenderer {
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h); g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
} }
private static void drawTypeLine(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) { private static void drawTypeLine(Graphics g, CardView card, boolean canShow, Color color1, Color color2, float x, float y, float w, float h) {
if (color2 == null) { if (color2 == null) {
g.fillRect(color1, x, y, w, h); g.fillRect(color1, x, y, w, h);
} }
@@ -225,7 +228,7 @@ public class CardImageRenderer {
//draw type //draw type
x += padding; x += padding;
g.drawText(CardDetailUtil.formatCardType(card.getCurrentState()), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true); g.drawText(CardDetailUtil.formatCardType(card.getCurrentState(), canShow), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true);
} }
//use text renderer to handle mana symbols and reminder text //use text renderer to handle mana symbols and reminder text

View File

@@ -161,8 +161,10 @@ public class CardRenderer {
w -= 2 * blackBorderThickness; w -= 2 * blackBorderThickness;
h -= 2 * blackBorderThickness; h -= 2 * blackBorderThickness;
boolean canShow = MatchUtil.canCardBeShown(card);
//determine colors for borders //determine colors for borders
List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card.getCurrentState()); List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card.getCurrentState(), canShow);
DetailColors borderColor = borderColors.get(0); DetailColors borderColor = borderColors.get(0);
Color color1 = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b); Color color1 = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b);
Color color2 = null; Color color2 = null;
@@ -188,7 +190,7 @@ public class CardRenderer {
//draw name/type box //draw name/type box
Color nameBoxColor1 = FSkinColor.tintColor(Color.WHITE, color1, NAME_BOX_TINT); Color nameBoxColor1 = FSkinColor.tintColor(Color.WHITE, color1, NAME_BOX_TINT);
Color nameBoxColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, NAME_BOX_TINT); Color nameBoxColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, NAME_BOX_TINT);
drawCardNameBox(g, card, nameBoxColor1, nameBoxColor2, x, y, w, cardNameBoxHeight); drawCardNameBox(g, card, canShow, nameBoxColor1, nameBoxColor2, x, y, w, cardNameBoxHeight);
float innerBorderThickness = outerBorderThickness / 2; float innerBorderThickness = outerBorderThickness / 2;
float ptBoxHeight = 2 * PT_FONT.getCapHeight(); float ptBoxHeight = 2 * PT_FONT.getCapHeight();
@@ -197,12 +199,12 @@ public class CardRenderer {
y += cardNameBoxHeight + innerBorderThickness; y += cardNameBoxHeight + innerBorderThickness;
Color textBoxColor1 = FSkinColor.tintColor(Color.WHITE, color1, TEXT_BOX_TINT); Color textBoxColor1 = FSkinColor.tintColor(Color.WHITE, color1, TEXT_BOX_TINT);
Color textBoxColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, TEXT_BOX_TINT); Color textBoxColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, TEXT_BOX_TINT);
drawCardTextBox(g, card, textBoxColor1, textBoxColor2, x, y, w, textBoxHeight); drawCardTextBox(g, card, canShow, textBoxColor1, textBoxColor2, x, y, w, textBoxHeight);
y += textBoxHeight + innerBorderThickness; y += textBoxHeight + innerBorderThickness;
Color ptColor1 = FSkinColor.tintColor(Color.WHITE, color1, PT_BOX_TINT); Color ptColor1 = FSkinColor.tintColor(Color.WHITE, color1, PT_BOX_TINT);
Color ptColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, PT_BOX_TINT); Color ptColor2 = color2 == null ? null : FSkinColor.tintColor(Color.WHITE, color2, PT_BOX_TINT);
drawCardIdAndPtBox(g, card, idForeColor, ptColor1, ptColor2, x, y, w, ptBoxHeight); drawCardIdAndPtBox(g, card, canShow, idForeColor, ptColor1, ptColor2, x, y, w, ptBoxHeight);
} }
public static float getCardListItemHeight(boolean compactMode) { public static float getCardListItemHeight(boolean compactMode) {
@@ -350,7 +352,7 @@ public class CardRenderer {
availableTypeWidth -= setWidth; availableTypeWidth -= setWidth;
drawSetLabel(g, typeFont, set, rarity, x + availableTypeWidth + SET_BOX_MARGIN, y - SET_BOX_MARGIN, setWidth, lineHeight + 2 * SET_BOX_MARGIN); drawSetLabel(g, typeFont, set, rarity, x + availableTypeWidth + SET_BOX_MARGIN, y - SET_BOX_MARGIN, setWidth, lineHeight + 2 * SET_BOX_MARGIN);
} }
String type = CardDetailUtil.formatCardType(card.getCurrentState()); String type = CardDetailUtil.formatCardType(card.getCurrentState(), true);
if (card.getCurrentState().isCreature()) { //include P/T or Loyalty at end of type if (card.getCurrentState().isCreature()) { //include P/T or Loyalty at end of type
type += " (" + power + " / " + toughness + ")"; type += " (" + power + " / " + toughness + ")";
} }
@@ -377,7 +379,7 @@ public class CardRenderer {
return false; return false;
} }
private static void drawCardNameBox(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) { private static void drawCardNameBox(Graphics g, CardView card, boolean canShow, Color color1, Color color2, float x, float y, float w, float h) {
if (color2 == null) { if (color2 == null) {
g.fillRect(color1, x, y, w, h); g.fillRect(color1, x, y, w, h);
} }
@@ -394,6 +396,7 @@ public class CardRenderer {
//draw mana cost for card //draw mana cost for card
float manaCostWidth = 0; float manaCostWidth = 0;
if (canShow) {
ManaCost mainManaCost = state.getManaCost(); ManaCost mainManaCost = state.getManaCost();
if (card.isSplitCard() && card.hasAlternateState()) { if (card.isSplitCard() && card.hasAlternateState()) {
//handle rendering both parts of split card //handle rendering both parts of split card
@@ -407,24 +410,30 @@ public class CardRenderer {
} }
manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE) + MANA_COST_PADDING; manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE) + MANA_COST_PADDING;
CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE); CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
}
//draw name for card //draw name for card
x += padding; x += padding;
w -= 2 * padding; w -= 2 * padding;
g.drawText(state.getName(), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, HAlignment.LEFT, true); g.drawText(CardDetailUtil.formatCardName(state, canShow), NAME_FONT, Color.BLACK, x, y, w - manaCostWidth - padding, h, false, HAlignment.LEFT, true);
//draw type and set label for card //draw type and set label for card
y += h; y += h;
h = 2 * TYPE_FONT.getCapHeight(); h = 2 * TYPE_FONT.getCapHeight();
String set = state.getSetCode(); String set = state.getSetCode();
CardRarity rarity = state.getRarity();
if (!canShow) {
set = CardEdition.UNKNOWN.getCode();
rarity = CardRarity.Unknown;
}
if (!StringUtils.isEmpty(set)) { if (!StringUtils.isEmpty(set)) {
float setWidth = getSetWidth(SET_FONT, set); float setWidth = getSetWidth(SET_FONT, set);
drawSetLabel(g, SET_FONT, set, state.getRarity(), x + w + padding - setWidth - SET_BOX_MARGIN, y + SET_BOX_MARGIN, setWidth, h - SET_BOX_MARGIN); drawSetLabel(g, SET_FONT, set, rarity, x + w + padding - setWidth - SET_BOX_MARGIN, y + SET_BOX_MARGIN, setWidth, h - SET_BOX_MARGIN);
w -= setWidth; //reduce available width for type w -= setWidth; //reduce available width for type
} }
g.drawText(CardDetailUtil.formatCardType(state), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true); g.drawText(CardDetailUtil.formatCardType(state, canShow), TYPE_FONT, Color.BLACK, x, y, w, h, false, HAlignment.LEFT, true);
} }
public static float getSetWidth(FSkinFont font, String set) { public static float getSetWidth(FSkinFont font, String set) {
@@ -441,7 +450,7 @@ public class CardRenderer {
//use text renderer to handle mana symbols and reminder text //use text renderer to handle mana symbols and reminder text
private static final TextRenderer cardTextRenderer = new TextRenderer(true); private static final TextRenderer cardTextRenderer = new TextRenderer(true);
private static void drawCardTextBox(Graphics g, CardView card, Color color1, Color color2, float x, float y, float w, float h) { private static void drawCardTextBox(Graphics g, CardView card, boolean canShow, Color color1, Color color2, float x, float y, float w, float h) {
if (color2 == null) { if (color2 == null) {
g.fillRect(color1, x, y, w, h); g.fillRect(color1, x, y, w, h);
} }
@@ -456,16 +465,16 @@ public class CardRenderer {
y += padY; y += padY;
w -= 2 * padX; w -= 2 * padX;
h -= 2 * padY; h -= 2 * padY;
cardTextRenderer.drawText(g, CardDetailUtil.composeCardText(card.getCurrentState()), TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, false); cardTextRenderer.drawText(g, CardDetailUtil.composeCardText(card.getCurrentState(), canShow), TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, false);
} }
private static void drawCardIdAndPtBox(Graphics g, CardView card, Color idForeColor, Color color1, Color color2, float x, float y, float w, float h) { private static void drawCardIdAndPtBox(Graphics g, CardView card, boolean canShow, Color idForeColor, Color color1, Color color2, float x, float y, float w, float h) {
final CardStateView state = card.getCurrentState(); final CardStateView state = card.getCurrentState();
String idText = CardDetailUtil.formatCardId(state); String idText = CardDetailUtil.formatCardId(state);
g.drawText(idText, ID_FONT, idForeColor, x, y + ID_FONT.getCapHeight() / 2, w, h, false, HAlignment.LEFT, false); g.drawText(idText, ID_FONT, idForeColor, x, y + ID_FONT.getCapHeight() / 2, w, h, false, HAlignment.LEFT, false);
String ptText = CardDetailUtil.formatPowerToughness(state); String ptText = CardDetailUtil.formatPowerToughness(state, canShow);
if (StringUtils.isEmpty(ptText)) { return; } if (StringUtils.isEmpty(ptText)) { return; }
float padding = PT_FONT.getCapHeight() / 2; float padding = PT_FONT.getCapHeight() / 2;
@@ -530,13 +539,13 @@ public class CardRenderer {
w -= 2 * padding; w -= 2 * padding;
h -= 2 * padding; h -= 2 * padding;
boolean canShow = MatchUtil.canCardBeShown(card);
CardStateView details = card.getCurrentState(); CardStateView details = card.getCurrentState();
DetailColors borderColor = CardDetailUtil.getBorderColor(details); DetailColors borderColor = CardDetailUtil.getBorderColor(details, canShow);
Color color = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b); Color color = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b);
color = FSkinColor.tintColor(Color.WHITE, color, CardRenderer.PT_BOX_TINT); color = FSkinColor.tintColor(Color.WHITE, color, CardRenderer.PT_BOX_TINT);
boolean canShow = MatchUtil.canCardBeShown(card);
//draw name and mana cost overlays if card is small or default card image being used //draw name and mana cost overlays if card is small or default card image being used
if (h <= NAME_COST_THRESHOLD && canShow) { if (h <= NAME_COST_THRESHOLD && canShow) {
if (showCardNameOverlay(card)) { if (showCardNameOverlay(card)) {

View File

@@ -231,7 +231,7 @@ public class VStack extends FDropDown {
text = "(OPTIONAL) " + text; text = "(OPTIONAL) " + text;
} }
DetailColors color = CardDetailUtil.getBorderColor(card.getCurrentState()); DetailColors color = CardDetailUtil.getBorderColor(card.getCurrentState(), true);
backColor = FSkinColor.fromRGB(color.r, color.g, color.b); backColor = FSkinColor.fromRGB(color.r, color.g, color.b);
foreColor = FSkinColor.getHighContrastColor(backColor); foreColor = FSkinColor.getHighContrastColor(backColor);

View File

@@ -50,20 +50,20 @@ public class CardDetailUtil {
} }
} }
public static DetailColors getBorderColor(final CardStateView card) { public static DetailColors getBorderColor(final CardStateView card, final boolean canShow) {
if (card == null) { if (card == null) {
return getBorderColors(null, false, false, false).iterator().next(); return getBorderColors(null, false, false, false).iterator().next();
} }
return getBorderColors(card.getColors(), card.isLand(), MatchUtil.canCardBeShown(card.getCard()), false).iterator().next(); return getBorderColors(card.getColors(), card.isLand(), canShow, false).iterator().next();
} }
public static DetailColors getBorderColor(final ColorSet cardColors, final boolean isLand, boolean canShow) { public static DetailColors getBorderColor(final ColorSet cardColors, final boolean isLand, boolean canShow) {
return getBorderColors(cardColors, isLand, canShow, false).get(0); return getBorderColors(cardColors, isLand, canShow, false).get(0);
} }
public static List<DetailColors> getBorderColors(final CardStateView card) { public static List<DetailColors> getBorderColors(final CardStateView card, final boolean canShow) {
if (card == null) { if (card == null) {
return getBorderColors(null, false, false, true); return getBorderColors(null, false, false, true);
} }
return getBorderColors(card.getColors(), card.isLand(), MatchUtil.canCardBeShown(card.getCard()), true); return getBorderColors(card.getColors(), card.isLand(), canShow, true);
} }
private static List<DetailColors> getBorderColors(final ColorSet cardColors, final boolean isLand, boolean canShow, boolean supportMultiple) { private static List<DetailColors> getBorderColors(final ColorSet cardColors, final boolean isLand, boolean canShow, boolean supportMultiple) {
List<DetailColors> borderColors = new ArrayList<DetailColors>(); List<DetailColors> borderColors = new ArrayList<DetailColors>();
@@ -162,16 +162,19 @@ public class CardDetailUtil {
return item.getName(); return item.getName();
} }
public static String formatCardName(final CardStateView card) { public static String formatCardName(final CardStateView card, final boolean canShow) {
final String name = card.getName(); final String name = card.getName();
return StringUtils.isEmpty(name) ? "???" : name.trim(); return StringUtils.isEmpty(name) || !canShow ? "???" : name.trim();
} }
public static String formatCardType(final CardStateView card) { public static String formatCardType(final CardStateView card, final boolean canShow) {
return card.getType().toString(); return canShow ? card.getType().toString() : (card.getState() == CardStateName.FaceDown ? "Creature" : "---");
} }
public static String formatPowerToughness(final CardStateView card) { public static String formatPowerToughness(final CardStateView card, final boolean canShow) {
if (!canShow && card.getState() != CardStateName.FaceDown) {
return "";
}
StringBuilder ptText = new StringBuilder(); StringBuilder ptText = new StringBuilder();
if (card.isCreature()) { if (card.isCreature()) {
ptText.append(card.getPower()).append(" / ").append(card.getToughness()); ptText.append(card.getPower()).append(" / ").append(card.getToughness());
@@ -196,7 +199,9 @@ public class CardDetailUtil {
return id > 0 ? "[" + id + "]" : ""; return id > 0 ? "[" + id + "]" : "";
} }
public static String composeCardText(final CardStateView state) { public static String composeCardText(final CardStateView state, final boolean canShow) {
if (!canShow) { return ""; }
final CardView card = state.getCard(); final CardView card = state.getCard();
final StringBuilder area = new StringBuilder(); final StringBuilder area = new StringBuilder();