diff --git a/src/java/com/threerings/media/util/LineSegmentPath.java b/src/java/com/threerings/media/util/LineSegmentPath.java
index e88ee8989..ba806aabb 100644
--- a/src/java/com/threerings/media/util/LineSegmentPath.java
+++ b/src/java/com/threerings/media/util/LineSegmentPath.java
@@ -1,5 +1,5 @@
//
-// $Id: LineSegmentPath.java,v 1.4 2001/08/03 22:23:47 shaper Exp $
+// $Id: LineSegmentPath.java,v 1.5 2001/08/09 21:17:06 shaper Exp $
package com.threerings.miso.sprite;
@@ -29,6 +29,12 @@ public class Path
public static final int DIR_SOUTHEAST = 6;
public static final int DIR_SOUTH = 7;
+ /** String translations for the direction constants. */
+ public static String[] XLATE_DIRS = {
+ "Southwest", "West", "Northwest", "North", "Northeast",
+ "East", "Southeast", "South"
+ };
+
/**
* Construct a Path object.
*/
diff --git a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java
index ac17f595e..a79b5a7a2 100644
--- a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java
+++ b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java
@@ -1,10 +1,11 @@
//
-// $Id: DisplayMisoSceneImpl.java,v 1.18 2001/08/09 05:44:07 shaper Exp $
+// $Id: DisplayMisoSceneImpl.java,v 1.19 2001/08/09 21:17:06 shaper Exp $
package com.threerings.miso.scene;
import java.awt.Point;
import java.io.*;
+import java.util.ArrayList;
import com.samskivert.util.StringUtil;
import com.threerings.miso.tile.Tile;
@@ -63,8 +64,8 @@ public class Scene
_sid = SID_INVALID;
_name = DEF_SCENE_NAME;
- _hotspots = new Point[0];
- _exits = new ExitPoint[0];
+ _locations = new ArrayList();
+ _exits = new ArrayList();
tiles = new Tile[TILE_WIDTH][TILE_HEIGHT][NUM_LAYERS];
_deftile = _tilemgr.getTile(deftsid, deftid);
@@ -80,23 +81,22 @@ public class Scene
}
/**
- * Construct a new Scene object with the given values, specifying
- * the tile manager from which the scene obtains tiles.
+ * Construct a new Scene object with the given values.
*
* @param tilemgr the tile manager.
* @param name the scene name.
- * @param hotspots the hotspot points.
- * @param exits the exit points.
+ * @param locations the locations.
+ * @param exits the exits.
* @param tiles the tiles comprising the scene.
*/
public Scene (TileManager tilemgr, String name,
- Point hotspots[], ExitPoint exits[],
+ ArrayList locations, ArrayList exits,
Tile tiles[][][])
{
_tilemgr = tilemgr;
_sid = SID_INVALID;
_name = name;
- _hotspots = hotspots;
+ _locations = locations;
_exits = exits;
this.tiles = tiles;
}
@@ -118,17 +118,17 @@ public class Scene
}
/**
- * Return the scene hot spots array.
+ * Return the scene locations list.
*/
- public Point[] getHotSpots ()
+ public ArrayList getLocations ()
{
- return _hotspots;
+ return _locations;
}
/**
- * Return the scene exits array.
+ * Return the scene exits list.
*/
- public ExitPoint[] getExitPoints ()
+ public ArrayList getExits ()
{
return _exits;
}
@@ -168,7 +168,7 @@ public class Scene
StringBuffer buf = new StringBuffer();
buf.append("[name=").append(_name);
buf.append(", sid=").append(_sid);
- buf.append(", hotspots=").append(StringUtil.toString(_hotspots));
+ buf.append(", locations=").append(StringUtil.toString(_locations));
buf.append(", exits=").append(StringUtil.toString(_exits));
return buf.append("]").toString();
}
@@ -182,11 +182,11 @@ public class Scene
/** The unique scene id. */
protected short _sid;
- /** The hot-spot zone points. */
- protected Point _hotspots[];
+ /** The locations within the scene. */
+ protected ArrayList _locations;
/** The exit points to different scenes. */
- protected ExitPoint _exits[];
+ protected ArrayList _exits;
/** The default tile for the base layer in the scene. */
protected Tile _deftile;
diff --git a/src/java/com/threerings/miso/client/Exit.java b/src/java/com/threerings/miso/client/Exit.java
new file mode 100644
index 000000000..5565aa956
--- /dev/null
+++ b/src/java/com/threerings/miso/client/Exit.java
@@ -0,0 +1,42 @@
+//
+// $Id: Exit.java,v 1.1 2001/08/09 21:17:06 shaper Exp $
+
+package com.threerings.miso.scene;
+
+/**
+ * The Exit class represents a Location in a
+ * scene that leads to a different scene.
+ *
+ * @see Location
+ */
+public class Exit
+{
+ /** The location this exit is associated with. */
+ public Location loc;
+
+ /** The scene name this exit transitions to. */
+ public String name;
+
+ /**
+ * Construct an Exit object.
+ *
+ * @param loc the location associated with the exit.
+ * @param name the scene name this exit leads to.
+ */
+ public Exit (Location loc, String name)
+ {
+ this.loc = loc;
+ this.name = name;
+ }
+
+ /**
+ * Return a String representation of this object.
+ */
+ public String toString ()
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append("[loc=").append(loc);
+ buf.append(", name=").append(name);
+ return buf.append("]").toString();
+ }
+}
diff --git a/src/java/com/threerings/miso/client/ExitPoint.java b/src/java/com/threerings/miso/client/ExitPoint.java
deleted file mode 100644
index fab9bf3c5..000000000
--- a/src/java/com/threerings/miso/client/ExitPoint.java
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// $Id: ExitPoint.java,v 1.5 2001/07/24 22:52:02 shaper Exp $
-
-package com.threerings.miso.scene;
-
-/**
- * The ExitPoint class represents a point in a scene that leads to a
- * different scene.
- */
-public class ExitPoint
-{
- /** Coordinates for this exit point. */
- public byte x, y;
-
- /** The scene name this exit transitions to. */
- public String name;
-
- /** The scene id this exit transitions to. */
- public short sid;
-
- /**
- * Return a String representation of this ExitPoint object.
- */
- public String toString ()
- {
- StringBuffer buf = new StringBuffer();
- buf.append("[x=").append(x);
- buf.append(", y=").append(y);
- buf.append(", name=").append(name);
- buf.append(", sid=").append(sid);
- return buf.append("]").toString();
- }
-}
diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java
index 793d6b165..e09eb1430 100644
--- a/src/java/com/threerings/miso/client/IsoSceneView.java
+++ b/src/java/com/threerings/miso/client/IsoSceneView.java
@@ -1,5 +1,5 @@
//
-// $Id: IsoSceneView.java,v 1.34 2001/08/09 17:04:56 shaper Exp $
+// $Id: IsoSceneView.java,v 1.35 2001/08/09 21:17:06 shaper Exp $
package com.threerings.miso.scene;
@@ -322,6 +322,11 @@ public class IsoSceneView implements EditableSceneView
IsoUtil.screenToFull(_model, x, y, _hfull);
}
+ public void getFullCoordinates (int sx, int sy, Point fpos)
+ {
+ IsoUtil.screenToFull(_model, sx, sy, fpos);
+ }
+
/**
* Invalidate a list of rectangles in the view for later repainting.
*
diff --git a/src/java/com/threerings/miso/client/Location.java b/src/java/com/threerings/miso/client/Location.java
new file mode 100644
index 000000000..76282c39d
--- /dev/null
+++ b/src/java/com/threerings/miso/client/Location.java
@@ -0,0 +1,53 @@
+//
+// $Id: Location.java,v 1.1 2001/08/09 21:17:06 shaper Exp $
+
+package com.threerings.miso.scene;
+
+/**
+ * The Location class represents a unique well-defined
+ * location within the scene at the lowest level of granularity
+ * available within the scene coordinate system. Locations reside at
+ * a full coordinate (comprised of tile coordinates and fine
+ * coordinates within the tile), and only one location may reside at
+ * each full coordinate in the scene.
+ */
+public class Location
+{
+ /** The spot index in the scene containing this location. */
+ public int spotid;
+
+ /** The location position in full coordinates. */
+ public int x, y;
+
+ /** The location orientation. */
+ public int orient;
+
+ /**
+ * Construct a Location object.
+ *
+ * @param spotid the spot id.
+ * @param x the x-position full coordinate.
+ * @param y the y-position full coordinate.
+ * @param orient the location orientation.
+ */
+ public Location (int spotid, int x, int y, int orient)
+ {
+ this.spotid = spotid;
+ this.x = x;
+ this.y = y;
+ this.orient = orient;
+ }
+
+ /**
+ * Return a String representation of this object.
+ */
+ public String toString ()
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append("[spotid=").append(spotid);
+ buf.append(", x=").append(x);
+ buf.append(", y=").append(y);
+ buf.append(", orient=").append(orient);
+ return buf.append("]").toString();
+ }
+}
diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneParser.java b/src/java/com/threerings/miso/tools/xml/XMLSceneParser.java
index 28f66f274..596066f74 100644
--- a/src/java/com/threerings/miso/tools/xml/XMLSceneParser.java
+++ b/src/java/com/threerings/miso/tools/xml/XMLSceneParser.java
@@ -1,5 +1,5 @@
//
-// $Id: XMLSceneParser.java,v 1.5 2001/08/02 01:19:47 shaper Exp $
+// $Id: XMLSceneParser.java,v 1.6 2001/08/09 21:17:06 shaper Exp $
package com.threerings.miso.scene.xml;
@@ -66,13 +66,13 @@ public class XMLSceneParser extends DefaultHandler
", known_version=" + Scene.VERSION + "].");
}
- } else if (qName.equals("hotspots")) {
+ } else if (qName.equals("locations")) {
int vals[] = StringUtil.parseIntArray(_chars.toString());
- _scHotspots = toPointArray(vals);
+ _scLocations = toLocationsList(vals);
} else if (qName.equals("exits")) {
String vals[] = StringUtil.parseStringArray(_chars.toString());
- _scExits = toExitPointArray(vals);
+ _scExits = toExitList(_scLocations, vals);
} else if (qName.equals("row")) {
if (_scLnum == Scene.LAYER_BASE) {
@@ -84,7 +84,7 @@ public class XMLSceneParser extends DefaultHandler
} else if (qName.equals("scene")) {
// construct the scene object on tag close
_scene = new Scene(
- _tilemgr, _scName, _scHotspots, _scExits, _scTiles);
+ _tilemgr, _scName, _scLocations, _scExits, _scTiles);
Log.info("Constructed parsed scene [scene=" + _scene + "].");
}
@@ -164,33 +164,37 @@ public class XMLSceneParser extends DefaultHandler
}
/**
- * Given an array of integer values, return a Point array
- * constructed from each successive tuple of values as (x, y) in
- * the array.
+ * Given an array of integer values, return a list of the
+ * Location objects represented therein, constructed
+ * from each successive quartet of values as (spotid, x, y,
+ * orientation) in the integer array.
*
* @param vals the integer values.
*
- * @return the point array, or null if an error occurred.
+ * @return the location list, or null if an error occurred.
*/
- protected Point[] toPointArray (int[] vals)
+ protected ArrayList toLocationsList (int[] vals)
{
- // make sure we have an even number of points
- if ((vals.length % 2) == 1) return null;
+ // make sure we have a seemingly-appropriate number of points
+ if ((vals.length % 4) != 0) return null;
- // pull the point coordinates out of the int array
- Point[] points = new Point[vals.length / 2];
- for (int ii = 0; ii < vals.length; ii += 2) {
- int idx = ii / 2;
- points[idx] = new Point(vals[ii], vals[ii + 1]);
+ // read in all of the locations and add to the list
+ ArrayList list = new ArrayList();
+ for (int ii = 0; ii < vals.length; ii += 4) {
+ Location loc = new Location(
+ vals[ii], vals[ii+1], vals[ii+2], vals[ii+3]);
+ list.add(loc);
}
- return points;
+ return list;
}
/**
- * Given an array of String values, return an ExitPoint array
- * constructed from each successive triplet of values as (x, y,
- * scene name) in the array.
+ * Given an array of string values, return a list of
+ * Exit objects constructed from each successive
+ * triplet of values as (locidx, scene name) in the array. The
+ * list of Location objects must have already been
+ * fully read previously.
*
*
This is something of a hack since we perhaps ought to parse
* the original String into its constituent components ourselves,
@@ -198,29 +202,25 @@ public class XMLSceneParser extends DefaultHandler
* StringUtil.toString() method to take care of
* tokenizing things for us, so, there you have it.
*
+ * @param ArrayList the location list.
* @param vals the String values.
*
- * @return the ExitPoint array, or null if an error occurred.
+ * @return the exit list, or null if an error occurred.
*/
- protected ExitPoint[] toExitPointArray (String[] vals)
+ protected ArrayList toExitList (ArrayList locs, String[] vals)
{
// make sure we have an appropriate number of values
- if ((vals.length % 3) != 0) return null;
+ if ((vals.length % 2) != 0) return null;
- // pull the point values out of the string array
- ExitPoint[] exits = new ExitPoint[vals.length / 3];
- for (int ii = 0; ii < vals.length; ii += 3) {
- int idx = ii / 3;
- exits[idx] = new ExitPoint();
- exits[idx].x = (byte)getInt(vals[ii]);
- exits[idx].y = (byte)getInt(vals[ii + 1]);
- exits[idx].name = vals[ii + 2];
+ // read in all of the exits and add to the list
+ ArrayList list = 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);
+ }
- // scene id is only valid at runtime
- exits[idx].sid = Scene.SID_INVALID;
- }
-
- return exits;
+ return list;
}
/**
@@ -237,6 +237,16 @@ public class XMLSceneParser extends DefaultHandler
}
}
+ protected void init ()
+ {
+ _chars = new StringBuffer();
+ _scene = null;
+ int width = Scene.TILE_WIDTH, height = Scene.TILE_HEIGHT;
+ _scTiles = new Tile[width][height][Scene.NUM_LAYERS];
+ _scLocations = null;
+ _scExits = null;
+ }
+
/**
* Parse the specified XML file and return a Scene object with the
* data contained therein.
@@ -255,10 +265,7 @@ public class XMLSceneParser extends DefaultHandler
BufferedInputStream bis = new BufferedInputStream(fis);
// prepare temporary data storage for parsing
- _chars = new StringBuffer();
- _scene = null;
- int width = Scene.TILE_WIDTH, height = Scene.TILE_HEIGHT;
- _scTiles = new Tile[width][height][Scene.NUM_LAYERS];
+ init();
// read the XML input stream and construct the scene object
XMLUtil.parse(this, bis);
@@ -289,8 +296,8 @@ public class XMLSceneParser extends DefaultHandler
// temporary storage of scene object values and data
protected StringBuffer _chars;
protected String _scName;
- protected Point[] _scHotspots;
- protected ExitPoint[] _scExits;
+ protected ArrayList _scLocations;
+ protected ArrayList _scExits;
protected Tile[][][] _scTiles;
protected int _scLnum, _scRownum, _scColstart;
}
diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java b/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java
index ab6d3f2d0..0f6e127ad 100644
--- a/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java
+++ b/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java
@@ -1,5 +1,5 @@
//
-// $Id: XMLSceneWriter.java,v 1.3 2001/07/24 20:12:18 shaper Exp $
+// $Id: XMLSceneWriter.java,v 1.4 2001/08/09 21:17:06 shaper Exp $
package com.threerings.miso.scene.xml;
@@ -13,12 +13,12 @@ import org.xml.sax.helpers.AttributesImpl;
import com.megginson.sax.DataWriter;
import com.threerings.miso.Log;
-import com.threerings.miso.scene.ExitPoint;
-import com.threerings.miso.scene.Scene;
+import com.threerings.miso.scene.*;
import com.threerings.miso.tile.Tile;
/**
- * The XMLSceneWriter writes a Scene object to an XML file.
+ * The XMLSceneWriter writes a Scene object
+ * to an XML file.
*
*
The scene id is omitted as the scene id is assigned when the
* scene template is actually loaded into a server. Similarly, exit
@@ -51,7 +51,7 @@ public class XMLSceneWriter extends DataWriter
dataElement("name", scene.getName());
dataElement("version", "" + Scene.VERSION);
- dataElement("hotspots", getHotSpotData(scene));
+ dataElement("locations", getLocationData(scene));
dataElement("exits", getExitData(scene));
startElement("tiles");
@@ -97,47 +97,51 @@ public class XMLSceneWriter extends DataWriter
}
/**
- * Return a string representation of the exit points in the
- * scene. Each exit point is specified by a comma-delimited
- * triplet of (x, y, scene name) values.
+ * Return a string representation of the exits in the scene. Each
+ * exit is specified by a comma-delimited tuple of (location
+ * index, scene name) values.
*
* @param scene the scene object.
*
- * @return the exit points in String format.
+ * @return the exits in String format.
*/
protected String getExitData (Scene scene)
{
- ExitPoint[] exits = scene.getExitPoints();
+ ArrayList locs = scene.getLocations();
+ ArrayList exits = scene.getExits();
- Object exitinfo[] = new Object[exits.length * 3];
StringBuffer buf = new StringBuffer();
- for (int ii = 0; ii < exits.length; ii++) {
- int idx = ii * 3;
- buf.append(exits[ii].x).append(",");
- buf.append(exits[ii].y).append(",");
- buf.append(exits[ii].name);
- if (ii < exits.length - 1) buf.append(",");
+ int size = exits.size();
+ for (int ii = 0; ii < size; ii++) {
+ Exit exit = (Exit)exits.get(ii);
+ buf.append(locs.indexOf(exit.loc)).append(",");
+ buf.append(exit.name);
+ if (ii < size - 1) buf.append(",");
}
return buf.toString();
}
/**
- * Return a string representation of the hotspot points in the
- * scene. Each hotspot point is specified by a comma-delimited
- * tuple of (x, y) values.
+ * Return a string representation of the locations in the scene.
+ * Each location is specified by a comma-delimited quartet of
+ * (spot id, x, y, orientation) values.
*
- * @return the hotspot points in String format.
+ * @return the locations in String format.
*/
- protected String getHotSpotData (Scene scene)
+ protected String getLocationData (Scene scene)
{
- StringBuffer buf = new StringBuffer();
+ ArrayList locs = scene.getLocations();
- Point[] hotspots = scene.getHotSpots();
- for (int ii = 0; ii < hotspots.length; ii++) {
- buf.append(hotspots[ii].x).append(",");
- buf.append(hotspots[ii].y);
- if (ii < hotspots.length - 1) buf.append(",");
+ StringBuffer buf = new StringBuffer();
+ int size = locs.size();
+ for (int ii = 0; ii < size; ii++) {
+ Location loc = (Location)locs.get(ii);
+ buf.append(loc.spotid).append(",");
+ buf.append(loc.x).append(",");
+ buf.append(loc.y).append(",");
+ buf.append(loc.orient);
+ if (ii < size - 1) buf.append(",");
}
return buf.toString();
diff --git a/tests/rsrc/scenes/default.xml b/tests/rsrc/scenes/default.xml
index bc7560eea..25b0b3f82 100644
--- a/tests/rsrc/scenes/default.xml
+++ b/tests/rsrc/scenes/default.xml
@@ -3,30 +3,30 @@