Moved things into lobby from client. Sorted out a better (but still
temporary) mechanism for getting into the first lobby after we logon. Other cleanups. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@415 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClientController.java,v 1.4 2001/10/09 17:47:33 mdb Exp $
|
||||
// $Id: ClientController.java,v 1.5 2001/10/09 18:20:08 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -15,21 +15,16 @@ import com.threerings.cocktail.cher.net.UsernamePasswordCreds;
|
||||
import com.threerings.cocktail.party.client.*;
|
||||
import com.threerings.cocktail.party.data.*;
|
||||
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
import com.threerings.micasa.data.MiCasaBootstrapData;
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
|
||||
/**
|
||||
* The client controller is responsible for top-level control of the
|
||||
* client user interface. It deals with locating and displaying the proper
|
||||
* panels and controllers for particular user interface modes (walking
|
||||
* around the world, puzzling, etc.) and it manages the side-bar controls
|
||||
* as well.
|
||||
* Responsible for top-level control of the client user interface.
|
||||
*/
|
||||
public class ClientController
|
||||
extends Controller
|
||||
implements ClientObserver, LocationObserver, OccupantObserver, Subscriber
|
||||
implements ClientObserver
|
||||
{
|
||||
/**
|
||||
* Creates a new client controller. The controller will set everything
|
||||
@@ -44,19 +39,10 @@ public class ClientController
|
||||
// we want to know about logon/logoff
|
||||
_ctx.getClient().addObserver(this);
|
||||
|
||||
// we want to know about location changes
|
||||
_ctx.getLocationDirector().addLocationObserver(this);
|
||||
|
||||
// we also want to know about occupant changes
|
||||
_ctx.getOccupantManager().addOccupantObserver(this);
|
||||
|
||||
// create the logon panel and display it
|
||||
_logonPanel = new LogonPanel(_ctx);
|
||||
// _frame.setPanel(_logonPanel);
|
||||
|
||||
// create a sprite manager
|
||||
_spritemgr = new SpriteManager();
|
||||
|
||||
// configure the client with some credentials and logon
|
||||
String username = "bob" +
|
||||
((int)(Math.random() * Integer.MAX_VALUE) % 500);
|
||||
@@ -80,6 +66,11 @@ public class ClientController
|
||||
|
||||
// keep the body object around for stuff
|
||||
_body = (BodyObject)client.getClientObject();
|
||||
|
||||
// head to the default lobby to start things off
|
||||
MiCasaBootstrapData data = (MiCasaBootstrapData)
|
||||
client.getBootstrapData();
|
||||
_ctx.getLocationDirector().moveTo(data.defLobbyOid);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -111,77 +102,11 @@ public class ClientController
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public boolean locationMayChange (int placeId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void locationDidChange (PlaceObject place)
|
||||
{
|
||||
Log.info("Moved to new location [place=" + place + "].");
|
||||
|
||||
// clean up after the old place
|
||||
if (_place != null) {
|
||||
// dispatch didLeavePlace to our views
|
||||
PlaceViewUtil.dispatchDidLeavePlace(_frame, _place);
|
||||
_place.removeSubscriber(this);
|
||||
}
|
||||
|
||||
_place = place;
|
||||
|
||||
// and enter the new place with bells on
|
||||
if (_place != null) {
|
||||
_place.addSubscriber(this);
|
||||
// dispatch willEnterPlace to our views
|
||||
PlaceViewUtil.dispatchWillEnterPlace(_frame, _place);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void locationChangeFailed (int placeId, String reason)
|
||||
{
|
||||
Log.info("Location change failed [plid=" + placeId +
|
||||
", reason=" + reason + "].");
|
||||
}
|
||||
|
||||
public void occupantEntered (OccupantInfo info)
|
||||
{
|
||||
Log.info("New occupant " + info + ".");
|
||||
}
|
||||
|
||||
public void occupantLeft (OccupantInfo info)
|
||||
{
|
||||
}
|
||||
|
||||
public void occupantUpdated (OccupantInfo info)
|
||||
{
|
||||
}
|
||||
|
||||
public void objectAvailable (DObject object)
|
||||
{
|
||||
// don't care
|
||||
}
|
||||
|
||||
public void requestFailed (int oid, ObjectAccessException cause)
|
||||
{
|
||||
// don't care
|
||||
}
|
||||
|
||||
public boolean handleEvent (DEvent event, DObject target)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected MiCasaContext _ctx;
|
||||
protected MiCasaFrame _frame;
|
||||
protected BodyObject _body;
|
||||
protected PlaceObject _place;
|
||||
|
||||
// managers
|
||||
protected SpriteManager _spritemgr;
|
||||
|
||||
// our panels
|
||||
protected LogonPanel _logonPanel;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaFrame.java,v 1.2 2001/10/09 17:47:33 mdb Exp $
|
||||
// $Id: MiCasaFrame.java,v 1.3 2001/10/09 18:20:08 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -10,19 +10,17 @@ import com.samskivert.swing.Controller;
|
||||
import com.samskivert.swing.ControllerProvider;
|
||||
|
||||
/**
|
||||
* The micasa frame contains the user interface for the MiCasa client
|
||||
* application. It divides the screen into space for the primary panel and
|
||||
* the side-bar controls and allows user interface elements to be placed
|
||||
* in either region.
|
||||
* Contains the user interface for the MiCasa client application.
|
||||
*/
|
||||
public class MiCasaFrame
|
||||
extends JFrame implements ControllerProvider
|
||||
{
|
||||
/**
|
||||
* Constructs the top-level MiCasa client frame.
|
||||
*/
|
||||
public MiCasaFrame ()
|
||||
{
|
||||
super("MiCasa Client");
|
||||
// for now, quit if we're closed
|
||||
// setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,24 +36,6 @@ 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
|
||||
@@ -73,6 +53,4 @@ public class MiCasaFrame
|
||||
}
|
||||
|
||||
protected Controller _controller;
|
||||
|
||||
protected LobbyPanel _lopanel;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// $Id: MiCasaBootstrapData.java,v 1.1 2001/10/09 18:20:08 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.data;
|
||||
|
||||
import com.threerings.cocktail.cher.net.BootstrapData;
|
||||
|
||||
/**
|
||||
* Extends the basic Cher bootstrap data and provides some bootstrap
|
||||
* information specific to the MiCasa services.
|
||||
*/
|
||||
public class MiCasaBootstrapData extends BootstrapData
|
||||
{
|
||||
/** The oid of the default lobby. */
|
||||
public int defLobbyOid;
|
||||
|
||||
// documentation inherited
|
||||
public void toString (StringBuffer buf)
|
||||
{
|
||||
super.toString(buf);
|
||||
buf.append(", defLobbyOid=").append(defLobbyOid);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: LobbyController.java,v 1.2 2001/10/09 17:47:33 mdb Exp $
|
||||
// $Id: LobbyController.java,v 1.3 2001/10/09 18:20:08 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
@@ -9,13 +9,15 @@ 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
|
||||
{
|
||||
public void init (PartyContext ctx, PlaceConfig config)
|
||||
{
|
||||
// cast our context reference
|
||||
_ctx = (MiCasaContext)ctx;
|
||||
|
||||
super.init(ctx, config);
|
||||
|
||||
Log.info("Lobby controller created [config=" + config + "].");
|
||||
@@ -23,6 +25,8 @@ public class LobbyController extends PlaceController
|
||||
|
||||
protected PlaceView createPlaceView ()
|
||||
{
|
||||
return null;
|
||||
return new LobbyPanel(_ctx);
|
||||
}
|
||||
|
||||
protected MiCasaContext _ctx;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
//
|
||||
// $Id: LobbyPanel.java,v 1.2 2001/10/04 23:41:44 mdb Exp $
|
||||
// $Id: LobbyPanel.java,v 1.3 2001/10/09 18:20:08 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import javax.swing.*;
|
||||
import com.samskivert.swing.*;
|
||||
|
||||
import com.threerings.cocktail.party.client.PlaceView;
|
||||
import com.threerings.cocktail.party.data.PlaceObject;
|
||||
|
||||
import com.threerings.micasa.client.*;
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
|
||||
/**
|
||||
* The lobby panel is used to display the interface for the lobbies. It
|
||||
* contains a lobby selection mechanism, a chat interface and a user
|
||||
* interface for whatever matchmaking mechanism is appropriate for a
|
||||
* particular lobby.
|
||||
* Used to display the interface for the lobbies. It contains a lobby
|
||||
* selection mechanism, a chat interface and a user interface for whatever
|
||||
* match-making mechanism is appropriate for this particular lobby.
|
||||
*/
|
||||
public class LobbyPanel extends JPanel
|
||||
public class LobbyPanel
|
||||
extends JPanel implements PlaceView
|
||||
{
|
||||
/**
|
||||
* Constructs a new lobby panel and the associated user interface
|
||||
@@ -31,56 +36,64 @@ public class LobbyPanel extends JPanel
|
||||
gl.setJustification(GroupLayout.RIGHT);
|
||||
setLayout(gl);
|
||||
|
||||
// create our main panel
|
||||
gl = new VGroupLayout(GroupLayout.STRETCH);
|
||||
gl.setOffAxisPolicy(GroupLayout.STRETCH);
|
||||
_main = new JPanel(gl);
|
||||
|
||||
// create our match-making view
|
||||
_main.add(createMatchMakingView(ctx));
|
||||
|
||||
// create a chat box and stick that in as well
|
||||
JLabel label = new JLabel("Chat with other people in this lobby...");
|
||||
_main.add(label, GroupLayout.FIXED);
|
||||
_main.add(new ChatPanel(ctx));
|
||||
|
||||
// create our sidebar panel
|
||||
gl = new VGroupLayout(GroupLayout.STRETCH);
|
||||
gl.setOffAxisPolicy(GroupLayout.STRETCH);
|
||||
_sidePanel = new JPanel(gl);
|
||||
JPanel sidePanel = new JPanel(gl);
|
||||
|
||||
// the sidebar contains a lobby selector...
|
||||
JLabel label = new JLabel("Select a lobby...");
|
||||
_sidePanel.add(label, GroupLayout.FIXED);
|
||||
label = new JLabel("Select a lobby...");
|
||||
sidePanel.add(label, GroupLayout.FIXED);
|
||||
LobbySelector selector = new LobbySelector(ctx);
|
||||
_sidePanel.add(selector);
|
||||
sidePanel.add(selector);
|
||||
|
||||
// ...a lobby info display...
|
||||
|
||||
// and an occupants list
|
||||
label = new JLabel("Occupants");
|
||||
_sidePanel.add(label, GroupLayout.FIXED);
|
||||
OccupantList occupants = new OccupantList(ctx);
|
||||
_sidePanel.add(occupants);
|
||||
sidePanel.add(label, GroupLayout.FIXED);
|
||||
_occupants = new OccupantList(ctx);
|
||||
sidePanel.add(_occupants);
|
||||
|
||||
// add our sidebar panel into the mix
|
||||
add(_sidePanel, GroupLayout.FIXED);
|
||||
add(sidePanel, GroupLayout.FIXED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the primary view. This is the large view that displays the
|
||||
* primary activity going on in the client (the iso view when they're
|
||||
* walking around, the puzzle view when they're puzzling, etc.).
|
||||
* Derived classes override this function and create the appropriate
|
||||
* matchmaking user interface component.
|
||||
*/
|
||||
public void setPrimary (JPanel view)
|
||||
protected JComponent createMatchMakingView (MiCasaContext ctx)
|
||||
{
|
||||
// ignore requests to set the same view. it's simplest to deal
|
||||
// with this here
|
||||
if (view == _primView) {
|
||||
return;
|
||||
return new JLabel("Match-making view goes here.");
|
||||
}
|
||||
|
||||
// remove the previous primary view
|
||||
if (_primView != null) {
|
||||
remove(_primView);
|
||||
// documentation inherited
|
||||
public void willEnterPlace (PlaceObject plobj)
|
||||
{
|
||||
}
|
||||
|
||||
// add the new view
|
||||
_primView = view;
|
||||
add(_primView, 0);
|
||||
validate();
|
||||
// documentation inherited
|
||||
public void didLeavePlace (PlaceObject plobj)
|
||||
{
|
||||
}
|
||||
|
||||
/** The sidebar panel. */
|
||||
protected JPanel _sidePanel;
|
||||
/** Contains the match-making view and the chatbox. */
|
||||
protected JPanel _main;
|
||||
|
||||
/** The primary view. */
|
||||
protected JPanel _primView;
|
||||
/** Our occupant list display. */
|
||||
protected OccupantList _occupants;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: LobbySelector.java,v 1.1 2001/10/04 23:41:44 mdb Exp $
|
||||
// $Id: LobbySelector.java,v 1.2 2001/10/09 18:20:08 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// $Id: MiCasaClient.java,v 1.1 2001/10/09 18:20:08 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.server;
|
||||
|
||||
import com.threerings.cocktail.cher.net.BootstrapData;
|
||||
import com.threerings.cocktail.cher.server.CherClient;
|
||||
|
||||
/**
|
||||
* Extends the cher client and provides bootstrap data specific to the
|
||||
* MiCasa services.
|
||||
*/
|
||||
public class MiCasaClient extends CherClient
|
||||
{
|
||||
// documentation inherited
|
||||
protected BootstrapData createBootstrapData ()
|
||||
{
|
||||
return new BootstrapData();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void populateBootstrapData (BootstrapData data)
|
||||
{
|
||||
super.populateBootstrapData(data);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaServer.java,v 1.2 2001/10/04 23:41:44 mdb Exp $
|
||||
// $Id: MiCasaServer.java,v 1.3 2001/10/09 18:20:08 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.server;
|
||||
|
||||
@@ -40,6 +40,9 @@ public class MiCasaServer extends PartyServer
|
||||
// do the cher server initialization
|
||||
super.init();
|
||||
|
||||
// configure the client manager to use our client class
|
||||
clmgr.setClientClass(MiCasaClient.class);
|
||||
|
||||
// bind the whirled server config into the namespace
|
||||
config.bindProperties(CONFIG_KEY, CONFIG_PATH, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user