Serious scene surgery.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@344 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.34 2001/09/21 00:21:40 mdb Exp $
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.35 2001/09/21 02:30:35 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -21,32 +21,8 @@ import com.threerings.miso.scene.util.ClusterUtil;
|
||||
* screen for game play. For instance, one scene might display a portion
|
||||
* of a street with several buildings scattered about on the periphery.
|
||||
*/
|
||||
public class MisoScene implements Scene
|
||||
public class MisoSceneImpl implements EditableMisoScene
|
||||
{
|
||||
/** The base layer id. */
|
||||
public static final int LAYER_BASE = 0;
|
||||
|
||||
/** The fringe layer id. */
|
||||
public static final int LAYER_FRINGE = 1;
|
||||
|
||||
/** The object layer id. */
|
||||
public static final int LAYER_OBJECT = 2;
|
||||
|
||||
/** The total number of layers. */
|
||||
public static final int NUM_LAYERS = 3;
|
||||
|
||||
/** The latest scene file format version. */
|
||||
public static final short VERSION = 1;
|
||||
|
||||
/** String translations of each tile layer name. */
|
||||
public static final String[] XLATE_LAYERS = { "Base", "Fringe", "Object" };
|
||||
|
||||
/** Scene id to denote an unset or otherwise invalid scene id. */
|
||||
public static final int SID_INVALID = -1;
|
||||
|
||||
/** The tiles comprising the scene. */
|
||||
public Tile tiles[][][];
|
||||
|
||||
/**
|
||||
* Construct a new miso scene object. The base layer tiles are
|
||||
* initialized to contain tiles of the specified default tileset and
|
||||
@@ -57,8 +33,8 @@ public class MisoScene implements Scene
|
||||
* @param deftsid the default tileset id.
|
||||
* @param deftid the default tile id.
|
||||
*/
|
||||
public MisoScene (IsoSceneViewModel model, TileManager tilemgr,
|
||||
int deftsid, int deftid)
|
||||
public MisoSceneImpl (IsoSceneViewModel model, TileManager tilemgr,
|
||||
int deftsid, int deftid)
|
||||
{
|
||||
_model = model;
|
||||
_tilemgr = tilemgr;
|
||||
@@ -70,13 +46,13 @@ public class MisoScene implements Scene
|
||||
_clusters = new ArrayList();
|
||||
_portals = new ArrayList();
|
||||
|
||||
tiles = new Tile[_model.scenewid][_model.scenehei][NUM_LAYERS];
|
||||
_tiles = new Tile[_model.scenewid][_model.scenehei][NUM_LAYERS];
|
||||
_deftile = _tilemgr.getTile(deftsid, deftid);
|
||||
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||
for (int ii = 0; ii < NUM_LAYERS; ii++) {
|
||||
if (ii == LAYER_BASE) {
|
||||
tiles[xx][yy][ii] = _deftile;
|
||||
_tiles[xx][yy][ii] = _deftile;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +60,7 @@ public class MisoScene implements Scene
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new miso scene object with the given values.
|
||||
* Construct a new Miso scene object with the given values.
|
||||
*
|
||||
* @param model the iso scene view model.
|
||||
* @param tilemgr the tile manager.
|
||||
@@ -93,10 +69,10 @@ public class MisoScene implements Scene
|
||||
* @param portals the portals.
|
||||
* @param tiles the tiles comprising the scene.
|
||||
*/
|
||||
public MisoScene (IsoSceneViewModel model, TileManager tilemgr,
|
||||
String name, ArrayList locations,
|
||||
ArrayList clusters, ArrayList portals,
|
||||
Tile tiles[][][])
|
||||
public MisoSceneImpl (IsoSceneViewModel model, TileManager tilemgr,
|
||||
String name, ArrayList locations,
|
||||
ArrayList clusters, ArrayList portals,
|
||||
Tile[][][] tiles)
|
||||
{
|
||||
_model = model;
|
||||
_tilemgr = tilemgr;
|
||||
@@ -105,7 +81,7 @@ public class MisoScene implements Scene
|
||||
_locations = locations;
|
||||
_clusters = clusters;
|
||||
_portals = portals;
|
||||
this.tiles = tiles;
|
||||
_tiles = tiles;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -133,89 +109,60 @@ public class MisoScene implements Scene
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default tile for the base layer of the scene.
|
||||
*/
|
||||
// documentation inherited
|
||||
public Tile[][][] getTiles ()
|
||||
{
|
||||
return _tiles;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public Tile getDefaultTile ()
|
||||
{
|
||||
return _deftile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the scene locations list.
|
||||
*/
|
||||
public ArrayList getLocations ()
|
||||
// documentation inherited
|
||||
public Location[] getLocations ()
|
||||
{
|
||||
return _locations;
|
||||
Location[] locs = new Location[_locations.size()];
|
||||
_locations.toArray(locs);
|
||||
return locs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cluster list.
|
||||
*/
|
||||
public ArrayList getClusters ()
|
||||
// documentation inherited
|
||||
public Cluster[] getClusters ()
|
||||
{
|
||||
return _clusters;
|
||||
Cluster[] clusters = new Cluster[_clusters.size()];
|
||||
_clusters.toArray(clusters);
|
||||
return clusters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the scene portals list.
|
||||
*/
|
||||
public ArrayList getPortals ()
|
||||
// documentation inherited
|
||||
public Portal[] getPortals ()
|
||||
{
|
||||
return _portals;
|
||||
Portal[] portals = new Portal[_portals.size()];
|
||||
_portals.toArray(portals);
|
||||
return portals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default entrance portal for this scene.
|
||||
*
|
||||
* @param entrance the entrance portal.
|
||||
*/
|
||||
// documentation inherited
|
||||
public Portal getEntrance ()
|
||||
{
|
||||
return _entrance;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void setName (String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void setEntrance (Portal entrance)
|
||||
{
|
||||
_entrance = entrance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of clusters in the scene.
|
||||
*/
|
||||
public int getNumClusters ()
|
||||
{
|
||||
return _clusters.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of actual (non-null) tiles present in the
|
||||
* specified tile layer for this scene.
|
||||
*/
|
||||
public int getNumLayerTiles (int lnum)
|
||||
{
|
||||
if (lnum == LAYER_BASE) {
|
||||
return _model.scenewid * _model.scenehei;
|
||||
}
|
||||
|
||||
int numTiles = 0;
|
||||
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||
if (tiles[xx][yy] != null) {
|
||||
numTiles++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return numTiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cluster index number the given location is in, or -1
|
||||
* if the location is not in any cluster.
|
||||
*
|
||||
* @param loc the location.
|
||||
*/
|
||||
public int getClusterIndex (Location loc)
|
||||
{
|
||||
return ClusterUtil.getClusterIndex(_clusters, loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified location in the scene. If the cluster
|
||||
* index number is -1, the location will be removed from any
|
||||
@@ -259,28 +206,9 @@ public class MisoScene implements Scene
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the location object at the given full coordinates, or
|
||||
* null if no location is currently present at that location.
|
||||
*
|
||||
* @param x the full x-position coordinate.
|
||||
* @param y the full y-position coordinate.
|
||||
*
|
||||
* @return the location object.
|
||||
*/
|
||||
public Location getLocation (int x, int y)
|
||||
{
|
||||
int size = _locations.size();
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Location loc = (Location)_locations.get(ii);
|
||||
if (loc.x == x && loc.y == y) return loc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given location object from the location list, and
|
||||
* from any containing cluster. If the location is a portal, it
|
||||
* is removed from the portal list as well.
|
||||
* Remove the given location object from the location list, and from
|
||||
* any containing cluster. If the location is a portal, it is removed
|
||||
* from the portal list as well.
|
||||
*
|
||||
* @param loc the location object.
|
||||
*/
|
||||
@@ -301,25 +229,7 @@ public class MisoScene implements Scene
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the portal with the given name, or null if the portal
|
||||
* isn't found in the portal list.
|
||||
*
|
||||
* @param name the portal name.
|
||||
*
|
||||
* @return the portal object.
|
||||
*/
|
||||
public Portal getPortal (String name)
|
||||
{
|
||||
int size = _portals.size();
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Portal portal = (Portal)_portals.get(ii);
|
||||
if (portal.name.equals(name)) return portal;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of this Scene object.
|
||||
* Return a string representation of this Miso scene object.
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
@@ -341,6 +251,9 @@ public class MisoScene implements Scene
|
||||
/** The unique scene id. */
|
||||
protected int _sid;
|
||||
|
||||
/** The tiles comprising the scene. */
|
||||
public Tile[][][] _tiles;
|
||||
|
||||
/** The default entrance portal. */
|
||||
protected Portal _entrance;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: IsoSceneView.java,v 1.54 2001/09/13 19:10:26 mdb Exp $
|
||||
// $Id: IsoSceneView.java,v 1.55 2001/09/21 02:30:35 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -17,12 +17,13 @@ import com.threerings.media.tile.TileManager;
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.util.AStarPathUtil;
|
||||
import com.threerings.miso.scene.util.IsoUtil;
|
||||
import com.threerings.miso.scene.util.MisoSceneUtil;
|
||||
|
||||
/**
|
||||
* The <code>IsoSceneView</code> provides an isometric view of a
|
||||
* particular scene.
|
||||
*/
|
||||
public class IsoSceneView implements EditableSceneView
|
||||
public class IsoSceneView implements SceneView
|
||||
{
|
||||
/**
|
||||
* Construct an <code>IsoSceneView</code> object.
|
||||
@@ -39,10 +40,6 @@ public class IsoSceneView implements EditableSceneView
|
||||
|
||||
setModel(model);
|
||||
|
||||
// initialize the highlighted objects
|
||||
_htile = new Point(-1, -1);
|
||||
_hfull = new Point(-1, -1);
|
||||
|
||||
// get the font used to render tile coordinates
|
||||
_font = new Font("Arial", Font.PLAIN, 7);
|
||||
|
||||
@@ -65,6 +62,12 @@ public class IsoSceneView implements EditableSceneView
|
||||
clearDirtyRegions();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void setScene (MisoScene scene)
|
||||
{
|
||||
_scene = scene;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint the scene view and any highlighted tiles to the given
|
||||
* graphics context.
|
||||
@@ -73,7 +76,9 @@ public class IsoSceneView implements EditableSceneView
|
||||
*/
|
||||
public void paint (Graphics g)
|
||||
{
|
||||
if (_scene == null) return;
|
||||
if (_scene == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Graphics2D gfx = (Graphics2D)g;
|
||||
|
||||
@@ -107,13 +112,21 @@ public class IsoSceneView implements EditableSceneView
|
||||
paintLocations(gfx);
|
||||
}
|
||||
|
||||
// draw highlighted tiles and full coordinates
|
||||
paintHighlights(gfx);
|
||||
// paint any extra goodies
|
||||
paintExtras(gfx);
|
||||
|
||||
// restore the original clipping region
|
||||
gfx.setClip(oldclip);
|
||||
}
|
||||
|
||||
/**
|
||||
* A function where derived classes can paint extra stuff while we've
|
||||
* got the clipping region set up.
|
||||
*/
|
||||
protected void paintExtras (Graphics2D g)
|
||||
{
|
||||
}
|
||||
|
||||
protected void clearDirtyRegions ()
|
||||
{
|
||||
_dirtyRects.clear();
|
||||
@@ -155,6 +168,7 @@ public class IsoSceneView implements EditableSceneView
|
||||
protected void renderSceneInvalid (Graphics2D gfx)
|
||||
{
|
||||
int numDrawn = 0;
|
||||
Tile[][][] tiles = _scene.getTiles();
|
||||
|
||||
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||
@@ -169,7 +183,7 @@ public class IsoSceneView implements EditableSceneView
|
||||
for (int kk = 0; kk < MisoScene.NUM_LAYERS; kk++) {
|
||||
|
||||
// get the tile at these coordinates and layer
|
||||
Tile tile = _scene.tiles[xx][yy][kk];
|
||||
Tile tile = tiles[xx][yy][kk];
|
||||
if (tile == null) continue;
|
||||
|
||||
// offset the image y-position by the tile-specific height
|
||||
@@ -202,6 +216,7 @@ public class IsoSceneView implements EditableSceneView
|
||||
*/
|
||||
protected void renderScene (Graphics2D gfx)
|
||||
{
|
||||
Tile[][][] tiles = _scene.getTiles();
|
||||
int mx = 1;
|
||||
int my = 0;
|
||||
|
||||
@@ -222,7 +237,7 @@ public class IsoSceneView implements EditableSceneView
|
||||
|
||||
for (int kk = 0; kk < MisoScene.NUM_LAYERS; kk++) {
|
||||
// grab the tile we're rendering
|
||||
Tile tile = _scene.tiles[tx][ty][kk];
|
||||
Tile tile = tiles[tx][ty][kk];
|
||||
if (tile == null) continue;
|
||||
|
||||
// determine screen y-position, accounting for
|
||||
@@ -290,45 +305,6 @@ public class IsoSceneView implements EditableSceneView
|
||||
gfx.drawString(str, sx + cx - (fm.stringWidth(str)/2), sy + cy + fhei);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint highlights around any highlighted tiles and fine coordinates.
|
||||
*
|
||||
* @param gfx the graphics context.
|
||||
*/
|
||||
protected void paintHighlights (Graphics2D gfx)
|
||||
{
|
||||
// paint the highlighted tile
|
||||
if (_htile.x != -1 && _htile.y != -1) {
|
||||
// set the desired stroke and color
|
||||
Stroke ostroke = gfx.getStroke();
|
||||
gfx.setStroke(_hstroke);
|
||||
gfx.setColor(Color.green);
|
||||
|
||||
// draw the tile outline
|
||||
gfx.draw(_polys[_htile.x][_htile.y]);
|
||||
|
||||
// restore the original stroke
|
||||
gfx.setStroke(ostroke);
|
||||
}
|
||||
|
||||
// paint the highlighted full coordinate
|
||||
if (_hfull.x != -1 && _hfull.y != -1) {
|
||||
Point spos = new Point();
|
||||
IsoUtil.fullToScreen(_model, _hfull.x, _hfull.y, spos);
|
||||
|
||||
// set the desired stroke and color
|
||||
Stroke ostroke = gfx.getStroke();
|
||||
gfx.setStroke(_hstroke);
|
||||
|
||||
// draw a red circle at the coordinate
|
||||
gfx.setColor(Color.red);
|
||||
gfx.draw(new Ellipse2D.Float(spos.x - 1, spos.y - 1, 3, 3));
|
||||
|
||||
// restore the original stroke
|
||||
gfx.setStroke(ostroke);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paint demarcations at all locations in the scene, with each
|
||||
* location's cluster index, if any, along the right side of its
|
||||
@@ -338,8 +314,8 @@ public class IsoSceneView implements EditableSceneView
|
||||
*/
|
||||
protected void paintLocations (Graphics2D gfx)
|
||||
{
|
||||
ArrayList locations = _scene.getLocations();
|
||||
int size = locations.size();
|
||||
Location[] locations = _scene.getLocations();
|
||||
int size = locations.length;
|
||||
|
||||
// create the location triangle
|
||||
Polygon tri = new Polygon();
|
||||
@@ -350,10 +326,10 @@ public class IsoSceneView implements EditableSceneView
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
|
||||
// retrieve the location
|
||||
Location loc = (Location)locations.get(ii);
|
||||
Location loc = locations[ii];
|
||||
|
||||
// get the cluster index this location is in, if any
|
||||
int clusteridx = _scene.getClusterIndex(loc);
|
||||
int clusteridx = MisoSceneUtil.getClusterIndex(_scene, loc);
|
||||
|
||||
Point spos = new Point();
|
||||
IsoUtil.fullToScreen(_model, loc.x, loc.y, spos);
|
||||
@@ -393,26 +369,6 @@ public class IsoSceneView implements EditableSceneView
|
||||
}
|
||||
}
|
||||
|
||||
public void setHighlightedTile (int sx, int sy)
|
||||
{
|
||||
if (sx == -1 && sy == -1) {
|
||||
_htile.setLocation(-1, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
IsoUtil.screenToTile(_model, sx, sy, _htile);
|
||||
}
|
||||
|
||||
public void setHighlightedFull (int x, int y)
|
||||
{
|
||||
if (x == -1 && y == -1) {
|
||||
_hfull.setLocation(-1, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
IsoUtil.screenToFull(_model, x, y, _hfull);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate a list of rectangles in the view for later repainting.
|
||||
*
|
||||
@@ -560,27 +516,6 @@ public class IsoSceneView implements EditableSceneView
|
||||
_spritemgr.invalidateIntersectingSprites(rects, _polys[x][y]);
|
||||
}
|
||||
|
||||
public void setScene (MisoScene scene)
|
||||
{
|
||||
_scene = scene;
|
||||
}
|
||||
|
||||
public void setTile (int x, int y, int lnum, Tile tile)
|
||||
{
|
||||
Point tpos = new Point();
|
||||
IsoUtil.screenToTile(_model, x, y, tpos);
|
||||
_scene.tiles[tpos.x][tpos.y][lnum] = tile;
|
||||
}
|
||||
|
||||
public void deleteTile (int x, int y, int lnum)
|
||||
{
|
||||
Point tpos = new Point();
|
||||
IsoUtil.screenToTile(_model, x, y, tpos);
|
||||
|
||||
Tile tile = (lnum == 0) ? _scene.getDefaultTile() : null;
|
||||
_scene.tiles[tpos.x][tpos.y][lnum] = tile;
|
||||
}
|
||||
|
||||
public void setModel (IsoSceneViewModel model)
|
||||
{
|
||||
_model = model;
|
||||
@@ -608,7 +543,7 @@ public class IsoSceneView implements EditableSceneView
|
||||
// get a reasonable path from start to end
|
||||
List tilepath =
|
||||
AStarPathUtil.getPath(
|
||||
_scene.tiles, _model.scenewid, _model.scenehei,
|
||||
_scene.getTiles(), _model.scenewid, _model.scenehei,
|
||||
sprite, stpos.x, stpos.y, tbx, tby);
|
||||
if (tilepath == null) {
|
||||
return null;
|
||||
@@ -666,54 +601,6 @@ public class IsoSceneView implements EditableSceneView
|
||||
return path;
|
||||
}
|
||||
|
||||
public void updateLocation (Location loc, int clusteridx)
|
||||
{
|
||||
_scene.updateLocation(loc, clusteridx);
|
||||
}
|
||||
|
||||
public void addPortal (Portal portal)
|
||||
{
|
||||
_scene.addPortal(portal);
|
||||
}
|
||||
|
||||
public void removeLocation (Location loc)
|
||||
{
|
||||
_scene.removeLocation(loc);
|
||||
}
|
||||
|
||||
public Location createLocation (int sx, int sy)
|
||||
{
|
||||
Point fpos = new Point();
|
||||
IsoUtil.screenToFull(_model, sx, sy, fpos);
|
||||
return new Location(fpos.x, fpos.y);
|
||||
}
|
||||
|
||||
public Location getLocation (int sx, int sy)
|
||||
{
|
||||
Point fpos = new Point();
|
||||
IsoUtil.screenToFull(_model, sx, sy, fpos);
|
||||
return _scene.getLocation(fpos.x, fpos.y);
|
||||
}
|
||||
|
||||
public int getClusterIndex (Location loc)
|
||||
{
|
||||
return _scene.getClusterIndex(loc);
|
||||
}
|
||||
|
||||
public int getNumClusters ()
|
||||
{
|
||||
return (_scene == null) ? 0 : _scene.getNumClusters();
|
||||
}
|
||||
|
||||
/** The stroke object used to draw highlighted tiles and coordinates. */
|
||||
protected BasicStroke _hstroke = new BasicStroke(3);
|
||||
|
||||
/** The currently highlighted tile. */
|
||||
protected Point _htile;
|
||||
|
||||
/** The currently highlighted full coordinate. */
|
||||
protected Point _hfull;
|
||||
|
||||
/** The font to draw tile coordinates. */
|
||||
protected Font _font;
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// $Id: MisoScene.java,v 1.1 2001/09/21 02:30:35 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.whirled.data.Scene;
|
||||
|
||||
/**
|
||||
* A scene object represents the data model corresponding to a single
|
||||
* screen for game play. For instance, one scene might display a portion
|
||||
* of a street with several buildings scattered about on the periphery.
|
||||
*/
|
||||
public interface MisoScene extends Scene
|
||||
{
|
||||
/** The total number of layers. */
|
||||
public static final int NUM_LAYERS = 3;
|
||||
|
||||
/** The base layer id. */
|
||||
public static final int LAYER_BASE = 0;
|
||||
|
||||
/** The fringe layer id. */
|
||||
public static final int LAYER_FRINGE = 1;
|
||||
|
||||
/** The object layer id. */
|
||||
public static final int LAYER_OBJECT = 2;
|
||||
|
||||
/**
|
||||
* Return the tiles that comprise this scene.
|
||||
*/
|
||||
public Tile[][][] getTiles ();
|
||||
|
||||
/**
|
||||
* Return the default tile for the base layer of the scene.
|
||||
*/
|
||||
public Tile getDefaultTile ();
|
||||
|
||||
/**
|
||||
* Return the locations in this scene.
|
||||
*/
|
||||
public Location[] getLocations ();
|
||||
|
||||
/**
|
||||
* Return the clusters in this scene.
|
||||
*/
|
||||
public Cluster[] getClusters ();
|
||||
|
||||
/**
|
||||
* Return the portals associated with this scene.
|
||||
*/
|
||||
public Portal[] getPortals ();
|
||||
|
||||
/**
|
||||
* Return the portal that is the default entrance to this scene.
|
||||
*/
|
||||
public Portal getEntrance ();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneViewPanel.java,v 1.13 2001/08/29 18:41:46 shaper Exp $
|
||||
// $Id: SceneViewPanel.java,v 1.14 2001/09/21 02:30:35 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -30,13 +30,22 @@ public class SceneViewPanel
|
||||
_smodel = new IsoSceneViewModel(config);
|
||||
|
||||
// create the scene view
|
||||
_view = new IsoSceneView(tilemgr, spritemgr, _smodel);
|
||||
_view = newSceneView(tilemgr, spritemgr, _smodel);
|
||||
|
||||
// set our attributes for optimal display performance
|
||||
setDoubleBuffered(false);
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the underlying scene view implementation.
|
||||
*/
|
||||
protected IsoSceneView newSceneView (
|
||||
TileManager tmgr, SpriteManager smgr, IsoSceneViewModel model)
|
||||
{
|
||||
return new IsoSceneView(tmgr, smgr, model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scene managed by the panel.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClusterUtil.java,v 1.1 2001/08/14 21:29:40 shaper Exp $
|
||||
// $Id: ClusterUtil.java,v 1.2 2001/09/21 02:30:35 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
|
||||
@@ -22,12 +22,14 @@ public class ClusterUtil
|
||||
* @param clusters the cluster list.
|
||||
* @param loc the location.
|
||||
*/
|
||||
public static int getClusterIndex (ArrayList clusters, Location loc)
|
||||
public static int getClusterIndex (Cluster[] clusters, Location loc)
|
||||
{
|
||||
int size = clusters.size();
|
||||
int size = clusters.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Cluster cluster = (Cluster)clusters.get(ii);
|
||||
if (cluster.contains(loc)) return ii;
|
||||
Cluster cluster = clusters[ii];
|
||||
if (cluster.contains(loc)) {
|
||||
return ii;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -35,7 +37,7 @@ public class ClusterUtil
|
||||
/**
|
||||
* Remove the given location from its cluster, if any.
|
||||
*
|
||||
* @param clusters the cluster list.
|
||||
* @param clusters the cluster array.
|
||||
* @param loc the location.
|
||||
*/
|
||||
public static void remove (ArrayList clusters, Location loc)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// $Id: MisoSceneUtil.java,v 1.1 2001/09/21 02:30:35 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
|
||||
import com.threerings.miso.scene.*;
|
||||
|
||||
/**
|
||||
* Miso scene related utility functions and information.
|
||||
*/
|
||||
public class MisoSceneUtil
|
||||
{
|
||||
/** String translations of each tile layer name. */
|
||||
public static final String[] XLATE_LAYERS = { "Base", "Fringe", "Object" };
|
||||
|
||||
/**
|
||||
* Return the location object at the given full coordinates, or null
|
||||
* if no location is currently present at that location.
|
||||
*
|
||||
* @param scene the scene whose locations should be searched.
|
||||
* @param x the full x-position coordinate.
|
||||
* @param y the full y-position coordinate.
|
||||
*
|
||||
* @return the location object.
|
||||
*/
|
||||
public static Location getLocation (MisoScene scene, int x, int y)
|
||||
{
|
||||
Location[] locs = scene.getLocations();
|
||||
int size = locs.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Location loc = locs[ii];
|
||||
if (loc.x == x && loc.y == y) {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the portal with the given name, or null if the portal isn't
|
||||
* found in the portal list.
|
||||
*
|
||||
* @param scene the scene whose portals should be searched.
|
||||
* @param name the portal name.
|
||||
*
|
||||
* @return the portal object.
|
||||
*/
|
||||
public static Portal getPortal (MisoScene scene, String name)
|
||||
{
|
||||
Portal[] portals = scene.getPortals();
|
||||
int size = portals.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Portal portal = portals[ii];
|
||||
if (portal.name.equals(name)) {
|
||||
return portal;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cluster index number the given location is in, or -1
|
||||
* if the location is not in any cluster.
|
||||
*
|
||||
* @param scene the containing scene.
|
||||
* @param loc the location.
|
||||
*
|
||||
* @return the cluster index or -1 if the location is not in any
|
||||
* cluster.
|
||||
*/
|
||||
public static int getClusterIndex (MisoScene scene, Location loc)
|
||||
{
|
||||
return ClusterUtil.getClusterIndex(scene.getClusters(), loc);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user