Revised various iso scene view debug rendering options to be accessible

via the runtime adjustments.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2159 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2003-01-15 21:12:45 +00:00
parent cb9daa9f41
commit 90480544e1
3 changed files with 35 additions and 103 deletions
@@ -1,5 +1,5 @@
// //
// $Id: IsoSceneView.java,v 1.129 2003/01/15 04:25:45 shaper Exp $ // $Id: IsoSceneView.java,v 1.130 2003/01/15 21:12:45 shaper Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
@@ -168,7 +168,7 @@ public class IsoSceneView implements SceneView
renderDirtyItems(gfx, dirtyRect); renderDirtyItems(gfx, dirtyRect);
// draw sprite paths // draw sprite paths
if (_model.showPaths) { if (_pathsDebug.getValue()) {
_spritemgr.renderSpritePaths(gfx); _spritemgr.renderSpritePaths(gfx);
} }
@@ -239,13 +239,12 @@ public class IsoSceneView implements SceneView
// if we're showing coordinates, we need to do some setting up // if we're showing coordinates, we need to do some setting up
int thw = 0, thh = 0, fhei = 0; int thw = 0, thh = 0, fhei = 0;
FontMetrics fm = null; FontMetrics fm = null;
if (_model.showCoords) { if (_coordsDebug.getValue()) {
fm = gfx.getFontMetrics(_font); fm = gfx.getFontMetrics(_font);
fhei = fm.getAscent(); fhei = fm.getAscent();
thw = _model.tilehwid; thw = _model.tilehwid;
thh = _model.tilehhei; thh = _model.tilehhei;
gfx.setFont(_font); gfx.setFont(_font);
gfx.setColor(Color.white);
} }
// determine which tiles intersect this clipping region: this is // determine which tiles intersect this clipping region: this is
@@ -316,7 +315,7 @@ public class IsoSceneView implements SceneView
passable = ((BaseTile)tile).isPassable(); passable = ((BaseTile)tile).isPassable();
// highlight impassable tiles // highlight impassable tiles
if (_isoRenderDebug.getValue() && !passable) { if (_traverseDebug.getValue() && !passable) {
fillTile(gfx, tx, ty, Color.yellow); fillTile(gfx, tx, ty, Color.yellow);
} }
} }
@@ -326,7 +325,7 @@ public class IsoSceneView implements SceneView
} }
// highlight passable non-traversable tiles // highlight passable non-traversable tiles
if (_isoRenderDebug.getValue() && passable && if (_traverseDebug.getValue() && passable &&
!_scene.canTraverse(null, tx, ty)) { !_scene.canTraverse(null, tx, ty)) {
fillTile(gfx, tx, ty, Color.green); fillTile(gfx, tx, ty, Color.green);
} }
@@ -338,9 +337,8 @@ public class IsoSceneView implements SceneView
} }
// if we're showing coordinates, do that // if we're showing coordinates, do that
if (_model.showCoords) { if (_coordsDebug.getValue()) {
// outline the tile gfx.setColor(Color.white);
// gfx.draw(tpoly);
// get the top-left screen coordinates of the tile // get the top-left screen coordinates of the tile
int sx = _tbounds.x, sy = _tbounds.y; int sx = _tbounds.x, sy = _tbounds.y;
@@ -430,7 +428,7 @@ public class IsoSceneView implements SceneView
// compute the footprint if we're rendering those // compute the footprint if we're rendering those
Polygon foot = null; Polygon foot = null;
if (_model.showFootprints) { if (_fprintDebug.getValue()) {
foot = IsoUtil.getObjectFootprint(_model, scobj); foot = IsoUtil.getObjectFootprint(_model, scobj);
} }
@@ -739,11 +737,32 @@ public class IsoSceneView implements SceneView
/** The stroke object used to draw highlighted tiles and coordinates. */ /** The stroke object used to draw highlighted tiles and coordinates. */
protected BasicStroke _hstroke = new BasicStroke(2); protected BasicStroke _hstroke = new BasicStroke(2);
/** A debug hook that toggles debug rendering in the iso scene view. */ /** A debug hook that toggles debug rendering of traversable tiles. */
protected static RuntimeAdjust.BooleanAdjust _isoRenderDebug = protected static RuntimeAdjust.BooleanAdjust _traverseDebug =
new RuntimeAdjust.BooleanAdjust( new RuntimeAdjust.BooleanAdjust(
"Toggles debug rendering in the iso scene view.", "Toggles debug rendering of traversable and impassable tiles in " +
"narya.miso.iso_debug_render", MisoPrefs.config, false); "the iso scene view.", "narya.miso.iso_traverse_debug_render",
MisoPrefs.config, false);
/** A debug hook that toggles debug rendering of tile coordinates. */
protected static RuntimeAdjust.BooleanAdjust _coordsDebug =
new RuntimeAdjust.BooleanAdjust(
"Toggles debug rendering of tile coordinates in the iso scene " +
"view.", "narya.miso.iso_coords_debug_render",
MisoPrefs.config, false);
/** A debug hook that toggles debug rendering of sprite paths. */
protected static RuntimeAdjust.BooleanAdjust _pathsDebug =
new RuntimeAdjust.BooleanAdjust(
"Toggles debug rendering of sprite paths in the iso scene view.",
"narya.miso.iso_paths_debug_render", MisoPrefs.config, false);
/** A debug hook that toggles debug rendering of object footprints. */
protected static RuntimeAdjust.BooleanAdjust _fprintDebug =
new RuntimeAdjust.BooleanAdjust(
"Toggles debug rendering of object footprints in the iso scene " +
"view.", "narya.miso.iso_fprint_debug_render",
MisoPrefs.config, false);
/** The stroke used to draw dirty rectangles. */ /** The stroke used to draw dirty rectangles. */
protected static final Stroke DIRTY_RECT_STROKE = new BasicStroke(2); protected static final Stroke DIRTY_RECT_STROKE = new BasicStroke(2);
@@ -1,11 +1,10 @@
// //
// $Id: IsoSceneViewModel.java,v 1.26 2002/06/21 00:04:41 mdb Exp $ // $Id: IsoSceneViewModel.java,v 1.27 2003/01/15 21:12:45 shaper Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList;
import com.threerings.miso.Log; import com.threerings.miso.Log;
import com.threerings.miso.MisoConfig; import com.threerings.miso.MisoConfig;
@@ -71,15 +70,6 @@ public class IsoSceneViewModel
/** The slope of the x- and y-axis lines within a tile. */ /** The slope of the x- and y-axis lines within a tile. */
public float fineSlopeX, fineSlopeY; public float fineSlopeX, fineSlopeY;
/** Whether tile coordinates should be drawn. */
public boolean showCoords;
/** Whether sprite paths should be drawn. */
public boolean showPaths;
/** Whether object footprints should be drawn. */
public boolean showFootprints;
/** /**
* Construct an iso scene view model with view parameters as * Construct an iso scene view model with view parameters as
* specified in the given config object. * specified in the given config object.
@@ -107,13 +97,6 @@ public class IsoSceneViewModel
// set the fine coordinate granularity // set the fine coordinate granularity
finegran = MisoConfig.config.getValue(FINE_GRAN_KEY, DEF_FINE_GRAN); finegran = MisoConfig.config.getValue(FINE_GRAN_KEY, DEF_FINE_GRAN);
// set our various flags
showCoords = MisoConfig.config.getValue(
SHOW_COORDS_KEY, DEF_SHOW_COORDS);
showPaths = MisoConfig.config.getValue(SHOW_PATHS_KEY, DEF_SHOW_PATHS);
showFootprints = MisoConfig.config.getValue(
SHOW_FOOTPRINTS_KEY, DEF_SHOW_FOOTPRINTS);
// precalculate various things // precalculate various things
int offy = MisoConfig.config.getValue(SCENE_OFFSET_Y_KEY, DEF_OFFSET_Y); int offy = MisoConfig.config.getValue(SCENE_OFFSET_Y_KEY, DEF_OFFSET_Y);
precalculate(offy); precalculate(offy);
@@ -153,31 +136,6 @@ public class IsoSceneViewModel
precalculate(offy); precalculate(offy);
} }
/**
* Add an iso scene view model listener.
*
* @param l the listener.
*/
public void addListener (IsoSceneViewModelListener l)
{
if (!_listeners.contains(l)) {
_listeners.add(l);
}
}
/**
* Notify all model listeners that the iso scene view model has
* changed.
*/
protected void notifyListeners (int event)
{
int size = _listeners.size();
for (int ii = 0; ii < size; ii++) {
((IsoSceneViewModelListener)_listeners.get(ii)).
viewChanged(event);
}
}
/** /**
* Returns whether the given tile coordinate is a valid coordinate * Returns whether the given tile coordinate is a valid coordinate
* within the scene. * within the scene.
@@ -201,24 +159,6 @@ public class IsoSceneViewModel
fy >= 0 && fy < finegran); fy >= 0 && fy < finegran);
} }
/**
* Toggle whether coordinates should be drawn for each tile.
*/
public void toggleShowCoordinates ()
{
showCoords = !showCoords;
notifyListeners(IsoSceneViewModelListener.SHOW_COORDINATES_CHANGED);
}
/**
* Toggle whether footprints should be drawn for each object tile.
*/
public void toggleShowFootprints ()
{
showFootprints = !showFootprints;
notifyListeners(IsoSceneViewModelListener.SHOW_FOOTPRINTS_CHANGED);
}
/** /**
* Pre-calculate various member data that are commonly used in working * Pre-calculate various member data that are commonly used in working
* with an isometric view. * with an isometric view.
@@ -312,15 +252,6 @@ public class IsoSceneViewModel
/** The config key for scene origin vertical offset in tile count. */ /** The config key for scene origin vertical offset in tile count. */
protected static final String SCENE_OFFSET_Y_KEY = "scene_offset_y"; protected static final String SCENE_OFFSET_Y_KEY = "scene_offset_y";
/** The config key for whether to show tile coordinates. */
protected static final String SHOW_COORDS_KEY = "show_coords";
/** The config key for whether to show sprite paths. */
protected static final String SHOW_PATHS_KEY = "show_paths";
/** The config key for whether to show object tile footprints. */
protected static final String SHOW_FOOTPRINTS_KEY = "show_footprints";
/** Default scene view parameters. */ /** Default scene view parameters. */
protected static final int DEF_TILE_WIDTH = 64; protected static final int DEF_TILE_WIDTH = 64;
protected static final int DEF_TILE_HEIGHT = 48; protected static final int DEF_TILE_HEIGHT = 48;
@@ -330,10 +261,4 @@ public class IsoSceneViewModel
protected static final int DEF_SCENE_WIDTH = 22; protected static final int DEF_SCENE_WIDTH = 22;
protected static final int DEF_SCENE_HEIGHT = 22; protected static final int DEF_SCENE_HEIGHT = 22;
protected static final int DEF_OFFSET_Y = -5; protected static final int DEF_OFFSET_Y = -5;
protected static final boolean DEF_SHOW_COORDS = false;
protected static final boolean DEF_SHOW_PATHS = false;
protected static final boolean DEF_SHOW_FOOTPRINTS = false;
/** The model listeners. */
protected ArrayList _listeners = new ArrayList();
} }
@@ -1,5 +1,5 @@
// //
// $Id: SceneViewPanel.java,v 1.47 2002/12/05 23:06:30 mdb Exp $ // $Id: SceneViewPanel.java,v 1.48 2003/01/15 21:12:45 shaper Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
@@ -30,7 +30,6 @@ import com.threerings.miso.scene.util.IsoUtil;
* UI events. * UI events.
*/ */
public class SceneViewPanel extends VirtualMediaPanel public class SceneViewPanel extends VirtualMediaPanel
implements IsoSceneViewModelListener
{ {
/** /**
* Constructs the scene view panel with the supplied view model. * Constructs the scene view panel with the supplied view model.
@@ -45,10 +44,6 @@ public class SceneViewPanel extends VirtualMediaPanel
// create the data model for the scene view // create the data model for the scene view
_viewmodel = model; _viewmodel = model;
// listen to the iso scene view model to receive notice when
// the scene display has changed and needs must be repainted
_viewmodel.addListener(this);
// create the scene view // create the scene view
_view = newSceneView(_spritemgr, _viewmodel); _view = newSceneView(_spritemgr, _viewmodel);
@@ -171,13 +166,6 @@ public class SceneViewPanel extends VirtualMediaPanel
super.getPreferredSize() : _viewmodel.bounds.getSize(); super.getPreferredSize() : _viewmodel.bounds.getSize();
} }
// documentation inherited
public void viewChanged (int event)
{
// update the scene view display
repaint();
}
/** The scene view data model. */ /** The scene view data model. */
protected IsoSceneViewModel _viewmodel; protected IsoSceneViewModel _viewmodel;