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:
Walter Korman
2001-08-29 19:50:46 +00:00
parent 8c7efb79fe
commit a7c639ffe0
7 changed files with 113 additions and 69 deletions
@@ -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;
@@ -27,8 +27,9 @@ import com.threerings.miso.scene.*;
*/
public class XMLSceneParser extends DefaultHandler
{
public XMLSceneParser (TileManager tilemgr)
public XMLSceneParser (IsoSceneViewModel model, TileManager tilemgr)
{
_model = model;
_tilemgr = tilemgr;
}
@@ -119,7 +120,7 @@ public class XMLSceneParser extends DefaultHandler
int[] vals = StringUtil.parseIntArray(data);
// make sure we have a suitable number of tiles
int validLen = MisoScene.TILE_WIDTH * 2;
int validLen = _model.scenewid * 2;
if (vals.length != validLen) {
Log.warning(
"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. */
protected String _tag;
/** The iso scene view data model. */
protected IsoSceneViewModel _model;
/** The tile manager object for use in constructing scenes. */
protected TileManager _tilemgr;
@@ -354,7 +358,7 @@ public class XMLSceneParser extends DefaultHandler
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];
clusters = new ArrayList();
}
@@ -362,7 +366,7 @@ public class XMLSceneParser extends DefaultHandler
public void constructScene (TileManager tilemgr)
{
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;
@@ -10,6 +10,7 @@ import java.util.ArrayList;
import com.samskivert.util.Config;
import com.threerings.media.tile.TileManager;
import com.threerings.miso.Log;
import com.threerings.miso.scene.IsoSceneViewModel;
import com.threerings.miso.scene.MisoScene;
import com.threerings.miso.util.MisoUtil;
@@ -38,9 +39,12 @@ public class XMLFileSceneRepository
_root = System.getProperty("root", "");
_sceneRoot = _config.getValue(SCENEROOT_KEY, DEF_SCENEROOT);
// create the parser and writer objects
_parser = new XMLSceneParser(_tilemgr);
_writer = new XMLSceneWriter();
// create an iso scene view model detailing scene dimensions
_model = new IsoSceneViewModel(config);
// 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. */
protected String _sceneRoot;
/** The iso scene view data model. */
protected IsoSceneViewModel _model;
/** The parser object for reading scenes from files. */
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;
@@ -30,8 +30,9 @@ public class XMLSceneWriter extends DataWriter
/**
* Construct an XMLSceneWriter object.
*/
public XMLSceneWriter ()
public XMLSceneWriter (IsoSceneViewModel model)
{
_model = model;
setIndentStep(2);
}
@@ -122,7 +123,7 @@ public class XMLSceneWriter extends DataWriter
attrs.addAttribute("", "lnum", "", "CDATA", "" + lnum);
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) {
writeTileRowData(scene, yy, lnum);
} else {
@@ -239,8 +240,7 @@ public class XMLSceneWriter extends DataWriter
attrs.addAttribute("", "rownum", "", "CDATA", "" + rownum);
// output the full row data element
String data = getTileData(scene, rownum, lnum, 0,
MisoScene.TILE_WIDTH);
String data = getTileData(scene, rownum, lnum, 0, _model.scenewid);
dataElement("", "row", "", attrs, data);
}
@@ -266,7 +266,7 @@ public class XMLSceneWriter extends DataWriter
MisoScene scene, int rownum, int lnum, int info[])
{
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];
if (tile == null) {
if (start == -1) continue;
@@ -320,4 +320,7 @@ public class XMLSceneWriter extends DataWriter
info[0] = info[0] + info[1];
}
}
/** The iso scene view data model. */
protected IsoSceneViewModel _model;
}