Load tileset descriptions from an XML file.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@57 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-17 17:21:33 +00:00
parent 7fe2849a93
commit cb4d268139
10 changed files with 258 additions and 81 deletions
@@ -1,5 +1,5 @@
//
// $Id: DisplayMisoSceneImpl.java,v 1.4 2001/07/16 22:12:01 shaper Exp $
// $Id: DisplayMisoSceneImpl.java,v 1.5 2001/07/17 17:21:33 shaper Exp $
package com.threerings.cocktail.miso.scene;
@@ -216,7 +216,7 @@ public class Scene
protected static final String DEF_SCENE_NAME = "Untitled Scene";
protected static final short DEF_TSID = 0;
protected static final short DEF_TSID = 1000;
protected static final short DEF_TID = 1;
protected String _name; // the scene name
@@ -1,9 +1,9 @@
//
// $Id: SceneManagerImpl.java,v 1.1 2001/07/16 22:12:01 shaper Exp $
// $Id: SceneManagerImpl.java,v 1.2 2001/07/17 17:21:33 shaper Exp $
package com.threerings.cocktail.miso.scene;
public class SceneManagerImpl implements SceneManager
public abstract class SceneManagerImpl implements SceneManager
{
public Scene getScene (int sid)
{
@@ -1,14 +1,15 @@
//
// $Id: CompiledTileSetManager.java,v 1.2 2001/07/16 18:59:31 shaper Exp $
// $Id: CompiledTileSetManager.java,v 1.3 2001/07/17 17:21:33 shaper Exp $
package com.threerings.cocktail.miso.tile;
import com.samskivert.util.Config;
import java.io.InputStream;
import java.io.IOException;
public class CompiledTileSetManager extends TileSetManagerImpl
{
public CompiledTileSetManager (Config config)
public void loadTileSets (InputStream tis) throws IOException
{
super(config);
// TBD
}
}
@@ -1,14 +1,41 @@
//
// $Id: EditableTileSetManager.java,v 1.2 2001/07/16 18:59:31 shaper Exp $
// $Id: EditableTileSetManager.java,v 1.3 2001/07/17 17:21:33 shaper Exp $
package com.threerings.cocktail.miso.tile;
import com.samskivert.util.Config;
import com.threerings.cocktail.miso.Log;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
/**
* Extends general tileset manager functionality to allow reading
* tileset information from XML files. The XML file format allows for
* improved version-control, and makes tilesets easier to view, edit,
* and re-use than might otherwise be the case.
*/
public class EditableTileSetManager extends TileSetManagerImpl
{
public EditableTileSetManager (Config config)
public void loadTileSets (InputStream tis) throws IOException
{
super(config);
// read all tileset descriptions from the XML input stream
XMLTileSetParser parser = new XMLTileSetParser();
parser.loadTileSets(tis);
// grab any resulting tileset objects
ArrayList tsets = parser.getTileSets();
if (tsets == null) {
Log.warning("No tileset descriptions found [tis=" + tis + "].");
return;
}
// and copy them 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 + "].");
}
}
}