mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Added forge.profile.properties setting to specify custom names for edition folders in pics directory
This commit is contained in:
@@ -226,11 +226,18 @@ public class ImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (includeSet) {
|
if (includeSet) {
|
||||||
return String.format("%s/%s", Singletons.getModel().getEditions().getCode2ByCode(cp.getEdition()), fname);
|
String editionAliased = isDownloadUrl ? Singletons.getModel().getEditions().getCode2ByCode(edition) : getSetFolder(edition);
|
||||||
|
return String.format("%s/%s", editionAliased, fname);
|
||||||
} else {
|
} else {
|
||||||
return fname;
|
return fname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getSetFolder(String edition) {
|
||||||
|
return !NewConstants.CACHE_CARD_PICS_SUBDIR.containsKey(edition)
|
||||||
|
? Singletons.getModel().getEditions().getCode2ByCode(edition) // by default 2-letter codes from MWS are used
|
||||||
|
: NewConstants.CACHE_CARD_PICS_SUBDIR.get(edition); // may use custom paths though
|
||||||
|
}
|
||||||
|
|
||||||
public static String getImageName(CardPrinted cp) {
|
public static String getImageName(CardPrinted cp) {
|
||||||
return CardSplitType.Split != cp.getRules().getSplitType() ? cp.getName() : cp.getRules().getMainPart().getName() + cp.getRules().getOtherPart().getName();
|
return CardSplitType.Split != cp.getRules().getSplitType() ? cp.getName() : cp.getRules().getMainPart().getName() + cp.getRules().getOtherPart().getName();
|
||||||
|
|||||||
@@ -51,9 +51,12 @@ final class ImageLoader extends CacheLoader<String, BufferedImage> {
|
|||||||
|
|
||||||
BufferedImage ret = _findFile(key, path, filename);
|
BufferedImage ret = _findFile(key, path, filename);
|
||||||
|
|
||||||
// some S00/S2K cards are really part of 6ED/6E
|
// some S00 cards are really part of 6ED
|
||||||
if (null == ret && filename.startsWith("S00") ) {
|
if (null == ret ) {
|
||||||
ret = _findFile(key, path, filename.replace("S00", "6ED"));
|
String s2kAlias = ImageCache.getSetFolder("S00");
|
||||||
|
if ( filename.startsWith(s2kAlias) ) {
|
||||||
|
ret = _findFile(key, path, filename.replace(s2kAlias, ImageCache.getSetFolder("6ED")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try without set prefix
|
// try without set prefix
|
||||||
|
|||||||
@@ -227,6 +227,8 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
|||||||
System.err.println(String.format("Ignoring unknown type in set definitions: name: %s; type: %s", name, type));
|
System.err.println(String.format("Ignoring unknown type in set definitions: name: %s; type: %s", name, type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if( !code2.equals(code) ) System.out.printf("%s->%s|", code, code);
|
||||||
|
|
||||||
return new CardEdition(index, code2, code, enumType, name, alias, borderWhite);
|
return new CardEdition(index, code2, code, enumType, name, alias, borderWhite);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ public final class CardPrinted implements Comparable<IPaperCard>, InventoryItemF
|
|||||||
private final boolean foiled;
|
private final boolean foiled;
|
||||||
|
|
||||||
// Calculated fields are below:
|
// Calculated fields are below:
|
||||||
private final transient CardRarity rarity; // rarity is given in ctor when
|
private final transient CardRarity rarity; // rarity is given in ctor when set is assigned
|
||||||
// set is assigned
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|||||||
@@ -20,11 +20,14 @@ package forge.properties;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import forge.util.FileSection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the user data and cache dirs, first looking at the specified file for overrides
|
* Determines the user data and cache dirs, first looking at the specified file for overrides
|
||||||
* then falling back to platform-specific defaults. Resulting dir strings are guaranteed to end in a slash
|
* then falling back to platform-specific defaults. Resulting dir strings are guaranteed to end in a slash
|
||||||
@@ -34,10 +37,12 @@ public class ForgeProfileProperties {
|
|||||||
public final String userDir;
|
public final String userDir;
|
||||||
public final String cacheDir;
|
public final String cacheDir;
|
||||||
public final String cardPicsDir;
|
public final String cardPicsDir;
|
||||||
|
public final Map<String, String> cardPicsSubDir;
|
||||||
|
|
||||||
private static final String _USER_DIR_KEY = "userDir";
|
private static final String _USER_DIR_KEY = "userDir";
|
||||||
private static final String _CACHE_DIR_KEY = "cacheDir";
|
private static final String _CACHE_DIR_KEY = "cacheDir";
|
||||||
private static final String _CARD_PICS_DIR_KEY = "cardPicsDir";
|
private static final String _CARD_PICS_DIR_KEY = "cardPicsDir";
|
||||||
|
private static final String _CARD_PICS_SUB_DIRS_KEY = "cardPicsSubDirs";
|
||||||
|
|
||||||
public ForgeProfileProperties(String filename) {
|
public ForgeProfileProperties(String filename) {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
@@ -54,6 +59,13 @@ public class ForgeProfileProperties {
|
|||||||
userDir = _getDir(props, _USER_DIR_KEY, defaults.getLeft());
|
userDir = _getDir(props, _USER_DIR_KEY, defaults.getLeft());
|
||||||
cacheDir = _getDir(props, _CACHE_DIR_KEY, defaults.getRight());
|
cacheDir = _getDir(props, _CACHE_DIR_KEY, defaults.getRight());
|
||||||
cardPicsDir = _getDir(props, _CARD_PICS_DIR_KEY, cacheDir + "pics/cards/");
|
cardPicsDir = _getDir(props, _CARD_PICS_DIR_KEY, cacheDir + "pics/cards/");
|
||||||
|
cardPicsSubDir = _getMap(props, _CARD_PICS_SUB_DIRS_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Map<String,String> _getMap(Properties props, String propertyKey) {
|
||||||
|
String strMap = props.getProperty(propertyKey, "").trim();
|
||||||
|
return FileSection.parseToMap(strMap, "->", "|");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String _getDir(Properties props, String propertyKey, String defaultVal) {
|
private static String _getDir(Properties props, String propertyKey, String defaultVal) {
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package forge.properties;
|
package forge.properties;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public final class NewConstants {
|
public final class NewConstants {
|
||||||
public static final String PROFILE_FILE = "forge.profile.properties";
|
public static final String PROFILE_FILE = "forge.profile.properties";
|
||||||
public static final String PROFILE_TEMPLATE_FILE = PROFILE_FILE + ".example";
|
public static final String PROFILE_TEMPLATE_FILE = PROFILE_FILE + ".example";
|
||||||
@@ -50,11 +53,13 @@ public final class NewConstants {
|
|||||||
public static final String USER_DIR;
|
public static final String USER_DIR;
|
||||||
public static final String CACHE_DIR;
|
public static final String CACHE_DIR;
|
||||||
public static final String CACHE_CARD_PICS_DIR;
|
public static final String CACHE_CARD_PICS_DIR;
|
||||||
|
public static final Map<String, String> CACHE_CARD_PICS_SUBDIR;
|
||||||
static {
|
static {
|
||||||
ForgeProfileProperties profileProps = new ForgeProfileProperties(PROFILE_FILE);
|
ForgeProfileProperties profileProps = new ForgeProfileProperties(PROFILE_FILE);
|
||||||
USER_DIR = profileProps.userDir;
|
USER_DIR = profileProps.userDir;
|
||||||
CACHE_DIR = profileProps.cacheDir;
|
CACHE_DIR = profileProps.cacheDir;
|
||||||
CACHE_CARD_PICS_DIR = profileProps.cardPicsDir;
|
CACHE_CARD_PICS_DIR = profileProps.cardPicsDir;
|
||||||
|
CACHE_CARD_PICS_SUBDIR = Collections.unmodifiableMap(profileProps.cardPicsSubDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// data that is only in the profile dirs
|
// data that is only in the profile dirs
|
||||||
|
|||||||
Reference in New Issue
Block a user