General updating per initial code review. Created EditableSceneView

to separate scene display from editing functionality.  Load and
initialize managers in a fashion that more appropriately hides the
implementation details.  Tidied comments up a bit.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@103 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-23 18:52:51 +00:00
parent 00388caaa5
commit 2572535f95
19 changed files with 210 additions and 252 deletions
@@ -1,15 +1,8 @@
//
// $Id: CompiledSceneManager.java,v 1.4 2001/07/20 08:08:59 shaper Exp $
// $Id: CompiledSceneManager.java,v 1.5 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.scene;
import java.io.InputStream;
import java.io.IOException;
public class CompiledSceneManager extends SceneManagerImpl
{
public void loadScenes (InputStream in) throws IOException
{
}
}
@@ -1,5 +1,5 @@
//
// $Id: DisplayMisoSceneImpl.java,v 1.8 2001/07/20 07:09:56 shaper Exp $
// $Id: DisplayMisoSceneImpl.java,v 1.9 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.scene;
@@ -43,18 +43,6 @@ public class Scene
}
}
}
_file = null;
}
public File getFile ()
{
return _file;
}
public void setFile (File file)
{
_file = file;
}
/**
@@ -225,7 +213,5 @@ public class Scene
protected Point _hotspots[]; // hot spot zone points
protected ExitPoint _exits[]; // exit points to different scenes
protected File _file; // the file last associated with this scene
protected TileManager _tmgr;
}
@@ -1,15 +1,8 @@
//
// $Id: EditableSceneManager.java,v 1.4 2001/07/20 08:08:59 shaper Exp $
// $Id: EditableSceneManager.java,v 1.5 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.scene;
import java.io.InputStream;
import java.io.IOException;
public class EditableSceneManager extends SceneManagerImpl
{
public void loadScenes (InputStream in) throws IOException
{
}
}
@@ -1,13 +1,17 @@
//
// $Id: ExitPoint.java,v 1.2 2001/07/18 21:45:42 shaper Exp $
// $Id: ExitPoint.java,v 1.3 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.scene;
/**
* Represents a point in a scene that leads to a different scene.
* The ExitPoint class represents a point in a scene that leads to a
* different scene.
*/
public class ExitPoint
{
byte x, y; // coordinates for this exit point
short sid; // scene id this exit transitions to
/** Coordinates for this exit point. */
public byte x, y;
/** The scene id this exit transitions to. */
public short sid;
}
@@ -1,5 +1,5 @@
//
// $Id: IsoSceneView.java,v 1.13 2001/07/20 08:17:10 shaper Exp $
// $Id: IsoSceneView.java,v 1.14 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.scene;
@@ -15,7 +15,7 @@ import java.awt.image.*;
* The IsoSceneView provides an isometric graphics view of a
* particular scene.
*/
public class IsoSceneView implements SceneView
public class IsoSceneView implements EditableSceneView
{
public IsoSceneView (TileManager tmgr)
{
@@ -246,19 +246,23 @@ public class IsoSceneView implements SceneView
_scene.tiles[tpos.x][tpos.y][lnum] = tile;
}
// default dimensions of the scene view
/** The default width of a scene in pixels. */
protected static final int DEF_BOUNDS_WIDTH = 18 * Tile.WIDTH;
/** The default height of a scene in pixels. */
protected static final int DEF_BOUNDS_HEIGHT = 37 * Tile.HEIGHT;
// total number of tile rows to render the full view
/** The total number of tile rows to render the full scene view. */
protected static final int TILE_RENDER_ROWS =
(Scene.TILE_WIDTH * Scene.TILE_HEIGHT) - 1;
// starting x/y-positions to render the view
/** The starting x-position to render the view. */
protected static final int DEF_CENTER_X = DEF_BOUNDS_WIDTH / 2;
/** The starting y-position to render the view. */
protected static final int DEF_CENTER_Y = -(9 * Tile.HEIGHT);
// length of a tile edge as rendered from an isometric perspective
/** The length of a tile edge as rendered from an isometric perspective. */
public static final float TILE_EDGE_LENGTH = (float)
Math.sqrt((Tile.HALF_WIDTH * Tile.HALF_WIDTH) +
(Tile.HALF_HEIGHT * Tile.HALF_HEIGHT));
@@ -1,5 +1,5 @@
//
// $Id: SceneManager.java,v 1.4 2001/07/20 08:08:59 shaper Exp $
// $Id: SceneManager.java,v 1.5 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.scene;
@@ -22,16 +22,4 @@ public interface SceneManager
* layer id.
*/
public String[] getLayerNames ();
/**
* Load all scene objects described in the specified file into the
* set of available scenes.
*/
public void loadScenes (String fname);
/**
* Load all scene objects described in the specified input stream
* into the set of available scenes.
*/
public void loadScenes (InputStream in) throws IOException;
}
@@ -1,5 +1,5 @@
//
// $Id: SceneManagerImpl.java,v 1.4 2001/07/20 08:08:59 shaper Exp $
// $Id: SceneManagerImpl.java,v 1.5 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.scene;
@@ -22,21 +22,4 @@ public abstract class SceneManagerImpl implements SceneManager
{
return Scene.XLATE_LAYERS;
}
public void loadScenes (String fname)
{
try {
InputStream tis = ConfigUtil.getStream(fname);
if (tis == null) {
Log.warning("Couldn't find file [fname=" + fname + "].");
return;
}
loadScenes(tis);
} catch (IOException ioe) {
Log.warning("Exception loading tileset [fname=" + fname +
", ioe=" + ioe + "].");
}
}
}
@@ -1,5 +1,5 @@
//
// $Id: SceneView.java,v 1.6 2001/07/20 00:35:09 shaper Exp $
// $Id: SceneView.java,v 1.7 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.scene;
@@ -9,9 +9,9 @@ import java.awt.Component;
import java.awt.Graphics;
/**
* An interface to be implemented by classes that provide a view of a
* given scene by drawing the scene contents onto a particular GUI
* component.
* The SceneView interface provides an interface to be implemented by
* classes that provide a view of a given scene by drawing the scene
* contents onto a particular GUI component.
*/
public interface SceneView
{
@@ -20,23 +20,8 @@ public interface SceneView
*/
public void paint (Graphics g);
/**
* Set a tile to be highlighted when the scene is rendered.
*/
public void setHighlightedTile (int x, int y);
/**
* Set the scene that we're rendering.
*/
public void setScene (Scene scene);
/**
* Set whether coordinates should be drawn for each tile.
*/
public void setShowCoordinates (boolean show);
/**
* Set the tile at the specified location and layer in the scene.
*/
public void setTile (int x, int y, int lnum, Tile tile);
}