It looks like Vilya uses CastUtil, so we'll just make it slightly less hacky

and put it back into the main codebase.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1063 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2010-11-08 22:25:14 +00:00
parent 310ff1e3ba
commit f94d7c8d1a
2 changed files with 21 additions and 13 deletions
@@ -19,7 +19,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.cast;
package com.threerings.cast.util;
import java.util.ArrayList;
import java.util.Iterator;
@@ -32,6 +32,10 @@ import com.samskivert.util.RandomUtil;
import com.threerings.media.image.ColorPository;
import com.threerings.media.image.Colorization;
import com.threerings.cast.CharacterDescriptor;
import com.threerings.cast.ComponentClass;
import com.threerings.cast.ComponentRepository;
import static com.threerings.cast.Log.log;
/**
@@ -43,11 +47,12 @@ public class CastUtil
* Returns a new character descriptor populated with a random set of components.
*/
public static CharacterDescriptor getRandomDescriptor (
String gender, ComponentRepository crepo, ColorPository cpos)
ComponentRepository crepo, String gender, String[] COMP_CLASSES,
ColorPository cpos, String[] COLOR_CLASSES)
{
// get all available classes
ArrayList<ComponentClass> classes = Lists.newArrayList();
for (String element : CLASSES) {
for (String element : COMP_CLASSES) {
String cname = gender + "/" + element;
ComponentClass cclass = crepo.getComponentClass(cname);
@@ -100,11 +105,4 @@ public class CastUtil
return new CharacterDescriptor(components, zations);
}
// these are all specific to our test resourcse
protected static final String[] CLASSES = {
"legs", "feet", "hand_left", "hand_right", "torso",
"head", "hair", "hat", "eyepatch" };
protected static final String[] COLOR_CLASSES = {
"skin", "hair", "textile_p", "textile_s" };
}
@@ -41,11 +41,11 @@ import com.threerings.miso.client.MisoScenePanel;
import com.threerings.miso.data.MisoSceneModel;
import com.threerings.miso.util.MisoContext;
import com.threerings.cast.CastUtil;
import com.threerings.cast.CharacterDescriptor;
import com.threerings.cast.CharacterManager;
import com.threerings.cast.CharacterSprite;
import com.threerings.cast.ComponentRepository;
import com.threerings.cast.util.CastUtil;
import static com.threerings.miso.Log.log;
@@ -61,8 +61,9 @@ public class ViewerSceneViewPanel extends MisoScenePanel
super(ctx, MisoConfig.getSceneMetrics());
// create the character descriptors
_descUser = CastUtil.getRandomDescriptor("female", crepo, cpos);
_descDecoy = CastUtil.getRandomDescriptor("male", crepo, cpos);
_descUser = CastUtil.getRandomDescriptor(
crepo, "female", COMP_CLASSES, cpos, COLOR_CLASSES);
_descDecoy = CastUtil.getRandomDescriptor(crepo, "male", COMP_CLASSES, cpos, COLOR_CLASSES);
// create the manipulable sprite
_sprite = createSprite(_spritemgr, charmgr, _descUser);
@@ -234,4 +235,13 @@ public class ViewerSceneViewPanel extends MisoScenePanel
/** The test sprites that meander about aimlessly. */
protected CharacterSprite _decoys[];
/** Defines our various character component classes. */
protected static final String[] COMP_CLASSES = {
"legs", "feet", "hand_left", "hand_right", "torso",
"head", "hair", "hat", "eyepatch" };
/** Defines the colorization classes used in the character component images. */
protected static final String[] COLOR_CLASSES = {
"skin", "hair", "textile_p", "textile_s" };
}