Oh the vast sweeping changes, and they're not even close to complete, but

things compile and most things run so this is a good time to checkpoint.
Let me recall:

- Refactored the whole scene deal.
- Revamped the XML parser stuff (now uses Digester).
- Rethought the tile management.
- Started tile bundle stuff.
- Wrote some tests.
- Did a bit of Mike-ification.

Onward and moreward.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@621 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-11-18 04:09:23 +00:00
parent 45251dba8c
commit ae1052a371
77 changed files with 2188 additions and 3512 deletions
@@ -1,65 +1,66 @@
//
// $Id: ObjectTileSet.java,v 1.1 2001/11/08 03:04:44 mdb Exp $
// $Id: ObjectTileSet.java,v 1.2 2001/11/18 04:09:21 mdb Exp $
package com.threerings.media.tile;
import java.awt.Image;
import java.awt.Point;
import java.util.Arrays;
import com.samskivert.util.HashIntMap;
import com.threerings.media.Log;
import com.threerings.media.ImageManager;
/**
* The objcet tileset supports the specification of object information for
* The object tileset supports the specification of object information for
* object tiles in addition to all of the features of the swiss army
* tileset.
*
* @see ObjectTile
*/
public class ObjectTileSet extends SwissArmyTileSet
{
/**
* Constructs a tileset with all of the swiss army configuration
* parameters, with the addition of object information for those tiles
* in the set that are object tiles.
* Adds object data for the tile at the specified index.
*
* @param objects object information for those tiles that are objects.
*
* @see SwissArmyTileSet#SwissArmyTileSet
* @param tileIndex the tile for which we are adding object data.
* @param objWidth the width of the object in tile units.
* @param objHeight the height of the object in tile units.
*/
public ObjectTileSet (
ImageManager imgmgr, String imgPath, String name, int tsid,
int[] tileCount, int[] rowWidth, int[] rowHeight,
Point offsetPos, Point gapDist, HashIntMap objects)
public void addObjectData (int tileIndex, int objWidth, int objHeight)
{
super(imgmgr, imgPath, name, tsid, tileCount, rowWidth, rowHeight,
offsetPos, gapDist);
// create our objects arrays if we've not already got them
if (_owidths == null) {
_owidths = new int[getTileCount()];
_oheights = new int[_owidths.length];
// initialize the default tile dimensions to one unit
Arrays.fill(_owidths, 1);
Arrays.fill(_oheights, 1);
}
// keep this for later
_objects = objects;
// now fill in the appropriate slot
_owidths[tileIndex] = objWidth;
_oheights[tileIndex] = objHeight;
}
/**
* Creates instances of {@link ObjectTile} which can span more than a
* Creates instances of {@link ObjectTile}, which can span more than a
* single tile's space in a display.
*/
protected Tile createTile (int tileId)
protected Tile createTile (int tileIndex, Image image)
{
// default object dimensions to (1, 1)
int wid = 1, hei = 1;
// retrieve object dimensions if known
if (_objects != null) {
int size[] = (int[])_objects.get(tileId);
if (size != null) {
wid = size[0];
hei = size[1];
}
if (_owidths != null) {
wid = _owidths[tileIndex];
wid = _oheights[tileIndex];
}
return new ObjectTile(_tsid, tileId, wid, hei);
return new ObjectTile(image, wid, hei);
}
/** Mapping of object tile ids to object dimensions. */
protected HashIntMap _objects;
/** The width (in tile units) of our object tiles. */
protected int[] _owidths;
/** The height (in tile units) of our object tiles. */
protected int[] _oheights;
}