Bundles! Got all the tileset bundle stuff working and wrote some tests to
inrease my confidence in the use of the word "working". git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@635 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# $Id: manager.properties,v 1.1 2001/11/21 02:42:16 mdb Exp $
|
||||
#
|
||||
# Test resource manager configuration
|
||||
|
||||
# used to test the BundledTileSetRepository
|
||||
resource.set.bundle_test = rsrc/media/tools/tile/bundle.jar
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 155 KiB |
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- test tileset bundle -->
|
||||
<bundle>
|
||||
<uniform>
|
||||
<tileset name="Node Icons">
|
||||
<imagePath>node-icons.png</imagePath>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
<tileCount>8</tileCount>
|
||||
</tileset>
|
||||
</uniform>
|
||||
|
||||
<swissarmy>
|
||||
<tileset name="Fringe">
|
||||
<imagePath>fringe.png</imagePath>
|
||||
<heights>48, 48, 48, 48, 48</heights>
|
||||
<widths>64, 64, 64, 64, 64</widths>
|
||||
<tileCounts>8, 8, 8, 8, 8</tileCounts>
|
||||
</tileset>
|
||||
</swissarmy>
|
||||
|
||||
<object>
|
||||
<tileset name="Building">
|
||||
<imagePath>building.png</imagePath>
|
||||
<heights>293</heights>
|
||||
<widths>224</widths>
|
||||
<tileCounts>4</tileCounts>
|
||||
<offsetPos>2, 2</offsetPos>
|
||||
<gapDist>4, 0</gapDist>
|
||||
<objects>
|
||||
<object tid="0" width="4" height="3"/>
|
||||
<object tid="1" width="3" height="4"/>
|
||||
<object tid="2" width="4" height="3"/>
|
||||
<object tid="3" width="3" height="4"/>
|
||||
</objects>
|
||||
</tileset>
|
||||
</object>
|
||||
</bundle>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- test configuration for the tileset bundler -->
|
||||
<bundler-config>
|
||||
<mapping>
|
||||
<path>bundle/uniform</path>
|
||||
<ruleset>com.threerings.media.tools.tile.xml.UniformTileSetRuleSet</ruleset>
|
||||
</mapping>
|
||||
<mapping>
|
||||
<path>bundle/swissarmy</path>
|
||||
<ruleset>
|
||||
com.threerings.media.tools.tile.xml.SwissArmyTileSetRuleSet
|
||||
</ruleset>
|
||||
</mapping>
|
||||
<!--
|
||||
<mapping>
|
||||
<path>bundle/object</path>
|
||||
<ruleset>com.threerings.media.tools.tile.xml.ObjectTileSetRuleSet</ruleset>
|
||||
</mapping>
|
||||
-->
|
||||
</bundler-config>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 369 B |
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TestApp.java,v 1.5 2001/11/18 04:09:20 mdb Exp $
|
||||
// $Id: TestApp.java,v 1.6 2001/11/21 02:42:16 mdb Exp $
|
||||
|
||||
package com.threerings.cast.tools.builder;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TestApp
|
||||
// create the handles on our various services
|
||||
_config = MisoUtil.createConfig();
|
||||
|
||||
ResourceManager rsrcmgr = new ResourceManager("rsrc");
|
||||
ResourceManager rsrcmgr = new ResourceManager(null, "rsrc");
|
||||
|
||||
// TBD: sort out component repository
|
||||
ComponentRepository crepo = null;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// $Id: BundledTileSetRepositoryTest.java,v 1.1 2001/11/21 02:42:16 mdb Exp $
|
||||
|
||||
package com.threerings.media.tile.bundle;
|
||||
|
||||
import java.util.Iterator;
|
||||
import com.threerings.resource.ResourceManager;
|
||||
|
||||
public class BundledTileSetRepositoryTest
|
||||
{
|
||||
public static void main (String[] args)
|
||||
{
|
||||
try {
|
||||
ResourceManager rmgr = new ResourceManager(null, "rsrc");
|
||||
BundledTileSetRepository repo =
|
||||
new BundledTileSetRepository(rmgr, "bundle_test");
|
||||
Iterator sets = repo.enumerateTileSets();
|
||||
while (sets.hasNext()) {
|
||||
System.out.println(sets.next());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// $Id: BuildTestTileSetBundle.java,v 1.1 2001/11/21 02:42:16 mdb Exp $
|
||||
|
||||
package com.threerings.media.tools.tile.bundle;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.samskivert.io.PersistenceException;
|
||||
import com.samskivert.test.TestUtil;
|
||||
|
||||
import com.threerings.media.tile.TileSetIDBroker;
|
||||
|
||||
public class TileSetBundlerTest
|
||||
{
|
||||
public static void main (String[] args)
|
||||
{
|
||||
try {
|
||||
TileSetIDBroker broker = new DummyTileSetIDBroker();
|
||||
|
||||
// sort out some paths
|
||||
String configPath = TestUtil.getResourcePath(CONFIG_PATH);
|
||||
String descPath = TestUtil.getResourcePath(BUNDLE_DESC_PATH);
|
||||
String targetPath = TestUtil.getResourcePath(TARGET_PATH);
|
||||
|
||||
// create our bundler and get going
|
||||
TileSetBundler bundler = new TileSetBundler(configPath);
|
||||
File descFile = new File(descPath);
|
||||
bundler.createBundle(broker, descFile, targetPath);
|
||||
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/** Dummy tileset id broker that makes up tileset ids (which are
|
||||
* consistent in the course of execution of the application, but not
|
||||
* between invocations). */
|
||||
protected static class DummyTileSetIDBroker
|
||||
extends HashMap
|
||||
implements TileSetIDBroker
|
||||
{
|
||||
public int getTileSetID (String tileSetName)
|
||||
throws PersistenceException
|
||||
{
|
||||
Integer id = (Integer)get(tileSetName);
|
||||
if (id == null) {
|
||||
id = new Integer(++_nextId);
|
||||
put(tileSetName, id);
|
||||
}
|
||||
return id.intValue();
|
||||
}
|
||||
|
||||
public void commit ()
|
||||
throws PersistenceException
|
||||
{
|
||||
}
|
||||
|
||||
protected int _nextId;
|
||||
}
|
||||
|
||||
protected static final String CONFIG_PATH =
|
||||
"media/tools/tile/bundle/bundler-config.xml";
|
||||
|
||||
protected static final String BUNDLE_DESC_PATH =
|
||||
"media/tools/tile/bundle/bundle.xml";
|
||||
|
||||
protected static final String TARGET_PATH =
|
||||
"media/tools/tile/bundle.jar";
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// $Id: XMLTileSetParserTest.java,v 1.1 2001/11/21 02:42:16 mdb Exp $
|
||||
|
||||
package com.threerings.media.tools.tile.xml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class XMLTileSetParserTest extends TestCase
|
||||
{
|
||||
public XMLTileSetParserTest ()
|
||||
{
|
||||
super(XMLTileSetParserTest.class.getName());
|
||||
}
|
||||
|
||||
public void runTest ()
|
||||
{
|
||||
HashMap sets = new HashMap();
|
||||
|
||||
XMLTileSetParser parser = new XMLTileSetParser();
|
||||
// add some rulesets
|
||||
parser.addRuleSet("tilesets/uniform", new UniformTileSetRuleSet());
|
||||
parser.addRuleSet("tilesets/swissarmy", new SwissArmyTileSetRuleSet());
|
||||
// parser.addRuleSet("tilesets/object", new ObjectTileSetRuleSet());
|
||||
|
||||
// load up the tilesets
|
||||
try {
|
||||
parser.loadTileSets(TILESET_PATH, sets);
|
||||
|
||||
// print them out
|
||||
Iterator iter = sets.values().iterator();
|
||||
while (iter.hasNext()) {
|
||||
System.out.println(iter.next());
|
||||
}
|
||||
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
fail("loadTileSets() failed");
|
||||
}
|
||||
}
|
||||
|
||||
public static Test suite ()
|
||||
{
|
||||
return new XMLTileSetParserTest();
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
XMLTileSetParserTest test = new XMLTileSetParserTest();
|
||||
test.runTest();
|
||||
}
|
||||
|
||||
protected static final String TILESET_PATH =
|
||||
"rsrc/media/tools/tile/xml/tilesets.xml";
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ViewerApp.java,v 1.15 2001/11/18 04:09:20 mdb Exp $
|
||||
// $Id: ViewerApp.java,v 1.16 2001/11/21 02:42:16 mdb Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ViewerApp
|
||||
{
|
||||
// we don't need to configure anything
|
||||
_config = new Config();
|
||||
_rsrcmgr = new ResourceManager("rsrc");
|
||||
_rsrcmgr = new ResourceManager(null, "rsrc");
|
||||
_tilemgr = new TileManager(_rsrcmgr);
|
||||
|
||||
// create the context object
|
||||
|
||||
Reference in New Issue
Block a user