Reworked location placement so that the editor knows only about

Location objects and needn't muck about with full coordinates.
Beginning work on exit placement.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@214 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-08-11 00:00:13 +00:00
parent 356f15595e
commit 60b47ff298
4 changed files with 44 additions and 25 deletions
@@ -1,5 +1,5 @@
//
// $Id: DisplayMisoSceneImpl.java,v 1.23 2001/08/10 23:07:04 shaper Exp $
// $Id: DisplayMisoSceneImpl.java,v 1.24 2001/08/11 00:00:13 shaper Exp $
package com.threerings.miso.scene;
@@ -115,6 +115,14 @@ public class Scene
return ClusterUtil.getClusterIndex(_clusters, loc);
}
/**
* Update the specified location in the scene. If the cluster
* index number is -1, the location will be removed from any
* cluster it may reside in.
*
* @param loc the location.
* @param clusteridx the cluster index number.
*/
public void updateLocation (Location loc, int clusteridx)
{
// look the location up in our existing location list
@@ -195,6 +203,9 @@ public class Scene
return _exits;
}
/**
* Return the number of clusters in the scene.
*/
public int getNumClusters ()
{
return _clusters.size();
+5 -12
View File
@@ -1,19 +1,14 @@
//
// $Id: Exit.java,v 1.1 2001/08/09 21:17:06 shaper Exp $
// $Id: Exit.java,v 1.2 2001/08/11 00:00:13 shaper Exp $
package com.threerings.miso.scene;
/**
* The <code>Exit</code> class represents a <code>Location</code> in a
* scene that leads to a different scene.
*
* @see Location
*/
public class Exit
public class Exit extends Location
{
/** The location this exit is associated with. */
public Location loc;
/** The scene name this exit transitions to. */
public String name;
@@ -25,18 +20,16 @@ public class Exit
*/
public Exit (Location loc, String name)
{
this.loc = loc;
super(loc.x, loc.y, loc.orient);
this.name = name;
}
/**
* Return a String representation of this object.
*/
public String toString ()
protected void toString (StringBuffer buf)
{
StringBuffer buf = new StringBuffer();
buf.append("[loc=").append(loc);
super.toString(buf);
buf.append(", name=").append(name);
return buf.append("]").toString();
}
}
@@ -1,5 +1,5 @@
//
// $Id: IsoSceneView.java,v 1.39 2001/08/10 23:07:04 shaper Exp $
// $Id: IsoSceneView.java,v 1.40 2001/08/11 00:00:13 shaper Exp $
package com.threerings.miso.scene;
@@ -390,11 +390,6 @@ public class IsoSceneView implements EditableSceneView
IsoUtil.screenToFull(_model, x, y, _hfull);
}
public void getFullCoordinates (int sx, int sy, Point fpos)
{
IsoUtil.screenToFull(_model, sx, sy, fpos);
}
/**
* Invalidate a list of rectangles in the view for later repainting.
*
@@ -564,9 +559,18 @@ public class IsoSceneView implements EditableSceneView
_scene.updateLocation(loc, clusteridx);
}
public Location getLocation (int x, int y)
public Location createLocation (int sx, int sy)
{
return _scene.getLocation(x, y);
Point fpos = new Point();
IsoUtil.screenToFull(_model, sx, sy, fpos);
return new Location(fpos.x, fpos.y);
}
public Location getLocation (int sx, int sy)
{
Point fpos = new Point();
IsoUtil.screenToFull(_model, sx, sy, fpos);
return _scene.getLocation(fpos.x, fpos.y);
}
public int getClusterIndex (Location loc)
@@ -1,5 +1,5 @@
//
// $Id: Location.java,v 1.3 2001/08/10 23:07:04 shaper Exp $
// $Id: Location.java,v 1.4 2001/08/11 00:00:13 shaper Exp $
package com.threerings.miso.scene;
@@ -54,9 +54,20 @@ public class Location
public String toString ()
{
StringBuffer buf = new StringBuffer();
buf.append("[x=").append(x);
buf.append(", y=").append(y);
buf.append(", orient=").append(orient);
buf.append("[");
toString(buf);
return buf.append("]").toString();
}
/**
* This should be overridden by derived classes (which should be sure
* to call <code>super.toString()</code>) to append the derived class
* specific event information to the string buffer.
*/
protected void toString (StringBuffer buf)
{
buf.append("x=").append(x);
buf.append(", y=").append(y);
buf.append(", orient=").append(orient);
}
}