A bunch of intertwingled changes:

Refactored TileSet into TileSet, UniformTileSet, SwissArmyTileSet and
ObjectTileSet.

Removed dependence on the "root" system property from the
XMLSceneRepository (things either pass in full paths now or input streams
fetched via the resource manager).

Removed MisoUtil.createImageManager() because everyone does that by hand
now (which is good because some non-Miso things were using MisoUtil for
that).

I think that's it, but if there was something else, don't blame me. Blame
the monkeys.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@608 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-11-08 03:04:45 +00:00
parent 0b5d51a80c
commit feb2a2633e
12 changed files with 563 additions and 277 deletions
@@ -1,5 +1,5 @@
//
// $Id: BaseTileSet.java,v 1.4 2001/11/01 01:40:42 shaper Exp $
// $Id: BaseTileSet.java,v 1.5 2001/11/08 03:04:45 mdb Exp $
package com.threerings.miso.tile;
@@ -13,23 +13,31 @@ import com.threerings.media.tile.*;
import com.threerings.miso.scene.MisoScene;
/**
* The miso tile set extends the base tile set to add support for tile
* passability. Passability is used to determine whether {@link
* com.threerings.miso.scene.Traverser} objects can traverse a
* particular tile in a {@link com.threerings.miso.scene.MisoScene}.
* The miso tile set extends the swiss army tile set to add support for
* tile passability. Passability is used to determine whether {@link
* com.threerings.miso.scene.Traverser} objects can traverse a particular
* tile in a {@link MisoScene}.
*/
public class MisoTileSet extends TileSet
public class MisoTileSet extends SwissArmyTileSet
{
/**
* Constructs a Miso tileset with the swiss army tile set
* configuration information and additional information about tile
* passability.
*
* @param layer the layer to which this tileset is assigned.
* @param passable info on each tile indicating whether or not the
* tile is passable (can be walked on by sprites).
*
* @see SwissArmyTileSet#SwissArmyTileSet
*/
public MisoTileSet (
ImageManager imgmgr, int tsid, String name, String imgFile,
int tileCount[], int rowWidth[], int rowHeight[],
int numTiles, Point offsetPos, Point gapDist,
boolean isObjectSet, HashIntMap objects,
int layer, int passable[])
ImageManager imgmgr, String imgFile, String name, int tsid,
int[] tileCount, int[] rowWidth, int[] rowHeight,
Point offsetPos, Point gapDist, int layer, int[] passable)
{
super(imgmgr, tsid, name, imgFile, tileCount, rowWidth,
rowHeight, numTiles, offsetPos, gapDist,
isObjectSet, objects);
super(imgmgr, imgFile, name, tsid, tileCount,
rowWidth, rowHeight, offsetPos, gapDist);
_layer = layer;
_passable = passable;
@@ -1,5 +1,5 @@
//
// $Id: XMLMisoTileSetParser.java,v 1.5 2001/11/01 01:40:42 shaper Exp $
// $Id: XMLMisoTileSetParser.java,v 1.6 2001/11/08 03:04:45 mdb Exp $
package com.threerings.miso.tile;
@@ -45,6 +45,7 @@ public class XMLMisoTileSetParser extends XMLTileSetParser
if (qName.equals("passable")) {
_passable = StringUtil.parseIntArray(data);
} else if (qName.equals("tileset")) {
_passable = null;
_layer = -1;
@@ -54,13 +55,24 @@ public class XMLMisoTileSetParser extends XMLTileSetParser
// documentation inherited
protected TileSet createTileSet ()
{
return new MisoTileSet(
_imgmgr, _info.tsid, _info.name, _info.imgFile, _info.tileCount,
_info.rowWidth, _info.rowHeight, _info.numTiles, _info.offsetPos,
_info.gapDist, _info.isObjectSet, _info.objects,
_layer, _passable);
if (_info.isObjectSet) {
return new ObjectTileSet(
_imgmgr, _info.imgFile, _info.name, _info.tsid,
_info.tileCount, _info.rowWidth, _info.rowHeight,
_info.offsetPos, _info.gapDist, _info.objects);
} else {
return new MisoTileSet(
_imgmgr, _info.imgFile, _info.name, _info.tsid,
_info.tileCount, _info.rowWidth, _info.rowHeight,
_info.offsetPos, _info.gapDist, _layer, _passable);
}
}
protected int _passable[];
/** Info on whether or not the tiles are passable (can be walked on by
* sprites). */
protected int[] _passable;
/** The layer to which the tiles are assigned. */
protected int _layer = -1;
}
@@ -1,5 +1,5 @@
//
// $Id: XMLSceneParser.java,v 1.23 2001/10/25 16:36:43 shaper Exp $
// $Id: XMLSceneParser.java,v 1.24 2001/11/08 03:04:44 mdb Exp $
package com.threerings.miso.scene.xml;
@@ -58,7 +58,7 @@ public class XMLSceneParser extends SimpleParser
Log.warning(
"Unrecognized scene file format version, will attempt " +
"to continue parsing file but your mileage may vary " +
"[fname=" + _fname + ", version=" + version +
"[version=" + version +
", known_version=" + XMLSceneVersion.VERSION + "].");
}
@@ -268,14 +268,28 @@ public class XMLSceneParser extends SimpleParser
* Parse the specified XML file and return a miso scene object with
* the data contained therein.
*
* @param fname the file name.
* @param path the full path to the scene description file.
*
* @return the scene object, or null if an error occurred.
*/
public EditableMisoScene loadScene (String fname) throws IOException
public EditableMisoScene loadScene (String path) throws IOException
{
return loadScene(getInputStream(path));
}
/**
* Parse the specified XML file and return a miso scene object with
* the data contained therein.
*
* @param stream the input stream from which the XML scene description
* can be read.
*
* @return the scene object, or null if an error occurred.
*/
public EditableMisoScene loadScene (InputStream stream) throws IOException
{
_info = new SceneInfo();
parseFile(fname);
parseStream(stream);
// place shadow tiles for any objects in the scene
_info.scene.generateAllObjectShadows();
// return the final scene object
@@ -1,10 +1,11 @@
//
// $Id: XMLSceneRepository.java,v 1.13 2001/11/02 02:52:16 shaper Exp $
// $Id: XMLSceneRepository.java,v 1.14 2001/11/08 03:04:44 mdb Exp $
package com.threerings.miso.scene.xml;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import com.samskivert.util.Config;
@@ -48,27 +49,31 @@ public class XMLSceneRepository
}
/**
* Returns the path to the scene root directory.
* Loads and returns a miso scene object for the scene described in
* the specified XML file.
*
* @param path the full pathname to the file.
*
* @return the scene object.
*/
public String getScenePath ()
public EditableMisoScene loadScene (String path) throws IOException
{
return _root + File.separator + _sceneRoot + File.separator;
Log.info("Loading scene [path=" + path + "].");
return _parser.loadScene(path);
}
/**
* Loads and returns a miso scene object for the scene described in
* the specified XML file. The filename should be relative to the
* scene root directory.
* the XML file available via the supplied input stream.
*
* @param path the full pathname to the file.
*
* @param fname the full pathname to the file.
* @return the scene object.
*/
public EditableMisoScene loadScene (String fname) throws IOException
public EditableMisoScene loadScene (InputStream stream)
throws IOException
{
String path = getScenePath() + fname;
Log.info("Loading scene [path=" + path + "].");
return _parser.loadScene(path);
return _parser.loadScene(stream);
}
/**
@@ -77,13 +82,11 @@ public class XMLSceneRepository
* the scene root directory.
*
* @param scene the scene to save.
* @param fname the file to write the scene to.
* @param path the full path of the file to write the scene to.
*/
public void saveScene (MisoScene scene, String fname) throws IOException
public void saveScene (MisoScene scene, String path) throws IOException
{
String path = getScenePath() + fname;
Log.info("Saving scene [path=" + path + "].");
_writer.saveScene(scene, path);
}
@@ -1,5 +1,5 @@
//
// $Id: MisoUtil.java,v 1.13 2001/11/02 02:52:16 shaper Exp $
// $Id: MisoUtil.java,v 1.14 2001/11/08 03:04:45 mdb Exp $
package com.threerings.miso.util;
@@ -12,8 +12,6 @@ import com.samskivert.util.*;
import com.threerings.cast.CharacterManager;
import com.threerings.resource.ResourceManager;
import com.threerings.media.ImageManager;
import com.threerings.media.tile.*;
@@ -122,19 +120,6 @@ public class MisoUtil
}
}
/**
* Creates an <code>ImageManager</code> object.
*
* @param frame the root frame to which images will be rendered.
*
* @return the new tile manager object or null if an error occurred.
*/
public static ImageManager createImageManager (Frame frame)
{
ResourceManager rmgr = createResourceManager();
return new ImageManager(rmgr, frame);
}
/**
* Creates a <code>TileManager</code> object.
*
@@ -147,20 +132,11 @@ public class MisoUtil
Config config, ImageManager imgmgr)
{
TileSetRepository tsrepo = createTileSetRepository(config, imgmgr);
TileManager tilemgr = new TileManager(tsrepo);
TileManager tilemgr = new TileManager(imgmgr);
tilemgr.setTileSetRepository(tsrepo);
return tilemgr;
}
/**
* Creates a <code>ResourceManager</code> object.
*
* @return the new resource manager object or null if an error occurred.
*/
protected static ResourceManager createResourceManager ()
{
return new ResourceManager("rsrc");
}
/**
* Creates a <code>TileSetRepository</code> object, reading the
* class name to instantiate from the config object.