Reworking exits and locations en route to editor support for placement
within a scene. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@208 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -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;
|
package com.threerings.miso.sprite;
|
||||||
|
|
||||||
@@ -29,6 +29,12 @@ public class Path
|
|||||||
public static final int DIR_SOUTHEAST = 6;
|
public static final int DIR_SOUTHEAST = 6;
|
||||||
public static final int DIR_SOUTH = 7;
|
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 <code>Path</code> object.
|
* Construct a <code>Path</code> object.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
import com.threerings.miso.tile.Tile;
|
import com.threerings.miso.tile.Tile;
|
||||||
@@ -63,8 +64,8 @@ public class Scene
|
|||||||
|
|
||||||
_sid = SID_INVALID;
|
_sid = SID_INVALID;
|
||||||
_name = DEF_SCENE_NAME;
|
_name = DEF_SCENE_NAME;
|
||||||
_hotspots = new Point[0];
|
_locations = new ArrayList();
|
||||||
_exits = new ExitPoint[0];
|
_exits = new ArrayList();
|
||||||
|
|
||||||
tiles = new Tile[TILE_WIDTH][TILE_HEIGHT][NUM_LAYERS];
|
tiles = new Tile[TILE_WIDTH][TILE_HEIGHT][NUM_LAYERS];
|
||||||
_deftile = _tilemgr.getTile(deftsid, deftid);
|
_deftile = _tilemgr.getTile(deftsid, deftid);
|
||||||
@@ -80,23 +81,22 @@ public class Scene
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Scene object with the given values, specifying
|
* Construct a new Scene object with the given values.
|
||||||
* the tile manager from which the scene obtains tiles.
|
|
||||||
*
|
*
|
||||||
* @param tilemgr the tile manager.
|
* @param tilemgr the tile manager.
|
||||||
* @param name the scene name.
|
* @param name the scene name.
|
||||||
* @param hotspots the hotspot points.
|
* @param locations the locations.
|
||||||
* @param exits the exit points.
|
* @param exits the exits.
|
||||||
* @param tiles the tiles comprising the scene.
|
* @param tiles the tiles comprising the scene.
|
||||||
*/
|
*/
|
||||||
public Scene (TileManager tilemgr, String name,
|
public Scene (TileManager tilemgr, String name,
|
||||||
Point hotspots[], ExitPoint exits[],
|
ArrayList locations, ArrayList exits,
|
||||||
Tile tiles[][][])
|
Tile tiles[][][])
|
||||||
{
|
{
|
||||||
_tilemgr = tilemgr;
|
_tilemgr = tilemgr;
|
||||||
_sid = SID_INVALID;
|
_sid = SID_INVALID;
|
||||||
_name = name;
|
_name = name;
|
||||||
_hotspots = hotspots;
|
_locations = locations;
|
||||||
_exits = exits;
|
_exits = exits;
|
||||||
this.tiles = tiles;
|
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;
|
return _exits;
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ public class Scene
|
|||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
buf.append("[name=").append(_name);
|
buf.append("[name=").append(_name);
|
||||||
buf.append(", sid=").append(_sid);
|
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));
|
buf.append(", exits=").append(StringUtil.toString(_exits));
|
||||||
return buf.append("]").toString();
|
return buf.append("]").toString();
|
||||||
}
|
}
|
||||||
@@ -182,11 +182,11 @@ public class Scene
|
|||||||
/** The unique scene id. */
|
/** The unique scene id. */
|
||||||
protected short _sid;
|
protected short _sid;
|
||||||
|
|
||||||
/** The hot-spot zone points. */
|
/** The locations within the scene. */
|
||||||
protected Point _hotspots[];
|
protected ArrayList _locations;
|
||||||
|
|
||||||
/** The exit points to different scenes. */
|
/** The exit points to different scenes. */
|
||||||
protected ExitPoint _exits[];
|
protected ArrayList _exits;
|
||||||
|
|
||||||
/** The default tile for the base layer in the scene. */
|
/** The default tile for the base layer in the scene. */
|
||||||
protected Tile _deftile;
|
protected Tile _deftile;
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// $Id: Exit.java,v 1.1 2001/08/09 21:17:06 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.
|
||||||
|
*
|
||||||
|
* @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 <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)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -322,6 +322,11 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
IsoUtil.screenToFull(_model, x, y, _hfull);
|
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.
|
* Invalidate a list of rectangles in the view for later repainting.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
//
|
||||||
|
// $Id: Location.java,v 1.1 2001/08/09 21:17:06 shaper Exp $
|
||||||
|
|
||||||
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The <code>Location</code> 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 <code>Location</code> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
package com.threerings.miso.scene.xml;
|
||||||
|
|
||||||
@@ -66,13 +66,13 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
", known_version=" + Scene.VERSION + "].");
|
", known_version=" + Scene.VERSION + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (qName.equals("hotspots")) {
|
} else if (qName.equals("locations")) {
|
||||||
int vals[] = StringUtil.parseIntArray(_chars.toString());
|
int vals[] = StringUtil.parseIntArray(_chars.toString());
|
||||||
_scHotspots = toPointArray(vals);
|
_scLocations = toLocationsList(vals);
|
||||||
|
|
||||||
} else if (qName.equals("exits")) {
|
} else if (qName.equals("exits")) {
|
||||||
String vals[] = StringUtil.parseStringArray(_chars.toString());
|
String vals[] = StringUtil.parseStringArray(_chars.toString());
|
||||||
_scExits = toExitPointArray(vals);
|
_scExits = toExitList(_scLocations, vals);
|
||||||
|
|
||||||
} else if (qName.equals("row")) {
|
} else if (qName.equals("row")) {
|
||||||
if (_scLnum == Scene.LAYER_BASE) {
|
if (_scLnum == Scene.LAYER_BASE) {
|
||||||
@@ -84,7 +84,7 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
} else if (qName.equals("scene")) {
|
} else if (qName.equals("scene")) {
|
||||||
// construct the scene object on tag close
|
// construct the scene object on tag close
|
||||||
_scene = new Scene(
|
_scene = new Scene(
|
||||||
_tilemgr, _scName, _scHotspots, _scExits, _scTiles);
|
_tilemgr, _scName, _scLocations, _scExits, _scTiles);
|
||||||
|
|
||||||
Log.info("Constructed parsed scene [scene=" + _scene + "].");
|
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
|
* Given an array of integer values, return a list of the
|
||||||
* constructed from each successive tuple of values as (x, y) in
|
* <code>Location</code> objects represented therein, constructed
|
||||||
* the array.
|
* from each successive quartet of values as (spotid, x, y,
|
||||||
|
* orientation) in the integer array.
|
||||||
*
|
*
|
||||||
* @param vals the integer values.
|
* @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
|
// make sure we have a seemingly-appropriate number of points
|
||||||
if ((vals.length % 2) == 1) return null;
|
if ((vals.length % 4) != 0) return null;
|
||||||
|
|
||||||
// pull the point coordinates out of the int array
|
// read in all of the locations and add to the list
|
||||||
Point[] points = new Point[vals.length / 2];
|
ArrayList list = new ArrayList();
|
||||||
for (int ii = 0; ii < vals.length; ii += 2) {
|
for (int ii = 0; ii < vals.length; ii += 4) {
|
||||||
int idx = ii / 2;
|
Location loc = new Location(
|
||||||
points[idx] = new Point(vals[ii], vals[ii + 1]);
|
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
|
* Given an array of string values, return a list of
|
||||||
* constructed from each successive triplet of values as (x, y,
|
* <code>Exit</code> objects constructed from each successive
|
||||||
* scene name) in the array.
|
* triplet of values as (locidx, scene name) in the array. The
|
||||||
|
* list of <code>Location</code> objects must have already been
|
||||||
|
* fully read previously.
|
||||||
*
|
*
|
||||||
* <p> This is something of a hack since we perhaps ought to parse
|
* <p> This is something of a hack since we perhaps ought to parse
|
||||||
* the original String into its constituent components ourselves,
|
* the original String into its constituent components ourselves,
|
||||||
@@ -198,29 +202,25 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
* <code>StringUtil.toString()</code> method to take care of
|
* <code>StringUtil.toString()</code> method to take care of
|
||||||
* tokenizing things for us, so, there you have it.
|
* tokenizing things for us, so, there you have it.
|
||||||
*
|
*
|
||||||
|
* @param ArrayList the location list.
|
||||||
* @param vals the String values.
|
* @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
|
// 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
|
// read in all of the exits and add to the list
|
||||||
ExitPoint[] exits = new ExitPoint[vals.length / 3];
|
ArrayList list = new ArrayList();
|
||||||
for (int ii = 0; ii < vals.length; ii += 3) {
|
for (int ii = 0; ii < vals.length; ii += 2) {
|
||||||
int idx = ii / 3;
|
Exit exit = new Exit(
|
||||||
exits[idx] = new ExitPoint();
|
(Location)locs.get(getInt(vals[ii])), vals[ii+1]);
|
||||||
exits[idx].x = (byte)getInt(vals[ii]);
|
list.add(exit);
|
||||||
exits[idx].y = (byte)getInt(vals[ii + 1]);
|
}
|
||||||
exits[idx].name = vals[ii + 2];
|
|
||||||
|
|
||||||
// scene id is only valid at runtime
|
return list;
|
||||||
exits[idx].sid = Scene.SID_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
return exits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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
|
* Parse the specified XML file and return a Scene object with the
|
||||||
* data contained therein.
|
* data contained therein.
|
||||||
@@ -255,10 +265,7 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
BufferedInputStream bis = new BufferedInputStream(fis);
|
BufferedInputStream bis = new BufferedInputStream(fis);
|
||||||
|
|
||||||
// prepare temporary data storage for parsing
|
// prepare temporary data storage for parsing
|
||||||
_chars = new StringBuffer();
|
init();
|
||||||
_scene = null;
|
|
||||||
int width = Scene.TILE_WIDTH, height = Scene.TILE_HEIGHT;
|
|
||||||
_scTiles = new Tile[width][height][Scene.NUM_LAYERS];
|
|
||||||
|
|
||||||
// read the XML input stream and construct the scene object
|
// read the XML input stream and construct the scene object
|
||||||
XMLUtil.parse(this, bis);
|
XMLUtil.parse(this, bis);
|
||||||
@@ -289,8 +296,8 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
// temporary storage of scene object values and data
|
// temporary storage of scene object values and data
|
||||||
protected StringBuffer _chars;
|
protected StringBuffer _chars;
|
||||||
protected String _scName;
|
protected String _scName;
|
||||||
protected Point[] _scHotspots;
|
protected ArrayList _scLocations;
|
||||||
protected ExitPoint[] _scExits;
|
protected ArrayList _scExits;
|
||||||
protected Tile[][][] _scTiles;
|
protected Tile[][][] _scTiles;
|
||||||
protected int _scLnum, _scRownum, _scColstart;
|
protected int _scLnum, _scRownum, _scColstart;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.miso.scene.xml;
|
||||||
|
|
||||||
@@ -13,12 +13,12 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||||||
import com.megginson.sax.DataWriter;
|
import com.megginson.sax.DataWriter;
|
||||||
|
|
||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
import com.threerings.miso.scene.ExitPoint;
|
import com.threerings.miso.scene.*;
|
||||||
import com.threerings.miso.scene.Scene;
|
|
||||||
import com.threerings.miso.tile.Tile;
|
import com.threerings.miso.tile.Tile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The XMLSceneWriter writes a Scene object to an XML file.
|
* The <code>XMLSceneWriter</code> writes a <code>Scene</code> object
|
||||||
|
* to an XML file.
|
||||||
*
|
*
|
||||||
* <p> The scene id is omitted as the scene id is assigned when the
|
* <p> The scene id is omitted as the scene id is assigned when the
|
||||||
* scene template is actually loaded into a server. Similarly, exit
|
* scene template is actually loaded into a server. Similarly, exit
|
||||||
@@ -51,7 +51,7 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
|
|
||||||
dataElement("name", scene.getName());
|
dataElement("name", scene.getName());
|
||||||
dataElement("version", "" + Scene.VERSION);
|
dataElement("version", "" + Scene.VERSION);
|
||||||
dataElement("hotspots", getHotSpotData(scene));
|
dataElement("locations", getLocationData(scene));
|
||||||
dataElement("exits", getExitData(scene));
|
dataElement("exits", getExitData(scene));
|
||||||
|
|
||||||
startElement("tiles");
|
startElement("tiles");
|
||||||
@@ -97,47 +97,51 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a string representation of the exit points in the
|
* Return a string representation of the exits in the scene. Each
|
||||||
* scene. Each exit point is specified by a comma-delimited
|
* exit is specified by a comma-delimited tuple of (location
|
||||||
* triplet of (x, y, scene name) values.
|
* index, scene name) values.
|
||||||
*
|
*
|
||||||
* @param scene the scene object.
|
* @param scene the scene object.
|
||||||
*
|
*
|
||||||
* @return the exit points in String format.
|
* @return the exits in String format.
|
||||||
*/
|
*/
|
||||||
protected String getExitData (Scene scene)
|
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();
|
StringBuffer buf = new StringBuffer();
|
||||||
for (int ii = 0; ii < exits.length; ii++) {
|
int size = exits.size();
|
||||||
int idx = ii * 3;
|
for (int ii = 0; ii < size; ii++) {
|
||||||
buf.append(exits[ii].x).append(",");
|
Exit exit = (Exit)exits.get(ii);
|
||||||
buf.append(exits[ii].y).append(",");
|
buf.append(locs.indexOf(exit.loc)).append(",");
|
||||||
buf.append(exits[ii].name);
|
buf.append(exit.name);
|
||||||
if (ii < exits.length - 1) buf.append(",");
|
if (ii < size - 1) buf.append(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a string representation of the hotspot points in the
|
* Return a string representation of the locations in the scene.
|
||||||
* scene. Each hotspot point is specified by a comma-delimited
|
* Each location is specified by a comma-delimited quartet of
|
||||||
* tuple of (x, y) values.
|
* (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();
|
StringBuffer buf = new StringBuffer();
|
||||||
for (int ii = 0; ii < hotspots.length; ii++) {
|
int size = locs.size();
|
||||||
buf.append(hotspots[ii].x).append(",");
|
for (int ii = 0; ii < size; ii++) {
|
||||||
buf.append(hotspots[ii].y);
|
Location loc = (Location)locs.get(ii);
|
||||||
if (ii < hotspots.length - 1) buf.append(",");
|
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();
|
return buf.toString();
|
||||||
|
|||||||
@@ -3,30 +3,30 @@
|
|||||||
<scene>
|
<scene>
|
||||||
<name>Untitled Scene</name>
|
<name>Untitled Scene</name>
|
||||||
<version>1</version>
|
<version>1</version>
|
||||||
<hotspots></hotspots>
|
<locations></locations>
|
||||||
<exits></exits>
|
<exits></exits>
|
||||||
<tiles>
|
<tiles>
|
||||||
<layer lnum="0">
|
<layer lnum="0">
|
||||||
<row rownum="0">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="0">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="1">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="1">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="2">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="2">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="3">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="3">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="4">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="4">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="5">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="5">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="6">1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,6,1004,10,1004,8,1004,3,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="6">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="7">1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,6,1004,10,1004,8,1004,3,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="7">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,10,1004,10,1004,10,1004,10,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="8">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,10,1004,8,1004,3,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="8">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,6,1004,6,1004,10,1004,10,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="9">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,12,1004,12,1004,12,1004,12,1004,12,1004,12,1004,12,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="9">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="10">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,3,1004,6,1004,6,1004,6,1004,12,1004,11,1004,13,1004,12,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="10">1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,3,1004,2,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="11">1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,6,1004,6,1004,6,1004,3,1004,12,1004,11,1004,13,1004,12,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="11">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,3,1004,2,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="12">1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,6,1004,6,1004,10,1004,8,1004,6,1004,3,1004,6,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="12">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,11,1004,2,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="13">1004,10,1004,10,1004,10,1004,10,1004,9,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,3,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="13">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,11,1004,1,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="14">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,3,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="14">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,10,1004,6,1004,6,1004,6,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="15">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,8,1004,6,1004,6,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="15">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,9,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="16">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="16">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="17">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="17">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="18">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="18">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="19">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="19">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,6,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="20">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="20">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
<row rownum="21">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="21">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
</layer>
|
</layer>
|
||||||
|
|||||||
Reference in New Issue
Block a user