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 classPlayerRoster.Addstatic classPlayerRoster.PlayerInfostatic interfacePlayerRoster.SideChangeListenerCall-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 StringBUTTON_ICONstatic StringBUTTON_KEYSTROKEstatic StringBUTTON_TEXTstatic StringCOMMAND_PREFIXstatic StringOBSERVERprotected List<PlayerRoster.PlayerInfo>playersprotected LaunchButtonretireButtonprotected List<PlayerRoster.SideChangeListener>sideChangeListenersprotected StringEnumConfigurersideConfigprotected List<String>sidesstatic StringSIDESstatic StringTOOL_TIPprotected StringtranslatedObserverprotected String[]untranslatedSidesFields 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 Constructor Description PlayerRoster() -
Method Summary
Modifier and Type Method Description voidadd(String playerId, String playerName, String side)voidadd(Buildable child)Set the owning translatable of this componentvoidaddPropertyChangeListener(PropertyChangeListener l)Add a PropertyChangeListener.static voidaddSideChangeListener(PlayerRoster.SideChangeListener l)Deprecated.voidaddSideChangeListenerToInstance(PlayerRoster.SideChangeListener l)voidaddTo(Buildable b)Adds this component to its parent.protected booleanallSidesAllocated()voidbuild(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 attributeCommanddecode(String command)Translate a String into aCommandStringencode(Command c)Translate aCommandinto a Stringvoidfinish()Apply the information gathered via the component to the game in progressprotected voidfireSideChange(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.StringgetAttributeValueString(String key)Called by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML elementElementgetBuildElement(Document doc)Configurable[]getConfigureComponents()StringgetConfigureName()ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager.ConfigurergetConfigurer()static StringgetConfigureTypeName()ComponentgetControls()A GUI component that prompts the player for the needed information.HelpFilegetHelpFile()protected static PlayerRostergetInstance()Deprecated.static StringgetMyLocalizedSide()static StringgetMySide()protected static StringgetMySide(boolean localized)PlayerRoster.PlayerInfo[]getPlayers()CommandgetRestoreCommand()When saving a game, each GameComponent should return aCommandthat, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullprotected StringgetSidesAsString()StringgetStepTitle()A human-understandable description of this stepstatic booleanisActive()booleanisFinished()protected voidlaunch()protected StringpromptForSide()voidremove(String playerId)voidremove(Buildable child)Remove a Buildable object from this objectvoidremoveFrom(Buildable parent)Remove this component from its parentstatic voidremoveSideChangeListener(PlayerRoster.SideChangeListener l)voidsetAttribute(String key, Object value)Sets a buildFile (XML) attribute value for this component.voidsetup(boolean gameStarting)Notify the GameComponent that a game has started/endedprotected StringtranslateSide(String side)protected StringuntranslateSide(String side)Methods inherited from class VASSAL.build.AbstractConfigurable
getAttributeVisibility, getI18nData, getI18nPrefix, getLocalizedConfigureName, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods 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:ConfigurableRemove this component from its parent- Specified by:
removeFromin interfaceConfigurable
-
remove
Description copied from class:AbstractConfigurableRemove a Buildable object from this object- Specified by:
removein interfaceConfigurable- Overrides:
removein classAbstractConfigurable
-
build
Description copied from class:AbstractBuildableBuild 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:
buildin interfaceBuildable- Overrides:
buildin classAbstractBuildable- Parameters:
e- the XML element containing the object data
-
getConfigureName
Description copied from class:AbstractConfigurableConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager.- Specified by:
getConfigureNamein interfaceConfigurable- Overrides:
getConfigureNamein 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:AbstractConfigurableSet the owning translatable of this component- Specified by:
addin interfaceBuildable- Overrides:
addin classAbstractConfigurable
-
getConfigureComponents
- Specified by:
getConfigureComponentsin interfaceConfigurable- Overrides:
getConfigureComponentsin classAbstractConfigurable- Returns:
- A list of all child components (i.e. subcomponents) of this component that are configurable.
-
getBuildElement
- Specified by:
getBuildElementin interfaceBuildable- Overrides:
getBuildElementin classAbstractBuildable- Returns:
- an XML element from which this component can be built
-
getConfigurer
Description copied from class:AbstractConfigurable- Specified by:
getConfigurerin interfaceConfigurable- Overrides:
getConfigurerin classAbstractConfigurable- Returns:
- Configurer for this component
-
addPropertyChangeListener
Description copied from interface:ConfigurableAdd a PropertyChangeListener. A PropertyChangeEvent should be fired with property nameConfigurable.NAME_PROPERTYwhen the value returned fromConfigurable.getConfigureName()has changed- Specified by:
addPropertyChangeListenerin interfaceConfigurable- Overrides:
addPropertyChangeListenerin classAbstractConfigurable
-
addSideChangeListener
-
addSideChangeListenerToInstance
-
removeSideChangeListener
-
getHelpFile
- Specified by:
getHelpFilein interfaceConfigurable- Returns:
- a HelpFilte describing how to use and configure this component
-
getAllowableConfigureComponents
Description copied from interface:ConfigurableReturn 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:
getAllowableConfigureComponentsin interfaceConfigurable
-
addTo
Description copied from interface:BuildableAdds 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:CommandEncoderTranslate a String into aCommand- Specified by:
decodein interfaceCommandEncoder
-
encode
Description copied from interface:CommandEncoderTranslate aCommandinto a String- Specified by:
encodein interfaceCommandEncoder
-
getRestoreCommand
Description copied from interface:GameComponentWhen saving a game, each GameComponent should return aCommandthat, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null- Specified by:
getRestoreCommandin interfaceGameComponent
-
setup
public void setup(boolean gameStarting)Description copied from interface:GameComponentNotify the GameComponent that a game has started/ended- Specified by:
setupin interfaceGameComponent- Parameters:
gameStarting- if true, a game is starting. If false, then a game is ending
-
finish
public void finish()Description copied from interface:GameSetupStepApply the information gathered via the component to the game in progress- Specified by:
finishin interfaceGameSetupStep
-
getControls
Description copied from interface:GameSetupStepA GUI component that prompts the player for the needed information. If null, then no further information is needed- Specified by:
getControlsin interfaceGameSetupStep
-
getStepTitle
Description copied from interface:GameSetupStepA human-understandable description of this step- Specified by:
getStepTitlein interfaceGameSetupStep
-
isFinished
public boolean isFinished()- Specified by:
isFinishedin 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:
getAttributeNamesin interfaceAutoConfigurable- Specified by:
getAttributeNamesin classAbstractBuildable- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeTypes
Description copied from class:AbstractConfigurableReturn 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 ofAutoConfigurerwill 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:
getAttributeTypesin interfaceAutoConfigurable- Specified by:
getAttributeTypesin classAbstractConfigurable
-
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:
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:AbstractBuildableSets a buildFile (XML) attribute value for this component. Thekeyparameter will be one of those listed inAbstractBuildable.getAttributeNames(). If thevalueparameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluewill be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()- Specified by:
setAttributein interfaceAutoConfigurable- Specified by:
setAttributein interfaceTranslatable- Specified by:
setAttributein classAbstractBuildable- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()value- If thevalueparameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
getSidesAsString
-
untranslateSide
-
translateSide
-
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()
-
GameModule.addSideChangeListenerToPlayerRoster(SideChangeListener)