diff --git a/src/as/com/threerings/parlor/client/DefaultFlexTableConfigurator.as b/src/as/com/threerings/parlor/client/DefaultFlexTableConfigurator.as index 040b5493..dadcfa6a 100644 --- a/src/as/com/threerings/parlor/client/DefaultFlexTableConfigurator.as +++ b/src/as/com/threerings/parlor/client/DefaultFlexTableConfigurator.as @@ -27,13 +27,11 @@ import mx.controls.CheckBox; import mx.controls.ComboBox; import mx.controls.Label; -// TODO: we shouldn't use these here but I don't feel like a major refactor -import com.threerings.ezgame.data.ToggleParameter; -import com.threerings.ezgame.data.RangeParameter; - import com.threerings.flex.GridUtil; +import com.threerings.parlor.data.RangeParameter; import com.threerings.parlor.data.TableConfig; +import com.threerings.parlor.data.ToggleParameter; import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.game.client.FlexGameConfigurator; diff --git a/src/as/com/threerings/parlor/data/ChoiceParameter.as b/src/as/com/threerings/parlor/data/ChoiceParameter.as new file mode 100644 index 00000000..f5bd2bdb --- /dev/null +++ b/src/as/com/threerings/parlor/data/ChoiceParameter.as @@ -0,0 +1,47 @@ +// +// $Id$ + +package com.threerings.parlor.data { + +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; +import com.threerings.io.TypedArray; + +/** + * 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 var choices :TypedArray; + + /** The starting selection. */ + public var start :String; + + public function ChoiceParameter () + { + } + + // documentation inherited + override public function getDefaultValue () :Object + { + return start; + } + + // from interface Streamable + override public function readObject (ins :ObjectInputStream) :void + { + super.readObject(ins); + choices = (ins.readObject() as TypedArray); + start = (ins.readField(String) as String); + } + + // from interface Streamable + override public function writeObject (out :ObjectOutputStream) :void + { + super.writeObject(out); + out.writeObject(choices); + out.writeField(start); + } +} +} diff --git a/src/as/com/threerings/parlor/data/Parameter.as b/src/as/com/threerings/parlor/data/Parameter.as new file mode 100644 index 00000000..b85dd1be --- /dev/null +++ b/src/as/com/threerings/parlor/data/Parameter.as @@ -0,0 +1,63 @@ +// +// $Id$ + +package com.threerings.parlor.data { + +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; +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 var ident :String; + + /** A human readable name for this configuration parameter. */ + public var name :String; + + /** A human readable tooltip to display when the mouse is hovered over this configuration + * parameter. */ + public var tip :String; + + public function Parameter () + { + } + + public function toString () :String + { + return ident; + } + + public function getDefaultValue () :Object + { + throw new Error("Abstract"); + } + + /** Returns the translation key for this parameter's label. */ + public function getLabel () :String + { + return "m." + ident; + } + + // from interface Streamable + public function readObject (ins :ObjectInputStream) :void + { + ident = (ins.readField(String) as String); + name = (ins.readField(String) as String); + tip = (ins.readField(String) as String); + } + + // from interface Streamable + public function writeObject (out :ObjectOutputStream) :void + { + out.writeField(ident); + out.writeField(name); + out.writeField(tip); + } +} +} diff --git a/src/as/com/threerings/parlor/data/RangeParameter.as b/src/as/com/threerings/parlor/data/RangeParameter.as new file mode 100644 index 00000000..ff4aef3c --- /dev/null +++ b/src/as/com/threerings/parlor/data/RangeParameter.as @@ -0,0 +1,51 @@ +// +// $Id$ + +package com.threerings.parlor.data { + +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; + +/** + * 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 var minimum :int; + + /** The maximum value of this parameter. */ + public var maximum :int; + + /** The starting value for this parameter. */ + public var start :int; + + public function RangeParameter () + { + } + + // documentation inherited + override public function getDefaultValue () :Object + { + return start; + } + + // from interface Streamable + override public function readObject (ins :ObjectInputStream) :void + { + super.readObject(ins); + minimum = ins.readInt(); + maximum = ins.readInt(); + start = ins.readInt(); + } + + // from interface Streamable + override public function writeObject (out :ObjectOutputStream) :void + { + super.writeObject(out); + out.writeInt(minimum); + out.writeInt(maximum); + out.writeInt(start); + } +} +} diff --git a/src/as/com/threerings/parlor/data/ToggleParameter.as b/src/as/com/threerings/parlor/data/ToggleParameter.as new file mode 100644 index 00000000..d88f2988 --- /dev/null +++ b/src/as/com/threerings/parlor/data/ToggleParameter.as @@ -0,0 +1,41 @@ +// +// $Id$ + +package com.threerings.parlor.data { + +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; + +/** + * Models a parameter that allows the toggling of a single value. + */ +public class ToggleParameter extends Parameter +{ + /** The starting state for this parameter. */ + public var start :Boolean; + + public function ToggleParameter () + { + } + + // documentation inherited + override public function getDefaultValue () :Object + { + return start; + } + + // from interface Streamable + override public function readObject (ins :ObjectInputStream) :void + { + super.readObject(ins); + start = ins.readBoolean(); + } + + // from interface Streamable + override public function writeObject (out :ObjectOutputStream) :void + { + super.writeObject(out); + out.writeBoolean(start); + } +} +}