Added code to read configuration of which fringing tiles we have images
for. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1183 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: FringeConfiguration.java,v 1.1 2002/04/03 22:52:44 ray Exp $
|
// $Id: FringeConfiguration.java,v 1.2 2002/04/04 04:06:57 ray Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -59,6 +59,25 @@ public class FringeConfiguration implements Serializable
|
|||||||
_frecs.put(frec.base_tsid, frec);
|
_frecs.put(frec.base_tsid, frec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* During parsing we get an int[] representing the fringes we have
|
||||||
|
* defined.
|
||||||
|
*/
|
||||||
|
public void setTiles (int[] tiles)
|
||||||
|
{
|
||||||
|
// create an array of all possible tiles and set them all to invalid
|
||||||
|
_bits = new int[256];
|
||||||
|
for (int ii=0; ii < 256; ii++) {
|
||||||
|
_bits[ii] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill in the fringebit configurations we have tiles for with the
|
||||||
|
// index of the tiles
|
||||||
|
for (int ii=0; ii < tiles.length; ii++) {
|
||||||
|
_bits[tiles[ii]] = ii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the first tileset fringe upon the second?
|
* Does the first tileset fringe upon the second?
|
||||||
*/
|
*/
|
||||||
@@ -85,6 +104,32 @@ public class FringeConfiguration implements Serializable
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the tile index of any fringing tileset that should be used
|
||||||
|
* if the following fringebits are turned on.
|
||||||
|
* @return -1 if not defined
|
||||||
|
*/
|
||||||
|
public int getTileIndexFromFringeBits (int bits)
|
||||||
|
{
|
||||||
|
return _bits[bits];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tileset id of the fringe for the specified basesetid.
|
||||||
|
* We don't error check anything because you should be doing the right
|
||||||
|
* thing here.
|
||||||
|
*/
|
||||||
|
public int getFringeTileSetID (int basesetid)
|
||||||
|
{
|
||||||
|
FringeRecord f = (FringeRecord) _frecs.get(basesetid);
|
||||||
|
|
||||||
|
// for now we just return the 1st tilesetid... no randomization
|
||||||
|
return ((FringeTileSetRecord) f.tilesets.get(0)).fringe_tsid;
|
||||||
|
}
|
||||||
|
|
||||||
/** The mapping from base tileset id to fringerecord. */
|
/** The mapping from base tileset id to fringerecord. */
|
||||||
protected HashIntMap _frecs = new HashIntMap();
|
protected HashIntMap _frecs = new HashIntMap();
|
||||||
|
|
||||||
|
/** An array that matches fringebits to fringe tile indexes. */
|
||||||
|
protected int[] _bits;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: FringeConfigurationParser.java,v 1.1 2002/04/03 22:52:44 ray Exp $
|
// $Id: FringeConfigurationParser.java,v 1.2 2002/04/04 04:06:57 ray Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene.tools.xml;
|
package com.threerings.miso.scene.tools.xml;
|
||||||
|
|
||||||
@@ -42,8 +42,27 @@ public class FringeConfigurationParser extends CompiledConfigParser
|
|||||||
protected void addRules (Digester digest)
|
protected void addRules (Digester digest)
|
||||||
{
|
{
|
||||||
// configure top-level constraints
|
// configure top-level constraints
|
||||||
String prefix = "fringes";
|
String prefix = "fringe";
|
||||||
digest.addRule(prefix, new SetPropertyFieldsRule(digest));
|
digest.addRule(prefix, new Rule(digest) {
|
||||||
|
// parse the bits
|
||||||
|
public void begin (Attributes attrs)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
FringeConfiguration fc = (FringeConfiguration) digester.peek();
|
||||||
|
|
||||||
|
for (int ii=0; ii < attrs.getLength(); ii++) {
|
||||||
|
String name = attrs.getLocalName(ii);
|
||||||
|
if (StringUtil.blank(name)) {
|
||||||
|
name = attrs.getQName(ii);
|
||||||
|
}
|
||||||
|
String value = attrs.getValue(ii);
|
||||||
|
|
||||||
|
if ("tiles".equals(name)) {
|
||||||
|
fc.setTiles(StringUtil.parseIntArray(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// create and configure fringe config instances
|
// create and configure fringe config instances
|
||||||
prefix += "/base";
|
prefix += "/base";
|
||||||
|
|||||||
Reference in New Issue
Block a user