diff --git a/rsrc/config/miso/miso.properties b/rsrc/config/miso/miso.properties index 9f28e847d..dd69c7482 100644 --- a/rsrc/config/miso/miso.properties +++ b/rsrc/config/miso/miso.properties @@ -1,9 +1,14 @@ # -# $Id: miso.properties,v 1.6 2001/07/20 02:19:38 shaper Exp $ +# $Id: miso.properties,v 1.7 2001/07/21 01:51:09 shaper Exp $ # # Initial test config values for miso development. # -tilesets = rsrc/config/miso/tilesets.xml +# the tileset manager class to use for working with tilesets +tilesetmgr = com.threerings.miso.tile.EditableTileSetManager -editor.default_tileset = Ground +# the scene manager class to use for working with scenes +scenemanager = com.threerings.miso.scene.CompiledSceneManager + +# the tileset descriptions +tilesets = rsrc/config/miso/tilesets.xml diff --git a/src/java/com/threerings/media/tile/TileManager.java b/src/java/com/threerings/media/tile/TileManager.java index d2e1e1c3d..2aa0d2de9 100644 --- a/src/java/com/threerings/media/tile/TileManager.java +++ b/src/java/com/threerings/media/tile/TileManager.java @@ -1,5 +1,5 @@ // -// $Id: TileManager.java,v 1.8 2001/07/20 02:23:34 shaper Exp $ +// $Id: TileManager.java,v 1.9 2001/07/21 01:51:10 shaper Exp $ package com.threerings.miso.tile; @@ -57,6 +57,14 @@ public class TileManager return tile; } + /** + * Return the TileSetManager that the TileManager is using. + */ + public TileSetManager getTileSetManager () + { + return _tsmgr; + } + /** * Load all tileset objects described in the specified file into * the set of available tilesets. diff --git a/src/java/com/threerings/media/tile/TileSetManager.java b/src/java/com/threerings/media/tile/TileSetManager.java index 82fec3d44..c70232cd6 100644 --- a/src/java/com/threerings/media/tile/TileSetManager.java +++ b/src/java/com/threerings/media/tile/TileSetManager.java @@ -1,8 +1,10 @@ // -// $Id: TileSetManager.java,v 1.6 2001/07/20 02:23:34 shaper Exp $ +// $Id: TileSetManager.java,v 1.7 2001/07/21 01:51:10 shaper Exp $ package com.threerings.miso.tile; +import com.threerings.media.ImageManager; + import java.awt.Image; import java.io.InputStream; import java.io.IOException; @@ -10,6 +12,11 @@ import java.util.ArrayList; public interface TileSetManager { + /** + * Initialize the TileSetManager with the given ImageManager. + */ + public void init (ImageManager imgmgr); + /** * Return the total number of tiles in the specified tileset. */ diff --git a/src/java/com/threerings/media/tile/TileSetManagerImpl.java b/src/java/com/threerings/media/tile/TileSetManagerImpl.java index f64be4d66..a1b3e4645 100644 --- a/src/java/com/threerings/media/tile/TileSetManagerImpl.java +++ b/src/java/com/threerings/media/tile/TileSetManagerImpl.java @@ -1,5 +1,5 @@ // -// $Id: TileSetManagerImpl.java,v 1.5 2001/07/20 02:23:34 shaper Exp $ +// $Id: TileSetManagerImpl.java,v 1.6 2001/07/21 01:51:10 shaper Exp $ package com.threerings.miso.tile; @@ -13,7 +13,7 @@ import java.util.Enumeration; public abstract class TileSetManagerImpl implements TileSetManager { - public TileSetManagerImpl (ImageManager imgr) + public void init (ImageManager imgr) { _imgr = imgr; } diff --git a/src/java/com/threerings/miso/tile/CompiledTileSetManager.java b/src/java/com/threerings/miso/tile/CompiledTileSetManager.java index c3044dcc7..0c9cb55ff 100644 --- a/src/java/com/threerings/miso/tile/CompiledTileSetManager.java +++ b/src/java/com/threerings/miso/tile/CompiledTileSetManager.java @@ -1,5 +1,5 @@ // -// $Id: CompiledTileSetManager.java,v 1.5 2001/07/18 22:45:35 shaper Exp $ +// $Id: CompiledTileSetManager.java,v 1.6 2001/07/21 01:51:10 shaper Exp $ package com.threerings.miso.tile; @@ -10,11 +10,6 @@ import java.io.IOException; public class CompiledTileSetManager extends TileSetManagerImpl { - public CompiledTileSetManager (ImageManager imgr) - { - super(imgr); - } - public void loadTileSets (InputStream tis) throws IOException { // TBD diff --git a/src/java/com/threerings/miso/tile/EditableTileSetManager.java b/src/java/com/threerings/miso/tile/EditableTileSetManager.java index 4a28f75b2..0871f2002 100644 --- a/src/java/com/threerings/miso/tile/EditableTileSetManager.java +++ b/src/java/com/threerings/miso/tile/EditableTileSetManager.java @@ -1,5 +1,5 @@ // -// $Id: EditableTileSetManager.java,v 1.5 2001/07/18 22:45:35 shaper Exp $ +// $Id: EditableTileSetManager.java,v 1.6 2001/07/21 01:51:10 shaper Exp $ package com.threerings.miso.tile; @@ -18,11 +18,6 @@ import java.util.ArrayList; */ public class EditableTileSetManager extends TileSetManagerImpl { - public EditableTileSetManager (ImageManager imgr) - { - super(imgr); - } - public void loadTileSets (InputStream tis) throws IOException { // read all tileset descriptions from the XML input stream diff --git a/src/java/com/threerings/miso/util/MisoContext.java b/src/java/com/threerings/miso/util/MisoContext.java index 75a63e770..0029f736b 100644 --- a/src/java/com/threerings/miso/util/MisoContext.java +++ b/src/java/com/threerings/miso/util/MisoContext.java @@ -1,5 +1,5 @@ // -// $Id: MisoContext.java,v 1.1 2001/07/20 23:42:20 shaper Exp $ +// $Id: MisoContext.java,v 1.2 2001/07/21 01:51:10 shaper Exp $ package com.threerings.miso.util; @@ -10,12 +10,14 @@ import com.threerings.miso.scene.SceneManager; public interface MisoContext extends Context { /** - * Return a reference to the TileManager. + * Return a reference to the TileManager. This reference is valid + * for the lifetime of the application. */ public TileManager getTileManager (); /** - * Return a reference to the SceneManager. + * Return a reference to the SceneManager. This reference is + * valid for the lifetime of the application. */ public SceneManager getSceneManager (); } diff --git a/src/java/com/threerings/miso/util/MisoUtil.java b/src/java/com/threerings/miso/util/MisoUtil.java new file mode 100644 index 000000000..3358125e4 --- /dev/null +++ b/src/java/com/threerings/miso/util/MisoUtil.java @@ -0,0 +1,88 @@ +// +// $Id: MisoUtil.java,v 1.1 2001/07/21 01:51:10 shaper Exp $ + +package com.threerings.miso.util; + +import java.awt.Frame; +import java.io.IOException; +import java.net.URL; +import java.net.MalformedURLException; + +import com.samskivert.util.Config; +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; + +public class MisoUtil +{ + public static void bindProperties (Config config) throws IOException + { + config.bindProperties("miso", "rsrc/config/miso/miso"); + } + + public static SceneManager createSceneManager (Config config) + { + try { + return (SceneManager) + config.instantiateValue("miso.scenemgr", DEF_SCENEMGR); + + } catch (Exception e) { + Log.warning("Failed to instantiate scene manager [e=" + e + "]."); + return null; + } + } + + public static TileManager createTileManager (Config config, Frame frame) + { + ResourceManager rmgr = createResourceManager(); + ImageManager imgmgr = new ImageManager(rmgr, frame); + 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; + } + + protected static ResourceManager createResourceManager () + { + String root = System.getProperty("root", ""); + String localroot = "file:" + root + "/rsrc"; + + try { + return new ResourceManager(new URL(localroot)); + + } catch (MalformedURLException mue) { + Log.warning("Malformed resource manager URL [url=" + localroot + + ", mue=" + mue + "]."); + } + + return null; + } + + protected static TileSetManager + createTileSetManager (Config config, ImageManager imgmgr) + { + TileSetManager tilesetmgr = null; + try { + tilesetmgr = (TileSetManager) + config.instantiateValue("miso.tilesetmgr", DEF_TILESETMGR); + tilesetmgr.init(imgmgr); + + } catch (Exception e) { + Log.warning("Failed to instantiate tileset manager " + + "[e=" + e + "]."); + } + + return tilesetmgr; + } + + protected static final String DEF_SCENEMGR = + CompiledSceneManager.class.getName(); + protected static final String DEF_TILESETMGR = + EditableTileSetManager.class.getName(); +} diff --git a/src/java/com/threerings/miso/util/SwingUtil.java b/src/java/com/threerings/miso/util/SwingUtil.java deleted file mode 100644 index 8d82868ae..000000000 --- a/src/java/com/threerings/miso/util/SwingUtil.java +++ /dev/null @@ -1,18 +0,0 @@ -// -// $Id: SwingUtil.java,v 1.2 2001/07/18 21:45:42 shaper Exp $ - -package com.threerings.miso.util; - -import java.awt.*; - -public class SwingUtil -{ - public static void centerFrame (Frame frame) - { - Toolkit tk = frame.getToolkit(); - Dimension ss = tk.getScreenSize(); - int width = frame.getWidth(), height = frame.getHeight(); - frame.setBounds((ss.width-width)/2, (ss.height-height)/2, - width, height); - } -}