forked from External/mage
* GUI: added card icon for commander on battlefield;
Card icons: added support of custom card icon colors;
This commit is contained in:
parent
06ae494c5b
commit
4d1985476f
17 changed files with 327 additions and 116 deletions
|
|
@ -2,6 +2,7 @@ package org.mage.plugins.card.images;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ComputationException;
|
||||
import mage.abilities.icon.CardIconColor;
|
||||
import mage.client.constants.Constants;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.SoftValuesLoadingCache;
|
||||
|
|
@ -52,7 +53,7 @@ public final class ImageCache {
|
|||
* Common pattern for keys. See ImageCache.getKey for structure info
|
||||
*/
|
||||
private static final Pattern KEY_PATTERN = Pattern.compile("(.*)#(.*)#(.*)#(.*)#(.*)#(.*)");
|
||||
private static final Pattern CARD_ICON_KEY_PATTERN = Pattern.compile("(.*)#(.*)");
|
||||
private static final Pattern CARD_ICON_KEY_PATTERN = Pattern.compile("(.*)#(.*)#(.*)");
|
||||
|
||||
static {
|
||||
// softValues() = Specifies that each value (not key) stored in the map should be wrapped in a SoftReference
|
||||
|
|
@ -232,7 +233,8 @@ public final class ImageCache {
|
|||
if (m.matches()) {
|
||||
int cardSize = Integer.parseInt(m.group(1));
|
||||
String resourceName = m.group(2);
|
||||
BufferedImage image = ImageManagerImpl.instance.getCardIcon(resourceName, cardSize);
|
||||
CardIconColor cardIconColor = CardIconColor.valueOf(m.group(3));
|
||||
BufferedImage image = ImageManagerImpl.instance.getCardIcon(resourceName, cardSize, cardIconColor);
|
||||
return image;
|
||||
} else {
|
||||
throw new RuntimeException("Wrong card icons image key format: " + key);
|
||||
|
|
@ -426,8 +428,8 @@ public final class ImageCache {
|
|||
return getImage(getKey(card, card.getAlternateName(), ""));
|
||||
}
|
||||
|
||||
public static BufferedImage getCardIconImage(String resourceName, int iconSize) {
|
||||
return getCardIconImage(getCardIconKey(resourceName, iconSize));
|
||||
public static BufferedImage getCardIconImage(String resourceName, int iconSize, String cardColorName) {
|
||||
return getCardIconImage(getCardIconKey(resourceName, iconSize, cardColorName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -502,8 +504,8 @@ public final class ImageCache {
|
|||
return name + '#' + set + "####";
|
||||
}
|
||||
|
||||
private static String getCardIconKey(String resourceName, int size) {
|
||||
return size + "#" + resourceName;
|
||||
private static String getCardIconKey(String resourceName, int size, String cardColorName) {
|
||||
return size + "#" + resourceName + "#" + cardColorName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.mage.plugins.card.utils;
|
||||
|
||||
import mage.abilities.icon.CardIconColor;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
|
|
@ -77,7 +79,7 @@ public interface ImageManager {
|
|||
|
||||
Image getToggleRecordMacroButtonImage();
|
||||
|
||||
BufferedImage getCardIcon(String resourceName, int size);
|
||||
BufferedImage getCardIcon(String resourceName, int size, CardIconColor cardIconColor);
|
||||
|
||||
Image getPhaseImage(String phase);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.mage.plugins.card.utils.impl;
|
||||
|
||||
import mage.abilities.icon.CardIconColor;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.gui.BufferedImageBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -363,14 +364,14 @@ public enum ImageManagerImpl implements ImageManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage getCardIcon(String resourceName, int size) {
|
||||
public BufferedImage getCardIcon(String resourceName, int size, CardIconColor cardIconColor) {
|
||||
// icon must be same, but color can be changed by themes
|
||||
InputStream data = ImageManager.class.getResourceAsStream(PreferencesDialog.getCurrentTheme().getCardIconsResourcePath(resourceName));
|
||||
try {
|
||||
// no need to resize svg (lib already do it on load)
|
||||
return SvgUtils.loadSVG(data, "card icon = " + resourceName,
|
||||
PreferencesDialog.getCurrentTheme().getCardIconsCssFile(),
|
||||
PreferencesDialog.getCurrentTheme().getCardIconsCssSettings(),
|
||||
return SvgUtils.loadSVG(data, "card icon = " + resourceName + "; " + cardIconColor.toString(),
|
||||
PreferencesDialog.getCurrentTheme().getCardIconsCssFile(cardIconColor),
|
||||
PreferencesDialog.getCurrentTheme().getCardIconsCssSettings(cardIconColor),
|
||||
size, size, false);
|
||||
} catch (Exception e) {
|
||||
logger.error("Can't load card icon: " + resourceName + " , reason: " + e.getMessage(), e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue