Package VASSAL.build.module
Class PlayerRoster
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.AbstractToolbarItem
VASSAL.build.module.PlayerRoster
- All Implemented Interfaces:
AutoConfigurable,Buildable,Configurable,GameComponent,GameSetupStep,PropertyNameSource,CommandEncoder,ValidityChecker,Translatable,ImageSearchTarget,SearchTarget
public class PlayerRoster extends AbstractToolbarItem 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 class VASSAL.build.AbstractToolbarItem
AbstractToolbarItem.IconConfigNested 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 StringMODERATORstatic StringOBSERVERprotected List<PlayerRoster.PlayerInfo>playersstatic StringREFEREEprotected LaunchButtonretireButtonprotected List<PlayerRoster.SideChangeListener>sideChangeListenersprotected StringEnumConfigurersideConfigprotected List<String>sidesstatic StringSIDESstatic StringSOLITAIREstatic StringSOLOstatic 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)Default behavior adds the button to the module toolbar.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()String[]getAttributeDescriptions()This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.String[]getAttributeNames()PlayerRoster is not a true AbstractConfigurable, it handles it's own configuration.Class<?>[]getAttributeTypes()This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.StringgetAttributeValueString(String key)Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.ElementgetBuildElement(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()List<String>getPropertyList()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 nullList<String>getSides()protected StringgetSidesAsString()StringgetStepTitle()A human-understandable description of this stepstatic booleanisActive()booleanisFinished()booleanisMultiPlayer()static booleanisSoloSide(String side)protected voidlaunch()protected StringpromptForSide()voidremove(String playerId)voidremove(Buildable child)Remove a Buildable object from this objectvoidremoveFrom(Buildable parent)Default behavior assumes we are removing this from the module toolbarstatic voidremoveSideChangeListener(PlayerRoster.SideChangeListener l)voidsetAttribute(String key, Object value)Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.voidsetup(boolean gameStarting)Notify the GameComponent that a game has started/endedStringtranslateSide(String side)StringuntranslateSide(String side)Methods inherited from class VASSAL.build.AbstractToolbarItem
addLocalImageNames, getComponent, getLaunchButton, getMenuTextList, getNamedKeyStrokeList, makeLaunchButton, setButtonTextKey, setHotKeyKey, setIconKey, setLaunchButton, setNameKey, setTooltipKeyMethods inherited from class VASSAL.build.AbstractConfigurable
getAttributeVisibility, getExpressionList, getFormattedStringList, getI18nData, getI18nPrefix, getLocalizedConfigureName, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getComponents, getComponentsOf, getPropertyNames, validateMethods inherited from class VASSAL.search.AbstractImageFinder
getAllImageNames, getLocalImageNames
-
Field Details
-
BUTTON_ICON
- See Also:
- Constant Field Values
-
BUTTON_TEXT
- See Also:
- Constant Field Values
-
TOOL_TIP
- See Also:
- Constant Field Values
-
BUTTON_KEYSTROKE
- See Also:
- Constant Field Values
-
SIDES
- See Also:
- Constant Field Values
-
COMMAND_PREFIX
- See Also:
- Constant Field Values
-
OBSERVER
- See Also:
- Constant Field Values
-
SOLITAIRE
- See Also:
- Constant Field Values
-
REFEREE
- See Also:
- Constant Field Values
-
SOLO
- See Also:
- Constant Field Values
-
MODERATOR
- See Also:
- Constant Field Values
-
players
-
sides
-
untranslatedSides
-
retireButton
-
sideChangeListeners
-
translatedObserver
-
sideConfig
-
-
Constructor Details
-
PlayerRoster
public PlayerRoster()
-
-
Method Details
-
removeFrom
Description copied from class:AbstractToolbarItemDefault behavior assumes we are removing this from the module toolbar- Specified by:
removeFromin interfaceConfigurable- Overrides:
removeFromin classAbstractToolbarItem- Parameters:
parent- parent
-
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- Parameters:
child- Child to attach to this buildable as a subcomponent
-
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- Parameters:
doc- XML file- 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 HelpFile describing how to use and configure * this component
-
getAllowableConfigureComponents
- 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.
-
addTo
Description copied from class:AbstractToolbarItemDefault behavior adds the button to the module toolbar.- Specified by:
addToin interfaceBuildable- Overrides:
addToin classAbstractToolbarItem- Parameters:
b- parent Buildable to add this component to as a subcomponent.
-
launch
protected void launch() -
fireSideChange
-
isActive
public static boolean isActive() -
getInstance
Deprecated. -
getMySide
-
getMyLocalizedSide
-
getMySide
-
getPlayers
-
getSides
-
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
-
isSoloSide
- Parameters:
side- Name of a side to see if it's a "solo side"- Returns:
- True if the side is "Solitaire", "Solo", "Moderator", or "Referee"
-
isMultiPlayer
public boolean isMultiPlayer()- Returns:
- True if this is currently a multiPlayer game (either connected to a server, or more than one player side allocated)
-
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- Overrides:
getAttributeNamesin classAbstractToolbarItem- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeTypes
Description copied from class:AbstractToolbarItemThis getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeTypes(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeTypesin interfaceAutoConfigurable- Overrides:
getAttributeTypesin classAbstractToolbarItem- 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 in
AbstractBuildable.getAttributeNames()
-
getAttributeValueString
Description copied from class:AbstractToolbarItemClasses extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.- Specified by:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Overrides:
getAttributeValueStringin classAbstractToolbarItem- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractToolbarItem.getAttributeNames()- Returns:
- a String representation of the XML buildFile attribute with the given name. When initializing a module,
this String value will loaded from the XML and passed to
AbstractToolbarItem.setAttribute(java.lang.String, java.lang.Object). It is also frequently used for checking the current value of an attribute.
-
setAttribute
Description copied from class:AbstractToolbarItemClasses extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button. Sets a buildFile (XML) attribute value for this component. Thekeyparameter will be one of those listed inAbstractToolbarItem.getAttributeNames(). If thevalueparameter is a String, it will be the value returned byAbstractToolbarItem.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- Overrides:
setAttributein classAbstractToolbarItem- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractToolbarItem.getAttributeNames()value- If thevalueparameter is a String, it will be the value returned byAbstractToolbarItem.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 class:AbstractToolbarItemThis getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeDescriptions(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeDescriptionsin interfaceAutoConfigurable- Overrides:
getAttributeDescriptionsin classAbstractToolbarItem- 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()
-
getPropertyList
- Specified by:
getPropertyListin interfaceSearchTarget- Overrides:
getPropertyListin classAbstractConfigurable- Returns:
- a list of any Property Names referenced in the Configurable, if any (for search)
-
GameModule.addSideChangeListenerToPlayerRoster(SideChangeListener)