Brought into the newly revamped world of contexts. Moved SwingUtil to
samskivert. Added config values to specify the tileset manager and scene manager. Split miso and editor config into two separate properties files. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@101 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user