A few substantial changes:
- Tiles are initialized after being constructed which makes life simpler for custom tiles which no longer have to have their own constructor that passes Tile's stuff down to it. - Tiles are no longer LRU cached (because we blow through that cache instantly on all but the smallest of scenes), and are now tracked by weak references so that we guarantee that only one instance of a tile is ever in memory. - Added code to track and report memory usage of weak cached tiles as well as "stray" tiles which are created through other means than asking a TileSet for a tile (fringe tiles being the most prolific example). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2628 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: AutoFringer.java,v 1.24 2003/05/29 01:58:06 ray Exp $
|
||||
// $Id: AutoFringer.java,v 1.25 2003/05/31 00:56:38 mdb Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
@@ -140,7 +140,9 @@ public class AutoFringer
|
||||
}
|
||||
}
|
||||
|
||||
return new Tile(new BufferedMirage(ftimg));
|
||||
Tile tile = new Tile();
|
||||
tile.setImage(new BufferedMirage(ftimg));
|
||||
return tile;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
//
|
||||
// $Id: BaseTile.java,v 1.7 2003/01/13 22:55:12 mdb Exp $
|
||||
// $Id: BaseTile.java,v 1.8 2003/05/31 00:56:38 mdb Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import com.threerings.media.image.Mirage;
|
||||
import com.threerings.media.tile.Tile;
|
||||
|
||||
/**
|
||||
@@ -13,24 +12,6 @@ import com.threerings.media.tile.Tile;
|
||||
*/
|
||||
public class BaseTile extends Tile
|
||||
{
|
||||
/**
|
||||
* Constructs a new base tile with the specified image. Passability
|
||||
* will be assumed to be true.
|
||||
*/
|
||||
public BaseTile (Mirage image)
|
||||
{
|
||||
this(image, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new base tile with the specified passability.
|
||||
*/
|
||||
public BaseTile (Mirage image, boolean passable)
|
||||
{
|
||||
super(image);
|
||||
_passable = passable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this tile can be walked upon by character
|
||||
* sprites.
|
||||
@@ -40,6 +21,14 @@ public class BaseTile extends Tile
|
||||
return _passable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures this base tile as passable or impassable.
|
||||
*/
|
||||
public void setPassable (boolean passable)
|
||||
{
|
||||
_passable = passable;
|
||||
}
|
||||
|
||||
/** Whether the tile is passable. */
|
||||
protected boolean _passable = true;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//
|
||||
// $Id: BaseTileSet.java,v 1.12 2003/01/15 09:11:37 mdb Exp $
|
||||
// $Id: BaseTileSet.java,v 1.13 2003/05/31 00:56:38 mdb Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.media.image.Mirage;
|
||||
import com.threerings.media.image.Colorization;
|
||||
import com.threerings.media.tile.SwissArmyTileSet;
|
||||
import com.threerings.media.tile.Tile;
|
||||
|
||||
@@ -35,9 +35,16 @@ public class BaseTileSet extends SwissArmyTileSet
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected Tile createTile (int tileIndex, Mirage tileImage)
|
||||
protected Tile createTile ()
|
||||
{
|
||||
return new BaseTile(tileImage, _passable[tileIndex]);
|
||||
return new BaseTile();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void initTile (Tile tile, int tileIndex, Colorization[] zations)
|
||||
{
|
||||
super.initTile(tile, tileIndex, zations);
|
||||
((BaseTile)tile).setPassable(_passable[tileIndex]);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
//
|
||||
// $Id: FringeTile.java,v 1.4 2003/01/13 22:55:12 mdb Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.media.image.Mirage;
|
||||
|
||||
/**
|
||||
* A fringe tile may be composed of multiple images.
|
||||
*/
|
||||
public class FringeTile extends Tile
|
||||
{
|
||||
/**
|
||||
* Construct a fringe tile with the specified image.
|
||||
*/
|
||||
public FringeTile (Mirage mirage)
|
||||
{
|
||||
super(mirage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another image to this fringe tile.
|
||||
*/
|
||||
public void addExtraImage (Mirage mirage)
|
||||
{
|
||||
if (_extras == null) {
|
||||
_extras = new ArrayList();
|
||||
}
|
||||
_extras.add(mirage);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void paint (Graphics2D gfx, int x, int y)
|
||||
{
|
||||
// paint our main image
|
||||
super.paint(gfx, x, y);
|
||||
|
||||
if (_extras != null) {
|
||||
int size = _extras.size();
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Mirage image = (Mirage)_extras.get(ii);
|
||||
image.paint(gfx, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Extra fringe images beyond the one stored in our superclass. */
|
||||
protected ArrayList _extras = null;
|
||||
}
|
||||
Reference in New Issue
Block a user