A bunch of intertwingled changes:

Refactored TileSet into TileSet, UniformTileSet, SwissArmyTileSet and
ObjectTileSet.

Removed dependence on the "root" system property from the
XMLSceneRepository (things either pass in full paths now or input streams
fetched via the resource manager).

Removed MisoUtil.createImageManager() because everyone does that by hand
now (which is good because some non-Miso things were using MisoUtil for
that).

I think that's it, but if there was something else, don't blame me. Blame
the monkeys.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@608 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-11-08 03:04:45 +00:00
parent 0b5d51a80c
commit feb2a2633e
12 changed files with 563 additions and 277 deletions
@@ -0,0 +1,74 @@
//
// $Id: UniformTileSet.java,v 1.1 2001/11/08 03:04:44 mdb Exp $
package com.threerings.media.tile;
import java.awt.Image;
import com.threerings.media.Log;
import com.threerings.media.ImageManager;
/**
* A uniform tileset is one that is composed of tiles that are all the
* same width and height and are arranged into rows, with each row having
* the same number of tiles except possibly the final row which can
* contain the same as or less than the number of tiles contained by the
* previous rows.
*/
public class UniformTileSet extends TileSet
{
/**
* Constructs a tile set object with the specified tileset
* configuration parameters.
*
* @param imgmgr the image manager via which to load the tileset
* image.
* @param imgPath the path to supply to the image manager when loading
* the tile (which will fetch the image using the resource manager).
* @param count the number of tiles in the tile image.
* @param width the width of each tile, in pixels.
* @param height the height of each tile, in pixels.
*/
public UniformTileSet (ImageManager imgmgr, String imgPath,
int count, int width, int height)
{
super(imgmgr, imgPath, null, 0);
// keep these for later
_count = count;
_width = width;
_height = height;
}
// documentation inherited
public int getTileCount ()
{
return _count;
}
// documentation inherited
protected Image getTileImage (int tileId)
{
Image tsimg = getTilesetImage();
if (tsimg == null) {
return null;
}
// figure out from whence to crop the tile
int tilesPerRow = tsimg.getWidth(null) / _width;
int row = tilesPerRow / tileId;
int col = tilesPerRow % tileId;
// crop the tile-sized image chunk from the full image
return _imgmgr.getImageCropped(
tsimg, col * _width, row * _height, _width, _height);
}
/** The total number of tiles in this tileset. */
protected int _count;
/** The width (in pixels) of the tiles in this tileset. */
protected int _width;
/** The height (in pixels) of the tiles in this tileset. */
protected int _height;
}