Fix card detail text

This commit is contained in:
Anthony Calosa
2021-01-14 10:11:13 +08:00
parent 465abe2a43
commit 52f5120a1e
3 changed files with 260 additions and 262 deletions

View File

@@ -256,7 +256,7 @@ public class CardDetailPanel extends SkinnedPanel {
idLabel.setText(mayView ? CardDetailUtil.formatCardId(state) : ""); idLabel.setText(mayView ? CardDetailUtil.formatCardId(state) : "");
// fill the card text // fill the card text
cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText( card.isSplitCard() && !isInAltState ? card.getLeftSplitState() : state, gameView, mayView), true)); cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText( state, gameView, mayView), true));
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override public void run() { @Override public void run() {

View File

@@ -459,7 +459,7 @@ public class CardImageRenderer {
y += cardNameBoxHeight + innerBorderThickness; y += cardNameBoxHeight + innerBorderThickness;
Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT); Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT);
drawDetailsTextBox(g, card.isSplitCard() && !altState ? card.getLeftSplitState() : state, gameView, canShow, textBoxColors, x, y, w, textBoxHeight); drawDetailsTextBox(g, state, gameView, canShow, textBoxColors, x, y, w, textBoxHeight);
y += textBoxHeight + innerBorderThickness; y += textBoxHeight + innerBorderThickness;
Color[] ptColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.PT_BOX_TINT); Color[] ptColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.PT_BOX_TINT);

View File

@@ -641,14 +641,66 @@ public class CardRenderer {
} }
//Ability Icons //Ability Icons
boolean onbattlefield = ZoneType.Battlefield.equals(card.getZone()); boolean onbattlefield = ZoneType.Battlefield.equals(card.getZone());
float abiY = cy;
float abiX = cx + ((cw*2)/2.3f);
float abiScale = cw / 5.5f;
float abiSpace = cw / 5.7f;
float abiCount = 0;
if (unselectable){ g.setAlphaComposite(0.6f); } if (unselectable){ g.setAlphaComposite(0.6f); }
if (onbattlefield && onTop && showAbilityIcons(card)) { if (onbattlefield && onTop && showAbilityIcons(card)) {
drawAbilityIcons(g,card, cx, cy, cw, cx + ((cw*2)/2.3f), cy, cw / 5.5f, cw / 5.7f);
} else if (canShow && !onbattlefield && showAbilityIcons(card)) {
//draw indicator for flash or can be cast at instant speed, enabled if show ability icons is enabled
String keywordKey = card.getCurrentState().getKeywordKey();
String abilityText = card.getCurrentState().getAbilityText();
if ((keywordKey.indexOf("Flash") != -1)
|| ((abilityText.indexOf("May be played by") != -1)
&& (abilityText.indexOf("and as though it has flash") != -1))){
if (keywordKey.indexOf("Flashback") == -1)
CardFaceSymbols.drawSymbol("flash", g, cx + ((cw*2)/2.3f), cy, cw / 5.5f, cw / 5.5f);
}
}
//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)) {
float multiplier;
switch (Forge.extrawide) {
case "default":
multiplier = 0.145f; //good for tablets with 16:10 or similar
break;
case "wide":
multiplier = 0.150f;
break;
case "extrawide":
multiplier = 0.155f; //good for tall phones with 21:9 or similar
break;
default:
multiplier = 0.150f;
break;
}
g.drawOutlinedText(CardTranslation.getTranslatedName(details.getName()), FSkinFont.forHeight(h * multiplier), Color.WHITE, Color.BLACK, x + padding -1f, y + padding, w - 2 * padding, h * 0.4f, true, Align.left, false);
}
if (showCardManaCostOverlay(card)) {
float manaSymbolSize = w / 4.5f;
if (card.isSplitCard() && card.hasAlternateState()) {
if (!card.isFaceDown()) { // no need to draw mana symbols on face down split cards (e.g. manifested)
float dy = manaSymbolSize / 2 + Utils.scale(5);
PaperCard pc = StaticData.instance().getCommonCards().getCard(card.getName());
if (Card.getCardForUi(pc).hasKeyword(Keyword.AFTERMATH)){
dy *= -1; // flip card costs for Aftermath cards
}
drawManaCost(g, card.getRightSplitState().getManaCost(), x - padding, y - dy, w + 2 * padding, h, manaSymbolSize);
drawManaCost(g, card.getLeftSplitState().getManaCost(), x - padding, y + dy, w + 2 * padding, h, manaSymbolSize);
}
}
else {
drawManaCost(g, showAltState ? card.getAlternateState().getManaCost() : card.getCurrentState().getManaCost(), x - padding, y, w + 2 * padding, h, manaSymbolSize);
}
}
}
//reset alpha
g.setAlphaComposite(oldAlpha);
}
public static void drawAbilityIcons(Graphics g, CardView card, float cx, float cy, float cw, float abiX, float abiY, float abiScale, float abiSpace) {
float abiCount = 0;
if (card.isToken()){ if (card.isToken()){
CardFaceSymbols.drawSymbol("token", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("token", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
@@ -902,61 +954,7 @@ public class CardRenderer {
abiCount += 1; abiCount += 1;
} }
} }
} else if (canShow && !onbattlefield && showAbilityIcons(card)) {
//draw indicator for flash or can be cast at instant speed, enabled if show ability icons is enabled
String keywordKey = card.getCurrentState().getKeywordKey();
String abilityText = card.getCurrentState().getAbilityText();
if ((keywordKey.indexOf("Flash") != -1)
|| ((abilityText.indexOf("May be played by") != -1)
&& (abilityText.indexOf("and as though it has flash") != -1))){
if (keywordKey.indexOf("Flashback") == -1)
CardFaceSymbols.drawSymbol("flash", g, cx + ((cw*2)/2.3f), cy, cw / 5.5f, cw / 5.5f);
} }
}
//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)) {
float multiplier;
switch (Forge.extrawide) {
case "default":
multiplier = 0.145f; //good for tablets with 16:10 or similar
break;
case "wide":
multiplier = 0.150f;
break;
case "extrawide":
multiplier = 0.155f; //good for tall phones with 21:9 or similar
break;
default:
multiplier = 0.150f;
break;
}
g.drawOutlinedText(CardTranslation.getTranslatedName(details.getName()), FSkinFont.forHeight(h * multiplier), Color.WHITE, Color.BLACK, x + padding -1f, y + padding, w - 2 * padding, h * 0.4f, true, Align.left, false);
}
if (showCardManaCostOverlay(card)) {
float manaSymbolSize = w / 4.5f;
if (card.isSplitCard() && card.hasAlternateState()) {
if (!card.isFaceDown()) { // no need to draw mana symbols on face down split cards (e.g. manifested)
float dy = manaSymbolSize / 2 + Utils.scale(5);
PaperCard pc = StaticData.instance().getCommonCards().getCard(card.getName());
if (Card.getCardForUi(pc).hasKeyword(Keyword.AFTERMATH)){
dy *= -1; // flip card costs for Aftermath cards
}
drawManaCost(g, card.getRightSplitState().getManaCost(), x - padding, y - dy, w + 2 * padding, h, manaSymbolSize);
drawManaCost(g, card.getLeftSplitState().getManaCost(), x - padding, y + dy, w + 2 * padding, h, manaSymbolSize);
}
}
else {
drawManaCost(g, showAltState ? card.getAlternateState().getManaCost() : card.getCurrentState().getManaCost(), x - padding, y, w + 2 * padding, h, manaSymbolSize);
}
}
}
//reset alpha
g.setAlphaComposite(oldAlpha);
}
private static void drawCounterTabs(final CardView card, final Graphics g, final float x, final float y, final float w, final float h) { private static void drawCounterTabs(final CardView card, final Graphics g, final float x, final float y, final float w, final float h) {
int fontSize = Math.max(11, Math.min(22, (int) (h * 0.08))); int fontSize = Math.max(11, Math.min(22, (int) (h * 0.08)));
@@ -1180,7 +1178,7 @@ public class CardRenderer {
isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST); isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST);
} }
private static boolean showAbilityIcons(CardView card) { public static boolean showAbilityIcons(CardView card) {
return isShowingOverlays(card) && isPreferenceEnabled(FPref.UI_OVERLAY_ABILITY_ICONS); return isShowingOverlays(card) && isPreferenceEnabled(FPref.UI_OVERLAY_ABILITY_ICONS);
} }