mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48: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;
|
package forge;
|
||||||
|
|
||||||
|
import forge.card.CardEdition;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.TextUtil;
|
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, String> CACHE_CARD_PICS_SUBDIR;
|
||||||
|
|
||||||
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 Set<String> toFind = new HashSet<>();
|
private static Set<String> toFind = new HashSet<>();
|
||||||
|
|
||||||
private static boolean isLibGDXPort = false;
|
private static boolean isLibGDXPort = false;
|
||||||
@@ -187,6 +190,19 @@ public final class ImageKeys {
|
|||||||
toFind.remove(filename);
|
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 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")) {
|
||||||
@@ -355,6 +371,11 @@ public final class ImageKeys {
|
|||||||
Boolean editionHasImage = editionImageLookup.get(pc.getEdition());
|
Boolean editionHasImage = editionImageLookup.get(pc.getEdition());
|
||||||
if (editionHasImage == null) {
|
if (editionHasImage == null) {
|
||||||
String setFolder = getSetFolder(pc.getEdition());
|
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);
|
editionHasImage = FileUtil.isDirectoryWithFiles(CACHE_CARD_PICS_DIR + setFolder);
|
||||||
editionImageLookup.put(pc.getEdition(), editionHasImage);
|
editionImageLookup.put(pc.getEdition(), editionHasImage);
|
||||||
if (editionHasImage) {
|
if (editionHasImage) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Code=PLG20
|
|||||||
Date=2020-05-18
|
Date=2020-05-18
|
||||||
Name=Love Your LGS 2020
|
Name=Love Your LGS 2020
|
||||||
Code2=PLGS
|
Code2=PLGS
|
||||||
Alias=PLGS
|
|
||||||
Type=Promo
|
Type=Promo
|
||||||
ScryfallCode=PLG20
|
ScryfallCode=PLG20
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Code=H1R
|
|||||||
Date=2021-06-18
|
Date=2021-06-18
|
||||||
Name=Modern Horizons 1 Timeshifts
|
Name=Modern Horizons 1 Timeshifts
|
||||||
Code2=RMH1
|
Code2=RMH1
|
||||||
Alias=RMH1
|
|
||||||
Type=Draft
|
Type=Draft
|
||||||
ScryfallCode=H1R
|
ScryfallCode=H1R
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
Code=HOP
|
Code=HOP
|
||||||
Date=2009-09-04
|
Date=2009-09-04
|
||||||
Name=Planechase
|
Name=Planechase
|
||||||
Alias=PCH
|
Code2=PCH
|
||||||
Code2=HOP
|
|
||||||
Type=Multiplayer
|
Type=Multiplayer
|
||||||
ScryfallCode=HOP
|
ScryfallCode=HOP
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Code=PW09
|
|||||||
Date=2009-01-01
|
Date=2009-01-01
|
||||||
Name=Wizards Play Network 2009
|
Name=Wizards Play Network 2009
|
||||||
Code2=PWP09
|
Code2=PWP09
|
||||||
Alias=PWP09
|
|
||||||
Type=Promo
|
Type=Promo
|
||||||
ScryfallCode=PW09
|
ScryfallCode=PW09
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Code=PW10
|
|||||||
Date=2010-01-01
|
Date=2010-01-01
|
||||||
Name=Wizards Play Network 2010
|
Name=Wizards Play Network 2010
|
||||||
Code2=PWP10
|
Code2=PWP10
|
||||||
Alias=PWP10
|
|
||||||
Type=Promo
|
Type=Promo
|
||||||
ScryfallCode=PW10
|
ScryfallCode=PW10
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Code=PW11
|
|||||||
Date=2011-01-01
|
Date=2011-01-01
|
||||||
Name=Wizards Play Network 2011
|
Name=Wizards Play Network 2011
|
||||||
Code2=PWP11
|
Code2=PWP11
|
||||||
Alias=PWP11
|
|
||||||
Type=Promo
|
Type=Promo
|
||||||
ScryfallCode=PW11
|
ScryfallCode=PW11
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Code=PW12
|
|||||||
Date=2012-01-01
|
Date=2012-01-01
|
||||||
Name=Wizards Play Network 2012
|
Name=Wizards Play Network 2012
|
||||||
Code2=PWP12
|
Code2=PWP12
|
||||||
Alias=PWP12
|
|
||||||
Type=Promo
|
Type=Promo
|
||||||
ScryfallCode=PW12
|
ScryfallCode=PW12
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Code=PW21
|
|||||||
Date=2021-06-18
|
Date=2021-06-18
|
||||||
Name=Wizards Play Network 2021
|
Name=Wizards Play Network 2021
|
||||||
Code2=PWP21
|
Code2=PWP21
|
||||||
Alias=PWP21
|
|
||||||
Type=Promo
|
Type=Promo
|
||||||
ScryfallCode=PW21
|
ScryfallCode=PW21
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Code=WMC
|
|||||||
Date=2013-04-06
|
Date=2013-04-06
|
||||||
Name=World Magic Cup Qualifiers
|
Name=World Magic Cup Qualifiers
|
||||||
Code2=PWCQ
|
Code2=PWCQ
|
||||||
Alias=PWCQ
|
|
||||||
Type=Promo
|
Type=Promo
|
||||||
ScryfallCode=WMC
|
ScryfallCode=WMC
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user