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
This commit is contained in:
@@ -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<String> existentPaths)
|
||||
{
|
||||
return _frameProvider.getFramePath(this, action, type);
|
||||
return _frameProvider.getFramePath(this, action, type, existentPaths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<String> existentPaths);
|
||||
}
|
||||
|
||||
@@ -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<String> 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) {
|
||||
|
||||
Reference in New Issue
Block a user