Add option to enable/disable Non-Legal Cards

Playtest and Un-sets Cards
This commit is contained in:
Anthony Calosa
2021-03-03 22:29:44 +08:00
parent ff4803c506
commit 36e55ae72f
14 changed files with 60 additions and 10 deletions

View File

@@ -54,11 +54,11 @@ public class StaticData {
private static StaticData lastInstance = null; private static StaticData lastInstance = null;
public StaticData(CardStorageReader cardReader, String editionFolder, String blockDataFolder, boolean enableUnknownCards) { public StaticData(CardStorageReader cardReader, String editionFolder, String blockDataFolder, boolean enableUnknownCards, boolean loadNonLegalCards) {
this(cardReader, null, editionFolder, blockDataFolder, enableUnknownCards); this(cardReader, null, editionFolder, blockDataFolder, enableUnknownCards, loadNonLegalCards);
} }
public StaticData(CardStorageReader cardReader, CardStorageReader tokenReader, String editionFolder, String blockDataFolder, boolean enableUnknownCards) { public StaticData(CardStorageReader cardReader, CardStorageReader tokenReader, String editionFolder, String blockDataFolder, boolean enableUnknownCards, boolean loadNonLegalCards) {
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)));
@@ -84,8 +84,8 @@ public class StaticData {
variantCards = new CardDb(variantsCards, editions); variantCards = new CardDb(variantsCards, editions);
//must initialize after establish field values for the sake of card image logic //must initialize after establish field values for the sake of card image logic
commonCards.initialize(false, false, enableUnknownCards); commonCards.initialize(false, false, enableUnknownCards, loadNonLegalCards);
variantCards.initialize(false, false, enableUnknownCards); variantCards.initialize(false, false, enableUnknownCards, loadNonLegalCards);
} }
{ {

View File

@@ -166,7 +166,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
reIndex(); reIndex();
} }
public void initialize(boolean logMissingPerEdition, boolean logMissingSummary, boolean enableUnknownCards) { public void initialize(boolean logMissingPerEdition, boolean logMissingSummary, boolean enableUnknownCards, boolean loadNonLegalCards) {
Set<String> allMissingCards = new LinkedHashSet<>(); Set<String> allMissingCards = new LinkedHashSet<>();
List<String> missingCards = new ArrayList<>(); List<String> missingCards = new ArrayList<>();
CardEdition upcomingSet = null; CardEdition upcomingSet = null;
@@ -184,6 +184,11 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
for (CardEdition.CardInSet cis : e.getAllCardsInSet()) { for (CardEdition.CardInSet cis : e.getAllCardsInSet()) {
CardRules cr = rulesByName.get(cis.name); CardRules cr = rulesByName.get(cis.name);
if (cr != null && !cr.getType().isBasicLand() && !loadNonLegalCards
&& (e.getCode().equals("CMB1") ||e.getCode().equals("UGL")
||e.getCode().equals("UNH")||e.getCode().equals("UND")||e.getCode().equals("UST")))
continue; //todo sets with nonlegal cards should have tags in them so we don't need to specify the code here
if (cr != null) { if (cr != null) {
addSetCard(e, cis, cr); addSetCard(e, cis, cr);
} }

View File

@@ -128,6 +128,7 @@ public enum CSubmenuPreferences implements ICDoc {
lstControls.add(Pair.of(view.getCbSingletons(), FPref.DECKGEN_SINGLETONS)); lstControls.add(Pair.of(view.getCbSingletons(), FPref.DECKGEN_SINGLETONS));
lstControls.add(Pair.of(view.getCbEnableAICheats(), FPref.UI_ENABLE_AI_CHEATS)); lstControls.add(Pair.of(view.getCbEnableAICheats(), FPref.UI_ENABLE_AI_CHEATS));
lstControls.add(Pair.of(view.getCbEnableUnknownCards(), FPref.UI_LOAD_UNKNOWN_CARDS)); lstControls.add(Pair.of(view.getCbEnableUnknownCards(), FPref.UI_LOAD_UNKNOWN_CARDS));
lstControls.add(Pair.of(view.getCbEnableNonLegalCards(), FPref.UI_LOAD_NONLEGAL_CARDS));
lstControls.add(Pair.of(view.getCbUseExperimentalNetworkStream(), FPref.UI_NETPLAY_COMPAT)); lstControls.add(Pair.of(view.getCbUseExperimentalNetworkStream(), FPref.UI_NETPLAY_COMPAT));
lstControls.add(Pair.of(view.getCbImageFetcher(), FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER)); lstControls.add(Pair.of(view.getCbImageFetcher(), FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER));
lstControls.add(Pair.of(view.getCbDisplayFoil(), FPref.UI_OVERLAY_FOIL_EFFECT)); lstControls.add(Pair.of(view.getCbDisplayFoil(), FPref.UI_OVERLAY_FOIL_EFFECT));

View File

@@ -109,6 +109,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final JCheckBox cbRemindOnPriority = new OptionsCheckBox(localizer.getMessage("cbRemindOnPriority")); private final JCheckBox cbRemindOnPriority = new OptionsCheckBox(localizer.getMessage("cbRemindOnPriority"));
private final JCheckBox cbUseSentry = new OptionsCheckBox(localizer.getMessage("cbUseSentry")); private final JCheckBox cbUseSentry = new OptionsCheckBox(localizer.getMessage("cbUseSentry"));
private final JCheckBox cbEnableUnknownCards = new OptionsCheckBox(localizer.getMessage("lblEnableUnknownCards")); private final JCheckBox cbEnableUnknownCards = new OptionsCheckBox(localizer.getMessage("lblEnableUnknownCards"));
private final JCheckBox cbEnableNonLegalCards = new OptionsCheckBox(localizer.getMessage("lblEnableNonLegalCards"));
private final JCheckBox cbUseExperimentalNetworkStream = new OptionsCheckBox(localizer.getMessage("lblExperimentalNetworkCompatibility")); private final JCheckBox cbUseExperimentalNetworkStream = new OptionsCheckBox(localizer.getMessage("lblExperimentalNetworkCompatibility"));
private final Map<FPref, KeyboardShortcutField> shortcutFields = new HashMap<>(); private final Map<FPref, KeyboardShortcutField> shortcutFields = new HashMap<>();
@@ -297,6 +298,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbEnableUnknownCards, titleConstraints); pnlPrefs.add(cbEnableUnknownCards, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlEnableUnknownCards")), descriptionConstraints); pnlPrefs.add(new NoteLabel(localizer.getMessage("nlEnableUnknownCards")), descriptionConstraints);
pnlPrefs.add(cbEnableNonLegalCards, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlEnableNonLegalCards")), descriptionConstraints);
pnlPrefs.add(cbUseExperimentalNetworkStream, titleConstraints); pnlPrefs.add(cbUseExperimentalNetworkStream, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlExperimentalNetworkCompatibility")), descriptionConstraints); pnlPrefs.add(new NoteLabel(localizer.getMessage("nlExperimentalNetworkCompatibility")), descriptionConstraints);
@@ -598,6 +602,11 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbEnableUnknownCards; return cbEnableUnknownCards;
} }
/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getCbEnableNonLegalCards() {
return cbEnableNonLegalCards;
}
/** @return {@link javax.swing.JCheckBox} */ /** @return {@link javax.swing.JCheckBox} */
public JCheckBox getCbUseExperimentalNetworkStream() { public JCheckBox getCbUseExperimentalNetworkStream() {
return cbUseExperimentalNetworkStream; return cbUseExperimentalNetworkStream;

View File

@@ -29,7 +29,7 @@ public class CardDatabaseHelper {
private static void initialize() { private static void initialize() {
final CardStorageReader reader = new CardStorageReader(ForgeConstants.CARD_DATA_DIR, null, FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY)); final CardStorageReader reader = new CardStorageReader(ForgeConstants.CARD_DATA_DIR, null, FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY));
staticData = new StaticData(reader, ForgeConstants.EDITIONS_DIR, ForgeConstants.BLOCK_DATA_DIR, FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS)); staticData = new StaticData(reader, ForgeConstants.EDITIONS_DIR, ForgeConstants.BLOCK_DATA_DIR, FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS), FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS));
} }
private static boolean hasBeenInitialized() { private static boolean hasBeenInitialized() {

View File

@@ -256,8 +256,8 @@ public class SettingsPage extends TabPage<SettingsScreen> {
localizer.getMessage("lblLater"), new Callback<Boolean>() { localizer.getMessage("lblLater"), new Callback<Boolean>() {
@Override @Override
public void run(Boolean result) { public void run(Boolean result) {
if (result) { if (result) {
Forge.restart(true); Forge.restart(true);
} }
} }
} }
@@ -265,6 +265,28 @@ public class SettingsPage extends TabPage<SettingsScreen> {
} }
}, },
3); 3);
lstSettings.addItem(new BooleanSetting(FPref.UI_LOAD_NONLEGAL_CARDS,
localizer.getMessage("lblEnableNonLegalCards"),
localizer.getMessage("nlEnableNonLegalCards")) {
@Override
public void select() {
super.select();
FOptionPane.showConfirmDialog(
localizer.getMessage("lblRestartForgeDescription"),
localizer.getMessage("lblRestartForge"),
localizer.getMessage("lblRestart"),
localizer.getMessage("lblLater"), new Callback<Boolean>() {
@Override
public void run(Boolean result) {
if (result) {
Forge.restart(true);
}
}
}
);
}
},
3);
lstSettings.addItem(new BooleanSetting(FPref.UI_NETPLAY_COMPAT, lstSettings.addItem(new BooleanSetting(FPref.UI_NETPLAY_COMPAT,
localizer.getMessage("lblExperimentalNetworkCompatibility"), localizer.getMessage("lblExperimentalNetworkCompatibility"),
localizer.getMessage("nlExperimentalNetworkCompatibility")) { localizer.getMessage("nlExperimentalNetworkCompatibility")) {

View File

@@ -1009,6 +1009,8 @@ lblShowFPSDisplay=FPS-Anzeige
nlShowFPSDisplay=Aktiviert die Frames-per-second-Anzeige (Experimentell). nlShowFPSDisplay=Aktiviert die Frames-per-second-Anzeige (Experimentell).
lblEnableUnknownCards=Erlaube unbekannte Karten lblEnableUnknownCards=Erlaube unbekannte Karten
nlEnableUnknownCards=Erlaube unbekannte Karten von unbekannten Sets. (Erfordert Neustart) nlEnableUnknownCards=Erlaube unbekannte Karten von unbekannten Sets. (Erfordert Neustart)
lblEnableNonLegalCards=Enable Non-Legal Cards
nlEnableNonLegalCards=Enable Non-Legal Cards like Un-sets and PlayTest Cards. (Requires restart)
lblExperimentalNetworkCompatibility=Experimentelle Netzwerkkompatibilität lblExperimentalNetworkCompatibility=Experimentelle Netzwerkkompatibilität
nlExperimentalNetworkCompatibility=Forge wechselt auf kompatiblen Netzwerk-Stream. (Im Zweifel bitte ausschalten) nlExperimentalNetworkCompatibility=Forge wechselt auf kompatiblen Netzwerk-Stream. (Im Zweifel bitte ausschalten)
lblDisposeTextures=Texturen anordnen lblDisposeTextures=Texturen anordnen

View File

@@ -1009,6 +1009,8 @@ lblShowFPSDisplay=Show FPS Display
nlShowFPSDisplay=When enabled, show the FPS Display (Experimental). nlShowFPSDisplay=When enabled, show the FPS Display (Experimental).
lblEnableUnknownCards=Enable Unknown Cards lblEnableUnknownCards=Enable Unknown Cards
nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart) nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart)
lblEnableNonLegalCards=Enable Non-Legal Cards
nlEnableNonLegalCards=Enable Non-Legal Cards like Un-sets and PlayTest Cards. (Requires restart)
lblExperimentalNetworkCompatibility=Experimental Network Compatibility lblExperimentalNetworkCompatibility=Experimental Network Compatibility
nlExperimentalNetworkCompatibility=Forge switches to compatible network stream. (If unsure, turn OFF this option) nlExperimentalNetworkCompatibility=Forge switches to compatible network stream. (If unsure, turn OFF this option)
lblDisposeTextures=Dispose Textures lblDisposeTextures=Dispose Textures

View File

@@ -1009,6 +1009,8 @@ lblShowFPSDisplay=Mostrar FPS
nlShowFPSDisplay=Cuando está habilitado, muestra los FPS (Experimental). nlShowFPSDisplay=Cuando está habilitado, muestra los FPS (Experimental).
lblEnableUnknownCards=Habilitar cartas desconocidas lblEnableUnknownCards=Habilitar cartas desconocidas
nlEnableUnknownCards=Habilitar que las cartas desconocidas se carguen en el Unknown Set. (Requiere reinicio) nlEnableUnknownCards=Habilitar que las cartas desconocidas se carguen en el Unknown Set. (Requiere reinicio)
lblEnableNonLegalCards=Enable Non-Legal Cards
nlEnableNonLegalCards=Enable Non-Legal Cards like Un-sets and PlayTest Cards. (Requires restart)
lblExperimentalNetworkCompatibility=Compatibilidad de red experimental lblExperimentalNetworkCompatibility=Compatibilidad de red experimental
nlExperimentalNetworkCompatibility=Forge cambia a un flujo de red compatible. (Si no estás seguro, deshabilita esta opción) nlExperimentalNetworkCompatibility=Forge cambia a un flujo de red compatible. (Si no estás seguro, deshabilita esta opción)
lblDisposeTextures=Desechar texturas lblDisposeTextures=Desechar texturas

View File

@@ -1009,6 +1009,8 @@ lblShowFPSDisplay=Mostra display FPS
nlShowFPSDisplay=Se abilitato, mostra il display FPS (sperimentale). nlShowFPSDisplay=Se abilitato, mostra il display FPS (sperimentale).
lblEnableUnknownCards=Enable Unknown Cards lblEnableUnknownCards=Enable Unknown Cards
nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart) nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart)
lblEnableNonLegalCards=Enable Non-Legal Cards
nlEnableNonLegalCards=Enable Non-Legal Cards like Un-sets and PlayTest Cards. (Requires restart)
lblExperimentalNetworkCompatibility=Experimental Network Compatibility lblExperimentalNetworkCompatibility=Experimental Network Compatibility
nlExperimentalNetworkCompatibility=Forge switches to compatible network stream. (If unsure, turn OFF this option) nlExperimentalNetworkCompatibility=Forge switches to compatible network stream. (If unsure, turn OFF this option)
lblDisposeTextures=Dispose Textures lblDisposeTextures=Dispose Textures

View File

@@ -1009,6 +1009,8 @@ lblShowFPSDisplay=FPS ディスプレイを表示
nlShowFPSDisplay=有効にすると、FPS ディスプレイ(実験的)を表示します。 nlShowFPSDisplay=有効にすると、FPS ディスプレイ(実験的)を表示します。
lblEnableUnknownCards=未知のカードを有効にする lblEnableUnknownCards=未知のカードを有効にする
nlEnableUnknownCards=未知のカードを未知のセットにまとめます。(再起動必須) nlEnableUnknownCards=未知のカードを未知のセットにまとめます。(再起動必須)
lblEnableNonLegalCards=Enable Non-Legal Cards
nlEnableNonLegalCards=Enable Non-Legal Cards like Un-sets and PlayTest Cards. (Requires restart)
lblExperimentalNetworkCompatibility=実験的なネットワークコンパチビリティ lblExperimentalNetworkCompatibility=実験的なネットワークコンパチビリティ
nlExperimentalNetworkCompatibility=Forge がコンパチブルネットワークストリーミに切り替えます。 (分からない場合はオフにしてください) nlExperimentalNetworkCompatibility=Forge がコンパチブルネットワークストリーミに切り替えます。 (分からない場合はオフにしてください)
lblDisposeTextures=テキスチャー廃棄 lblDisposeTextures=テキスチャー廃棄

View File

@@ -1008,6 +1008,8 @@ lblShowFPSDisplay=显示当前的FPS值
nlShowFPSDisplay=启用后将在画面左上角显示当前Forge的FPS实验性特性 nlShowFPSDisplay=启用后将在画面左上角显示当前Forge的FPS实验性特性
lblEnableUnknownCards=启用未知卡牌 lblEnableUnknownCards=启用未知卡牌
nlEnableUnknownCards=将未知卡牌加载到未知系列中。(需要重启) nlEnableUnknownCards=将未知卡牌加载到未知系列中。(需要重启)
lblEnableNonLegalCards=Enable Non-Legal Cards
nlEnableNonLegalCards=Enable Non-Legal Cards like Un-sets and PlayTest Cards. (Requires restart)
lblExperimentalNetworkCompatibility=实验性网络兼容 lblExperimentalNetworkCompatibility=实验性网络兼容
nlExperimentalNetworkCompatibility=Forge将切换为兼容性的网络流。如果不清楚此选项的作用请关闭此选项 nlExperimentalNetworkCompatibility=Forge将切换为兼容性的网络流。如果不清楚此选项的作用请关闭此选项
lblDisposeTextures=释放纹理 lblDisposeTextures=释放纹理

View File

@@ -164,7 +164,7 @@ public final class FModel {
FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY)); FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY));
final CardStorageReader tokenReader = new CardStorageReader(ForgeConstants.TOKEN_DATA_DIR, progressBarBridge, final CardStorageReader tokenReader = new CardStorageReader(ForgeConstants.TOKEN_DATA_DIR, progressBarBridge,
FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY)); FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY));
magicDb = new StaticData(reader, tokenReader, ForgeConstants.EDITIONS_DIR, ForgeConstants.BLOCK_DATA_DIR, FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS)); magicDb = new StaticData(reader, tokenReader, ForgeConstants.EDITIONS_DIR, ForgeConstants.BLOCK_DATA_DIR, FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS), FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS));
CardTranslation.preloadTranslation(preferences.getPref(FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR); CardTranslation.preloadTranslation(preferences.getPref(FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR);
//create profile dirs if they don't already exist //create profile dirs if they don't already exist

View File

@@ -148,6 +148,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
UI_NETPLAY_COMPAT("false"), UI_NETPLAY_COMPAT("false"),
UI_ENABLE_DISPOSE_TEXTURES("false"), UI_ENABLE_DISPOSE_TEXTURES("false"),
UI_LOAD_UNKNOWN_CARDS("true"), UI_LOAD_UNKNOWN_CARDS("true"),
UI_LOAD_NONLEGAL_CARDS("true"),
UI_AUTO_CACHE_SIZE("false"), UI_AUTO_CACHE_SIZE("false"),
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"), UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),
UI_DEFAULT_FONT_SIZE("12"), UI_DEFAULT_FONT_SIZE("12"),