The simulator should provide a MiCasaContext and generally be a good

MiCasa citizen.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1571 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-07-12 03:49:37 +00:00
parent 40cbabe20c
commit 7a3daa1d2b
3 changed files with 28 additions and 39 deletions
@@ -1,5 +1,5 @@
//
// $Id: SimpleClient.java,v 1.4 2002/04/15 14:38:45 shaper Exp $
// $Id: SimpleClient.java,v 1.5 2002/07/12 03:49:37 mdb Exp $
package com.threerings.micasa.simulator.client;
@@ -11,6 +11,8 @@ import java.io.IOException;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.threerings.util.MessageManager;
import com.threerings.presents.client.Client;
import com.threerings.presents.dobj.DObjectManager;
@@ -22,7 +24,9 @@ import com.threerings.parlor.client.ParlorDirector;
import com.threerings.parlor.util.ParlorContext;
import com.threerings.micasa.Log;
import com.threerings.micasa.client.MiCasaFrame;
import com.threerings.micasa.simulator.data.SimulatorInfo;
import com.threerings.micasa.util.MiCasaContext;
public class SimpleClient
implements Client.Invoker, SimulatorClient
@@ -31,12 +35,13 @@ public class SimpleClient
throws IOException
{
// create our context
_ctx = new ParlorContextImpl();
_ctx = new MiCasaContextImpl();
// create the handles on our various services
_client = new Client(null, this);
// create our managers and directors
_msgmgr = new MessageManager("rsrc");
_locdir = new LocationDirector(_ctx);
_occdir = new OccupantDirector(_ctx);
_pardtr = new ParlorDirector(_ctx);
@@ -78,7 +83,7 @@ public class SimpleClient
* The context implementation. This provides access to all of the
* objects and services that are needed by the operating client.
*/
protected class ParlorContextImpl implements ParlorContext
protected class MiCasaContextImpl implements MiCasaContext
{
public Client getClient ()
{
@@ -110,10 +115,21 @@ public class SimpleClient
// stick the place view into our frame
_frame.setPanel((JPanel)view);
}
public MiCasaFrame getFrame ()
{
return (MiCasaFrame)_frame;
}
public MessageManager getMessageManager ()
{
return _msgmgr;
}
}
protected ParlorContext _ctx;
protected MiCasaContext _ctx;
protected SimulatorFrame _frame;
protected MessageManager _msgmgr;
protected Client _client;
protected LocationDirector _locdir;
@@ -1,5 +1,5 @@
//
// $Id: SimpleFrame.java,v 1.2 2002/07/10 02:02:59 mdb Exp $
// $Id: SimpleFrame.java,v 1.3 2002/07/12 03:49:37 mdb Exp $
package com.threerings.micasa.simulator.client;
@@ -10,11 +10,13 @@ import javax.swing.JPanel;
import com.samskivert.swing.Controller;
import com.samskivert.swing.util.SwingUtil;
import com.threerings.micasa.client.MiCasaFrame;
/**
* Contains the user interface for the Simulator client application.
*/
public class SimpleFrame
extends JFrame implements SimulatorFrame
public class SimpleFrame extends MiCasaFrame
implements SimulatorFrame
{
/**
* Constructs the top-level Simulator client frame.
@@ -30,35 +32,5 @@ public class SimpleFrame
return this;
}
/**
* Sets the panel that makes up the entire client display.
*/
public void setPanel (JPanel panel)
{
// remove the old panel
getContentPane().removeAll();
// add the new one
getContentPane().add(panel, BorderLayout.CENTER);
// adjust ourselves to fit this lovely new child
pack();
SwingUtil.centerWindow(this);
}
/**
* Sets the controller for the outermost scope. This controller will
* handle all actions that aren't handled by controllers of tigher
* scope.
*/
public void setController (Controller controller)
{
_controller = controller;
}
// documentation inherited
public Controller getController ()
{
return _controller;
}
protected Controller _controller;
}
@@ -1,5 +1,5 @@
//
// $Id: SimulatorApp.java,v 1.8 2002/06/10 19:16:41 shaper Exp $
// $Id: SimulatorApp.java,v 1.9 2002/07/12 03:49:37 mdb Exp $
package com.threerings.micasa.simulator.client;
@@ -88,7 +88,8 @@ public class SimulatorApp
{
// configure and display the main frame
JFrame frame = _frame.getFrame();
frame.pack();
// position everything and show the frame
_frame.setSize(800, 600);
SwingUtil.centerWindow(frame);
frame.show();