mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Merge pull request #2407 from kevlahnota/newmaster2
add support for Edition code/alias for card images
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package forge;
|
||||
|
||||
import forge.card.CardEdition;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.TextUtil;
|
||||
@@ -38,6 +39,8 @@ public final class ImageKeys {
|
||||
private static Map<String, String> CACHE_CARD_PICS_SUBDIR;
|
||||
|
||||
private static Map<String, Boolean> editionImageLookup = new HashMap<>();
|
||||
|
||||
private static Map<String, String> editionAlias = new HashMap<>();
|
||||
private static Set<String> toFind = new HashSet<>();
|
||||
|
||||
private static boolean isLibGDXPort = false;
|
||||
@@ -187,6 +190,19 @@ public final class ImageKeys {
|
||||
toFind.remove(filename);
|
||||
}
|
||||
}
|
||||
String setCode = filename.contains("/") ? filename.substring(0, filename.indexOf("/")) : "";
|
||||
if (!setCode.isEmpty() && editionAlias.containsKey(setCode)) {
|
||||
file = findFile(dir, TextUtil.fastReplace(filename, setCode + "/", editionAlias.get(setCode) + "/"));
|
||||
if (file != null) {
|
||||
cachedCards.put(filename, file);
|
||||
return file;
|
||||
}
|
||||
file = findFile(dir, TextUtil.fastReplace(fullborderFile, setCode + "/", editionAlias.get(setCode) + "/"));
|
||||
if (file != null) {
|
||||
cachedCards.put(filename, 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 (!filename.contains(".full")) {
|
||||
@@ -355,6 +371,11 @@ public final class ImageKeys {
|
||||
Boolean editionHasImage = editionImageLookup.get(pc.getEdition());
|
||||
if (editionHasImage == null) {
|
||||
String setFolder = getSetFolder(pc.getEdition());
|
||||
CardEdition ed = StaticData.instance().getEditions().get(setFolder);
|
||||
if (ed != null && !editionAlias.containsKey(setFolder)) {
|
||||
String alias = ed.getAlias();
|
||||
editionAlias.put(setFolder, alias == null ? ed.getCode() : alias);
|
||||
}
|
||||
editionHasImage = FileUtil.isDirectoryWithFiles(CACHE_CARD_PICS_DIR + setFolder);
|
||||
editionImageLookup.put(pc.getEdition(), editionHasImage);
|
||||
if (editionHasImage) {
|
||||
|
||||
@@ -3,7 +3,6 @@ Code=PLG20
|
||||
Date=2020-05-18
|
||||
Name=Love Your LGS 2020
|
||||
Code2=PLGS
|
||||
Alias=PLGS
|
||||
Type=Promo
|
||||
ScryfallCode=PLG20
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ Code=H1R
|
||||
Date=2021-06-18
|
||||
Name=Modern Horizons 1 Timeshifts
|
||||
Code2=RMH1
|
||||
Alias=RMH1
|
||||
Type=Draft
|
||||
ScryfallCode=H1R
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Code=HOP
|
||||
Date=2009-09-04
|
||||
Name=Planechase
|
||||
Alias=PCH
|
||||
Code2=HOP
|
||||
Code2=PCH
|
||||
Type=Multiplayer
|
||||
ScryfallCode=HOP
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ Code=PW09
|
||||
Date=2009-01-01
|
||||
Name=Wizards Play Network 2009
|
||||
Code2=PWP09
|
||||
Alias=PWP09
|
||||
Type=Promo
|
||||
ScryfallCode=PW09
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ Code=PW10
|
||||
Date=2010-01-01
|
||||
Name=Wizards Play Network 2010
|
||||
Code2=PWP10
|
||||
Alias=PWP10
|
||||
Type=Promo
|
||||
ScryfallCode=PW10
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ Code=PW11
|
||||
Date=2011-01-01
|
||||
Name=Wizards Play Network 2011
|
||||
Code2=PWP11
|
||||
Alias=PWP11
|
||||
Type=Promo
|
||||
ScryfallCode=PW11
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ Code=PW12
|
||||
Date=2012-01-01
|
||||
Name=Wizards Play Network 2012
|
||||
Code2=PWP12
|
||||
Alias=PWP12
|
||||
Type=Promo
|
||||
ScryfallCode=PW12
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ Code=PW21
|
||||
Date=2021-06-18
|
||||
Name=Wizards Play Network 2021
|
||||
Code2=PWP21
|
||||
Alias=PWP21
|
||||
Type=Promo
|
||||
ScryfallCode=PW21
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ Code=WMC
|
||||
Date=2013-04-06
|
||||
Name=World Magic Cup Qualifiers
|
||||
Code2=PWCQ
|
||||
Alias=PWCQ
|
||||
Type=Promo
|
||||
ScryfallCode=WMC
|
||||
|
||||
|
||||
Reference in New Issue
Block a user