From 22b001eb738e39502e6728f66185cecdb4784a50 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 24 Jul 2002 22:24:05 +0000 Subject: [PATCH] Added support for falling back to a "default" action image for components that do not have an image specificly for a particular action sequence. In the future, I'd like to at least provide a mechanism for specifying on a per action sequence basis which action sequence to fall back to in the event that a component is missing imagery for that sequence. Then the default mecahism could be used without forcing all action sequences for a particular class of components to be exactly alike. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1614 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/cast/ActionSequence.java | 12 +++++++++- .../bundle/BundledComponentRepository.java | 22 +++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/java/com/threerings/cast/ActionSequence.java b/src/java/com/threerings/cast/ActionSequence.java index fa8b0874b..08393df4e 100644 --- a/src/java/com/threerings/cast/ActionSequence.java +++ b/src/java/com/threerings/cast/ActionSequence.java @@ -1,5 +1,5 @@ // -// $Id: ActionSequence.java,v 1.4 2002/06/26 23:53:06 mdb Exp $ +// $Id: ActionSequence.java,v 1.5 2002/07/24 22:24:05 mdb Exp $ package com.threerings.cast; @@ -15,6 +15,16 @@ import java.io.Serializable; */ public class ActionSequence implements Serializable { + /** + * Defines the name of the default action sequence. When component + * tilesets are loaded to build a set of composited images for a + * particular action sequence, a check is first made for a component + * tileset specific to the action sequence and then for the + * component's default tileset if the action specific tileset did not + * exist. + */ + public static final String DEFAULT_SEQUENCE = "default"; + /** The action sequence name. */ public String name; diff --git a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java index 3cda544b2..2ccb04101 100644 --- a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java +++ b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java @@ -1,5 +1,5 @@ // -// $Id: BundledComponentRepository.java,v 1.15 2002/06/26 23:53:06 mdb Exp $ +// $Id: BundledComponentRepository.java,v 1.16 2002/07/24 22:24:05 mdb Exp $ package com.threerings.cast.bundle; @@ -263,11 +263,6 @@ public class BundledComponentRepository public ActionFrames getFrames ( CharacterComponent component, String action) { - // load up the tileset for this action - String path = component.componentClass.name + "/" + - component.name + "/" + action + - BundleUtil.TILESET_EXTENSION; - // obtain the action sequence definition for this action ActionSequence actseq = (ActionSequence)_actions.get(action); if (actseq == null) { @@ -277,8 +272,21 @@ public class BundledComponentRepository return null; } + // first try loading up a tileset customized for this action + String root = component.componentClass.name + "/" + + component.name + "/"; + String path = root + action + BundleUtil.TILESET_EXTENSION; + try { - TileSet aset = (TileSet)BundleUtil.loadObject(_bundle, path); + TileSet aset = null; + aset = (TileSet)BundleUtil.loadObject(_bundle, path); + if (aset == null) { + Log.info("Falling back to default [path=" + path + "]."); + // try loading the default tileset + path = root + ActionSequence.DEFAULT_SEQUENCE + + BundleUtil.TILESET_EXTENSION; + aset = (TileSet)BundleUtil.loadObject(_bundle, path); + } aset.setImageProvider(this); return new TileSetFrameImage(aset, actseq);