General updating per initial code review. Created EditableSceneView

to separate scene display from editing functionality.  Load and
initialize managers in a fashion that more appropriately hides the
implementation details.  Tidied comments up a bit.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@103 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-23 18:52:51 +00:00
parent 00388caaa5
commit 2572535f95
19 changed files with 210 additions and 252 deletions
@@ -1,17 +1,8 @@
//
// $Id: CompiledTileSetManager.java,v 1.6 2001/07/21 01:51:10 shaper Exp $
// $Id: CompiledTileSetManager.java,v 1.7 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.tile;
import com.threerings.media.ImageManager;
import java.io.InputStream;
import java.io.IOException;
public class CompiledTileSetManager extends TileSetManagerImpl
{
public void loadTileSets (InputStream tis) throws IOException
{
// TBD
}
}
@@ -1,15 +1,17 @@
//
// $Id: EditableTileSetManager.java,v 1.6 2001/07/21 01:51:10 shaper Exp $
// $Id: EditableTileSetManager.java,v 1.7 2001/07/23 18:52:51 shaper Exp $
package com.threerings.miso.tile;
import com.threerings.miso.Log;
import com.threerings.media.ImageManager;
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;
/**
* Extends general tileset manager functionality to allow reading
* tileset information from XML files. The XML file format allows for
@@ -18,25 +20,47 @@ import java.util.ArrayList;
*/
public class EditableTileSetManager extends TileSetManagerImpl
{
public void loadTileSets (InputStream tis) throws IOException
public void init (Config config, ImageManager imgmgr)
{
// read all tileset descriptions from the XML input stream
XMLTileSetParser parser = new XMLTileSetParser();
parser.loadTileSets(tis);
super.init(config, imgmgr);
// grab any resulting tileset objects
ArrayList tsets = parser.getTileSets();
if (tsets == null) {
Log.warning("No tileset descriptions found [tis=" + tis + "].");
return;
}
// load the tileset descriptions
String fname = config.getValue("miso.tilesets", (String)null);
loadTileSets(fname);
}
// 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 + "].");
/**
* 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 + "].");
}
} catch (IOException ioe) {
Log.warning("Exception loading tileset [fname=" + fname +
", ioe=" + ioe + "].");
}
}
}