Changed exit to portal. Limit tile bounds to something reasonable

when invalidating the scene view.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@270 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-08-16 18:05:17 +00:00
parent 2f7f106271
commit a99829818f
11 changed files with 149 additions and 128 deletions
@@ -1,5 +1,5 @@
//
// $Id: DisplayMisoSceneImpl.java,v 1.29 2001/08/15 01:10:09 mdb Exp $
// $Id: DisplayMisoSceneImpl.java,v 1.30 2001/08/16 18:05:16 shaper Exp $
package com.threerings.miso.scene;
@@ -71,7 +71,7 @@ public class MisoScene implements Scene
_locations = new ArrayList();
_clusters = new ArrayList();
_exits = new ArrayList();
_portals = new ArrayList();
tiles = new Tile[TILE_WIDTH][TILE_HEIGHT][NUM_LAYERS];
_deftile = _tilemgr.getTile(deftsid, deftid);
@@ -92,19 +92,19 @@ public class MisoScene implements Scene
* @param tilemgr the tile manager.
* @param name the scene name.
* @param locations the locations.
* @param exits the exits.
* @param portals the portals.
* @param tiles the tiles comprising the scene.
*/
public MisoScene (
TileManager tilemgr, String name, ArrayList locations,
ArrayList clusters, ArrayList exits, Tile tiles[][][])
ArrayList clusters, ArrayList portals, Tile tiles[][][])
{
_tilemgr = tilemgr;
_sid = SID_INVALID;
_name = name;
_locations = locations;
_clusters = clusters;
_exits = exits;
_portals = portals;
this.tiles = tiles;
}
@@ -139,26 +139,26 @@ public class MisoScene implements Scene
}
/**
* Add the specified exit to the scene. Adds the exit to the
* Add the specified portal to the scene. Adds the portal to the
* location list as well if it's not already present and removes
* it from any cluster it may reside in.
*
* @param exit the exit.
* @param portal the portal.
*/
public void addExit (Exit exit)
public void addPortal (Portal portal)
{
// make sure it's in the location list and absent from any cluster
updateLocation(exit, -1);
updateLocation(portal, -1);
// don't allow adding an exit more than once
if (_exits.contains(exit)) {
Log.warning("Attempt to add already-existing exit " +
"[exit=" + exit + "].");
// don't allow adding an portal more than once
if (_portals.contains(portal)) {
Log.warning("Attempt to add already-existing portal " +
"[portal=" + portal + "].");
return;
}
// add it to the list
_exits.add(exit);
_portals.add(portal);
}
/**
@@ -182,8 +182,8 @@ public class MisoScene implements Scene
/**
* Remove the given location object from the location list, and
* from any containing cluster. If the location is an exit, it
* is removed from the exit list as well.
* from any containing cluster. If the location is an portal, it
* is removed from the portal list as well.
*
* @param loc the location object.
*/
@@ -192,15 +192,15 @@ public class MisoScene implements Scene
// remove from the location list
if (!_locations.remove(loc)) {
// we didn't know about it, so it can't be in a cluster or
// the exit list
// the portal list
return;
}
// remove from any possible cluster
ClusterUtil.remove(_clusters, loc);
// remove from any possible existence on the exit list
_exits.remove(loc);
// remove from any possible existence on the portal list
_portals.remove(loc);
}
/**
@@ -230,9 +230,9 @@ public class MisoScene implements Scene
}
/**
* Returns the scene ids of the exits from this scene.
* Returns the scene ids of the portals from this scene.
*/
public int[] getExitIds ()
public int[] getPortalIds ()
{
return null;
}
@@ -254,11 +254,11 @@ public class MisoScene implements Scene
}
/**
* Return the scene exits list.
* Return the scene portals list.
*/
public ArrayList getExits ()
public ArrayList getPortals ()
{
return _exits;
return _portals;
}
/**
@@ -306,7 +306,7 @@ public class MisoScene implements Scene
buf.append(", sid=").append(_sid);
buf.append(", locations=").append(StringUtil.toString(_locations));
buf.append(", clusters=").append(StringUtil.toString(_clusters));
buf.append(", exits=").append(StringUtil.toString(_exits));
buf.append(", portals=").append(StringUtil.toString(_portals));
return buf.append("]").toString();
}
@@ -325,8 +325,8 @@ public class MisoScene implements Scene
/** The clusters within the scene. */
protected ArrayList _clusters;
/** The exits to different scenes. */
protected ArrayList _exits;
/** The portals to different scenes. */
protected ArrayList _portals;
/** The default tile for the base layer in the scene. */
protected Tile _deftile;
@@ -1,35 +0,0 @@
//
// $Id: Exit.java,v 1.2 2001/08/11 00:00:13 shaper Exp $
package com.threerings.miso.scene;
/**
* The <code>Exit</code> class represents a <code>Location</code> in a
* scene that leads to a different scene.
*/
public class Exit extends Location
{
/** The scene name this exit transitions to. */
public String name;
/**
* Construct an <code>Exit</code> object.
*
* @param loc the location associated with the exit.
* @param name the scene name this exit leads to.
*/
public Exit (Location loc, String name)
{
super(loc.x, loc.y, loc.orient);
this.name = name;
}
/**
* Return a String representation of this object.
*/
protected void toString (StringBuffer buf)
{
super.toString(buf);
buf.append(", name=").append(name);
}
}
@@ -1,5 +1,5 @@
//
// $Id: IsoSceneView.java,v 1.48 2001/08/15 22:16:43 shaper Exp $
// $Id: IsoSceneView.java,v 1.49 2001/08/16 18:05:16 shaper Exp $
package com.threerings.miso.scene;
@@ -359,7 +359,7 @@ public class IsoSceneView implements EditableSceneView
gfx.rotate(rot);
// draw the triangle
Color fcol = (loc instanceof Exit) ? Color.green : Color.yellow;
Color fcol = (loc instanceof Portal) ? Color.green : Color.yellow;
gfx.setColor(fcol);
gfx.fill(tri);
@@ -460,8 +460,7 @@ public class IsoSceneView implements EditableSceneView
if (y < (screenY + _model.tilehhei)) {
ty--;
for (int ii = 0; ii < numh; ii++) {
if (!_dirty[tx][ty]) _numDirty++;
_dirty[tx++][ty--] = true;
addDirtyTile(tx++, ty--);
}
}
@@ -500,8 +499,7 @@ public class IsoSceneView implements EditableSceneView
// add all tiles in the row to the dirty set
for (int jj = 0; jj < length; jj++) {
if (!_dirty[tx][ty]) _numDirty++;
_dirty[tx++][ty--] = true;
addDirtyTile(tx++, ty--);
}
// step along the x- or y-axis appropriately
@@ -519,6 +517,30 @@ public class IsoSceneView implements EditableSceneView
}
}
protected void addDirtyTile (int x, int y)
{
// constrain x-coordinate to a valid range
if (x < 0) {
x = 0;
} else if (x >= MisoScene.TILE_WIDTH) {
x = MisoScene.TILE_WIDTH - 1;
}
// constrain y-coordinate to a valid range
if (y < 0) {
y = 0;
} else if (y >= MisoScene.TILE_HEIGHT) {
y = MisoScene.TILE_HEIGHT - 1;
}
// do nothing if the tile's already dirty
if (_dirty[x][y]) return;
// mark the tile dirty
_numDirty++;
_dirty[x][y] = true;
}
public void setScene (MisoScene scene)
{
_scene = scene;
@@ -629,9 +651,9 @@ public class IsoSceneView implements EditableSceneView
_scene.updateLocation(loc, clusteridx);
}
public void addExit (Exit exit)
public void addPortal (Portal portal)
{
_scene.addExit(exit);
_scene.addPortal(portal);
}
public void removeLocation (Location loc)
@@ -0,0 +1,36 @@
//
// $Id: Portal.java,v 1.1 2001/08/16 18:05:17 shaper Exp $
package com.threerings.miso.scene;
/**
* The <code>Portal</code> class represents a <code>Location</code> in
* a scene that both leads to a different scene and serves as a
* potential entrance into its containing scene.
*/
public class Portal extends Location
{
/** The portal name used for binding the portal to another scene. */
public String name;
/**
* Construct an <code>Portal</code> object.
*
* @param loc the location associated with the portal.
* @param name the portal name.
*/
public Portal (Location loc, String name)
{
super(loc.x, loc.y, loc.orient);
this.name = name;
}
/**
* Return a String representation of this object.
*/
protected void toString (StringBuffer buf)
{
super.toString(buf);
buf.append(", name=").append(name);
}
}