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
Nested ClassesModifier and TypeClassDescriptionstatic enumLast 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 final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThePrefskey for the user's personal infostatic final StringThePrefskey for the user's real namestatic final Stringstatic final StringThePrefskey for the user's secret namestatic final Stringstatic final Stringstatic final Stringstatic final 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 keyvoidDeprecated, 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 voidcreatePiece(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).final voidRecord the end of a multi-piece UI gesturevoidfireKeyStroke(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.Called by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML elementlonglonggetCombinedCrc(boolean forceRegenerate) static StringGets the generic name for this type of class across all instances of it.longgetCrc()longgetCrc(boolean forceRegenerate) VASSAL modules are stored in ".vmod" files, which are actually simple ".zip" files with a unique extension.getFrame()Deprecated.static GameModuleReturn 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".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.Override this method to provide a list of properties to be exposed for use by expressions 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 containerintReturn number of pieces to be processed by the current multi-piece UI gestureintReturn the index of the current piece being processed by the current multi-piece UI gesturestatic StringgetWindowTitleString(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 voidinit(GameModule module) Loads a module object into the player window.voidSets the proper name for module window's title barfinal voidinitializeUiPieceProcessing(int pieceCount) A multi-piece UI gesture is starting.booleanIs an editor window currently openstatic booleanbooleanbooleanbooleanIs the module being translated into the user's Locale? Localization is disabled when editing a modulebooleanbooleanbooleanbooleanbooleanReturns true if user has supplied a real password for current GameModule.booleanReturns true if user has supplied a real name Test's whether GameModule.REAL_NAME is non-empty and not "newbie"booleanbooleanbooleanbooleanbooleanbooleanbooleanPause logging and return true if successful.final voidThe next piece in a multi-piece UI gesture is about to be processed.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 KeyStrokeListenersfinal voidRefresh the visible portions of all currently showing maps.voidThis 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 namesvoidRemoves 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.voidWhen 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.voidAllows 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.voidRegisters a GamePiece ID support object for us to manage a namespace for unique GamePiece objects.voidsetLoadingContinuationSemaphore(boolean state) voidsetLoadOverSemaphore(boolean state) voidvoidsetMatSupport(boolean matSupport) voidsetMutableButtonSupport(boolean support) 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) voidsetSuppressAutoCenterUpdate(boolean suppressAutoCenterUpdate) voidsetSuppressSounds(boolean suppressSounds) static voidsetTempUserId(String id) voidsetTrueMovedSupport(boolean trueMovedSupport) 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.voidA property has changed somewhere, so we need to redraw all the toolbar buttons that use propertiesvoidUpdates 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, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, setAncestor, 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.script.expression.Auditable
getComponentName, getComponentTypeNameMethods inherited from interface VASSAL.build.Buildable
getBuildElement, isMandatory, isMovable, isUniqueMethods 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:
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)
-
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:
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:
-
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:
-
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:
-
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:
-
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 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
-
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 aCommandEncoderto the list of objects that will attempt to decode/encode a command.- See Also:
-
removeCommandEncoder
This method removes aCommandEncoderfrom 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 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
-
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:
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 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 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:
-
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:
generateGpIdin interfaceGpIdSupport- Returns:
- an available GpID
- See Also:
-
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:
-
setNextGpId
public void setNextGpId(int id) Sets the next available GamePiece ID- Specified by:
setNextGpIdin 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:
trueif 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:
trueif 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:
getPropertyin 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:AbstractBuildableOverride this method to provide a list of properties to be exposed for use by expressions in the module.- Specified by:
getPropertyNamesin interfacePropertyNameSource- Overrides:
getPropertyNamesin 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:
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
-
getCrc
public long getCrc(boolean forceRegenerate) -
getCombinedCrc
public long getCombinedCrc() -
getCombinedCrc
public long getCombinedCrc(boolean forceRegenerate) -
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()