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,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
Nested ClassesModifier and TypeClassDescriptionstatic classLast type of game save/load for our current gameNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.UtilNested classes/interfaces inherited from interface VASSAL.build.module.properties.MutablePropertiesContainer
MutablePropertiesContainer.ImplNested classes/interfaces inherited from interface VASSAL.build.module.properties.TranslatableStringContainer
TranslatableStringContainer.Impl -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic StringThePrefskey for the user's personal infostatic StringThePrefskey for the user's real namestatic StringThePrefskey for the user's secret namestatic Stringstatic StringThe 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, nameFields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validatorFields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidGameModule holds the master list of CommandEncoders, and invokes them as appropriate when commands are sent and received.voidCurrently used to listen for changes to player namesvoidThe GameModule acts as the mediator for hotkey events.voidThe GameModule acts as the mediator for hotkey events.voidaddMutableProperty(String key, MutableProperty p)Adds a new mutable (changeable) "Global Property" to the Module.voidAdds listener for players changing sidesvoidGame Module is normally at the root of the hierarchy, so it doesn't expect to get added to anything.voidAdd a property under the given keyvoidappendToTitle(String s)Deprecated, for removal: This API element is subject to removal in a future version.voidBuilds the module's component hierarchy from a given XML element, or a null one is given initializes a brand new default "new module" hierarchy.voidClear outstanding Commands Use where the calling level handles the sending of outstanding commandsstatic voidstatic intcompareVersions(String v1, String v2)Deprecated, for removal: This API element is subject to removal in a future version.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 inboundCommandtraffic -- incoming player commands ready to be executed.Encodes our outboundCommandtraffic -- outgoing player commands to be sent to other players' clients via either online (server) or logfile (PBEM).voidfireKeyStroke(KeyStroke stroke)Deprecated, for removal: This API element is subject to removal in a future version.voidfireKeyStroke(NamedKeyStroke stroke)Invokes aNamedKeyStroketo all of our listeners.Allocates the next available GamePiece ID and returns it.static StringClass<?>[]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.getAttributeValueString(String name)Called by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML elementstatic StringGets the generic name for this type of class across all instances of it.longgetCrc()VASSAL modules are stored in ".vmod" files, which are actually simple ".zip" files with a unique extension.Deprecated, for removal: This API element is subject to removal in a future version.UsegetFileChooser()instead.getFrame()Deprecated, for removal: This API element is subject to removal in a future version.static GameModuleReturn the object responsible for tracking the state of a game.Deprecated, for removal: This API element is subject to removal in a future version.getLocalizedProperty(Object key)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".intAccessors to check and update the next GpId if necessary."Player" in this context meaning the VASSAL Player, i.e.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.getRNG()static StringReturns 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 containerstatic StringgetWindowTitleString(String key, String name)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 voidinit(GameModule module)Loads a module object into the player window.voidSets the proper name for module window's title barbooleanIs an editor window currently openstatic booleanbooleanbooleanbooleanIs the module being translated into the user's Locale? Localization is disabled when editing a modulebooleanbooleanbooleanbooleanbooleanPause logging and return true if successful.voidquit()Exit the application, prompting user to save if necessaryvoidIf our keyboard mapping paradigm changes (example: Mac Legacy preference checked/unchecked), we need to reregister all of our KeyStrokeListenersvoidThis method removes aCommandEncoderfrom the list of objects that will attempt to decode/encode a commandvoidremoveFrom(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.voidCurrently used to listen for changes to player namesvoidremoveMutableProperty(String key)Removes a mutable property from the Global Properties list.voidRemoves listener for players changing sidesRemove the property with the given keyvoidRestart logging and return any outstanding commandsvoidsave()If the module is being edited, write the module data to the current filenamevoidsaveAs()If the module is being edited, write the module data after prompting for a new filename.voidsendAndLog(Command c)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 aCommandand sent here.voidsetAttribute(String name, Object value)Sets a buildFile (XML) attribute value for this component.voidsetChatter(Chatter c)Allows the Chat Log window to register itself to the Module.voidsetDirty(boolean touchThis)static voidsetErrorLogToChat(boolean errorLogToChat)voidsetGameFile(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.voidSets the type of interaction we most recently had with saving/loading/replaying/logging, for managing title bars of windows.voidsetGlobalPrefs(Prefs p)Deprecated, for removal: This API element is subject to removal in a future version.no replacementvoidRegisters a GamePiece ID support object for us to manage a namespace for unique GamePiece objects.voidsetLoadingContinuationSemaphore(boolean state)voidsetLoadOverSemaphore(boolean state)voidsetNextGpId(int id)Sets the next available GamePiece IDvoidsetPieceWindow(PieceWindow pieceWindow)Allows a PieceWindow that wants to be our docked PieceWindow to register itself.voidvoidsetRefreshingSemaphore(boolean state)static voidsetTempUserId(String id)static voidSet the identifier for the userbooleanshutDown()Prompt user to save open game and modules/extensions being editedtoString()voidSave the current buildString for comparison when we try and quit.voidUpdates the title bar of the main module window, and all map windowsvoidDisplay 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, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getPropertyNames, validateMethods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNamesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface VASSAL.build.Buildable
getBuildElement
-
Field Details
-
MODULE_NAME
- See Also:
- Constant Field Values
-
MODULE_VERSION
- See Also:
- Constant Field Values
-
DESCRIPTION
- See Also:
- Constant Field Values
-
VASSAL_VERSION_CREATED
- See Also:
- Constant Field Values
-
VASSAL_VERSION_RUNNING
The System property of this name will return a version identifier for the version of VASSAL being run- See Also:
- Constant Field Values
-
NEXT_PIECESLOT_ID
- See Also:
- Constant Field Values
-
BUILDFILE
- See Also:
- Constant Field Values
-
BUILDFILE_OLD
- See Also:
- Constant Field Values
-
REAL_NAME
ThePrefskey for the user's real name- See Also:
- Constant Field Values
-
SECRET_NAME
ThePrefskey for the user's secret name- See Also:
- Constant Field Values
-
PERSONAL_INFO
ThePrefskey for the user's personal info- See Also:
- Constant Field Values
-
MODULE_NAME_PROPERTY
- See Also:
- Constant Field Values
-
MODULE_VERSION_PROPERTY
- See Also:
- Constant Field Values
-
MODULE_DESCRIPTION_PROPERTY
- See Also:
- Constant Field Values
-
MODULE_OTHER1_PROPERTY
- See Also:
- Constant Field Values
-
MODULE_OTHER2_PROPERTY
- See Also:
- Constant Field Values
-
MODULE_VASSAL_VERSION_CREATED_PROPERTY
- See Also:
- Constant Field Values
-
MODULE_VASSAL_VERSION_RUNNING_PROPERTY
- See Also:
- Constant Field Values
-
MODULE_CURRENT_LOCALE
- See Also:
- Constant Field Values
-
MODULE_CURRENT_LOCALE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Details
-
GameModule
Constructor for a GameModule.- Parameters:
archive- The .vmod (or .tmp) archive to associate
-
-
Method Details
-
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, for removal: This API element is subject to removal in a future version.- 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.
-
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:
getI18nPrefixin 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:
buildin interfaceBuildable- Overrides:
buildin 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:
setAttributein interfaceAutoConfigurable- Specified by:
setAttributein interfaceTranslatable- Specified by:
setAttributein classAbstractBuildable- Parameters:
name- the name of the attribute. Will be one of those listed ingetAttributeNames()value- If thevalueparameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan also be an instance of
-
getAttributeValueString
Description copied from interface:AutoConfigurableCalled by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML element- Specified by:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Specified by:
getAttributeValueStringin 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)
-
compareVersions
@Deprecated(since="2020-08-06", forRemoval=true) public static int compareVersions(String v1, String v2)Deprecated, for removal: This API element is subject to removal in a future version.A valid version format is "w.x.y[bz]", where 'w','x','y', and 'z' are integers.- Returns:
- a negative number if
v2is a later version thev1, a positive number if an earlier version, or zero if the versions are the same.
-
addTo
Game Module is normally at the root of the hierarchy, so it doesn't expect to get added to anything. -
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:
removeFromin interfaceConfigurable- Parameters:
parent- Notional "parent" of this GameModule
-
getHelpFile
- Specified by:
getHelpFilein 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:
getAttributeNamesin interfaceAutoConfigurable- Specified by:
getAttributeNamesin classAbstractBuildable- Returns:
- a list of all buildFile (XML) attribute names for this component
- See Also:
AbstractBuildable
-
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:
- 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:
AbstractConfigurable
-
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:
- 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
AutoConfigurerwill 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:
AbstractConfigurable
-
getAllowableConfigureComponents
List of subcomponents which can be added to a GameModule.- Specified by:
getAllowableConfigureComponentsin 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
ConfigureTreewindow by right-clicking on the component and selecting the appropriate "Add" option. - See Also:
Configurable
-
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
Deprecated, for removal: This API element is subject to removal in a future version. -
fireKeyStroke
Invokes aNamedKeyStroketo 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
-
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
-
getGlobalPrefs
Deprecated, for removal: This API element is subject to removal in a future version.A set of preferences that applies to all modules -
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 aCommandEncoderto the list of objects that will attempt to decode/encode a command. -
removeCommandEncoder
This method removes aCommandEncoderfrom the list of objects that will attempt to decode/encode a command -
createPiece
Central location to create any type of GamePiece from within VASSAL- Parameters:
type- String definition of the piece- Returns:
- Created Piece
-
createPiece
Central location to create any type of GamePiece Trait (Decorator) from within VASSAL- Parameters:
type- String definition of the Trait (Decorator)- Returns:
- Created Piece
-
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
-
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
-
setGlobalPrefs
Deprecated, for removal: This API element is subject to removal in a future version.no replacement -
decode
Decodes our inboundCommandtraffic -- 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 registeredCommandEncoders in turn until one of them is able to deserialize the command from a String into aCommandobject ready to be executed.- Specified by:
decodein interfaceCommandEncoder
-
encode
Encodes our outboundCommandtraffic -- 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 registeredCommandEncoders in turn until one of them is able to serialize theCommandobject 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:
encodein interfaceCommandEncoder
-
getFileChooser
- Returns:
- a common FileChooser so that recent file locations can be remembered
-
getFileDialog
Deprecated, for removal: This API element is subject to removal in a future version.UsegetFileChooser()instead. -
getToolBar
Provides access to the Game Module's toolbar.- Specified by:
getToolBarin 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 generated- Returns:
- appropriate title bar string for a window.
-
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 aCommandand 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- TheCommandto be sent and logged.- See Also:
encode(VASSAL.command.Command)
-
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
Restart logging and return any outstanding commands- Returns:
- any outstanding
Command(can contain multiple chained commands)
-
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.
-
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:
generateGpIdin interfaceGpIdSupport- Returns:
- an available GpID
- See Also:
GpIdSupport
-
getNextGpId
public int getNextGpId()Description copied from interface:GpIdSupportAccessors to check and update the next GpId if necessary.- Specified by:
getNextGpIdin interfaceGpIdSupport- Returns:
- the next available GpId (GamePiece ID) (but doesn't allocate it -- for that see
generateGpId()) - See Also:
GpIdSupport
-
setNextGpId
public void setNextGpId(int id)Sets the next available GamePiece ID- Specified by:
setNextGpIdin interfaceGpIdSupport- Parameters:
id- new value for nextGpId.- See Also:
GpIdSupport
-
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 -
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:
getPropertyin interfacePropertySource- Parameters:
key- identifies the global property to be returned- Returns:
- value of designated global property
-
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:
getMutablePropertyin interfaceMutablePropertiesContainer- Parameters:
name- identifies the Global Property whose value should be returned- Returns:
- value of designated global property
-
getTranslatableString
Description copied from interface:TranslatableStringContainerFind an object with the given name- Specified by:
getTranslatableStringin 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:
addMutablePropertyin interfaceMutablePropertiesContainer- Parameters:
key- Name for the new Global Propertyp- Starting property value
-
addTranslatableString
Description copied from interface:TranslatableStringContainerAdd a property under the given key- Specified by:
addTranslatableStringin interfaceTranslatableStringContainer- Parameters:
key- keyp- property
-
removeMutableProperty
Removes a mutable property from the Global Properties list.- Specified by:
removeMutablePropertyin interfaceMutablePropertiesContainer- Parameters:
key- Name of the Global Property- Returns:
- the removed property, for some reason.
-
removeTranslatableString
Description copied from interface:TranslatableStringContainerRemove the property with the given key- Specified by:
removeTranslatableStringin interfaceTranslatableStringContainer- Parameters:
key- key
-
getMutablePropertiesContainerId
Description copied from interface:MutablePropertiesContainerReturn a unique Id for the container- Specified by:
getMutablePropertiesContainerIdin interfaceMutablePropertiesContainer- Returns:
- Identifies the ID/level for mutable properties stored here in the Module.
-
getTranslatableStringContainerId
Description copied from interface:TranslatableStringContainerReturn a unique Id for the container- Specified by:
getTranslatableStringContainerIdin interfaceTranslatableStringContainer
-
getLocalizedProperty
Description copied from interface:PropertySourceReturns a localized translation of the specified property value, if available. Otherwise returns the non-localized version.- Specified by:
getLocalizedPropertyin 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
-
getI18nData
- Specified by:
getI18nDatain interfaceTranslatable- Overrides:
getI18nDatain classAbstractConfigurable- Returns:
- the object containing the internationalization/localization information for this component
-
getPlayerRoster
- Returns:
- the
PlayerRosterinstance, ornullif noPlayerRosterexists 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:
getExpressionListin interfaceSearchTarget- Overrides:
getExpressionListin classAbstractConfigurable- Returns:
- a list of the Configurables string/expression fields if any (for search)
-
updateTitleBar()