Added getColorizer() to allow derived classes to provide a colorizer for
use when obtaining object tiles. Broke out display scene initialization into an init() method so that derived classes can overrride getColorizer() and rely on their constructor having already been called. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2368 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DisplayMisoScene.java,v 1.10 2003/02/12 07:21:15 mdb Exp $
|
// $Id: DisplayMisoScene.java,v 1.11 2003/04/01 02:17:58 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.client;
|
package com.threerings.miso.client;
|
||||||
|
|
||||||
@@ -13,6 +13,12 @@ import com.threerings.miso.tile.BaseTile;
|
|||||||
*/
|
*/
|
||||||
public interface DisplayMisoScene extends MisoScene
|
public interface DisplayMisoScene extends MisoScene
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* This will be called before the scene is displayed to give it a
|
||||||
|
* chance to look up its image data and prepare itself for display.
|
||||||
|
*/
|
||||||
|
public void init ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base tile at the specified coordinates.
|
* Returns the base tile at the specified coordinates.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IsoSceneView.java,v 1.134 2003/03/10 09:24:04 ray Exp $
|
// $Id: IsoSceneView.java,v 1.135 2003/04/01 02:17:58 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.client;
|
package com.threerings.miso.client;
|
||||||
|
|
||||||
@@ -106,6 +106,7 @@ public class IsoSceneView implements SceneView
|
|||||||
public void setScene (DisplayMisoScene scene)
|
public void setScene (DisplayMisoScene scene)
|
||||||
{
|
{
|
||||||
_scene = scene;
|
_scene = scene;
|
||||||
|
_scene.init();
|
||||||
|
|
||||||
// obtain a list of the objects in the scene and generate records
|
// obtain a list of the objects in the scene and generate records
|
||||||
// for each of them that contain precomputed metrics
|
// for each of them that contain precomputed metrics
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SimpleDisplayMisoSceneImpl.java,v 1.2 2003/02/20 00:40:13 ray Exp $
|
// $Id: SimpleDisplayMisoSceneImpl.java,v 1.3 2003/04/01 02:17:58 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.client;
|
package com.threerings.miso.client;
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ import com.threerings.media.tile.NoSuchTileException;
|
|||||||
import com.threerings.media.tile.NoSuchTileSetException;
|
import com.threerings.media.tile.NoSuchTileSetException;
|
||||||
import com.threerings.media.tile.ObjectTile;
|
import com.threerings.media.tile.ObjectTile;
|
||||||
import com.threerings.media.tile.Tile;
|
import com.threerings.media.tile.Tile;
|
||||||
|
import com.threerings.media.tile.TileSet;
|
||||||
|
|
||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
import com.threerings.miso.client.util.ObjectSet;
|
import com.threerings.miso.client.util.ObjectSet;
|
||||||
@@ -49,6 +50,13 @@ public class SimpleDisplayMisoSceneImpl extends SimpleMisoSceneImpl
|
|||||||
_base = new BaseTile[swid*shei];
|
_base = new BaseTile[swid*shei];
|
||||||
_fringe = new Tile[swid*shei];
|
_fringe = new Tile[swid*shei];
|
||||||
_covered = new boolean[swid*shei];
|
_covered = new boolean[swid*shei];
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public void init ()
|
||||||
|
{
|
||||||
|
int swid = _model.width;
|
||||||
|
int shei = _model.height;
|
||||||
|
|
||||||
// load up the tiles for our base layer
|
// load up the tiles for our base layer
|
||||||
for (int column = 0; column < shei; column++) {
|
for (int column = 0; column < shei; column++) {
|
||||||
@@ -155,7 +163,6 @@ public class SimpleDisplayMisoSceneImpl extends SimpleMisoSceneImpl
|
|||||||
// nothing doing
|
// nothing doing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int tsid = fqTileId >> 16, tid = (fqTileId & 0xFFFF);
|
|
||||||
|
|
||||||
// this is a bit magical, but the tile manager will fetch tiles
|
// this is a bit magical, but the tile manager will fetch tiles
|
||||||
// from the tileset repository and the tile set id from which we
|
// from the tileset repository and the tile set id from which we
|
||||||
@@ -164,7 +171,7 @@ public class SimpleDisplayMisoSceneImpl extends SimpleMisoSceneImpl
|
|||||||
// is well
|
// is well
|
||||||
String errmsg = null;
|
String errmsg = null;
|
||||||
try {
|
try {
|
||||||
_base[y*_model.width+x] = (BaseTile)_tmgr.getTile(tsid, tid);
|
_base[y*_model.width+x] = (BaseTile)_tmgr.getTile(fqTileId);
|
||||||
} catch (ClassCastException cce) {
|
} catch (ClassCastException cce) {
|
||||||
errmsg = "Scene contains non-base tile in base layer";
|
errmsg = "Scene contains non-base tile in base layer";
|
||||||
} catch (NoSuchTileSetException nste) {
|
} catch (NoSuchTileSetException nste) {
|
||||||
@@ -174,7 +181,7 @@ public class SimpleDisplayMisoSceneImpl extends SimpleMisoSceneImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (errmsg != null) {
|
if (errmsg != null) {
|
||||||
Log.warning(errmsg + " [tsid=" + tsid + ", tid=" + tid +
|
Log.warning(errmsg + " [fqtid=" + fqTileId +
|
||||||
", x=" + x + ", y=" + y + "].");
|
", x=" + x + ", y=" + y + "].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,7 +193,8 @@ public class SimpleDisplayMisoSceneImpl extends SimpleMisoSceneImpl
|
|||||||
{
|
{
|
||||||
int tsid = (info.tileId >> 16) & 0xFFFF, tid = (info.tileId & 0xFFFF);
|
int tsid = (info.tileId >> 16) & 0xFFFF, tid = (info.tileId & 0xFFFF);
|
||||||
try {
|
try {
|
||||||
initObject(info, (ObjectTile)_tmgr.getTile(tsid, tid));
|
initObject(info, (ObjectTile)_tmgr.getTile(
|
||||||
|
tsid, tid, getColorizer(info)));
|
||||||
return true;
|
return true;
|
||||||
} catch (NoSuchTileException nste) {
|
} catch (NoSuchTileException nste) {
|
||||||
Log.warning("Scene contains non-existent object tile " +
|
Log.warning("Scene contains non-existent object tile " +
|
||||||
@@ -277,6 +285,18 @@ public class SimpleDisplayMisoSceneImpl extends SimpleMisoSceneImpl
|
|||||||
return new DisplayObjectInfo(source);
|
return new DisplayObjectInfo(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the colorizer for the specified display object. The
|
||||||
|
* colorizer must provide colorization assignments that will be used
|
||||||
|
* to recolor the tile image when it is obtained from the tile
|
||||||
|
* manager. For an object with no colorizations, it is valid to return
|
||||||
|
* null here.
|
||||||
|
*/
|
||||||
|
protected TileSet.Colorizer getColorizer (DisplayObjectInfo oinfo)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/** The tile manager from which we load tiles. */
|
/** The tile manager from which we load tiles. */
|
||||||
protected MisoTileManager _tmgr;
|
protected MisoTileManager _tmgr;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: VirtualDisplayMisoSceneImpl.java,v 1.1 2003/02/12 07:21:15 mdb Exp $
|
// $Id: VirtualDisplayMisoSceneImpl.java,v 1.2 2003/04/01 02:17:58 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.client;
|
package com.threerings.miso.client;
|
||||||
|
|
||||||
@@ -20,6 +20,11 @@ import com.threerings.miso.tile.BaseTile;
|
|||||||
public class VirtualDisplayMisoSceneImpl
|
public class VirtualDisplayMisoSceneImpl
|
||||||
implements DisplayMisoScene
|
implements DisplayMisoScene
|
||||||
{
|
{
|
||||||
|
// documentation inherited from interface
|
||||||
|
public void init ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int getBaseTileId (int x, int y)
|
public int getBaseTileId (int x, int y)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user