diff --git a/src/java/com/threerings/parlor/data/ChoiceParameter.java b/src/java/com/threerings/parlor/data/ChoiceParameter.java new file mode 100644 index 00000000..c3b6d457 --- /dev/null +++ b/src/java/com/threerings/parlor/data/ChoiceParameter.java @@ -0,0 +1,39 @@ +// +// $Id$ + +package com.threerings.parlor.data; + +import com.threerings.util.ActionScript; + +/** + * Models a parameter that allows the selection of one of a list of choices (specified as strings). + */ +public class ChoiceParameter extends Parameter +{ + /** The set of choices available for this parameter. */ + public String[] choices; + + /** The starting selection. */ + public String start; + + /** + * Returns the translation key for the specified choice. + */ + @ActionScript(omit=true) + public String getChoiceLabel (int index) + { + return "m.choice_" + choices[index]; + } + + @Override @ActionScript(omit=true) // documentation inherited + public String getLabel () + { + return "m.choice_" + ident; + } + + @Override // documentation inherited + public Object getDefaultValue () + { + return start; + } +} diff --git a/src/java/com/threerings/parlor/data/Parameter.java b/src/java/com/threerings/parlor/data/Parameter.java new file mode 100644 index 00000000..826439d3 --- /dev/null +++ b/src/java/com/threerings/parlor/data/Parameter.java @@ -0,0 +1,37 @@ +// +// $Id$ + +package com.threerings.parlor.data; + +import com.samskivert.util.StringUtil; + +import com.threerings.io.Streamable; + +/** + * Defines a configuration parameter for a game. Various derived classes exist that define + * particular types of configuration parameters including choices, toggles, ranges, etc. + */ +public abstract class Parameter implements Streamable +{ + /** A string identifier that names this parameter. */ + public String ident; + + /** A human readable name for this configuration parameter. */ + public String name; + + /** A human readable tooltip to display when the mouse is hovered over this configuration + * parameter. */ + public String tip; + + /** Returns the translation key for this parameter's label. */ + public abstract String getLabel (); + + /** Returns the default value of this parameter. */ + public abstract Object getDefaultValue (); + + /** Generates a string representation of this instance. */ + public String toString () + { + return StringUtil.fieldsToString(this); + } +} diff --git a/src/java/com/threerings/parlor/data/RangeParameter.java b/src/java/com/threerings/parlor/data/RangeParameter.java new file mode 100644 index 00000000..9c683235 --- /dev/null +++ b/src/java/com/threerings/parlor/data/RangeParameter.java @@ -0,0 +1,33 @@ +// +// $Id$ + +package com.threerings.parlor.data; + +import com.threerings.util.ActionScript; + +/** + * Models a parameter that can contain an integer value in a specified range. + */ +public class RangeParameter extends Parameter +{ + /** The minimum value of this parameter. */ + public int minimum; + + /** The maximum value of this parameter. */ + public int maximum; + + /** The starting value for this parameter. */ + public int start; + + @Override @ActionScript(omit=true) // documentation inherited + public String getLabel () + { + return "m.range_" + ident; + } + + @Override // documentation inherited + public Object getDefaultValue () + { + return start; + } +} diff --git a/src/java/com/threerings/parlor/data/ToggleParameter.java b/src/java/com/threerings/parlor/data/ToggleParameter.java new file mode 100644 index 00000000..72c51b17 --- /dev/null +++ b/src/java/com/threerings/parlor/data/ToggleParameter.java @@ -0,0 +1,27 @@ +// +// $Id$ + +package com.threerings.parlor.data; + +import com.threerings.util.ActionScript; + +/** + * Models a parameter that allows the toggling of a single value. + */ +public class ToggleParameter extends Parameter +{ + /** The starting state for this parameter. */ + public boolean start; + + @Override @ActionScript(omit=true) // documentation inherited + public String getLabel () + { + return "m.toggle_" + ident; + } + + @Override // documentation inherited + public Object getDefaultValue () + { + return start; + } +}