Wait for the call to wasResolved to call back about being abandoned as the scene panel is expecting that to be on the AWT thread
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@671 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -67,7 +67,7 @@ public class SceneBlock
|
|||||||
width, height);
|
width, height);
|
||||||
_panel = panel;
|
_panel = panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SceneBlock (MisoSceneModel model, MisoSceneMetrics metrics, TileManager tileMgr,
|
public SceneBlock (MisoSceneModel model, MisoSceneMetrics metrics, TileManager tileMgr,
|
||||||
int tx, int ty, int width, int height)
|
int tx, int ty, int width, int height)
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,13 @@ public class SceneBlock
|
|||||||
if (_panel != null) {
|
if (_panel != null) {
|
||||||
if (_panel.getBlock(_bounds.x, _bounds.y) != this) {
|
if (_panel.getBlock(_bounds.x, _bounds.y) != this) {
|
||||||
// Log.info("Not resolving abandoned block " + this + ".");
|
// Log.info("Not resolving abandoned block " + this + ".");
|
||||||
_panel.blockAbandoned(this);
|
_wasAbandoned = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_panel.blockResolving(this);
|
_panel.blockResolving(this);
|
||||||
}
|
}
|
||||||
|
// We're doing our work, we're needed!
|
||||||
|
_wasAbandoned = false;
|
||||||
|
|
||||||
// start with the bounds of the footprint polygon
|
// start with the bounds of the footprint polygon
|
||||||
Rectangle sbounds = new Rectangle(_footprint.getBounds());
|
Rectangle sbounds = new Rectangle(_footprint.getBounds());
|
||||||
@@ -199,10 +201,10 @@ public class SceneBlock
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SceneObject makeSceneObject (ObjectInfo info)
|
protected SceneObject makeSceneObject (ObjectInfo info)
|
||||||
{
|
{
|
||||||
return new SceneObject(_metrics, _tileMgr,
|
return new SceneObject(_metrics, _tileMgr,
|
||||||
_panel == null ? null : _panel.getColorizer(info), info);
|
_panel == null ? null : _panel.getColorizer(info), info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +221,11 @@ public class SceneBlock
|
|||||||
protected void wasResolved ()
|
protected void wasResolved ()
|
||||||
{
|
{
|
||||||
if (_panel != null) {
|
if (_panel != null) {
|
||||||
_panel.blockResolved(this);
|
if (_wasAbandoned) {
|
||||||
|
_panel.blockAbandoned(this);
|
||||||
|
} else {
|
||||||
|
_panel.blockResolved(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +246,7 @@ public class SceneBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bounds of the screen coordinate rectangle that contains all pixels that are
|
* Returns the bounds of the screen coordinate rectangle that contains all pixels that are
|
||||||
* drawn on by all tiles and objects in this block.
|
* drawn on by all tiles and objects in this block.
|
||||||
*/
|
*/
|
||||||
public Rectangle getScreenBounds ()
|
public Rectangle getScreenBounds ()
|
||||||
@@ -358,8 +364,8 @@ public class SceneBlock
|
|||||||
{
|
{
|
||||||
// make sure we don't already have this same object at these
|
// make sure we don't already have this same object at these
|
||||||
// coordinates
|
// coordinates
|
||||||
for (int ii = 0; ii < _objects.length; ii++) {
|
for (SceneObject _object : _objects) {
|
||||||
if (_objects[ii].info.equals(info)) {
|
if (_object.info.equals(info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -524,8 +530,8 @@ public class SceneBlock
|
|||||||
// if we need to regenerate the set of tiles covered by our
|
// if we need to regenerate the set of tiles covered by our
|
||||||
// objects, do so
|
// objects, do so
|
||||||
if (recover) {
|
if (recover) {
|
||||||
for (int ii = 0; ii < _objects.length; ii++) {
|
for (SceneObject _object : _objects) {
|
||||||
setCovered(blocks, _objects[ii]);
|
setCovered(blocks, _object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -576,11 +582,11 @@ public class SceneBlock
|
|||||||
|
|
||||||
/** The panel for which we contain a block or null if we aren't backed by a panel. */
|
/** The panel for which we contain a block or null if we aren't backed by a panel. */
|
||||||
protected MisoScenePanel _panel;
|
protected MisoScenePanel _panel;
|
||||||
|
|
||||||
protected MisoSceneMetrics _metrics;
|
protected MisoSceneMetrics _metrics;
|
||||||
|
|
||||||
protected MisoSceneModel _model;
|
protected MisoSceneModel _model;
|
||||||
|
|
||||||
protected TileManager _tileMgr;
|
protected TileManager _tileMgr;
|
||||||
|
|
||||||
/** The bounds of (in tile coordinates) of this block. */
|
/** The bounds of (in tile coordinates) of this block. */
|
||||||
@@ -616,6 +622,9 @@ public class SceneBlock
|
|||||||
/** A debug flag indicating whether we were visible at creation. */
|
/** A debug flag indicating whether we were visible at creation. */
|
||||||
protected boolean _visi;
|
protected boolean _visi;
|
||||||
|
|
||||||
|
/** If we discovered we were no longer needed in our last call to resolve. */
|
||||||
|
protected boolean _wasAbandoned;
|
||||||
|
|
||||||
// used to link up to our neighbors
|
// used to link up to our neighbors
|
||||||
protected static final int[] DX = { -1, -1, 0, 1, 1, 1, 0, -1 };
|
protected static final int[] DX = { -1, -1, 0, 1, 1, 1, 0, -1 };
|
||||||
protected static final int[] DY = { 0, -1, -1, -1, 0, 1, 1, 1 };
|
protected static final int[] DY = { 0, -1, -1, -1, 0, 1, 1, 1 };
|
||||||
|
|||||||
Reference in New Issue
Block a user