mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
CardUtils uses a more generalized interface somewhere
ImageCache exports methods to get image key
This commit is contained in:
@@ -39,7 +39,7 @@ import forge.card.spellability.SpellAbility;
|
|||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiDisplayUtil;
|
import forge.gui.GuiDisplayUtil;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.IPaperCard;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ public final class CardUtil {
|
|||||||
* the card
|
* the card
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String buildFilename(final CardPrinted card) {
|
public static String buildFilename(final IPaperCard card) {
|
||||||
CardRules cr = card.getRules();
|
CardRules cr = card.getRules();
|
||||||
final int maxIndex = cr.getEditionInfo(card.getEdition()).getCopiesCount();
|
final int maxIndex = cr.getEditionInfo(card.getEdition()).getCopiesCount();
|
||||||
// picture is named AssaultBattery.full.jpg
|
// picture is named AssaultBattery.full.jpg
|
||||||
@@ -199,7 +199,7 @@ public final class CardUtil {
|
|||||||
* the name to use
|
* the name to use
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String buildFilename(final CardPrinted card, final String nameToUse) {
|
public static String buildFilename(final IPaperCard card, final String nameToUse) {
|
||||||
final int maxIndex = card.getRules().getEditionInfo(card.getEdition()).getCopiesCount();
|
final int maxIndex = card.getRules().getEditionInfo(card.getEdition()).getCopiesCount();
|
||||||
return CardUtil.buildFilename(nameToUse, card.getEdition(), card.getArtIndex(), maxIndex, false);
|
return CardUtil.buildFilename(nameToUse, card.getEdition(), card.getArtIndex(), maxIndex, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,13 +59,17 @@ public class ImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static BufferedImage getImage(final InventoryItem card, final int width, final int height) {
|
public static BufferedImage getImage(final InventoryItem ii, final int width, final int height) {
|
||||||
// TODO: move all the path-building logics here from the very objects. They don't have to know where their picture is
|
// TODO: move all the path-building logics here from the very objects. They don't have to know where their picture is
|
||||||
String key = card.getImageFilename();
|
String key = getKey(ii);
|
||||||
|
|
||||||
return scaleImage(key, width, height);
|
return scaleImage(key, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BufferedImage getImage(final String key, final int width, final int height) {
|
||||||
|
return scaleImage(key, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
* @param original
|
* @param original
|
||||||
@@ -141,13 +145,15 @@ public class ImageCache {
|
|||||||
* a {@link forge.Card} object.
|
* a {@link forge.Card} object.
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private static String getKey(final Card card) {
|
public static String getKey(final Card card) {
|
||||||
|
|
||||||
if ((card.isToken() && !card.isCopiedToken()) || card.isFaceDown()) {
|
if ((card.isToken() && !card.isCopiedToken()) || card.isFaceDown()) {
|
||||||
return ImageCache.TOKEN + GuiDisplayUtil.cleanString(card.getImageFilename());
|
return ImageCache.TOKEN + GuiDisplayUtil.cleanString(card.getImageFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
return card.getImageFilename(); // key;
|
return card.getImageFilename(); // key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getKey(final InventoryItem ii) {
|
||||||
|
return ii.getImageFilename();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user