Package VASSAL.build.module
Class SpecialDiceButton
java.lang.Object
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.module.SpecialDiceButton
- All Implemented Interfaces:
AutoConfigurable
,Buildable
,Configurable
,PropertyNameSource
,CommandEncoder
,ValidityChecker
,Translatable
,UniqueIdManager.Identifyable
public class SpecialDiceButton extends AbstractConfigurable implements CommandEncoder, UniqueIdManager.Identifyable
...
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SpecialDiceButton.IconConfig
static class
SpecialDiceButton.ReportFormatConfig
static class
SpecialDiceButton.ShowResults
Command for displaying the results of a roll of the diceNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
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 SpecialDiceButton()
-
Method Summary
Modifier and Type Method Description void
addSpecialDie(SpecialDie d)
void
addTo(Buildable parent)
Expects to be added to a SymbolDice.Command
decode(String s)
Translate a String into aCommand
protected void
DR()
Forwards the result of the roll to theChatter.send(java.lang.String)
method of theChatter
of theGameModule
.String
encode(Command c)
Translate aCommand
into a StringClass<?>[]
getAllowableConfigureComponents()
Return a list of valid sub-component Classes.String[]
getAttributeDescriptions()
Return an array of Strings describing the attributes of this object.String[]
getAttributeNames()
The Attributes of a DiceButton are:BUTTON_TEXT
the label of the button in the toolbarICON
the icon of the button in the toolbarHOTKEY
the hotkey equivalent of the buttonDICE_SET
list of dice sets, an entry can be: [number]name of die[+|-modifier] "name of die" must be SpecialDie "modifier" is added/subtracted to/from total of dice [number]Dnumber of sides (e.g.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 elementVisibilityCondition
getAttributeVisibility(String name)
By default, all attributes are visiblestatic String
getConfigureTypeName()
HelpFile
getHelpFile()
String
getId()
String
getIdentifier()
Make a best gues for a unique identifier for the target.List<String>
getPropertyNames()
Implement PropertyNameSource - Expose roll result propertyprotected String
getReportPrefix()
The text reported before the results of the rollprotected String
getReportSuffix()
Deprecated, for removal: This API element is subject to removal in a future version.Handled by Message Formatstatic String
intArrayToString(int[] ia)
create String from int arrayvoid
removeFrom(Buildable b)
Remove this component from its parentvoid
removeSpecialDie(SpecialDie d)
void
setAttribute(String key, Object o)
Sets a buildFile (XML) attribute value for this component.protected void
setFormat(int[] results)
void
setId(String id)
static int[]
stringToIntArray(String s)
get int array from stringMethods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
build, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.build.Buildable
build, getBuildElement
Methods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
idMgr
-
SHOW_RESULTS_COMMAND
- See Also:
- Constant Field Values
-
dice
-
ran
-
reportResultAsText
protected boolean reportResultAsText -
reportResultInWindow
protected boolean reportResultInWindow -
reportResultInButton
protected boolean reportResultInButton -
id
-
sMapName
-
dialog
-
dialogLabel
-
bgColor
-
resultsIcon
protected VASSAL.build.module.SpecialDiceButton.ResultsIcon resultsIcon -
format
-
chatResultFormat
-
windowTitleResultFormat
-
tooltip
-
property
-
BUTTON_TEXT
- See Also:
- Constant Field Values
-
TOOLTIP
- See Also:
- Constant Field Values
-
NAME
- See Also:
- Constant Field Values
-
ICON
- See Also:
- Constant Field Values
-
RESULT_CHATTER
- See Also:
- Constant Field Values
-
CHAT_RESULT_FORMAT
- See Also:
- Constant Field Values
-
RESULT_N
- See Also:
- Constant Field Values
-
RESULT_TOTAL
- See Also:
- Constant Field Values
-
RESULT_WINDOW
- See Also:
- Constant Field Values
-
WINDOW_TITLE_RESULT_FORMAT
- See Also:
- Constant Field Values
-
RESULT_BUTTON
- See Also:
- Constant Field Values
-
WINDOW_X
- See Also:
- Constant Field Values
-
WINDOW_Y
- See Also:
- Constant Field Values
-
BACKGROUND_COLOR
- See Also:
- Constant Field Values
-
DICE_SET
- See Also:
- Constant Field Values
-
HOTKEY
- See Also:
- Constant Field Values
-
NONE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
SpecialDiceButton
public SpecialDiceButton()
-
-
Method Details
-
getConfigureTypeName
-
getReportPrefix
The text reported before the results of the roll -
getReportSuffix
Deprecated, for removal: This API element is subject to removal in a future version.Handled by Message FormatThe text reported after the results of the roll; -
DR
protected void DR()Forwards the result of the roll to theChatter.send(java.lang.String)
method of theChatter
of theGameModule
. Format is prefix+[comma-separated roll list]+suffix additionally a command for every die is generated -
setFormat
protected void setFormat(int[] results) -
getAttributeNames
The Attributes of a DiceButton are:BUTTON_TEXT
the label of the button in the toolbarICON
the icon of the button in the toolbarHOTKEY
the hotkey equivalent of the buttonDICE_SET
list of dice sets, an entry can be: [number]name of die[+|-modifier] "name of die" must be SpecialDie "modifier" is added/subtracted to/from total of dice [number]Dnumber of sides (e.g. 2D6)NUMERIC
result of all dice is numericREPORT_TOTAL
If numeric and true, add the results of the dice together and report the total. Otherwise, report the individual resultsSORT
if true sort results per die by numeric valueRESULT_CHATTER
if true report results in chatterRESULT_WINDOW
if true show result graphical in extra windowWINDOW_X
width of window or buttonWINDOW_Y
height of window or buttonRESULT_MAP
:TODO: if true show result in special area in mapMAP_NAME
:TODO: name of mapRESULT_BUTTON
if true show result graphical in button- Specified by:
getAttributeNames
in interfaceAutoConfigurable
- Specified by:
getAttributeNames
in classAbstractBuildable
- Returns:
- a list of all buildFile (XML) attribute names for this component
-
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()
-
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
-
getAttributeVisibility
Description copied from class:AbstractConfigurable
By default, all attributes are visible- Specified by:
getAttributeVisibility
in interfaceAutoConfigurable
- Overrides:
getAttributeVisibility
in classAbstractConfigurable
- Parameters:
name
- Name (key) of one of this component's attributes- Returns:
- a
VisibilityCondition
for this attribute, or null if attribute should always be visible.
-
addSpecialDie
-
removeSpecialDie
-
addTo
Expects to be added to a SymbolDice. Adds the button to the control window's toolbar and registers itself as aKeyStrokeListener
-
removeFrom
Description copied from interface:Configurable
Remove this component from its parent- Specified by:
removeFrom
in interfaceConfigurable
-
setId
- Specified by:
setId
in interfaceUniqueIdManager.Identifyable
-
getId
- Specified by:
getId
in interfaceUniqueIdManager.Identifyable
-
getIdentifier
Make a best gues for a unique identifier for the target. Useif non-null, otherwise use {@link VASSAL.tools.UniqueIdManager.Identifyable#getId
- Parameters:
target
-- Returns:
-
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()
o
- 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()
-
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)
.
-
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
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- a HelpFilte describing how to use and configure this component
-
intArrayToString
create String from int array- Parameters:
ia
- int-array- Returns:
- encoded String
-
stringToIntArray
get int array from string- Parameters:
s
- string with encoded int array- Returns:
- int array
-
getPropertyNames
Implement PropertyNameSource - Expose roll result property- Specified by:
getPropertyNames
in interfacePropertyNameSource
- Overrides:
getPropertyNames
in classAbstractBuildable
- Returns:
- Default implementation of PropertyNameSource - No properties exposed
-
encode
Description copied from interface:CommandEncoder
Translate aCommand
into a String- Specified by:
encode
in interfaceCommandEncoder
-
decode
Description copied from interface:CommandEncoder
Translate a String into aCommand
- Specified by:
decode
in interfaceCommandEncoder
-