Fix the scene editor's test tile functionality - we need to place any loaded test tiles into the tile manager so they can show up in the actual scene.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@278 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Mike Thomas
2007-04-11 17:15:39 +00:00
parent a0850ca4e1
commit cccc3a308e
3 changed files with 95 additions and 5 deletions
@@ -156,7 +156,7 @@ public class EditorApp implements Runnable
{
_msgmgr = new MessageManager("rsrc.i18n");
_imgr = new ImageManager(_rmgr, _frame);
_tilemgr = new MisoTileManager(_rmgr, _imgr);
_tilemgr = new EditorTileManager(_rmgr, _imgr);
try {
_tsrepo = new BundledTileSetRepository(_rmgr, _imgr, "tilesets");
@@ -0,0 +1,76 @@
//
// $Id$
//
// Vilya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/vilya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.stage.tools.editor;
import com.samskivert.util.HashIntMap;
import com.threerings.media.tile.NoSuchTileSetException;
import com.threerings.media.tile.TileSet;
import com.threerings.media.image.ImageManager;
import com.threerings.miso.tile.MisoTileManager;
import com.threerings.resource.ResourceManager;
/**
* Extends the normal Miso Tile Manager to allow the use of a set of test tiles that can be used in
* the editor. These are loaded through the TestTileLoader.
*/
public class EditorTileManager extends MisoTileManager
{
public EditorTileManager (ResourceManager rmgr, ImageManager imgr)
{
super(rmgr, imgr);
}
@Override //Documentation inherited
public TileSet getTileSet (int tileSetId)
throws NoSuchTileSetException
{
TileSet testSet = _testSets.get(tileSetId);
if (testSet != null) {
return testSet;
} else {
return super.getTileSet(tileSetId);
}
}
/**
* Add a test tile set to search before normal tilesets.
*/
public void addTestTileSet (int id, TileSet set)
{
_testSets.put(id, set);
}
/**
* Clear all of our existing test tile sets.
*/
public void clearTestTileSets ()
{
_testSets.clear();
}
/**
* All the test tile sets we have available.
*/
protected HashIntMap<TileSet> _testSets = new HashIntMap<TileSet>();
}
@@ -60,6 +60,7 @@ import com.samskivert.util.StringUtil;
import com.threerings.media.SafeScrollPane;
import com.threerings.media.tile.TileManager;
import com.threerings.media.tile.TileSet;
import com.threerings.media.tile.TileSetRepository;
@@ -84,6 +85,7 @@ public class TileInfoPanel extends JSplitPane
registerKeyListener(ctx);
_model = model;
_ctx = ctx;
// we're going to sort all of the available tilesets into those
// which are applicable to each layer
@@ -321,6 +323,11 @@ public class TileInfoPanel extends JSplitPane
}
}
TileManager tileMgr = _ctx.getTileManager();
if (tileMgr instanceof EditorTileManager) {
((EditorTileManager)tileMgr).clearTestTileSets();
}
// insert the new test tiles
Iterator iter = tests.keys();
while (iter.hasNext()) {
@@ -333,7 +340,11 @@ public class TileInfoPanel extends JSplitPane
if (lidx != -1) {
// make up a negative number to refer to this temporary tileset
_layerSets[lidx].add(
new TileSetRecord(lidx, tsid.intValue(), set));
new TileSetRecord(lidx, tsid, set));
}
if (tileMgr instanceof EditorTileManager) {
((EditorTileManager)tileMgr).addTestTileSet(tsid, set);
}
}
@@ -720,6 +731,9 @@ public class TileInfoPanel extends JSplitPane
/** The editor model. */
protected EditorModel _model;
/** Our editor client context. */
protected EditorContext _ctx;
/** The tile table data model. */
protected TileTableModel _tablemodel;
}