Parameter needs to live here.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@560 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user