Helped the scene manager to depart from the scene. The viewer and editor
applications really need to deal directly with the scene repository. The display part of the MISO code doesn't need a scene manager, per se, because it is simply told to visualize a particular scene and scene management happens entirely externally. This is in preparation for making the MISO code work and place nicely with the Whirled code. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@246 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,57 +0,0 @@
|
|||||||
//
|
|
||||||
// $Id: SceneManager.java,v 1.7 2001/07/24 16:10:19 shaper Exp $
|
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
|
||||||
|
|
||||||
import com.samskivert.util.IntMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The SceneManager provides a single access point for retrieving and
|
|
||||||
* caching the various scenes that make up a game.
|
|
||||||
*/
|
|
||||||
public class SceneManager
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Initialize the SceneManager with the given scene repository.
|
|
||||||
*
|
|
||||||
* @param repo the scene repository.
|
|
||||||
*/
|
|
||||||
public SceneManager (SceneRepository repo)
|
|
||||||
{
|
|
||||||
_repo = repo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the Scene object for the specified scene id.
|
|
||||||
*
|
|
||||||
* @param sid the scene id.
|
|
||||||
* @return the Scene object.
|
|
||||||
*/
|
|
||||||
public Scene getScene (int sid)
|
|
||||||
{
|
|
||||||
// TBD
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SceneRepository getSceneRepository ()
|
|
||||||
{
|
|
||||||
return _repo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a String array of all scene layer names ordered by
|
|
||||||
* ascending layer id.
|
|
||||||
*
|
|
||||||
* @return the layer names.
|
|
||||||
*/
|
|
||||||
public String[] getLayerNames ()
|
|
||||||
{
|
|
||||||
return Scene.XLATE_LAYERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The repository used to read and write scenes. */
|
|
||||||
protected SceneRepository _repo;
|
|
||||||
|
|
||||||
/** The currently cached scenes. */
|
|
||||||
protected IntMap _scenes = new IntMap();
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,21 @@
|
|||||||
//
|
//
|
||||||
// $Id: SceneRepository.java,v 1.1 2001/07/24 16:10:19 shaper Exp $
|
// $Id: SceneRepository.java,v 1.2 2001/08/15 00:00:51 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SceneRepository interface manages persistent scene storage.
|
* The SceneRepository interface manages persistent scene storage.
|
||||||
*/
|
*/
|
||||||
public interface SceneRepository
|
public interface SceneRepository
|
||||||
{
|
{
|
||||||
// TBD
|
/**
|
||||||
|
* Loads and returns the scene object with the specified id.
|
||||||
|
*
|
||||||
|
* @param fname the full pathname to the file.
|
||||||
|
*
|
||||||
|
* @return the scene object.
|
||||||
|
*/
|
||||||
|
public Scene loadScene (String fname) throws IOException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
//
|
//
|
||||||
// $Id: MisoContext.java,v 1.2 2001/07/21 01:51:10 shaper Exp $
|
// $Id: MisoContext.java,v 1.3 2001/08/15 00:00:51 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.util;
|
package com.threerings.miso.util;
|
||||||
|
|
||||||
import com.samskivert.util.Context;
|
import com.samskivert.util.Context;
|
||||||
import com.threerings.miso.tile.TileManager;
|
import com.threerings.miso.tile.TileManager;
|
||||||
import com.threerings.miso.scene.SceneManager;
|
|
||||||
|
|
||||||
public interface MisoContext extends Context
|
public interface MisoContext extends Context
|
||||||
{
|
{
|
||||||
@@ -14,10 +13,4 @@ public interface MisoContext extends Context
|
|||||||
* for the lifetime of the application.
|
* for the lifetime of the application.
|
||||||
*/
|
*/
|
||||||
public TileManager getTileManager ();
|
public TileManager getTileManager ();
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a reference to the SceneManager. This reference is
|
|
||||||
* valid for the lifetime of the application.
|
|
||||||
*/
|
|
||||||
public SceneManager getSceneManager ();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: MisoUtil.java,v 1.5 2001/08/13 15:00:24 shaper Exp $
|
// $Id: MisoUtil.java,v 1.6 2001/08/15 00:00:51 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.util;
|
package com.threerings.miso.util;
|
||||||
|
|
||||||
@@ -33,27 +33,26 @@ public class MisoUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a <code>SceneManager</code> object, reading the class
|
* Create an <code>XMLFileSceneRepository</code> object, reading the
|
||||||
* name to instantiate from the config object.
|
* name of the class to instantiate from the config object.
|
||||||
*
|
*
|
||||||
* @param config the <code>Config</code> object.
|
* @param config the <code>Config</code> object.
|
||||||
*
|
*
|
||||||
* @return the new scene manager object or null if an error occurred.
|
* @return the new scene repository object or null if an error
|
||||||
|
* occurred.
|
||||||
*/
|
*/
|
||||||
public static SceneManager
|
public static XMLFileSceneRepository createSceneRepository (
|
||||||
createSceneManager (Config config, TileManager tilemgr)
|
Config config, TileManager tilemgr)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
SceneRepositoryImpl scenerepo = (SceneRepositoryImpl)
|
XMLFileSceneRepository scenerepo = (XMLFileSceneRepository)
|
||||||
config.instantiateValue("miso.scenerepo", DEF_SCENEREPO);
|
config.instantiateValue("miso.scenerepo", DEF_SCENEREPO);
|
||||||
scenerepo.init(config, tilemgr);
|
scenerepo.init(config, tilemgr);
|
||||||
|
return scenerepo;
|
||||||
SceneManager scenemgr = new SceneManager(scenerepo);
|
|
||||||
|
|
||||||
return scenemgr;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Failed to instantiate scene manager [e=" + e + "].");
|
Log.warning("Failed to instantiate scene repository " +
|
||||||
|
"[e=" + e + "].");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,8 +105,8 @@ public class MisoUtil
|
|||||||
*
|
*
|
||||||
* @return the new tileset manager object or null if an error occurred.
|
* @return the new tileset manager object or null if an error occurred.
|
||||||
*/
|
*/
|
||||||
protected static TileSetManager
|
protected static TileSetManager createTileSetManager (
|
||||||
createTileSetManager (Config config, ImageManager imgmgr)
|
Config config, ImageManager imgmgr)
|
||||||
{
|
{
|
||||||
TileSetManagerImpl tilesetmgr = null;
|
TileSetManagerImpl tilesetmgr = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ViewerApp.java,v 1.3 2001/08/02 00:42:02 shaper Exp $
|
// $Id: ViewerApp.java,v 1.4 2001/08/15 00:00:51 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.viewer;
|
package com.threerings.miso.viewer;
|
||||||
|
|
||||||
@@ -8,8 +8,9 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import com.samskivert.swing.util.SwingUtil;
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
import com.samskivert.util.Config;
|
import com.samskivert.util.Config;
|
||||||
|
|
||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
import com.threerings.miso.scene.SceneManager;
|
import com.threerings.miso.scene.SceneRepository;
|
||||||
import com.threerings.miso.tile.TileManager;
|
import com.threerings.miso.tile.TileManager;
|
||||||
import com.threerings.miso.util.MisoUtil;
|
import com.threerings.miso.util.MisoUtil;
|
||||||
import com.threerings.miso.viewer.util.ViewerContext;
|
import com.threerings.miso.viewer.util.ViewerContext;
|
||||||
@@ -33,7 +34,7 @@ public class ViewerApp
|
|||||||
// create the handles on our various services
|
// create the handles on our various services
|
||||||
_config = createConfig();
|
_config = createConfig();
|
||||||
_tilemgr = MisoUtil.createTileManager(_config, _frame);
|
_tilemgr = MisoUtil.createTileManager(_config, _frame);
|
||||||
_scenemgr = MisoUtil.createSceneManager(_config, _tilemgr);
|
_screpo = MisoUtil.createSceneRepository(_config, _tilemgr);
|
||||||
_ctx = new ViewerContextImpl();
|
_ctx = new ViewerContextImpl();
|
||||||
|
|
||||||
// initialize the frame with the now-prepared context
|
// initialize the frame with the now-prepared context
|
||||||
@@ -63,8 +64,8 @@ public class ViewerApp
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The implementation of the ViewerContext interface that provides
|
* The implementation of the ViewerContext interface that provides
|
||||||
* handles to the config and manager objects that offer commonly
|
* handles to the config and manager objects that offer commonly used
|
||||||
* used services.
|
* services.
|
||||||
*/
|
*/
|
||||||
protected class ViewerContextImpl implements ViewerContext
|
protected class ViewerContextImpl implements ViewerContext
|
||||||
{
|
{
|
||||||
@@ -73,15 +74,15 @@ public class ViewerApp
|
|||||||
return _config;
|
return _config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SceneManager getSceneManager ()
|
|
||||||
{
|
|
||||||
return _scenemgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileManager getTileManager ()
|
public TileManager getTileManager ()
|
||||||
{
|
{
|
||||||
return _tilemgr;
|
return _tilemgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SceneRepository getSceneRepository ()
|
||||||
|
{
|
||||||
|
return _screpo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,8 +109,8 @@ public class ViewerApp
|
|||||||
/** The config object. */
|
/** The config object. */
|
||||||
protected Config _config;
|
protected Config _config;
|
||||||
|
|
||||||
/** The scene manager object. */
|
/** The scene repository. */
|
||||||
protected SceneManager _scenemgr;
|
protected SceneRepository _screpo;
|
||||||
|
|
||||||
/** The tile manager object. */
|
/** The tile manager object. */
|
||||||
protected TileManager _tilemgr;
|
protected TileManager _tilemgr;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ViewerSceneViewPanel.java,v 1.7 2001/08/14 23:35:22 mdb Exp $
|
// $Id: ViewerSceneViewPanel.java,v 1.8 2001/08/15 00:00:51 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.viewer;
|
package com.threerings.miso.viewer;
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ import com.threerings.media.sprite.*;
|
|||||||
|
|
||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
import com.threerings.miso.scene.*;
|
import com.threerings.miso.scene.*;
|
||||||
import com.threerings.miso.scene.xml.XMLFileSceneRepository;
|
import com.threerings.miso.scene.SceneRepository;
|
||||||
import com.threerings.miso.util.*;
|
import com.threerings.miso.util.*;
|
||||||
import com.threerings.miso.viewer.util.ViewerContext;
|
import com.threerings.miso.viewer.util.ViewerContext;
|
||||||
|
|
||||||
@@ -49,9 +49,7 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
|||||||
*/
|
*/
|
||||||
protected void prepareStartingScene ()
|
protected void prepareStartingScene ()
|
||||||
{
|
{
|
||||||
// get the scene repository
|
SceneRepository screpo = _ctx.getSceneRepository();
|
||||||
XMLFileSceneRepository repo = (XMLFileSceneRepository)
|
|
||||||
_ctx.getSceneManager().getSceneRepository();
|
|
||||||
|
|
||||||
// get the starting scene filename
|
// get the starting scene filename
|
||||||
Config config = _ctx.getConfig();
|
Config config = _ctx.getConfig();
|
||||||
@@ -59,7 +57,7 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// load and set up the scene
|
// load and set up the scene
|
||||||
_view.setScene(repo.loadScene(fname));
|
_view.setScene(screpo.loadScene(fname));
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.warning("Exception loading scene [fname=" + fname +
|
Log.warning("Exception loading scene [fname=" + fname +
|
||||||
", ioe=" + ioe + "].");
|
", ioe=" + ioe + "].");
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: ViewerContext.java,v 1.1 2001/07/25 17:38:15 shaper Exp $
|
// $Id: ViewerContext.java,v 1.2 2001/08/15 00:00:52 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.viewer.util;
|
package com.threerings.miso.viewer.util;
|
||||||
|
|
||||||
import com.samskivert.util.Context;
|
import com.samskivert.util.Context;
|
||||||
|
|
||||||
|
import com.threerings.miso.scene.SceneRepository;
|
||||||
import com.threerings.miso.util.MisoContext;
|
import com.threerings.miso.util.MisoContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,5 +14,8 @@ import com.threerings.miso.util.MisoContext;
|
|||||||
*/
|
*/
|
||||||
public interface ViewerContext extends MisoContext, Context
|
public interface ViewerContext extends MisoContext, Context
|
||||||
{
|
{
|
||||||
// nothing for now.
|
/**
|
||||||
|
* Returns the scene repository that we can use to get scenes.
|
||||||
|
*/
|
||||||
|
public SceneRepository getSceneRepository ();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user