Making things work; moving lobby stuff entirely into lobby; simplifying.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@411 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-10-09 17:47:33 +00:00
parent 0546a29259
commit f8846ab016
7 changed files with 85 additions and 53 deletions
@@ -1,5 +1,5 @@
//
// $Id: ChatPanel.java,v 1.1 2001/10/03 23:24:09 mdb Exp $
// $Id: ChatPanel.java,v 1.2 2001/10/09 17:47:33 mdb Exp $
package com.threerings.micasa.client;
@@ -21,7 +21,7 @@ import com.threerings.micasa.Log;
public class ChatPanel
extends JPanel
implements ActionListener, LocationObserver, ChatDisplay, OccupantObserver
implements ActionListener, ChatDisplay, OccupantObserver, PlaceView
{
public ChatPanel (PartyContext ctx)
{
@@ -32,8 +32,7 @@ public class ChatPanel
_chatdtr = new ChatDirector(_ctx);
_chatdtr.addChatDisplay(this);
// register as a location observer
_ctx.getLocationDirector().addLocationObserver(this);
// register as an occupant observer
_ctx.getOccupantManager().addOccupantObserver(this);
GroupLayout gl = new VGroupLayout(GroupLayout.STRETCH);
@@ -115,29 +114,6 @@ public class ChatPanel
}
}
public boolean locationMayChange (int placeId)
{
// we're always amenable to change
return true;
}
public void locationDidChange (PlaceObject place)
{
Log.info("We be here: " + place);
// enable our chat input elements since we're now somewhere that
// we can chat
_entry.setEnabled(true);
_send.setEnabled(true);
_entry.requestFocus();
}
public void locationChangeFailed (int placeId, String reason)
{
Log.warning("Unable to change to location [plid=" + placeId +
", reason=" + reason + "].");
}
public void occupantEntered (OccupantInfo info)
{
displayOccupantMessage("*** " + info.username + " entered.");
@@ -252,6 +228,22 @@ public class ChatPanel
}
}
public void willEnterPlace (PlaceObject place)
{
Log.info("We be here: " + place);
// enable our chat input elements since we're now somewhere that
// we can chat
_entry.setEnabled(true);
_send.setEnabled(true);
_entry.requestFocus();
}
public void didLeavePlace (PlaceObject place)
{
// nothing doing
}
protected PartyContext _ctx;
protected ChatDirector _chatdtr;
@@ -1,5 +1,5 @@
//
// $Id: ClientController.java,v 1.3 2001/10/09 00:48:34 mdb Exp $
// $Id: ClientController.java,v 1.4 2001/10/09 17:47:33 mdb Exp $
package com.threerings.micasa.client;
@@ -18,7 +18,6 @@ import com.threerings.cocktail.party.data.*;
import com.threerings.media.sprite.SpriteManager;
import com.threerings.micasa.Log;
import com.threerings.micasa.lobby.LobbyService;
import com.threerings.micasa.util.MiCasaContext;
/**
@@ -51,9 +50,6 @@ public class ClientController
// we also want to know about occupant changes
_ctx.getOccupantManager().addOccupantObserver(this);
// 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);
// _frame.setPanel(_logonPanel);
@@ -84,10 +80,6 @@ public class ClientController
// keep the body object around for stuff
_body = (BodyObject)client.getClientObject();
// we're logged on, so we lose the login panel and move to our
// primary display
_frame.setPanel(_lobbyPanel);
}
// documentation inherited
@@ -192,5 +184,4 @@ public class ClientController
// our panels
protected LogonPanel _logonPanel;
protected LobbyPanel _lobbyPanel;
}
@@ -1,5 +1,5 @@
//
// $Id: MiCasaClient.java,v 1.1 2001/10/03 23:24:09 mdb Exp $
// $Id: MiCasaClient.java,v 1.2 2001/10/09 17:47:33 mdb Exp $
package com.threerings.micasa.client;
@@ -16,6 +16,7 @@ import com.threerings.cocktail.cher.net.*;
import com.threerings.cocktail.party.client.LocationDirector;
import com.threerings.cocktail.party.client.OccupantManager;
import com.threerings.cocktail.party.client.PlaceView;
import com.threerings.parlor.client.ParlorDirector;
@@ -37,16 +38,6 @@ public class MiCasaClient
public MiCasaClient (MiCasaFrame frame)
throws IOException
{
// keep this for later
_frame = frame;
// log off when they close the window
_frame.addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent evt) {
_client.logoff(true);
}
});
// create our context
_ctx = new MiCasaContextImpl();
@@ -60,7 +51,17 @@ public class MiCasaClient
_pardtr = new ParlorDirector(_ctx);
// for test purposes, hardcode the server info
_client.setServer("bering", 4007);
_client.setServer("localhost", 4007);
// keep this for later
_frame = frame;
// log off when they close the window
_frame.addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent evt) {
_client.logoff(true);
}
});
// create our client controller and stick it in the frame
_frame.setController(new ClientController(_ctx, _frame));
@@ -117,6 +118,17 @@ public class MiCasaClient
{
return _pardtr;
}
public void setPlaceView (PlaceView view)
{
// stick the place view into our frame
_frame.setPanel((JPanel)view);
}
public MiCasaFrame getFrame ()
{
return _frame;
}
}
protected MiCasaContext _ctx;
@@ -1,5 +1,5 @@
//
// $Id: MiCasaFrame.java,v 1.1 2001/10/03 23:24:09 mdb Exp $
// $Id: MiCasaFrame.java,v 1.2 2001/10/09 17:47:33 mdb Exp $
package com.threerings.micasa.client;
@@ -25,6 +25,9 @@ public class MiCasaFrame
// setDefaultCloseOperation(EXIT_ON_CLOSE);
}
/**
* Sets the panel that makes up the entire client display.
*/
public void setPanel (JPanel panel)
{
// remove the old panel
@@ -35,6 +38,24 @@ public class MiCasaFrame
validate();
}
/**
* Sets the match-making panel to be used when the lobby panel is
* being displayed.
*/
public void setMatchMakingPanel (JPanel panel)
{
_lopanel.setPrimary(panel);
}
/**
* Provides a reference to the lobby panel that will be used to
* provide our lobby interfaces.
*/
protected void setLobbyPanel (LobbyPanel panel)
{
_lopanel = panel;
}
/**
* Sets the controller for the outermost scope. This controller will
* handle all actions that aren't handled by controllers of tigher
@@ -52,4 +73,6 @@ public class MiCasaFrame
}
protected Controller _controller;
protected LobbyPanel _lopanel;
}
@@ -1,5 +1,5 @@
//
// $Id: LobbyController.java,v 1.1 2001/10/09 00:48:34 mdb Exp $
// $Id: LobbyController.java,v 1.2 2001/10/09 17:47:33 mdb Exp $
package com.threerings.micasa.lobby;
@@ -9,6 +9,8 @@ import com.threerings.cocktail.party.client.PlaceView;
import com.threerings.cocktail.party.util.PartyContext;
import com.threerings.micasa.Log;
import com.threerings.micasa.client.ChatPanel;
import com.threerings.micasa.util.MiCasaContext;
public class LobbyController extends PlaceController
{
@@ -1,11 +1,13 @@
//
// $Id: LobbyManager.java,v 1.2 2001/10/04 23:41:44 mdb Exp $
// $Id: LobbyManager.java,v 1.3 2001/10/09 17:47:33 mdb Exp $
package com.threerings.micasa.lobby;
import java.util.Properties;
import com.samskivert.util.StringUtil;
import com.threerings.cocktail.party.chat.ChatService;
import com.threerings.cocktail.party.chat.ChatMessageHandler;
import com.threerings.cocktail.party.server.PlaceManager;
import com.threerings.micasa.Log;
@@ -59,6 +61,11 @@ public class LobbyManager extends PlaceManager
// let the lobby registry know that we're up and running
_lobreg.lobbyReady(_plobj.getOid(), _gameIdent, _name);
// register a chat message handler because we want to support
// chatting
MessageHandler handler = new ChatMessageHandler();
registerMessageHandler(ChatService.SPEAK_REQUEST, handler);
}
/** The universal game identifier for the game matchmade by this
@@ -1,10 +1,12 @@
//
// $Id: MiCasaContext.java,v 1.1 2001/10/03 23:24:09 mdb Exp $
// $Id: MiCasaContext.java,v 1.2 2001/10/09 17:47:33 mdb Exp $
package com.threerings.micasa.util;
import com.threerings.parlor.util.ParlorContext;
import com.threerings.micasa.client.MiCasaFrame;
/**
* The micasa context encapsulates the contexts of all of the services
* that are used by the micasa client so that we can pass around one
@@ -14,4 +16,7 @@ import com.threerings.parlor.util.ParlorContext;
public interface MiCasaContext
extends ParlorContext
{
/** Returns a reference to the primary user interface frame. This can
* be used to set the top-level panel when we enter a game, etc. */
public MiCasaFrame getFrame ();
}