Cache tilesets loaded out of component bundles.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2691 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: BundledComponentRepository.java,v 1.28 2003/07/01 21:56:10 mdb Exp $
|
// $Id: BundledComponentRepository.java,v 1.29 2003/07/02 00:01:17 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cast.bundle;
|
package com.threerings.cast.bundle;
|
||||||
|
|
||||||
@@ -286,21 +286,44 @@ public class BundledComponentRepository
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// first try loading up a tileset customized for this action
|
|
||||||
String root = component.componentClass.name + "/" +
|
String root = component.componentClass.name + "/" +
|
||||||
component.name + "/";
|
component.name + "/";
|
||||||
String path = root + action + BundleUtil.TILESET_EXTENSION;
|
String cpath = root + action + BundleUtil.TILESET_EXTENSION;
|
||||||
|
String dpath = root + ActionSequence.DEFAULT_SEQUENCE +
|
||||||
|
BundleUtil.TILESET_EXTENSION;
|
||||||
|
|
||||||
|
// look to see if this tileset is already cached (as the
|
||||||
|
// custom action or the default action)
|
||||||
|
TileSet aset = (TileSet)_setcache.get(cpath);
|
||||||
|
if (aset == null) {
|
||||||
|
aset = (TileSet)_setcache.get(dpath);
|
||||||
|
if (aset != null) {
|
||||||
|
// save ourselves a lookup next time
|
||||||
|
_setcache.put(cpath, aset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TileSet aset = (TileSet)BundleUtil.loadObject(_bundle, path);
|
// then try loading up a tileset customized for this action
|
||||||
if (aset == null) {
|
if (aset == null) {
|
||||||
Log.debug("Falling back to default [path=" + path + "].");
|
aset = (TileSet)BundleUtil.loadObject(_bundle, cpath);
|
||||||
// try loading the default tileset
|
|
||||||
path = root + ActionSequence.DEFAULT_SEQUENCE +
|
|
||||||
BundleUtil.TILESET_EXTENSION;
|
|
||||||
aset = (TileSet)BundleUtil.loadObject(_bundle, path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if that failed, try loading the default tileset
|
||||||
|
if (aset == null) {
|
||||||
|
aset = (TileSet)BundleUtil.loadObject(_bundle, dpath);
|
||||||
|
_setcache.put(dpath, aset);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if that failed too, we're hosed
|
||||||
|
if (aset == null) {
|
||||||
|
Log.warning("Unable to locate tileset for action '" +
|
||||||
|
action + "' " + component + ".");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
aset.setImageProvider(this);
|
aset.setImageProvider(this);
|
||||||
|
_setcache.put(cpath, aset);
|
||||||
return new TileSetFrameImage(aset, actseq);
|
return new TileSetFrameImage(aset, actseq);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -313,6 +336,9 @@ public class BundledComponentRepository
|
|||||||
|
|
||||||
/** The resource bundle from which we obtain image data. */
|
/** The resource bundle from which we obtain image data. */
|
||||||
protected ResourceBundle _bundle;
|
protected ResourceBundle _bundle;
|
||||||
|
|
||||||
|
/** Cache of tilesets loaded from our bundle. */
|
||||||
|
protected HashMap _setcache = new HashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user