diff --git a/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java b/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java index df513072f..88392e015 100644 --- a/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java +++ b/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java @@ -1,5 +1,5 @@ // -// $Id: BundledTileSetRepository.java,v 1.5 2001/11/30 02:34:57 mdb Exp $ +// $Id: BundledTileSetRepository.java,v 1.6 2002/09/23 18:19:57 mdb Exp $ package com.threerings.media.tile.bundle; @@ -80,6 +80,40 @@ public class BundledTileSetRepository tbundles.toArray(_bundles); } + /** + * Searches for the tileset with the specified name, which must reside + * in a tileset bundle identified by the supplied bundle identifying + * string. + * + * @param bundleId a string that will be substring matched against the + * names of all known tileset bundles. Only bundles whose bundle file + * path contains this string will be searched. + * @param setName the name of the tileset to be located. + * + * @return The first tileset matching the supplied parameters or null + * if no matching tileset could be found. + */ + public TileSet locateTileSet (String bundleId, String setName) + { + int bcount = _bundles.length; + for (int ii = 0; ii < bcount; ii++) { + TileSetBundle tsb = _bundles[ii]; + // skip non-matching bundles + if (tsb.getSource().getPath().indexOf(bundleId) == -1) { + continue; + } + // search for the tileset in this bundle + Iterator tsiter = tsb.enumerateTileSets(); + while (tsiter.hasNext()) { + TileSet set = (TileSet)tsiter.next(); + if (set.getName().equals(setName)) { + return set; + } + } + } + return null; + } + // documentation inherited public Iterator enumerateTileSetIds () throws PersistenceException diff --git a/src/java/com/threerings/media/tile/bundle/TileSetBundle.java b/src/java/com/threerings/media/tile/bundle/TileSetBundle.java index b864292f0..4efb34377 100644 --- a/src/java/com/threerings/media/tile/bundle/TileSetBundle.java +++ b/src/java/com/threerings/media/tile/bundle/TileSetBundle.java @@ -1,11 +1,12 @@ // -// $Id: TileSetBundle.java,v 1.9 2002/08/19 22:58:15 mdb Exp $ +// $Id: TileSetBundle.java,v 1.10 2002/09/23 18:19:57 mdb Exp $ package com.threerings.media.tile.bundle; import java.awt.Image; import javax.imageio.ImageIO; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -40,6 +41,14 @@ public class TileSetBundle extends HashIntMap _imgr = imgr; } + /** + * Returns the bundle file from which our tiles are fetched. + */ + public File getSource () + { + return _bundle.getSource(); + } + /** * Adds a tileset to this tileset bundle. */