Package VASSAL.build
Class GameModule
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.GameModule
- All Implemented Interfaces:
AutoConfigurable
,Buildable
,Configurable
,GpIdSupport
,MutablePropertiesContainer
,PropertyNameSource
,PropertySource
,TranslatableStringContainer
,CommandEncoder
,ValidityChecker
,Translatable
,Auditable
,ImageSearchTarget
,SearchTarget
,ToolBarComponent
- Direct Known Subclasses:
BasicModule
public class GameModule
extends AbstractConfigurable
implements CommandEncoder, ToolBarComponent, PropertySource, MutablePropertiesContainer, TranslatableStringContainer, GpIdSupport
The GameModule class is the base class for a VASSAL module. It is
the root of the
Buildable
containment hierarchy, and thus also
the root of the Editor's ConfigureTree
. GameModule's implementation
of CommandEncoder
is slightly different, serving as a central dispatch
point for all other CommandEncoders, which register themselves with GameModule.
Components which are intended to be added directly to the GameModule are contained
in the VASSAL.build.module
package.
GameModule is a singleton, and contains access points for many other classes,
such as DataArchive
, ServerConnection
, Logger
, Chatter
, and Prefs
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Last type of game save/load for our current gameNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
Nested classes/interfaces inherited from interface VASSAL.build.module.properties.MutablePropertiesContainer
MutablePropertiesContainer.Impl
Nested classes/interfaces inherited from interface VASSAL.build.module.properties.TranslatableStringContainer
TranslatableStringContainer.Impl
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
ThePrefs
key for the user's personal infostatic final String
ThePrefs
key for the user's real namestatic final String
static final String
ThePrefs
key for the user's secret namestatic final String
static final String
static final String
static final String
The System property of this name will return a version identifier for the version of VASSAL being runFields 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
GameModule holds the master list of CommandEncoders, and invokes them as appropriate when commands are sent and received.void
Currently used to listen for changes to player namesvoid
The GameModule acts as the mediator for hotkey events.void
The GameModule acts as the mediator for hotkey events.void
addMutableProperty
(String key, MutableProperty p) Adds a new mutable (changeable) "Global Property" to the Module.void
Adds listener for players changing sidesvoid
Game Module is normally at the root of the hierarchy, so it doesn't expect to get added to anything.void
Add a property under the given keyvoid
Deprecated, for removal: This API element is subject to removal in a future version.void
Builds the module's component hierarchy from a given XML element, or a null one is given initializes a brand new default "new module" hierarchy.void
Clear outstanding Commands Use where the calling level handles the sending of outstanding commandsstatic void
createPiece
(String type) Central location to create any type of GamePiece from within VASSALcreatePiece
(String type, GamePiece inner) Central location to create any type of GamePiece Trait (Decorator) from within VASSALDecodes our inboundCommand
traffic -- incoming player commands ready to be executed.Encodes our outboundCommand
traffic -- outgoing player commands to be sent to other players' clients via either online (server) or logfile (PBEM).final void
Record the end of a multi-piece UI gesturevoid
fireKeyStroke
(NamedKeyStroke stroke) Invokes aNamedKeyStroke
to all of our listeners.Allocates the next available GamePiece ID and returns it.static String
Class<?>[]
List of subcomponents which can be added to a GameModule.VASSAL modules are stored in ".vmod" files, which are actually simple ".zip" files with a unique extension.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.Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML elementlong
long
getCombinedCrc
(boolean forceRegenerate) static String
Gets the generic name for this type of class across all instances of it.long
getCrc()
long
getCrc
(boolean forceRegenerate) VASSAL modules are stored in ".vmod" files, which are actually simple ".zip" files with a unique extension.getFrame()
Deprecated.static GameModule
Return the object responsible for tracking the state of a game.Returns a localized translation of the specified property value, if available.Return a unique Id for the containergetMutableProperty
(String name) Gets the value of a mutable (changeable) "Global Property".int
Accessors to check and update the next GpId if necessary."Player" in this context meaning the VASSAL Player, i.e. the main module window, as opposed to any individual player meaning participant-in-a-boardgame.getPrefs()
getProperty
(Object key) Gets the value of a module level global property -- this includes identification information for the local player as well as the contents of any Global Property objects defined at module level in the Module.Override this method to provide a list of properties to be exposed for use by expressions in the module.getRNG()
static String
Returns an appropriate Title Bar string for the main module window, based on the module name, the last read/written game file, and the manner of interaction with it.Provides access to the Game Module's toolbar.getTranslatableString
(String name) Find an object with the given nameReturn a unique Id for the containerint
Return number of pieces to be processed by the current multi-piece UI gestureint
Return the index of the current piece being processed by the current multi-piece UI gesturestatic String
getWindowTitleString
(String key, String name) getWindowTitleString
(String key, String name, boolean moduleVersion) Returns an appropriate Title Bar string for a window, based on the module name, the last read/written game file, and the manner of interaction with it.static void
init
(GameModule module) Loads a module object into the player window.void
Sets the proper name for module window's title barfinal void
initializeUiPieceProcessing
(int pieceCount) A multi-piece UI gesture is starting.boolean
Is an editor window currently openstatic boolean
boolean
boolean
boolean
Is the module being translated into the user's Locale?boolean
boolean
boolean
boolean
boolean
Returns true if user has supplied a real password for current GameModule.boolean
Returns true if user has supplied a real name Test's whether GameModule.REAL_NAME is non-empty and not "newbie"boolean
boolean
boolean
boolean
boolean
boolean
boolean
Pause logging and return true if successful.final void
The next piece in a multi-piece UI gesture is about to be processed.void
quit()
Exit the application, prompting user to save if necessaryvoid
If our keyboard mapping paradigm changes (example: Mac Legacy preference checked/unchecked), we need to reregister all of our KeyStrokeListenersfinal void
Refresh the visible portions of all currently showing maps.void
This method removes aCommandEncoder
from the list of objects that will attempt to decode/encode a commandvoid
removeFrom
(Buildable parent) Since we aren't expecting to beaddTo(VASSAL.build.Buildable)
'ed to a parent, we likewise don't need to do much about being "removeFrom'ed" one.void
Currently used to listen for changes to player namesvoid
Removes a mutable property from the Global Properties list.void
Removes listener for players changing sidesRemove the property with the given keyvoid
Restart logging and return any outstanding commandsvoid
save()
If the module is being edited, write the module data to the current filenamevoid
saveAs()
If the module is being edited, write the module data after prompting for a new filename.void
When the local player has taken any action that would change the game state (or otherwise needs to be sent to any other players' clients), the action should be encapsulated into aCommand
and sent here.void
setAttribute
(String name, Object value) Sets a buildFile (XML) attribute value for this component.void
Allows the Chat Log window to register itself to the Module.void
setDirty
(boolean touchThis) static void
setErrorLogToChat
(boolean errorLogToChat) void
setGameFile
(String gameFile, GameModule.GameFileMode mode) Sets the most recent .VSAV / .VLOG file saved, loaded, or logged to, along with the type of action taken with that file.void
Sets the type of interaction we most recently had with saving/loading/replaying/logging, for managing title bars of windows.void
Registers a GamePiece ID support object for us to manage a namespace for unique GamePiece objects.void
setLoadingContinuationSemaphore
(boolean state) void
setLoadOverSemaphore
(boolean state) void
void
setMatSupport
(boolean matSupport) void
setMutableButtonSupport
(boolean support) void
setNextGpId
(int id) Sets the next available GamePiece IDvoid
setPieceWindow
(PieceWindow pieceWindow) Allows a PieceWindow that wants to be our docked PieceWindow to register itself.void
void
setRefreshingSemaphore
(boolean state) void
setSuppressAutoCenterUpdate
(boolean suppressAutoCenterUpdate) void
setSuppressSounds
(boolean suppressSounds) static void
setTempUserId
(String id) void
setTrueMovedSupport
(boolean trueMovedSupport) static void
Set the identifier for the userboolean
shutDown()
Prompt user to save open game and modules/extensions being editedtoString()
void
Save the current buildString for comparison when we try and quit.void
A property has changed somewhere, so we need to redraw all the toolbar buttons that use propertiesvoid
Updates the title bar of the main module window, and all map windowsvoid
Display the given text in the control window's status line.Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getAttributeVisibility, getConfigureComponents, getConfigureName, getConfigurer, getFormattedStringList, 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, 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, wait, wait, wait
Methods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeName
Methods inherited from interface VASSAL.build.Buildable
getBuildElement, isMandatory, isMovable, isUnique
Methods inherited from interface VASSAL.tools.ToolBarComponent
updateToolbarButtons
-
Field Details
-
MODULE_NAME
- See Also:
-
MODULE_VERSION
- See Also:
-
DESCRIPTION
- See Also:
-
VASSAL_VERSION_CREATED
- See Also:
-
VASSAL_VERSION_RUNNING
The System property of this name will return a version identifier for the version of VASSAL being run- See Also:
-
NEXT_PIECESLOT_ID
- See Also:
-
BUILDFILE
- See Also:
-
BUILDFILE_OLD
- See Also:
-
REAL_NAME
-
SECRET_NAME
-
PERSONAL_INFO
-
MODULE_NAME_PROPERTY
- See Also:
-
MODULE_VERSION_PROPERTY
- See Also:
-
MODULE_DESCRIPTION_PROPERTY
- See Also:
-
MODULE_OTHER1_PROPERTY
- See Also:
-
MODULE_OTHER2_PROPERTY
- See Also:
-
MODULE_VASSAL_VERSION_CREATED_PROPERTY
- See Also:
-
MODULE_VASSAL_VERSION_RUNNING_PROPERTY
- See Also:
-
MODULE_CURRENT_LOCALE
- See Also:
-
MODULE_CURRENT_LOCALE_NAME
- See Also:
-
DRAWING_MOUSEOVER_PROPERTY
- See Also:
-
DRAWING_MOUSEOVER_INDEX_PROPERTY
- See Also:
-
IS_VISIBLE
- See Also:
-
UI_PIECE_COUNT
- See Also:
-
UI_PIECE_INDEX
- See Also:
-
RECENT_GAMES
- See Also:
-
-
Constructor Details
-
GameModule
Constructor for a GameModule.- Parameters:
archive
- The .vmod (or .tmp) archive to associate
-
-
Method Details
-
getDeckManager
-
getPasswordConfigurer
-
isMatSupport
public boolean isMatSupport()- Returns:
- True if there are any Mat or MatCargo objects in the module
-
setMatSupport
public void setMatSupport(boolean matSupport) - Parameters:
matSupport
- true if a Mat or MatCargo trait has been added to the module (thus meaning we'll want to do those calculations during moves/selects)
-
isTrueMovedSupport
public boolean isTrueMovedSupport()- Returns:
- True if there are any ignore-small-moves traits in the module
-
setTrueMovedSupport
public void setTrueMovedSupport(boolean trueMovedSupport) - Parameters:
trueMovedSupport
- true if a ignore-small-moves trait exists in the module
-
setMutableButtonSupport
public void setMutableButtonSupport(boolean support) - Parameters:
support
- true if any toolbar buttons use $...$ or { } expressions
-
isMutableButtonLabelSupport
public boolean isMutableButtonLabelSupport()- Returns:
- True if there are toolbar buttons using $...$ or { } expressions in the module
-
isSuppressSounds
public boolean isSuppressSounds()- Returns:
- True if currently suppressing sounds (eg during a Global Key Command)
-
setSuppressSounds
public void setSuppressSounds(boolean suppressSounds) - Parameters:
suppressSounds
- true if sounds should be suppressed during command processing
-
setSuppressAutoCenterUpdate
public void setSuppressAutoCenterUpdate(boolean suppressAutoCenterUpdate) -
isSuppressAutoCenterUpdate
public boolean isSuppressAutoCenterUpdate() -
getLocationKeyCommand
-
setLocationKeyCommand
-
getIndexManager
-
setLoadOverSemaphore
public void setLoadOverSemaphore(boolean state) - Parameters:
state
- - true if we're loading-over-top of an existing game (so don't disturb UI elements if possible, will receive a setup(true) soon enough)
-
isLoadOverSemaphore
public boolean isLoadOverSemaphore()- Returns:
- true if we're loading-over-top of an existing game (so don't disturb UI elements if possible, will receive a setup(true) soon enough)
-
setRefreshingSemaphore
public void setRefreshingSemaphore(boolean state) - Parameters:
state
- - true if refreshing (suppresses GameState.setup method)
-
isRefreshingSemaphore
public boolean isRefreshingSemaphore()- Returns:
- true if refreshing (suppresses GameState.setup method)
-
setLoadingContinuationSemaphore
public void setLoadingContinuationSemaphore(boolean state) - Parameters:
state
- - true if loading game as continuation (don't thrash listeners)
-
isLoadingContinuationSemaphore
public boolean isLoadingContinuationSemaphore()- Returns:
- true if loading game as continuation (don't thrash listeners)
-
getFrame
Deprecated.- Returns:
- the top-level frame of the controls window
-
toString
-
getPlayerWindow
"Player" in this context meaning the VASSAL Player, i.e. the main module window, as opposed to any individual player meaning participant-in-a-boardgame.- Returns:
- The main window for the module
-
initFrameTitle
public void initFrameTitle()Sets the proper name for module window's title bar -
getWizardSupport
- Returns:
- Our wizard
-
getServerControls
- Returns:
- our ChatServerControls.
-
getDebugControls
- Returns:
- our DebugControls
-
getConsole
- Returns:
- our Console
-
isErrorLogToChat
public static boolean isErrorLogToChat()- Returns:
- True if errorLog should also be sent to chat log.
-
setErrorLogToChat
public static void setErrorLogToChat(boolean errorLogToChat) - Parameters:
errorLogToChat
- true if errorLog should also be sent to chat log
-
getI18nPrefix
- Overrides:
getI18nPrefix
in classAbstractConfigurable
- Returns:
- Generate a standard prefix for i18n keys for attributes of this component - Classname.attributeName
-
setDirty
public void setDirty(boolean touchThis) -
build
Builds the module's component hierarchy from a given XML element, or a null one is given initializes a brand new default "new module" hierarchy.- Specified by:
build
in interfaceBuildable
- Overrides:
build
in classAbstractBuildable
- Parameters:
e
- XML element to build from, or null to build the default hierarchy
-
setAttribute
Sets a buildFile (XML) attribute value for this component.- Specified by:
setAttribute
in interfaceAutoConfigurable
- Specified by:
setAttribute
in interfaceTranslatable
- Specified by:
setAttribute
in classAbstractBuildable
- Parameters:
name
- the name of the attribute. Will be one of those listed ingetAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
can also be an instance of
-
getAttributeValueString
Description copied from interface:AutoConfigurable
Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML element- Specified by:
getAttributeValueString
in interfaceAutoConfigurable
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Specified by:
getAttributeValueString
in classAbstractBuildable
- Parameters:
name
- the name of the attribute. Will be one of those listed ingetAttributeNames()
- Returns:
- a String representation of the attribute with the given name. When initializing a module, this String value will be passed to
setAttribute(java.lang.String, java.lang.Object)
-
addTo
-
getConfigureTypeName
Gets the generic name for this type of class across all instances of it. Appears in the Editor window in [..] as e.g. [Map], [Prototype], etc.- Returns:
- The generic name for this kind of component, i.e. the part appearing [In Brackets] in the Editor's
ConfigureTree
.
-
removeFrom
Since we aren't expecting to beaddTo(VASSAL.build.Buildable)
'ed to a parent, we likewise don't need to do much about being "removeFrom'ed" one.- Specified by:
removeFrom
in interfaceConfigurable
- Parameters:
parent
- Notional "parent" of this GameModule
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- a HelpFile describing how to use and configure this component
-
getAttributeNames
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:
- a list of all buildFile (XML) attribute names for this component
- See Also:
-
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:
- 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()
- See Also:
-
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:
- 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 inAbstractBuildable.getAttributeNames()
- See Also:
-
getAllowableConfigureComponents
List of subcomponents which can be added to a GameModule.- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
- Returns:
- a list of valid sub-component Classes. If a Class
appears in this list, then instances of that class may be added
to this component from the Editor's
ConfigureTree
window by right-clicking on the component and selecting the appropriate "Add" option. - See Also:
-
addKeyStrokeSource
The GameModule acts as the mediator for hotkey events. Components that wish to fire hotkey events when they have the focus should register themselves using this method. These events will be forwarded to all listeners that have registered themselves withaddKeyStrokeListener(VASSAL.tools.KeyStrokeListener)
- Parameters:
src
- KeyStrokeSource Component that wants to register as a source for hotkey events
-
removeKeyStrokeListener
-
addKeyStrokeListener
The GameModule acts as the mediator for hotkey events. Objects that react to hotkey events should register themselves using this method. Any component that has been registered withaddKeyStrokeSource(VASSAL.tools.KeyStrokeSource)
will forward hotkey events to listeners registered with this method.- Parameters:
l
- KeystrokeListener to add
-
resetSourcesAndListeners
public void resetSourcesAndListeners() -
refreshKeyStrokeListeners
public void refreshKeyStrokeListeners()If our keyboard mapping paradigm changes (example: Mac Legacy preference checked/unchecked), we need to reregister all of our KeyStrokeListeners -
fireKeyStroke
Invokes aNamedKeyStroke
to all of our listeners.- Parameters:
stroke
- NamedKeyStroke to invoke
-
getGameName
- Returns:
- the name of the game for this module
-
getLocalizedGameName
- Returns:
- the localized/translated game name for this module
-
getGameVersion
- Returns:
- the version number for this module
-
getModuleOther1
- Returns:
- extra information 1 for module
-
getModuleOther2
- Returns:
- extra information 2 for module
-
addIdChangeListener
Currently used to listen for changes to player names- Parameters:
l
- propertyChangeListener to add
-
removeIdChangeListener
Currently used to listen for changes to player names- Parameters:
l
- propertyChangeListener to remove
-
getPrefs
- Returns:
- the preferences for this module
-
isTranslatableSupport
public boolean isTranslatableSupport() -
addCommandEncoder
GameModule holds the master list of CommandEncoders, and invokes them as appropriate when commands are sent and received. This method adds aCommandEncoder
to the list of objects that will attempt to decode/encode a command.- See Also:
-
removeCommandEncoder
This method removes aCommandEncoder
from the list of objects that will attempt to decode/encode a command- See Also:
-
createPiece
-
createPiece
-
warn
Display the given text in the control window's status line. Save the messages for later if the Chatter has not been initialised yet- Parameters:
s
- message to display in Chat Log
-
getRNG
- Returns:
- a single Random number generator that all objects may share
-
getLogger
- Returns:
- the object responsible for logging commands to a .vlog logfile to support PBEM play
-
getBasicLogger
- Returns:
- BasicLogger, if we have one
-
setChatter
Allows the Chat Log window to register itself to the Module. When a Chat Log is first registered, display any warning messages deferred during earlier initialisation- Parameters:
c
- The Chat Log window we want to use
-
getControlPanel
-
getChatter
- Returns:
- the registered Chat Log for the Module Window (window that displays chat text)
-
getPieceWindow
- Returns:
- the registered docked PieceWindow (game piece palette) for the module
-
setPieceWindow
Allows a PieceWindow that wants to be our docked PieceWindow to register itself.- Parameters:
pieceWindow
- PieceWindow to be our docked one
-
setPrefs
-
decode
Decodes our inboundCommand
traffic -- incoming player commands ready to be executed. Unlike everybody else's decode method, the GameModule's method first pulls apart strings of multiple commands into singles. It then invokes each of its registeredCommandEncoder
s in turn until one of them is able to deserialize the command from a String into aCommand
object ready to be executed.- Specified by:
decode
in interfaceCommandEncoder
-
encode
Encodes our outboundCommand
traffic -- outgoing player commands to be sent to other players' clients via either online (server) or logfile (PBEM). Unlike everybody else's encode method, the GameModule's method accepts Command trees containing multiple appended commands. It goes through them in order and for each command invokes each of its registeredCommandEncoder
s in turn until one of them is able to serialize theCommand
object into an ascii-compatible String ready to be sent to other players' clients. It does this for each of the subcommands in the list, and the results for all are returned as a single String.- Specified by:
encode
in interfaceCommandEncoder
-
getFileChooser
- Returns:
- a common FileChooser so that recent file locations can be remembered
-
getEditorImageChooser
- Returns:
- a common FileChooser so that recent file locations can be remembered
-
getEditorSoundChooser
- Returns:
- a common FileChooser so that recent file locations can be remembered
-
getToolBar
Provides access to the Game Module's toolbar.- Specified by:
getToolBar
in interfaceToolBarComponent
- Returns:
- the JToolBar of the command window
-
getWindowTitleString
Returns an appropriate Title Bar string for a window, based on the module name, the last read/written game file, and the manner of interaction with it.- Parameters:
key
- Localization key to be used to generate stringname
- Name of the object whose title bar is to be generatedmoduleVersion
- if true, include the module version number- Returns:
- appropriate title bar string for a window.
-
getWindowTitleString
-
getTitleString
Returns an appropriate Title Bar string for the main module window, based on the module name, the last read/written game file, and the manner of interaction with it.- Returns:
- appropriate title bar string for main module window.
-
updateTitleBar
public void updateTitleBar()Updates the title bar of the main module window, and all map windows -
appendToTitle
Deprecated, for removal: This API element is subject to removal in a future version.useupdateTitleBar()
- Parameters:
s
- String to append to title
-
setGameFile
Sets the most recent .VSAV / .VLOG file saved, loaded, or logged to, along with the type of action taken with that file.- Parameters:
gameFile
- Most recent VSAV/VLOG if anymode
- mode of access
-
getGameFile
- Returns:
- Most recent .VSAV/.VLOG that we've read or written.
-
setGameFileMode
Sets the type of interaction we most recently had with saving/loading/replaying/logging, for managing title bars of windows.- Parameters:
mode
- mode of access
-
getGameFileMode
- Returns:
- Returns the most recent type of interaction we've had for saving/loading/replaying/logging the game, for managing title bars of windows.
-
isReplayingOrLogging
public boolean isReplayingOrLogging()- Returns:
- true if we are currently logging or replaying a game.
-
quit
public void quit()Exit the application, prompting user to save if necessary -
shutDown
public boolean shutDown()Prompt user to save open game and modules/extensions being edited- Returns:
- true if shutDown should proceed, i.e. user did not cancel
-
sendAndLog
When the local player has taken any action that would change the game state (or otherwise needs to be sent to any other players' clients), the action should be encapsulated into aCommand
and sent here. This method encodes theCommand
, sends it to the server (if we're online) and write it to a .vlog PBEM logfile (if any is open). It thus drives both formats of multiplayer game through a common interface.- Parameters:
c
- TheCommand
to be sent and logged.- See Also:
-
pauseLogging
public boolean pauseLogging()Pause logging and return true if successful. Return false if logging already paused While Paused, commands are accumulated into pausedCommands so that they can all be logged at the same time, and generate a single UNDO command.- Returns:
- Current logging pause status, false if logging currently paused
-
resumeLogging
-
clearPausedCommands
public void clearPausedCommands()Clear outstanding Commands Use where the calling level handles the sending of outstanding commands -
getActiveUserId
- Returns:
- the userId/password we're currently using, in case we're using one of our alternate defaults. Or if none explicitly picked, the actual contents of our password field.
-
getTempUserId
-
setTempUserId
-
clearTempUserId
public static void clearTempUserId() -
getUserId
- Returns:
- a String that uniquely identifies the user
-
setUserId
Set the identifier for the user -
getServer
- Returns:
- the object responsible for sending messages to the server
-
isMultiPlayer
public boolean isMultiPlayer()- Returns:
- true if the game is online or has ever had more than one player.
-
isMultiplayerConnected
public boolean isMultiplayerConnected()- Returns:
- true if the game is currently online
-
init
Loads a module object into the player window. Registers a singleton GameModule and invokesBuildable.build(org.w3c.dom.Element)
on it to build it from the XML buildFile. This will have the effect of invokingBuildable.build(org.w3c.dom.Element)
on all of the module's subcomponents as well, effectively building our whole component hierarchy from the XML.- Throws:
IOException
-
updateLastSave
public void updateLastSave()Save the current buildString for comparison when we try and quit. -
generateGpId
Allocates the next available GamePiece ID and returns it.- Specified by:
generateGpId
in interfaceGpIdSupport
- Returns:
- an available GpID
- See Also:
-
getNextGpId
public int getNextGpId()Description copied from interface:GpIdSupport
Accessors to check and update the next GpId if necessary.- Specified by:
getNextGpId
in interfaceGpIdSupport
- Returns:
- the next available GpId (GamePiece ID) (but doesn't allocate it -- for that see
generateGpId()
) - See Also:
-
setNextGpId
public void setNextGpId(int id) Sets the next available GamePiece ID- Specified by:
setNextGpId
in interfaceGpIdSupport
- Parameters:
id
- new value for nextGpId.- See Also:
-
setGpIdSupport
Registers a GamePiece ID support object for us to manage a namespace for unique GamePiece objects.- Parameters:
s
- GamePiece ID object
-
getGpIdSupport
- Returns:
- Our registered Game Piece ID namespace service provider.
-
getDataArchive
VASSAL modules are stored in ".vmod" files, which are actually simple ".zip" files with a unique extension.- Returns:
- the object which stores data for the module -- our .vmod Zip file.
-
getResourcePathFinder
-
getArchiveWriter
VASSAL modules are stored in ".vmod" files, which are actually simple ".zip" files with a unique extension. If the module is being edited, return the writeable archive for the module- Returns:
- the writer for our .vmod Zip file
-
getImageTileSource
- Returns:
- the object that provides tiling and caching services for tiling large map images.
-
isLocalizationEnabled
public boolean isLocalizationEnabled()Is the module being translated into the user's Locale? Localization is disabled when editing a module- Returns:
- true if the module/extension has been localized
-
isEditorOpen
public boolean isEditorOpen()Is an editor window currently open- Returns:
- true if we're running with an editor window
-
getGameModule
- Returns:
- the singleton instance of GameModule
-
getGameState
Return the object responsible for tracking the state of a game. Only one game in progress is allowed; -
saveAs
public void saveAs()If the module is being edited, write the module data after prompting for a new filename. -
save
public void save()If the module is being edited, write the module data to the current filename -
isRealName
public boolean isRealName()Returns true if user has supplied a real name Test's whether GameModule.REAL_NAME is non-empty and not "newbie"- Returns:
true
if user supplied a real name
-
isNonBlankPassword
public boolean isNonBlankPassword()Returns true if user has supplied a real password for current GameModule. Test's whether GameModule.SECRET_NAME is non-empty- Returns:
true
if user supplied a real password
-
getProperty
Gets the value of a module level global property -- this includes identification information for the local player as well as the contents of any Global Property objects defined at module level in the Module.- Specified by:
getProperty
in interfacePropertySource
- Parameters:
key
- identifies the global property to be returned- Returns:
- value of designated global property
-
refreshVisibleMaps
public final void refreshVisibleMaps()Refresh the visible portions of all currently showing maps. This is called in when the following are completed: - Any right-click menu option on a piece - Any Toolbar button action - Any Toolbar Menu item selection - Each Step replay from a log file - Each Undo - Each time a counter or stack is drag'n'dropped - Each message received during on-line play - Any click on an Action Button These eight actions can cause changes that result in text displaying Calculated properties and Beanshell expressions to change in places unrelated to where the action occurred, leaving these counters out of sync until a later click in their general area. -
getUiPieceCount
public int getUiPieceCount()Return number of pieces to be processed by the current multi-piece UI gesture -
getUiPieceIndex
public int getUiPieceIndex()Return the index of the current piece being processed by the current multi-piece UI gesture -
initializeUiPieceProcessing
public final void initializeUiPieceProcessing(int pieceCount) A multi-piece UI gesture is starting. Record the number of pieces to be processed and reset the counter.- Parameters:
pieceCount
- Number of pieces to be processed
-
processNextUiPiece
public final void processNextUiPiece()The next piece in a multi-piece UI gesture is about to be processed. -
finalizeUiPieceProcessing
public final void finalizeUiPieceProcessing()Record the end of a multi-piece UI gesture -
getPropertyNames
Description copied from class:AbstractBuildable
Override this method to provide a list of properties to be exposed for use by expressions in the module.- Specified by:
getPropertyNames
in interfacePropertyNameSource
- Overrides:
getPropertyNames
in classAbstractBuildable
- Returns:
- Default implementation of PropertyNameSource - No properties exposed
-
updateMutableButtonLabels
public void updateMutableButtonLabels()A property has changed somewhere, so we need to redraw all the toolbar buttons that use properties -
getMutableProperty
Gets the value of a mutable (changeable) "Global Property". Module level Global Properties serve as the "global variables" of a VASSAL Module, as they are accessible by any component at any time.- Specified by:
getMutableProperty
in interfaceMutablePropertiesContainer
- Parameters:
name
- identifies the Global Property whose value should be returned- Returns:
- value of designated global property
-
getTranslatableString
Description copied from interface:TranslatableStringContainer
Find an object with the given name- Specified by:
getTranslatableString
in interfaceTranslatableStringContainer
-
addMutableProperty
Adds a new mutable (changeable) "Global Property" to the Module. Module level Global Properties serve as the "global variables" of a VASSAL Module, as they are accessible by any component at any time.- Specified by:
addMutableProperty
in interfaceMutablePropertiesContainer
- Parameters:
key
- Name for the new Global Propertyp
- Starting property value
-
addTranslatableString
Description copied from interface:TranslatableStringContainer
Add a property under the given key- Specified by:
addTranslatableString
in interfaceTranslatableStringContainer
- Parameters:
key
- keyp
- property
-
removeMutableProperty
Removes a mutable property from the Global Properties list.- Specified by:
removeMutableProperty
in interfaceMutablePropertiesContainer
- Parameters:
key
- Name of the Global Property- Returns:
- the removed property, for some reason.
-
removeTranslatableString
Description copied from interface:TranslatableStringContainer
Remove the property with the given key- Specified by:
removeTranslatableString
in interfaceTranslatableStringContainer
- Parameters:
key
- key
-
getMutablePropertiesContainerId
Description copied from interface:MutablePropertiesContainer
Return a unique Id for the container- Specified by:
getMutablePropertiesContainerId
in interfaceMutablePropertiesContainer
- Returns:
- Identifies the ID/level for mutable properties stored here in the Module.
-
getTranslatableStringContainerId
Description copied from interface:TranslatableStringContainer
Return a unique Id for the container- Specified by:
getTranslatableStringContainerId
in interfaceTranslatableStringContainer
-
getLocalizedProperty
Description copied from interface:PropertySource
Returns a localized translation of the specified property value, if available. Otherwise returns the non-localized version.- Specified by:
getLocalizedProperty
in interfacePropertySource
- Parameters:
key
- Name of the property to get the value of- Returns:
- Localized/translated name of the named property, if one is available, otherwise returns the non-localized name
-
getCrc
public long getCrc()- Returns:
- a cumulative CRC from all of our files
-
getCrc
public long getCrc(boolean forceRegenerate) -
getCombinedCrc
public long getCombinedCrc() -
getCombinedCrc
public long getCombinedCrc(boolean forceRegenerate) -
getI18nData
- Specified by:
getI18nData
in interfaceTranslatable
- Overrides:
getI18nData
in classAbstractConfigurable
- Returns:
- the object containing the internationalization/localization information for this component
-
getPlayerRoster
- Returns:
- the
PlayerRoster
instance, ornull
if noPlayerRoster
exists within thisGameModule
-
addSideChangeListenerToPlayerRoster
Adds listener for players changing sides- Parameters:
l
- new SideChangeListener
-
removeSideChangeListenerFromPlayerRoster
Removes listener for players changing sides- Parameters:
l
- old SideChangeListener
-
getExpressionList
Description copied from class:AbstractConfigurable
- Specified by:
getExpressionList
in interfaceSearchTarget
- Overrides:
getExpressionList
in classAbstractConfigurable
- Returns:
- a list of the Configurables string/expression fields if any (for search)
-
updateTitleBar()