More work on object tiles. Simplified tile set manager as the editor

will now obtain tile set information directly from the tile sets.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@446 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-10-12 00:38:15 +00:00
parent 1cd07dc217
commit e8d41b9592
4 changed files with 27 additions and 64 deletions
@@ -1,17 +1,16 @@
// //
// $Id: ObjectTile.java,v 1.1 2001/10/11 00:41:26 shaper Exp $ // $Id: ObjectTile.java,v 1.2 2001/10/12 00:38:15 shaper Exp $
package com.threerings.media.tile; package com.threerings.media.tile;
import java.awt.Graphics2D; import java.awt.*;
import java.awt.Shape;
/** /**
* An object tile extends the base tile to provide support for objects * An object tile extends the base tile to provide support for objects
* whose image spans more than one tile. The object has dimensions * whose image spans more than one tile. An object tile has
* that represent its footprint or "shadow", which the scene * dimensions that represent its footprint or "shadow", which the
* containing the tile can reference to do things like make the * scene containing the tile can then reference to do things like
* footprint tiles impassable. * making the footprint tiles impassable.
*/ */
public class ObjectTile extends Tile public class ObjectTile extends Tile
{ {
@@ -28,13 +27,4 @@ public class ObjectTile extends Tile
this.baseWidth = baseWidth; this.baseWidth = baseWidth;
this.baseHeight = baseHeight; this.baseHeight = baseHeight;
} }
// documentation inherited
public void paint (Graphics2D gfx, Shape dest)
{
super.paint(gfx, dest);
// TODO: draw the object image offset to account for its
// actual dimensions
}
} }
+3 -3
View File
@@ -1,5 +1,5 @@
// //
// $Id: Tile.java,v 1.14 2001/10/11 00:41:26 shaper Exp $ // $Id: Tile.java,v 1.15 2001/10/12 00:38:15 shaper Exp $
package com.threerings.media.tile; package com.threerings.media.tile;
@@ -49,8 +49,8 @@ public class Tile
} }
/** /**
* Render the tile into the given rectangle in the given graphics * Render the tile image at the top-left corner of the given shape
* context. * in the given graphics context.
*/ */
public void paint (Graphics2D gfx, Shape dest) public void paint (Graphics2D gfx, Shape dest)
{ {
@@ -1,12 +1,12 @@
// //
// $Id: TileSetManager.java,v 1.13 2001/10/11 00:41:26 shaper Exp $ // $Id: TileSetManager.java,v 1.14 2001/10/12 00:38:15 shaper Exp $
package com.threerings.media.tile; package com.threerings.media.tile;
import com.threerings.media.ImageManager; import com.threerings.media.ImageManager;
import java.awt.Image; import java.awt.Image;
import java.util.ArrayList; import java.util.Iterator;
/** /**
* The <code>TileSetManager</code> provides tileset management * The <code>TileSetManager</code> provides tileset management
@@ -20,22 +20,12 @@ import java.util.ArrayList;
public interface TileSetManager public interface TileSetManager
{ {
/** /**
* Return the total number of tiles in the specified tileset or -1 * Return an <code>Iterator</code> over all <code>TileSet</code>
* if the tileset is not found. * objects available.
* *
* @param tsid the tileset identifier. * @return the tileset iterator.
* @return the number of tiles.
*/ */
public int getNumTilesInSet (int tsid) public Iterator getTileSets ();
throws NoSuchTileSetException;
/**
* Return an <code>ArrayList</code> containing all
* <code>TileSet</code> objects available.
*
* @return the list of tilesets.
*/
public ArrayList getAllTileSets ();
/** /**
* Return the tileset object corresponding to the specified * Return the tileset object corresponding to the specified
@@ -58,11 +48,4 @@ public interface TileSetManager
*/ */
public Tile getTile (int tsid, int tid) public Tile getTile (int tsid, int tid)
throws NoSuchTileSetException, NoSuchTileException; throws NoSuchTileSetException, NoSuchTileException;
/**
* Return the total number of tilesets available for use.
*
* @return the number of tilesets.
*/
public int getNumTileSets ();
} }
@@ -1,12 +1,12 @@
// //
// $Id: TileSetManagerImpl.java,v 1.13 2001/10/11 00:41:26 shaper Exp $ // $Id: TileSetManagerImpl.java,v 1.14 2001/10/12 00:38:15 shaper Exp $
package com.threerings.media.tile; package com.threerings.media.tile;
import java.awt.Image; import java.awt.Image;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.Collections;
import java.util.Enumeration; import java.util.Iterator;
import com.samskivert.util.*; import com.samskivert.util.*;
@@ -16,7 +16,7 @@ import com.threerings.media.Log;
public abstract class TileSetManagerImpl implements TileSetManager public abstract class TileSetManagerImpl implements TileSetManager
{ {
/** /**
* Initialize the <code>TileSetManager</code>. * Initialize the tile set manager.
* *
* @param config the config object. * @param config the config object.
* @param imgmgr the image manager. * @param imgmgr the image manager.
@@ -27,12 +27,7 @@ public abstract class TileSetManagerImpl implements TileSetManager
_config = config; _config = config;
} }
public int getNumTilesInSet (int tsid) // documentation inherited
throws NoSuchTileSetException
{
return getTileSet(tsid).getNumTiles();
}
public TileSet getTileSet (int tsid) public TileSet getTileSet (int tsid)
throws NoSuchTileSetException throws NoSuchTileSetException
{ {
@@ -44,24 +39,19 @@ public abstract class TileSetManagerImpl implements TileSetManager
return tset; return tset;
} }
// documentation inherited
public Iterator getTileSets ()
{
return Collections.unmodifiableMap(_tilesets).values().iterator();
}
// documentation inherited
public Tile getTile (int tsid, int tid) public Tile getTile (int tsid, int tid)
throws NoSuchTileSetException, NoSuchTileException throws NoSuchTileSetException, NoSuchTileException
{ {
return getTileSet(tsid).getTile(_imgmgr, tid); return getTileSet(tsid).getTile(_imgmgr, tid);
} }
public ArrayList getAllTileSets ()
{
ArrayList list = new ArrayList();
CollectionUtil.addAll(list, _tilesets.elements());
return list;
}
public int getNumTileSets ()
{
return _tilesets.size();
}
/** The config object. */ /** The config object. */
protected Config _config; protected Config _config;