Oh the vast sweeping changes, and they're not even close to complete, but
things compile and most things run so this is a good time to checkpoint. Let me recall: - Refactored the whole scene deal. - Revamped the XML parser stuff (now uses Digester). - Rethought the tile management. - Started tile bundle stuff. - Wrote some tests. - Did a bit of Mike-ification. Onward and moreward. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@621 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: TestApp.java,v 1.4 2001/11/08 02:58:23 mdb Exp $
|
||||
// $Id: TestApp.java,v 1.5 2001/11/18 04:09:20 mdb Exp $
|
||||
|
||||
package com.threerings.cast.builder;
|
||||
package com.threerings.cast.tools.builder;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.swing.JFrame;
|
||||
@@ -10,11 +10,12 @@ import com.samskivert.util.Config;
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
|
||||
import com.threerings.resource.ResourceManager;
|
||||
import com.threerings.media.ImageManager;
|
||||
|
||||
import com.threerings.cast.Log;
|
||||
import com.threerings.cast.CharacterManager;
|
||||
import com.threerings.cast.ComponentRepository;
|
||||
|
||||
import com.threerings.miso.scene.MisoCharacterSprite;
|
||||
import com.threerings.miso.util.MisoUtil;
|
||||
|
||||
public class TestApp
|
||||
@@ -29,10 +30,11 @@ public class TestApp
|
||||
_config = MisoUtil.createConfig();
|
||||
|
||||
ResourceManager rsrcmgr = new ResourceManager("rsrc");
|
||||
_imgmgr = new ImageManager(rsrcmgr, _frame);
|
||||
|
||||
CharacterManager charmgr =
|
||||
MisoUtil.createCharacterManager(_config, _imgmgr);
|
||||
// TBD: sort out component repository
|
||||
ComponentRepository crepo = null;
|
||||
CharacterManager charmgr = new CharacterManager(crepo);
|
||||
charmgr.setCharacterClass(MisoCharacterSprite.class);
|
||||
|
||||
// initialize the frame
|
||||
((TestFrame)_frame).init(charmgr);
|
||||
@@ -55,7 +57,4 @@ public class TestApp
|
||||
|
||||
/** The config object. */
|
||||
protected Config _config;
|
||||
|
||||
/** The image manager object. */
|
||||
protected ImageManager _imgmgr;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: TestFrame.java,v 1.2 2001/11/08 02:07:36 mdb Exp $
|
||||
// $Id: TestFrame.java,v 1.3 2001/11/18 04:09:20 mdb Exp $
|
||||
|
||||
package com.threerings.cast.builder;
|
||||
package com.threerings.cast.tools.builder;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
//
|
||||
// $Id: ViewerApp.java,v 1.14 2001/11/08 02:58:24 mdb Exp $
|
||||
// $Id: ViewerApp.java,v 1.15 2001/11/18 04:09:20 mdb Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
import com.samskivert.util.Config;
|
||||
|
||||
import com.threerings.resource.ResourceManager;
|
||||
|
||||
import com.threerings.media.ImageManager;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
import com.threerings.media.tile.TileManager;
|
||||
import com.threerings.cast.CharacterManager;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.xml.XMLSceneRepository;
|
||||
import com.threerings.miso.util.MisoUtil;
|
||||
import com.threerings.miso.viewer.util.ViewerContext;
|
||||
import com.threerings.miso.util.MisoContext;
|
||||
|
||||
/**
|
||||
* The ViewerApp is a scene viewing application that allows for trying
|
||||
@@ -30,72 +27,48 @@ public class ViewerApp
|
||||
*/
|
||||
public ViewerApp (String[] args)
|
||||
{
|
||||
// we don't need to configure anything
|
||||
_config = new Config();
|
||||
_rsrcmgr = new ResourceManager("rsrc");
|
||||
_tilemgr = new TileManager(_rsrcmgr);
|
||||
|
||||
// create the context object
|
||||
MisoContext ctx = new ContextImpl();
|
||||
|
||||
// create the various managers
|
||||
SpriteManager spritemgr = new SpriteManager();
|
||||
// XMLComponentRepository crepo = new XMLComponentRepository(
|
||||
// ctx.getConfig(), ctx.getImageManager());
|
||||
CharacterManager charmgr = new CharacterManager(null);
|
||||
|
||||
// create and size the main application frame
|
||||
_frame = new ViewerFrame();
|
||||
_frame.setSize(WIDTH, HEIGHT);
|
||||
SwingUtil.centerWindow(_frame);
|
||||
|
||||
// create the handles on our various services
|
||||
_config = MisoUtil.createConfig(
|
||||
ViewerModel.CONFIG_KEY, "rsrc/config/miso/viewer");
|
||||
_model = createModel(_config, args);
|
||||
_rsrcmgr = new ResourceManager("rsrc");
|
||||
_imgmgr = new ImageManager(_rsrcmgr, _frame);
|
||||
_tilemgr = MisoUtil.createTileManager(_config, _imgmgr);
|
||||
_screpo = MisoUtil.createSceneRepository(_config, _tilemgr);
|
||||
// create our scene view panel
|
||||
_panel = new ViewerSceneViewPanel(ctx, spritemgr, charmgr);
|
||||
_frame.setPanel(_panel);
|
||||
|
||||
// create the context object
|
||||
_ctx = new ViewerContextImpl();
|
||||
|
||||
// initialize the frame with the now-prepared context
|
||||
((ViewerFrame)_frame).init(_ctx);
|
||||
}
|
||||
|
||||
protected ViewerModel createModel (Config config, String args[])
|
||||
{
|
||||
ViewerModel model = new ViewerModel(config);
|
||||
if (args.length >= 1) {
|
||||
model.scenefile = args[0];
|
||||
}
|
||||
return model;
|
||||
// determine whether or not the user specified a scene to be
|
||||
// displayed or if we'll be using the default
|
||||
}
|
||||
|
||||
/**
|
||||
* The implementation of the ViewerContext interface that provides
|
||||
* The implementation of the MisoContext interface that provides
|
||||
* handles to the config and manager objects that offer commonly used
|
||||
* services.
|
||||
*/
|
||||
protected class ViewerContextImpl implements ViewerContext
|
||||
protected class ContextImpl implements MisoContext
|
||||
{
|
||||
public Config getConfig ()
|
||||
{
|
||||
return _config;
|
||||
}
|
||||
|
||||
public ImageManager getImageManager ()
|
||||
{
|
||||
return _imgmgr;
|
||||
}
|
||||
|
||||
public TileManager getTileManager ()
|
||||
{
|
||||
return _tilemgr;
|
||||
}
|
||||
|
||||
public ResourceManager getResourceManager ()
|
||||
{
|
||||
return _rsrcmgr;
|
||||
}
|
||||
|
||||
public XMLSceneRepository getSceneRepository ()
|
||||
{
|
||||
return _screpo;
|
||||
}
|
||||
|
||||
public ViewerModel getViewerModel ()
|
||||
{
|
||||
return _model;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,6 +77,7 @@ public class ViewerApp
|
||||
public void run ()
|
||||
{
|
||||
_frame.pack();
|
||||
SwingUtil.centerWindow(_frame);
|
||||
_frame.show();
|
||||
}
|
||||
|
||||
@@ -126,21 +100,15 @@ public class ViewerApp
|
||||
/** The resource manager. */
|
||||
protected ResourceManager _rsrcmgr;
|
||||
|
||||
/** The scene repository. */
|
||||
protected XMLSceneRepository _screpo;
|
||||
|
||||
/** The tile manager object. */
|
||||
protected TileManager _tilemgr;
|
||||
|
||||
/** The image manager object. */
|
||||
protected ImageManager _imgmgr;
|
||||
|
||||
/** The viewer data model. */
|
||||
protected ViewerModel _model;
|
||||
|
||||
/** The context object. */
|
||||
protected ViewerContext _ctx;
|
||||
|
||||
/** The main application window. */
|
||||
protected Frame _frame;
|
||||
protected ViewerFrame _frame;
|
||||
|
||||
/** The main panel. */
|
||||
protected ViewerSceneViewPanel _panel;
|
||||
|
||||
/** The default scene to load and display. */
|
||||
protected static final String DEF_SCENE = "rsrc/scenes/default.xml";
|
||||
}
|
||||
|
||||
@@ -1,39 +1,37 @@
|
||||
//
|
||||
// $Id: ViewerFrame.java,v 1.27 2001/11/02 03:09:10 shaper Exp $
|
||||
// $Id: ViewerFrame.java,v 1.28 2001/11/18 04:09:21 mdb Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import com.threerings.media.ImageManager;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.util.MisoUtil;
|
||||
import com.threerings.miso.viewer.util.ViewerContext;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
* The viewer frame is the main application window.
|
||||
*/
|
||||
public class ViewerFrame extends JFrame
|
||||
{
|
||||
/**
|
||||
* Creates a frame in which the viewer application can operate.
|
||||
*/
|
||||
public ViewerFrame ()
|
||||
{
|
||||
super("Scene Viewer");
|
||||
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the frame with the context object.
|
||||
*/
|
||||
public void init (ViewerContext ctx)
|
||||
public void setPanel (JPanel panel)
|
||||
{
|
||||
// create the various managers
|
||||
SpriteManager spritemgr = new SpriteManager();
|
||||
// if we had an old panel, remove it
|
||||
if (_panel != null) {
|
||||
getContentPane().remove(_panel);
|
||||
}
|
||||
|
||||
// add the main panel to the frame
|
||||
getContentPane().add(new ViewerSceneViewPanel(ctx, spritemgr));
|
||||
// now add the new one
|
||||
_panel = panel;
|
||||
getContentPane().add(_panel);
|
||||
}
|
||||
|
||||
protected JPanel _panel;
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// $Id: ViewerModel.java,v 1.2 2001/09/05 00:45:27 shaper Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
import com.samskivert.util.Config;
|
||||
|
||||
public class ViewerModel
|
||||
{
|
||||
/** The config key prefix for miso viewer properties. */
|
||||
public static final String CONFIG_KEY = "miso-viewer";
|
||||
|
||||
/** The filename of the scene to display. */
|
||||
public String scenefile;
|
||||
|
||||
public ViewerModel (Config config)
|
||||
{
|
||||
scenefile = config.getValue(SCENE_KEY, DEF_SCENE);
|
||||
}
|
||||
|
||||
/** The config key to obtain the default scene filename. */
|
||||
protected static final String SCENE_KEY =
|
||||
CONFIG_KEY + ".default_scene";
|
||||
|
||||
/** The default scene to load and display. */
|
||||
protected static final String DEF_SCENE = "rsrc/scenes/default.xml";
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
//
|
||||
// $Id: ViewerSceneViewPanel.java,v 1.30 2001/11/08 02:58:24 mdb Exp $
|
||||
// $Id: ViewerSceneViewPanel.java,v 1.31 2001/11/18 04:09:21 mdb Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import com.samskivert.util.Config;
|
||||
|
||||
@@ -15,19 +13,22 @@ import com.threerings.cast.CharacterDescriptor;
|
||||
import com.threerings.cast.CharacterManager;
|
||||
import com.threerings.cast.util.CastUtil;
|
||||
|
||||
import com.threerings.media.ImageManager;
|
||||
import com.threerings.media.sprite.*;
|
||||
import com.threerings.media.tile.TileManager;
|
||||
import com.threerings.media.sprite.AnimationManager;
|
||||
import com.threerings.media.sprite.LineSegmentPath;
|
||||
import com.threerings.media.sprite.PathCompletedEvent;
|
||||
import com.threerings.media.sprite.SpriteEvent;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
import com.threerings.media.sprite.SpriteObserver;
|
||||
|
||||
import com.threerings.media.util.RandomUtil;
|
||||
import com.threerings.media.util.PerformanceMonitor;
|
||||
import com.threerings.media.util.PerformanceObserver;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.*;
|
||||
import com.threerings.miso.scene.xml.XMLSceneRepository;
|
||||
import com.threerings.miso.scene.MisoCharacterSprite;
|
||||
import com.threerings.miso.scene.SceneViewPanel;
|
||||
import com.threerings.miso.scene.util.IsoUtil;
|
||||
import com.threerings.miso.util.*;
|
||||
import com.threerings.miso.viewer.util.ViewerContext;
|
||||
import com.threerings.miso.util.MisoContext;
|
||||
|
||||
public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
implements PerformanceObserver, SpriteObserver
|
||||
@@ -35,21 +36,16 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
/**
|
||||
* Construct the panel and initialize it with a context.
|
||||
*/
|
||||
public ViewerSceneViewPanel (ViewerContext ctx, SpriteManager spritemgr)
|
||||
public ViewerSceneViewPanel (MisoContext ctx, SpriteManager spritemgr,
|
||||
CharacterManager charmgr)
|
||||
{
|
||||
super(ctx.getConfig(), spritemgr);
|
||||
|
||||
_ctx = ctx;
|
||||
|
||||
// create an animation manager for this panel
|
||||
_animmgr = new AnimationManager(spritemgr, this);
|
||||
|
||||
// load up the initial scene
|
||||
prepareStartingScene();
|
||||
|
||||
// construct the character manager from which we obtain sprites
|
||||
CharacterManager charmgr = MisoUtil.createCharacterManager(
|
||||
ctx.getConfig(), ctx.getImageManager());
|
||||
// configure the character manager from which we obtain sprites
|
||||
charmgr.setCharacterClass(MisoCharacterSprite.class);
|
||||
|
||||
// create the character descriptors
|
||||
_descUser = CastUtil.getRandomDescriptor(charmgr);
|
||||
@@ -105,24 +101,6 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and set up the starting scene for display.
|
||||
*/
|
||||
protected void prepareStartingScene ()
|
||||
{
|
||||
ViewerModel model = _ctx.getViewerModel();
|
||||
try {
|
||||
XMLSceneRepository screpo = _ctx.getSceneRepository();
|
||||
InputStream scin = _ctx.getResourceManager().
|
||||
getResource(model.scenefile);
|
||||
_view.setScene(screpo.loadScene(scin));
|
||||
|
||||
} catch (IOException ioe) {
|
||||
Log.warning("Exception loading scene [fname=" + model.scenefile +
|
||||
", ioe=" + ioe + "].");
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void paintComponent (Graphics g)
|
||||
{
|
||||
@@ -162,14 +140,14 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
protected boolean createPath (MisoCharacterSprite s, int x, int y)
|
||||
{
|
||||
// get the path from here to there
|
||||
Path path = _view.getPath(s, x, y);
|
||||
LineSegmentPath path = (LineSegmentPath)_view.getPath(s, x, y);
|
||||
if (path == null) {
|
||||
s.cancelMove();
|
||||
return false;
|
||||
}
|
||||
|
||||
// start the sprite moving along the path
|
||||
((LineSegmentPath)path).setVelocity(100f/1000f);
|
||||
path.setVelocity(100f/1000f);
|
||||
s.move(path);
|
||||
return true;
|
||||
}
|
||||
@@ -218,7 +196,4 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
|
||||
/** The test sprites that meander about aimlessly. */
|
||||
protected MisoCharacterSprite _decoys[];
|
||||
|
||||
/** The context object. */
|
||||
protected ViewerContext _ctx;
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// $Id: ViewerContext.java,v 1.6 2001/11/08 02:58:24 mdb Exp $
|
||||
|
||||
package com.threerings.miso.viewer.util;
|
||||
|
||||
import com.samskivert.util.Context;
|
||||
|
||||
import com.threerings.resource.ResourceManager;
|
||||
|
||||
import com.threerings.miso.scene.xml.XMLSceneRepository;
|
||||
import com.threerings.miso.util.MisoContext;
|
||||
import com.threerings.miso.viewer.ViewerModel;
|
||||
|
||||
/**
|
||||
* A mix-in interface that combines the MisoContext and Context
|
||||
* interfaces to provide an interface with the best of both worlds.
|
||||
*/
|
||||
public interface ViewerContext extends MisoContext, Context
|
||||
{
|
||||
/**
|
||||
* Returns the resource manager via which we can load resources.
|
||||
*/
|
||||
public ResourceManager getResourceManager ();
|
||||
|
||||
/**
|
||||
* Returns the scene repository that we can use to get scenes.
|
||||
*/
|
||||
public XMLSceneRepository getSceneRepository ();
|
||||
|
||||
/**
|
||||
* Returns the viewer data model.
|
||||
*/
|
||||
public ViewerModel getViewerModel ();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DummyClientSceneRepository.java,v 1.4 2001/11/08 02:57:14 mdb Exp $
|
||||
// $Id: DummyClientSceneRepository.java,v 1.5 2001/11/18 04:09:21 mdb Exp $
|
||||
|
||||
package com.threerings.whirled;
|
||||
|
||||
@@ -7,8 +7,7 @@ import java.io.IOException;
|
||||
|
||||
import com.threerings.whirled.Log;
|
||||
import com.threerings.whirled.client.persist.SceneRepository;
|
||||
import com.threerings.whirled.data.DummyScene;
|
||||
import com.threerings.whirled.data.Scene;
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
import com.threerings.whirled.util.NoSuchSceneException;
|
||||
|
||||
/**
|
||||
@@ -19,15 +18,15 @@ import com.threerings.whirled.util.NoSuchSceneException;
|
||||
public class DummyClientSceneRepository implements SceneRepository
|
||||
{
|
||||
// documentation inherited
|
||||
public Scene loadScene (int sceneId)
|
||||
public SceneModel loadSceneModel (int sceneId)
|
||||
throws IOException, NoSuchSceneException
|
||||
{
|
||||
Log.info("Creating dummy scene [id=" + sceneId + "].");
|
||||
return new DummyScene(sceneId);
|
||||
Log.info("Creating dummy scene model [id=" + sceneId + "].");
|
||||
return new SceneModel();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void updateScene (Scene scene)
|
||||
public void updateSceneModel (SceneModel scene)
|
||||
throws IOException
|
||||
{
|
||||
// nothing doing
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TestClient.java,v 1.7 2001/11/08 02:07:36 mdb Exp $
|
||||
// $Id: TestClient.java,v 1.8 2001/11/18 04:09:21 mdb Exp $
|
||||
|
||||
package com.threerings.whirled;
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.threerings.crowd.client.*;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
import com.threerings.whirled.client.SceneDirector;
|
||||
import com.threerings.whirled.client.DefaultDisplaySceneFactory;
|
||||
import com.threerings.whirled.client.persist.SceneRepository;
|
||||
import com.threerings.whirled.util.WhirledContext;
|
||||
|
||||
@@ -31,7 +32,8 @@ public class TestClient
|
||||
_client = new Client(creds, this);
|
||||
_screp = new DummyClientSceneRepository();
|
||||
_occmgr = new OccupantManager(_ctx);
|
||||
_scdir = new SceneDirector(_ctx, _screp);
|
||||
_scdir = new SceneDirector(
|
||||
_ctx, _screp, new DefaultDisplaySceneFactory());
|
||||
|
||||
// we want to know about logon/logoff
|
||||
_client.addObserver(this);
|
||||
|
||||
Reference in New Issue
Block a user