Moved much of the IsoSceneView data into the IsoSceneModel. More work

on sprites and animation.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@138 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-08-02 00:42:02 +00:00
parent ad506a13d5
commit 1032b8f325
14 changed files with 795 additions and 177 deletions
@@ -1,5 +1,5 @@
//
// $Id: SceneViewPanel.java,v 1.4 2001/07/31 01:38:28 shaper Exp $
// $Id: SceneViewPanel.java,v 1.5 2001/08/02 00:42:02 shaper Exp $
package com.threerings.miso.viewer;
@@ -14,13 +14,15 @@ import com.threerings.miso.viewer.util.ViewerContext;
import com.threerings.miso.scene.*;
import com.threerings.miso.scene.xml.XMLFileSceneRepository;
import com.threerings.miso.sprite.*;
import com.threerings.miso.util.PerformanceMonitor;
import com.threerings.miso.util.PerformanceObserver;
/**
* The SceneViewPanel class is responsible for managing a SceneView,
* rendering it to the screen, and handling view-related UI events.
*/
public class SceneViewPanel extends JPanel
implements MouseListener, MouseMotionListener
implements MouseListener, MouseMotionListener, PerformanceObserver
{
/**
* Construct the panel and initialize it with a context.
@@ -33,7 +35,12 @@ public class SceneViewPanel extends JPanel
_sprite = sprite;
// construct the view object
_view = new IsoSceneView(_ctx.getTileManager(), spritemgr);
_view = new IsoSceneView(_ctx.getTileManager(), spritemgr,
new IsoSceneModel());
// create an animation manager for this panel
AnimationManager animmgr =
new AnimationManager(spritemgr, this, _view);
// listen to the desired events
addMouseListener(this);
@@ -41,6 +48,10 @@ public class SceneViewPanel extends JPanel
// load up the initial scene
prepareStartingScene();
setDoubleBuffered(false);
PerformanceMonitor.register(this, "paint", 1000);
}
/**
@@ -76,10 +87,24 @@ public class SceneViewPanel extends JPanel
/**
* Render the panel and the scene view to the given graphics object.
*/
public void paint (Graphics g)
public void paintComponent (Graphics g)
{
super.paint(g);
Rectangle bounds = getBounds();
// Log.info("SceneViewPanel: paint [width=" + bounds.width +
// ", height=" + bounds.height + "].");
_view.paint(g);
g.setColor(Color.yellow);
g.drawRect(0, 0, 600, 600);
PerformanceMonitor.tick(this, "paint");
}
public void checkpoint (String name, int ticks)
{
Log.info(name + "[ticks=" + ticks + "].");
}
/** MouseListener interface methods */
@@ -1,5 +1,5 @@
//
// $Id: ViewerApp.java,v 1.2 2001/07/28 01:31:51 shaper Exp $
// $Id: ViewerApp.java,v 1.3 2001/08/02 00:42:02 shaper Exp $
package com.threerings.miso.viewer;
@@ -103,7 +103,7 @@ public class ViewerApp
/** The desired width and height for the main application window. */
protected static final int WIDTH = 800;
protected static final int HEIGHT = 600;
protected static final int HEIGHT = 622;
/** The config object. */
protected Config _config;
@@ -1,5 +1,5 @@
//
// $Id: ViewerFrame.java,v 1.4 2001/07/31 01:38:28 shaper Exp $
// $Id: ViewerFrame.java,v 1.5 2001/08/02 00:42:02 shaper Exp $
package com.threerings.miso.viewer;
@@ -41,16 +41,13 @@ class ViewerFrame extends JFrame implements WindowListener
TileManager tilemgr = _ctx.getTileManager();
// add the test character sprite to the sprite manager
MobileSprite ms = new MobileSprite(300, 300, tilemgr, TSID_CHAR);
//ms.setAnimationDelay(10);
MobileSprite ms =
new MobileSprite(spritemgr, 300, 300, tilemgr, TSID_CHAR);
spritemgr.addSprite(ms);
// set up the scene view panel with a default scene
SceneViewPanel svpanel = new SceneViewPanel(_ctx, spritemgr, ms);
// create the animation manager for this panel
AnimationManager animmgr = new AnimationManager(spritemgr, svpanel);
// add the scene view panel
getContentPane().add(svpanel, BorderLayout.CENTER);
}