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
Nested ClassesModifier and TypeClassDescriptionstatic classAutoconfigurer for master chessclock button icon (allows user to choose an icon image)static classAutoconfigurer for the days/hours/minutes/seconds/tenths stylesNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected booleanstatic final Stringstatic final Stringprotected LaunchButtonprotected List<ChessClock> protected booleanstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final charprotected Stringstatic final Stringstatic final Stringprotected Stringprotected static final UniqueIdManagerprotected booleanstatic final Stringstatic final Stringprotected NamedKeyStrokeListenerprotected booleanstatic final Stringprotected NamedKeyStrokeListenerstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringprotected Stringprotected NamedKeyStrokeListenerprotected Stringprotected Stringstatic final Stringprotected NamedKeyStrokeListenerstatic final Stringstatic final Stringstatic final StringFields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, nameFields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validatorFields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChessClock(ChessClock clock) Allows individual chess clocks to add themselves to our control schemevoidRegisters us with the game module, tool bar, command encoder, etc.voidBuilds 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 attributesbooleanintstatic StringgetId()static ChessClockControlWhen we need to find a ChessClockControl in a static contextWhen saving a game, each GameComponent should return aCommandthat, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullvoidHide all the clocks on the toolbarbooleanbooleanbooleanisOnline()booleanisUnique()There can be only one!voidFigures out "the right thing to do" when player clicks the main Chess Clock Control button.voidremoveChessClock(ChessClock clock) Removes a chess clockvoidremoveFrom(Buildable parent) Unregisters us from everything when shutting down.voidsetAttribute(String key, Object value) Sets the value of one of this component's XML attributesvoidManages our unique IDvoidsetOnline(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")voidsetup(boolean gameStarting) Handles starting and ending a game from the point of view of Chess Clocks.voidShow all the clocks on the toolbarstartClock(ChessClock targetClock) stopClock(ChessClock targetClock) voidUpdate 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, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor, validateMethods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNamesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeNameMethods inherited from interface VASSAL.build.Buildable
getBuildElement, isMandatory, isMovableMethods 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:
getDescriptionin 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:
buildin interfaceBuildable- Overrides:
buildin classAbstractBuildable- Parameters:
e- XML element to build from, or null to build the default hierarchy
-
addTo
Registers us with the game module, tool bar, command encoder, etc. -
removeFrom
Unregisters us from everything when shutting down.- Specified by:
removeFromin 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:
setIdin interfaceUniqueIdManager.Identifyable- Parameters:
id- - sets our unique id
-
getId
- Specified by:
getIdin 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:
getAllowableConfigureComponentsin 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:AbstractBuildableLists 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:
getAttributeNamesin interfaceAutoConfigurable- Specified by:
getAttributeNamesin classAbstractBuildable- Returns:
- Key names for our attributes from the buildFile (XML) definition.
-
getAttributeDescriptions
Description copied from interface:AutoConfigurableReturn 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:
getAttributeDescriptionsin interfaceAutoConfigurable- Specified by:
getAttributeDescriptionsin classAbstractConfigurable- Returns:
- Descriptions for our buildFile (XML) attributes. These appear when our component is configured in the Editor window.
-
getAttributeTypes
Description copied from interface:AutoConfigurableReturn the Class for the attributes of this object. Valid classes are: String, Integer, Double, Boolean, Image, File, Color, and KeyStroke- Specified by:
getAttributeTypesin interfaceAutoConfigurable- Specified by:
getAttributeTypesin 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:
setAttributein interfaceAutoConfigurable- Specified by:
setAttributein interfaceTranslatable- Specified by:
setAttributein 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:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Specified by:
getAttributeValueStringin classAbstractBuildable- Parameters:
key- the name of the attribute. Will be one of those listed ingetAttributeNames()- Returns:
- String value of the attribute.
-
getHelpFile
- Specified by:
getHelpFilein 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:
setupin 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:
decodein interfaceCommandEncoder- Parameters:
command- Serialized string command- Returns:
- An
ChessClockControl.UpdateClockControlCommand
-
encode
Serializes our command into a string, if it belongs to us- Specified by:
encodein 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:GameComponentWhen saving a game, each GameComponent should return aCommandthat, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null- Specified by:
getRestoreCommandin interfaceGameComponent- Returns:
- Our command for restoring from a saved game (or adding an online player)
-
isUnique
public boolean isUnique()There can be only one!
-