VASSAL.build.module
Class SymbolDiceButton

java.lang.Object
  |
  +--VASSAL.build.AbstractBuildable
        |
        +--VASSAL.build.AbstractConfigurable
              |
              +--VASSAL.build.module.SymbolDiceButton
All Implemented Interfaces:
AutoConfigurable, Buildable, CommandEncoder, Configurable

public class SymbolDiceButton
extends AbstractConfigurable
implements CommandEncoder

This component places a button into the symboldice window toolbar. Pressing the button generates random numbers and displays the results graphically.


Inner Class Summary
static class SymbolDiceButton.AssignedDeckPrompt
          generates a prompt with the names of all decks already defined
static class SymbolDiceButton.IconConfig
           
static class SymbolDiceButton.RollSymbolDice
           
 
Inner classes inherited from class VASSAL.build.AutoConfigurable
AutoConfigurable.Util
 
Field Summary
static java.lang.String BUTTON_TEXT
           
static java.lang.String DECK
           
static java.lang.String HOTKEY
           
static java.lang.String ICON
           
protected  java.lang.String id
           
protected  LaunchButton launch
           
protected  Map map
           
static java.lang.String N_DICE
           
static java.lang.String N_SIDES
           
static java.lang.String NAME
           
protected  int nDice
           
static java.lang.String NONE
           
protected  int nSides
           
static java.lang.String PROMPT_ALWAYS
           
protected  boolean promptAlways
           
protected  java.util.Random ran
           
 
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, name
 
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents
 
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
 
Constructor Summary
SymbolDiceButton()
           
 
Method Summary
 void addTo(Buildable parent)
          Expects to be added to a SymbolDice.
 Command decode(java.lang.String s)
          Translate a String into a Command
protected  void DR()
          Forwards the result of the roll to the Chatter.send(java.lang.String) method of the Chatter of the GameModule.
 java.lang.String encode(Command c)
          Translate a Command into a String
static SymbolDiceButton findSymbolDiceButton(java.lang.String id)
           
 java.lang.Class[] getAllowableConfigureComponents()
          Return a list of valid sub-component Classes.
 java.lang.String[] getAttributeDescriptions()
          Return an array of Strings describing the attributes of this object.
 java.lang.String[] getAttributeNames()
          The Attributes of a DiceButton are: LABEL the label of the button in the toolbar HOTKEY the hotkey equivalent of the button N_DICE the number of dice to roll on each button press DECK the name of the DrawPile with the symbols you can have more than one deck in a module but you must name them different.
 java.lang.Class[] getAttributeTypes()
          Return the Class for the attributes of this object.
 java.lang.String getAttributeValueString(java.lang.String key)
          Called by the AbstractBuildable.getBuildElement(org.w3c.dom.Document) method to write the attributes into an XML element
 VisibilityCondition getAttributeVisibility(java.lang.String name)
          By default, all attributes are visible
protected  java.awt.Component getComponent()
          The component to be added to the control window toolbar
static java.lang.String getConfigureTypeName()
           
 HelpFile getHelpFile()
           
 java.lang.String getId()
           
protected  java.lang.String getReportPrefix()
          The text reported before the results of the roll
protected  java.lang.String getReportSuffix()
          The text reported after the results of the roll;
static java.lang.String intArrayToString(int[] ia)
           
 void removeFrom(Buildable b)
          Remove this component from its parent
 void setAttribute(java.lang.String key, java.lang.Object o)
          Called by the AbstractBuildable.build(org.w3c.dom.Element) method, where value is the String value read by the XML attribute.
 void setId(java.lang.String id)
           
static int[] stringToIntArray(java.lang.String s)
           
 
Methods inherited from class VASSAL.build.AbstractConfigurable
addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, remove, setConfigureName
 
Methods inherited from class VASSAL.build.AbstractBuildable
add, build, getBuildComponents, getBuildElement, getComponents
 
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
add, build, getBuildElement
 

Field Detail

ran

protected java.util.Random ran

nSides

protected int nSides

nDice

protected int nDice

promptAlways

protected boolean promptAlways

launch

protected LaunchButton launch

map

protected Map map

id

protected java.lang.String id

BUTTON_TEXT

public static final java.lang.String BUTTON_TEXT

NAME

public static final java.lang.String NAME

ICON

public static final java.lang.String ICON

N_DICE

public static final java.lang.String N_DICE

N_SIDES

public static final java.lang.String N_SIDES

HOTKEY

public static final java.lang.String HOTKEY

PROMPT_ALWAYS

public static final java.lang.String PROMPT_ALWAYS

DECK

public static final java.lang.String DECK

NONE

public static final java.lang.String NONE
Constructor Detail

SymbolDiceButton

public SymbolDiceButton()
Method Detail

getConfigureTypeName

public static java.lang.String getConfigureTypeName()

getReportPrefix

protected java.lang.String getReportPrefix()
The text reported before the results of the roll

getReportSuffix

protected java.lang.String getReportSuffix()
The text reported after the results of the roll;

DR

protected void DR()
Forwards the result of the roll to the Chatter.send(java.lang.String) method of the Chatter of the GameModule. Format is prefix+[comma-separated roll list]+suffix

getAttributeNames

public java.lang.String[] getAttributeNames()
The Attributes of a DiceButton are: LABEL the label of the button in the toolbar HOTKEY the hotkey equivalent of the button N_DICE the number of dice to roll on each button press DECK the name of the DrawPile with the symbols you can have more than one deck in a module but you must name them different. N_SIDES the number of sides of each die REPORT_TOTALL If true, add the results of the dice together and report the total. Otherwise, report the individual results
Overrides:
getAttributeNames in class AbstractBuildable
Following copied from interface: VASSAL.build.AutoConfigurable
Returns:
an array of Strings giving all attributes of this Buildable component that will be written to/read from an XML element

getAttributeDescriptions

public java.lang.String[] getAttributeDescriptions()
Description copied from class: AbstractConfigurable
Return an array of Strings describing the attributes of this object. These strings are used as prompts in the Properties window for this object. The order of descriptions should be the same as the order of names in AbstractBuildable.getAttributeNames()
Overrides:
getAttributeDescriptions in class AbstractConfigurable

getAttributeTypes

public java.lang.Class[] getAttributeTypes()
Description copied from class: AbstractConfigurable
Return the Class for the attributes of this object. Valid classes are: String, Integer, Double, Boolean, Image, Color, and KeyStroke The order of classes should be the same as the order of names in AbstractBuildable.getAttributeNames()
Overrides:
getAttributeTypes in class AbstractConfigurable

getAttributeVisibility

public VisibilityCondition getAttributeVisibility(java.lang.String name)
Description copied from class: AbstractConfigurable
By default, all attributes are visible
Overrides:
getAttributeVisibility in class AbstractConfigurable
Following copied from class: VASSAL.build.AbstractConfigurable
Parameters:
name -  
Returns:
 

addTo

public void addTo(Buildable parent)
Expects to be added to a SymbolDice. Adds the button to the control window's toolbar and registers itself as a KeyStrokeListener

removeFrom

public void removeFrom(Buildable b)
Description copied from interface: Configurable
Remove this component from its parent

setId

public void setId(java.lang.String id)

getId

public java.lang.String getId()

findSymbolDiceButton

public static SymbolDiceButton findSymbolDiceButton(java.lang.String id)
Parameters:
id -  
Returns:
the SymbolDiceButton with the given id

getComponent

protected java.awt.Component getComponent()
The component to be added to the control window toolbar

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object o)
Description copied from interface: AutoConfigurable
Called by the Buildable.build(org.w3c.dom.Element) method, where value is the String value read by the XML attribute. Can also be called with Object value to set the attribute.
Overrides:
setAttribute in class AbstractBuildable
Following copied from class: VASSAL.build.AbstractBuildable
Parameters:
key - the name of the attribute. Will be one of those listed in AbstractBuildable.getAttributeNames()

getAttributeValueString

public java.lang.String getAttributeValueString(java.lang.String key)
Description copied from interface: AutoConfigurable
Called by the Buildable.getBuildElement(org.w3c.dom.Document) method to write the attributes into an XML element
Overrides:
getAttributeValueString in class AbstractBuildable
Following copied from class: VASSAL.build.AbstractBuildable
Parameters:
key - the name of the attribute. Will be one of those listed in AbstractBuildable.getAttributeNames()

getAllowableConfigureComponents

public java.lang.Class[] 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.

getHelpFile

public HelpFile getHelpFile()
Following copied from interface: VASSAL.build.Configurable
Returns:
a HelpFilte describing how to use and configure this component

intArrayToString

public static java.lang.String intArrayToString(int[] ia)

stringToIntArray

public static int[] stringToIntArray(java.lang.String s)

encode

public java.lang.String encode(Command c)
Description copied from interface: CommandEncoder
Translate a Command into a String
Specified by:
encode in interface CommandEncoder

decode

public Command decode(java.lang.String s)
Description copied from interface: CommandEncoder
Translate a String into a Command
Specified by:
decode in interface CommandEncoder