Skip to content

Commit

Permalink
Move prefs set up to GlobalOptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
riverwanderer committed Sep 25, 2023
1 parent e8ac208 commit c1936a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
19 changes: 19 additions & 0 deletions vassal-app/src/main/java/VASSAL/build/module/GlobalOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import VASSAL.configure.FormattedStringConfigurer;
import VASSAL.configure.IconConfigurer;
import VASSAL.configure.IntConfigurer;
import VASSAL.configure.StringConfigurer;
import VASSAL.configure.StringEnum;
import VASSAL.i18n.Resources;
import VASSAL.launch.AbstractLaunchAction;
Expand Down Expand Up @@ -336,6 +337,24 @@ public void addTo(Buildable parent) {
Boolean.FALSE);
soundGlobalMuteConf.addPropertyChangeListener(evt -> setSoundGlobalMute(soundGlobalMuteConf.getValueBoolean()));
prefs.addOption(Resources.getString("Prefs.sounds_tab"), soundGlobalMuteConf);

////////////////
// RESERVED USER PREFS STORED HIDDEN - FACILITATES USER-SPECIFIC CONTROL INTERFACE
// Standardised here so that Designers will be able to use Set Global Property trait without further set up.
// Defined here so that the property set up occurs
////////////////

// PlayerRoster control features
final BooleanConfigurer VassalRandomSideCfg = new BooleanConfigurer("VassalRandomSide", "", false);
prefs.addOption(null, VassalRandomSideCfg);

StringConfigurer VassalForceSideCfg = new StringConfigurer("VassalForceSide", "", null);
prefs.addOption(null, VassalForceSideCfg);

// Initialise values that are intended to be transient within a module
prefs.setValue("VassalRandomSide", false);
prefs.setValue("VassalForceSide", "");

}

/**
Expand Down
20 changes: 0 additions & 20 deletions vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
import VASSAL.command.Command;
import VASSAL.command.CommandEncoder;
import VASSAL.command.Logger;
import VASSAL.configure.BooleanConfigurer;
import VASSAL.configure.ComponentDescription;
import VASSAL.configure.ConfigureTree;
import VASSAL.configure.StringArrayConfigurer;
import VASSAL.configure.StringConfigurer;
import VASSAL.configure.StringEnumConfigurer;
import VASSAL.configure.ValidationReport;
import VASSAL.configure.ValidityChecker;
Expand All @@ -40,7 +38,6 @@
import VASSAL.i18n.Localization;
import VASSAL.i18n.Resources;
import VASSAL.i18n.Translation;
import VASSAL.preferences.Prefs;
import VASSAL.tools.DataArchive;
import VASSAL.tools.LaunchButton;
import VASSAL.tools.NamedKeyStroke;
Expand Down Expand Up @@ -266,23 +263,6 @@ public Class<?>[] getAllowableConfigureComponents() {
@Override
public void addTo(Buildable b) {
final GameModule gm = GameModule.getGameModule();
final Prefs pr = gm.getPrefs();

// Module control features: set required string prefs so that module designers don't need to.
// Designers will be able to use Set Global Property without further set up.
final String Demo = "Demo";
final BooleanConfigurer bConfig = new BooleanConfigurer(VassalRandomSide, "Random", false);
pr.addOption(Demo, bConfig);
StringConfigurer sConfig = new StringConfigurer(VassalForceSide, "Force", null);
pr.addOption(Demo, sConfig);
// testing this works
sConfig = new StringConfigurer("TestCfg", "Test Cfg", "this tests out lovely");
pr.addOption(Demo, sConfig);
sConfig = new StringConfigurer("TestCfg2", "Test Cfg2", "this tests out better");
pr.addOption(Demo, sConfig);
// Initialise otherwise values might persist
pr.setValue(VassalRandomSide, false);
pr.setValue(VassalForceSide, "");

gm.getGameState().addGameComponent(this);
gm.getGameState().addGameSetupStep(this);
Expand Down

0 comments on commit c1936a2

Please sign in to comment.