Added basic framework for providing game configuration interfaces that can
be used by a matchmaking interface when setting up a game. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1617 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// $Id: GameConfigurator.java,v 1.1 2002/07/25 23:20:22 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.client;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import com.samskivert.swing.VGroupLayout;
|
||||
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.parlor.util.ParlorContext;
|
||||
|
||||
/**
|
||||
* Provides the base from which interfaces can be built to configure games
|
||||
* prior to starting them. Derived classes would extend the base
|
||||
* configurator adding interface elements and wiring them up properly to
|
||||
* allow the user to configure an instance of their game.
|
||||
*
|
||||
* <p> Clients that use the game configurator will want to instantiate one
|
||||
* based on the class returned from the {@link GameConfig} and then
|
||||
* initialize it with a call to {@link #init}.
|
||||
*/
|
||||
public class GameConfigurator extends JPanel
|
||||
{
|
||||
/**
|
||||
* Initializes this game configurator, creates its user interface
|
||||
* elements and prepares it for display.
|
||||
*/
|
||||
public void init (ParlorContext ctx)
|
||||
{
|
||||
// save this for later
|
||||
_ctx = ctx;
|
||||
|
||||
// set up our layout manager
|
||||
VGroupLayout layout = new VGroupLayout(VGroupLayout.NONE);
|
||||
layout.setOffAxisPolicy(VGroupLayout.STRETCH);
|
||||
setLayout(layout);
|
||||
|
||||
// create our interface elements
|
||||
createConfigInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default implementation creates a label indicating that no game
|
||||
* specific configurations are available.
|
||||
*/
|
||||
protected void createConfigInterface ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides this configurator with its configuration. It should set up
|
||||
* all of its user interface elements to reflect the configuration.
|
||||
*/
|
||||
public void setGameConfig (GameConfig config)
|
||||
{
|
||||
_config = config;
|
||||
// set up the user interface
|
||||
gotGameConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes will likely want to override this method and
|
||||
* configure their user interface elements accordingly.
|
||||
*/
|
||||
protected void gotGameConfig ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a configured game configuration.
|
||||
*/
|
||||
public GameConfig getGameConfig ()
|
||||
{
|
||||
// flush our changes to the config object
|
||||
flushGameConfig();
|
||||
return _config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes will want to override this method, flushing values
|
||||
* from the user interface to the game config object so that it is
|
||||
* properly configured prior to being returned to the {@link
|
||||
* #getGameConfig} caller.
|
||||
*/
|
||||
protected void flushGameConfig ()
|
||||
{
|
||||
}
|
||||
|
||||
/** Provides access to client services. */
|
||||
protected ParlorContext _ctx;
|
||||
|
||||
/** Our game configuration. */
|
||||
protected GameConfig _config;
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
//
|
||||
// $Id: GameConfig.java,v 1.10 2002/07/23 05:54:52 mdb Exp $
|
||||
// $Id: GameConfig.java,v 1.11 2002/07/25 23:20:22 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.parlor.client.GameConfigurator;
|
||||
|
||||
/**
|
||||
* The game config class encapsulates the configuration information for a
|
||||
@@ -27,6 +28,14 @@ public abstract class GameConfig extends PlaceConfig
|
||||
/** Indicates whether or not this game is rated. */
|
||||
public boolean rated = true;
|
||||
|
||||
/**
|
||||
* Returns the class that should be used to create a user interface
|
||||
* that can be used to configure this instance prior to starting the
|
||||
* game. The configurator class must derive from {@link
|
||||
* GameConfigurator}.
|
||||
*/
|
||||
public abstract Class getConfiguratorClass ();
|
||||
|
||||
/**
|
||||
* Returns true if this game config object is equal to the supplied
|
||||
* object (meaning it is also a game config object and its
|
||||
|
||||
Reference in New Issue
Block a user