UniformTileSets no longer need to have their tileCount set, they will
figure it out from their width/height compared to the source image's width/height. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2573 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IconManager.java,v 1.5 2002/12/07 02:13:00 shaper Exp $
|
// $Id: IconManager.java,v 1.6 2003/05/13 21:33:58 ray Exp $
|
||||||
|
|
||||||
package com.threerings.media;
|
package com.threerings.media;
|
||||||
|
|
||||||
@@ -32,10 +32,10 @@ import com.threerings.media.tile.TileSet;
|
|||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* arrows.path = /rsrc/media/icons/arrows.png
|
* arrows.path = /rsrc/media/icons/arrows.png
|
||||||
* arrows.metrics = 4, 20, 20 # 4 icons that are 20x20
|
* arrows.metrics = 20, 25 # icons that are 20 pixels wide and 25 pixels tall
|
||||||
*
|
*
|
||||||
* smileys.path = /rsrc/media/icons/smileys.png
|
* smileys.path = /rsrc/media/icons/smileys.png
|
||||||
* smileys.metrics = 10, 16, 16 # 16 icons that are 16x16
|
* smileys.metrics = 16, 16 # icons that are 16 pixels square
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* A user could then request an <code>arrows</code> icon like so:
|
* A user could then request an <code>arrows</code> icon like so:
|
||||||
@@ -107,7 +107,7 @@ public class IconManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
int[] metrics = StringUtil.parseIntArray(metstr);
|
int[] metrics = StringUtil.parseIntArray(metstr);
|
||||||
if (metrics == null || metrics.length != 3) {
|
if (metrics == null || metrics.length != 2) {
|
||||||
throw new Exception("Invalid icon set metrics " +
|
throw new Exception("Invalid icon set metrics " +
|
||||||
"[metrics=" + metstr + "]");
|
"[metrics=" + metstr + "]");
|
||||||
}
|
}
|
||||||
@@ -115,10 +115,10 @@ public class IconManager
|
|||||||
// load up the tileset
|
// load up the tileset
|
||||||
if (_rsrcSet == null) {
|
if (_rsrcSet == null) {
|
||||||
set = _tilemgr.loadTileSet(
|
set = _tilemgr.loadTileSet(
|
||||||
path, metrics[0], metrics[1], metrics[2]);
|
path, metrics[0], metrics[1]);
|
||||||
} else {
|
} else {
|
||||||
set = _tilemgr.loadTileSet(
|
set = _tilemgr.loadTileSet(
|
||||||
_rsrcSet, path, metrics[0], metrics[1], metrics[2]);
|
_rsrcSet, path, metrics[0], metrics[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cache it
|
// cache it
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileManager.java,v 1.32 2003/05/05 22:34:48 ray Exp $
|
// $Id: TileManager.java,v 1.33 2003/05/13 21:33:58 ray Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile;
|
package com.threerings.media.tile;
|
||||||
|
|
||||||
@@ -57,10 +57,9 @@ public class TileManager
|
|||||||
* Loads up a tileset from the specified image with the specified
|
* Loads up a tileset from the specified image with the specified
|
||||||
* metadata parameters.
|
* metadata parameters.
|
||||||
*/
|
*/
|
||||||
public UniformTileSet loadTileSet (
|
public UniformTileSet loadTileSet (String imgPath, int width, int height)
|
||||||
String imgPath, int count, int width, int height)
|
|
||||||
{
|
{
|
||||||
return loadCachedTileSet("", imgPath, count, width, height);
|
return loadCachedTileSet("", imgPath, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,20 +67,20 @@ public class TileManager
|
|||||||
* specified resource set) with the specified metadata parameters.
|
* specified resource set) with the specified metadata parameters.
|
||||||
*/
|
*/
|
||||||
public UniformTileSet loadTileSet (
|
public UniformTileSet loadTileSet (
|
||||||
String rset, String imgPath, int count, int width, int height)
|
String rset, String imgPath, int width, int height)
|
||||||
{
|
{
|
||||||
return loadTileSet(
|
return loadTileSet(
|
||||||
getImageProvider(rset), rset, imgPath, count, width, height);
|
getImageProvider(rset), rset, imgPath, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public UniformTileSet loadTileSet (
|
public UniformTileSet loadTileSet (
|
||||||
ImageProvider improv, String improvKey, String imgPath,
|
ImageProvider improv, String improvKey, String imgPath,
|
||||||
int count, int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
UniformTileSet uts = loadCachedTileSet(
|
UniformTileSet uts = loadCachedTileSet(
|
||||||
improvKey, imgPath, count, width, height);
|
improvKey, imgPath, width, height);
|
||||||
uts.setImageProvider(improv);
|
uts.setImageProvider(improv);
|
||||||
return uts;
|
return uts;
|
||||||
}
|
}
|
||||||
@@ -99,7 +98,7 @@ public class TileManager
|
|||||||
* Used to load and cache tilesets loaded via {@link #loadTileSet}.
|
* Used to load and cache tilesets loaded via {@link #loadTileSet}.
|
||||||
*/
|
*/
|
||||||
protected UniformTileSet loadCachedTileSet (
|
protected UniformTileSet loadCachedTileSet (
|
||||||
String bundle, String imgPath, int count, int width, int height)
|
String bundle, String imgPath, int width, int height)
|
||||||
{
|
{
|
||||||
String key = bundle + "::" + imgPath;
|
String key = bundle + "::" + imgPath;
|
||||||
UniformTileSet uts = (UniformTileSet)_handcache.get(key);
|
UniformTileSet uts = (UniformTileSet)_handcache.get(key);
|
||||||
@@ -107,7 +106,6 @@ public class TileManager
|
|||||||
uts = new UniformTileSet();
|
uts = new UniformTileSet();
|
||||||
uts.setImageProvider(_defaultProvider);
|
uts.setImageProvider(_defaultProvider);
|
||||||
uts.setImagePath(imgPath);
|
uts.setImagePath(imgPath);
|
||||||
uts.setTileCount(count);
|
|
||||||
uts.setWidth(width);
|
uts.setWidth(width);
|
||||||
uts.setHeight(height);
|
uts.setHeight(height);
|
||||||
_handcache.put(key, uts);
|
_handcache.put(key, uts);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: UniformTileSet.java,v 1.13 2003/05/02 23:32:56 mdb Exp $
|
// $Id: UniformTileSet.java,v 1.14 2003/05/13 21:33:58 ray Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile;
|
package com.threerings.media.tile;
|
||||||
|
|
||||||
@@ -18,16 +18,10 @@ public class UniformTileSet extends TileSet
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
public int getTileCount ()
|
public int getTileCount ()
|
||||||
{
|
{
|
||||||
return _count;
|
BufferedImage tsimg = getRawTileSetImage();
|
||||||
}
|
int perRow = tsimg.getWidth() / _width;
|
||||||
|
int perCol = tsimg.getHeight() / _height;
|
||||||
/**
|
return perRow * perCol;
|
||||||
* Specifies the number of tiles that will be found in the tileset
|
|
||||||
* image managed by this tileset.
|
|
||||||
*/
|
|
||||||
public void setTileCount (int tileCount)
|
|
||||||
{
|
|
||||||
_count = tileCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,9 +84,6 @@ public class UniformTileSet extends TileSet
|
|||||||
buf.append(", height=").append(_height);
|
buf.append(", height=").append(_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The total number of tiles in this tileset. */
|
|
||||||
protected int _count;
|
|
||||||
|
|
||||||
/** The width (in pixels) of the tiles in this tileset. */
|
/** The width (in pixels) of the tiles in this tileset. */
|
||||||
protected int _width;
|
protected int _width;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DumpBundle.java,v 1.9 2003/01/13 22:49:47 mdb Exp $
|
// $Id: DumpBundle.java,v 1.10 2003/05/13 21:33:58 ray Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile.bundle.tools;
|
package com.threerings.media.tile.bundle.tools;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class DumpBundle
|
|||||||
TileSet set = tsb.getTileSet(tsid.intValue());
|
TileSet set = tsb.getTileSet(tsid.intValue());
|
||||||
System.out.println(tsid + " => " + set);
|
System.out.println(tsid + " => " + set);
|
||||||
if (dumpTiles) {
|
if (dumpTiles) {
|
||||||
for (int t = 0; t < set.getTileCount(); t++) {
|
for (int t = 0, nn = set.getTileCount(); t < nn; t++) {
|
||||||
System.out.println(" " + t + " => " +
|
System.out.println(" " + t + " => " +
|
||||||
set.getTile(t));
|
set.getTile(t));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileSetBundler.java,v 1.15 2003/04/27 06:34:43 mdb Exp $
|
// $Id: TileSetBundler.java,v 1.16 2003/05/13 21:33:58 ray Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile.bundle.tools;
|
package com.threerings.media.tile.bundle.tools;
|
||||||
|
|
||||||
@@ -367,7 +367,6 @@ public class TileSetBundler
|
|||||||
ets.setName(set.getName());
|
ets.setName(set.getName());
|
||||||
ets.setWidth(50);
|
ets.setWidth(50);
|
||||||
ets.setHeight(50);
|
ets.setHeight(50);
|
||||||
ets.setTileCount(1);
|
|
||||||
ets.setImagePath(imagePath);
|
ets.setImagePath(imagePath);
|
||||||
bundle.addTileSet(tileSetId, ets);
|
bundle.addTileSet(tileSetId, ets);
|
||||||
// and write an error image to the jar file
|
// and write an error image to the jar file
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: UniformTileSetRuleSet.java,v 1.7 2002/02/05 20:29:10 mdb Exp $
|
// $Id: UniformTileSetRuleSet.java,v 1.8 2003/05/13 21:33:58 ray Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile.tools.xml;
|
package com.threerings.media.tile.tools.xml;
|
||||||
|
|
||||||
@@ -21,8 +21,6 @@ import com.threerings.media.tile.UniformTileSet;
|
|||||||
* <width>64</width>
|
* <width>64</width>
|
||||||
* <!-- the height of each tile in pixels -->
|
* <!-- the height of each tile in pixels -->
|
||||||
* <height>48</height>
|
* <height>48</height>
|
||||||
* <!-- the total number of tiles in the set -->
|
|
||||||
* <tileCount>16</tileCount>
|
|
||||||
* </tileset>
|
* </tileset>
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@@ -39,9 +37,6 @@ public class UniformTileSetRuleSet extends TileSetRuleSet
|
|||||||
digester.addCallMethod(
|
digester.addCallMethod(
|
||||||
_prefix + TILESET_PATH + "/height", "setHeight", 0,
|
_prefix + TILESET_PATH + "/height", "setHeight", 0,
|
||||||
new Class[] { java.lang.Integer.TYPE });
|
new Class[] { java.lang.Integer.TYPE });
|
||||||
digester.addCallMethod(
|
|
||||||
_prefix + TILESET_PATH + "/tileCount", "setTileCount", 0,
|
|
||||||
new Class[] { java.lang.Integer.TYPE });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -64,13 +59,6 @@ public class UniformTileSetRuleSet extends TileSetRuleSet
|
|||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for a <tileCount> element
|
|
||||||
if (set.getTileCount() == 0) {
|
|
||||||
Log.warning("Tile set definition missing valid <tileCount> " +
|
|
||||||
"element [set=" + set + "].");
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user