Implemented and/or cleaned up the XML scene writers.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@675 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
//
|
//
|
||||||
// $Id: MisoSceneWriter.java,v 1.2 2001/11/20 04:15:44 mdb Exp $
|
// $Id: MisoSceneWriter.java,v 1.3 2001/11/29 06:36:28 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.tools.scene.xml;
|
package com.threerings.miso.tools.scene.xml;
|
||||||
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import com.megginson.sax.DataWriter;
|
import com.megginson.sax.DataWriter;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.threerings.miso.scene.MisoSceneModel;
|
import com.threerings.miso.scene.MisoSceneModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,11 +25,24 @@ public class MisoSceneWriter
|
|||||||
throws SAXException
|
throws SAXException
|
||||||
{
|
{
|
||||||
writer.startElement("miso");
|
writer.startElement("miso");
|
||||||
writer.dataElement("width", Integer.toString(model.width));
|
writeSceneData(model, writer);
|
||||||
writer.dataElement("height", Integer.toString(model.height));
|
|
||||||
writer.dataElement("base", StringUtil.toString(model.baseTileIds));
|
|
||||||
writer.dataElement("fringe", StringUtil.toString(model.fringeTileIds));
|
|
||||||
writer.dataElement("object", StringUtil.toString(model.objectTileIds));
|
|
||||||
writer.endElement("miso");
|
writer.endElement("miso");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes just the scene data which is handy for derived classes which
|
||||||
|
* may wish to add their own scene data to the scene output.
|
||||||
|
*/
|
||||||
|
protected void writeSceneData (MisoSceneModel model, DataWriter writer)
|
||||||
|
throws SAXException
|
||||||
|
{
|
||||||
|
writer.dataElement("width", Integer.toString(model.width));
|
||||||
|
writer.dataElement("height", Integer.toString(model.height));
|
||||||
|
writer.dataElement("base",
|
||||||
|
StringUtil.toString(model.baseTileIds, "", ""));
|
||||||
|
writer.dataElement("fringe",
|
||||||
|
StringUtil.toString(model.fringeTileIds, "", ""));
|
||||||
|
writer.dataElement("object",
|
||||||
|
StringUtil.toString(model.objectTileIds, "", ""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
//
|
||||||
|
// $Id: SpotSceneWriter.java,v 1.1 2001/11/29 06:36:28 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.whirled.tools.spot.xml;
|
||||||
|
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import com.megginson.sax.DataWriter;
|
||||||
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
|
import com.threerings.whirled.tools.xml.SceneWriter;
|
||||||
|
import com.threerings.whirled.spot.data.SpotSceneModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates an XML representation of a {@link SpotSceneModel}.
|
||||||
|
*/
|
||||||
|
public class SpotSceneWriter extends SceneWriter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Writes the data for the supplied {@link SceneModel} to the XML
|
||||||
|
* writer supplied. The writer will already be configured with the
|
||||||
|
* appropriate indentation level so that this writer can simply output
|
||||||
|
* its elements and allow the calling code to determine where in the
|
||||||
|
* greater scene description file the scene data should live.
|
||||||
|
*/
|
||||||
|
public void writeScene (SpotSceneModel model, DataWriter writer)
|
||||||
|
throws SAXException
|
||||||
|
{
|
||||||
|
writer.startElement("spot");
|
||||||
|
writeSceneData(model, writer);
|
||||||
|
writer.endElement("spot");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes just the scene data which is handy for derived classes which
|
||||||
|
* may wish to add their own scene data to the scene output.
|
||||||
|
*/
|
||||||
|
protected void writeSceneData (SpotSceneModel model, DataWriter writer)
|
||||||
|
throws SAXException
|
||||||
|
{
|
||||||
|
super.writeSceneData(model, writer);
|
||||||
|
|
||||||
|
writer.dataElement("locationIds",
|
||||||
|
StringUtil.toString(model.locationIds, "", ""));
|
||||||
|
writer.dataElement("locationX",
|
||||||
|
StringUtil.toString(model.locationX, "", ""));
|
||||||
|
writer.dataElement("locationY",
|
||||||
|
StringUtil.toString(model.locationY, "", ""));
|
||||||
|
writer.dataElement("locationOrients",
|
||||||
|
StringUtil.toString(model.locationOrients, "", ""));
|
||||||
|
writer.dataElement("locationClusters",
|
||||||
|
StringUtil.toString(model.locationClusters, "", ""));
|
||||||
|
writer.dataElement("defaultEntranceId",
|
||||||
|
Integer.toString(model.defaultEntranceId));
|
||||||
|
writer.dataElement("portalIds",
|
||||||
|
StringUtil.toString(model.portalIds, "", ""));
|
||||||
|
writer.dataElement("targetLocIds",
|
||||||
|
StringUtil.toString(model.targetLocIds, "", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// $Id: SceneWriter.java,v 1.1 2001/11/29 06:36:29 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.whirled.tools.xml;
|
||||||
|
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import com.megginson.sax.DataWriter;
|
||||||
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
|
import com.threerings.whirled.data.SceneModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates an XML representation of a {@link SceneModel}.
|
||||||
|
*/
|
||||||
|
public class SceneWriter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Writes the data for the supplied {@link SceneModel} to the XML
|
||||||
|
* writer supplied. The writer will already be configured with the
|
||||||
|
* appropriate indentation level so that this writer can simply output
|
||||||
|
* its elements and allow the calling code to determine where in the
|
||||||
|
* greater scene description file the scene data should live.
|
||||||
|
*/
|
||||||
|
public void writeScene (SceneModel model, DataWriter writer)
|
||||||
|
throws SAXException
|
||||||
|
{
|
||||||
|
writer.startElement("scene");
|
||||||
|
writeSceneData(model, writer);
|
||||||
|
writer.endElement("scene");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes just the scene data which is handy for derived classes which
|
||||||
|
* may wish to add their own scene data to the scene output.
|
||||||
|
*/
|
||||||
|
protected void writeSceneData (SceneModel model, DataWriter writer)
|
||||||
|
throws SAXException
|
||||||
|
{
|
||||||
|
writer.dataElement("sceneId", Integer.toString(model.sceneId));
|
||||||
|
writer.dataElement("version", Integer.toString(model.version));
|
||||||
|
writer.dataElement("neighborIds",
|
||||||
|
StringUtil.toString(model.neighborIds, "", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user