Package VASSAL.preferences
Class Prefs
java.lang.Object
VASSAL.preferences.Prefs
- All Implemented Interfaces:
Closeable,AutoCloseable
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
-
Field Summary
Fields Modifier and Type Field Description static StringDISABLE_D3Dstatic 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.protected voidread()static Stringsanitize(String str)voidsave()Store this set of preferencesvoidsetValue(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
-
-
Constructor Details
-
Prefs
-
Prefs
-
-
Method Details
-
getEditor
-
getFile
-
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-- 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
-