Made the ruleset actually do the right thing.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@669 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,30 +1,24 @@
|
|||||||
//
|
//
|
||||||
// $Id: BaseTileSetRuleSet.java,v 1.5 2001/11/27 22:17:42 mdb Exp $
|
// $Id: BaseTileSetRuleSet.java,v 1.6 2001/11/29 00:18:33 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.tools.tile.xml;
|
package com.threerings.miso.tools.tile.xml;
|
||||||
|
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.apache.commons.digester.Digester;
|
import org.apache.commons.digester.Digester;
|
||||||
|
|
||||||
|
import com.samskivert.util.StringUtil;
|
||||||
|
import com.samskivert.xml.CallMethodSpecialRule;
|
||||||
|
|
||||||
import com.threerings.media.tile.TileSet;
|
import com.threerings.media.tile.TileSet;
|
||||||
import com.threerings.media.tools.tile.xml.SwissArmyTileSetRuleSet;
|
import com.threerings.media.tools.tile.xml.SwissArmyTileSetRuleSet;
|
||||||
import com.threerings.miso.tile.BaseTileSet;
|
import com.threerings.miso.tile.BaseTileSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses {@link BaseTileSet} instances from a tileset description. A
|
* Parses {@link BaseTileSet} instances from a tileset description. Base
|
||||||
* uniform tileset description looks like so:
|
* tilesets extend swiss army tilesets with the addition of a passability
|
||||||
|
* flag for each tile.
|
||||||
*
|
*
|
||||||
* <pre>
|
* @see SwissArmyTileSetRuleSet
|
||||||
* <tileset name="Sample Miso Tileset">
|
|
||||||
* <imgpath>path/to/image.png</imgpath>
|
|
||||||
* <!-- the width of each tile in pixels -->
|
|
||||||
* <width>64</width>
|
|
||||||
* <!-- the height of each tile in pixels -->
|
|
||||||
* <height>48</height>
|
|
||||||
* <!-- the total number of tiles in the set -->
|
|
||||||
* <tileCount>16</tileCount>
|
|
||||||
* </tileset>
|
|
||||||
* </pre>
|
|
||||||
*/
|
*/
|
||||||
public class BaseTileSetRuleSet extends SwissArmyTileSetRuleSet
|
public class BaseTileSetRuleSet extends SwissArmyTileSetRuleSet
|
||||||
{
|
{
|
||||||
@@ -33,15 +27,25 @@ public class BaseTileSetRuleSet extends SwissArmyTileSetRuleSet
|
|||||||
{
|
{
|
||||||
super.addRuleInstances(digester);
|
super.addRuleInstances(digester);
|
||||||
|
|
||||||
digester.addCallMethod(
|
digester.addRule(
|
||||||
_prefix + "/tileset/width", "setWidth", 0,
|
_prefix + TILESET_PATH + "/passable",
|
||||||
new Class[] { java.lang.Integer.TYPE });
|
new CallMethodSpecialRule(digester) {
|
||||||
|
public void parseAndSet (String bodyText, Object target)
|
||||||
|
{
|
||||||
|
int[] values = StringUtil.parseIntArray(bodyText);
|
||||||
|
boolean[] passable = new boolean[values.length];
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
passable[i] = (values[i] != 0);
|
||||||
|
}
|
||||||
|
BaseTileSet starget = (BaseTileSet)target;
|
||||||
|
starget.setPassability(passable);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected TileSet createTileSet (Attributes attributes)
|
protected Class getTileSetClass ()
|
||||||
{
|
{
|
||||||
// we use uniform tilesets
|
return BaseTileSet.class;
|
||||||
return new BaseTileSet();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user