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 ClassesModifier and TypeClassDescriptionstatic class
static class
static interface
Call-back interface for when a player changes sides during a gameNested classes/interfaces inherited from class VASSAL.build.AbstractToolbarItem
AbstractToolbarItem.IconConfig
Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic String
static String
static String
static String
static String
static String
protected List<PlayerRoster.PlayerInfo>
static String
protected LaunchButton
Deprecated, for removal: This API element is subject to removal in a future version.use launch from the superclassprotected List<PlayerRoster.SideChangeListener>
protected StringEnumConfigurer
static String
static String
static String
static String
protected String
protected String[]
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a player to the list of active players occupying sidesvoid
Set the owning translatable of this componentvoid
Add a PropertyChangeListener.static void
Deprecated, for removal: This API element is subject to removal in a future version.void
void
Default behavior adds the button to the module toolbar.protected boolean
void
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 attributeprotected void
Claims the appropriate occupied side, if any, for the current player.protected void
claimSlot(int index)
Claims an existing slot for the current player, and sets our temporary user id appropriatelyTranslate a String into aCommand
Translate aCommand
into a Stringvoid
finish()
finish() step for Wizardprotected void
fireSideChange(String oldSide, String newSide)
Class<?>[]
String[]
This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.String[]
PlayerRoster is not a true AbstractConfigurable, it handles it's own configuration.Class<?>[]
This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.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.getBuildElement(Document doc)
ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager
.static String
A GUI component that prompts the player for the needed information.protected static PlayerRoster
Deprecated.static String
static String
protected static String
getMySide(boolean localized)
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 nullgetSides()
protected String
A human-understandable description of this stepstatic boolean
isActive()
boolean
Implement GameSetupStep for Wizardboolean
static boolean
isSoloSide(String side)
protected void
launch()
Called when the Launch Button for the player roster is clicked (i.e.protected String
void
Remove a player from the list of active players occupying sidesvoid
Remove a Buildable object from this objectvoid
removeFrom(Buildable parent)
Default behavior assumes we are removing this from the module toolbarstatic void
Deprecated, for removal: This API element is subject to removal in a future version.void
void
setAttribute(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.void
setup(boolean gameStarting)
Notify the GameComponent that a game has started/endedtranslateSide(String side)
untranslateSide(String side)
Methods inherited from class VASSAL.build.AbstractToolbarItem
addLocalImageNames, getComponent, getLaunchButton, getMenuTextList, getNamedKeyStrokeList, makeLaunchButton, setButtonTextKey, setHotKeyKey, setIconKey, setLaunchButton, setNameKey, setTooltipKey
Methods inherited from class VASSAL.build.AbstractConfigurable
getAttributeVisibility, getExpressionList, getFormattedStringList, getI18nData, getI18nPrefix, getLocalizedConfigureName, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getComponents, getComponentsOf, getPropertyNames, validate
Methods 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
Deprecated, for removal: This API element is subject to removal in a future version.use launch from the superclass -
sideChangeListeners
-
translatedObserver
-
sideConfig
-
-
Constructor Details
-
PlayerRoster
public PlayerRoster()
-
-
Method Details
-
removeFrom
Description copied from class:AbstractToolbarItem
Default behavior assumes we are removing this from the module toolbar- Specified by:
removeFrom
in interfaceConfigurable
- Overrides:
removeFrom
in classAbstractToolbarItem
- Parameters:
parent
- parent
-
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
- Parameters:
child
- Child to attach to this buildable as a subcomponent
-
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
- Parameters:
doc
- XML file- 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
@Deprecated(since="2020-06-15", forRemoval=true) public static void addSideChangeListener(PlayerRoster.SideChangeListener l)Deprecated, for removal: This API element is subject to removal in a future version. -
addSideChangeListenerToInstance
-
removeSideChangeListener
@Deprecated(since="2020-06-15", forRemoval=true) public static void removeSideChangeListener(PlayerRoster.SideChangeListener l)Deprecated, for removal: This API element is subject to removal in a future version. -
removeSideChangeListenerFromInstance
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- a HelpFile describing how to use and configure * this component
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponents
in 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
ConfigureTree
window by right-clicking on the component and selecting the appropriate "Add" option.
-
addTo
Description copied from class:AbstractToolbarItem
Default behavior adds the button to the module toolbar.- Specified by:
addTo
in interfaceBuildable
- Overrides:
addTo
in classAbstractToolbarItem
- Parameters:
b
- parent Buildable to add this component to as a subcomponent.
-
launch
protected void launch()Called when the Launch Button for the player roster is clicked (i.e. the "Retire" or "Change Sides" button) -
fireSideChange
-
isActive
public static boolean isActive() -
getInstance
Deprecated. -
getMySide
-
getMyLocalizedSide
-
getCurrentPasswords
- Returns:
- List of currently matchable passwords, including "defaults" of various types.
-
getMySide
-
getPlayers
-
getSides
-
add
Adds a player to the list of active players occupying sides- Parameters:
playerId
- player unique id (password)playerName
- player nameside
- player side
-
remove
Remove a player from the list of active players occupying sides- Parameters:
playerId
- player unique id (password)
-
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()finish() step for Wizard- 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
- Returns:
- step title for Wizard's GameSetupStep
-
isFinished
public boolean isFinished()Implement GameSetupStep for Wizard- Specified by:
isFinished
in interfaceGameSetupStep
- Returns:
- true if Wizard GameSetupStep is finished
-
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)
-
claimSlot
protected void claimSlot(int index)Claims an existing slot for the current player, and sets our temporary user id appropriately- Parameters:
index
- The index of the slot to be claimed in the roster
-
claimOccupiedSide
protected void claimOccupiedSide()Claims the appropriate occupied side, if any, for the current player. If more than one is available, prompts. -
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
- Overrides:
getAttributeNames
in classAbstractToolbarItem
- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeTypes
Description copied from class:AbstractToolbarItem
This 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:
getAttributeTypes
in interfaceAutoConfigurable
- Overrides:
getAttributeTypes
in 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
AutoConfigurer
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 in
AbstractBuildable.getAttributeNames()
-
getAttributeValueString
Description copied from class:AbstractToolbarItem
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.- Specified by:
getAttributeValueString
in interfaceAutoConfigurable
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Overrides:
getAttributeValueString
in 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:AbstractToolbarItem
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. Sets a buildFile (XML) attribute value for this component. Thekey
parameter will be one of those listed inAbstractToolbarItem.getAttributeNames()
. If thevalue
parameter is a String, it will be the value returned byAbstractToolbarItem.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
- Overrides:
setAttribute
in classAbstractToolbarItem
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractToolbarItem.getAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned byAbstractToolbarItem.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 class:AbstractToolbarItem
This 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:
getAttributeDescriptions
in interfaceAutoConfigurable
- Overrides:
getAttributeDescriptions
in 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:
getPropertyList
in interfaceSearchTarget
- Overrides:
getPropertyList
in classAbstractConfigurable
- Returns:
- a list of any Property Names referenced in the Configurable, if any (for search)
-