From fde9727f0795a5cf0fd38a579446fc970894cffe Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 21 Mar 2007 21:51:11 +0000 Subject: [PATCH] Nix place-specific willEnter and didLeave pattern since we're no longer bound to places. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@257 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../threerings/parlor/client/TableDirector.as | 32 +++++++++---------- .../micasa/lobby/table/TableListView.java | 4 +-- .../parlor/client/TableDirector.java | 28 ++++++++-------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/as/com/threerings/parlor/client/TableDirector.as b/src/as/com/threerings/parlor/client/TableDirector.as index 9447bcc6..dc9109f1 100644 --- a/src/as/com/threerings/parlor/client/TableDirector.as +++ b/src/as/com/threerings/parlor/client/TableDirector.as @@ -28,7 +28,9 @@ import com.threerings.util.Util; import com.threerings.presents.client.BasicDirector; import com.threerings.presents.client.Client; import com.threerings.presents.client.ClientEvent; +import com.threerings.presents.client.InvocationService_ResultListener; +import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.EntryAddedEvent; import com.threerings.presents.dobj.EntryRemovedEvent; import com.threerings.presents.dobj.EntryUpdatedEvent; @@ -58,7 +60,7 @@ import com.threerings.parlor.util.ParlorContext; * matchmaking takes place implements the {@link TableLobbyObject} interface. */ public class TableDirector extends BasicDirector - implements SetListener, ParlorService_TableListener + implements SetListener, InvocationService_ResultListener { protected static const log :Log = Log.getLog(TableDirector); @@ -83,29 +85,27 @@ public class TableDirector extends BasicDirector /** * This must be called by the entity that uses the table director when the using entity - * prepares to enter and display a place. It is assumed that the client is already subscribed - * to the provided place object. + * prepares to enter and display a "place". */ - public function willEnterPlace (place :PlaceObject) :void + public function setTableObject (tlobj :DObject) :void { - // the place should be a TableLobbyObject - _tlobj = TableLobbyObject(place); - - // add ourselves as a listener to the place object - place.addListener(this); + // the distributed object should be a TableLobbyObject + _tlobj = TableLobbyObject(tlobj); + // listen for table set updates + tlobj.addListener(this); } /** * This must be called by the entity that uses the table director when the using entity has - * left and is done displaying a place. + * left and is done displaying the "place". */ - public function didLeavePlace (place :PlaceObject) :void + public function clearTableObject () :void { - // remove our listenership - place.removeListener(this); - - // clear out our reference - _tlobj = null; + // remove our listenership and clear out + if (_tlobj != null) { + (_tlobj as DObject).removeListener(this); + _tlobj = null; + } } /** diff --git a/src/java/com/threerings/micasa/lobby/table/TableListView.java b/src/java/com/threerings/micasa/lobby/table/TableListView.java index 99a04ab9..8810c986 100644 --- a/src/java/com/threerings/micasa/lobby/table/TableListView.java +++ b/src/java/com/threerings/micasa/lobby/table/TableListView.java @@ -149,7 +149,7 @@ public class TableListView extends JPanel public void willEnterPlace (PlaceObject place) { // pass the good word on to our table director - _tdtr.willEnterPlace(place); + _tdtr.setTableObject(place); // iterate over the tables already active in this lobby and put // them in their respective lists @@ -164,7 +164,7 @@ public class TableListView extends JPanel public void didLeavePlace (PlaceObject place) { // pass the good word on to our table director - _tdtr.didLeavePlace(place); + _tdtr.clearTableObject(); // clear out our table lists _matchList.removeAll(); diff --git a/src/java/com/threerings/parlor/client/TableDirector.java b/src/java/com/threerings/parlor/client/TableDirector.java index 706cba5e..31abb1bf 100644 --- a/src/java/com/threerings/parlor/client/TableDirector.java +++ b/src/java/com/threerings/parlor/client/TableDirector.java @@ -28,13 +28,13 @@ import com.samskivert.util.ObserverList; import com.threerings.presents.client.BasicDirector; import com.threerings.presents.client.Client; +import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.EntryAddedEvent; import com.threerings.presents.dobj.EntryRemovedEvent; import com.threerings.presents.dobj.EntryUpdatedEvent; import com.threerings.presents.dobj.SetListener; import com.threerings.crowd.data.BodyObject; -import com.threerings.crowd.data.PlaceObject; import com.threerings.parlor.Log; import com.threerings.parlor.data.Table; @@ -81,27 +81,27 @@ public class TableDirector extends BasicDirector /** * This must be called by the entity that uses the table director when the using entity - * prepares to enter and display a place. It is assumed that the client is already subscribed - * to the provided place object. + * prepares to enter and display a place. */ - public void willEnterPlace (PlaceObject place) + public void setTableObject (DObject tlobj) { // the place should be a TableLobbyObject - _tlobj = (TableLobbyObject)place; - // add ourselves as a listener to the place object - place.addListener(this); + _tlobj = (TableLobbyObject)tlobj; + // listen for table set changes + tlobj.addListener(this); } /** * This must be called by the entity that uses the table director when the using entity has - * left and is done displaying a place. + * left and is done dealing with tables. */ - public void didLeavePlace (PlaceObject place) + public void clearTableObject () { - // remove our listenership - place.removeListener(this); - // clear out our reference - _tlobj = null; + // remove our listenership and clear out + if (_tlobj != null) { + ((DObject)_tlobj).removeListener(this); + _tlobj = null; + } } /** @@ -279,7 +279,7 @@ public class TableDirector extends BasicDirector } } - // documentation inherited from interface + // from interface TableService.ResultListener public void requestFailed (String reason) { Log.warning("Table action failed [reason=" + reason + "].");