diff --git a/rsrc/config/miso/miso.properties b/rsrc/config/miso/miso.properties index 84c80a6ef..a62e20186 100644 --- a/rsrc/config/miso/miso.properties +++ b/rsrc/config/miso/miso.properties @@ -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. # @@ -27,8 +27,12 @@ tile_height = 48 fine_granularity = 4 # scene dimensions in tile counts -scene_width = 10 -scene_height = 12 +scene_width = 22 +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 scene_offset_y = -5 diff --git a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java index 9c0c0487d..c6c7c603a 100644 --- a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java +++ b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java @@ -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; @@ -38,12 +38,6 @@ public class MisoScene implements Scene /** The latest scene file format version. */ 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. */ 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 * tile id. * + * @param model the iso scene view model. * @param tilemgr the tile manager. * @param deftsid the default tileset 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; _sid = SID_INVALID; @@ -73,10 +70,10 @@ public class MisoScene implements Scene _clusters = 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); - for (int xx = 0; xx < TILE_WIDTH; xx++) { - for (int yy = 0; yy < TILE_HEIGHT; yy++) { + for (int xx = 0; xx < _model.scenewid; xx++) { + for (int yy = 0; yy < _model.scenehei; yy++) { for (int ii = 0; ii < NUM_LAYERS; ii++) { if (ii == LAYER_BASE) { tiles[xx][yy][ii] = _deftile; @@ -89,17 +86,20 @@ public class MisoScene implements Scene /** * Construct a new miso scene object with the given values. * + * @param model the iso scene view model. * @param tilemgr the tile manager. * @param name the scene name. * @param locations the locations. * @param portals the portals. * @param tiles the tiles comprising the scene. */ - public MisoScene ( - TileManager tilemgr, String name, ArrayList locations, - ArrayList clusters, ArrayList portals, Tile tiles[][][]) + public MisoScene (IsoSceneViewModel model, TileManager tilemgr, + String name, ArrayList locations, + ArrayList clusters, ArrayList portals, + Tile tiles[][][]) { - _tilemgr = tilemgr; + _model = model; + _tilemgr = tilemgr; _sid = SID_INVALID; _name = name; _locations = locations; @@ -303,13 +303,16 @@ public class MisoScene implements Scene */ 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; - - for (int xx = 0; xx < TILE_WIDTH; xx++) { - for (int yy = 0; yy < TILE_HEIGHT; yy++) { - if (tiles[xx][yy] != null) numTiles++; + for (int xx = 0; xx < _model.scenewid; xx++) { + for (int yy = 0; yy < _model.scenehei; yy++) { + if (tiles[xx][yy] != null) { + numTiles++; + } } } @@ -362,6 +365,9 @@ public class MisoScene implements Scene /** The default tile for the base layer in the scene. */ protected Tile _deftile; + /** The iso scene view data model. */ + protected IsoSceneViewModel _model; + /** The tile manager. */ protected TileManager _tilemgr; } diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java index a5f269ee6..71936cbf9 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.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; @@ -49,15 +49,15 @@ public class IsoSceneView implements EditableSceneView // create our polygon arrays and create polygons for each of the // tiles. we use these repeatedly, so we go ahead and make 'em all // up front - _polys = new Polygon[MisoScene.TILE_WIDTH][MisoScene.TILE_HEIGHT]; - for (int xx = 0; xx < MisoScene.TILE_WIDTH; xx++) { - for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) { + _polys = new Polygon[model.scenewid][model.scenehei]; + for (int xx = 0; xx < model.scenewid; xx++) { + for (int yy = 0; yy < model.scenehei; yy++) { _polys[xx][yy] = IsoUtil.getTilePolygon(_model, xx, yy); } } // 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 _dirtyRects = new ArrayList(); @@ -119,8 +119,8 @@ public class IsoSceneView implements EditableSceneView _dirtyRects.clear(); _numDirty = 0; - for (int xx = 0; xx < MisoScene.TILE_WIDTH; xx++) { - for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) { + for (int xx = 0; xx < _model.scenewid; xx++) { + for (int yy = 0; yy < _model.scenehei; yy++) { _dirty[xx][yy] = false; } } @@ -130,8 +130,8 @@ public class IsoSceneView implements EditableSceneView { // draw the dirty tiles gfx.setColor(Color.cyan); - for (int xx = 0; xx < MisoScene.TILE_WIDTH; xx++) { - for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) { + for (int xx = 0; xx < _model.scenewid; xx++) { + for (int yy = 0; yy < _model.scenehei; yy++) { if (_dirty[xx][yy]) { gfx.draw(_polys[xx][yy]); } @@ -156,8 +156,8 @@ public class IsoSceneView implements EditableSceneView { int numDrawn = 0; - for (int yy = 0; yy < MisoScene.TILE_HEIGHT; yy++) { - for (int xx = 0; xx < MisoScene.TILE_WIDTH; xx++) { + for (int yy = 0; yy < _model.scenehei; yy++) { + for (int xx = 0; xx < _model.scenewid; xx++) { // skip this tile if it's not marked dirty if (!_dirty[xx][yy]) continue; @@ -209,7 +209,7 @@ public class IsoSceneView implements EditableSceneView for (int ii = 0; ii < _model.tilerows; ii++) { // determine starting tile coordinates - int tx = (ii < MisoScene.TILE_HEIGHT) ? 0 : mx++; + int tx = (ii < _model.scenehei) ? 0 : mx++; int ty = my; // determine number of tiles in this row @@ -255,8 +255,8 @@ public class IsoSceneView implements EditableSceneView screenY += _model.tilehhei; // advance starting y-axis coordinate unless we've hit bottom - if ((++my) > MisoScene.TILE_HEIGHT - 1) { - my = MisoScene.TILE_HEIGHT - 1; + if ((++my) > _model.scenehei - 1) { + my = _model.scenehei - 1; } } } @@ -537,15 +537,15 @@ public class IsoSceneView implements EditableSceneView // constrain x-coordinate to a valid range if (x < 0) { x = 0; - } else if (x >= MisoScene.TILE_WIDTH) { - x = MisoScene.TILE_WIDTH - 1; + } else if (x >= _model.scenewid) { + x = _model.scenewid - 1; } // constrain y-coordinate to a valid range if (y < 0) { y = 0; - } else if (y >= MisoScene.TILE_HEIGHT) { - y = MisoScene.TILE_HEIGHT - 1; + } else if (y >= _model.scenehei) { + y = _model.scenehei - 1; } // 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 List tilepath = AStarPathUtil.getPath( - _scene.tiles, MisoScene.TILE_WIDTH, MisoScene.TILE_HEIGHT, + _scene.tiles, _model.scenewid, _model.scenehei, sprite, stpos.x, stpos.y, tbx, tby); if (tilepath == null) { return null; diff --git a/src/java/com/threerings/miso/client/IsoSceneViewModel.java b/src/java/com/threerings/miso/client/IsoSceneViewModel.java index 5475175c8..f404575ae 100644 --- a/src/java/com/threerings/miso/client/IsoSceneViewModel.java +++ b/src/java/com/threerings/miso/client/IsoSceneViewModel.java @@ -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; @@ -31,6 +31,9 @@ public class IsoSceneViewModel /** Number of fine coordinates on each axis within a tile. */ public int finegran; + /** Scene dimensions in tile count. */ + public int scenewid, scenehei; + /** The bounds dimensions for the view. */ public Dimension bounds; @@ -78,18 +81,25 @@ public class IsoSceneViewModel */ 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 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); // set the fine coordinate granularity setFineGranularity(config.getValue(FINE_GRAN_KEY, DEF_FINE_GRAN)); // set the desired scene view bounds - int swid = config.getValue(SCENE_WIDTH_KEY, DEF_SCENE_WIDTH); - int shei = config.getValue(SCENE_HEIGHT_KEY, DEF_SCENE_HEIGHT); - setBounds(swid * twid, shei * thei); + int svwid = config.getValue(SCENE_VWIDTH_KEY, DEF_SCENE_VWIDTH); + int svhei = config.getValue(SCENE_VHEIGHT_KEY, DEF_SCENE_VHEIGHT); + setBounds(svwid * twid, svhei * thei); // set the scene display origin int offy = config.getValue(SCENE_OFFSET_Y_KEY, DEF_OFFSET_Y); @@ -182,7 +192,7 @@ public class IsoSceneViewModel (tilehwid * tilehwid) + (tilehhei * tilehhei)); // 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 slopeX = (float)tilehei / (float)tilewid; @@ -245,7 +255,7 @@ public class IsoSceneViewModel bX = (int)-(slopeX * origin.x); // 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); // calculate tile-based x-axis line for conversion from @@ -276,6 +286,14 @@ public class IsoSceneViewModel protected static final String FINE_GRAN_KEY = 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. */ protected static final String SCENE_WIDTH_KEY = MisoUtil.CONFIG_KEY + ".scene_width"; @@ -301,12 +319,14 @@ public class IsoSceneViewModel MisoUtil.CONFIG_KEY + ".show_paths"; /** Default scene view parameters. */ - protected static final int DEF_TILE_WIDTH = 32; - protected static final int DEF_TILE_HEIGHT = 16; + protected static final int DEF_TILE_WIDTH = 64; + protected static final int DEF_TILE_HEIGHT = 48; protected static final int DEF_FINE_GRAN = 4; - protected static final int DEF_SCENE_WIDTH = 20; - protected static final int DEF_SCENE_HEIGHT = 20; - protected static final int DEF_OFFSET_Y = 9; + protected static final int DEF_SCENE_VWIDTH = 10; + protected static final int DEF_SCENE_VHEIGHT = 12; + 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_LOCS = false; protected static final boolean DEF_SHOW_PATHS = false; diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneParser.java b/src/java/com/threerings/miso/tools/xml/XMLSceneParser.java index 74227b5e9..0c0b1ddbb 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.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); } } } diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneRepository.java b/src/java/com/threerings/miso/tools/xml/XMLSceneRepository.java index c194dfbd8..8ed133d76 100644 --- a/src/java/com/threerings/miso/tools/xml/XMLSceneRepository.java +++ b/src/java/com/threerings/miso/tools/xml/XMLSceneRepository.java @@ -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; diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java b/src/java/com/threerings/miso/tools/xml/XMLSceneWriter.java index abd21fd60..f2926fab7 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.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; }