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
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated, for removal: This API element is subject to removal in a future version.static classstatic classCommand for displaying the results of a roll of the diceNested classes/interfaces inherited from class DoActionButton
DoActionButton.HotkeyConfig, DoActionButton.LoopConfig, DoActionButton.LoopCountConfig, DoActionButton.LoopTypeConfig, DoActionButton.NamedHotkeyListConfigurer, DoActionButton.SoundConfigModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classDeprecated, for removal: This API element is subject to removal in a future version.not replacedstatic classNested classes/interfaces inherited from class AbstractToolbarItem
AbstractToolbarItem.FormattedStringConfigNested classes/interfaces inherited from interface AutoConfigurable
AutoConfigurable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected Colorstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.static final Stringprotected Stringprotected Stringstatic final Stringprotected JDialogprotected JLabelprotected List<SpecialDie> static final Stringprotected FormattedStringstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.static final StringDeprecated, for removal: This API element is subject to removal in a future version.protected Stringprotected static final UniqueIdManagerstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.static final Stringprotected final MutableProperty.Implprotected Randomprotected booleanprotected booleanprotected booleanstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected VASSAL.build.module.SpecialDiceButton.ResultsIconstatic final Stringprotected Stringprotected Stringstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.static final Stringstatic final Stringstatic final Stringprotected StringFields inherited from class 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, whileExpressionModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected List<NamedKeyStroke> static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringprotected intprotected intprotected intprotected LaunchButtonDeprecated, for removal: This API element is subject to removal in a future version.use launch from the superclassstatic final Stringstatic final Stringprotected FormattedStringprotected MutableProperty.Implprotected booleanprotected Stringstatic final Stringprotected NamedKeyStrokestatic final Stringprotected NamedKeyStrokestatic final Stringprotected FormattedStringstatic final Stringprotected Stringstatic final Stringprotected PropertyExpressionstatic final Stringprotected PropertyExpressionFields inherited from class AbstractToolbarItem
CAN_DISABLE, canDisable, DISABLED_ICON, disabledIconConfig, HIDE_WHEN_DISABLED, hideWhenDisabled, PROPERTY_GATE, propertyGate, showDisabledOptionsFields inherited from class AbstractConfigurable
changeSupport, config, localizedName, myI18nData, nameModifier and TypeFieldDescriptionprotected PropertyChangeSupportprotected Configurerprotected Stringprotected ComponentI18nDataprotected StringFields inherited from class AbstractBuildable
buildComponents, validatorFields inherited from interface Configurable
NAME_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidIn case reports use HTML and refer to any image filesvoidvoidExpects to be added to a SymbolDice.Translate a String into aCommandprotected voidDR()Forwards the result of the roll to theChatter.send(String)method of theChatterof theGameModule.Translate aCommandinto 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_TEXTthe label of the button in the toolbarICONthe icon of the button in the toolbarHOTKEYthe hotkey equivalent of the buttonDICE_SETlist 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)NUMERICresult of all dice is numericREPORT_TOTALIf 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 StringgetId()Make a best guess for a unique identifier for the target.Implement PropertyNameSource - Expose roll result propertyprotected StringThe text reported before the results of the rollstatic StringintArrayToString(int[] ia) create String from int arrayvoidRemove from our parentvoidvoidsetAttribute(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 voidsetFormat(int[] results) voidstatic int[]get int array from stringMethods inherited from class DoActionButton
decodeHotkeys, doActions, doHotKey, encodeHotkeys, executeActions, getComponentName, getComponentTypeName, getExpressionList, getNamedKeyStrokeList, getPropertyList, setIndexPropertyValue, updateLoopPropertyRegistrationModifier and TypeMethodDescriptionprotected List<NamedKeyStroke> protected voidprotected voiddoHotKey(Command c, NamedKeyStroke key) protected Stringprotected voidexecuteActions(Command command) Execute the set of actions that make up this button and return the set of Commands generated.Return the name of the trait or Component an Auditable isReturn a description of the Type of trait or Component an Auditable isprotected voidprotected voidRegister/Deregister the Global Property exposing the index property.Methods inherited from class AbstractToolbarItem
addPropertyGateListener, addPropertyGateListener, checkDisabled, disableIfTrue, getComponent, getLaunchButton, getMenuTextList, getNameKey, getRestoreCommand, isShowDisabledOptions, makeLaunchButton, propertyChange, removePropertyGateListener, setButtonTextKey, setHotKeyKey, setIconKey, setLaunchButton, setNameKey, setNamePrompt, setShowDisabledOptions, setTooltipKey, setupModifier and TypeMethodDescriptionprotected voidprotected voidaddPropertyGateListener(boolean dontCheck) If we have a disable-this-button property, set a listener on itvoidCheck our disable-this-button property and enable/disable our button as appropriate based on its valuevoiddisableIfTrue(boolean disable) protected ComponentThe component to be added to the control window toolbarprotected StringWhen 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 nullbooleanprotected LaunchButtonmakeLaunchButton(String tooltip, String button_text, String iconFile, ActionListener action) Create a standard toolbar launcher button for this itemvoidListens to our disable-this-button property; enables/disables our button as appropriate when it changesprotected voidRemove any existing disable-this-button propertyprotected voidsetButtonTextKey(String buttonTextKey) protected voidsetHotKeyKey(String hotKeyKey) protected voidsetIconKey(String iconKey) protected voidsetLaunchButton(LaunchButton launch) Sets launch button for this toolbar itemprotected voidsetNameKey(String nameKey) protected voidsetNamePrompt(String namePrompt) protected voidsetShowDisabledOptions(boolean show) protected voidsetTooltipKey(String tooltipKey) voidsetup(boolean gameStarting) Notify the GameComponent that a game has started/endedMethods inherited from class AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameModifier and TypeMethodDescriptionvoidSet the owning translatable of this componentvoidAdd a PropertyChangeListener.ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager.protected StringReturns the name of the configurable type for display purposes.voidRemove a Buildable object from this objectvoidprotected voidSets all attributes untranslatable.protected voidsetAttributeTranslatable(String attr, boolean b) Over-ride the default attribute translatability.voidSets the name and fires a PropertyChangeEventMethods inherited from class AbstractBuildable
addImageNamesRecursively, build, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, setAncestor, validateModifier and TypeMethodDescriptionvoidAdds all images used by this component AND any subcomponents to the collectionvoidBuild this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(String, Object)with the String value of the attribute<T> List<T> getAllDescendantComponentsOf(Class<T> target) Recursively descend the build tree and return aListof all components that are instances of the given classDeprecated, for removal: This API element is subject to removal in a future version.UseAbstractBuildable.getBuildables()instead.getBuildElement(Document doc) <T> Enumeration<T> getComponents(Class<T> target) Deprecated, for removal: This API element is subject to removal in a future version.UseAbstractBuildable.getComponentsOf(Class)instead.<T> List<T> getComponentsOf(Class<T> target) voidsetAncestor(Buildable ancestor) voidvalidate(Buildable target, ValidationReport report) Methods inherited from class AbstractImageFinder
getAllImageNames, getLocalImageNamesModifier and TypeMethodDescriptionMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Buildable
isMandatory, isMovable, isUniqueModifier and TypeMethodDescriptiondefault booleanIs this component a reqired component within its parent?default booleanIs this component allowed to be moved around the Configure Tree?default booleanisUnique()Does this component need to be unique within it's parent?Methods inherited from interface 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:
getDescriptionin 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(String)method of theChatterof 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_TEXTthe label of the button in the toolbarICONthe icon of the button in the toolbarHOTKEYthe hotkey equivalent of the buttonDICE_SETlist 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)NUMERICresult of all dice is numericREPORT_TOTALIf numeric and true, add the results of the dice together and report the total. Otherwise, report the individual resultsSORTif true sort results per die by numeric valueRESULT_CHATTERif true report results in chatterRESULT_WINDOWif true show result graphical in extra windowWINDOW_Xwidth of window or buttonWINDOW_Yheight of window or buttonRESULT_MAP:TODO: if true show result in special area in mapMAP_NAME:TODO: name of mapRESULT_BUTTONif true show result graphical in button- Specified by:
getAttributeNamesin interfaceAutoConfigurable- Overrides:
getAttributeNamesin classDoActionButton- Returns:
- an array of all buildFile (XML) attribute names for this component
-
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 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: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 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
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()
-
getAttributeVisibility
Description copied from class:AbstractConfigurableBy default, all attributes are visible- Specified by:
getAttributeVisibilityin interfaceAutoConfigurable- Overrides:
getAttributeVisibilityin classDoActionButton- Parameters:
name- Name (key) of one of this component's attributes- Returns:
- a
VisibilityConditionfor 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:
addToin interfaceBuildable- Overrides:
addToin classAbstractToolbarItem- Parameters:
parent- parent Buildable to add this component to as a subcomponent.
-
removeFrom
Description copied from class:AbstractToolbarItemRemove from our parent- Specified by:
removeFromin interfaceConfigurable- Overrides:
removeFromin classAbstractToolbarItem- Parameters:
b- parent
-
setId
- Specified by:
setIdin interfaceUniqueIdManager.Identifyable
-
getId
- Specified by:
getIdin 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: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. The
keyparameter will be one of those listed inAbstractToolbarItem.getAttributeNames(). If thevalueparameter is a String, it will be the value returned byAbstractToolbarItem.getAttributeValueString(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 classDoActionButton- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractToolbarItem.getAttributeNames()o- If thevalueparameter is a String, it will be the value returned byAbstractToolbarItem.getAttributeValueString(String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
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 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(String, Object). It is also frequently used for checking the current value of an attribute.
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponentsin interfaceConfigurable- Overrides:
getAllowableConfigureComponentsin 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
ConfigureTreewindow by right-clicking on the component and selecting the appropriate "Add" option.
-
getHelpFile
- Specified by:
getHelpFilein interfaceConfigurable- Overrides:
getHelpFilein 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:
getPropertyNamesin interfacePropertyNameSource- Overrides:
getPropertyNamesin classDoActionButton- Returns:
- Default implementation of PropertyNameSource - No properties exposed
-
encode
Description copied from interface:CommandEncoderTranslate aCommandinto a String- Specified by:
encodein interfaceCommandEncoder
-
decode
Description copied from interface:CommandEncoderTranslate a String into aCommand- Specified by:
decodein interfaceCommandEncoder
-
getFormattedStringList
- Specified by:
getFormattedStringListin interfaceSearchTarget- Overrides:
getFormattedStringListin 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:
addLocalImageNamesin interfaceImageSearchTarget- Overrides:
addLocalImageNamesin classDoActionButton- Parameters:
s- Collection to add image names to
-
AbstractToolbarItem.IconConfiginstead.