The continuing refactor.
- GameConfigurators are no longer JPanels, but rather abstract classes that show UI in their own way. There is a SwingGameConfigurator that has a panel. - TableConfigurator is no longer an interface, but is now more closely like the GameConfigurator. - Repackaged some things that were in the wrong place. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3593 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -40,14 +40,14 @@ import com.threerings.micasa.Log;
|
|||||||
import com.threerings.micasa.lobby.LobbyConfig;
|
import com.threerings.micasa.lobby.LobbyConfig;
|
||||||
import com.threerings.micasa.util.MiCasaContext;
|
import com.threerings.micasa.util.MiCasaContext;
|
||||||
|
|
||||||
import com.threerings.parlor.client.GameConfigurator;
|
|
||||||
import com.threerings.parlor.client.SeatednessObserver;
|
import com.threerings.parlor.client.SeatednessObserver;
|
||||||
|
import com.threerings.parlor.client.TableConfigurator;
|
||||||
import com.threerings.parlor.client.TableDirector;
|
import com.threerings.parlor.client.TableDirector;
|
||||||
import com.threerings.parlor.client.TableObserver;
|
import com.threerings.parlor.client.TableObserver;
|
||||||
import com.threerings.parlor.data.Table;
|
import com.threerings.parlor.data.Table;
|
||||||
import com.threerings.parlor.data.TableConfigurator;
|
import com.threerings.parlor.game.client.GameConfigurator;
|
||||||
|
import com.threerings.parlor.game.client.SwingGameConfigurator;
|
||||||
import com.threerings.parlor.game.data.GameConfig;
|
import com.threerings.parlor.game.data.GameConfig;
|
||||||
import com.threerings.parlor.game.data.TableableGameConfig;
|
|
||||||
|
|
||||||
import com.threerings.crowd.client.PlaceView;
|
import com.threerings.crowd.client.PlaceView;
|
||||||
import com.threerings.crowd.data.PlaceObject;
|
import com.threerings.crowd.data.PlaceObject;
|
||||||
@@ -100,15 +100,22 @@ public class TableListView extends JPanel
|
|||||||
GameConfig gconfig = null;
|
GameConfig gconfig = null;
|
||||||
try {
|
try {
|
||||||
gconfig = config.getGameConfig();
|
gconfig = config.getGameConfig();
|
||||||
_tableFigger =
|
|
||||||
((TableableGameConfig) gconfig).createTableConfigurator(_ctx);
|
_tableFigger = gconfig.createTableConfigurator();
|
||||||
panel.add((Component) _tableFigger, VGroupLayout.FIXED);
|
if (_tableFigger == null) {
|
||||||
|
Log.warning("Game config has not been set up to work with " +
|
||||||
|
"tables: it needs to return non-null from " +
|
||||||
|
"createTableConfigurator().");
|
||||||
|
// let's just wait until we throw an NPE below
|
||||||
|
}
|
||||||
|
|
||||||
_figger = gconfig.createConfigurator();
|
_figger = gconfig.createConfigurator();
|
||||||
|
_tableFigger.init(_ctx, _figger);
|
||||||
if (_figger != null) {
|
if (_figger != null) {
|
||||||
_figger.init(_ctx);
|
_figger.init(_ctx);
|
||||||
_figger.setGameConfig(gconfig);
|
_figger.setGameConfig(gconfig);
|
||||||
panel.add(_figger, VGroupLayout.FIXED);
|
panel.add(((SwingGameConfigurator) _figger).getPanel(),
|
||||||
|
VGroupLayout.FIXED);
|
||||||
}
|
}
|
||||||
|
|
||||||
_create = new JButton("Create table");
|
_create = new JButton("Create table");
|
||||||
|
|||||||
@@ -22,80 +22,100 @@
|
|||||||
package com.threerings.parlor.client;
|
package com.threerings.parlor.client;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import com.samskivert.swing.SimpleSlider;
|
import com.samskivert.swing.SimpleSlider;
|
||||||
import com.samskivert.swing.VGroupLayout;
|
import com.samskivert.swing.VGroupLayout;
|
||||||
|
|
||||||
import com.threerings.parlor.data.TableConfigurator;
|
|
||||||
import com.threerings.parlor.data.TableConfig;
|
import com.threerings.parlor.data.TableConfig;
|
||||||
import com.threerings.parlor.util.ParlorContext;
|
import com.threerings.parlor.util.ParlorContext;
|
||||||
|
|
||||||
|
import com.threerings.parlor.game.client.SwingGameConfigurator;
|
||||||
|
import com.threerings.parlor.game.data.GameConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a default implementation of a TableConfigurator for
|
* Provides a default implementation of a TableConfigurator for
|
||||||
* a Swing interface.
|
* a Swing interface.
|
||||||
*/
|
*/
|
||||||
public class DefaultSwingTableConfigurator extends JPanel
|
public class DefaultSwingTableConfigurator extends TableConfigurator
|
||||||
implements TableConfigurator
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a TableConfigurator that allows only the specified number
|
* Create a TableConfigurator that allows only the specified number
|
||||||
* of players and lets the configuring user enable private games
|
* of players and lets the configuring user enable private games
|
||||||
* only if the number of players is greater than 2.
|
* only if the number of players is greater than 2.
|
||||||
*/
|
*/
|
||||||
public DefaultSwingTableConfigurator (ParlorContext ctx, int players)
|
public DefaultSwingTableConfigurator (int players)
|
||||||
{
|
{
|
||||||
this(ctx, players, (players > 2));
|
this(players, (players > 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a TableConfigurator that allows only the specified number
|
* Create a TableConfigurator that allows only the specified number
|
||||||
* of players and lets the user configure a private table, or not.
|
* of players and lets the user configure a private table, or not.
|
||||||
*/
|
*/
|
||||||
public DefaultSwingTableConfigurator (ParlorContext ctx, int players,
|
public DefaultSwingTableConfigurator (int players, boolean allowPrivate)
|
||||||
boolean allowPrivate)
|
|
||||||
{
|
{
|
||||||
this(ctx, players, players, players, allowPrivate);
|
this(players, players, players, allowPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a TableConfigurator that allows for the specified configuration
|
* Create a TableConfigurator that allows for the specified configuration
|
||||||
* parameters.
|
* parameters.
|
||||||
*/
|
*/
|
||||||
public DefaultSwingTableConfigurator (ParlorContext ctx, int minPlayers,
|
public DefaultSwingTableConfigurator (int minPlayers,
|
||||||
int desiredPlayers, int maxPlayers, boolean allowPrivate)
|
int desiredPlayers, int maxPlayers, boolean allowPrivate)
|
||||||
{
|
{
|
||||||
super(new VGroupLayout()); // TODO: layout improvement?
|
// create a slider for players, if applicable
|
||||||
|
|
||||||
// TODO: translations
|
|
||||||
_playerSlider = new SimpleSlider(
|
|
||||||
"Seats:", minPlayers, maxPlayers, desiredPlayers);
|
|
||||||
_privateCheck = new JCheckBox("Private?:");
|
|
||||||
|
|
||||||
// figure out what to actually show
|
|
||||||
if (minPlayers != maxPlayers) {
|
if (minPlayers != maxPlayers) {
|
||||||
add(_playerSlider);
|
_playerSlider = new SimpleSlider(
|
||||||
|
"", minPlayers, maxPlayers, desiredPlayers);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_config.desiredPlayerCount = desiredPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create up the checkbox for private games, if applicable
|
||||||
if (allowPrivate) {
|
if (allowPrivate) {
|
||||||
add(_privateCheck);
|
_privateCheck = new JCheckBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface TableConfigurator
|
// documentation inherited
|
||||||
|
protected void createConfigInterface ()
|
||||||
|
{
|
||||||
|
super.createConfigInterface();
|
||||||
|
|
||||||
|
SwingGameConfigurator gconf = (SwingGameConfigurator) _gameConfigurator;
|
||||||
|
|
||||||
|
if (_playerSlider != null) {
|
||||||
|
// TODO: proper translation
|
||||||
|
gconf.addControl(new JLabel("Players:"), _playerSlider);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_privateCheck != null) {
|
||||||
|
// TODO: proper translation
|
||||||
|
gconf.addControl(new JLabel("Private:"), _privateCheck);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
public boolean isEmpty ()
|
public boolean isEmpty ()
|
||||||
{
|
{
|
||||||
return (getComponentCount() == 0);
|
return (_playerSlider == null) && (_privateCheck == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface TableConfigurator
|
// documentation inherited
|
||||||
public TableConfig getTableConfig ()
|
protected void flushTableConfig()
|
||||||
{
|
{
|
||||||
TableConfig tconfig = new TableConfig();
|
super.flushTableConfig();
|
||||||
tconfig.desiredPlayerCount = _playerSlider.getValue();
|
|
||||||
tconfig.privateTable = _privateCheck.isSelected();
|
|
||||||
|
|
||||||
return tconfig;
|
if (_playerSlider != null) {
|
||||||
|
_config.desiredPlayerCount = _playerSlider.getValue();
|
||||||
|
}
|
||||||
|
if (_privateCheck != null) {
|
||||||
|
_config.privateTable = _privateCheck.isSelected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A slider for configuring the number of players at the table. */
|
/** A slider for configuring the number of players at the table. */
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Narya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2005 Three Rings Design, Inc., All Rights Reserved
|
||||||
|
// http://www.threerings.net/code/narya/
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU Lesser General Public License as published
|
||||||
|
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
package com.threerings.parlor.client;
|
||||||
|
|
||||||
|
import com.threerings.parlor.util.ParlorContext;
|
||||||
|
|
||||||
|
import com.threerings.parlor.data.TableConfig;
|
||||||
|
|
||||||
|
import com.threerings.parlor.game.client.GameConfigurator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should be implemented some user-interface element that allows
|
||||||
|
* the user to configure whichever TableConfig options are relevant.
|
||||||
|
*/
|
||||||
|
public abstract class TableConfigurator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a TableConfigurator.
|
||||||
|
*/
|
||||||
|
public TableConfigurator ()
|
||||||
|
{
|
||||||
|
_config = createTableConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the TableConfigurator.
|
||||||
|
*
|
||||||
|
* At the time this is called, the GameConfigurator should have
|
||||||
|
* already been initialized.
|
||||||
|
*/
|
||||||
|
public void init (ParlorContext ctx, GameConfigurator gameConfigurator)
|
||||||
|
{
|
||||||
|
_ctx = ctx;
|
||||||
|
_gameConfigurator = gameConfigurator;
|
||||||
|
createConfigInterface();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the table config object that will be used.
|
||||||
|
*/
|
||||||
|
protected TableConfig createTableConfig ()
|
||||||
|
{
|
||||||
|
return new TableConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the config interface.
|
||||||
|
*/
|
||||||
|
protected void createConfigInterface ()
|
||||||
|
{
|
||||||
|
// nothing by default
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, the TableConfigurator is empty, which doesn't mean that
|
||||||
|
* it will not return a TableConfig object (for it must), but rather
|
||||||
|
* that there are no user-editable options being presented in the
|
||||||
|
* config interface.
|
||||||
|
*/
|
||||||
|
public abstract boolean isEmpty ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the fully configured table config according to the currently
|
||||||
|
* configured user interface elements.
|
||||||
|
*/
|
||||||
|
public TableConfig getTableConfig ()
|
||||||
|
{
|
||||||
|
flushTableConfig();
|
||||||
|
return _config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived classes will want to override this method, flushing
|
||||||
|
* values from the user interface to the table config object.
|
||||||
|
*/
|
||||||
|
protected void flushTableConfig ()
|
||||||
|
{
|
||||||
|
// nothing by default
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Provides access to client services. */
|
||||||
|
protected ParlorContext _ctx;
|
||||||
|
|
||||||
|
/** The config we're configurating. */
|
||||||
|
protected TableConfig _config;
|
||||||
|
|
||||||
|
/** The game configurator, which we may wish to reference. */
|
||||||
|
protected GameConfigurator _gameConfigurator;
|
||||||
|
}
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
//
|
|
||||||
// $Id$
|
|
||||||
//
|
|
||||||
// Narya library - tools for developing networked games
|
|
||||||
// Copyright (C) 2002-2005 Three Rings Design, Inc., All Rights Reserved
|
|
||||||
// http://www.threerings.net/code/narya/
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or modify it
|
|
||||||
// under the terms of the GNU Lesser General Public License as published
|
|
||||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
package com.threerings.parlor.data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This should be implemented some user-interface element that allows
|
|
||||||
* the user to configure whichever TableConfig options are relevant.
|
|
||||||
*/
|
|
||||||
public interface TableConfigurator
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* If true, the tableConfigurator is empty, useful if the lobby code
|
|
||||||
* can skip the step of letting the table creator configure things
|
|
||||||
* if the game configurator is also empty.
|
|
||||||
*/
|
|
||||||
public boolean isEmpty ();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the fully configured table config when the user is ready
|
|
||||||
* to create their table.
|
|
||||||
*/
|
|
||||||
public TableConfig getTableConfig ();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
//
|
||||||
|
// $Id: GameConfigurator.java 3590 2005-06-08 23:20:18Z ray $
|
||||||
|
//
|
||||||
|
// Narya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||||
|
// http://www.threerings.net/code/narya/
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU Lesser General Public License as published
|
||||||
|
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
package com.threerings.parlor.game.client;
|
||||||
|
|
||||||
|
import com.threerings.parlor.game.data.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 abstract class GameConfigurator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
// create our interface elements
|
||||||
|
createConfigInterface();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default implementation creates nothing.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
+19
-74
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id$
|
// $Id: GameConfigurator.java 3590 2005-06-08 23:20:18Z ray $
|
||||||
//
|
//
|
||||||
// Narya library - tools for developing networked games
|
// Narya library - tools for developing networked games
|
||||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
package com.threerings.parlor.client;
|
package com.threerings.parlor.game.client;
|
||||||
|
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
@@ -43,64 +43,14 @@ import com.threerings.parlor.util.ParlorContext;
|
|||||||
* based on the class returned from the {@link GameConfig} and then
|
* based on the class returned from the {@link GameConfig} and then
|
||||||
* initialize it with a call to {@link #init}.
|
* initialize it with a call to {@link #init}.
|
||||||
*/
|
*/
|
||||||
public class GameConfigurator extends JPanel
|
public abstract class SwingGameConfigurator extends GameConfigurator
|
||||||
{
|
{
|
||||||
// initializer
|
|
||||||
{
|
|
||||||
// BACKcompatible, older code (and toybox) expects the layout
|
|
||||||
// to be a vgroup, so we default to that
|
|
||||||
VGroupLayout layout = new VGroupLayout(VGroupLayout.NONE);
|
|
||||||
layout.setOffAxisPolicy(VGroupLayout.STRETCH);
|
|
||||||
setLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this game configurator, creates its user interface
|
* Get the Swing JPanel that contains the UI elements for this configurator.
|
||||||
* elements and prepares it for display.
|
|
||||||
*/
|
*/
|
||||||
public void init (ParlorContext ctx)
|
public JPanel getPanel ()
|
||||||
{
|
{
|
||||||
// save this for later
|
return _panel;
|
||||||
_ctx = ctx;
|
|
||||||
|
|
||||||
// create our interface elements
|
|
||||||
createConfigInterface();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default implementation creates nothing.
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,8 +64,8 @@ public class GameConfigurator extends JPanel
|
|||||||
{
|
{
|
||||||
// BACKcompatible, newer code will call this method, and so
|
// BACKcompatible, newer code will call this method, and so
|
||||||
// we need to switch the layout to gridbag instead of vgroup
|
// we need to switch the layout to gridbag instead of vgroup
|
||||||
if (!(getLayout() instanceof GridBagLayout)) {
|
if (!(_panel.getLayout() instanceof GridBagLayout)) {
|
||||||
setLayout(new GridBagLayout());
|
_panel.setLayout(new GridBagLayout());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the constraints. There's really no point in saving
|
// Set up the constraints. There's really no point in saving
|
||||||
@@ -133,26 +83,21 @@ public class GameConfigurator extends JPanel
|
|||||||
cc.gridwidth = GridBagConstraints.REMAINDER;
|
cc.gridwidth = GridBagConstraints.REMAINDER;
|
||||||
|
|
||||||
// add the components
|
// add the components
|
||||||
add(label, lc);
|
_panel.add(label, lc);
|
||||||
add(control, cc);
|
_panel.add(control, cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** The panel on which the config options are placed. */
|
||||||
* Derived classes will want to override this method, flushing values
|
protected JPanel _panel = new JPanel();
|
||||||
* from the user interface to the game config object so that it is
|
|
||||||
* properly configured prior to being returned to the {@link
|
{ // initializer
|
||||||
* #getGameConfig} caller.
|
// BACKcompatible, older code (and toybox) expects the layout
|
||||||
*/
|
// to be a vgroup, so we default to that
|
||||||
protected void flushGameConfig ()
|
VGroupLayout layout = new VGroupLayout(VGroupLayout.NONE);
|
||||||
{
|
layout.setOffAxisPolicy(VGroupLayout.STRETCH);
|
||||||
|
_panel.setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Provides access to client services. */
|
|
||||||
protected ParlorContext _ctx;
|
|
||||||
|
|
||||||
/** Our game configuration. */
|
|
||||||
protected GameConfig _config;
|
|
||||||
|
|
||||||
/** Insets for configuration labels. */
|
/** Insets for configuration labels. */
|
||||||
protected Insets _labelInsets = new Insets(1, 0, 1, 4);
|
protected Insets _labelInsets = new Insets(1, 0, 1, 4);
|
||||||
|
|
||||||
@@ -27,7 +27,8 @@ import java.util.List;
|
|||||||
import com.threerings.crowd.data.PlaceConfig;
|
import com.threerings.crowd.data.PlaceConfig;
|
||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
|
|
||||||
import com.threerings.parlor.client.GameConfigurator;
|
import com.threerings.parlor.client.TableConfigurator;
|
||||||
|
import com.threerings.parlor.game.client.GameConfigurator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The game config class encapsulates the configuration information for a
|
* The game config class encapsulates the configuration information for a
|
||||||
@@ -75,6 +76,15 @@ public abstract class GameConfig extends PlaceConfig implements Cloneable
|
|||||||
*/
|
*/
|
||||||
public abstract GameConfigurator createConfigurator ();
|
public abstract GameConfigurator createConfigurator ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a table configurator for initializing 'table' properties
|
||||||
|
* of the game. The default implementation returns null.
|
||||||
|
*/
|
||||||
|
public TableConfigurator createTableConfigurator ()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a translatable label describing this game.
|
* Returns a translatable label describing this game.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
//
|
|
||||||
// $Id$
|
|
||||||
//
|
|
||||||
// Narya library - tools for developing networked games
|
|
||||||
// Copyright (C) 2002-2005 Three Rings Design, Inc., All Rights Reserved
|
|
||||||
// http://www.threerings.net/code/narya/
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or modify it
|
|
||||||
// under the terms of the GNU Lesser General Public License as published
|
|
||||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
package com.threerings.parlor.game.data;
|
|
||||||
|
|
||||||
import com.threerings.parlor.data.TableConfigurator;
|
|
||||||
import com.threerings.parlor.util.ParlorContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface to be implemented by GameConfigs if they want to be
|
|
||||||
* able to use Table matchmaking services.
|
|
||||||
*/
|
|
||||||
public interface TableableGameConfig
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Called when this GameConfig is to be used for Table matchmaking,
|
|
||||||
* returns the TableConfigurator to be used to configure the Table.
|
|
||||||
*/
|
|
||||||
public TableConfigurator createTableConfigurator (ParlorContext ctx);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user