Little fix to always show icons and names for cards without images.

This commit is contained in:
Oleg Agafonov 2017-11-18 16:44:34 +04:00
parent e2e4646863
commit b78dab27a1

View file

@ -182,8 +182,11 @@ public class CardPanelComponentImpl extends CardPanel {
IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function<Key, BufferedImage>) key -> createImage(key))); IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function<Key, BufferedImage>) key -> createImage(key)));
} }
static private boolean canShowCardIcons(int fullWidth){ static private boolean canShowCardIcons(int cardFullWidth, boolean cardHasImage){
return (fullWidth > 60) && (fullWidth < 200); // cards without images show icons and text always
// TODO: apply "card names on card" setting to icon too?
// TODO: fix card min-max size to hide (compare to settings size, not direct 60 and 200)
return ((cardFullWidth > 60) && (cardFullWidth < 200)) || (!cardHasImage);
} }
private static class CardSizes{ private static class CardSizes{
@ -474,7 +477,7 @@ public class CardPanelComponentImpl extends CardPanel {
g.drawRect(ptText.getX(), ptText.getY(), ptText.getBounds().width, ptText.getBounds().height); g.drawRect(ptText.getX(), ptText.getY(), ptText.getBounds().width, ptText.getBounds().height);
//*/ //*/
if (getShowCastingCost() && !isAnimationPanel() && canShowCardIcons(getCardWidth())) { if (getShowCastingCost() && !isAnimationPanel() && canShowCardIcons(getCardWidth(), hasImage)) {
String manaCost = ManaSymbols.getStringManaCost(gameCard.getManaCost()); String manaCost = ManaSymbols.getStringManaCost(gameCard.getManaCost());
int manaWidth = getManaWidth(manaCost); int manaWidth = getManaWidth(manaCost);
@ -562,7 +565,7 @@ public class CardPanelComponentImpl extends CardPanel {
//int fontHeight = Math.round(cardHeight * (26f / 672)); //int fontHeight = Math.round(cardHeight * (26f / 672));
//boolean showText = (!isAnimationPanel() && fontHeight < 12); //boolean showText = (!isAnimationPanel() && fontHeight < 12);
boolean showText = !isAnimationPanel() && canShowCardIcons(cardWidth); boolean showText = !isAnimationPanel() && canShowCardIcons(cardWidth, hasImage);
titleText.setVisible(showText); titleText.setVisible(showText);
ptText.setVisible(showText); ptText.setVisible(showText);
fullImageText.setVisible(fullImagePath != null); fullImageText.setVisible(fullImagePath != null);