mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Merge pull request #2413 from kevlahnota/newmaster2
support code, code2 & alias on image lookup
This commit is contained in:
@@ -40,7 +40,7 @@ public final class ImageKeys {
|
|||||||
|
|
||||||
private static Map<String, Boolean> editionImageLookup = new HashMap<>();
|
private static Map<String, Boolean> editionImageLookup = new HashMap<>();
|
||||||
|
|
||||||
private static Map<String, String> editionAlias = new HashMap<>();
|
private static Map<String, Set<String>> editionAlias = new HashMap<>();
|
||||||
private static Set<String> toFind = new HashSet<>();
|
private static Set<String> toFind = new HashSet<>();
|
||||||
|
|
||||||
private static boolean isLibGDXPort = false;
|
private static boolean isLibGDXPort = false;
|
||||||
@@ -192,18 +192,20 @@ public final class ImageKeys {
|
|||||||
}
|
}
|
||||||
String setCode = filename.contains("/") ? filename.substring(0, filename.indexOf("/")) : "";
|
String setCode = filename.contains("/") ? filename.substring(0, filename.indexOf("/")) : "";
|
||||||
if (!setCode.isEmpty() && editionAlias.containsKey(setCode)) {
|
if (!setCode.isEmpty() && editionAlias.containsKey(setCode)) {
|
||||||
file = findFile(dir, TextUtil.fastReplace(filename, setCode + "/", editionAlias.get(setCode) + "/"));
|
for (String alias : editionAlias.get(setCode)) {
|
||||||
|
file = findFile(dir, TextUtil.fastReplace(filename, setCode + "/", alias + "/"));
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
cachedCards.put(filename, file);
|
cachedCards.put(filename, file);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
file = findFile(dir, TextUtil.fastReplace(fullborderFile, setCode + "/", editionAlias.get(setCode) + "/"));
|
file = findFile(dir, TextUtil.fastReplace(fullborderFile, setCode + "/", alias + "/"));
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
cachedCards.put(filename, file);
|
cachedCards.put(filename, file);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//if an image, like phenomenon or planes is missing .full in their filenames but you have an existing images that have .full/.fullborder
|
//if an image, like phenomenon or planes is missing .full in their filenames but you have an existing images that have .full/.fullborder
|
||||||
if (!filename.contains(".full")) {
|
if (!filename.contains(".full")) {
|
||||||
file = findFile(dir, TextUtil.addSuffix(filename,".full"));
|
file = findFile(dir, TextUtil.addSuffix(filename,".full"));
|
||||||
@@ -288,12 +290,13 @@ public final class ImageKeys {
|
|||||||
}
|
}
|
||||||
String setCode = filename.substring(0, filename.indexOf("/"));
|
String setCode = filename.substring(0, filename.indexOf("/"));
|
||||||
if (!setCode.isEmpty() && editionAlias.containsKey(setCode)) {
|
if (!setCode.isEmpty() && editionAlias.containsKey(setCode)) {
|
||||||
file = findFile(dir, TextUtil.fastReplace(newFilename, setCode + "/", editionAlias.get(setCode) + "/"));
|
for (String alias : editionAlias.get(setCode)) {
|
||||||
|
file = findFile(dir, TextUtil.fastReplace(newFilename, setCode + "/", alias + "/"));
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
cachedCards.put(filename, file);
|
cachedCards.put(filename, file);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
file = findFile(dir, TextUtil.fastReplace(newFilename2, setCode + "/", editionAlias.get(setCode) + "/"));
|
file = findFile(dir, TextUtil.fastReplace(newFilename2, setCode + "/", alias + "/"));
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
cachedCards.put(filename, file);
|
cachedCards.put(filename, file);
|
||||||
return file;
|
return file;
|
||||||
@@ -302,6 +305,7 @@ public final class ImageKeys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// System.out.println("File not found, no image created: " + key);
|
// System.out.println("File not found, no image created: " + key);
|
||||||
//add missing cards - disable for desktop version for compatibility reasons with autodownloader
|
//add missing cards - disable for desktop version for compatibility reasons with autodownloader
|
||||||
@@ -402,10 +406,18 @@ public final class ImageKeys {
|
|||||||
CardEdition ed = StaticData.instance().getEditions().get(setFolder);
|
CardEdition ed = StaticData.instance().getEditions().get(setFolder);
|
||||||
if (ed != null && !editionAlias.containsKey(setFolder)) {
|
if (ed != null && !editionAlias.containsKey(setFolder)) {
|
||||||
String alias = ed.getAlias();
|
String alias = ed.getAlias();
|
||||||
if (alias == null)
|
Set aliasSet = new HashSet<>();
|
||||||
alias = ed.getCode();
|
if (alias != null) {
|
||||||
if (!alias.equalsIgnoreCase(setFolder))
|
if (!alias.equalsIgnoreCase(setFolder))
|
||||||
editionAlias.put(setFolder, alias);
|
aliasSet.add(alias);
|
||||||
|
}
|
||||||
|
String code = ed.getCode();
|
||||||
|
if (code != null) {
|
||||||
|
if (!code.equalsIgnoreCase(setFolder))
|
||||||
|
aliasSet.add(code);
|
||||||
|
}
|
||||||
|
if (!aliasSet.isEmpty())
|
||||||
|
editionAlias.put(setFolder, aliasSet);
|
||||||
}
|
}
|
||||||
editionHasImage = FileUtil.isDirectoryWithFiles(CACHE_CARD_PICS_DIR + setFolder);
|
editionHasImage = FileUtil.isDirectoryWithFiles(CACHE_CARD_PICS_DIR + setFolder);
|
||||||
editionImageLookup.put(pc.getEdition(), editionHasImage);
|
editionImageLookup.put(pc.getEdition(), editionHasImage);
|
||||||
|
|||||||
Reference in New Issue
Block a user