Started tooling about with Java2D BufferedImages. Retrieve tileset

config information from miso.properties for now.  Don't pass around
ImageObservers since we're hoping to be able to address that
differently.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@49 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-14 00:21:24 +00:00
parent 007ce996f7
commit edc687fcb4
5 changed files with 74 additions and 67 deletions
@@ -1,21 +1,20 @@
//
// $Id: TileManager.java,v 1.1 2001/07/12 22:38:03 shaper Exp $
// $Id: TileManager.java,v 1.2 2001/07/14 00:21:24 shaper Exp $
package com.threerings.cocktail.miso.tile;
import com.threerings.cocktail.miso.Log;
import com.samskivert.util.IntMap;
import java.awt.*;
import java.awt.image.ImageObserver;
import java.util.Vector;
/**
* Provides a simplified interface for retrieving tile objects from
* various tilesets, by name or identifier, and manages caching of
* tiles and related resources as appropriate.
*/
public class TileManager implements ImageObserver
public class TileManager
{
public TileManager (TileSetManager tsmgr)
{
@@ -38,43 +37,25 @@ public class TileManager implements ImageObserver
// 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, this);
tile.img = tset.getTileImage(tid);
_tiles.put(utid, tile);
}
return tile;
}
public void registerObserver (ImageObserver obs)
{
if (_observers == null) _observers = new Vector();
_observers.addElement(obs);
}
public boolean imageUpdate (Image img, int infoflags, int x, int y,
int width, int height)
{
int size = _observers.size();
for (int ii = 0; ii < size; ii++) {
ImageObserver obs = (ImageObserver)_observers.elementAt(ii);
obs.imageUpdate(img, infoflags, x, y, width, height);
}
return true;
}
// 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();
// registered tile image observers
protected Vector _observers;
// our tile set manager
protected TileSetManager _tsmgr;
}