Package VASSAL.preferences
Class Prefs
java.lang.Object
VASSAL.preferences.Prefs
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
GlobalPrefs
public class Prefs extends Object implements Closeable
A set of preferences. Each set of preferences is identified by a name, and different sets may share a common editor,
which is responsible for writing the preferences to disk.
See also:
See also:
GlobalOptions - main nexus for preferences being added-
Field Summary
Fields Modifier and Type Field Description static StringDISABLE_D3Dstatic StringMAIN_WINDOW_HEIGHTstatic StringMAIN_WINDOW_REMEMBERstatic StringMAIN_WINDOW_WIDTHstatic StringMODULES_DIR_KEYPreferences key for the directory containing modules -
Constructor Summary
Constructors Modifier Constructor Description protectedPrefs(PrefsEditor editor, File file)Prefs(PrefsEditor editor, String name) -
Method Summary
Modifier and Type Method Description voidaddOption(String category, Configurer o)voidaddOption(String category, Configurer o, String prompt)Add a configurable property to the preferences in the given categoryvoidaddOption(Configurer o)voidclose()PrefsEditorgetEditor()FilegetFile()static PrefsgetGlobalPrefs()A global set of preferences that exists independent of any individual module.ConfigurergetOption(String s)StringgetStoredValue(String key)Return the value of a given preference.ObjectgetValue(String key)static voidinitSharedGlobalPrefs()Initialize visible Global Preferences that are shared between the Module Manager and the Editor/Player.booleanisDisableAutoWrite()protected voidread()static Stringsanitize(String str)voidsave()Store this set of preferencesvoidsetDisableAutoWrite(boolean b)voidsetValue(String option, Object value)voidwrite()Save these preferences and write to disk.
-
Field Details
-
MODULES_DIR_KEY
Preferences key for the directory containing modules- See Also:
- Constant Field Values
-
DISABLE_D3D
- See Also:
- Constant Field Values
-
MAIN_WINDOW_REMEMBER
- See Also:
- Constant Field Values
-
MAIN_WINDOW_HEIGHT
- See Also:
- Constant Field Values
-
MAIN_WINDOW_WIDTH
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Prefs
-
Prefs
-
-
Method Details
-
getEditor
-
getFile
-
isDisableAutoWrite
public boolean isDisableAutoWrite()- Returns:
- false -> overridden by GlobalPrefs
-
setDisableAutoWrite
public void setDisableAutoWrite(boolean b)- Parameters:
b- - no action taken -> overridden by GlobalPrefs
-
addOption
-
addOption
-
addOption
Add a configurable property to the preferences in the given category- Parameters:
category- the tab under which to add the Configurer's controls in the editor window. If null, do not add controls.prompt- If non-null and the value was not read from the preferences file on initialization (i.e. first-time setup), prompt the user for an initial value
-
setValue
-
getOption
-
getValue
- Parameters:
key- Pref Key- Returns:
- the value of the preferences setting stored under key
-
getStoredValue
Return the value of a given preference.- Parameters:
key- the name of the preference to retrieve- Returns:
- the value of this option read from the Preferences file at startup, or
nullif no value is undefined
-
sanitize
-
read
protected void read() -
save
Store this set of preferences- Throws:
IOException
-
write
Save these preferences and write to disk.- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getGlobalPrefs
A global set of preferences that exists independent of any individual module.- Returns:
- the global
Prefsobject
-