show front face of facedown cards in VPicture when player can legitmately look at them

This commit is contained in:
myk
2013-03-29 17:47:02 +00:00
parent c0a8ca9e95
commit 780ed417c7
3 changed files with 23 additions and 7 deletions

View File

@@ -8427,6 +8427,14 @@ public class Card extends GameEntity implements Comparable<Card> {
return this.getCharacteristics().getImageKey(); return this.getCharacteristics().getImageKey();
} }
public final String getImageKey(CardCharacteristicName state) {
CardCharacteristics characteristics = characteristicsMap.get(state);
if (null == characteristics) {
return null;
}
return characteristics.getImageKey();
}
/** /**
* <p> * <p>
* Setter for the field <code>evoked</code>. * Setter for the field <code>evoked</code>.

View File

@@ -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. * 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) { 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; 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; key = TOKEN_PREFIX + NewConstants.CACHE_MORPH_IMAGE_FILE;
} else { } else {
key = card.getImageKey(); key = ignoreFaceDown ? card.getImageKey(CardCharacteristicName.Original) : card.getImageKey();
} }
return scaleImage(key, width, height, true); 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. * 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) { public static BufferedImage getImage(InventoryItem ii, int width, int height) {

View File

@@ -86,9 +86,9 @@ public final class CardPicturePanel extends JPanel {
if (displayed instanceof InventoryItem) { if (displayed instanceof InventoryItem) {
image = ImageCache.getImage((InventoryItem)this.displayed, this.getWidth() - i.left - i.right, this.getHeight() image = ImageCache.getImage((InventoryItem)this.displayed, this.getWidth() - i.left - i.right, this.getHeight()
- i.top - i.bottom); - i.top - i.bottom);
} else if ( displayed instanceof Card ) { } else if (displayed instanceof Card) {
image = ImageCache.getImage((Card)this.displayed, this.getWidth() - i.left - i.right - 2, this.getHeight() - i.top image = ImageCache.getImage((Card)this.displayed,
- i.bottom - 2); this.getWidth() - i.left - i.right - 2, this.getHeight() - i.top - i.bottom - 2, true);
} }
if (image != this.currentImage) { if (image != this.currentImage) {