Class GlobalOptions

All Implemented Interfaces:
AutoConfigurable, Buildable, Configurable, PropertyNameSource, ComponentDescription, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget

public class GlobalOptions extends AbstractConfigurable implements ComponentDescription
GlobalOptions is a junction point for several flavors of "preferences"-related categories. It also configures the toolbar buttons basic VASSAL functions: Undo, Step Forward, and show/hide Servers. Global Options is a Singleton.
(1) Its attributes, set in the Editor, control the module-designer-set "hybrid preference" categories (Allowing non-owners to unmask pieces, Enabling HTML chat, format of player ID in reports), determining whether the preference in question is forced on or off, or whether a player preference is used.
(2) Its sub-components allow the module designer to "create custom preferences" which appear in their own tab.
(3) Many of its fields, configured mostly in the addTo(VASSAL.build.Buildable) method, supply the majority of the preferences shown on the "General" tab, though some of that tab's preferences are also set elsewhere -- see:
Prefs - reading/writing the preference file, maintaining lists of configurers for tabs
Prefs.initSharedGlobalPrefs() - disable d3d pipeline, wizard support
BasicLogger - configurers for Undo and Step Forward. Adds logging-related preferences to pane
AdjustableSpeedScrollPane - scroll increment
  • Field Details

  • Constructor Details

    • GlobalOptions

      public GlobalOptions()
  • Method Details

    • getInstance

      public static GlobalOptions getInstance()
      Returns:
      our singleton instance
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface ComponentDescription
      Returns:
      Description to be displayed next to component type/name in the main Editor window. Or null or "" to not display anything.
    • addTo

      public void addTo(Buildable parent)
      GlobalOptions are added to the GameModule. This method creates the configurers for the "General" tab of the preference dialog, and some for the "Compatibility" tab.
      Specified by:
      addTo in interface Buildable
      Parameters:
      parent - our GameModule object
    • isForceNonNativeDrag

      public boolean isForceNonNativeDrag()
      Returns:
      true if we're forcing use of non-native drag and drop cursor
    • isUseSingleWindow

      public boolean isUseSingleWindow()
      Returns:
      true if preference to dock first map window to main module window with Chatter is selected
    • isUseClassicMoveFixedDistance

      public boolean isUseClassicMoveFixedDistance()
      Returns:
      true if compatibility version of Move Fixed Distance is selected
    • setUseClassicMoveFixedDistance

      public void setUseClassicMoveFixedDistance(boolean b)
      Parameters:
      b - sets the compatibility Move Fixed Distance preference
    • setPrefMacLegacy

      public void setPrefMacLegacy(boolean b)
      Parameters:
      b - sets the Mac Legacy compatibility preference
    • getPrefMacLegacy

      public boolean getPrefMacLegacy()
      Returns:
      the Mac Legacy compatibility preference
    • setWarnOldContinuation

      public void setWarnOldContinuation(boolean b)
      Parameters:
      b - sets the warnOldContinuation compatibility preference
    • isWarnOldContinuation

      public boolean isWarnOldContinuation()
      Returns:
      the warnOldContinuation compatibility preference
    • setSoundGlobalMute

      public void setSoundGlobalMute(Boolean b)
      Parameters:
      b - sets the global sound mute preference
    • isSoundGlobalMute

      public Boolean isSoundGlobalMute()
      Returns:
      true if sounds should be muted globally
    • setSoundWakeupMute

      public void setSoundWakeupMute(Boolean b)
      Parameters:
      b - sets the mute for the wake-up sound
    • isSoundWakeupMute

      public Boolean isSoundWakeupMute()
      Returns:
      true if the wake-up sound should be muted
    • getConfigureTypeName

      public static String getConfigureTypeName()
      Returns:
      component name to be displayed in the editor, e.g. [Global Options]
    • getAllowableConfigureComponents

      public Class<?>[] getAllowableConfigureComponents()
      Specified by:
      getAllowableConfigureComponents in interface Configurable
      Returns:
      classes allowed to be added as subcomponents (in this case, custom preferences)
    • getAttributeDescriptions

      public String[] getAttributeDescriptions()
      Description copied from interface: AutoConfigurable
      Return an array of Strings describing the attributes of this object. These strings are used as prompts in the Properties window for this object.
      Specified by:
      getAttributeDescriptions in interface AutoConfigurable
      Specified by:
      getAttributeDescriptions in class AbstractConfigurable
      Returns:
      Display strings describing attributes available for configuration
    • getAttributeNames

      public String[] getAttributeNames()
      Description copied from class: AbstractBuildable
      Lists all the buildFile (XML) attribute names for this component. If this component is ALSO an AbstractConfigurable, then this list of attributes determines the appropriate attribute order for AbstractConfigurable.getAttributeDescriptions() and AbstractConfigurable.getAttributeTypes().
      Specified by:
      getAttributeNames in interface AutoConfigurable
      Specified by:
      getAttributeNames in class AbstractBuildable
      Returns:
      Attribute keys for XML buildFile
    • getAttributeTypes

      public Class<?>[] getAttributeTypes()
      Description copied from interface: AutoConfigurable
      Return the Class for the attributes of this object. Valid classes are: String, Integer, Double, Boolean, Image, File, Color, and KeyStroke
      Specified by:
      getAttributeTypes in interface AutoConfigurable
      Specified by:
      getAttributeTypes in class AbstractConfigurable
      Returns:
      configurer classes for our attributes
    • addOption

      public void addOption(Configurer option)
      Components may use GlobalOptions to store generic global attributes. This method registers the given key as an attribute of the GlobalOptions with the given type.
      Parameters:
      option - - configurer to add
    • build

      public void build(Element e)
      Builds our component from the buildFile. In our case it mainly involves checkout for subcomponents which represent "custom preferences" and appropriately creating configurers and a preferences tab for them.
      Specified by:
      build in interface Buildable
      Overrides:
      build in class AbstractBuildable
      Parameters:
      e - our XML element from the buildFile
    • getBuildElement

      public Element getBuildElement(Document doc)
      Packages any "custom preferences" back up into XML for the buildFile
      Specified by:
      getBuildElement in interface Buildable
      Overrides:
      getBuildElement in class AbstractBuildable
      Parameters:
      doc - the XML document we are writing to
      Returns:
      XML Element
    • getConfigurer

      public Configurer getConfigurer()
      Description copied from class: AbstractConfigurable
      The default Configurer of an AbstractConfigurable class is an instance of AutoConfigurer
      Specified by:
      getConfigurer in interface Configurable
      Overrides:
      getConfigurer in class AbstractConfigurable
      Returns:
      a configurer including all custom preferences
    • getAttributeValueString

      public String getAttributeValueString(String key)
      Returns current setting of an attribute in String form
      Specified by:
      getAttributeValueString in interface AutoConfigurable
      Specified by:
      getAttributeValueString in interface Translatable
      Specified by:
      getAttributeValueString in class AbstractBuildable
      Parameters:
      key - the name of the attribute. Will be one of those listed in getAttributeNames()
      Returns:
      String value of attribute
    • getHelpFile

      public HelpFile getHelpFile()
      Specified by:
      getHelpFile in interface Configurable
      Returns:
      Help file to be used on this component's configuration dialog
    • removeFrom

      public void removeFrom(Buildable parent)
      Removes us from our parent component
      Specified by:
      removeFrom in interface Configurable
      Parameters:
      parent - our parent (GameModule)
    • setAttribute

      public void setAttribute(String key, Object value)
      Sets a new value for one of our attributes. Some special attention is needed when one of the designer-controlled attributes changes, as it may necessitate the showing/hiding of a new user preference checkbox configurer
      Specified by:
      setAttribute in interface AutoConfigurable
      Specified by:
      setAttribute in interface Translatable
      Specified by:
      setAttribute in class AbstractBuildable
      Parameters:
      key - the name of the attribute. Will be one of those listed in getAttributeNames()
      value - If the value parameter is a String, it will be the value returned by getAttributeValueString(java.lang.String) for the same key. If the implementing class extends AbstractConfigurable, then value can also be an instance of
    • autoReportEnabled

      public boolean autoReportEnabled()
      Returns:
      true if auto-reporting moves is enabled (designer-setting or user-pref, depending)
    • centerOnOpponentsMove

      public boolean centerOnOpponentsMove()
      Returns:
      true if center-on-opponents-move user pref is selected (no longer a designer setting)
    • isReverseStackViewerOrder

      public boolean isReverseStackViewerOrder()
      Returns:
      true if stack viewer should reverse left-to-right order
    • isShowMarkMoved

      public boolean isShowMarkMoved()
    • centerOnOpponentsMoveSensitivity

      public double centerOnOpponentsMoveSensitivity()
      Returns:
      percent-distance-from-center sensitivity for centering on opponent's move
    • chatterHTMLSetting

      public String chatterHTMLSetting()
      Returns:
      designer's setting for enabling HTML chat
    • chatterHTMLSupport

      public boolean chatterHTMLSupport()
      Returns:
      true if chat is enabled in HTML (uses designer setting only)
    • isHotKeysOnClosedWindows

      public boolean isHotKeysOnClosedWindows()
      Returns:
      designer's setting for allowing hotkeys on closed windows
    • isSendToLocationMoveTrails

      public boolean isSendToLocationMoveTrails()
      Returns:
      designer's setting for whether send-to-location generates movement trails
    • isInventoryVisibleToAll

      public boolean isInventoryVisibleToAll()
      Returns:
      designer's setting for whether inventory can see units on private windows that current player doesn't have access to
    • isMarkMoveEnabled

      public boolean isMarkMoveEnabled()
      Returns:
      - NO LONGER USED
    • getDragThreshold

      public int getDragThreshold()
      Returns:
      drag threshold - pixels of movement required to distinguish drag from click
    • getPlayerId

      public String getPlayerId()
      Returns:
      player ID for current player using the designer-configured format
    • isStoreLeadingZeroIntegersAsStrings

      public boolean isStoreLeadingZeroIntegersAsStrings()
    • isPurgeBlankPropertyPrompts

      public boolean isPurgeBlankPropertyPrompts()
    • isDisableUsePieceIndexes

      public boolean isDisableUsePieceIndexes()
    • getPropertyNames

      public List<String> getPropertyNames()
      Implement PropertyNameSource - Expose our preference names
      Specified by:
      getPropertyNames in interface PropertyNameSource
      Overrides:
      getPropertyNames in class AbstractBuildable
      Returns:
      property names for custom preferences
    • getPropertyList

      public List<String> getPropertyList()
      Specified by:
      getPropertyList in interface SearchTarget
      Overrides:
      getPropertyList in class AbstractConfigurable
      Returns:
      a list of any properties referenced in the configurer (for search)
    • getFormattedStringList

      public List<String> getFormattedStringList()
      Specified by:
      getFormattedStringList in interface SearchTarget
      Overrides:
      getFormattedStringList in class AbstractConfigurable
      Returns:
      a list of any Message Format strings referenced in the Configurable, if any (for search)
    • getNamedKeyStrokeList

      public List<NamedKeyStroke> getNamedKeyStrokeList()
      Specified by:
      getNamedKeyStrokeList in interface SearchTarget
      Overrides:
      getNamedKeyStrokeList in class AbstractConfigurable
      Returns:
      a list of any Named KeyStrokes referenced in the Configurable, if any (for search)
    • addImageNamesRecursively

      public void addImageNamesRecursively(Collection<String> s)
      Our Option Configurers (undo button, server button, step-forward button) potentially have icons to add the references for
      Specified by:
      addImageNamesRecursively in interface ImageSearchTarget
      Overrides:
      addImageNamesRecursively in class AbstractBuildable
      Parameters:
      s - Collection to add image names to
    • isMandatory

      public boolean isMandatory()
      Description copied from interface: Buildable
      Is this component a reqired component within its parent?
      Specified by:
      isMandatory in interface Buildable
      Returns:
      true if component is mandatory
    • isUnique

      public boolean isUnique()
      Description copied from interface: Buildable
      Does this component need to be unique within it's parent?
      Specified by:
      isUnique in interface Buildable
      Returns: