From fcb8e1f8c97b79bba5c5fa08b3dfa382de1fe4c4 Mon Sep 17 00:00:00 2001 From: "Jamin W. Collins" Date: Sat, 27 Jan 2018 08:53:54 -0700 Subject: [PATCH] allow for custom deck directory paths This adds support for two additional configuration options to the forge.profile.properties file: * decksDir * decksConstructedDir The first sets the desired path for all decks. The second sets the desired path specifically for constructed decks. This allows users to reference an external directory that may be synced between multiple users or systems by an external (to forge) mechanism. Signed-off-by: Jamin W. Collins --- .../java/forge/properties/ForgeConstants.java | 6 ++++-- .../properties/ForgeProfileProperties.java | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/forge-gui/src/main/java/forge/properties/ForgeConstants.java b/forge-gui/src/main/java/forge/properties/ForgeConstants.java index eb58b3e76ec..67b7cabb440 100644 --- a/forge-gui/src/main/java/forge/properties/ForgeConstants.java +++ b/forge-gui/src/main/java/forge/properties/ForgeConstants.java @@ -187,12 +187,16 @@ public final class ForgeConstants { public static final String CACHE_CARD_PICS_DIR; public static final Map CACHE_CARD_PICS_SUBDIR; public static final int SERVER_PORT_NUMBER; + public static final String DECK_BASE_DIR; + public static final String DECK_CONSTRUCTED_DIR; static { ForgeProfileProperties.load(); USER_DIR = ForgeProfileProperties.getUserDir(); CACHE_DIR = ForgeProfileProperties.getCacheDir(); CACHE_CARD_PICS_DIR = ForgeProfileProperties.getCardPicsDir(); CACHE_CARD_PICS_SUBDIR = Collections.unmodifiableMap(ForgeProfileProperties.getCardPicsSubDirs()); + DECK_BASE_DIR = ForgeProfileProperties.getDecksDir(); + DECK_CONSTRUCTED_DIR = ForgeProfileProperties.getDecksConstructedDir(); SERVER_PORT_NUMBER = ForgeProfileProperties.getServerPort(); } @@ -203,9 +207,7 @@ public final class ForgeConstants { public static final String USER_PREFS_DIR = USER_DIR + "preferences" + PATH_SEPARATOR; public static final String USER_GAMES_DIR = USER_DIR + "games" + PATH_SEPARATOR; public static final String LOG_FILE = USER_DIR + "forge.log"; - public static final String DECK_BASE_DIR = USER_DIR + "decks" + PATH_SEPARATOR; public static final String ACHIEVEMENTS_DIR = USER_DIR + "achievements" + PATH_SEPARATOR; - public static final String DECK_CONSTRUCTED_DIR = DECK_BASE_DIR + "constructed" + PATH_SEPARATOR; public static final String DECK_DRAFT_DIR = DECK_BASE_DIR + "draft" + PATH_SEPARATOR; public static final String DECK_WINSTON_DIR = DECK_BASE_DIR + "winston" + PATH_SEPARATOR; public static final String DECK_SEALED_DIR = DECK_BASE_DIR + "sealed" + PATH_SEPARATOR; diff --git a/forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java b/forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java index 8cc6b21690a..b5210d30179 100644 --- a/forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java +++ b/forge-gui/src/main/java/forge/properties/ForgeProfileProperties.java @@ -41,12 +41,16 @@ public class ForgeProfileProperties { private static String cacheDir; private static String cardPicsDir; private static Map cardPicsSubDirs; + private static String decksDir; + private static String decksConstructedDir; private static int serverPort; private static final String USER_DIR_KEY = "userDir"; private static final String CACHE_DIR_KEY = "cacheDir"; private static final String CARD_PICS_DIR_KEY = "cardPicsDir"; private static final String CARD_PICS_SUB_DIRS_KEY = "cardPicsSubDirs"; + private static final String DECKS_DIR_KEY = "decksDir"; + private static final String DECKS_CONSTRUCTED_DIR_KEY = "decksConstructedDir"; private static final String SERVER_PORT_KEY = "serverPort"; private ForgeProfileProperties() { @@ -69,6 +73,8 @@ public class ForgeProfileProperties { cacheDir = getDir(props, CACHE_DIR_KEY, defaults.getRight()); cardPicsDir = getDir(props, CARD_PICS_DIR_KEY, cacheDir + "pics" + File.separator + "cards" + File.separator); cardPicsSubDirs = getMap(props, CARD_PICS_SUB_DIRS_KEY); + decksDir = getDir(props, DECKS_DIR_KEY, userDir + "decks" + File.separator); + decksConstructedDir = getDir(props, DECKS_CONSTRUCTED_DIR_KEY, decksDir + "constructed" + File.separator);; serverPort = getInt(props, SERVER_PORT_KEY, 36743); // "Forge" using phone keypad //ensure directories exist @@ -109,6 +115,18 @@ public class ForgeProfileProperties { return cardPicsSubDirs; } + public static String getDecksDir() { return decksDir; } + public static void setDecksDir(final String decksDir0) { + decksDir = decksDir0; + save(); + } + + public static String getDecksConstructedDir() { return decksConstructedDir; } + public static void setDecksConstructedDir(final String decksConstructedDir0) { + decksConstructedDir = decksConstructedDir0; + save(); + } + public static int getServerPort() { return serverPort; }