From f94d7c8d1a302ffb0556d27d018e9a9353b33110 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 8 Nov 2010 22:25:14 +0000 Subject: [PATCH] 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 --- .../com/threerings/cast/util}/CastUtil.java | 18 ++++++++---------- .../miso/viewer/ViewerSceneViewPanel.java | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 13 deletions(-) rename src/{test/java/com/threerings/cast => main/java/com/threerings/cast/util}/CastUtil.java (89%) diff --git a/src/test/java/com/threerings/cast/CastUtil.java b/src/main/java/com/threerings/cast/util/CastUtil.java similarity index 89% rename from src/test/java/com/threerings/cast/CastUtil.java rename to src/main/java/com/threerings/cast/util/CastUtil.java index 4602747e..bcd52c7b 100644 --- a/src/test/java/com/threerings/cast/CastUtil.java +++ b/src/main/java/com/threerings/cast/util/CastUtil.java @@ -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 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" }; } diff --git a/src/test/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java b/src/test/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java index 46d0c86e..3608e3e3 100644 --- a/src/test/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java +++ b/src/test/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java @@ -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" }; }