Avoid showing IDs for hidden cards

This commit is contained in:
drdev
2014-10-18 00:36:37 +00:00
parent df378e7a13
commit 652e7c2238
3 changed files with 10 additions and 6 deletions

View File

@@ -252,7 +252,7 @@ public class CardDetailPanel extends SkinnedPanel {
powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(state, canShow)); powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(state, canShow));
idLabel.setText(CardDetailUtil.formatCardId(state)); idLabel.setText(canShow ? CardDetailUtil.formatCardId(state) : "");
// fill the card text // fill the card text
cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state, canShow), true)); cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state, canShow), true));

View File

@@ -326,7 +326,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
displayCardNameOverlay(showText && canShow && showCardNameOverlay(), imgSize, imgPos); displayCardNameOverlay(showText && canShow && showCardNameOverlay(), imgSize, imgPos);
displayPTOverlay(showText && (canShow || card.isFaceDown()) && showCardPowerOverlay(), imgSize, imgPos); displayPTOverlay(showText && (canShow || card.isFaceDown()) && showCardPowerOverlay(), imgSize, imgPos);
displayCardIdOverlay(showText && showCardIdOverlay(), imgSize, imgPos); displayCardIdOverlay(showText && canShow && showCardIdOverlay(), imgSize, imgPos);
} }
private void displayCardIdOverlay(boolean isVisible, Dimension imgSize, Point imgPos) { private void displayCardIdOverlay(boolean isVisible, Dimension imgSize, Point imgPos) {

View File

@@ -471,15 +471,19 @@ public class CardRenderer {
private static void drawCardIdAndPtBox(Graphics g, CardView card, boolean canShow, 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); float idWidth = 0;
g.drawText(idText, ID_FONT, idForeColor, x, y + ID_FONT.getCapHeight() / 2, w, h, false, HAlignment.LEFT, false); if (canShow) {
String idText = CardDetailUtil.formatCardId(state);
g.drawText(idText, ID_FONT, idForeColor, x, y + ID_FONT.getCapHeight() / 2, w, h, false, HAlignment.LEFT, false);
idWidth = ID_FONT.getBounds(idText).width;
}
String ptText = CardDetailUtil.formatPowerToughness(state, canShow); 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;
float boxWidth = Math.min(PT_FONT.getBounds(ptText).width + 2 * padding, float boxWidth = Math.min(PT_FONT.getBounds(ptText).width + 2 * padding,
w - ID_FONT.getBounds(idText).width - padding); //prevent box overlapping ID w - idWidth - padding); //prevent box overlapping ID
x += w - boxWidth; x += w - boxWidth;
w = boxWidth; w = boxWidth;
@@ -567,7 +571,7 @@ public class CardRenderer {
if (pos == CardStackPosition.BehindVert) { return; } //remaining rendering not needed if card is behind another card in a vertical stack if (pos == CardStackPosition.BehindVert) { return; } //remaining rendering not needed if card is behind another card in a vertical stack
boolean onTop = (pos == CardStackPosition.Top); boolean onTop = (pos == CardStackPosition.Top);
if (showCardIdOverlay(card)) { if (canShow && showCardIdOverlay(card)) {
FSkinFont idFont = FSkinFont.forHeight(h * 0.12f); FSkinFont idFont = FSkinFont.forHeight(h * 0.12f);
float idHeight = idFont.getCapHeight(); float idHeight = idFont.getCapHeight();
g.drawOutlinedText(String.valueOf(card.getId()), idFont, Color.WHITE, Color.BLACK, x + padding, y + h - idHeight - padding, w, h, false, HAlignment.LEFT, false); g.drawOutlinedText(String.valueOf(card.getId()), idFont, Color.WHITE, Color.BLACK, x + padding, y + h - idHeight - padding, w, h, false, HAlignment.LEFT, false);