diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index d4c11d29f3d..7889df8588c 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -8426,6 +8426,14 @@ public class Card extends GameEntity implements Comparable { public final String getImageKey() { return this.getCharacteristics().getImageKey(); } + + public final String getImageKey(CardCharacteristicName state) { + CardCharacteristics characteristics = characteristicsMap.get(state); + if (null == characteristics) { + return null; + } + return characteristics.getImageKey(); + } /** *

diff --git a/src/main/java/forge/ImageCache.java b/src/main/java/forge/ImageCache.java index 5997146fd3d..d53a016b5a1 100644 --- a/src/main/java/forge/ImageCache.java +++ b/src/main/java/forge/ImageCache.java @@ -99,21 +99,29 @@ public class ImageCache { } /** - * retrieve an image from the cache. returns null if the image is not found in the cache + * retrieve an image from the cache. returns a default image if the image is not found in the cache * and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension. */ public static BufferedImage getImage(Card card, int width, int height) { + return getImage(card, width, height, false); + } + + /** + * retrieve an image from the cache. returns a default image if the image is not found in the cache + * and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension. + */ + public static BufferedImage getImage(Card card, int width, int height, boolean ignoreFaceDown) { final String key; - if (!card.canBeShownTo(Singletons.getControl().getPlayer()) || card.isFaceDown()) { + if (!card.canBeShownTo(Singletons.getControl().getPlayer()) || (!ignoreFaceDown && card.isFaceDown())) { key = TOKEN_PREFIX + NewConstants.CACHE_MORPH_IMAGE_FILE; } else { - key = card.getImageKey(); + key = ignoreFaceDown ? card.getImageKey(CardCharacteristicName.Original) : card.getImageKey(); } return scaleImage(key, width, height, true); } /** - * retrieve an image from the cache. returns null if the image is not found in the cache + * retrieve an image from the cache. returns a default image if the image is not found in the cache * and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension. */ public static BufferedImage getImage(InventoryItem ii, int width, int height) { diff --git a/src/main/java/forge/gui/CardPicturePanel.java b/src/main/java/forge/gui/CardPicturePanel.java index 663108d6ff9..2fda6312c47 100644 --- a/src/main/java/forge/gui/CardPicturePanel.java +++ b/src/main/java/forge/gui/CardPicturePanel.java @@ -86,9 +86,9 @@ public final class CardPicturePanel extends JPanel { if (displayed instanceof InventoryItem) { image = ImageCache.getImage((InventoryItem)this.displayed, this.getWidth() - i.left - i.right, this.getHeight() - i.top - i.bottom); - } else if ( displayed instanceof Card ) { - image = ImageCache.getImage((Card)this.displayed, this.getWidth() - i.left - i.right - 2, this.getHeight() - i.top - - i.bottom - 2); + } else if (displayed instanceof Card) { + image = ImageCache.getImage((Card)this.displayed, + this.getWidth() - i.left - i.right - 2, this.getHeight() - i.top - i.bottom - 2, true); } if (image != this.currentImage) {