Modified the simulator stuff to allow it to be extended with the intent of
providing a specially configured client context for use by the code that runs in the simulator. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@861 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ClientController.java,v 1.1 2001/12/19 09:32:02 shaper Exp $
|
// $Id: ClientController.java,v 1.2 2002/01/16 02:59:08 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.micasa.simulator.client;
|
package com.threerings.micasa.simulator.client;
|
||||||
|
|
||||||
@@ -14,9 +14,9 @@ import com.threerings.crowd.client.*;
|
|||||||
import com.threerings.crowd.data.*;
|
import com.threerings.crowd.data.*;
|
||||||
|
|
||||||
import com.threerings.parlor.game.GameConfig;
|
import com.threerings.parlor.game.GameConfig;
|
||||||
|
import com.threerings.parlor.util.ParlorContext;
|
||||||
|
|
||||||
import com.threerings.micasa.Log;
|
import com.threerings.micasa.Log;
|
||||||
import com.threerings.micasa.simulator.util.SimulatorContext;
|
|
||||||
import com.threerings.micasa.simulator.data.SimulatorInfo;
|
import com.threerings.micasa.simulator.data.SimulatorInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,11 +30,13 @@ public class ClientController
|
|||||||
* Creates a new client controller. The controller will set everything
|
* Creates a new client controller. The controller will set everything
|
||||||
* up in preparation for logging on.
|
* up in preparation for logging on.
|
||||||
*/
|
*/
|
||||||
public ClientController (SimulatorContext ctx, SimulatorFrame frame)
|
public ClientController (ParlorContext ctx, SimulatorFrame frame,
|
||||||
|
SimulatorInfo info)
|
||||||
{
|
{
|
||||||
// we'll want to keep these around
|
// we'll want to keep these around
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
_frame = frame;
|
_frame = frame;
|
||||||
|
_info = info;
|
||||||
|
|
||||||
// we want to know about logon/logoff
|
// we want to know about logon/logoff
|
||||||
_ctx.getClient().addObserver(this);
|
_ctx.getClient().addObserver(this);
|
||||||
@@ -63,23 +65,20 @@ public class ClientController
|
|||||||
// keep the body object around for stuff
|
// keep the body object around for stuff
|
||||||
_body = (BodyObject)client.getClientObject();
|
_body = (BodyObject)client.getClientObject();
|
||||||
|
|
||||||
// get a handle on the simulator info
|
|
||||||
SimulatorInfo siminfo = _ctx.getSimulatorInfo();
|
|
||||||
|
|
||||||
// create the game config object
|
// create the game config object
|
||||||
GameConfig config = null;
|
GameConfig config = null;
|
||||||
try {
|
try {
|
||||||
config = (GameConfig)
|
config = (GameConfig)
|
||||||
Class.forName(siminfo.gameConfigClass).newInstance();
|
Class.forName(_info.gameConfigClass).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Failed to instantiate game config " +
|
Log.warning("Failed to instantiate game config " +
|
||||||
"[class=" + siminfo.gameConfigClass + "].");
|
"[class=" + _info.gameConfigClass + "].");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the game creation request
|
// send the game creation request
|
||||||
SimulatorDirector.createGame(
|
SimulatorDirector.createGame(
|
||||||
client, config, siminfo.simClass, siminfo.playerCount);
|
client, config, _info.simClass, _info.playerCount);
|
||||||
|
|
||||||
// our work here is done, as the location manager will move us
|
// our work here is done, as the location manager will move us
|
||||||
// into the game room straightaway
|
// into the game room straightaway
|
||||||
@@ -112,7 +111,8 @@ public class ClientController
|
|||||||
Log.info("Client did logoff [client=" + client + "].");
|
Log.info("Client did logoff [client=" + client + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SimulatorContext _ctx;
|
protected ParlorContext _ctx;
|
||||||
protected SimulatorFrame _frame;
|
protected SimulatorFrame _frame;
|
||||||
|
protected SimulatorInfo _info;
|
||||||
protected BodyObject _body;
|
protected BodyObject _body;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
//
|
||||||
|
// $Id: SimpleClient.java,v 1.1 2002/01/16 02:59:08 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.micasa.simulator.client;
|
||||||
|
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import com.samskivert.util.Config;
|
||||||
|
|
||||||
|
import com.threerings.presents.client.Client;
|
||||||
|
import com.threerings.presents.dobj.DObjectManager;
|
||||||
|
|
||||||
|
import com.threerings.crowd.client.LocationDirector;
|
||||||
|
import com.threerings.crowd.client.OccupantManager;
|
||||||
|
import com.threerings.crowd.client.PlaceView;
|
||||||
|
|
||||||
|
import com.threerings.parlor.client.ParlorDirector;
|
||||||
|
import com.threerings.parlor.util.ParlorContext;
|
||||||
|
|
||||||
|
import com.threerings.micasa.Log;
|
||||||
|
import com.threerings.micasa.simulator.data.SimulatorInfo;
|
||||||
|
|
||||||
|
public class SimpleClient
|
||||||
|
implements Client.Invoker, SimulatorClient
|
||||||
|
{
|
||||||
|
public SimpleClient (SimulatorFrame frame)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
// create our context
|
||||||
|
_ctx = new ParlorContextImpl();
|
||||||
|
|
||||||
|
// create the handles on our various services
|
||||||
|
_config = new Config();
|
||||||
|
_client = new Client(null, this);
|
||||||
|
|
||||||
|
// create our managers and directors
|
||||||
|
_locdir = new LocationDirector(_ctx);
|
||||||
|
_occmgr = new OccupantManager(_ctx);
|
||||||
|
_pardtr = new ParlorDirector(_ctx);
|
||||||
|
|
||||||
|
// for test purposes, hardcode the server info
|
||||||
|
_client.setServer("localhost", 4007);
|
||||||
|
|
||||||
|
// keep this for later
|
||||||
|
_frame = frame;
|
||||||
|
|
||||||
|
// log off when they close the window
|
||||||
|
_frame.getFrame().addWindowListener(new WindowAdapter() {
|
||||||
|
public void windowClosing (WindowEvent evt) {
|
||||||
|
// if we're logged on, log off
|
||||||
|
if (_client.loggedOn()) {
|
||||||
|
_client.logoff(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a reference to the context in effect for this client. This
|
||||||
|
* reference is valid for the lifetime of the application.
|
||||||
|
*/
|
||||||
|
public ParlorContext getContext ()
|
||||||
|
{
|
||||||
|
return _ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void invokeLater (Runnable run)
|
||||||
|
{
|
||||||
|
// queue it on up on the swing thread
|
||||||
|
SwingUtilities.invokeLater(run);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
{
|
||||||
|
public Config getConfig ()
|
||||||
|
{
|
||||||
|
return _config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Client getClient ()
|
||||||
|
{
|
||||||
|
return _client;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DObjectManager getDObjectManager ()
|
||||||
|
{
|
||||||
|
return _client.getDObjectManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocationDirector getLocationDirector ()
|
||||||
|
{
|
||||||
|
return _locdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OccupantManager getOccupantManager ()
|
||||||
|
{
|
||||||
|
return _occmgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParlorDirector getParlorDirector ()
|
||||||
|
{
|
||||||
|
return _pardtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlaceView (PlaceView view)
|
||||||
|
{
|
||||||
|
// stick the place view into our frame
|
||||||
|
_frame.setPanel((JPanel)view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ParlorContext _ctx;
|
||||||
|
protected SimulatorFrame _frame;
|
||||||
|
|
||||||
|
protected Config _config;
|
||||||
|
protected Client _client;
|
||||||
|
protected LocationDirector _locdir;
|
||||||
|
protected OccupantManager _occmgr;
|
||||||
|
protected ParlorDirector _pardtr;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
//
|
||||||
|
// $Id: SimpleFrame.java,v 1.1 2002/01/16 02:59:08 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.micasa.simulator.client;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import com.samskivert.swing.Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the user interface for the Simulator client application.
|
||||||
|
*/
|
||||||
|
public class SimpleFrame
|
||||||
|
extends JFrame implements SimulatorFrame
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructs the top-level Simulator client frame.
|
||||||
|
*/
|
||||||
|
public SimpleFrame ()
|
||||||
|
{
|
||||||
|
super("Simulator");
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public JFrame getFrame ()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
// swing doesn't properly repaint after adding/removing children
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,8 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: SimulatorApp.java,v 1.1 2001/12/19 09:32:02 shaper Exp $
|
// $Id: SimulatorApp.java,v 1.2 2002/01/16 02:59:08 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.micasa.simulator.client;
|
package com.threerings.micasa.simulator.client;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import com.samskivert.swing.Controller;
|
||||||
import com.samskivert.swing.util.SwingUtil;
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
|
|
||||||
import com.threerings.presents.client.Client;
|
import com.threerings.presents.client.Client;
|
||||||
@@ -28,7 +31,7 @@ public class SimulatorApp
|
|||||||
_serverThread = new ServerThread(server);
|
_serverThread = new ServerThread(server);
|
||||||
|
|
||||||
// create a frame
|
// create a frame
|
||||||
_frame = new SimulatorFrame();
|
_frame = createSimulatorFrame();
|
||||||
|
|
||||||
// create the simulator info object
|
// create the simulator info object
|
||||||
SimulatorInfo siminfo = new SimulatorInfo();
|
SimulatorInfo siminfo = new SimulatorInfo();
|
||||||
@@ -38,7 +41,23 @@ public class SimulatorApp
|
|||||||
System.getProperty("playercount"), DEFAULT_PLAYER_COUNT);
|
System.getProperty("playercount"), DEFAULT_PLAYER_COUNT);
|
||||||
|
|
||||||
// create our client instance
|
// create our client instance
|
||||||
_client = new SimulatorClient(_frame, siminfo);
|
_client = createSimulatorClient(_frame);
|
||||||
|
|
||||||
|
// set up the top-level client controller
|
||||||
|
Controller ctrl = new ClientController(
|
||||||
|
_client.getContext(), _frame, siminfo);
|
||||||
|
_frame.setController(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SimulatorFrame createSimulatorFrame ()
|
||||||
|
{
|
||||||
|
return new SimpleFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SimulatorClient createSimulatorClient (SimulatorFrame frame)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
return new SimpleClient(_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run ()
|
public void run ()
|
||||||
@@ -46,9 +65,10 @@ public class SimulatorApp
|
|||||||
// size and display the window
|
// size and display the window
|
||||||
int wid = getInt(System.getProperty("width"), 800);
|
int wid = getInt(System.getProperty("width"), 800);
|
||||||
int hei = getInt(System.getProperty("height"), 600);
|
int hei = getInt(System.getProperty("height"), 600);
|
||||||
_frame.setSize(wid, hei);
|
JFrame frame = _frame.getFrame();
|
||||||
SwingUtil.centerWindow(_frame);
|
frame.setSize(wid, hei);
|
||||||
_frame.show();
|
SwingUtil.centerWindow(frame);
|
||||||
|
frame.show();
|
||||||
|
|
||||||
// start up the server
|
// start up the server
|
||||||
_serverThread.start();
|
_serverThread.start();
|
||||||
@@ -84,16 +104,7 @@ public class SimulatorApp
|
|||||||
|
|
||||||
public static void main (String[] args)
|
public static void main (String[] args)
|
||||||
{
|
{
|
||||||
if (args.length < 2) {
|
if (!checkArgs(args)) {
|
||||||
String msg = "Usage:\n" +
|
|
||||||
" java com.threerings.simulator.SimulatorApp " +
|
|
||||||
"<game config class name> <simulant class name>\n" +
|
|
||||||
"Optional properties:\n" +
|
|
||||||
" -Dusername=<user>\n" +
|
|
||||||
" -Dplayercount=<number>\n" +
|
|
||||||
" -Dwidth=<width>\n" +
|
|
||||||
" -Dheight=<height>";
|
|
||||||
System.out.println(msg);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +119,24 @@ public class SimulatorApp
|
|||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static boolean checkArgs (String[] args)
|
||||||
|
{
|
||||||
|
if (args.length < 2) {
|
||||||
|
String msg = "Usage:\n" +
|
||||||
|
" java com.threerings.simulator.SimulatorApp " +
|
||||||
|
"<game config class name> <simulant class name>\n" +
|
||||||
|
"Optional properties:\n" +
|
||||||
|
" -Dusername=<user>\n" +
|
||||||
|
" -Dplayercount=<number>\n" +
|
||||||
|
" -Dwidth=<width>\n" +
|
||||||
|
" -Dheight=<height>";
|
||||||
|
System.out.println(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected int getInt (String value, int defval)
|
protected int getInt (String value, int defval)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,149 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: SimulatorClient.java,v 1.1 2001/12/19 09:32:02 shaper Exp $
|
// $Id: SimulatorClient.java,v 1.2 2002/01/16 02:59:08 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.micasa.simulator.client;
|
package com.threerings.micasa.simulator.client;
|
||||||
|
|
||||||
import java.awt.event.WindowAdapter;
|
import com.threerings.parlor.util.ParlorContext;
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
public interface SimulatorClient
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
import com.samskivert.swing.Controller;
|
|
||||||
import com.samskivert.util.Config;
|
|
||||||
|
|
||||||
import com.threerings.presents.client.Client;
|
|
||||||
import com.threerings.presents.dobj.DObjectManager;
|
|
||||||
|
|
||||||
import com.threerings.crowd.client.LocationDirector;
|
|
||||||
import com.threerings.crowd.client.OccupantManager;
|
|
||||||
import com.threerings.crowd.client.PlaceView;
|
|
||||||
|
|
||||||
import com.threerings.parlor.client.ParlorDirector;
|
|
||||||
|
|
||||||
import com.threerings.micasa.Log;
|
|
||||||
import com.threerings.micasa.simulator.data.SimulatorInfo;
|
|
||||||
import com.threerings.micasa.simulator.util.SimulatorContext;
|
|
||||||
|
|
||||||
public class SimulatorClient
|
|
||||||
implements Client.Invoker
|
|
||||||
{
|
{
|
||||||
public SimulatorClient (SimulatorFrame frame, SimulatorInfo siminfo)
|
public ParlorContext getContext ();
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
// create our context
|
|
||||||
_ctx = new SimulatorContextImpl();
|
|
||||||
|
|
||||||
// create the handles on our various services
|
|
||||||
_config = new Config();
|
|
||||||
_client = new Client(null, this);
|
|
||||||
|
|
||||||
// create our managers and directors
|
|
||||||
_locdir = new LocationDirector(_ctx);
|
|
||||||
_occmgr = new OccupantManager(_ctx);
|
|
||||||
_pardtr = new ParlorDirector(_ctx);
|
|
||||||
|
|
||||||
// for test purposes, hardcode the server info
|
|
||||||
_client.setServer("localhost", 4007);
|
|
||||||
|
|
||||||
// keep this for later
|
|
||||||
_frame = frame;
|
|
||||||
_siminfo = siminfo;
|
|
||||||
|
|
||||||
// log off when they close the window
|
|
||||||
_frame.addWindowListener(new WindowAdapter() {
|
|
||||||
public void windowClosing (WindowEvent evt) {
|
|
||||||
// if we're logged on, log off
|
|
||||||
if (_client.loggedOn()) {
|
|
||||||
_client.logoff(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// create our client controller and stick it in the frame
|
|
||||||
Controller ctrl = new ClientController(_ctx, _frame);
|
|
||||||
_frame.setController(ctrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a reference to the context in effect for this client. This
|
|
||||||
* reference is valid for the lifetime of the application.
|
|
||||||
*/
|
|
||||||
public SimulatorContext getContext ()
|
|
||||||
{
|
|
||||||
return _ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited
|
|
||||||
public void invokeLater (Runnable run)
|
|
||||||
{
|
|
||||||
// queue it on up on the swing thread
|
|
||||||
SwingUtilities.invokeLater(run);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The context implementation. This provides access to all of the
|
|
||||||
* objects and services that are needed by the operating client.
|
|
||||||
*/
|
|
||||||
protected class SimulatorContextImpl implements SimulatorContext
|
|
||||||
{
|
|
||||||
public Config getConfig ()
|
|
||||||
{
|
|
||||||
return _config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Client getClient ()
|
|
||||||
{
|
|
||||||
return _client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DObjectManager getDObjectManager ()
|
|
||||||
{
|
|
||||||
return _client.getDObjectManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocationDirector getLocationDirector ()
|
|
||||||
{
|
|
||||||
return _locdir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OccupantManager getOccupantManager ()
|
|
||||||
{
|
|
||||||
return _occmgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParlorDirector getParlorDirector ()
|
|
||||||
{
|
|
||||||
return _pardtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlaceView (PlaceView view)
|
|
||||||
{
|
|
||||||
// stick the place view into our frame
|
|
||||||
_frame.setPanel((JPanel)view);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimulatorFrame getFrame ()
|
|
||||||
{
|
|
||||||
return _frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimulatorInfo getSimulatorInfo ()
|
|
||||||
{
|
|
||||||
return _siminfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SimulatorContext _ctx;
|
|
||||||
protected SimulatorFrame _frame;
|
|
||||||
protected SimulatorInfo _siminfo;
|
|
||||||
|
|
||||||
protected Config _config;
|
|
||||||
protected Client _client;
|
|
||||||
protected LocationDirector _locdir;
|
|
||||||
protected OccupantManager _occmgr;
|
|
||||||
protected ParlorDirector _pardtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
//
|
//
|
||||||
// $Id: SimulatorFrame.java,v 1.1 2001/12/19 09:32:02 shaper Exp $
|
// $Id: SimulatorFrame.java,v 1.2 2002/01/16 02:59:08 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.micasa.simulator.client;
|
package com.threerings.micasa.simulator.client;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
@@ -13,45 +12,23 @@ import com.samskivert.swing.ControllerProvider;
|
|||||||
/**
|
/**
|
||||||
* Contains the user interface for the Simulator client application.
|
* Contains the user interface for the Simulator client application.
|
||||||
*/
|
*/
|
||||||
public class SimulatorFrame
|
public interface SimulatorFrame extends ControllerProvider
|
||||||
extends JFrame implements ControllerProvider
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs the top-level Simulator client frame.
|
* Returns a reference to the top-level frame that the simulator will
|
||||||
|
* use to display everything.
|
||||||
*/
|
*/
|
||||||
public SimulatorFrame ()
|
public JFrame getFrame ();
|
||||||
{
|
|
||||||
super("Simulator");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the panel that makes up the entire client display.
|
* Sets the panel that makes up the entire client display.
|
||||||
*/
|
*/
|
||||||
public void setPanel (JPanel panel)
|
public void setPanel (JPanel panel);
|
||||||
{
|
|
||||||
// remove the old panel
|
|
||||||
getContentPane().removeAll();
|
|
||||||
// add the new one
|
|
||||||
getContentPane().add(panel, BorderLayout.CENTER);
|
|
||||||
// swing doesn't properly repaint after adding/removing children
|
|
||||||
validate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the controller for the outermost scope. This controller will
|
* Sets the controller for the outermost scope. This controller will
|
||||||
* handle all actions that aren't handled by controllers of tigher
|
* handle all actions that aren't handled by controllers of tigher
|
||||||
* scope.
|
* scope.
|
||||||
*/
|
*/
|
||||||
public void setController (Controller controller)
|
public void setController (Controller controller);
|
||||||
{
|
|
||||||
_controller = controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited
|
|
||||||
public Controller getController ()
|
|
||||||
{
|
|
||||||
return _controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Controller _controller;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user