com.threerings.cast.builder
Class BuilderModel

java.lang.Object
  extended by com.threerings.cast.builder.BuilderModel

public class BuilderModel
extends Object

The builder model represents the current state of the character the user is building.


Field Summary
protected  ArrayList<ComponentClass> _classes
          The list of all available component classes.
protected  HashMap<ComponentClass,ArrayList<Integer>> _components
          The hashtable of available component ids for each class.
protected  ArrayList<BuilderModelListener> _listeners
          The model listeners.
protected  HashMap<ComponentClass,Integer> _selected
          The currently selected character components.
 
Constructor Summary
BuilderModel(ComponentRepository crepo)
          Constructs a builder model.
 
Method Summary
 void addListener(BuilderModelListener l)
          Adds a builder model listener.
protected  void gatherComponentInfo(ComponentRepository crepo)
          Gathers component class and component information from the character manager for later reference by others.
 List<ComponentClass> getComponentClasses()
          Returns a list of the available component classes.
 List<Integer> getComponents(ComponentClass cclass)
          Returns the list of components available in the specified class.
 int[] getSelectedComponents()
          Returns the selected components in an array.
protected  void notifyListeners(int event)
          Notifies all model listeners that the builder model has changed.
 void setSelectedComponent(ComponentClass cclass, int cid)
          Sets the selected component for the given component class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_selected

protected HashMap<ComponentClass,Integer> _selected
The currently selected character components.


_components

protected HashMap<ComponentClass,ArrayList<Integer>> _components
The hashtable of available component ids for each class.


_classes

protected ArrayList<ComponentClass> _classes
The list of all available component classes.


_listeners

protected ArrayList<BuilderModelListener> _listeners
The model listeners.

Constructor Detail

BuilderModel

public BuilderModel(ComponentRepository crepo)
Constructs a builder model.

Method Detail

addListener

public void addListener(BuilderModelListener l)
Adds a builder model listener.

Parameters:
l - the listener.

notifyListeners

protected void notifyListeners(int event)
Notifies all model listeners that the builder model has changed.


getComponentClasses

public List<ComponentClass> getComponentClasses()
Returns a list of the available component classes.


getComponents

public List<Integer> getComponents(ComponentClass cclass)
Returns the list of components available in the specified class.


getSelectedComponents

public int[] getSelectedComponents()
Returns the selected components in an array.


setSelectedComponent

public void setSelectedComponent(ComponentClass cclass,
                                 int cid)
Sets the selected component for the given component class.


gatherComponentInfo

protected void gatherComponentInfo(ComponentRepository crepo)
Gathers component class and component information from the character manager for later reference by others.