From 228762fc0d014edb38ec4efb99f31d567a617552 Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Wed, 4 Jun 2008 23:42:36 +0000 Subject: [PATCH] Pass the set of all valid paths through to getFramePath so it can fall back to the default action if the specified action doesn't exist git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@523 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../threerings/cast/CharacterComponent.java | 7 ++- .../com/threerings/cast/FrameProvider.java | 12 +++-- .../bundle/BundledComponentRepository.java | 50 ++++++++++--------- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/java/com/threerings/cast/CharacterComponent.java b/src/java/com/threerings/cast/CharacterComponent.java index af6008dc..6a1eabd6 100644 --- a/src/java/com/threerings/cast/CharacterComponent.java +++ b/src/java/com/threerings/cast/CharacterComponent.java @@ -22,6 +22,7 @@ package com.threerings.cast; import java.io.Serializable; +import java.util.Set; import com.samskivert.util.StringUtil; @@ -76,10 +77,12 @@ public class CharacterComponent implements Serializable * * @param type null for the normal action frames or one of the custom * action sub-types: {@link StandardActions#SHADOW_TYPE}, etc. + * + * @param existentPaths the set of all paths for which there are valid frames. */ - public String getFramePath (String action, String type) + public String getFramePath (String action, String type, Set existentPaths) { - return _frameProvider.getFramePath(this, action, type); + return _frameProvider.getFramePath(this, action, type, existentPaths); } /** diff --git a/src/java/com/threerings/cast/FrameProvider.java b/src/java/com/threerings/cast/FrameProvider.java index 1efdb731..af79dc97 100644 --- a/src/java/com/threerings/cast/FrameProvider.java +++ b/src/java/com/threerings/cast/FrameProvider.java @@ -21,6 +21,8 @@ package com.threerings.cast; +import java.util.Set; + /** * Provides a mechanism where by a character component can obtain access * to its image frames for a particular action in an on demand manner. @@ -36,10 +38,12 @@ public interface FrameProvider CharacterComponent component, String action, String type); /** - * Returns the file path of the animation frames (in the eight sprite directions) for - * the specified action of the specified component. May return null if - * the specified action does not exist for the specified component. + * Returns the file path of the animation frames (in the eight sprite directions) for the + * specified action of the specified component. May return a path to the default action or + * null if the specified action does not exist for the specified component. + * + * @param existentPaths the set of all paths for which there are valid frames. */ public String getFramePath ( - CharacterComponent component, String action, String type); + CharacterComponent component, String action, String type, Set existentPaths); } diff --git a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java index cb09bdeb..5ce05813 100644 --- a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java +++ b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java @@ -21,39 +21,22 @@ package com.threerings.cast.bundle; +import static com.threerings.cast.Log.log; + import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; - import java.io.IOException; - import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.Set; import com.samskivert.util.HashIntMap; import com.samskivert.util.IntIntMap; import com.samskivert.util.Predicate; import com.samskivert.util.Tuple; -import com.threerings.resource.FileResourceBundle; -import com.threerings.resource.ResourceBundle; -import com.threerings.resource.ResourceManager; - -import com.threerings.media.image.ImageManager; -import com.threerings.media.image.BufferedMirage; -import com.threerings.media.image.Colorization; -import com.threerings.media.image.ImageDataProvider; -import com.threerings.media.image.ImageUtil; -import com.threerings.media.image.Mirage; - -import com.threerings.media.tile.IMImageProvider; -import com.threerings.media.tile.Tile; -import com.threerings.media.tile.TileSet; -import com.threerings.media.tile.TrimmedTile; - -import com.threerings.util.DirectionCodes; - import com.threerings.cast.ActionFrames; import com.threerings.cast.ActionSequence; import com.threerings.cast.CharacterComponent; @@ -63,8 +46,19 @@ import com.threerings.cast.FrameProvider; import com.threerings.cast.NoSuchComponentException; import com.threerings.cast.StandardActions; import com.threerings.cast.TrimmedMultiFrameImage; - -import static com.threerings.cast.Log.log; +import com.threerings.media.image.BufferedMirage; +import com.threerings.media.image.Colorization; +import com.threerings.media.image.ImageDataProvider; +import com.threerings.media.image.ImageManager; +import com.threerings.media.image.Mirage; +import com.threerings.media.tile.IMImageProvider; +import com.threerings.media.tile.Tile; +import com.threerings.media.tile.TileSet; +import com.threerings.media.tile.TrimmedTile; +import com.threerings.resource.FileResourceBundle; +import com.threerings.resource.ResourceBundle; +import com.threerings.resource.ResourceManager; +import com.threerings.util.DirectionCodes; /** * A component repository implementation that obtains information from resource bundles. @@ -351,7 +345,17 @@ public class BundledComponentRepository } // from interface FrameProvider - public String getFramePath (CharacterComponent component, String action, String type) + public String getFramePath (CharacterComponent component, String action, String type, + Set existentPaths) + { + String actionPath = makePath(component, action, type); + if(!existentPaths.contains(actionPath)) { + return makePath(component, ActionSequence.DEFAULT_SEQUENCE, type); + } + return actionPath; + } + + protected String makePath(CharacterComponent component, String action, String type) { String imgpath = action; if (type != null) {