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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -125,25 +125,38 @@ public class Scene
|
|||||||
*/
|
*/
|
||||||
public void updateLocation (Location loc, int clusteridx)
|
public void updateLocation (Location loc, int clusteridx)
|
||||||
{
|
{
|
||||||
// look the location up in our existing location list
|
// add the location if it's not already present
|
||||||
int size = _locations.size();
|
if (!_locations.contains(loc)) {
|
||||||
for (int ii = 0; ii < size; ii++) {
|
_locations.add(loc);
|
||||||
Location tloc = (Location)_locations.get(ii);
|
|
||||||
|
|
||||||
if (tloc == loc) {
|
|
||||||
// if we found it, just update the cluster contents
|
|
||||||
ClusterUtil.regroup(_clusters, tloc, clusteridx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// else we didn't find it, so hold on to the sucker
|
// update the cluster contents
|
||||||
_locations.add(loc);
|
|
||||||
|
|
||||||
// and update the cluster contents
|
|
||||||
ClusterUtil.regroup(_clusters, loc, clusteridx);
|
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
|
* Return the location object at the given full coordinates, or
|
||||||
* null if no location is currently present.
|
* null if no location is currently present.
|
||||||
@@ -163,6 +176,29 @@ public class Scene
|
|||||||
return null;
|
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.
|
* 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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -346,7 +346,8 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
gfx.rotate(rot);
|
gfx.rotate(rot);
|
||||||
|
|
||||||
// draw the triangle
|
// draw the triangle
|
||||||
gfx.setColor(Color.yellow);
|
Color fcol = (loc instanceof Exit) ? Color.green : Color.yellow;
|
||||||
|
gfx.setColor(fcol);
|
||||||
gfx.fill(tri);
|
gfx.fill(tri);
|
||||||
|
|
||||||
// outline the triangle in black
|
// outline the triangle in black
|
||||||
@@ -559,6 +560,16 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
_scene.updateLocation(loc, clusteridx);
|
_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)
|
public Location createLocation (int sx, int sy)
|
||||||
{
|
{
|
||||||
Point fpos = new Point();
|
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;
|
package com.threerings.miso.scene.xml;
|
||||||
|
|
||||||
@@ -236,15 +236,20 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
// make sure we have an appropriate number of values
|
// make sure we have an appropriate number of values
|
||||||
if ((vals.length % 2) != 0) return null;
|
if ((vals.length % 2) != 0) return null;
|
||||||
|
|
||||||
// read in all of the exits and add to the list
|
// read in all of the exits
|
||||||
ArrayList list = new ArrayList();
|
ArrayList exits = new ArrayList();
|
||||||
for (int ii = 0; ii < vals.length; ii += 2) {
|
for (int ii = 0; ii < vals.length; ii += 2) {
|
||||||
Exit exit = new Exit(
|
int locidx = getInt(vals[ii]);
|
||||||
(Location)locs.get(getInt(vals[ii])), vals[ii+1]);
|
|
||||||
list.add(exit);
|
// 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