More progress on MiCasa services. Have lobby selection working now.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@397 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
//
|
||||
// $Id: ClientController.java,v 1.1 2001/10/03 23:24:09 mdb Exp $
|
||||
// $Id: ClientController.java,v 1.2 2001/10/04 23:41:44 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import com.samskivert.swing.Controller;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.cocktail.cher.dobj.*;
|
||||
import com.threerings.cocktail.cher.client.*;
|
||||
@@ -13,10 +14,12 @@ import com.threerings.cocktail.cher.net.UsernamePasswordCreds;
|
||||
|
||||
import com.threerings.cocktail.party.client.*;
|
||||
import com.threerings.cocktail.party.data.*;
|
||||
import com.threerings.cocktail.party.util.PlaceViewUtil;
|
||||
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
import com.threerings.micasa.lobby.LobbyService;
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
|
||||
/**
|
||||
@@ -49,12 +52,8 @@ public class ClientController
|
||||
// we also want to know about occupant changes
|
||||
_ctx.getOccupantManager().addOccupantObserver(this);
|
||||
|
||||
// create our main panel which we'll use once we're logged on
|
||||
_mainPanel = new MainPanel();
|
||||
|
||||
// create the chat ui
|
||||
ChatPanel panel = new ChatPanel(_ctx);
|
||||
_mainPanel.setNavigation(panel);
|
||||
// create our lobby panel which we'll use once we're logged on
|
||||
_lobbyPanel = new LobbyPanel(ctx);
|
||||
|
||||
// create the logon panel and display it
|
||||
_logonPanel = new LogonPanel(_ctx);
|
||||
@@ -89,7 +88,7 @@ public class ClientController
|
||||
|
||||
// we're logged on, so we lose the login panel and move to our
|
||||
// primary display
|
||||
_frame.setPanel(_mainPanel);
|
||||
_frame.setPanel(_lobbyPanel);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -132,12 +131,19 @@ public class ClientController
|
||||
{
|
||||
Log.info("Moved to new location [place=" + place + "].");
|
||||
|
||||
// we wants to subscribe to the location
|
||||
// clean up after the old place
|
||||
if (_place != null) {
|
||||
_place.removeSubscriber(this);
|
||||
PlaceViewUtil.dispatchDidLeavePlace(_frame, _place);
|
||||
}
|
||||
place.addSubscriber(this);
|
||||
|
||||
_place = place;
|
||||
|
||||
// and enter the new place with bells on
|
||||
if (_place != null) {
|
||||
_place.addSubscriber(this);
|
||||
PlaceViewUtil.dispatchWillEnterPlace(_frame, _place);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -185,5 +191,5 @@ public class ClientController
|
||||
|
||||
// our panels
|
||||
protected LogonPanel _logonPanel;
|
||||
protected MainPanel _mainPanel;
|
||||
protected LobbyPanel _lobbyPanel;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// $Id: OccupantList.java,v 1.1 2001/10/04 23:41:44 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.swing.*;
|
||||
|
||||
import com.threerings.cocktail.party.client.OccupantObserver;
|
||||
import com.threerings.cocktail.party.data.OccupantInfo;
|
||||
import com.threerings.cocktail.party.data.PlaceObject;
|
||||
import com.threerings.cocktail.party.util.PlaceView;
|
||||
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
|
||||
/**
|
||||
* The occupant list displays the list of users that are in a particular
|
||||
* place.
|
||||
*/
|
||||
public class OccupantList
|
||||
extends JList implements PlaceView, OccupantObserver
|
||||
{
|
||||
/**
|
||||
* Constructs an occupant list with the supplied context which it will
|
||||
* use to register itself with the necessary managers.
|
||||
*/
|
||||
public OccupantList (MiCasaContext ctx)
|
||||
{
|
||||
// set up our list model
|
||||
_model = new DefaultListModel();
|
||||
setModel(_model);
|
||||
|
||||
// keep our context around for later
|
||||
_ctx = ctx;
|
||||
|
||||
// register ourselves as an occupant observer
|
||||
_ctx.getOccupantManager().addOccupantObserver(this);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void willEnterPlace (PlaceObject plobj)
|
||||
{
|
||||
// add all of the occupants of the place to our list
|
||||
Iterator users = plobj.occupantInfo.elements();
|
||||
while (users.hasNext()) {
|
||||
OccupantInfo info = (OccupantInfo)users.next();
|
||||
_model.addElement(info.username);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void didLeavePlace (PlaceObject plobj)
|
||||
{
|
||||
// clear out our occupant entries
|
||||
_model.clear();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void occupantEntered (OccupantInfo info)
|
||||
{
|
||||
// simply add this user to our list
|
||||
_model.addElement(info.username);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void occupantLeft (OccupantInfo info)
|
||||
{
|
||||
// remove this occupant from our list
|
||||
_model.removeElement(info.username);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void occupantUpdated (OccupantInfo info)
|
||||
{
|
||||
// nothing doing
|
||||
}
|
||||
|
||||
/** Our client context. */
|
||||
protected MiCasaContext _ctx;
|
||||
|
||||
/** A list model that provides a vector interface. */
|
||||
protected DefaultListModel _model;
|
||||
}
|
||||
Reference in New Issue
Block a user