General updating per initial code review. Created EditableSceneView
to separate scene display from editing functionality. Load and initialize managers in a fashion that more appropriately hides the implementation details. Tidied comments up a bit. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@103 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,27 +1,44 @@
|
||||
//
|
||||
// $Id: MisoUtil.java,v 1.1 2001/07/21 01:51:10 shaper Exp $
|
||||
// $Id: MisoUtil.java,v 1.2 2001/07/23 18:52:51 shaper Exp $
|
||||
|
||||
package com.threerings.miso.util;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import com.samskivert.util.Config;
|
||||
import com.samskivert.util.*;
|
||||
import com.threerings.media.ImageManager;
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.*;
|
||||
import com.threerings.miso.tile.*;
|
||||
import com.threerings.resource.ResourceManager;
|
||||
|
||||
/**
|
||||
* MisoUtil provides miscellaneous routines for applications or other
|
||||
* layers that intend to make use of Miso services.
|
||||
*/
|
||||
public class MisoUtil
|
||||
{
|
||||
/**
|
||||
* Populate the config object with miso configuration values.
|
||||
*
|
||||
* @param config the Config object to populate.
|
||||
*/
|
||||
public static void bindProperties (Config config) throws IOException
|
||||
{
|
||||
config.bindProperties("miso", "rsrc/config/miso/miso");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SceneManager object, reading the class name to
|
||||
* instantiate from the "miso.scenemgr" config value.
|
||||
*
|
||||
* @param config the Config object.
|
||||
*
|
||||
* @return the new SceneManager object or null if an error occurred.
|
||||
*/
|
||||
public static SceneManager createSceneManager (Config config)
|
||||
{
|
||||
try {
|
||||
@@ -34,6 +51,14 @@ public class MisoUtil
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TileManager object.
|
||||
*
|
||||
* @param config the Config object.
|
||||
* @param frame the root frame to which images will be rendered.
|
||||
*
|
||||
* @return the new TileManager object or null if an error occurred.
|
||||
*/
|
||||
public static TileManager createTileManager (Config config, Frame frame)
|
||||
{
|
||||
ResourceManager rmgr = createResourceManager();
|
||||
@@ -41,13 +66,14 @@ public class MisoUtil
|
||||
TileSetManager tilesetmgr = createTileSetManager(config, imgmgr);
|
||||
TileManager tilemgr = new TileManager(tilesetmgr);
|
||||
|
||||
// load the tileset descriptions
|
||||
String tfile = config.getValue("miso.tilesets", (String)null);
|
||||
tilemgr.loadTileSets(tfile);
|
||||
|
||||
return tilemgr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ResourceManager object.
|
||||
*
|
||||
* @return the new ResourceManager object or null if an error occurred.
|
||||
*/
|
||||
protected static ResourceManager createResourceManager ()
|
||||
{
|
||||
String root = System.getProperty("root", "");
|
||||
@@ -59,19 +85,27 @@ public class MisoUtil
|
||||
} catch (MalformedURLException mue) {
|
||||
Log.warning("Malformed resource manager URL [url=" + localroot +
|
||||
", mue=" + mue + "].");
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TileSetManager object, reading the class name to
|
||||
* instantiate from the "miso.tilesetmgr" config value.
|
||||
*
|
||||
* @param config the Config object.
|
||||
* @param imgmgr the ImageManager object from which images are obtained.
|
||||
*
|
||||
* @return the new TileSetManager object or null if an error occurred.
|
||||
*/
|
||||
protected static TileSetManager
|
||||
createTileSetManager (Config config, ImageManager imgmgr)
|
||||
{
|
||||
TileSetManager tilesetmgr = null;
|
||||
TileSetManagerImpl tilesetmgr = null;
|
||||
try {
|
||||
tilesetmgr = (TileSetManager)
|
||||
tilesetmgr = (TileSetManagerImpl)
|
||||
config.instantiateValue("miso.tilesetmgr", DEF_TILESETMGR);
|
||||
tilesetmgr.init(imgmgr);
|
||||
tilesetmgr.init(config, imgmgr);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.warning("Failed to instantiate tileset manager " +
|
||||
@@ -81,8 +115,11 @@ public class MisoUtil
|
||||
return tilesetmgr;
|
||||
}
|
||||
|
||||
protected static final String DEF_SCENEMGR =
|
||||
/** The default SceneManager class name. */
|
||||
protected static final String DEF_SCENEMGR =
|
||||
CompiledSceneManager.class.getName();
|
||||
|
||||
/** The default TileSetManager class name. */
|
||||
protected static final String DEF_TILESETMGR =
|
||||
EditableTileSetManager.class.getName();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user