Modified MisoScene and related classes to obtain the scene tile
dimensions from the scene view data model. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@319 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# $Id: miso.properties,v 1.10 2001/08/29 18:41:46 shaper Exp $
|
# $Id: miso.properties,v 1.11 2001/08/29 19:50:45 shaper Exp $
|
||||||
#
|
#
|
||||||
# Initial test config values for miso development.
|
# Initial test config values for miso development.
|
||||||
#
|
#
|
||||||
@@ -27,8 +27,12 @@ tile_height = 48
|
|||||||
fine_granularity = 4
|
fine_granularity = 4
|
||||||
|
|
||||||
# scene dimensions in tile counts
|
# scene dimensions in tile counts
|
||||||
scene_width = 10
|
scene_width = 22
|
||||||
scene_height = 12
|
scene_height = 22
|
||||||
|
|
||||||
|
# scene viewport dimensions in tile counts
|
||||||
|
scene_view_width = 10
|
||||||
|
scene_view_height = 12
|
||||||
|
|
||||||
# vertical offset for scene display origin in tile count
|
# vertical offset for scene display origin in tile count
|
||||||
scene_offset_y = -5
|
scene_offset_y = -5
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DisplayMisoSceneImpl.java,v 1.32 2001/08/16 23:14:21 mdb Exp $
|
// $Id: DisplayMisoSceneImpl.java,v 1.33 2001/08/29 19:50:46 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -38,12 +38,6 @@ public class MisoScene implements Scene
|
|||||||
/** The latest scene file format version. */
|
/** The latest scene file format version. */
|
||||||
public static final short VERSION = 1;
|
public static final short VERSION = 1;
|
||||||
|
|
||||||
/** The scene width in tiles. */
|
|
||||||
public static final int TILE_WIDTH = 22;
|
|
||||||
|
|
||||||
/** The scene height in tiles. */
|
|
||||||
public static final int TILE_HEIGHT = 22;
|
|
||||||
|
|
||||||
/** String translations of each tile layer name. */
|
/** String translations of each tile layer name. */
|
||||||
public static final String[] XLATE_LAYERS = { "Base", "Fringe", "Object" };
|
public static final String[] XLATE_LAYERS = { "Base", "Fringe", "Object" };
|
||||||
|
|
||||||
@@ -58,12 +52,15 @@ public class MisoScene implements Scene
|
|||||||
* initialized to contain tiles of the specified default tileset and
|
* initialized to contain tiles of the specified default tileset and
|
||||||
* tile id.
|
* tile id.
|
||||||
*
|
*
|
||||||
|
* @param model the iso scene view model.
|
||||||
* @param tilemgr the tile manager.
|
* @param tilemgr the tile manager.
|
||||||
* @param deftsid the default tileset id.
|
* @param deftsid the default tileset id.
|
||||||
* @param deftid the default tile id.
|
* @param deftid the default tile id.
|
||||||
*/
|
*/
|
||||||
public MisoScene (TileManager tilemgr, int deftsid, int deftid)
|
public MisoScene (IsoSceneViewModel model, TileManager tilemgr,
|
||||||
|
int deftsid, int deftid)
|
||||||
{
|
{
|
||||||
|
_model = model;
|
||||||
_tilemgr = tilemgr;
|
_tilemgr = tilemgr;
|
||||||
|
|
||||||
_sid = SID_INVALID;
|
_sid = SID_INVALID;
|
||||||
@@ -73,10 +70,10 @@ public class MisoScene implements Scene
|
|||||||
_clusters = new ArrayList();
|
_clusters = new ArrayList();
|
||||||
_portals = new ArrayList();
|
_portals = new ArrayList();
|
||||||
|
|
||||||
tiles = new Tile[TILE_WIDTH][TILE_HEIGHT][NUM_LAYERS];
|
tiles = new Tile[_model.scenewid][_model.scenehei][NUM_LAYERS];
|
||||||
_deftile = _tilemgr.getTile(deftsid, deftid);
|
_deftile = _tilemgr.getTile(deftsid, deftid);
|
||||||
for (int xx = 0; xx < TILE_WIDTH; xx++) {
|
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||||
for (int yy = 0; yy < TILE_HEIGHT; yy++) {
|
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||||
for (int ii = 0; ii < NUM_LAYERS; ii++) {
|
for (int ii = 0; ii < NUM_LAYERS; ii++) {
|
||||||
if (ii == LAYER_BASE) {
|
if (ii == LAYER_BASE) {
|
||||||
tiles[xx][yy][ii] = _deftile;
|
tiles[xx][yy][ii] = _deftile;
|
||||||
@@ -89,17 +86,20 @@ public class MisoScene implements Scene
|
|||||||
/**
|
/**
|
||||||
* Construct a new miso scene object with the given values.
|
* Construct a new miso scene object with the given values.
|
||||||
*
|
*
|
||||||
|
* @param model the iso scene view model.
|
||||||
* @param tilemgr the tile manager.
|
* @param tilemgr the tile manager.
|
||||||
* @param name the scene name.
|
* @param name the scene name.
|
||||||
* @param locations the locations.
|
* @param locations the locations.
|
||||||
* @param portals the portals.
|
* @param portals the portals.
|
||||||
* @param tiles the tiles comprising the scene.
|
* @param tiles the tiles comprising the scene.
|
||||||
*/
|
*/
|
||||||
public MisoScene (
|
public MisoScene (IsoSceneViewModel model, TileManager tilemgr,
|
||||||
TileManager tilemgr, String name, ArrayList locations,
|
String name, ArrayList locations,
|
||||||
ArrayList clusters, ArrayList portals, Tile tiles[][][])
|
ArrayList clusters, ArrayList portals,
|
||||||
|
Tile tiles[][][])
|
||||||
{
|
{
|
||||||
_tilemgr = tilemgr;
|
_model = model;
|
||||||
|
_tilemgr = tilemgr;
|
||||||
_sid = SID_INVALID;
|
_sid = SID_INVALID;
|
||||||
_name = name;
|
_name = name;
|
||||||
_locations = locations;
|
_locations = locations;
|
||||||
@@ -303,13 +303,16 @@ public class MisoScene implements Scene
|
|||||||
*/
|
*/
|
||||||
public int getNumLayerTiles (int lnum)
|
public int getNumLayerTiles (int lnum)
|
||||||
{
|
{
|
||||||
if (lnum == LAYER_BASE) return TILE_WIDTH * TILE_HEIGHT;
|
if (lnum == LAYER_BASE) {
|
||||||
|
return _model.scenewid * _model.scenehei;
|
||||||
|
}
|
||||||
|
|
||||||
int numTiles = 0;
|
int numTiles = 0;
|
||||||
|
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||||
for (int xx = 0; xx < TILE_WIDTH; xx++) {
|
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||||
for (int yy = 0; yy < TILE_HEIGHT; yy++) {
|
if (tiles[xx][yy] != null) {
|
||||||
if (tiles[xx][yy] != null) numTiles++;
|
numTiles++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,6 +365,9 @@ public class MisoScene implements Scene
|
|||||||
/** 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;
|
||||||
|
|
||||||
|
/** The iso scene view data model. */
|
||||||
|
protected IsoSceneViewModel _model;
|
||||||
|
|
||||||
/** The tile manager. */
|
/** The tile manager. */
|
||||||
protected TileManager _tilemgr;
|
protected TileManager _tilemgr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IsoSceneView.java,v 1.52 2001/08/22 02:14:57 mdb Exp $
|
// $Id: IsoSceneView.java,v 1.53 2001/08/29 19:50:46 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -49,15 +49,15 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
// create our polygon arrays and create polygons for each of the
|
// create our polygon arrays and create polygons for each of the
|
||||||
// tiles. we use these repeatedly, so we go ahead and make 'em all
|
// tiles. we use these repeatedly, so we go ahead and make 'em all
|
||||||
// up front
|
// up front
|
||||||
_polys = new Polygon[MisoScene.TILE_WIDTH][MisoScene.TILE_HEIGHT];
|
_polys = new Polygon[model.scenewid][model.scenehei];
|
||||||
for (int xx = 0; xx < MisoScene.TILE_WIDTH; xx++) {
|
for (int xx = 0; xx < model.scenewid; xx++) {
|
||||||
for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) {
|
for (int yy = 0; yy < model.scenehei; yy++) {
|
||||||
_polys[xx][yy] = IsoUtil.getTilePolygon(_model, xx, yy);
|
_polys[xx][yy] = IsoUtil.getTilePolygon(_model, xx, yy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the array used to mark dirty tiles
|
// create the array used to mark dirty tiles
|
||||||
_dirty = new boolean[MisoScene.TILE_WIDTH][MisoScene.TILE_HEIGHT];
|
_dirty = new boolean[model.scenewid][model.tilehei];
|
||||||
|
|
||||||
// create the list of dirty rectangles
|
// create the list of dirty rectangles
|
||||||
_dirtyRects = new ArrayList();
|
_dirtyRects = new ArrayList();
|
||||||
@@ -119,8 +119,8 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
_dirtyRects.clear();
|
_dirtyRects.clear();
|
||||||
|
|
||||||
_numDirty = 0;
|
_numDirty = 0;
|
||||||
for (int xx = 0; xx < MisoScene.TILE_WIDTH; xx++) {
|
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||||
for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) {
|
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||||
_dirty[xx][yy] = false;
|
_dirty[xx][yy] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,8 +130,8 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
{
|
{
|
||||||
// draw the dirty tiles
|
// draw the dirty tiles
|
||||||
gfx.setColor(Color.cyan);
|
gfx.setColor(Color.cyan);
|
||||||
for (int xx = 0; xx < MisoScene.TILE_WIDTH; xx++) {
|
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||||
for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) {
|
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||||
if (_dirty[xx][yy]) {
|
if (_dirty[xx][yy]) {
|
||||||
gfx.draw(_polys[xx][yy]);
|
gfx.draw(_polys[xx][yy]);
|
||||||
}
|
}
|
||||||
@@ -156,8 +156,8 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
{
|
{
|
||||||
int numDrawn = 0;
|
int numDrawn = 0;
|
||||||
|
|
||||||
for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) {
|
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||||
for (int xx = 0; xx < MisoScene.TILE_WIDTH; xx++) {
|
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||||
|
|
||||||
// skip this tile if it's not marked dirty
|
// skip this tile if it's not marked dirty
|
||||||
if (!_dirty[xx][yy]) continue;
|
if (!_dirty[xx][yy]) continue;
|
||||||
@@ -209,7 +209,7 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
|
|
||||||
for (int ii = 0; ii < _model.tilerows; ii++) {
|
for (int ii = 0; ii < _model.tilerows; ii++) {
|
||||||
// determine starting tile coordinates
|
// determine starting tile coordinates
|
||||||
int tx = (ii < MisoScene.TILE_HEIGHT) ? 0 : mx++;
|
int tx = (ii < _model.scenehei) ? 0 : mx++;
|
||||||
int ty = my;
|
int ty = my;
|
||||||
|
|
||||||
// determine number of tiles in this row
|
// determine number of tiles in this row
|
||||||
@@ -255,8 +255,8 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
screenY += _model.tilehhei;
|
screenY += _model.tilehhei;
|
||||||
|
|
||||||
// advance starting y-axis coordinate unless we've hit bottom
|
// advance starting y-axis coordinate unless we've hit bottom
|
||||||
if ((++my) > MisoScene.TILE_HEIGHT - 1) {
|
if ((++my) > _model.scenehei - 1) {
|
||||||
my = MisoScene.TILE_HEIGHT - 1;
|
my = _model.scenehei - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,15 +537,15 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
// constrain x-coordinate to a valid range
|
// constrain x-coordinate to a valid range
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 0;
|
x = 0;
|
||||||
} else if (x >= MisoScene.TILE_WIDTH) {
|
} else if (x >= _model.scenewid) {
|
||||||
x = MisoScene.TILE_WIDTH - 1;
|
x = _model.scenewid - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// constrain y-coordinate to a valid range
|
// constrain y-coordinate to a valid range
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
y = 0;
|
y = 0;
|
||||||
} else if (y >= MisoScene.TILE_HEIGHT) {
|
} else if (y >= _model.scenehei) {
|
||||||
y = MisoScene.TILE_HEIGHT - 1;
|
y = _model.scenehei - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do nothing if the tile's already dirty
|
// do nothing if the tile's already dirty
|
||||||
@@ -608,7 +608,7 @@ public class IsoSceneView implements EditableSceneView
|
|||||||
// get a reasonable path from start to end
|
// get a reasonable path from start to end
|
||||||
List tilepath =
|
List tilepath =
|
||||||
AStarPathUtil.getPath(
|
AStarPathUtil.getPath(
|
||||||
_scene.tiles, MisoScene.TILE_WIDTH, MisoScene.TILE_HEIGHT,
|
_scene.tiles, _model.scenewid, _model.scenehei,
|
||||||
sprite, stpos.x, stpos.y, tbx, tby);
|
sprite, stpos.x, stpos.y, tbx, tby);
|
||||||
if (tilepath == null) {
|
if (tilepath == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IsoSceneViewModel.java,v 1.10 2001/08/29 18:41:46 shaper Exp $
|
// $Id: IsoSceneViewModel.java,v 1.11 2001/08/29 19:50:46 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -31,6 +31,9 @@ public class IsoSceneViewModel
|
|||||||
/** Number of fine coordinates on each axis within a tile. */
|
/** Number of fine coordinates on each axis within a tile. */
|
||||||
public int finegran;
|
public int finegran;
|
||||||
|
|
||||||
|
/** Scene dimensions in tile count. */
|
||||||
|
public int scenewid, scenehei;
|
||||||
|
|
||||||
/** The bounds dimensions for the view. */
|
/** The bounds dimensions for the view. */
|
||||||
public Dimension bounds;
|
public Dimension bounds;
|
||||||
|
|
||||||
@@ -78,18 +81,25 @@ public class IsoSceneViewModel
|
|||||||
*/
|
*/
|
||||||
public IsoSceneViewModel (Config config)
|
public IsoSceneViewModel (Config config)
|
||||||
{
|
{
|
||||||
// set tile dimensions
|
// set the scene tile dimensions
|
||||||
|
scenewid = config.getValue(SCENE_WIDTH_KEY, DEF_SCENE_WIDTH);
|
||||||
|
scenehei = config.getValue(SCENE_HEIGHT_KEY, DEF_SCENE_HEIGHT);
|
||||||
|
|
||||||
|
// get the tile dimensions
|
||||||
int twid = config.getValue(TILE_WIDTH_KEY, DEF_TILE_WIDTH);
|
int twid = config.getValue(TILE_WIDTH_KEY, DEF_TILE_WIDTH);
|
||||||
int thei = config.getValue(TILE_HEIGHT_KEY, DEF_TILE_HEIGHT);
|
int thei = config.getValue(TILE_HEIGHT_KEY, DEF_TILE_HEIGHT);
|
||||||
|
|
||||||
|
// set tile dimensions and pre-calculate related member data
|
||||||
|
// based on now-known tile and scene dimensions
|
||||||
setTileDimensions(twid, thei);
|
setTileDimensions(twid, thei);
|
||||||
|
|
||||||
// set the fine coordinate granularity
|
// set the fine coordinate granularity
|
||||||
setFineGranularity(config.getValue(FINE_GRAN_KEY, DEF_FINE_GRAN));
|
setFineGranularity(config.getValue(FINE_GRAN_KEY, DEF_FINE_GRAN));
|
||||||
|
|
||||||
// set the desired scene view bounds
|
// set the desired scene view bounds
|
||||||
int swid = config.getValue(SCENE_WIDTH_KEY, DEF_SCENE_WIDTH);
|
int svwid = config.getValue(SCENE_VWIDTH_KEY, DEF_SCENE_VWIDTH);
|
||||||
int shei = config.getValue(SCENE_HEIGHT_KEY, DEF_SCENE_HEIGHT);
|
int svhei = config.getValue(SCENE_VHEIGHT_KEY, DEF_SCENE_VHEIGHT);
|
||||||
setBounds(swid * twid, shei * thei);
|
setBounds(svwid * twid, svhei * thei);
|
||||||
|
|
||||||
// set the scene display origin
|
// set the scene display origin
|
||||||
int offy = config.getValue(SCENE_OFFSET_Y_KEY, DEF_OFFSET_Y);
|
int offy = config.getValue(SCENE_OFFSET_Y_KEY, DEF_OFFSET_Y);
|
||||||
@@ -182,7 +192,7 @@ public class IsoSceneViewModel
|
|||||||
(tilehwid * tilehwid) + (tilehhei * tilehhei));
|
(tilehwid * tilehwid) + (tilehhei * tilehhei));
|
||||||
|
|
||||||
// calculate the number of tile rows to render
|
// calculate the number of tile rows to render
|
||||||
tilerows = (MisoScene.TILE_WIDTH * MisoScene.TILE_HEIGHT) - 1;
|
tilerows = (scenewid * scenehei) - 1;
|
||||||
|
|
||||||
// calculate the slope of the x- and y-axis lines
|
// calculate the slope of the x- and y-axis lines
|
||||||
slopeX = (float)tilehei / (float)tilewid;
|
slopeX = (float)tilehei / (float)tilewid;
|
||||||
@@ -245,7 +255,7 @@ public class IsoSceneViewModel
|
|||||||
bX = (int)-(slopeX * origin.x);
|
bX = (int)-(slopeX * origin.x);
|
||||||
|
|
||||||
// determine the ending point
|
// determine the ending point
|
||||||
lineX[1].x = lineX[0].x + (tilehwid * MisoScene.TILE_WIDTH);
|
lineX[1].x = lineX[0].x + (tilehwid * scenewid);
|
||||||
lineX[1].y = lineX[0].y + (int)((slopeX * lineX[1].x) + bX);
|
lineX[1].y = lineX[0].y + (int)((slopeX * lineX[1].x) + bX);
|
||||||
|
|
||||||
// calculate tile-based x-axis line for conversion from
|
// calculate tile-based x-axis line for conversion from
|
||||||
@@ -276,6 +286,14 @@ public class IsoSceneViewModel
|
|||||||
protected static final String FINE_GRAN_KEY =
|
protected static final String FINE_GRAN_KEY =
|
||||||
MisoUtil.CONFIG_KEY + ".fine_granularity";
|
MisoUtil.CONFIG_KEY + ".fine_granularity";
|
||||||
|
|
||||||
|
/** The config key for scene view width in tile count. */
|
||||||
|
protected static final String SCENE_VWIDTH_KEY =
|
||||||
|
MisoUtil.CONFIG_KEY + ".scene_view_width";
|
||||||
|
|
||||||
|
/** The config key for scene view height in tile count. */
|
||||||
|
protected static final String SCENE_VHEIGHT_KEY =
|
||||||
|
MisoUtil.CONFIG_KEY + ".scene_view_height";
|
||||||
|
|
||||||
/** The config key for scene width in tile count. */
|
/** The config key for scene width in tile count. */
|
||||||
protected static final String SCENE_WIDTH_KEY =
|
protected static final String SCENE_WIDTH_KEY =
|
||||||
MisoUtil.CONFIG_KEY + ".scene_width";
|
MisoUtil.CONFIG_KEY + ".scene_width";
|
||||||
@@ -301,12 +319,14 @@ public class IsoSceneViewModel
|
|||||||
MisoUtil.CONFIG_KEY + ".show_paths";
|
MisoUtil.CONFIG_KEY + ".show_paths";
|
||||||
|
|
||||||
/** Default scene view parameters. */
|
/** Default scene view parameters. */
|
||||||
protected static final int DEF_TILE_WIDTH = 32;
|
protected static final int DEF_TILE_WIDTH = 64;
|
||||||
protected static final int DEF_TILE_HEIGHT = 16;
|
protected static final int DEF_TILE_HEIGHT = 48;
|
||||||
protected static final int DEF_FINE_GRAN = 4;
|
protected static final int DEF_FINE_GRAN = 4;
|
||||||
protected static final int DEF_SCENE_WIDTH = 20;
|
protected static final int DEF_SCENE_VWIDTH = 10;
|
||||||
protected static final int DEF_SCENE_HEIGHT = 20;
|
protected static final int DEF_SCENE_VHEIGHT = 12;
|
||||||
protected static final int DEF_OFFSET_Y = 9;
|
protected static final int DEF_SCENE_WIDTH = 22;
|
||||||
|
protected static final int DEF_SCENE_HEIGHT = 22;
|
||||||
|
protected static final int DEF_OFFSET_Y = -5;
|
||||||
protected static final boolean DEF_SHOW_COORDS = false;
|
protected static final boolean DEF_SHOW_COORDS = false;
|
||||||
protected static final boolean DEF_SHOW_LOCS = false;
|
protected static final boolean DEF_SHOW_LOCS = false;
|
||||||
protected static final boolean DEF_SHOW_PATHS = false;
|
protected static final boolean DEF_SHOW_PATHS = false;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: XMLSceneParser.java,v 1.14 2001/08/16 23:14:21 mdb Exp $
|
// $Id: XMLSceneParser.java,v 1.15 2001/08/29 19:50:46 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene.xml;
|
package com.threerings.miso.scene.xml;
|
||||||
|
|
||||||
@@ -27,8 +27,9 @@ import com.threerings.miso.scene.*;
|
|||||||
*/
|
*/
|
||||||
public class XMLSceneParser extends DefaultHandler
|
public class XMLSceneParser extends DefaultHandler
|
||||||
{
|
{
|
||||||
public XMLSceneParser (TileManager tilemgr)
|
public XMLSceneParser (IsoSceneViewModel model, TileManager tilemgr)
|
||||||
{
|
{
|
||||||
|
_model = model;
|
||||||
_tilemgr = tilemgr;
|
_tilemgr = tilemgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
int[] vals = StringUtil.parseIntArray(data);
|
int[] vals = StringUtil.parseIntArray(data);
|
||||||
|
|
||||||
// make sure we have a suitable number of tiles
|
// make sure we have a suitable number of tiles
|
||||||
int validLen = MisoScene.TILE_WIDTH * 2;
|
int validLen = _model.scenewid * 2;
|
||||||
if (vals.length != validLen) {
|
if (vals.length != validLen) {
|
||||||
Log.warning(
|
Log.warning(
|
||||||
"Invalid number of tiles in full row data set, skipping set " +
|
"Invalid number of tiles in full row data set, skipping set " +
|
||||||
@@ -311,6 +312,9 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
/** The XML element tag currently being processed. */
|
/** The XML element tag currently being processed. */
|
||||||
protected String _tag;
|
protected String _tag;
|
||||||
|
|
||||||
|
/** The iso scene view data model. */
|
||||||
|
protected IsoSceneViewModel _model;
|
||||||
|
|
||||||
/** The tile manager object for use in constructing scenes. */
|
/** The tile manager object for use in constructing scenes. */
|
||||||
protected TileManager _tilemgr;
|
protected TileManager _tilemgr;
|
||||||
|
|
||||||
@@ -354,7 +358,7 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
|
|
||||||
public SceneInfo ()
|
public SceneInfo ()
|
||||||
{
|
{
|
||||||
int width = MisoScene.TILE_WIDTH, height = MisoScene.TILE_HEIGHT;
|
int width = _model.scenewid, height = _model.scenehei;
|
||||||
tiles = new Tile[width][height][MisoScene.NUM_LAYERS];
|
tiles = new Tile[width][height][MisoScene.NUM_LAYERS];
|
||||||
clusters = new ArrayList();
|
clusters = new ArrayList();
|
||||||
}
|
}
|
||||||
@@ -362,7 +366,7 @@ public class XMLSceneParser extends DefaultHandler
|
|||||||
public void constructScene (TileManager tilemgr)
|
public void constructScene (TileManager tilemgr)
|
||||||
{
|
{
|
||||||
scene = new MisoScene(
|
scene = new MisoScene(
|
||||||
tilemgr, name, locations, clusters, portals, tiles);
|
_model, tilemgr, name, locations, clusters, portals, tiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: XMLSceneRepository.java,v 1.10 2001/08/29 18:41:46 shaper Exp $
|
// $Id: XMLSceneRepository.java,v 1.11 2001/08/29 19:50:46 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene.xml;
|
package com.threerings.miso.scene.xml;
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
|||||||
import com.samskivert.util.Config;
|
import com.samskivert.util.Config;
|
||||||
import com.threerings.media.tile.TileManager;
|
import com.threerings.media.tile.TileManager;
|
||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
|
import com.threerings.miso.scene.IsoSceneViewModel;
|
||||||
import com.threerings.miso.scene.MisoScene;
|
import com.threerings.miso.scene.MisoScene;
|
||||||
import com.threerings.miso.util.MisoUtil;
|
import com.threerings.miso.util.MisoUtil;
|
||||||
|
|
||||||
@@ -38,9 +39,12 @@ public class XMLFileSceneRepository
|
|||||||
_root = System.getProperty("root", "");
|
_root = System.getProperty("root", "");
|
||||||
_sceneRoot = _config.getValue(SCENEROOT_KEY, DEF_SCENEROOT);
|
_sceneRoot = _config.getValue(SCENEROOT_KEY, DEF_SCENEROOT);
|
||||||
|
|
||||||
// create the parser and writer objects
|
// create an iso scene view model detailing scene dimensions
|
||||||
_parser = new XMLSceneParser(_tilemgr);
|
_model = new IsoSceneViewModel(config);
|
||||||
_writer = new XMLSceneWriter();
|
|
||||||
|
// construct the scene parser and writer objects for later use
|
||||||
|
_parser = new XMLSceneParser(_model, _tilemgr);
|
||||||
|
_writer = new XMLSceneWriter(_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,6 +99,9 @@ public class XMLFileSceneRepository
|
|||||||
/** The root scene directory path. */
|
/** The root scene directory path. */
|
||||||
protected String _sceneRoot;
|
protected String _sceneRoot;
|
||||||
|
|
||||||
|
/** The iso scene view data model. */
|
||||||
|
protected IsoSceneViewModel _model;
|
||||||
|
|
||||||
/** The parser object for reading scenes from files. */
|
/** The parser object for reading scenes from files. */
|
||||||
protected XMLSceneParser _parser;
|
protected XMLSceneParser _parser;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: XMLSceneWriter.java,v 1.11 2001/08/16 23:14:21 mdb Exp $
|
// $Id: XMLSceneWriter.java,v 1.12 2001/08/29 19:50:46 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene.xml;
|
package com.threerings.miso.scene.xml;
|
||||||
|
|
||||||
@@ -30,8 +30,9 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
/**
|
/**
|
||||||
* Construct an XMLSceneWriter object.
|
* Construct an XMLSceneWriter object.
|
||||||
*/
|
*/
|
||||||
public XMLSceneWriter ()
|
public XMLSceneWriter (IsoSceneViewModel model)
|
||||||
{
|
{
|
||||||
|
_model = model;
|
||||||
setIndentStep(2);
|
setIndentStep(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
attrs.addAttribute("", "lnum", "", "CDATA", "" + lnum);
|
attrs.addAttribute("", "lnum", "", "CDATA", "" + lnum);
|
||||||
|
|
||||||
startElement("", "layer", "", attrs);
|
startElement("", "layer", "", attrs);
|
||||||
for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) {
|
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||||
if (lnum == MisoScene.LAYER_BASE) {
|
if (lnum == MisoScene.LAYER_BASE) {
|
||||||
writeTileRowData(scene, yy, lnum);
|
writeTileRowData(scene, yy, lnum);
|
||||||
} else {
|
} else {
|
||||||
@@ -239,8 +240,7 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
attrs.addAttribute("", "rownum", "", "CDATA", "" + rownum);
|
attrs.addAttribute("", "rownum", "", "CDATA", "" + rownum);
|
||||||
|
|
||||||
// output the full row data element
|
// output the full row data element
|
||||||
String data = getTileData(scene, rownum, lnum, 0,
|
String data = getTileData(scene, rownum, lnum, 0, _model.scenewid);
|
||||||
MisoScene.TILE_WIDTH);
|
|
||||||
dataElement("", "row", "", attrs, data);
|
dataElement("", "row", "", attrs, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
MisoScene scene, int rownum, int lnum, int info[])
|
MisoScene scene, int rownum, int lnum, int info[])
|
||||||
{
|
{
|
||||||
int start = -1, len = 0;
|
int start = -1, len = 0;
|
||||||
for (int xx = info[0]; xx < MisoScene.TILE_WIDTH; xx++) {
|
for (int xx = info[0]; xx < _model.scenewid; xx++) {
|
||||||
Tile tile = scene.tiles[xx][rownum][lnum];
|
Tile tile = scene.tiles[xx][rownum][lnum];
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
if (start == -1) continue;
|
if (start == -1) continue;
|
||||||
@@ -320,4 +320,7 @@ public class XMLSceneWriter extends DataWriter
|
|||||||
info[0] = info[0] + info[1];
|
info[0] = info[0] + info[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The iso scene view data model. */
|
||||||
|
protected IsoSceneViewModel _model;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user