Initial work on reading and writing scenes to XML files.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@113 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-23 22:31:48 +00:00
parent bc3d2a4e18
commit f02475b4c2
12 changed files with 285 additions and 116 deletions
@@ -1,14 +1,12 @@
//
// $Id: EditableTileSetManager.java,v 1.7 2001/07/23 18:52:51 shaper Exp $
// $Id: EditableTileSetManager.java,v 1.8 2001/07/23 22:31:48 shaper Exp $
package com.threerings.miso.tile;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import com.samskivert.util.Config;
import com.samskivert.util.ConfigUtil;
import com.threerings.miso.Log;
import com.threerings.media.ImageManager;
@@ -24,43 +22,29 @@ public class EditableTileSetManager extends TileSetManagerImpl
{
super.init(config, imgmgr);
// load the tileset descriptions
// load the tilesets from the XML description file
String fname = config.getValue("miso.tilesets", (String)null);
loadTileSets(fname);
}
/**
* Load the tilesets described in the specified file into the set
* of available tilesets.
*/
protected void loadTileSets (String fname)
{
try {
InputStream tis = ConfigUtil.getStream(fname);
if (tis == null) {
Log.warning("Couldn't find file [fname=" + fname + "].");
return;
}
// read all tileset descriptions from the XML input stream
XMLTileSetParser parser = new XMLTileSetParser();
ArrayList tsets = parser.loadTileSets(tis);
if (tsets == null) {
Log.warning("No tilesets found [tis=" + tis + "].");
return;
}
// copy new tilesets into the main tileset hashtable
int size = tsets.size();
for (int ii = 0; ii < size; ii++) {
TileSet tset = (TileSet)tsets.get(ii);
_tilesets.put(tset.getId(), tset);
Log.info("Adding tileset to cache [tset=" + tset + "].");
}
ArrayList tilesets = null;
try {
tilesets = new XMLTileSetParser().loadTileSets(fname);
} catch (IOException ioe) {
Log.warning("Exception loading tileset [fname=" + fname +
", ioe=" + ioe + "].");
}
return;
}
// bail if we didn't find any tilesets
int size = tilesets.size();
if (size == 0) {
Log.warning("No tilesets found [fname=" + fname + "].");
return;
}
// copy new tilesets into the main tileset hashtable
for (int ii = 0; ii < size; ii++) {
TileSet tset = (TileSet)tilesets.get(ii);
_tilesets.put(tset.getId(), tset);
Log.info("Adding tileset to cache [tset=" + tset + "].");
}
}
}