git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@779 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Dave Hoover
2008-11-12 18:46:33 +00:00
parent ac0df2aa6d
commit e480fed7ce
@@ -75,14 +75,12 @@ import com.threerings.stage.util.StageSceneUtil;
import static com.threerings.stage.Log.log; import static com.threerings.stage.Log.log;
/** /**
* Extends the basic Miso scene panel with Stage fun stuff like portals, * Extends the basic Miso scene panel with Stage fun stuff like portals, clusters and locations.
* clusters and locations.
*/ */
public class StageScenePanel extends MisoScenePanel public class StageScenePanel extends MisoScenePanel
implements ControllerProvider, KeyListener, PlaceView implements ControllerProvider, KeyListener, PlaceView
{ {
/** An action command generated when the user clicks on a location /** An action command generated when the user clicks on a location within the scene. */
* within the scene. */
public static final String LOCATION_CLICKED = "LocationClicked"; public static final String LOCATION_CLICKED = "LocationClicked";
/** An action command generated when a cluster is clicked. */ /** An action command generated when a cluster is clicked. */
@@ -149,7 +147,7 @@ public class StageScenePanel extends MisoScenePanel
// we're so hosed that we don't even know what time it is // we're so hosed that we don't even know what time it is
} }
} }
/** /**
* Called when we have received a scene update from the server. * Called when we have received a scene update from the server.
*/ */
@@ -158,9 +156,8 @@ public class StageScenePanel extends MisoScenePanel
// recompute the portals as those may well have changed // recompute the portals as those may well have changed
recomputePortals(); recomputePortals();
// we go aheand and completely replace our scene model which will // we go ahead and completely replace our scene model which will reload the whole good
// reload the whole good goddamned business; it is a little // goddamned business; it is a little shocking to the user, but it's guaranteed to work
// shocking to the user, but it's guaranteed to work
refreshScene(); refreshScene();
} }
@@ -231,7 +228,7 @@ public class StageScenePanel extends MisoScenePanel
setShowFlags(SHOW_TIPS, true); setShowFlags(SHOW_TIPS, true);
} }
} }
// documentation inherited from interface KeyListener // documentation inherited from interface KeyListener
public void keyReleased (KeyEvent e) public void keyReleased (KeyEvent e)
{ {
@@ -282,8 +279,7 @@ public class StageScenePanel extends MisoScenePanel
Controller.postAction(this, CLUSTER_CLICKED, actarg); Controller.postAction(this, CLUSTER_CLICKED, actarg);
} else { } else {
// post an action indicating that we've clicked on a location // post an action indicating that we've clicked on a location
Point lc = MisoUtil.screenToFull( Point lc = MisoUtil.screenToFull(_metrics, event.getX(), event.getY(), new Point());
_metrics, event.getX(), event.getY(), new Point());
Controller.postAction(this, LOCATION_CLICKED, Controller.postAction(this, LOCATION_CLICKED,
new StageLocation(lc.x, lc.y, (byte)0)); new StageLocation(lc.x, lc.y, (byte)0));
} }
@@ -313,8 +309,7 @@ public class StageScenePanel extends MisoScenePanel
*/ */
protected void clusterUpdated (Cluster cluster) protected void clusterUpdated (Cluster cluster)
{ {
// compute a screen rectangle that contains all possible "spots" // compute a screen rectangle that contains all possible "spots" in this cluster
// in this cluster
List<SceneLocation> spots = StageSceneUtil.getClusterLocs(cluster); List<SceneLocation> spots = StageSceneUtil.getClusterLocs(cluster);
Rectangle cbounds = null; Rectangle cbounds = null;
for (int ii = 0, ll = spots.size(); ii < ll; ii++) { for (int ii = 0, ll = spots.size(); ii < ll; ii++) {
@@ -337,12 +332,11 @@ public class StageScenePanel extends MisoScenePanel
} }
/** /**
* Adds or updates the specified cluster in the view. Metrics will be * Adds or updates the specified cluster in the view. Metrics will be created that allow the
* created that allow the cluster to be rendered and hovered over. * cluster to be rendered and hovered over.
* *
* @param cluster the cluster record to be added. * @param cluster the cluster record to be added.
* @param bounds the screen coordinates that bound the occupants of * @param bounds the screen coordinates that bound the occupants of the cluster.
* the cluster.
*/ */
public void updateCluster (Cluster cluster, Rectangle bounds) public void updateCluster (Cluster cluster, Rectangle bounds)
{ {
@@ -350,8 +344,7 @@ public class StageScenePanel extends MisoScenePanel
dirtyCluster(cluster); dirtyCluster(cluster);
// compute the screen coordinate bounds of this cluster // compute the screen coordinate bounds of this cluster
Shape shape = new Ellipse2D.Float( Shape shape = new Ellipse2D.Float(bounds.x, bounds.y, bounds.width, bounds.height);
bounds.x, bounds.y, bounds.width, bounds.height);
_clusters.put(cluster, shape); _clusters.put(cluster, shape);
// if the mouse is inside these bounds, we highlight this cluster // if the mouse is inside these bounds, we highlight this cluster
@@ -381,8 +374,7 @@ public class StageScenePanel extends MisoScenePanel
dirtyCluster(shape); dirtyCluster(shape);
// clear out the hover object if this cluster was it // clear out the hover object if this cluster was it
if (_hobject instanceof Cluster && if (_hobject instanceof Cluster && ((Cluster)_hobject).clusterOid == clusterOid) {
((Cluster)_hobject).clusterOid == clusterOid) {
_hobject = null; _hobject = null;
} }
return true; return true;
@@ -431,8 +423,7 @@ public class StageScenePanel extends MisoScenePanel
return null; return null;
} }
// if the current hover object is a cluster, see if we're still in // if the current hover object is a cluster, see if we're still in that cluster
// that cluster
if (_hobject instanceof Cluster) { if (_hobject instanceof Cluster) {
Cluster cluster = (Cluster)_hobject; Cluster cluster = (Cluster)_hobject;
if (containsPoint(cluster, mx, my)) { if (containsPoint(cluster, mx, my)) {
@@ -451,8 +442,7 @@ public class StageScenePanel extends MisoScenePanel
} }
/** /**
* Returns true if the specified cluster contains the supplied screen * Returns true if the specified cluster contains the supplied screen coordinate.
* coordinate.
*/ */
protected boolean containsPoint (Cluster cluster, int mx, int my) protected boolean containsPoint (Cluster cluster, int mx, int my)
{ {
@@ -635,12 +625,11 @@ public class StageScenePanel extends MisoScenePanel
/** The width of the portal icons. */ /** The width of the portal icons. */
protected static final int PORTAL_ICON_WIDTH = 48; protected static final int PORTAL_ICON_WIDTH = 48;
/** The height of the portal icons. */ /** The height of the portal icons. */
protected static final int PORTAL_ICON_HEIGHT = 48; protected static final int PORTAL_ICON_HEIGHT = 48;
/** The distance within which the mouse must be from a location /** The distance within which the mouse must be from a location in order to highlight it. */
* in order to highlight it. */
protected static final int MAX_LOCATION_DIST = 25; protected static final int MAX_LOCATION_DIST = 25;
/** The amount the stroke a cluster. */ /** The amount the stroke a cluster. */
@@ -663,7 +652,6 @@ public class StageScenePanel extends MisoScenePanel
/** The alpha with which to render inactive portals. */ /** The alpha with which to render inactive portals. */
protected static final Composite INACTIVE_PORTAL_ALPHA = HIGHLIGHT_ALPHA; protected static final Composite INACTIVE_PORTAL_ALPHA = HIGHLIGHT_ALPHA;
/** The number of pixels outside a cluster when we assume the mouse is /** The number of pixels outside a cluster when we assume the mouse is "over" that cluster. */
* "over" that cluster. */
protected static final int CLUSTER_SLOP = 25; protected static final int CLUSTER_SLOP = 25;
} }