Created base SceneViewPanel that the editor and viewer apps extend.
Added fringe layer to scenes. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@176 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AnimationManager.java,v 1.5 2001/08/02 23:12:19 shaper Exp $
|
// $Id: AnimationManager.java,v 1.6 2001/08/04 01:41:02 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.sprite;
|
package com.threerings.miso.sprite;
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ public class AnimationManager implements Interval, PerformanceObserver
|
|||||||
_view.invalidateRects(rects);
|
_view.invalidateRects(rects);
|
||||||
|
|
||||||
// update frame-rate information
|
// update frame-rate information
|
||||||
PerformanceMonitor.tick(AnimationManager.this, "refresh");
|
//PerformanceMonitor.tick(AnimationManager.this, "refresh");
|
||||||
|
|
||||||
// refresh the display
|
// refresh the display
|
||||||
_target.paintImmediately(_target.getBounds());
|
_target.paintImmediately(_target.getBounds());
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DisplayMisoSceneImpl.java,v 1.16 2001/08/02 18:58:59 shaper Exp $
|
// $Id: DisplayMisoSceneImpl.java,v 1.17 2001/08/04 01:41:02 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -22,10 +22,13 @@ public class Scene
|
|||||||
public static final int LAYER_BASE = 0;
|
public static final int LAYER_BASE = 0;
|
||||||
|
|
||||||
/** The object layer id. */
|
/** The object layer id. */
|
||||||
public static final int LAYER_OBJECT = 1;
|
public static final int LAYER_FRINGE = 1;
|
||||||
|
|
||||||
|
/** The object layer id. */
|
||||||
|
public static final int LAYER_OBJECT = 2;
|
||||||
|
|
||||||
/** The total number of layers. */
|
/** The total number of layers. */
|
||||||
public static final int NUM_LAYERS = 2;
|
public static final int NUM_LAYERS = 3;
|
||||||
|
|
||||||
/** The latest scene file format version. */
|
/** The latest scene file format version. */
|
||||||
public static final short VERSION = 1;
|
public static final short VERSION = 1;
|
||||||
@@ -37,7 +40,7 @@ public class Scene
|
|||||||
public static final int TILE_HEIGHT = 22;
|
public static final int TILE_HEIGHT = 22;
|
||||||
|
|
||||||
/** String translations of each tile layer name. */
|
/** String translations of each tile layer name. */
|
||||||
public static final String[] XLATE_LAYERS = { "Base", "Object" };
|
public static final String[] XLATE_LAYERS = { "Base", "Fringe", "Object" };
|
||||||
|
|
||||||
/** Scene id to denote an unset or otherwise invalid scene id. */
|
/** Scene id to denote an unset or otherwise invalid scene id. */
|
||||||
public static final short SID_INVALID = -1;
|
public static final short SID_INVALID = -1;
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
//
|
||||||
|
// $Id: SceneViewPanel.java,v 1.1 2001/08/04 01:41:02 shaper Exp $
|
||||||
|
|
||||||
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import com.threerings.miso.sprite.SpriteManager;
|
||||||
|
import com.threerings.miso.tile.TileManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The <code>SceneViewPanel</code> class is responsible for managing a
|
||||||
|
* <code>SceneView</code>, rendering it to the screen, and handling
|
||||||
|
* view-related UI events.
|
||||||
|
*/
|
||||||
|
public class SceneViewPanel extends JPanel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Construct the panel and initialize it with a context.
|
||||||
|
*/
|
||||||
|
public SceneViewPanel (TileManager tilemgr, SpriteManager spritemgr)
|
||||||
|
{
|
||||||
|
// create the data model for the scene view
|
||||||
|
_smodel = new IsoSceneModel();
|
||||||
|
_smodel.setTileDimensions(TWIDTH, THEIGHT);
|
||||||
|
_smodel.setBounds((HTILES * TWIDTH), (VTILES * THEIGHT));
|
||||||
|
_smodel.setOrigin(_smodel.bounds.width / 2, VOFFSET);
|
||||||
|
|
||||||
|
// create the scene view
|
||||||
|
_view = new IsoSceneView(tilemgr, spritemgr, _smodel);
|
||||||
|
|
||||||
|
// set our attributes for optimal display performance
|
||||||
|
setDoubleBuffered(false);
|
||||||
|
setOpaque(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the scene managed by the panel.
|
||||||
|
*/
|
||||||
|
public void setScene (Scene scene)
|
||||||
|
{
|
||||||
|
_view.setScene(scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the panel and the scene view to the given graphics object.
|
||||||
|
*/
|
||||||
|
public void paintComponent (Graphics g)
|
||||||
|
{
|
||||||
|
super.paintComponent(g);
|
||||||
|
_view.paint(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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 scene data model. */
|
||||||
|
protected IsoSceneModel _smodel;
|
||||||
|
|
||||||
|
/** The scene view we're managing. */
|
||||||
|
protected SceneView _view;
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
<row rownum="21">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
<row rownum="21">1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10,1004,10</row>
|
||||||
</layer>
|
</layer>
|
||||||
<layer lnum="1"></layer>
|
<layer lnum="1"></layer>
|
||||||
|
<layer lnum="2"></layer>
|
||||||
</tiles>
|
</tiles>
|
||||||
</scene>
|
</scene>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ViewerFrame.java,v 1.6 2001/08/02 21:02:57 shaper Exp $
|
// $Id: ViewerFrame.java,v 1.7 2001/08/04 01:41:02 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.viewer;
|
package com.threerings.miso.viewer;
|
||||||
|
|
||||||
@@ -25,7 +25,6 @@ class ViewerFrame extends JFrame implements WindowListener
|
|||||||
public ViewerFrame ()
|
public ViewerFrame ()
|
||||||
{
|
{
|
||||||
super("Scene Viewer");
|
super("Scene Viewer");
|
||||||
|
|
||||||
addWindowListener(this);
|
addWindowListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,8 +44,16 @@ class ViewerFrame extends JFrame implements WindowListener
|
|||||||
new AmbulatorySprite(spritemgr, 300, 300, tilemgr, TSID_CHAR);
|
new AmbulatorySprite(spritemgr, 300, 300, tilemgr, TSID_CHAR);
|
||||||
spritemgr.addSprite(sprite);
|
spritemgr.addSprite(sprite);
|
||||||
|
|
||||||
|
// create a top-level panel to manage everything
|
||||||
|
JPanel top = new JPanel();
|
||||||
|
GroupLayout gl = new HGroupLayout(GroupLayout.STRETCH);
|
||||||
|
gl.setOffAxisPolicy(GroupLayout.STRETCH);
|
||||||
|
top.setLayout(gl);
|
||||||
|
|
||||||
// set up the scene view panel with a default scene
|
// set up the scene view panel with a default scene
|
||||||
SceneViewPanel svpanel = new SceneViewPanel(_ctx, spritemgr, sprite);
|
ViewerSceneViewPanel svpanel =
|
||||||
|
new ViewerSceneViewPanel(_ctx, spritemgr, sprite);
|
||||||
|
top.add(svpanel, GroupLayout.FIXED);
|
||||||
|
|
||||||
// add the scene view panel
|
// add the scene view panel
|
||||||
getContentPane().add(svpanel, BorderLayout.CENTER);
|
getContentPane().add(svpanel, BorderLayout.CENTER);
|
||||||
@@ -69,7 +76,7 @@ class ViewerFrame extends JFrame implements WindowListener
|
|||||||
protected static final int TSID_CHAR = 1003;
|
protected static final int TSID_CHAR = 1003;
|
||||||
|
|
||||||
/** The panel displaying the scene. */
|
/** The panel displaying the scene. */
|
||||||
SceneViewPanel _svpanel;
|
ViewerSceneViewPanel _svpanel;
|
||||||
|
|
||||||
/** The context object. */
|
/** The context object. */
|
||||||
protected ViewerContext _ctx;
|
protected ViewerContext _ctx;
|
||||||
|
|||||||
+8
-50
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SceneViewPanel.java,v 1.8 2001/08/02 23:12:19 shaper Exp $
|
// $Id: ViewerSceneViewPanel.java,v 1.1 2001/08/04 01:41:02 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.viewer;
|
package com.threerings.miso.viewer;
|
||||||
|
|
||||||
@@ -14,38 +14,25 @@ import com.threerings.miso.viewer.util.ViewerContext;
|
|||||||
import com.threerings.miso.scene.*;
|
import com.threerings.miso.scene.*;
|
||||||
import com.threerings.miso.scene.xml.XMLFileSceneRepository;
|
import com.threerings.miso.scene.xml.XMLFileSceneRepository;
|
||||||
import com.threerings.miso.sprite.*;
|
import com.threerings.miso.sprite.*;
|
||||||
import com.threerings.miso.util.PerformanceMonitor;
|
import com.threerings.miso.util.*;
|
||||||
import com.threerings.miso.util.PerformanceObserver;
|
|
||||||
|
|
||||||
/**
|
public class ViewerSceneViewPanel extends SceneViewPanel
|
||||||
* The <code>SceneViewPanel</code> class is responsible for managing a
|
|
||||||
* <code>SceneView</code>, rendering it to the screen, and handling
|
|
||||||
* view-related UI events.
|
|
||||||
*/
|
|
||||||
public class SceneViewPanel extends JPanel
|
|
||||||
implements MouseListener, MouseMotionListener, PerformanceObserver
|
implements MouseListener, MouseMotionListener, PerformanceObserver
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Construct the panel and initialize it with a context.
|
* Construct the panel and initialize it with a context.
|
||||||
*/
|
*/
|
||||||
public SceneViewPanel (ViewerContext ctx, SpriteManager spritemgr,
|
public ViewerSceneViewPanel (
|
||||||
Sprite sprite)
|
ViewerContext ctx, SpriteManager spritemgr, Sprite sprite)
|
||||||
{
|
{
|
||||||
|
super(ctx.getTileManager(), spritemgr);
|
||||||
|
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
|
||||||
_sprite = sprite;
|
_sprite = sprite;
|
||||||
|
|
||||||
// construct the view object
|
|
||||||
IsoSceneModel smodel = new IsoSceneModel();
|
|
||||||
smodel.setTileDimensions(64, 48);
|
|
||||||
smodel.setBounds((10 * 64), (12 * 48));
|
|
||||||
smodel.setOrigin(320, -(5 * 48));
|
|
||||||
|
|
||||||
_view = new IsoSceneView(_ctx.getTileManager(), spritemgr, smodel);
|
|
||||||
|
|
||||||
// create an animation manager for this panel
|
// create an animation manager for this panel
|
||||||
AnimationManager animmgr =
|
AnimationManager animmgr =
|
||||||
new AnimationManager(spritemgr, this, _view);
|
new AnimationManager(spritemgr, this, _view);
|
||||||
|
|
||||||
// listen to the desired events
|
// listen to the desired events
|
||||||
addMouseListener(this);
|
addMouseListener(this);
|
||||||
@@ -54,9 +41,6 @@ public class SceneViewPanel extends JPanel
|
|||||||
// load up the initial scene
|
// load up the initial scene
|
||||||
prepareStartingScene();
|
prepareStartingScene();
|
||||||
|
|
||||||
setDoubleBuffered(false);
|
|
||||||
setOpaque(true);
|
|
||||||
|
|
||||||
PerformanceMonitor.register(this, "paint", 1000);
|
PerformanceMonitor.register(this, "paint", 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,29 +66,6 @@ public class SceneViewPanel extends JPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the scene managed by the panel.
|
|
||||||
*/
|
|
||||||
public void setScene (Scene scene)
|
|
||||||
{
|
|
||||||
_view.setScene(scene);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the panel and the scene view to the given graphics object.
|
|
||||||
*/
|
|
||||||
public void paintComponent (Graphics g)
|
|
||||||
{
|
|
||||||
Rectangle bounds = getBounds();
|
|
||||||
|
|
||||||
// Log.info("SceneViewPanel: paint [width=" + bounds.width +
|
|
||||||
// ", height=" + bounds.height + "].");
|
|
||||||
|
|
||||||
_view.paint(g);
|
|
||||||
|
|
||||||
PerformanceMonitor.tick(this, "paint");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkpoint (String name, int ticks)
|
public void checkpoint (String name, int ticks)
|
||||||
{
|
{
|
||||||
Log.info(name + " [ticks=" + ticks + "].");
|
Log.info(name + " [ticks=" + ticks + "].");
|
||||||
@@ -148,7 +109,4 @@ public class SceneViewPanel extends JPanel
|
|||||||
|
|
||||||
/** The context object. */
|
/** The context object. */
|
||||||
protected ViewerContext _ctx;
|
protected ViewerContext _ctx;
|
||||||
|
|
||||||
/** The scene view we're managing. */
|
|
||||||
protected SceneView _view;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user