Added optional customformats.txt file (to be put in the user preferences folder) to append formats to the regular list so that custom formats can be retained between upgrades

This commit is contained in:
austinio7116
2017-04-27 18:53:44 +00:00
parent b3a6403867
commit f5dbde0cf3
2 changed files with 13 additions and 0 deletions

View File

@@ -280,6 +280,11 @@ public class GameFormat implements Comparable<GameFormat> {
} }
return result; return result;
} }
@Override
public void add(GameFormat item) {
naturallyOrdered.add(item);
}
} }
public final Predicate<CardEdition> editionLegalPredicate = new Predicate<CardEdition>() { public final Predicate<CardEdition> editionLegalPredicate = new Predicate<CardEdition>() {

View File

@@ -93,6 +93,8 @@ public final class FModel {
private static IStorage<QuestWorld> worlds; private static IStorage<QuestWorld> worlds;
private static GameFormat.Collection formats; private static GameFormat.Collection formats;
private static GameFormat.Collection customFormats;
public static void initialize(final IProgressBar progressBar, Function<ForgePreferences, Void> adjustPrefs) { public static void initialize(final IProgressBar progressBar, Function<ForgePreferences, Void> adjustPrefs) {
ImageKeys.initializeDirs( ImageKeys.initializeDirs(
ForgeConstants.CACHE_CARD_PICS_DIR, ForgeConstants.CACHE_CARD_PICS_SUBDIR, ForgeConstants.CACHE_CARD_PICS_DIR, ForgeConstants.CACHE_CARD_PICS_SUBDIR,
@@ -162,6 +164,12 @@ public final class FModel {
ForgePreferences.UPLOAD_DRAFT = ForgePreferences.NET_CONN; ForgePreferences.UPLOAD_DRAFT = ForgePreferences.NET_CONN;
formats = new GameFormat.Collection(new GameFormat.Reader(new File(ForgeConstants.BLOCK_DATA_DIR + "formats.txt"))); formats = new GameFormat.Collection(new GameFormat.Reader(new File(ForgeConstants.BLOCK_DATA_DIR + "formats.txt")));
//add user custom formats if file present
customFormats = new GameFormat.Collection(new GameFormat.Reader(new File(ForgeConstants.USER_PREFS_DIR + "customformats.txt")));
for (GameFormat format:customFormats){
formats.add(format);
}
blocks = new StorageBase<>("Block definitions", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", magicDb.getEditions())); blocks = new StorageBase<>("Block definitions", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", magicDb.getEditions()));
questPreferences = new QuestPreferences(); questPreferences = new QuestPreferences();
conquestPreferences = new ConquestPreferences(); conquestPreferences = new ConquestPreferences();