Sweet Mary, mother of Jesus! Another fucking refactor. It turns out that

the way I was doing inheritance between the display and editable scene
implementations was not copacetic. The new method (which is for every
editable scene impl to delegate to a display scene impl so that regardless
of how far along you are on the inheritance chain, there are only ever two
actual objects, the display impl and the editable impl) is somewhat
cleaner, but makes it clear that no method can work as nicely as it would
were we to have mutliple inheritance.

The basic problem is that the editable versions of the scenes have to be
able to manipulate the instance variables in the display versions of the
scenes because they have to keep them up to date so that they are
displaying the right thing. As the editable versions are in different
packages, they don't have access to the display instance variables, so the
display versions simply have to make available enough "editable"
functionality to allow the editable versions to get their job done. It's
more coupling that I'd like, but at least it's only between the display
and editable versions across the inheritance hierarchy rather than down
the hierarchy.

Blah.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@745 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-05 08:45:06 +00:00
parent 7c60cb5df2
commit 2c27824718
5 changed files with 170 additions and 198 deletions
@@ -1,8 +1,10 @@
//
// $Id: DisplaySpotScene.java,v 1.2 2001/11/29 00:16:11 mdb Exp $
// $Id: DisplaySpotScene.java,v 1.3 2001/12/05 08:45:05 mdb Exp $
package com.threerings.whirled.spot.client;
import java.util.List;
import com.threerings.whirled.client.DisplayScene;
import com.threerings.whirled.spot.data.Location;
@@ -21,13 +23,13 @@ public interface DisplaySpotScene extends DisplayScene
public int getDefaultEntranceId ();
/**
* Returns an array of the locations in this scene (including portals
* Returns a list of the locations in this scene (including portals
* which will be instances of {@link Portal}).
*/
public Location[] getLocations ();
public List getLocations ();
/**
* Returns an array of the portals in this scene.
* Returns a list of the portals in this scene.
*/
public Portal[] getPortals ();
public List getPortals ();
}
@@ -1,8 +1,11 @@
//
// $Id: DisplaySpotSceneImpl.java,v 1.3 2001/12/05 03:38:09 mdb Exp $
// $Id: DisplaySpotSceneImpl.java,v 1.4 2001/12/05 08:45:05 mdb Exp $
package com.threerings.whirled.spot.client;
import java.util.ArrayList;
import java.util.List;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.whirled.client.DisplaySceneImpl;
@@ -30,8 +33,8 @@ public class DisplaySpotSceneImpl extends DisplaySceneImpl
// sort out our locations and portals
int lcount = model.locationIds.length;
int pcount = model.portalIds.length;
_portals = new Portal[pcount];
_locations = new Location[lcount - pcount];
_portals = new ArrayList(pcount);
_locations = new ArrayList(lcount - pcount);
// because the portals ids are in the same order as the location
// ids, we can parse them in one pass
@@ -43,29 +46,22 @@ public class DisplaySpotSceneImpl extends DisplaySceneImpl
if (model.locationIds[i] == pid) {
// add this portal to the portals array
_portals[pidx] = createPortal();
populatePortal(model, _portals[pidx], i, pidx);
loc = _portals[pidx];
Portal port = new Portal();
populatePortal(model, port, i, pidx);
_portals.add(port);;
loc = port;
pidx++;
} else {
loc = createLocation();
loc = new Location();
populateLocation(model, loc, i);
}
// everything goes into the locations array
_locations[i] = loc;
_locations.add(loc);
}
}
/**
* Returns a new location instance.
*/
protected Location createLocation ()
{
return new Location();
}
/**
* Populates a location instance with the specified index, using
* information from the model.
@@ -84,14 +80,6 @@ public class DisplaySpotSceneImpl extends DisplaySceneImpl
loc.clusterIndex = model.locationClusters[lidx];
}
/**
* Returns a new portal instance.
*/
protected Portal createPortal ()
{
return new Portal();
}
/**
* Populates a portal instance with the specified index, using
* information from the model.
@@ -119,13 +107,13 @@ public class DisplaySpotSceneImpl extends DisplaySceneImpl
}
// documentation inherited
public Location[] getLocations ()
public List getLocations ()
{
return _locations;
}
// documentation inherited
public Portal[] getPortals ()
public List getPortals ()
{
return _portals;
}
@@ -133,9 +121,9 @@ public class DisplaySpotSceneImpl extends DisplaySceneImpl
/** The data that makes up our scene. */
protected SpotSceneModel _model;
/** An array of the locations (and portals) in this scene. */
protected Location[] _locations;
/** A list of the locations (and portals) in this scene. */
protected ArrayList _locations;
/** An array of just the portals in this scene. */
protected Portal[] _portals;
/** A list of just the portals in this scene. */
protected ArrayList _portals;
}