Added support for animations to the animation manager. Moved animation
classes into their own package. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@849 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
//
|
||||
// $Id: IsoSceneView.java,v 1.82 2002/01/08 22:16:59 shaper Exp $
|
||||
// $Id: IsoSceneView.java,v 1.83 2002/01/11 16:17:34 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Point;
|
||||
import java.awt.Font;
|
||||
import java.awt.BasicStroke;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
|
||||
import com.threerings.media.sprite.DirtyRectList;
|
||||
import com.threerings.media.animation.AnimationManager;
|
||||
import com.threerings.media.sprite.Path;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
|
||||
@@ -45,14 +45,19 @@ public class IsoSceneView implements SceneView
|
||||
/**
|
||||
* Constructs an iso scene view.
|
||||
*
|
||||
* @param animmgr the animation manager.
|
||||
* @param spritemgr the sprite manager.
|
||||
* @param model the data model.
|
||||
*/
|
||||
public IsoSceneView (SpriteManager spritemgr, IsoSceneViewModel model)
|
||||
public IsoSceneView (AnimationManager animmgr, SpriteManager spritemgr,
|
||||
IsoSceneViewModel model)
|
||||
{
|
||||
// save off references
|
||||
_animmgr = animmgr;
|
||||
_spritemgr = spritemgr;
|
||||
|
||||
_model = model;
|
||||
|
||||
// give the model a chance to pre-calculate various things
|
||||
_model.precalculate();
|
||||
|
||||
// create our polygon arrays and create polygons for each of the
|
||||
@@ -106,6 +111,9 @@ public class IsoSceneView implements SceneView
|
||||
// render the scene to the graphics context
|
||||
renderScene(gfx);
|
||||
|
||||
// render any animations
|
||||
_animmgr.renderAnimations(gfx);
|
||||
|
||||
// draw frames of dirty tiles and rectangles
|
||||
// drawDirtyRegions(gfx);
|
||||
|
||||
@@ -366,7 +374,7 @@ public class IsoSceneView implements SceneView
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void invalidateRects (DirtyRectList rects)
|
||||
public void invalidateRects (List rects)
|
||||
{
|
||||
int size = rects.size();
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
@@ -625,4 +633,7 @@ public class IsoSceneView implements SceneView
|
||||
|
||||
/** The sprite manager. */
|
||||
protected SpriteManager _spritemgr;
|
||||
|
||||
/** The animation manager. */
|
||||
protected AnimationManager _animmgr;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneView.java,v 1.21 2002/01/08 22:16:59 shaper Exp $
|
||||
// $Id: SceneView.java,v 1.22 2002/01/11 16:17:34 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import com.threerings.media.sprite.DirtyRectList;
|
||||
import com.threerings.media.sprite.Path;
|
||||
|
||||
/**
|
||||
@@ -24,7 +23,7 @@ public interface SceneView
|
||||
*
|
||||
* @param rects the list of {@link java.awt.Rectangle} objects.
|
||||
*/
|
||||
public void invalidateRects (DirtyRectList rects);
|
||||
public void invalidateRects (List rects);
|
||||
|
||||
/**
|
||||
* Invalidate a rectangle in screen pixel coordinates in the scene
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneViewPanel.java,v 1.22 2002/01/08 22:16:59 shaper Exp $
|
||||
// $Id: SceneViewPanel.java,v 1.23 2002/01/11 16:17:34 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -7,10 +7,12 @@ import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.samskivert.util.Config;
|
||||
|
||||
import com.threerings.media.sprite.AnimatedPanel;
|
||||
import com.threerings.media.sprite.DirtyRectList;
|
||||
import com.threerings.media.animation.AnimationManager;
|
||||
import com.threerings.media.animation.AnimatedPanel;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
import com.threerings.miso.util.MisoUtil;
|
||||
|
||||
@@ -27,6 +29,12 @@ public class SceneViewPanel extends AnimatedPanel
|
||||
*/
|
||||
public SceneViewPanel (Config config, SpriteManager spritemgr)
|
||||
{
|
||||
// save off references
|
||||
_spritemgr = spritemgr;
|
||||
|
||||
// create an animation manager for this panel
|
||||
_animmgr = new AnimationManager(_spritemgr, this);
|
||||
|
||||
// create the data model for the scene view
|
||||
_viewmodel = new IsoSceneViewModel(config);
|
||||
|
||||
@@ -35,7 +43,7 @@ public class SceneViewPanel extends AnimatedPanel
|
||||
_viewmodel.addListener(this);
|
||||
|
||||
// create the scene view
|
||||
_view = newSceneView(spritemgr, _viewmodel);
|
||||
_view = newSceneView(_animmgr, spritemgr, _viewmodel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,9 +58,9 @@ public class SceneViewPanel extends AnimatedPanel
|
||||
* Constructs the underlying scene view implementation.
|
||||
*/
|
||||
protected IsoSceneView newSceneView (
|
||||
SpriteManager smgr, IsoSceneViewModel model)
|
||||
AnimationManager amgr, SpriteManager smgr, IsoSceneViewModel model)
|
||||
{
|
||||
return new IsoSceneView(smgr, model);
|
||||
return new IsoSceneView(amgr, smgr, model);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +86,7 @@ public class SceneViewPanel extends AnimatedPanel
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void invalidateRects (DirtyRectList rects)
|
||||
public void invalidateRects (List rects)
|
||||
{
|
||||
// pass the invalid rects on to our scene view
|
||||
_view.invalidateRects(rects);
|
||||
@@ -113,4 +121,10 @@ public class SceneViewPanel extends AnimatedPanel
|
||||
|
||||
/** The scene view we're managing. */
|
||||
protected SceneView _view;
|
||||
|
||||
/** A reference to the active sprite manager. */
|
||||
protected SpriteManager _spritemgr;
|
||||
|
||||
/** A reference to the active animation manager. */
|
||||
protected AnimationManager _animmgr;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SwingSceneViewPanel.java,v 1.1 2002/01/08 22:19:29 shaper Exp $
|
||||
// $Id: SwingSceneViewPanel.java,v 1.2 2002/01/11 16:17:34 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -10,11 +10,14 @@ import java.awt.Rectangle;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.samskivert.util.Config;
|
||||
|
||||
import com.threerings.media.sprite.AnimatedPanel;
|
||||
import com.threerings.media.sprite.DirtyRectList;
|
||||
import com.threerings.media.animation.AnimatedView;
|
||||
import com.threerings.media.animation.AnimationManager;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
|
||||
import com.threerings.miso.util.MisoUtil;
|
||||
|
||||
/**
|
||||
@@ -30,7 +33,7 @@ import com.threerings.miso.util.MisoUtil;
|
||||
* do not depend on use of the animation manager to refresh the display.
|
||||
*/
|
||||
public class SwingSceneViewPanel extends JComponent
|
||||
implements IsoSceneViewModelListener
|
||||
implements AnimatedView, IsoSceneViewModelListener
|
||||
{
|
||||
/**
|
||||
* Constructs the scene view panel.
|
||||
@@ -44,8 +47,11 @@ public class SwingSceneViewPanel extends JComponent
|
||||
// the scene display has changed and needs must be repainted
|
||||
_viewmodel.addListener(this);
|
||||
|
||||
// create an animation manager for this panel
|
||||
AnimationManager animmgr = new AnimationManager(spritemgr, this);
|
||||
|
||||
// create the scene view
|
||||
_view = newSceneView(spritemgr, _viewmodel);
|
||||
_view = newSceneView(animmgr, spritemgr, _viewmodel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,9 +66,9 @@ public class SwingSceneViewPanel extends JComponent
|
||||
* Constructs the underlying scene view implementation.
|
||||
*/
|
||||
protected IsoSceneView newSceneView (
|
||||
SpriteManager smgr, IsoSceneViewModel model)
|
||||
AnimationManager amgr, SpriteManager smgr, IsoSceneViewModel model)
|
||||
{
|
||||
return new IsoSceneView(smgr, model);
|
||||
return new IsoSceneView(amgr, smgr, model);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +95,7 @@ public class SwingSceneViewPanel extends JComponent
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void invalidateRects (DirtyRectList rects)
|
||||
public void invalidateRects (List rects)
|
||||
{
|
||||
// pass the invalid rects on to our scene view
|
||||
_view.invalidateRects(rects);
|
||||
@@ -101,6 +107,12 @@ public class SwingSceneViewPanel extends JComponent
|
||||
_view.invalidateRect(rect);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void paintImmediately ()
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the desired size for the panel based on the requested
|
||||
* and calculated bounds of the scene view.
|
||||
|
||||
Reference in New Issue
Block a user