diff --git a/src/java/com/threerings/media/image/ImageManager.java b/src/java/com/threerings/media/image/ImageManager.java index d0f71250..4c67a581 100644 --- a/src/java/com/threerings/media/image/ImageManager.java +++ b/src/java/com/threerings/media/image/ImageManager.java @@ -136,6 +136,16 @@ public class ImageManager this(rmgr, new AWTImageCreator(context)); } + /** + * Clears all images out of the cache. + */ + public void clearCache () + { + Log.info("Clearing image manager cache."); + + _ccache.clear(); + } + /** * Creates a buffered image, optimized for display on our graphics * device. diff --git a/src/java/com/threerings/resource/ResourceManager.java b/src/java/com/threerings/resource/ResourceManager.java index f3848a08..e1d764b3 100644 --- a/src/java/com/threerings/resource/ResourceManager.java +++ b/src/java/com/threerings/resource/ResourceManager.java @@ -193,6 +193,14 @@ public class ResourceManager } } + /** + * Set where we should look for locale-specific resources. + */ + public void setLocalePrefix (String prefix) + { + _localePrefix = prefix; + } + /** * Initializes the bundle sets to be made available by this resource * manager. Applications that wish to make use of resource bundles @@ -419,6 +427,23 @@ public class ResourceManager } // if we still didn't find anything, try the classloader + + // First try a locale-specific file + if (_localePrefix != null) { + final String rpath = PathUtil.appendPath(_rootPath, + PathUtil.appendPath(_localePrefix, path)); + in = (InputStream)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run () { + return _loader.getResourceAsStream(rpath); + } + }); + if (in != null) { + return in; + } + } + + // But if we didn't find that, try locale-neutral. final String rpath = PathUtil.appendPath(_rootPath, path); in = (InputStream)AccessController.doPrivileged(new PrivilegedAction() { public Object run () { @@ -462,6 +487,22 @@ public class ResourceManager return new FileImageInputStream(file); } + // First try a locale-specific file + if (_localePrefix != null) { + final String rpath = PathUtil.appendPath(_rootPath, + PathUtil.appendPath(_localePrefix, path)); + InputStream in = (InputStream)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run () { + return _loader.getResourceAsStream(rpath); + } + }); + if (in != null) { + return new MemoryCacheImageInputStream( + new BufferedInputStream(in)); + } + } + // if we still didn't find anything, try the classloader final String rpath = PathUtil.appendPath(_rootPath, path); InputStream in = (InputStream) @@ -686,6 +727,9 @@ public class ResourceManager /** A table of our resource sets. */ protected HashMap _sets = new HashMap(); + /** Locale to search for locale-specific resources, if any. */ + protected String _localePrefix = null; + /** The prefix of configuration entries that describe a resource * set. */ protected static final String RESOURCE_SET_PREFIX = "resource.set.";