diff --git a/rsrc/config/miso/miso.properties b/rsrc/config/miso/miso.properties index b64948cef..84c80a6ef 100644 --- a/rsrc/config/miso/miso.properties +++ b/rsrc/config/miso/miso.properties @@ -1,5 +1,5 @@ # -# $Id: miso.properties,v 1.9 2001/07/24 16:10:19 shaper Exp $ +# $Id: miso.properties,v 1.10 2001/08/29 18:41:46 shaper Exp $ # # Initial test config values for miso development. # @@ -15,3 +15,32 @@ sceneroot = rsrc/scenes # the tileset descriptions tilesets = rsrc/config/miso/tilesets.xml + +# ---------------------------------- +# begin isometric view configuration + +# tile dimensions in pixels +tile_width = 64 +tile_height = 48 + +# fine coordinate system granularity in intra-tile count +fine_granularity = 4 + +# scene dimensions in tile counts +scene_width = 10 +scene_height = 12 + +# vertical offset for scene display origin in tile count +scene_offset_y = -5 + +# whether to show tile coordinates +show_coords = false + +# whether to show locations +show_locs = false + +# whether to show sprite paths +show_paths = false + +# end isometric view configuration +# -------------------------------- diff --git a/src/java/com/threerings/miso/client/IsoSceneViewModel.java b/src/java/com/threerings/miso/client/IsoSceneViewModel.java index 53b945547..5475175c8 100644 --- a/src/java/com/threerings/miso/client/IsoSceneViewModel.java +++ b/src/java/com/threerings/miso/client/IsoSceneViewModel.java @@ -1,22 +1,24 @@ // -// $Id: IsoSceneViewModel.java,v 1.9 2001/08/15 22:16:43 shaper Exp $ +// $Id: IsoSceneViewModel.java,v 1.10 2001/08/29 18:41:46 shaper Exp $ package com.threerings.miso.scene; import java.awt.Dimension; import java.awt.Point; +import com.samskivert.util.Config; import com.threerings.miso.Log; +import com.threerings.miso.util.MisoUtil; /** - * The IsoSceneViewModel class provides a holding place - * for the myriad parameters and bits of data that describe the - * details of an isometric view of a scene. + * This class provides a holding place for the myriad parameters and + * bits of data that describe the details of an isometric view of a + * scene. * *

The member data are public to facilitate speedy referencing by - * the IsoSceneView class. Those wishing to set up an - * IsoSceneViewModel object should do so solely via the constructor and - * accessor methods. + * the {@link IsoSceneView} class. The model should only be + * configured through the constructor's passed-in {@link + * com.samskivert.util.Config} object and the accessor methods. */ public class IsoSceneViewModel { @@ -69,17 +71,34 @@ public class IsoSceneViewModel public boolean showPaths; /** - * Construct an IsoSceneViewModel with reasonable - * default values. + * Construct an iso scene view model with view parameters as + * specified in the given config object. + * + * @param config the config object. */ - public IsoSceneViewModel () + public IsoSceneViewModel (Config config) { - setTileDimensions(32, 16); - setFineGranularity(4); - setBounds(600, 600); - setOrigin(bounds.width / 2, -(9 * tilehei)); - showCoords = false; - showLocs = false; + // set tile dimensions + int twid = config.getValue(TILE_WIDTH_KEY, DEF_TILE_WIDTH); + int thei = config.getValue(TILE_HEIGHT_KEY, DEF_TILE_HEIGHT); + 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); + + // set the scene display origin + int offy = config.getValue(SCENE_OFFSET_Y_KEY, DEF_OFFSET_Y); + setOrigin(bounds.width / 2, offy * thei); + + // set our various flags + showCoords = config.getValue(SHOW_COORDS_KEY, DEF_SHOW_COORDS); + showLocs = config.getValue(SHOW_COORDS_KEY, DEF_SHOW_COORDS); + showPaths = config.getValue(SHOW_PATHS_KEY, DEF_SHOW_PATHS); } /** @@ -244,4 +263,51 @@ public class IsoSceneViewModel finehwid = (int)((float)tilehwid / (float)finegran); finehhei = (int)((float)tilehhei / (float)finegran); } + + /** The config key for tile width in pixels. */ + protected static final String TILE_WIDTH_KEY = + MisoUtil.CONFIG_KEY + ".tile_width"; + + /** The config key for tile height in pixels. */ + protected static final String TILE_HEIGHT_KEY = + MisoUtil.CONFIG_KEY + ".tile_height"; + + /** The config key for tile fine coordinate granularity. */ + protected static final String FINE_GRAN_KEY = + MisoUtil.CONFIG_KEY + ".fine_granularity"; + + /** The config key for scene width in tile count. */ + protected static final String SCENE_WIDTH_KEY = + MisoUtil.CONFIG_KEY + ".scene_width"; + + /** The config key for scene height in tile count. */ + protected static final String SCENE_HEIGHT_KEY = + MisoUtil.CONFIG_KEY + ".scene_height"; + + /** The config key for scene origin vertical offset in tile count. */ + protected static final String SCENE_OFFSET_Y_KEY = + MisoUtil.CONFIG_KEY + ".scene_offset_y"; + + /** The config key for whether to show tile coordinates. */ + protected static final String SHOW_COORDS_KEY = + MisoUtil.CONFIG_KEY + ".show_coords"; + + /** The config key for whether to show locations. */ + protected static final String SHOW_LOCS_KEY = + MisoUtil.CONFIG_KEY + ".show_locs"; + + /** The config key for whether to show sprite paths. */ + protected static final String SHOW_PATHS_KEY = + 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_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 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/client/SceneViewPanel.java b/src/java/com/threerings/miso/client/SceneViewPanel.java index ce9050382..9ffc45b74 100644 --- a/src/java/com/threerings/miso/client/SceneViewPanel.java +++ b/src/java/com/threerings/miso/client/SceneViewPanel.java @@ -1,5 +1,5 @@ // -// $Id: SceneViewPanel.java,v 1.12 2001/08/23 00:23:58 shaper Exp $ +// $Id: SceneViewPanel.java,v 1.13 2001/08/29 18:41:46 shaper Exp $ package com.threerings.miso.scene; @@ -7,13 +7,15 @@ import java.awt.*; import java.util.List; import javax.swing.*; +import com.samskivert.util.Config; import com.threerings.media.sprite.*; import com.threerings.media.tile.TileManager; +import com.threerings.miso.util.MisoUtil; /** - * The SceneViewPanel class is responsible for managing a - * SceneView, rendering it to the screen, and handling - * view-related UI events. + * The scene view panel is responsible for managing a {@link + * SceneView}, rendering it to the screen, and handling view-related + * UI events. */ public class SceneViewPanel extends JPanel implements AnimatedView @@ -21,13 +23,11 @@ public class SceneViewPanel /** * Construct the panel and initialize it with a context. */ - public SceneViewPanel (TileManager tilemgr, SpriteManager spritemgr) + public SceneViewPanel (Config config, TileManager tilemgr, + SpriteManager spritemgr) { // create the data model for the scene view - _smodel = new IsoSceneViewModel(); - _smodel.setTileDimensions(TWIDTH, THEIGHT); - _smodel.setBounds((HTILES * TWIDTH), (VTILES * THEIGHT)); - _smodel.setOrigin(_smodel.bounds.width / 2, VOFFSET); + _smodel = new IsoSceneViewModel(config); // create the scene view _view = new IsoSceneView(tilemgr, spritemgr, _smodel); @@ -125,21 +125,6 @@ public class SceneViewPanel return psize; } - /** Tile width in pixels. */ - protected static final int TWIDTH = 64; - - /** Tile height in pixels. */ - protected static final int THEIGHT = 48; - - /** Number of horizontal tiles in the scene. */ - protected static final int HTILES = 10; - - /** Number of vertical tiles in the scene. */ - protected static final int VTILES = 12; - - /** Origin vertical offset in pixels. */ - protected static final int VOFFSET = -(5 * THEIGHT); - /** The offscreen image used for double-buffering. */ protected Image _offimg; diff --git a/src/java/com/threerings/miso/tile/EditableTileSetManager.java b/src/java/com/threerings/miso/tile/EditableTileSetManager.java index 59f932d33..907bbbbc9 100644 --- a/src/java/com/threerings/miso/tile/EditableTileSetManager.java +++ b/src/java/com/threerings/miso/tile/EditableTileSetManager.java @@ -1,5 +1,5 @@ // -// $Id: EditableTileSetManager.java,v 1.9 2001/08/16 23:14:21 mdb Exp $ +// $Id: EditableTileSetManager.java,v 1.10 2001/08/29 18:41:46 shaper Exp $ package com.threerings.miso.tile; @@ -12,6 +12,7 @@ import com.threerings.media.ImageManager; import com.threerings.media.tile.*; import com.threerings.miso.Log; +import com.threerings.miso.util.MisoUtil; /** * Extends general tileset manager functionality to allow reading @@ -26,7 +27,7 @@ public class EditableTileSetManager extends TileSetManagerImpl super.init(config, imgmgr); // load the tilesets from the XML description file - String fname = config.getValue("miso.tilesets", (String)null); + String fname = config.getValue(TILESETS_KEY, (String)null); ArrayList tilesets = null; try { tilesets = new XMLTileSetParser().loadTileSets(fname); @@ -50,4 +51,8 @@ public class EditableTileSetManager extends TileSetManagerImpl Log.info("Adding tileset to cache [tset=" + tset + "]."); } } + + /** The config key for the tileset description file. */ + protected static final String TILESETS_KEY = + MisoUtil.CONFIG_KEY + ".tilesets"; } diff --git a/src/java/com/threerings/miso/tools/xml/XMLSceneRepository.java b/src/java/com/threerings/miso/tools/xml/XMLSceneRepository.java index 005006a0e..c194dfbd8 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.9 2001/08/16 23:14:21 mdb Exp $ +// $Id: XMLSceneRepository.java,v 1.10 2001/08/29 18:41:46 shaper Exp $ package com.threerings.miso.scene.xml; @@ -11,6 +11,7 @@ import com.samskivert.util.Config; import com.threerings.media.tile.TileManager; import com.threerings.miso.Log; import com.threerings.miso.scene.MisoScene; +import com.threerings.miso.util.MisoUtil; /** * The XMLFileSceneRepository provides a mechanism for @@ -35,7 +36,7 @@ public class XMLFileSceneRepository // get path-related information _root = System.getProperty("root", ""); - _sceneRoot = _config.getValue(CFG_SROOT, DEF_SROOT); + _sceneRoot = _config.getValue(SCENEROOT_KEY, DEF_SCENEROOT); // create the parser and writer objects _parser = new XMLSceneParser(_tilemgr); @@ -101,8 +102,9 @@ public class XMLFileSceneRepository protected XMLSceneWriter _writer; /** The config key for the root scene directory. */ - protected static final String CFG_SROOT = "miso.sceneroot"; + protected static final String SCENEROOT_KEY = + MisoUtil.CONFIG_KEY + ".sceneroot"; /** The default root scene directory path. */ - protected static final String DEF_SROOT = "rsrc/scenes"; + protected static final String DEF_SCENEROOT = "rsrc/scenes"; } diff --git a/src/java/com/threerings/miso/util/MisoUtil.java b/src/java/com/threerings/miso/util/MisoUtil.java index 42fad73fd..1c2b57539 100644 --- a/src/java/com/threerings/miso/util/MisoUtil.java +++ b/src/java/com/threerings/miso/util/MisoUtil.java @@ -1,5 +1,5 @@ // -// $Id: MisoUtil.java,v 1.8 2001/08/16 23:14:21 mdb Exp $ +// $Id: MisoUtil.java,v 1.9 2001/08/29 18:41:46 shaper Exp $ package com.threerings.miso.util; @@ -24,6 +24,9 @@ import com.threerings.miso.tile.*; */ public class MisoUtil { + /** The config key prefix for miso properties. */ + public static final String CONFIG_KEY = "miso"; + /** * Populate the config object with miso configuration values. * @@ -31,7 +34,7 @@ public class MisoUtil */ public static void bindProperties (Config config) throws IOException { - config.bindProperties("miso", "rsrc/config/miso/miso"); + config.bindProperties(CONFIG_KEY, "rsrc/config/miso/miso"); } /** @@ -48,7 +51,7 @@ public class MisoUtil { try { XMLFileSceneRepository scenerepo = (XMLFileSceneRepository) - config.instantiateValue("miso.scenerepo", DEF_SCENEREPO); + config.instantiateValue(SCENEREPO_KEY, DEF_SCENEREPO); scenerepo.init(config, tilemgr); return scenerepo; @@ -102,7 +105,7 @@ public class MisoUtil TileSetManagerImpl tilesetmgr = null; try { tilesetmgr = (TileSetManagerImpl) - config.instantiateValue("miso.tilesetmgr", DEF_TILESETMGR); + config.instantiateValue(TILESETMGR_KEY, DEF_TILESETMGR); tilesetmgr.init(config, imgmgr); } catch (Exception e) { @@ -120,4 +123,10 @@ public class MisoUtil /** The default tileset manager class name. */ protected static final String DEF_TILESETMGR = EditableTileSetManager.class.getName(); + + /** The config key for the scene repository class. */ + protected static final String SCENEREPO_KEY = CONFIG_KEY + ".scenerepo"; + + /** The config key for the tileset manager class. */ + protected static final String TILESETMGR_KEY = CONFIG_KEY + ".tilesetmgr"; } diff --git a/tests/src/java/com/threerings/miso/viewer/ViewerApp.java b/tests/src/java/com/threerings/miso/viewer/ViewerApp.java index f6ed531d8..fe87244f7 100644 --- a/tests/src/java/com/threerings/miso/viewer/ViewerApp.java +++ b/tests/src/java/com/threerings/miso/viewer/ViewerApp.java @@ -1,5 +1,5 @@ // -// $Id: ViewerApp.java,v 1.6 2001/08/16 23:14:21 mdb Exp $ +// $Id: ViewerApp.java,v 1.7 2001/08/29 18:41:46 shaper Exp $ package com.threerings.miso.viewer; @@ -53,7 +53,8 @@ public class ViewerApp MisoUtil.bindProperties(config); // load the viewer-specific config info - config.bindProperties("miso-viewer", "rsrc/config/miso/viewer"); + config.bindProperties( + ViewerModel.CONFIG_KEY, "rsrc/config/miso/viewer"); } catch (IOException ioe) { Log.warning("Error loading config information [e=" + ioe + "]."); diff --git a/tests/src/java/com/threerings/miso/viewer/ViewerModel.java b/tests/src/java/com/threerings/miso/viewer/ViewerModel.java new file mode 100644 index 000000000..8a26a9c08 --- /dev/null +++ b/tests/src/java/com/threerings/miso/viewer/ViewerModel.java @@ -0,0 +1,10 @@ +// +// $Id: ViewerModel.java,v 1.1 2001/08/29 18:41:46 shaper Exp $ + +package com.threerings.miso.viewer; + +public class ViewerModel +{ + /** The config key prefix for miso viewer properties. */ + public static final String CONFIG_KEY = "miso-viewer"; +} diff --git a/tests/src/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java b/tests/src/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java index 79cb55167..c006a653a 100644 --- a/tests/src/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java +++ b/tests/src/java/com/threerings/miso/viewer/ViewerSceneViewPanel.java @@ -1,5 +1,5 @@ // -// $Id: ViewerSceneViewPanel.java,v 1.13 2001/08/23 00:23:58 shaper Exp $ +// $Id: ViewerSceneViewPanel.java,v 1.14 2001/08/29 18:41:46 shaper Exp $ package com.threerings.miso.viewer; @@ -26,7 +26,7 @@ public class ViewerSceneViewPanel extends SceneViewPanel public ViewerSceneViewPanel ( ViewerContext ctx, SpriteManager spritemgr, AmbulatorySprite sprite) { - super(ctx.getTileManager(), spritemgr); + super(ctx.getConfig(), ctx.getTileManager(), spritemgr); _ctx = ctx; _sprite = sprite; @@ -41,9 +41,6 @@ public class ViewerSceneViewPanel extends SceneViewPanel // load up the initial scene prepareStartingScene(); - _smodel.setShowCoordinates(true); - _smodel.setShowSpritePaths(true); - PerformanceMonitor.register(this, "paint", 1000); } @@ -56,7 +53,7 @@ public class ViewerSceneViewPanel extends SceneViewPanel // get the starting scene filename Config config = _ctx.getConfig(); - String fname = config.getValue(CFG_SCENE, DEF_SCENE); + String fname = config.getValue(SCENE_KEY, DEF_SCENE); try { // load and set up the scene @@ -104,7 +101,8 @@ public class ViewerSceneViewPanel extends SceneViewPanel public void mouseDragged (MouseEvent e) { } /** The config key to obtain the default scene filename. */ - protected static final String CFG_SCENE = "miso-viewer.default_scene"; + protected static final String SCENE_KEY = + ViewerModel.CONFIG_KEY + ".default_scene"; /** The default scene to load and display. */ protected static final String DEF_SCENE = "rsrc/scenes/default.xml";