mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Prevent being able to view information in detail pane for hidden cards
Prevent foil overlay appearing for hidden cards
This commit is contained in:
@@ -31,6 +31,7 @@ import javax.swing.border.EmptyBorder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.CardEdition;
|
||||
import forge.game.card.Card;
|
||||
@@ -38,6 +39,7 @@ import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.toolbox.FHtmlViewer;
|
||||
import forge.toolbox.FLabel;
|
||||
@@ -69,33 +71,33 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
|
||||
public CardDetailPanel() {
|
||||
super();
|
||||
this.setLayout(null);
|
||||
this.setOpaque(false);
|
||||
setLayout(null);
|
||||
setOpaque(false);
|
||||
|
||||
this.nameCostLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
|
||||
this.typeLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
|
||||
this.idLabel = new FLabel.Builder().fontAlign(SwingConstants.LEFT).tooltip("Card ID").build();
|
||||
this.powerToughnessLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
|
||||
this.setInfoLabel = new JLabel();
|
||||
this.setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
nameCostLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
|
||||
typeLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
|
||||
idLabel = new FLabel.Builder().fontAlign(SwingConstants.LEFT).tooltip("Card ID").build();
|
||||
powerToughnessLabel = new FLabel.Builder().fontAlign(SwingConstants.CENTER).build();
|
||||
setInfoLabel = new JLabel();
|
||||
setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
final Font font = new Font("Dialog", 0, 14);
|
||||
this.nameCostLabel.setFont(font);
|
||||
this.typeLabel.setFont(font);
|
||||
this.idLabel.setFont(font);
|
||||
this.powerToughnessLabel.setFont(font);
|
||||
nameCostLabel.setFont(font);
|
||||
typeLabel.setFont(font);
|
||||
idLabel.setFont(font);
|
||||
powerToughnessLabel.setFont(font);
|
||||
|
||||
this.cdArea = new FHtmlViewer();
|
||||
this.cdArea.setBorder(new EmptyBorder(2, 6, 2, 6));
|
||||
this.cdArea.setOpaque(false);
|
||||
this.scrArea = new FScrollPane(this.cdArea, false);
|
||||
cdArea = new FHtmlViewer();
|
||||
cdArea.setBorder(new EmptyBorder(2, 6, 2, 6));
|
||||
cdArea.setOpaque(false);
|
||||
scrArea = new FScrollPane(cdArea, false);
|
||||
|
||||
this.add(this.nameCostLabel);
|
||||
this.add(this.typeLabel);
|
||||
this.add(this.idLabel);
|
||||
this.add(this.powerToughnessLabel);
|
||||
this.add(this.setInfoLabel);
|
||||
this.add(this.scrArea);
|
||||
add(nameCostLabel);
|
||||
add(typeLabel);
|
||||
add(idLabel);
|
||||
add(powerToughnessLabel);
|
||||
add(setInfoLabel);
|
||||
add(scrArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,23 +107,23 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
int x = insets;
|
||||
int y = insets;
|
||||
int lineWidth = getWidth() - 2 * insets;
|
||||
int lineHeight = this.nameCostLabel.getPreferredSize().height;
|
||||
int lineHeight = nameCostLabel.getPreferredSize().height;
|
||||
int dy = lineHeight + 1;
|
||||
|
||||
this.nameCostLabel.setBounds(x, y, lineWidth, lineHeight);
|
||||
nameCostLabel.setBounds(x, y, lineWidth, lineHeight);
|
||||
y += dy;
|
||||
|
||||
this.typeLabel.setBounds(x, y, lineWidth, lineHeight);
|
||||
typeLabel.setBounds(x, y, lineWidth, lineHeight);
|
||||
y += dy;
|
||||
|
||||
this.idLabel.setBounds(x, y, this.idLabel.getAutoSizeWidth(), lineHeight);
|
||||
this.powerToughnessLabel.setBounds(x, y, lineWidth, lineHeight);
|
||||
idLabel.setBounds(x, y, idLabel.getAutoSizeWidth(), 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
|
||||
this.setInfoLabel.setBounds(x + lineWidth - setInfoWidth + 1, y + 1, setInfoWidth, lineHeight);
|
||||
setInfoLabel.setBounds(x + lineWidth - setInfoWidth + 1, y + 1, setInfoWidth, lineHeight);
|
||||
y += dy;
|
||||
|
||||
this.scrArea.setBounds(0, y, getWidth(), getHeight() - y);
|
||||
scrArea.setBounds(0, y, getWidth(), getHeight() - y);
|
||||
}
|
||||
|
||||
public final void setItem(final InventoryItemFromSet item) {
|
||||
@@ -130,7 +132,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
powerToughnessLabel.setVisible(false);
|
||||
idLabel.setText("");
|
||||
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();
|
||||
setInfoLabel.setText(set);
|
||||
@@ -144,10 +146,10 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
setInfoLabel.setToolTipText(edition.getName());
|
||||
}
|
||||
|
||||
this.setInfoLabel.setOpaque(true);
|
||||
this.setInfoLabel.setBackground(Color.BLACK);
|
||||
this.setInfoLabel.setForeground(Color.WHITE);
|
||||
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
|
||||
setInfoLabel.setOpaque(true);
|
||||
setInfoLabel.setBackground(Color.BLACK);
|
||||
setInfoLabel.setForeground(Color.WHITE);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@@ -159,56 +161,66 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
}
|
||||
|
||||
public final void setCard(final CardView card) {
|
||||
this.setCard(card, false);
|
||||
setCard(card, false);
|
||||
}
|
||||
|
||||
public final void setCard(final CardView card, final boolean isInAltState) {
|
||||
this.nameCostLabel.setText("");
|
||||
this.typeLabel.setVisible(true);
|
||||
this.typeLabel.setText("");
|
||||
this.powerToughnessLabel.setVisible(true);
|
||||
this.powerToughnessLabel.setText("");
|
||||
this.idLabel.setText("");
|
||||
this.setInfoLabel.setText("");
|
||||
this.setInfoLabel.setToolTipText("");
|
||||
this.setInfoLabel.setOpaque(false);
|
||||
this.setInfoLabel.setBorder(null);
|
||||
this.cdArea.setText("");
|
||||
nameCostLabel.setText("");
|
||||
typeLabel.setVisible(true);
|
||||
typeLabel.setText("");
|
||||
powerToughnessLabel.setVisible(true);
|
||||
powerToughnessLabel.setText("");
|
||||
idLabel.setText("");
|
||||
setInfoLabel.setText("");
|
||||
setInfoLabel.setToolTipText("");
|
||||
setInfoLabel.setOpaque(false);
|
||||
setInfoLabel.setBorder(null);
|
||||
cdArea.setText("");
|
||||
if (card == null) {
|
||||
this.updateBorder(null);
|
||||
updateBorder(null, false);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean canShow = MatchUtil.canCardBeShown(card);
|
||||
|
||||
final CardStateView state = card.getState(isInAltState);
|
||||
|
||||
if (state.getManaCost().isNoCost()) {
|
||||
this.nameCostLabel.setText(CardDetailUtil.formatCardName(state));
|
||||
} else {
|
||||
if (state.getManaCost().isNoCost() || !canShow) {
|
||||
nameCostLabel.setText(CardDetailUtil.formatCardName(state, canShow));
|
||||
}
|
||||
else {
|
||||
final String manaCost;
|
||||
if (card.isSplitCard() && card.getAlternateState() != null) {
|
||||
manaCost = card.getCurrentState().getManaCost() + " // " + card.getAlternateState().getManaCost();
|
||||
} else {
|
||||
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();
|
||||
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 (canShow) {
|
||||
CardEdition edition = FModel.getMagicDb().getEditions().get(set);
|
||||
if (null == edition) {
|
||||
setInfoLabel.setToolTipText(state.getRarity().name());
|
||||
setInfoLabel.setToolTipText(rarity.name());
|
||||
}
|
||||
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;
|
||||
switch(state.getRarity()) {
|
||||
switch (rarity) {
|
||||
case Uncommon:
|
||||
backColor = fromDetailColor(DetailColors.UNCOMMON);
|
||||
break;
|
||||
@@ -231,19 +243,19 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
}
|
||||
|
||||
Color foreColor = FSkin.getHighContrastColor(backColor);
|
||||
this.setInfoLabel.setBackground(backColor);
|
||||
this.setInfoLabel.setForeground(foreColor);
|
||||
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(foreColor));
|
||||
setInfoLabel.setBackground(backColor);
|
||||
setInfoLabel.setForeground(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
|
||||
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state), true));
|
||||
cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state, canShow), true));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
@@ -255,39 +267,39 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
|
||||
/** @return FLabel */
|
||||
public FLabel getNameCostLabel() {
|
||||
return this.nameCostLabel;
|
||||
return nameCostLabel;
|
||||
}
|
||||
|
||||
/** @return FLabel */
|
||||
public FLabel getTypeLabel() {
|
||||
return this.typeLabel;
|
||||
return typeLabel;
|
||||
}
|
||||
|
||||
/** @return FLabel */
|
||||
public FLabel getPowerToughnessLabel() {
|
||||
return this.powerToughnessLabel;
|
||||
return powerToughnessLabel;
|
||||
}
|
||||
|
||||
/** @return JLabel */
|
||||
public JLabel getSetInfoLabel() {
|
||||
return this.setInfoLabel;
|
||||
return setInfoLabel;
|
||||
}
|
||||
|
||||
/** @return FHtmlViewer */
|
||||
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
|
||||
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));
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card));
|
||||
this.setBorder(BorderFactory.createLineBorder(color, 2));
|
||||
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card, canShow));
|
||||
setBorder(BorderFactory.createLineBorder(color, 2));
|
||||
scrArea.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, color));
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
setForeground(FSkin.getHighContrastColor(getBackground()));
|
||||
}
|
||||
|
||||
@@ -293,10 +293,13 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
return;
|
||||
}
|
||||
|
||||
displayIconOverlay(g);
|
||||
boolean canShow = MatchUtil.canCardBeShown(card);
|
||||
displayIconOverlay(g, canShow);
|
||||
if (canShow) {
|
||||
drawFoilEffect(g, card, cardXOffset, cardYOffset,
|
||||
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) {
|
||||
if (isPreferenceEnabled(FPref.UI_OVERLAY_FOIL_EFFECT)) {
|
||||
@@ -367,8 +370,8 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
titleText.setVisible(isVisible);
|
||||
}
|
||||
|
||||
private void displayIconOverlay(final Graphics g) {
|
||||
if (showCardManaCostOverlay() && cardWidth < 200 && MatchUtil.canCardBeShown(card)) {
|
||||
private void displayIconOverlay(final Graphics g, final boolean canShow) {
|
||||
if (canShow && showCardManaCostOverlay() && cardWidth < 200) {
|
||||
final boolean showSplitMana = card.isSplitCard();
|
||||
if (!showSplitMana) {
|
||||
drawManaCost(g, card.getCurrentState().getManaCost(), 0);
|
||||
|
||||
@@ -20,6 +20,7 @@ import forge.card.CardRenderer.CardStackPosition;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CardView.CardStateView;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.screens.FScreen;
|
||||
|
||||
public class CardImageRenderer {
|
||||
@@ -68,8 +69,10 @@ public class CardImageRenderer {
|
||||
w -= 2 * blackBorderThickness;
|
||||
h -= 2 * blackBorderThickness;
|
||||
|
||||
boolean canShow = MatchUtil.canCardBeShown(card);
|
||||
|
||||
//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);
|
||||
Color color1 = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b);
|
||||
Color color2 = null;
|
||||
@@ -133,7 +136,7 @@ public class CardImageRenderer {
|
||||
}
|
||||
|
||||
//draw type line
|
||||
drawTypeLine(g, card, headerColor1, headerColor2, x, y, w, typeBoxHeight);
|
||||
drawTypeLine(g, card, canShow, headerColor1, headerColor2, x, y, w, typeBoxHeight);
|
||||
y += typeBoxHeight;
|
||||
|
||||
//draw text box
|
||||
@@ -206,7 +209,7 @@ public class CardImageRenderer {
|
||||
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) {
|
||||
g.fillRect(color1, x, y, w, h);
|
||||
}
|
||||
@@ -225,7 +228,7 @@ public class CardImageRenderer {
|
||||
|
||||
//draw type
|
||||
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
|
||||
|
||||
@@ -161,8 +161,10 @@ public class CardRenderer {
|
||||
w -= 2 * blackBorderThickness;
|
||||
h -= 2 * blackBorderThickness;
|
||||
|
||||
boolean canShow = MatchUtil.canCardBeShown(card);
|
||||
|
||||
//determine colors for borders
|
||||
List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card.getCurrentState());
|
||||
List<DetailColors> borderColors = CardDetailUtil.getBorderColors(card.getCurrentState(), canShow);
|
||||
DetailColors borderColor = borderColors.get(0);
|
||||
Color color1 = FSkinColor.fromRGB(borderColor.r, borderColor.g, borderColor.b);
|
||||
Color color2 = null;
|
||||
@@ -188,7 +190,7 @@ public class CardRenderer {
|
||||
//draw name/type box
|
||||
Color nameBoxColor1 = FSkinColor.tintColor(Color.WHITE, color1, 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 ptBoxHeight = 2 * PT_FONT.getCapHeight();
|
||||
@@ -197,12 +199,12 @@ public class CardRenderer {
|
||||
y += cardNameBoxHeight + innerBorderThickness;
|
||||
Color textBoxColor1 = FSkinColor.tintColor(Color.WHITE, color1, 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;
|
||||
Color ptColor1 = FSkinColor.tintColor(Color.WHITE, color1, 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) {
|
||||
@@ -350,7 +352,7 @@ public class CardRenderer {
|
||||
availableTypeWidth -= setWidth;
|
||||
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
|
||||
type += " (" + power + " / " + toughness + ")";
|
||||
}
|
||||
@@ -377,7 +379,7 @@ public class CardRenderer {
|
||||
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) {
|
||||
g.fillRect(color1, x, y, w, h);
|
||||
}
|
||||
@@ -394,6 +396,7 @@ public class CardRenderer {
|
||||
|
||||
//draw mana cost for card
|
||||
float manaCostWidth = 0;
|
||||
if (canShow) {
|
||||
ManaCost mainManaCost = state.getManaCost();
|
||||
if (card.isSplitCard() && card.hasAlternateState()) {
|
||||
//handle rendering both parts of split card
|
||||
@@ -407,24 +410,30 @@ public class CardRenderer {
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
//draw name for card
|
||||
x += 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
|
||||
y += h;
|
||||
h = 2 * TYPE_FONT.getCapHeight();
|
||||
|
||||
String set = state.getSetCode();
|
||||
CardRarity rarity = state.getRarity();
|
||||
if (!canShow) {
|
||||
set = CardEdition.UNKNOWN.getCode();
|
||||
rarity = CardRarity.Unknown;
|
||||
}
|
||||
if (!StringUtils.isEmpty(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
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -441,7 +450,7 @@ public class CardRenderer {
|
||||
//use text renderer to handle mana symbols and reminder text
|
||||
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) {
|
||||
g.fillRect(color1, x, y, w, h);
|
||||
}
|
||||
@@ -456,16 +465,16 @@ public class CardRenderer {
|
||||
y += padY;
|
||||
w -= 2 * padX;
|
||||
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();
|
||||
|
||||
String idText = CardDetailUtil.formatCardId(state);
|
||||
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; }
|
||||
|
||||
float padding = PT_FONT.getCapHeight() / 2;
|
||||
@@ -530,13 +539,13 @@ public class CardRenderer {
|
||||
w -= 2 * padding;
|
||||
h -= 2 * padding;
|
||||
|
||||
boolean canShow = MatchUtil.canCardBeShown(card);
|
||||
|
||||
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 = 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
|
||||
if (h <= NAME_COST_THRESHOLD && canShow) {
|
||||
if (showCardNameOverlay(card)) {
|
||||
|
||||
@@ -231,7 +231,7 @@ public class VStack extends FDropDown {
|
||||
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);
|
||||
foreColor = FSkinColor.getHighContrastColor(backColor);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
List<DetailColors> borderColors = new ArrayList<DetailColors>();
|
||||
@@ -162,16 +162,19 @@ public class CardDetailUtil {
|
||||
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();
|
||||
return StringUtils.isEmpty(name) ? "???" : name.trim();
|
||||
return StringUtils.isEmpty(name) || !canShow ? "???" : name.trim();
|
||||
}
|
||||
|
||||
public static String formatCardType(final CardStateView card) {
|
||||
return card.getType().toString();
|
||||
public static String formatCardType(final CardStateView card, final boolean canShow) {
|
||||
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();
|
||||
if (card.isCreature()) {
|
||||
ptText.append(card.getPower()).append(" / ").append(card.getToughness());
|
||||
@@ -196,7 +199,9 @@ public class CardDetailUtil {
|
||||
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 StringBuilder area = new StringBuilder();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user