From 9082a89c59b37919e20f841386cb455b6c165674 Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Fri, 30 Mar 2018 07:49:54 +0100 Subject: [PATCH] Moved formats into separate folder so that additional custom format files can be added - added Pauper and Kaladesh_Standard as examples --- .../formats.txt => formats/coreformats.txt} | 0 forge-gui/res/formats/customformats.txt | 4 ++++ forge-gui/src/main/java/forge/model/FModel.java | 15 +++++++++++++-- .../java/forge/properties/ForgeConstants.java | 1 + forge-gui/tools/EditionTracking.py | 2 +- forge-gui/tools/PerSetTracking.py | 2 +- 6 files changed, 20 insertions(+), 4 deletions(-) rename forge-gui/res/{blockdata/formats.txt => formats/coreformats.txt} (100%) create mode 100644 forge-gui/res/formats/customformats.txt diff --git a/forge-gui/res/blockdata/formats.txt b/forge-gui/res/formats/coreformats.txt similarity index 100% rename from forge-gui/res/blockdata/formats.txt rename to forge-gui/res/formats/coreformats.txt diff --git a/forge-gui/res/formats/customformats.txt b/forge-gui/res/formats/customformats.txt new file mode 100644 index 00000000000..78e24e15de3 --- /dev/null +++ b/forge-gui/res/formats/customformats.txt @@ -0,0 +1,4 @@ +[Pauper] +Rarities:L, C +[Kaladesh_Standard] +Sets:KLD, AER, EMN, SOI, BFZ, OGW \ No newline at end of file diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index 32ee8cec852..4eebeb8db8b 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -166,8 +166,19 @@ public final class FModel { ForgePreferences.DEV_MODE = preferences.getPrefBoolean(FPref.DEV_MODE_ENABLED); ForgePreferences.UPLOAD_DRAFT = ForgePreferences.NET_CONN; - formats = new GameFormat.Collection(new GameFormat.Reader(new File(ForgeConstants.BLOCK_DATA_DIR + "formats.txt"))); - //add user custom formats if file present + + final File[] files = new File(ForgeConstants.FORMATS_DATA_DIR).listFiles(); + for (final File file : files) { + if(formats == null){ + formats = new GameFormat.Collection(new GameFormat.Reader(file)); + }else{ + GameFormat.Collection additionalformats = new GameFormat.Collection(new GameFormat.Reader(file)); + for (GameFormat format:additionalformats) { + formats.add(format); + } + } + } + //still support old user custom formats if file present GameFormat.Collection customFormats = new GameFormat.Collection(new GameFormat.Reader(new File(ForgeConstants.USER_PREFS_DIR + "customformats.txt"))); for (GameFormat format:customFormats){ formats.add(format); diff --git a/forge-gui/src/main/java/forge/properties/ForgeConstants.java b/forge-gui/src/main/java/forge/properties/ForgeConstants.java index effecd1e325..b66931f06e1 100644 --- a/forge-gui/src/main/java/forge/properties/ForgeConstants.java +++ b/forge-gui/src/main/java/forge/properties/ForgeConstants.java @@ -61,6 +61,7 @@ public final class ForgeConstants { public static final String TOKEN_DATA_DIR = RES_DIR + "tokenscripts" + PATH_SEPARATOR; public static final String EDITIONS_DIR = RES_DIR + "editions" + PATH_SEPARATOR; public static final String BLOCK_DATA_DIR = RES_DIR + "blockdata" + PATH_SEPARATOR; + public static final String FORMATS_DATA_DIR = RES_DIR + "formats" + PATH_SEPARATOR; public static final String DECK_CUBE_DIR = RES_DIR + "cube" + PATH_SEPARATOR; public static final String AI_PROFILE_DIR = RES_DIR + "ai" + PATH_SEPARATOR; public static final String SOUND_DIR = RES_DIR + "sound" + PATH_SEPARATOR; diff --git a/forge-gui/tools/EditionTracking.py b/forge-gui/tools/EditionTracking.py index 4e042f02100..aa5a97017b5 100644 --- a/forge-gui/tools/EditionTracking.py +++ b/forge-gui/tools/EditionTracking.py @@ -110,7 +110,7 @@ def initializeForgeCards(): def initializeFormats(): formats = {} - formatLocation = os.path.join(resDir, 'blockdata', 'formats.txt') + formatLocation = os.path.join(resDir, 'formats', 'coreformats.txt') print "Looking for formats in ", formatLocation with open(formatLocation) as formatFile: while formatFile: diff --git a/forge-gui/tools/PerSetTracking.py b/forge-gui/tools/PerSetTracking.py index b427dfe9981..523715a7beb 100644 --- a/forge-gui/tools/PerSetTracking.py +++ b/forge-gui/tools/PerSetTracking.py @@ -15,7 +15,7 @@ pathToMtgData = os.path.join(toolsDir, "mtg-data.txt") def initializeFormats(): formats = {} - formatLocation = os.path.join(resDir, 'blockdata', 'formats.txt') + formatLocation = os.path.join(resDir, 'formats', 'coreformats.txt') print "Looking for formats in ", formatLocation with open(formatLocation) as formatFile: while formatFile: