Added a means for looking up tilesets by name (though you should know

which bundle they are in to avoid scanning the whole goddamned lot).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1738 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-09-23 18:19:57 +00:00
parent bf25816235
commit 4d94555e09
2 changed files with 45 additions and 2 deletions
@@ -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
@@ -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.
*/