Added row-based tile width, image offset, and image row/column gap
distance parameters to tile sets. Removed constant tile width/height references except, for now, for isometric tile rendering which still requires tiles that are 32x16. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@130 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
//
|
||||
// $Id: XMLTileSetParser.java,v 1.7 2001/07/24 22:52:02 shaper Exp $
|
||||
// $Id: XMLTileSetParser.java,v 1.8 2001/07/28 01:31:51 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@@ -34,9 +35,14 @@ public class XMLTileSetParser extends DefaultHandler
|
||||
// construct the tileset object on tag close
|
||||
if (qName.equals("tileset")) {
|
||||
TileSet tset = new TileSet(
|
||||
_tsName, _tsTsid, _tsImgFile, _tsRowHeight, _tsTileCount);
|
||||
_tsName, _tsTsid, _tsImgFile, _tsRowWidth, _tsRowHeight,
|
||||
_tsTileCount, _tsOffsetPos, _tsGapDist);
|
||||
|
||||
_tilesets.add(tset);
|
||||
}
|
||||
|
||||
// prepare to read another tileset object
|
||||
init();
|
||||
}
|
||||
|
||||
// note that we're not within a tag to avoid considering any
|
||||
// characters during this quiescent time
|
||||
@@ -66,12 +72,21 @@ public class XMLTileSetParser extends DefaultHandler
|
||||
} else if (_tag.equals("imagefile")) {
|
||||
_tsImgFile = str;
|
||||
|
||||
} else if (_tag.equals("rowwidth")) {
|
||||
_tsRowWidth = StringUtil.parseIntArray(str);
|
||||
|
||||
} else if (_tag.equals("rowheight")) {
|
||||
_tsRowHeight = StringUtil.parseIntArray(str);
|
||||
|
||||
} else if (_tag.equals("tilecount")) {
|
||||
_tsTileCount = StringUtil.parseIntArray(str);
|
||||
}
|
||||
|
||||
} else if (_tag.equals("offsetpos")) {
|
||||
getPoint(str, _tsOffsetPos);
|
||||
|
||||
} else if (_tag.equals("gapdist")) {
|
||||
getPoint(str, _tsGapDist);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList loadTileSets (String fname) throws IOException
|
||||
@@ -83,6 +98,9 @@ public class XMLTileSetParser extends DefaultHandler
|
||||
return _tilesets;
|
||||
}
|
||||
|
||||
// prepare to read a new tileset
|
||||
init();
|
||||
|
||||
// read all tileset descriptions from the XML input stream
|
||||
XMLUtil.parse(this, tis);
|
||||
|
||||
@@ -96,6 +114,30 @@ public class XMLTileSetParser extends DefaultHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize internal member data used to gather tileset
|
||||
* information during parsing.
|
||||
*/
|
||||
protected void init ()
|
||||
{
|
||||
_tsOffsetPos = new Point();
|
||||
_tsGapDist = new Point();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string containing values as (x, y) into the
|
||||
* corresponding integer values and populates the given point
|
||||
* object.
|
||||
*
|
||||
* @param str the point values in string format.
|
||||
* @param point the point object to populate.
|
||||
*/
|
||||
protected void getPoint (String str, Point point)
|
||||
{
|
||||
int vals[] = StringUtil.parseIntArray(str);
|
||||
point.setLocation(vals[0], vals[1]);
|
||||
}
|
||||
|
||||
/** The XML element tag currently being processed. */
|
||||
protected String _tag;
|
||||
|
||||
@@ -106,5 +148,6 @@ public class XMLTileSetParser extends DefaultHandler
|
||||
protected String _tsName;
|
||||
protected int _tsTsid;
|
||||
protected String _tsImgFile;
|
||||
protected int[] _tsRowHeight, _tsTileCount;
|
||||
protected int[] _tsRowWidth, _tsRowHeight, _tsTileCount;
|
||||
protected Point _tsOffsetPos, _tsGapDist;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user