Class SpecialDiceButton
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.AbstractToolbarItem
VASSAL.build.module.DoActionButton
VASSAL.build.module.SpecialDiceButton
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,AutoConfigurable
,Buildable
,Configurable
,GameComponent
,PropertyNameSource
,CommandEncoder
,ComponentDescription
,ValidityChecker
,Translatable
,Auditable
,ImageSearchTarget
,SearchTarget
,RecursionLimiter.Loopable
,UniqueIdManager.Identifyable
public class SpecialDiceButton
extends DoActionButton
implements CommandEncoder, UniqueIdManager.Identifyable, ComponentDescription
...
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Deprecated, for removal: This API element is subject to removal in a future version.static class
static class
Command for displaying the results of a roll of the diceNested classes/interfaces inherited from class VASSAL.build.module.DoActionButton
DoActionButton.HotkeyConfig, DoActionButton.LoopConfig, DoActionButton.LoopCountConfig, DoActionButton.LoopTypeConfig, DoActionButton.NamedHotkeyListConfigurer, DoActionButton.SoundConfig
Nested classes/interfaces inherited from class VASSAL.build.AbstractToolbarItem
AbstractToolbarItem.FormattedStringConfig
Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected Color
static final String
Deprecated, for removal: This API element is subject to removal in a future version.static final String
protected String
protected String
static final String
protected JDialog
protected JLabel
protected List
<SpecialDie> static final String
protected FormattedString
static final String
Deprecated, for removal: This API element is subject to removal in a future version.static final String
Deprecated, for removal: This API element is subject to removal in a future version.protected String
protected static final UniqueIdManager
static final String
Deprecated, for removal: This API element is subject to removal in a future version.static final String
protected final MutableProperty.Impl
protected Random
protected boolean
protected boolean
protected boolean
static final String
static final String
static final String
static final String
static final String
protected VASSAL.build.module.SpecialDiceButton.ResultsIcon
static final String
protected String
protected String
static final String
Deprecated, for removal: This API element is subject to removal in a future version.static final String
static final String
static final String
protected String
Fields inherited from class VASSAL.build.module.DoActionButton
DO_HOTKEY, DO_LOOP, DO_REPORT, DO_SOUND, doHotkey, doLoop, doReport, doSound, hasIndex, hotkeys, HOTKEYS, INDEX, INDEX_PROPERTY, INDEX_START, INDEX_STEP, indexProperty, indexStart, indexStep, indexValue, launch, LOOP_COUNT, LOOP_TYPE, loopCount, loopIndexProperty, loopPropertyRegistered, loopType, POST_LOOP_HOTKEY, postLoopKey, PRE_LOOP_HOTKEY, preLoopKey, REPORT_FORMAT, reportFormat, SOUND_CLIP, soundClip, UNTIL_EXPRESSION, untilExpression, WHILE_EXPRESSION, whileExpression
Fields inherited from class VASSAL.build.AbstractToolbarItem
CAN_DISABLE, canDisable, DISABLED_ICON, disabledIconConfig, HIDE_WHEN_DISABLED, hideWhenDisabled, PROPERTY_GATE, propertyGate, showDisabledOptions
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
In case reports use HTML and refer to any image filesvoid
void
Expects to be added to a SymbolDice.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
.Translate aCommand
into a StringClass<?>[]
String[]
This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.String[]
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.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.getAttributeVisibility
(String name) By default, all attributes are visiblestatic String
getId()
Make a best guess for a unique identifier for the target.Implement PropertyNameSource - Expose roll result propertyprotected String
The text reported before the results of the rollstatic String
intArrayToString
(int[] ia) create String from int arrayvoid
Remove from our parentvoid
void
setAttribute
(String key, Object o) 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.protected void
setFormat
(int[] results) void
static int[]
get int array from stringMethods inherited from class VASSAL.build.module.DoActionButton
decodeHotkeys, doActions, doHotKey, encodeHotkeys, executeActions, getComponentName, getComponentTypeName, getExpressionList, getNamedKeyStrokeList, getPropertyList, setIndexPropertyValue, updateLoopPropertyRegistration
Methods inherited from class VASSAL.build.AbstractToolbarItem
addPropertyGateListener, addPropertyGateListener, checkDisabled, disableIfTrue, getComponent, getLaunchButton, getMenuTextList, getNameKey, getRestoreCommand, isShowDisabledOptions, makeLaunchButton, propertyChange, removePropertyGateListener, setButtonTextKey, setHotKeyKey, setIconKey, setLaunchButton, setNameKey, setNamePrompt, setShowDisabledOptions, setTooltipKey, setup
Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, build, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, setAncestor, validate
Methods inherited from class VASSAL.search.AbstractImageFinder
getAllImageNames, getLocalImageNames
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, isMandatory, isMovable, isUnique
Methods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
idMgr
-
SHOW_RESULTS_COMMAND
- See Also:
-
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
-
description
-
RESULT_CHATTER
- See Also:
-
CHAT_RESULT_FORMAT
- See Also:
-
RESULT_N
- See Also:
-
RESULT_TOTAL
- See Also:
-
RESULT_WINDOW
- See Also:
-
WINDOW_TITLE_RESULT_FORMAT
- See Also:
-
RESULT_BUTTON
- See Also:
-
WINDOW_X
- See Also:
-
WINDOW_Y
- See Also:
-
BACKGROUND_COLOR
- See Also:
-
DICE_SET
- See Also:
-
NONE
- See Also:
-
DESCRIPTION
- See Also:
-
BUTTON_TEXT
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
TOOLTIP
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
NAME
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
ICON
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
HOTKEY
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
-
Constructor Details
-
SpecialDiceButton
public SpecialDiceButton()
-
-
Method Details
-
getConfigureTypeName
-
getDescription
- Specified by:
getDescription
in interfaceComponentDescription
- Returns:
- Description to be displayed next to component type/name in the main Editor window. Or null or "" to not display anything.
-
getReportPrefix
The text reported before 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
- Overrides:
getAttributeNames
in classDoActionButton
- Returns:
- an array of all buildFile (XML) attribute names for this component
-
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 classDoActionButton
- 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: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 classDoActionButton
- 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()
-
getAttributeVisibility
Description copied from class:AbstractConfigurable
By default, all attributes are visible- Specified by:
getAttributeVisibility
in interfaceAutoConfigurable
- Overrides:
getAttributeVisibility
in classDoActionButton
- 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
- Specified by:
addTo
in interfaceBuildable
- Overrides:
addTo
in classAbstractToolbarItem
- Parameters:
parent
- parent Buildable to add this component to as a subcomponent.
-
removeFrom
Description copied from class:AbstractToolbarItem
Remove from our parent- Specified by:
removeFrom
in interfaceConfigurable
- Overrides:
removeFrom
in classAbstractToolbarItem
- Parameters:
b
- parent
-
setId
- Specified by:
setId
in interfaceUniqueIdManager.Identifyable
-
getId
- Specified by:
getId
in interfaceUniqueIdManager.Identifyable
-
getIdentifier
Make a best guess for a unique identifier for the target. UseUniqueIdManager.Identifyable.getConfigureName()
if non-null, otherwise useUniqueIdManager.Identifyable.getId()
-
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. The
key
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 classDoActionButton
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractToolbarItem.getAttributeNames()
o
- 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()
-
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 classDoActionButton
- 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.
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
- Overrides:
getAllowableConfigureComponents
in classDoActionButton
- 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.
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Overrides:
getHelpFile
in classDoActionButton
- Returns:
- a HelpFile 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 classDoActionButton
- 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
-
getFormattedStringList
- Specified by:
getFormattedStringList
in interfaceSearchTarget
- Overrides:
getFormattedStringList
in classDoActionButton
- Returns:
- a list of any Message Format strings referenced in the Configurable, if any (for search)
-
addLocalImageNames
In case reports use HTML and refer to any image files- Specified by:
addLocalImageNames
in interfaceImageSearchTarget
- Overrides:
addLocalImageNames
in classDoActionButton
- Parameters:
s
- Collection to add image names to
-
AbstractToolbarItem.IconConfig
instead.