Package VASSAL.build.module
Class PlayerRoster
java.lang.Object
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.module.PlayerRoster
- All Implemented Interfaces:
AutoConfigurable
,Buildable
,Configurable
,GameComponent
,GameSetupStep
,PropertyNameSource
,CommandEncoder
,ValidityChecker
,Translatable
public class PlayerRoster extends AbstractConfigurable implements CommandEncoder, GameComponent, GameSetupStep
Maintains a list of players involved in the current game
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PlayerRoster.Add
static class
PlayerRoster.PlayerInfo
static interface
PlayerRoster.SideChangeListener
Call-back interface for when a player changes sides during a gameNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Fields Modifier and Type Field Description static String
BUTTON_ICON
static String
BUTTON_KEYSTROKE
static String
BUTTON_TEXT
static String
COMMAND_PREFIX
static String
OBSERVER
protected List<PlayerRoster.PlayerInfo>
players
protected LaunchButton
retireButton
protected List<PlayerRoster.SideChangeListener>
sideChangeListeners
protected StringEnumConfigurer
sideConfig
protected List<String>
sides
static String
SIDES
static String
TOOL_TIP
protected String
translatedObserver
protected String[]
untranslatedSides
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, name
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Constructor Summary
Constructors Constructor Description PlayerRoster()
-
Method Summary
Modifier and Type Method Description void
add(String playerId, String playerName, String side)
void
add(Buildable child)
Set the owning translatable of this componentvoid
addPropertyChangeListener(PropertyChangeListener l)
Add a PropertyChangeListener.static void
addSideChangeListener(PlayerRoster.SideChangeListener l)
Deprecated.void
addSideChangeListenerToInstance(PlayerRoster.SideChangeListener l)
void
addTo(Buildable b)
Adds this component to its parent.protected boolean
allSidesAllocated()
void
build(Element e)
Build this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
with the String value of the attributeCommand
decode(String command)
Translate a String into aCommand
String
encode(Command c)
Translate aCommand
into a Stringvoid
finish()
Apply the information gathered via the component to the game in progressprotected void
fireSideChange(String oldSide, String newSide)
Class<?>[]
getAllowableConfigureComponents()
Return a list of valid sub-component Classes.String[]
getAttributeDescriptions()
Return an array of Strings describing the attributes of this object.String[]
getAttributeNames()
PlayerRoster is not a true AbstractConfigurable, it handles it's own configuration.Class<?>[]
getAttributeTypes()
Return the Class for the buildFile (XML) attributes of this component.String
getAttributeValueString(String key)
Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML elementElement
getBuildElement(Document doc)
Configurable[]
getConfigureComponents()
String
getConfigureName()
ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager
.Configurer
getConfigurer()
static String
getConfigureTypeName()
Component
getControls()
A GUI component that prompts the player for the needed information.HelpFile
getHelpFile()
protected static PlayerRoster
getInstance()
Deprecated.static String
getMyLocalizedSide()
static String
getMySide()
protected static String
getMySide(boolean localized)
PlayerRoster.PlayerInfo[]
getPlayers()
Command
getRestoreCommand()
When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullprotected String
getSidesAsString()
String
getStepTitle()
A human-understandable description of this stepstatic boolean
isActive()
boolean
isFinished()
protected void
launch()
protected String
promptForSide()
void
remove(String playerId)
void
remove(Buildable child)
Remove a Buildable object from this objectvoid
removeFrom(Buildable parent)
Remove this component from its parentstatic void
removeSideChangeListener(PlayerRoster.SideChangeListener l)
void
setAttribute(String key, Object value)
Sets a buildFile (XML) attribute value for this component.void
setup(boolean gameStarting)
Notify the GameComponent that a game has started/endedprotected String
translateSide(String side)
protected String
untranslateSide(String side)
Methods inherited from class VASSAL.build.AbstractConfigurable
getAttributeVisibility, getI18nData, getI18nPrefix, getLocalizedConfigureName, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getComponents, getComponentsOf, getPropertyNames, validate
-
Field Details
-
BUTTON_ICON
- See Also:
- Constant Field Values
-
BUTTON_TEXT
- See Also:
- Constant Field Values
-
TOOL_TIP
- See Also:
- Constant Field Values
-
SIDES
- See Also:
- Constant Field Values
-
COMMAND_PREFIX
- See Also:
- Constant Field Values
-
OBSERVER
- See Also:
- Constant Field Values
-
BUTTON_KEYSTROKE
- See Also:
- Constant Field Values
-
players
-
sides
-
untranslatedSides
-
retireButton
-
sideChangeListeners
-
translatedObserver
-
sideConfig
-
-
Constructor Details
-
PlayerRoster
public PlayerRoster()
-
-
Method Details
-
removeFrom
Description copied from interface:Configurable
Remove this component from its parent- Specified by:
removeFrom
in interfaceConfigurable
-
remove
Description copied from class:AbstractConfigurable
Remove a Buildable object from this object- Specified by:
remove
in interfaceConfigurable
- Overrides:
remove
in classAbstractConfigurable
-
build
Description copied from class:AbstractBuildable
Build this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
with the String value of the attribute- Specified by:
build
in interfaceBuildable
- Overrides:
build
in classAbstractBuildable
- Parameters:
e
- the XML element containing the object data
-
getConfigureName
Description copied from class:AbstractConfigurable
ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager
.- Specified by:
getConfigureName
in interfaceConfigurable
- Overrides:
getConfigureName
in classAbstractConfigurable
- Returns:
- The language-independent name of this component used for programmatic identification (including within Modules by e.g. Traits and module components)
-
getConfigureTypeName
-
add
Description copied from class:AbstractConfigurable
Set the owning translatable of this component- Specified by:
add
in interfaceBuildable
- Overrides:
add
in classAbstractConfigurable
-
getConfigureComponents
- Specified by:
getConfigureComponents
in interfaceConfigurable
- Overrides:
getConfigureComponents
in classAbstractConfigurable
- Returns:
- A list of all child components (i.e. subcomponents) of this component that are configurable.
-
getBuildElement
- Specified by:
getBuildElement
in interfaceBuildable
- Overrides:
getBuildElement
in classAbstractBuildable
- Returns:
- an XML element from which this component can be built
-
getConfigurer
Description copied from class:AbstractConfigurable
- Specified by:
getConfigurer
in interfaceConfigurable
- Overrides:
getConfigurer
in classAbstractConfigurable
- Returns:
- Configurer for this component
-
addPropertyChangeListener
Description copied from interface:Configurable
Add a PropertyChangeListener. A PropertyChangeEvent should be fired with property nameConfigurable.NAME_PROPERTY
when the value returned fromConfigurable.getConfigureName()
has changed- Specified by:
addPropertyChangeListener
in interfaceConfigurable
- Overrides:
addPropertyChangeListener
in classAbstractConfigurable
-
addSideChangeListener
-
addSideChangeListenerToInstance
-
removeSideChangeListener
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- a HelpFilte describing how to use and configure this component
-
getAllowableConfigureComponents
Description copied from interface:Configurable
Return 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 Configuration Window.- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
-
addTo
Description copied from interface:Buildable
Adds this component to its parent. In order to make Buildable objects extensible, the child is reponsible for adding itself to the parent. That way, Buildable subcomponents can be defined in an extension package without needing to modify the containing class. -
launch
protected void launch() -
fireSideChange
-
isActive
public static boolean isActive() -
getInstance
Deprecated. -
getMySide
-
getMyLocalizedSide
-
getMySide
-
getPlayers
-
add
-
remove
-
decode
Description copied from interface:CommandEncoder
Translate a String into aCommand
- Specified by:
decode
in interfaceCommandEncoder
-
encode
Description copied from interface:CommandEncoder
Translate aCommand
into a String- Specified by:
encode
in interfaceCommandEncoder
-
getRestoreCommand
Description copied from interface:GameComponent
When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null- Specified by:
getRestoreCommand
in interfaceGameComponent
-
setup
public void setup(boolean gameStarting)Description copied from interface:GameComponent
Notify the GameComponent that a game has started/ended- Specified by:
setup
in interfaceGameComponent
- Parameters:
gameStarting
- if true, a game is starting. If false, then a game is ending
-
finish
public void finish()Description copied from interface:GameSetupStep
Apply the information gathered via the component to the game in progress- Specified by:
finish
in interfaceGameSetupStep
-
getControls
Description copied from interface:GameSetupStep
A GUI component that prompts the player for the needed information. If null, then no further information is needed- Specified by:
getControls
in interfaceGameSetupStep
-
getStepTitle
Description copied from interface:GameSetupStep
A human-understandable description of this step- Specified by:
getStepTitle
in interfaceGameSetupStep
-
isFinished
public boolean isFinished()- Specified by:
isFinished
in interfaceGameSetupStep
- Returns:
- true if this step needs no further information, false if the player should be prompted for more information
-
allSidesAllocated
protected boolean allSidesAllocated()- Returns:
- true if all sides have been claimed by a player
-
promptForSide
-
getAttributeNames
PlayerRoster is not a true AbstractConfigurable, it handles it's own configuration. Implement the rest of the AbstractConfigurable abstract classes for i18n.- Specified by:
getAttributeNames
in interfaceAutoConfigurable
- Specified by:
getAttributeNames
in classAbstractBuildable
- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeTypes
Description copied from class:AbstractConfigurable
Return 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 ofAutoConfigurer
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()
- Specified by:
getAttributeTypes
in interfaceAutoConfigurable
- Specified by:
getAttributeTypes
in classAbstractConfigurable
-
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:
key
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
- Returns:
- a String representation of the attribute with the given name. When initializing a module, this String value will be passed to
AbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
.
-
setAttribute
Description copied from class:AbstractBuildable
Sets a buildFile (XML) attribute value for this component. Thekey
parameter will be one of those listed inAbstractBuildable.getAttributeNames()
. If thevalue
parameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
will be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
- Specified by:
setAttribute
in interfaceAutoConfigurable
- Specified by:
setAttribute
in interfaceTranslatable
- Specified by:
setAttribute
in classAbstractBuildable
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
can also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
getSidesAsString
-
untranslateSide
-
translateSide
-
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()
-
GameModule.addSideChangeListenerToPlayerRoster(SideChangeListener)