Added support for creating and editing exits.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@229 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.24 2001/08/11 00:00:13 shaper Exp $
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.25 2001/08/13 05:42:36 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -125,25 +125,38 @@ public class Scene
|
||||
*/
|
||||
public void updateLocation (Location loc, int clusteridx)
|
||||
{
|
||||
// look the location up in our existing location list
|
||||
int size = _locations.size();
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Location tloc = (Location)_locations.get(ii);
|
||||
|
||||
if (tloc == loc) {
|
||||
// if we found it, just update the cluster contents
|
||||
ClusterUtil.regroup(_clusters, tloc, clusteridx);
|
||||
return;
|
||||
}
|
||||
// add the location if it's not already present
|
||||
if (!_locations.contains(loc)) {
|
||||
_locations.add(loc);
|
||||
}
|
||||
|
||||
// else we didn't find it, so hold on to the sucker
|
||||
_locations.add(loc);
|
||||
|
||||
// and update the cluster contents
|
||||
// update the cluster contents
|
||||
ClusterUtil.regroup(_clusters, loc, clusteridx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified exit to the scene. Adds the exit 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.
|
||||
*/
|
||||
public void addExit (Exit exit)
|
||||
{
|
||||
// make sure it's in the location list and absent from any cluster
|
||||
updateLocation(exit, -1);
|
||||
|
||||
// don't allow adding an exit more than once
|
||||
if (_exits.contains(exit)) {
|
||||
Log.warning("Attempt to add already-existing exit " +
|
||||
"[exit=" + exit + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
// add it to the list
|
||||
_exits.add(exit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the location object at the given full coordinates, or
|
||||
* null if no location is currently present.
|
||||
@@ -163,6 +176,29 @@ public class Scene
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param loc the location object.
|
||||
*/
|
||||
public void removeLocation (Location loc)
|
||||
{
|
||||
// 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
|
||||
return;
|
||||
}
|
||||
|
||||
// remove from any possible cluster
|
||||
ClusterUtil.remove(_clusters, loc);
|
||||
|
||||
// remove from any possible existence on the exit list
|
||||
_exits.remove(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the scene name.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: IsoSceneView.java,v 1.40 2001/08/11 00:00:13 shaper Exp $
|
||||
// $Id: IsoSceneView.java,v 1.41 2001/08/13 05:42:36 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -346,7 +346,8 @@ public class IsoSceneView implements EditableSceneView
|
||||
gfx.rotate(rot);
|
||||
|
||||
// draw the triangle
|
||||
gfx.setColor(Color.yellow);
|
||||
Color fcol = (loc instanceof Exit) ? Color.green : Color.yellow;
|
||||
gfx.setColor(fcol);
|
||||
gfx.fill(tri);
|
||||
|
||||
// outline the triangle in black
|
||||
@@ -559,6 +560,16 @@ public class IsoSceneView implements EditableSceneView
|
||||
_scene.updateLocation(loc, clusteridx);
|
||||
}
|
||||
|
||||
public void addExit (Exit exit)
|
||||
{
|
||||
_scene.addExit(exit);
|
||||
}
|
||||
|
||||
public void removeLocation (Location loc)
|
||||
{
|
||||
_scene.removeLocation(loc);
|
||||
}
|
||||
|
||||
public Location createLocation (int sx, int sy)
|
||||
{
|
||||
Point fpos = new Point();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: XMLSceneParser.java,v 1.8 2001/08/10 01:31:25 shaper Exp $
|
||||
// $Id: XMLSceneParser.java,v 1.9 2001/08/13 05:42:36 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene.xml;
|
||||
|
||||
@@ -236,15 +236,20 @@ public class XMLSceneParser extends DefaultHandler
|
||||
// make sure we have an appropriate number of values
|
||||
if ((vals.length % 2) != 0) return null;
|
||||
|
||||
// read in all of the exits and add to the list
|
||||
ArrayList list = new ArrayList();
|
||||
// read in all of the exits
|
||||
ArrayList exits = new ArrayList();
|
||||
for (int ii = 0; ii < vals.length; ii += 2) {
|
||||
Exit exit = new Exit(
|
||||
(Location)locs.get(getInt(vals[ii])), vals[ii+1]);
|
||||
list.add(exit);
|
||||
int locidx = getInt(vals[ii]);
|
||||
|
||||
// create the exit and add to the list
|
||||
Exit exit = new Exit((Location)locs.get(locidx), vals[ii+1]);
|
||||
exits.add(exit);
|
||||
|
||||
// upgrade the corresponding location in the location list
|
||||
locs.set(locidx, exit);
|
||||
}
|
||||
|
||||
return list;
|
||||
return exits;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user