mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Support Set lookup for J21 and other future sets.
Forge loads all files found on the setlookup folder. Example J21.txt (J21 set code) contains a list of set codes (sorted from Newest to Oldest beforehand) to lookup for images on other sets.
This commit is contained in:
@@ -129,6 +129,23 @@ public final class ImageKeys {
|
|||||||
// if there's a 1st art variant try with it for .full images
|
// if there's a 1st art variant try with it for .full images
|
||||||
file = findFile(dir, filename.replaceAll("[0-9]*.full", "1.full"));
|
file = findFile(dir, filename.replaceAll("[0-9]*.full", "1.full"));
|
||||||
if (file != null) { return file; }
|
if (file != null) { return file; }
|
||||||
|
//setlookup
|
||||||
|
if (!StaticData.instance().getSetLookup().isEmpty()) {
|
||||||
|
for (String setKey : StaticData.instance().getSetLookup().keySet()) {
|
||||||
|
for (String setLookup : StaticData.instance().getSetLookup().get(setKey)) {
|
||||||
|
//.fullborder lookup
|
||||||
|
file = findFile(dir, TextUtil.fastReplace(fullborderFile, setKey, getSetFolder(setLookup)));
|
||||||
|
if (file != null) { return file; }
|
||||||
|
file = findFile(dir, TextUtil.fastReplace(fullborderFile, setKey, getSetFolder(setLookup)).replaceAll("[0-9]*.fullborder", "1.fullborder"));
|
||||||
|
if (file != null) { return file; }
|
||||||
|
//.full lookup
|
||||||
|
file = findFile(dir, TextUtil.fastReplace(filename, setKey, getSetFolder(setLookup)));
|
||||||
|
if (file != null) { return file; }
|
||||||
|
file = findFile(dir, TextUtil.fastReplace(filename, setKey, getSetFolder(setLookup)).replaceAll("[0-9]*.fullborder", "1.fullborder"));
|
||||||
|
if (file != null) { 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")) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import forge.item.FatPack;
|
|||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.item.SealedProduct;
|
import forge.item.SealedProduct;
|
||||||
import forge.token.TokenDb;
|
import forge.token.TokenDb;
|
||||||
|
import forge.util.FileUtil;
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
import forge.util.storage.IStorage;
|
import forge.util.storage.IStorage;
|
||||||
import forge.util.storage.StorageBase;
|
import forge.util.storage.StorageBase;
|
||||||
@@ -57,18 +58,19 @@ public class StaticData {
|
|||||||
private IStorage<FatPack.Template> fatPacks;
|
private IStorage<FatPack.Template> fatPacks;
|
||||||
private IStorage<BoosterBox.Template> boosterBoxes;
|
private IStorage<BoosterBox.Template> boosterBoxes;
|
||||||
private IStorage<PrintSheet> printSheets;
|
private IStorage<PrintSheet> printSheets;
|
||||||
|
private final Map<String, List<String>> setLookup = new HashMap<>();
|
||||||
|
|
||||||
private static StaticData lastInstance = null;
|
private static StaticData lastInstance = null;
|
||||||
|
|
||||||
public StaticData(CardStorageReader cardReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, String cardArtPreference, boolean enableUnknownCards, boolean loadNonLegalCards) {
|
public StaticData(CardStorageReader cardReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, String setLookupFolder, String cardArtPreference, boolean enableUnknownCards, boolean loadNonLegalCards) {
|
||||||
this(cardReader, null, customCardReader, editionFolder, customEditionsFolder, blockDataFolder, cardArtPreference, enableUnknownCards, loadNonLegalCards, false, false);
|
this(cardReader, null, customCardReader, editionFolder, customEditionsFolder, blockDataFolder, setLookupFolder, cardArtPreference, enableUnknownCards, loadNonLegalCards, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticData(CardStorageReader cardReader, CardStorageReader tokenReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, String cardArtPreference, boolean enableUnknownCards, boolean loadNonLegalCards, boolean allowCustomCardsInDecksConformance){
|
public StaticData(CardStorageReader cardReader, CardStorageReader tokenReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, String setLookupFolder, String cardArtPreference, boolean enableUnknownCards, boolean loadNonLegalCards, boolean allowCustomCardsInDecksConformance){
|
||||||
this(cardReader, tokenReader, customCardReader, editionFolder, customEditionsFolder, blockDataFolder, cardArtPreference, enableUnknownCards, loadNonLegalCards, allowCustomCardsInDecksConformance, false);
|
this(cardReader, tokenReader, customCardReader, editionFolder, customEditionsFolder, blockDataFolder, setLookupFolder, cardArtPreference, enableUnknownCards, loadNonLegalCards, allowCustomCardsInDecksConformance, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticData(CardStorageReader cardReader, CardStorageReader tokenReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, String cardArtPreference, boolean enableUnknownCards, boolean loadNonLegalCards, boolean allowCustomCardsInDecksConformance, boolean enableSmartCardArtSelection) {
|
public StaticData(CardStorageReader cardReader, CardStorageReader tokenReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, String setLookupFolder, String cardArtPreference, boolean enableUnknownCards, boolean loadNonLegalCards, boolean allowCustomCardsInDecksConformance, boolean enableSmartCardArtSelection) {
|
||||||
this.cardReader = cardReader;
|
this.cardReader = cardReader;
|
||||||
this.tokenReader = tokenReader;
|
this.tokenReader = tokenReader;
|
||||||
this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder)));
|
this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder)));
|
||||||
@@ -143,12 +145,24 @@ public class StaticData {
|
|||||||
} else {
|
} else {
|
||||||
allTokens = null;
|
allTokens = null;
|
||||||
}
|
}
|
||||||
|
//initialize setLookup
|
||||||
|
if (FileUtil.isDirectoryWithFiles(setLookupFolder)){
|
||||||
|
for (File f : Objects.requireNonNull(new File(setLookupFolder).listFiles())){
|
||||||
|
if (f.isFile()) {
|
||||||
|
setLookup.put(f.getName().replace(".txt",""), FileUtil.readFile(f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StaticData instance() {
|
public static StaticData instance() {
|
||||||
return lastInstance;
|
return lastInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, List<String>> getSetLookup() {
|
||||||
|
return setLookup;
|
||||||
|
}
|
||||||
|
|
||||||
public final CardEdition.Collection getEditions() {
|
public final CardEdition.Collection getEditions() {
|
||||||
return this.editions;
|
return this.editions;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class CardDatabaseHelper {
|
|||||||
customReader = null;
|
customReader = null;
|
||||||
}
|
}
|
||||||
staticData = new StaticData(reader, customReader, ForgeConstants.EDITIONS_DIR,
|
staticData = new StaticData(reader, customReader, ForgeConstants.EDITIONS_DIR,
|
||||||
ForgeConstants.USER_CUSTOM_EDITIONS_DIR ,ForgeConstants.BLOCK_DATA_DIR,
|
ForgeConstants.USER_CUSTOM_EDITIONS_DIR ,ForgeConstants.BLOCK_DATA_DIR, ForgeConstants.SETLOOKUP_DIR,
|
||||||
"Latest Art All Editions",
|
"Latest Art All Editions",
|
||||||
true,
|
true,
|
||||||
false);
|
false);
|
||||||
|
|||||||
73
forge-gui/res/setlookup/J21.txt
Normal file
73
forge-gui/res/setlookup/J21.txt
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
AFR
|
||||||
|
MH2
|
||||||
|
STX
|
||||||
|
TSR
|
||||||
|
KHM
|
||||||
|
CMR
|
||||||
|
KLR
|
||||||
|
ZNC
|
||||||
|
ZNR
|
||||||
|
AKR
|
||||||
|
ANB
|
||||||
|
2XM
|
||||||
|
JMP
|
||||||
|
M21
|
||||||
|
IKO
|
||||||
|
C20
|
||||||
|
THB
|
||||||
|
SLD
|
||||||
|
GN2
|
||||||
|
ELD
|
||||||
|
C19
|
||||||
|
M20
|
||||||
|
MH1
|
||||||
|
WAR
|
||||||
|
GK2
|
||||||
|
RNA
|
||||||
|
UMA
|
||||||
|
GK1
|
||||||
|
GRN
|
||||||
|
C18
|
||||||
|
M19
|
||||||
|
BBD
|
||||||
|
CM2
|
||||||
|
DOM
|
||||||
|
A25
|
||||||
|
RIX
|
||||||
|
IMA
|
||||||
|
DDT
|
||||||
|
XLN
|
||||||
|
HOU
|
||||||
|
AKH
|
||||||
|
MM3
|
||||||
|
AER
|
||||||
|
PCA
|
||||||
|
DDR
|
||||||
|
CN2
|
||||||
|
SOI
|
||||||
|
W16
|
||||||
|
DDQ
|
||||||
|
OGW
|
||||||
|
BFZ
|
||||||
|
ORI
|
||||||
|
MM2
|
||||||
|
DTK
|
||||||
|
FRF
|
||||||
|
KTK
|
||||||
|
EMN
|
||||||
|
M15
|
||||||
|
VMA
|
||||||
|
THS
|
||||||
|
M14
|
||||||
|
DGM
|
||||||
|
GTC
|
||||||
|
ISD
|
||||||
|
MBS
|
||||||
|
MOR
|
||||||
|
LRW
|
||||||
|
10E
|
||||||
|
LGN
|
||||||
|
ONS
|
||||||
|
PCY
|
||||||
|
P02
|
||||||
|
WTH
|
||||||
@@ -32,6 +32,7 @@ public final class ForgeConstants {
|
|||||||
|
|
||||||
public static final String RES_DIR = ASSETS_DIR + "res" + PATH_SEPARATOR;
|
public static final String RES_DIR = ASSETS_DIR + "res" + PATH_SEPARATOR;
|
||||||
public static final String LISTS_DIR = RES_DIR + "lists" + PATH_SEPARATOR;
|
public static final String LISTS_DIR = RES_DIR + "lists" + PATH_SEPARATOR;
|
||||||
|
public static final String SETLOOKUP_DIR = RES_DIR + "setlookup" + PATH_SEPARATOR;
|
||||||
public static final String KEYWORD_LIST_FILE = LISTS_DIR + "NonStackingKWList.txt";
|
public static final String KEYWORD_LIST_FILE = LISTS_DIR + "NonStackingKWList.txt";
|
||||||
public static final String TYPE_LIST_FILE = LISTS_DIR + "TypeLists.txt";
|
public static final String TYPE_LIST_FILE = LISTS_DIR + "TypeLists.txt";
|
||||||
public static final String PLANESWALKER_ACHIEVEMENT_LIST_FILE = LISTS_DIR + "planeswalker-achievements.txt";
|
public static final String PLANESWALKER_ACHIEVEMENT_LIST_FILE = LISTS_DIR + "planeswalker-achievements.txt";
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public final class FModel {
|
|||||||
customReader = null;
|
customReader = null;
|
||||||
}
|
}
|
||||||
magicDb = new StaticData(reader, tokenReader, customReader, ForgeConstants.EDITIONS_DIR,
|
magicDb = new StaticData(reader, tokenReader, customReader, ForgeConstants.EDITIONS_DIR,
|
||||||
ForgeConstants.USER_CUSTOM_EDITIONS_DIR, ForgeConstants.BLOCK_DATA_DIR,
|
ForgeConstants.USER_CUSTOM_EDITIONS_DIR, ForgeConstants.BLOCK_DATA_DIR, ForgeConstants.SETLOOKUP_DIR,
|
||||||
FModel.getPreferences().getPref(FPref.UI_PREFERRED_ART),
|
FModel.getPreferences().getPref(FPref.UI_PREFERRED_ART),
|
||||||
FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS),
|
FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS),
|
||||||
FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS),
|
FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS),
|
||||||
|
|||||||
Reference in New Issue
Block a user