Class StartupGlobalKeyCommand

All Implemented Interfaces:
AutoConfigurable, Buildable, Configurable, GameComponent, PropertyNameSource, CommandEncoder, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget, RecursionLimiter.Loopable, UniqueIdManager.Identifyable

public class StartupGlobalKeyCommand extends GlobalKeyCommand implements GameComponent, CommandEncoder, UniqueIdManager.Identifyable
A Global Key Command that is automatically invoked on game start-up, once the various Key Listeners have been started.

As of 3.6, multiple Startup Global Key Commands can be depended on to process in the correct order.

Author:
Pieter Geerkens
  • Field Details

  • Constructor Details

    • StartupGlobalKeyCommand

      public StartupGlobalKeyCommand()
    • StartupGlobalKeyCommand

      public StartupGlobalKeyCommand(MassKeyCommand gkc)
  • Method Details

    • addTo

      public void addTo(Buildable parent)
      Description copied from class: AbstractToolbarItem
      Default behavior adds the button to the module toolbar.
      Specified by:
      addTo in interface Buildable
      Overrides:
      addTo in class MassKeyCommand
      Parameters:
      parent - parent Buildable to add this component to as a subcomponent.
    • removeFrom

      public void removeFrom(Buildable parent)
      Description copied from class: AbstractToolbarItem
      Default behavior assumes we are removing this from the module toolbar
      Specified by:
      removeFrom in interface Configurable
      Overrides:
      removeFrom in class MassKeyCommand
      Parameters:
      parent - parent
    • getConfigureTypeName

      public static String getConfigureTypeName()
    • getHelpFile

      public HelpFile getHelpFile()
      Specified by:
      getHelpFile in interface Configurable
      Overrides:
      getHelpFile in class MassKeyCommand
      Returns:
      a HelpFile describing how to use and configure * this component
    • getAttributeVisibility

      public VisibilityCondition getAttributeVisibility(String key)
      Description copied from class: AbstractConfigurable
      By default, all attributes are visible
      Specified by:
      getAttributeVisibility in interface AutoConfigurable
      Overrides:
      getAttributeVisibility in class GlobalKeyCommand
      Parameters:
      key - Name (key) of one of this component's attributes
      Returns:
      a VisibilityCondition for this attribute, or null if attribute should always be visible.
    • getAttributeDescriptions

      public String[] getAttributeDescriptions()
      Description copied from class: AbstractToolbarItem
      This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeDescriptions(), key1, ..., keyN), or supply their own order from scratch.
      Specified by:
      getAttributeDescriptions in interface AutoConfigurable
      Overrides:
      getAttributeDescriptions in class MassKeyCommand
      Returns:
      an array of Strings describing the buildFile (XML) attributes of this component. These strings are used as prompts in the Properties window for this object, when the component is configured in the Editor. The order of descriptions should be the same as the order of names in AbstractBuildable.getAttributeNames()
    • getAttributeNames

      public String[] getAttributeNames()
      Description copied from class: AbstractToolbarItem
      This getAttributeNames() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeNames(), key1, ..., keyN), or supply their own order from scratch.

      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
      Overrides:
      getAttributeNames in class MassKeyCommand
      Returns:
      a list of all buildFile (XML) attribute names for this component
    • getAttributeTypes

      public Class<?>[] getAttributeTypes()
      Description copied from class: AbstractToolbarItem
      This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeTypes(), key1, ..., keyN), or supply their own order from scratch.
      Specified by:
      getAttributeTypes in interface AutoConfigurable
      Overrides:
      getAttributeTypes in class MassKeyCommand
      Returns:
      the Class for the buildFile (XML) attributes of this component. Valid classes include: String, Integer, Double, Boolean, Image, Color, and KeyStroke, along with any class for which a Configurer exists in VASSAL.configure. The class determines, among other things, which type of AutoConfigurer will be used to configure the attribute when the object is configured in the Editor.

      The order of classes should be the same as the order of names in AbstractBuildable.getAttributeNames()

    • setAttribute

      public void setAttribute(String key, Object value)
      Description copied from class: AbstractToolbarItem
      Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button. Sets a buildFile (XML) attribute value for this component. The key parameter will be one of those listed in AbstractToolbarItem.getAttributeNames(). If the value parameter is a String, it will be the value returned by AbstractToolbarItem.getAttributeValueString(java.lang.String) for the same key. If the implementing class extends AbstractConfigurable, then value will be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()
      Specified by:
      setAttribute in interface AutoConfigurable
      Specified by:
      setAttribute in interface Translatable
      Overrides:
      setAttribute in class MassKeyCommand
      Parameters:
      key - the name of the attribute. Will be one of those listed in AbstractToolbarItem.getAttributeNames()
      value - If the value parameter is a String, it will be the value returned by AbstractToolbarItem.getAttributeValueString(java.lang.String) for the same key. If the implementing class extends AbstractConfigurable, then value can also be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()
    • getAttributeValueString

      public String getAttributeValueString(String key)
      Description copied from class: AbstractToolbarItem
      Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.
      Specified by:
      getAttributeValueString in interface AutoConfigurable
      Specified by:
      getAttributeValueString in interface Translatable
      Overrides:
      getAttributeValueString in class MassKeyCommand
      Parameters:
      key - the name of the attribute. Will be one of those listed in AbstractToolbarItem.getAttributeNames()
      Returns:
      a String representation of the XML buildFile attribute with the given name. When initializing a module, this String value will loaded from the XML and passed to AbstractToolbarItem.setAttribute(java.lang.String, java.lang.Object). It is also frequently used for checking the current value of an attribute.
    • applyIfNotApplied

      public boolean applyIfNotApplied()
      Apply the command, but only if it hasn't been marked as already-applied (by whatever its when-to-apply parameters are)
      Returns:
      true if command was applied
    • setup

      public void setup(boolean gameStarting)
      Description copied from interface: GameComponent
      Notify the GameComponent that a game has started/ended
      Specified by:
      setup in interface GameComponent
      Parameters:
      gameStarting - if true, a game is starting. If false, then a game is ending
    • freshGame

      public void freshGame()
      When initializing a new game from a Predefined Setup that loads a saved game, mark that this is actually a fresh game rather than a load of an old one
    • getRestoreCommand

      public Command getRestoreCommand()
      Description copied from interface: GameComponent
      When saving a game, each GameComponent should return a Command that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null
      Specified by:
      getRestoreCommand in interface GameComponent
    • setId

      public void setId(String id)
      Sets our unique ID (among Startup Global Key Commands), so that multiple SGKCs can sort their save/restore commands from each other
      Specified by:
      setId in interface UniqueIdManager.Identifyable
      Parameters:
      id - Sets our unique ID
    • getId

      public String getId()
      Specified by:
      getId in interface UniqueIdManager.Identifyable
      Returns:
      unique ID of this SGKC
    • decode

      public Command decode(String command)
      Deserializes our command from a string version, if the command belongs to us.
      Specified by:
      decode in interface CommandEncoder
      Parameters:
      command - Serialized string command
      Returns:
      An ChessClockControl.UpdateStartupGlobalKeyCommand
    • encode

      public String encode(Command c)
      Serializes our command into a string, if it belongs to us
      Specified by:
      encode in interface CommandEncoder
      Parameters:
      c - Command to serialize. Only serialized if it's an UpdateClockControlCommand.
      Returns:
      Serialized command, or null if command passed wasn't an UpdateClockControlCommand.