Initial work on adding a selectable tile panel to the right of the

scene display.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@52 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-16 18:59:31 +00:00
parent 0a0fce7db3
commit 6806cfb6f7
6 changed files with 140 additions and 47 deletions
@@ -1,5 +1,5 @@
//
// $Id: TileManager.java,v 1.2 2001/07/14 00:21:24 shaper Exp $
// $Id: TileManager.java,v 1.3 2001/07/16 18:59:31 shaper Exp $
package com.threerings.cocktail.miso.tile;
@@ -20,42 +20,49 @@ public class TileManager
{
_tsmgr = tsmgr;
}
public Tile getTile (String setName, String tileName)
public int getNumTilesInSet (int tsid)
{
return new Tile(0, 0);
TileSet tset = _tsmgr.getTileSet(tsid);
if (tset == null) return -1;
return tset.getNumTiles();
}
public Tile getTile (short tsid, short tid)
public String[] getTileSetNames ()
{
return _tsmgr.getTileSetNames();
}
public Tile getTile (int tsid, int tid)
{
// the fully unique tile id is the conjoined tile set and tile id
int utid = tsid << 16 | tid;
// look the tile up in our hash
Tile tile = (Tile) _tiles.get(utid);
if (tile == null) {
// retrieve the tileset containing the tile
TileSet tset = _tsmgr.getTileSet(tsid);
Log.info("Retrieved tileset [tsid=" + tsid + ", tid=" +
tid + ", tset=" + tset + "].");
// retrieve the tile image from the tileset
tile = new Tile(tsid, tid);
tile.img = tset.getTileImage(tid);
_tiles.put(utid, tile);
if (tile != null) {
// Log.info("Retrieved tile from cache [tsid=" + tsid +
// ", tid=" + tid + "].");
return tile;
}
// retrieve the tileset containing the tile
TileSet tset = _tsmgr.getTileSet(tsid);
// retrieve the tile image from the tileset
tile = new Tile(tsid, tid);
tile.img = tset.getTileImage(tid);
_tiles.put(utid, tile);
Log.info("Loaded tile into cache [tsid="+tsid+", tid="+tid+"].");
return tile;
}
// mapping from (tsid << 16 | tid) to tile objects
protected IntMap _tiles = new IntMap();
// mapping from tileset ids to tileset objects
protected IntMap _tilesets = new IntMap();
// our tile set manager
protected TileSetManager _tsmgr;
}