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 Details

  • Constructor Details

  • Method Details

    • getEditor

      public PrefsEditor getEditor()
    • getFile

      public File getFile()
    • addOption

      public void addOption​(Configurer o)
    • addOption

      public void addOption​(String category, Configurer o)
    • addOption

      public void addOption​(String category, Configurer o, String prompt)
      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

      public void setValue​(String option, Object value)
    • getOption

      public Configurer getOption​(String s)
    • getValue

      public Object getValue​(String key)
      Parameters:
      key -
      Returns:
      the value of the preferences setting stored under key
    • getStoredValue

      public String getStoredValue​(String key)
      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 null if no value is undefined
    • sanitize

      public static String sanitize​(String str)
    • read

      protected void read()
    • save

      public void save() throws IOException
      Store this set of preferences
      Throws:
      IOException
    • write

      public void write() throws IOException
      Save these preferences and write to disk.
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getGlobalPrefs

      public static Prefs getGlobalPrefs()
      A global set of preferences that exists independent of any individual module.
      Returns:
      the global Prefs object
    • initSharedGlobalPrefs

      public static void initSharedGlobalPrefs()
      Initialize visible Global Preferences that are shared between the Module Manager and the Editor/Player.