Package VASSAL.build.module
Class ChessClockControl
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.module.ChessClockControl
- All Implemented Interfaces:
AutoConfigurable
,Buildable
,Configurable
,GameComponent
,PropertyNameSource
,CommandEncoder
,ComponentDescription
,ValidityChecker
,Translatable
,Auditable
,ImageSearchTarget
,SearchTarget
,UniqueIdManager.Identifyable
public class ChessClockControl
extends AbstractConfigurable
implements CommandEncoder, GameComponent, UniqueIdManager.Identifyable, ComponentDescription
CHESS CLOCK CONTROLLER for VASSAL.
This Module-level component manages a set of one or more
ChessClock
clocks. It creates a master "Chess Clocks" button on the
Module's toolbar. Clicking the button shows/hides the clocks themselves, when no clocks are running, or stops all clocks if one
is running. The Chess Clock Control component also contains the configurable elements that specify how the clocks are to be displayed.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Autoconfigurer for master chessclock button icon (allows user to choose an icon image)static class
Autoconfigurer for the days/hours/minutes/seconds/tenths stylesNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected boolean
static final String
static final String
protected LaunchButton
protected List
<ChessClock> protected boolean
static final String
static final String
static final String
static final String
static final String
static final String
static final char
protected String
static final String
static final String
protected String
protected static final UniqueIdManager
protected boolean
static final String
static final String
protected NamedKeyStrokeListener
protected boolean
static final String
protected NamedKeyStrokeListener
static final String
static final String
static final String
static final String
static final String
protected String
protected String
protected NamedKeyStrokeListener
protected String
protected String
static final String
protected NamedKeyStrokeListener
static final String
static final String
static final String
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, name
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addChessClock
(ChessClock clock) Allows individual chess clocks to add themselves to our control schemevoid
Registers us with the game module, tool bar, command encoder, etc.void
Builds the clock control's component hierarchy from a given XML element, or a null one is given initializes a brand new default "new clock control" hierarchy.Deserializes our command from a string version, if the command belongs to us.Serializes our command into a string, if it belongs to usClass<?>[]
String[]
Return an array of Strings describing the attributes of this object.String[]
Lists all the buildFile (XML) attribute names for this component.Class<?>[]
Return the Class for the attributes of this object.Gets the value of one of this component's XML attributesboolean
int
static String
getId()
static ChessClockControl
When we need to find a ChessClockControl in a static contextWhen saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullvoid
Hide all the clocks on the toolbarboolean
boolean
boolean
isOnline()
boolean
isUnique()
There can be only one!void
Figures out "the right thing to do" when player clicks the main Chess Clock Control button.void
removeChessClock
(ChessClock clock) Removes a chess clockvoid
removeFrom
(Buildable parent) Unregisters us from everything when shutting down.void
setAttribute
(String key, Object value) Sets the value of one of this component's XML attributesvoid
Manages our unique IDvoid
setOnline
(boolean online) Tells Chess Clock Control that this is a real online game, meaning we move to stricter verification standards for clocks (completely non-online clocks are really just "sandbox toys")void
setup
(boolean gameStarting) Handles starting and ending a game from the point of view of Chess Clocks.void
Show all the clocks on the toolbarstartClock
(ChessClock targetClock) stopClock
(ChessClock targetClock) void
Update all clocks (when our time-display format changes)Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getAttributeVisibility, getConfigureComponents, getConfigureName, getConfigurer, getExpressionList, getFormattedStringList, getI18nData, getI18nPrefix, getLocalizedConfigureName, getMenuTextList, getNamedKeyStrokeList, getPropertyList, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor, validate
Methods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNames
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeName
Methods inherited from interface VASSAL.build.Buildable
getBuildElement, isMandatory, isMovable
Methods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
ID_MGR
-
chessclocks
-
showTenthSeconds
-
showSeconds
-
showHours
-
showDays
-
allowReset
protected boolean allowReset -
chessClockButton
-
chessClocksVisible
protected boolean chessClocksVisible -
onlineGame
protected boolean onlineGame -
nextListener
-
startOpponentListener
-
showListener
-
pauseListener
-
instanceIsActive
protected boolean instanceIsActive -
id
-
description
-
DELIMITER
public static final char DELIMITER- See Also:
-
NAME
- See Also:
-
ICON
- See Also:
-
BUTTON_TEXT
- See Also:
-
BUTTON_TOOLTIP
- See Also:
-
DESCRIPTION
- See Also:
-
PAUSE_HOTKEY
- See Also:
-
NEXT_HOTKEY
- See Also:
-
START_OPPONENT_HOTKEY
- See Also:
-
SHOW_HOTKEY
- See Also:
-
SHOW_TENTHSECONDS
- See Also:
-
SHOW_SECONDS
- See Also:
-
SHOW_HOURS
- See Also:
-
SHOW_DAYS
- See Also:
-
ALLOW_RESET
- See Also:
-
STYLE_ALWAYS
- See Also:
-
STYLE_AUTO
- See Also:
-
STYLE_NEVER
- See Also:
-
CHESSMENU_PAUSE
-
CHESSMENU_SHOW
-
CHESSMENU_HIDE
-
CHESSMENU_NEXT
-
CHESSMENU_START_OPPONENT
-
COMMAND_PREFIX
- See Also:
-
-
Constructor Details
-
ChessClockControl
public ChessClockControl()
-
-
Method Details
-
isInstanceIsActive
public boolean isInstanceIsActive() -
getChessClocks
- Returns:
- Our list of chessclocks
-
getDescription
- Specified by:
getDescription
in interfaceComponentDescription
- Returns:
- Description to be displayed next to component type/name in the main Editor window. Or null or "" to not display anything.
-
build
Builds the clock control's component hierarchy from a given XML element, or a null one is given initializes a brand new default "new clock control" hierarchy.- Specified by:
build
in interfaceBuildable
- Overrides:
build
in classAbstractBuildable
- Parameters:
e
- XML element to build from, or null to build the default hierarchy
-
addTo
-
removeFrom
Unregisters us from everything when shutting down.- Specified by:
removeFrom
in interfaceConfigurable
- Parameters:
parent
- - Presumably the main GameModule, but in any event that's what we remove ourselves from.
-
setId
Manages our unique ID- Specified by:
setId
in interfaceUniqueIdManager.Identifyable
- Parameters:
id
- - sets our unique id
-
getId
- Specified by:
getId
in interfaceUniqueIdManager.Identifyable
- Returns:
- our unique id
-
isAllowReset
public boolean isAllowReset()- Returns:
- Whether clocks can be reset manually
-
getChessClocksVisible
public boolean getChessClocksVisible()- Returns:
- true if the group of chess clocks we manage is currently visible
-
getConfigureTypeName
- Returns:
- Component type name, which appears in [..] in Editor window
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
- Returns:
- List of valid subcomponent class types for this component (in our case, individual Chess Clocks!) which can be added in the Editor.
-
getAttributeNames
Description copied from class:AbstractBuildable
Lists all the buildFile (XML) attribute names for this component. If this component is ALSO anAbstractConfigurable
, then this list of attributes determines the appropriate attribute order forAbstractConfigurable.getAttributeDescriptions()
andAbstractConfigurable.getAttributeTypes()
.- Specified by:
getAttributeNames
in interfaceAutoConfigurable
- Specified by:
getAttributeNames
in classAbstractBuildable
- Returns:
- Key names for our attributes from the buildFile (XML) definition.
-
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 interfaceAutoConfigurable
- Specified by:
getAttributeDescriptions
in classAbstractConfigurable
- Returns:
- Descriptions for our buildFile (XML) attributes. These appear when our component is configured in the Editor window.
-
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 interfaceAutoConfigurable
- Specified by:
getAttributeTypes
in classAbstractConfigurable
- Returns:
- Class types for configuring each of our buildFile (XML) attributes. Specifies which flavor of configurer to uses.
-
setAttribute
Sets the value of one of this component's XML attributes- Specified by:
setAttribute
in interfaceAutoConfigurable
- Specified by:
setAttribute
in interfaceTranslatable
- Specified by:
setAttribute
in classAbstractBuildable
- Parameters:
key
- the name of the attribute. Will be one of those listed ingetAttributeNames()
value
- New value for the attribute. Can be either String version or the actual Object.
-
getAttributeValueString
Gets the value of one of this component's XML attributes- Specified by:
getAttributeValueString
in interfaceAutoConfigurable
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Specified by:
getAttributeValueString
in classAbstractBuildable
- Parameters:
key
- the name of the attribute. Will be one of those listed ingetAttributeNames()
- Returns:
- String value of the attribute.
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- The help file for this component. Used when user clicks "Help" button while configuring the component in the Editor.
-
getInstance
When we need to find a ChessClockControl in a static context- Returns:
- First ChessClockControl in our module
-
getShowTenths
- Returns:
- Setting for showing tenths of seconds. (Always, Auto, Never)
-
getShowSeconds
- Returns:
- Setting for showing seconds. (Always, Auto, Never)
-
getShowHours
- Returns:
- Setting for showing hours. (Always, Auto, Never)
-
getShowDays
- Returns:
- Setting for showing days. (Always, Auto, Never)
-
getClocksTicking
public int getClocksTicking()- Returns:
- the number of chess clocks currently ticking/active
-
stopAllClocks
- Returns:
- A command to stop all the clocks
-
startNextClock
- Returns:
- a command to start the next clock after stopping the one currently running (if any)
-
startOpponentClock
- Returns:
- a command to start the opponents clock after stopping the one currently running (if any)
-
startClock
- Returns:
- a command to start the requested clock after stopping the one currently running (if any)
-
stopClock
- Returns:
- a command to start the requested clock after stopping the one currently running (if any)
-
hideClocks
public void hideClocks()Hide all the clocks on the toolbar -
showClocks
public void showClocks()Show all the clocks on the toolbar -
updateAllClocks
public void updateAllClocks()Update all clocks (when our time-display format changes) -
pressControlButton
public void pressControlButton()Figures out "the right thing to do" when player clicks the main Chess Clock Control button. Does one of the following, in order of priority: (1) If the clocks are hidden, show them (2) If any clock is running, stop them all (3) Hide all the clocks -
setOnline
public void setOnline(boolean online) Tells Chess Clock Control that this is a real online game, meaning we move to stricter verification standards for clocks (completely non-online clocks are really just "sandbox toys")- Parameters:
online
- True if this is an online game
-
isOnline
public boolean isOnline()- Returns:
- True if this has been marked as an online game
-
setup
public void setup(boolean gameStarting) Handles starting and ending a game from the point of view of Chess Clocks.- Specified by:
setup
in interfaceGameComponent
- Parameters:
gameStarting
- If true, a game is starting. If false, then a game is ending.
-
addChessClock
Allows individual chess clocks to add themselves to our control scheme- Parameters:
clock
- clock to be added
-
removeChessClock
Removes a chess clock- Parameters:
clock
- clock to be removed
-
decode
Deserializes our command from a string version, if the command belongs to us.- Specified by:
decode
in interfaceCommandEncoder
- Parameters:
command
- Serialized string command- Returns:
- An
ChessClockControl.UpdateClockControlCommand
-
encode
Serializes our command into a string, if it belongs to us- Specified by:
encode
in interfaceCommandEncoder
- Parameters:
c
- Command to serialize. Only serialized if it's an UpdateClockControlCommand.- Returns:
- Serialized command, or null if command passed wasn't an UpdateClockControlCommand.
-
getRestoreCommand
Description copied from interface:GameComponent
When saving a game, each GameComponent should return aCommand
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 interfaceGameComponent
- Returns:
- Our command for restoring from a saved game (or adding an online player)
-
isUnique
-