soc.client
Class NewGameOptionsFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by soc.client.NewGameOptionsFrame
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.TextListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class NewGameOptionsFrame
extends java.awt.Frame
implements java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.ItemListener, java.awt.event.TextListener, java.awt.event.MouseListener

This is the dialog for options to set in a new game. Prompt for name and options.

Also used for showing a game's options (read-only) during game play.

If this window already exists and you'd like to make it topmost, call setVisible(boolean) instead of Component.requestFocus().

Game option "SC" (Scenarios) gets special rendering. Internally it's SOCGameOption.OTYPE_STR, but it's presented as a checkbox and Choice. When a scenario is picked in the Choice, related options are updated by "SC"'s SOCGameOption.ChangeListener.

This class also contains the "Scenario Info" popup window, called from this dialog's Scenario Info button, and from SOCPlayerInterface when first joining a game with a scenario. See showScenarioInfoDialog(SOCScenario, Map, int, SOCPlayerClient.GameAwtDisplay, Frame).

Since:
1.1.07
Author:
Jeremy D Monin <jeremy@nand.net>
See Also:
Serialized Form

Nested Class Summary
 class NewGameOptionsFrame.IntTextField
          A textfield that accepts only nonnegative-integer characters.
private  class NewGameOptionsFrame.VersionConfirmDialog
          This is the modal dialog to ask user if these options' required minimum client version is OK.
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.util.Map<java.lang.String,SOCScenario> allSc
          Scenario info for scenDropdown, if opts contains the "SC" game option, or null.
private  java.util.Map<java.lang.String,java.awt.Checkbox> boolOptCheckboxes
          Key = SOCGameOption.key; value = Checkbox if bool/intbool option.
private  java.awt.Button cancel
          Cancel button; text is "OK" if readOnly
private  java.util.Map<java.awt.Component,SOCGameOption> controlsOpts
          Key = AWT control; value = SOCGameOption within opts.
private  java.awt.Button create
          Create Game button; null if readOnly
private  boolean forNewGame
          Is this NGOF used to set options for a new game, not to show them for an existing one?
private  boolean forPractice
          should this be sent to the remote tcp server, or local practice server?
private  SOCPlayerClient.GameAwtDisplay gameDisplay
           
private  java.awt.TextField gameName
           
private static java.awt.Color HEADER_LABEL_BG
           
private static java.awt.Color HEADER_LABEL_FG
           
static int INTFIELD_POPUP_MAXRANGE
          Maximum range (min-max value) for integer-type options to be rendered using a value popup, instead of a textfield.
private static java.awt.Color LABEL_TXT_COLOR
           
private static double LOG_10
          Natural log of 10.
private  java.awt.TextField msgText
          msgText is null if readOnly
private static java.awt.Color NGOF_BG
           
private  java.util.Map<java.lang.String,SOCGameOption> opts
          Contains this game's SOCGameOptions, or null if none.
private  java.util.Map<java.lang.String,java.awt.Component> optsControls
          AWT control for each gameopt, for handling SOCGameOption.refreshDisplay() if called by SOCGameOption.ChangeListeners.
private  boolean readOnly
          is this for display only?
private  javax.swing.JComboBox scenDropdown
          Scenario choice dropdown if opts contains the "SC" game option, or null.
private  java.awt.Button scenInfo
          Scenario Info button, for info window about scenDropdown's selected scenario, or null.
private static SOCStringManager strings
          i18n text strings; will use same locale as SOCPlayerClient's string manager.
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
NewGameOptionsFrame(SOCPlayerClient.GameAwtDisplay gd, java.lang.String gaName, java.util.Map<java.lang.String,SOCGameOption> opts, boolean forPractice, boolean readOnly)
          Creates a new NewGameOptionsFrame.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          React to button clicks
private  void clickCancel()
          Dismiss the frame
private  void clickCreate(boolean checkOptionsMinVers)
          "Connect..." from connect setup; check fields, etc
private  void clickScenarioInfo()
          The "Scenario Info" button was clicked.
static NewGameOptionsFrame createAndShow(SOCPlayerClient.GameAwtDisplay cli, java.lang.String gaName, java.util.Map<java.lang.String,SOCGameOption> opts, boolean forPractice, boolean readOnly)
          Creates and shows a new NewGameOptionsFrame.
 void dispose()
          Dismiss the frame, and clear client's SOCPlayerClient.GameAwtDisplay.newGameOptsFrame reference to null if it's to this frame.
private  void fireOptionChangeListener(SOCGameOption.ChangeListener cl, SOCGameOption opt, java.lang.Object oldValue, java.lang.Object newValue)
          Handle firing a game option's ChangeListener, and refreshing related gameopts' values on-screen if needed.
private  void fireUserChangedOptListeners(SOCGameOption opt, java.lang.Object ctrl, boolean newBoolValue, boolean changeBoolValue)
          A game option's value widget was changed by the user.
private  void initInterface_Opt1(SOCGameOption op, java.awt.Component oc, boolean hasCB, boolean allowPH, java.awt.Panel bp, java.awt.GridBagLayout gbl, java.awt.GridBagConstraints gbc)
          Add one GridBagLayout row with this game option (component and label(s)).
private  void initInterface_Options(java.awt.Panel bp, java.awt.GridBagLayout gbl, java.awt.GridBagConstraints gbc)
          Interface setup: Options.
private  void initInterface_OptLine(SOCGameOption op, java.awt.Panel bp, java.awt.GridBagLayout gbl, java.awt.GridBagConstraints gbc)
          Set up one game option in one line of the panel.
private  void initInterfaceElements(java.lang.String gaName)
          Interface setup for constructor.
private  java.awt.Choice initOption_enum(SOCGameOption op)
          Create a popup menu for the choices of this enum.
private  java.awt.Component initOption_int(SOCGameOption op)
          Based on this game option's type, present its intvalue either as a numeric textfield, or a popup menu if min/max are near each other.
 void itemStateChanged(java.awt.event.ItemEvent e)
          Called when a Choice or Checkbox value changes (ItemListener).
 void keyPressed(java.awt.event.KeyEvent e)
          Handle Enter or Esc key (KeyListener)
 void keyReleased(java.awt.event.KeyEvent arg0)
          Stub required by KeyListener
 void keyTyped(java.awt.event.KeyEvent arg0)
          Stub required by KeyListener
 void mouseClicked(java.awt.event.MouseEvent e)
          when an option with a boolValue's label is clicked, toggle its checkbox
 void mouseEntered(java.awt.event.MouseEvent e)
          required stub for MouseListener
 void mouseExited(java.awt.event.MouseEvent e)
          required stub for MouseListener
 void mousePressed(java.awt.event.MouseEvent e)
          required stub for MouseListener
 void mouseReleased(java.awt.event.MouseEvent e)
          required stub for MouseListener
private  boolean readOptsValuesFromControls(boolean checkOptionsMinVers)
          Read option values from controls, as prep to request the new game.
 void setVisible(boolean b)
          When the window is shown, request focus on game name textfield.
static void showScenarioInfoDialog(SOCGame ga, SOCPlayerClient.GameAwtDisplay cli, java.awt.Frame parent)
          Show a popup window with this game's scenario's description, special rules, and number of victory points to win.
static void showScenarioInfoDialog(SOCScenario sc, java.util.Map<java.lang.String,SOCGameOption> gameOpts, int vpWinner, SOCPlayerClient.GameAwtDisplay cli, java.awt.Frame parent)
          Show a popup window with this scenario's description, special rules, and number of victory points to win.
 void textValueChanged(java.awt.event.TextEvent e)
          When gamename contents change, enable/disable buttons as appropriate.
 
Methods inherited from class java.awt.Frame
addNotify, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

INTFIELD_POPUP_MAXRANGE

public static final int INTFIELD_POPUP_MAXRANGE
Maximum range (min-max value) for integer-type options to be rendered using a value popup, instead of a textfield.

See Also:
initOption_int(SOCGameOption), Constant Field Values

gameDisplay

private final SOCPlayerClient.GameAwtDisplay gameDisplay

forPractice

private final boolean forPractice
should this be sent to the remote tcp server, or local practice server?


forNewGame

private final boolean forNewGame
Is this NGOF used to set options for a new game, not to show them for an existing one?

Since:
1.1.19

readOnly

private final boolean readOnly
is this for display only?


opts

private java.util.Map<java.lang.String,SOCGameOption> opts
Contains this game's SOCGameOptions, or null if none. Unknowns (OTYPE_UNKNOWN) are removed in initInterface_options.

The opts' values are updated from controls when the user hits the Create Game button, and sent to the server to create the game. If there are SOCGameOption.ChangeListeners, they are updated as soon as the user changes them in the controls, then re-updated when Create is hit.

See Also:
readOptsValuesFromControls(boolean)

controlsOpts

private java.util.Map<java.awt.Component,SOCGameOption> controlsOpts
Key = AWT control; value = SOCGameOption within opts. Empty if opts is null.


optsControls

private java.util.Map<java.lang.String,java.awt.Component> optsControls
AWT control for each gameopt, for handling SOCGameOption.refreshDisplay() if called by SOCGameOption.ChangeListeners. Key = option key; value = Component. Null if readOnly. For game options with 2 input controls (OTYPE_INTBOOL, OTYPE_ENUMBOOL), the TextField/Choice is found here, and the boolean Checkbox is found in boolOptCheckboxes. The scenario dropdown (option "SC") uses a JComboBox control holding SOCScenario objects and the string "(none)".

Since:
1.1.13
See Also:
fireOptionChangeListener(soc.game.SOCGameOption.ChangeListener, SOCGameOption, Object, Object)

boolOptCheckboxes

private java.util.Map<java.lang.String,java.awt.Checkbox> boolOptCheckboxes
Key = SOCGameOption.key; value = Checkbox if bool/intbool option. Empty if none, null if readOnly. Used to quickly find an option's associated checkbox.


allSc

private java.util.Map<java.lang.String,SOCScenario> allSc
Scenario info for scenDropdown, if opts contains the "SC" game option, or null. Initialized from SOCScenario.getAllKnownScenarios() during initInterface_Options(Panel, GridBagLayout, GridBagConstraints), which is called after any server negotiations.

Since:
2.0.00

scenDropdown

private javax.swing.JComboBox scenDropdown
Scenario choice dropdown if opts contains the "SC" game option, or null. When an item is selected, actionPerformed(ActionEvent) reacts specially for this control to update "SC" within opts and enable/disable scenInfo.

Since:
2.0.00

scenInfo

private java.awt.Button scenInfo
Scenario Info button, for info window about scenDropdown's selected scenario, or null.

Since:
2.0.00
See Also:
clickScenarioInfo()

create

private java.awt.Button create
Create Game button; null if readOnly


cancel

private java.awt.Button cancel
Cancel button; text is "OK" if readOnly


gameName

private java.awt.TextField gameName

msgText

private java.awt.TextField msgText
msgText is null if readOnly


NGOF_BG

private static final java.awt.Color NGOF_BG

HEADER_LABEL_BG

private static final java.awt.Color HEADER_LABEL_BG

HEADER_LABEL_FG

private static final java.awt.Color HEADER_LABEL_FG

strings

private static final SOCStringManager strings
i18n text strings; will use same locale as SOCPlayerClient's string manager. Localized option names are requested from the server when client locale isn't en_US.

Since:
2.0.00

LABEL_TXT_COLOR

private static final java.awt.Color LABEL_TXT_COLOR

LOG_10

private static final double LOG_10
Natural log of 10. For use in initOption_int(SOCGameOption), to determine number of digits needed for the option in a textfield (not available in java 1.4)

Constructor Detail

NewGameOptionsFrame

public NewGameOptionsFrame(SOCPlayerClient.GameAwtDisplay gd,
                           java.lang.String gaName,
                           java.util.Map<java.lang.String,SOCGameOption> opts,
                           boolean forPractice,
                           boolean readOnly)
Creates a new NewGameOptionsFrame. Once created, reset the mouse cursor from hourglass to normal, and clear main panel's status text.

Parameters:
gd - Game display interface
gaName - Name of existing game, or null for new game; will be blank or (forPractice) to use SOCPlayerClient.DEFAULT_PRACTICE_GAMENAME.
opts - Set of SOCGameOptions; its values will be changed when "New Game" button is pressed, so the next OptionsFrame will default to the values the user has chosen. To preserve them, call SOCGameOption.cloneOptions(Map) beforehand. Null if server doesn't support game options. Unknown options (SOCGameOption.OTYPE_UNKNOWN) will be removed. If not readOnly, each option's userChanged flag will be cleared, to reset status from any previously shown NewGameOptionsFrame.
forPractice - Will this game be on local practice server, vs remote tcp server?
readOnly - Is this display-only (for use during a game), or can it be changed (making a new game)?
Method Detail

createAndShow

public static NewGameOptionsFrame createAndShow(SOCPlayerClient.GameAwtDisplay cli,
                                                java.lang.String gaName,
                                                java.util.Map<java.lang.String,SOCGameOption> opts,
                                                boolean forPractice,
                                                boolean readOnly)
Creates and shows a new NewGameOptionsFrame. Once created, reset the mouse cursor from hourglass to normal, and clear main panel's status text. See constructor for notes about opts and other parameters.

Parameters:
gaName - Name of existing game, or null to show options for a new game; see constructor for details
Returns:
the new frame

initInterfaceElements

private void initInterfaceElements(java.lang.String gaName)
Interface setup for constructor. Assumes BorderLayout. Most elements are part of a sub-panel occupying most of this Frame, and using GridBagLayout.


initInterface_Options

private void initInterface_Options(java.awt.Panel bp,
                                   java.awt.GridBagLayout gbl,
                                   java.awt.GridBagConstraints gbc)
Interface setup: Options. One row per option, except for 3-letter options which group with 2-letter ones. Boolean checkboxes go on the left edge; text and int/enum values are to right of checkboxes.

When showing options to create a new game, option keys starting with '_' are hidden unless the player nickname is "debug". This prevents unwanted changes to those options, which are set at the server during game creation. When the options are shown read-only during a game, these options are shown and not hidden.

Options which have SOCGameOption.FLAG_INTERNAL_GAME_PROPERTY are always hidden. If not readOnly, they're removed from opts. Unknown opts are always removed.

This is called from constructor, so this is a new NGOF being shown. If not read-only, clear SOCGameOption.userChanged flag for each option in opts.

If options are null, put a label with "This server version does not support game options" (localized).


initInterface_OptLine

private void initInterface_OptLine(SOCGameOption op,
                                   java.awt.Panel bp,
                                   java.awt.GridBagLayout gbl,
                                   java.awt.GridBagConstraints gbc)
Set up one game option in one line of the panel. Based on the option type, create the appropriate AWT component and call initInterface_Opt1(SOCGameOption, Component, boolean, boolean, Panel, GridBagLayout, GridBagConstraints).

Special handling: Scenario (option "SC") gets a checkbox, label, dropdown, and a second line with an Info button. (Sets scenDropdown, scenInfo).

Parameters:
op - Option data
bp - Add to this panel
gbl - Use this layout
gbc - Use these constraints

initInterface_Opt1

private void initInterface_Opt1(SOCGameOption op,
                                java.awt.Component oc,
                                boolean hasCB,
                                boolean allowPH,
                                java.awt.Panel bp,
                                java.awt.GridBagLayout gbl,
                                java.awt.GridBagConstraints gbc)
Add one GridBagLayout row with this game option (component and label(s)). The option's descriptive text may have "#" as a placeholder for where int/enum value is specified (IntTextField or Choice-dropdown).

Parameters:
op - Option data
oc - Component with option choices (popup menu, textfield, etc). If oc is a NewGameOptionsFrame.IntTextField or Choice, and hasCB, changing the component's value will set the checkbox. oc will be added to optsControls and controlsOpts.
hasCB - Add a checkbox? If oc is Checkbox, set this true; it won't add a second checkbox. The checkbox will be added to boolOptCheckboxes and controlsOpts.
allowPH - Allow the "#" placeholder within option desc?
bp - Add to this panel
gbl - Use this layout
gbc - Use these constraints; gridwidth will be set to 1 and then REMAINDER

initOption_int

private java.awt.Component initOption_int(SOCGameOption op)
Based on this game option's type, present its intvalue either as a numeric textfield, or a popup menu if min/max are near each other. The maximum min/max distance which creates a popup is INTFIELD_POPUP_MAXRANGE.

Parameters:
op - A SOCGameOption with an integer value, that is, of type OTYPE_INT or OTYPE_INTBOOL
Returns:
an IntTextField or Choice (popup menu)

initOption_enum

private java.awt.Choice initOption_enum(SOCGameOption op)
Create a popup menu for the choices of this enum.

Parameters:
op - Game option, of type OTYPE_ENUM or OTYPE_ENUMBOOL

setVisible

public void setVisible(boolean b)
When the window is shown, request focus on game name textfield. To make this window topmost, call setVisible(true) instead of Component.requestFocus().

Overrides:
setVisible in class java.awt.Window

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
React to button clicks

Specified by:
actionPerformed in interface java.awt.event.ActionListener

clickCreate

private void clickCreate(boolean checkOptionsMinVers)
"Connect..." from connect setup; check fields, etc


clickCancel

private void clickCancel()
Dismiss the frame


clickScenarioInfo

private void clickScenarioInfo()
The "Scenario Info" button was clicked. Reads the current scenario, if any, from scenDropdown. Calls showScenarioInfoDialog(SOCScenario, Map, int, SOCPlayerClient.GameAwtDisplay, Frame).

Since:
2.0.00

dispose

public void dispose()
Dismiss the frame, and clear client's SOCPlayerClient.GameAwtDisplay.newGameOptsFrame reference to null if it's to this frame.

Overrides:
dispose in class java.awt.Window

readOptsValuesFromControls

private boolean readOptsValuesFromControls(boolean checkOptionsMinVers)
Read option values from controls, as prep to request the new game. If there is a problem (out of range, bad character in integer field, etc), set msgText and set focus on the field.

Parameters:
checkOptionsMinVers - Warn the user if the options will require a minimum client version? Won't do so if forPractice is set, because this isn't a problem for local practice games. The warning is skipped if that minimum is an old version <= Version.versionNumberMaximumNoWarn().
Returns:
true if all were read OK, false if a problem (such as NumberFormatException)

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Handle Enter or Esc key (KeyListener)

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent arg0)
Stub required by KeyListener

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent arg0)
Stub required by KeyListener

Specified by:
keyTyped in interface java.awt.event.KeyListener

textValueChanged

public void textValueChanged(java.awt.event.TextEvent e)
When gamename contents change, enable/disable buttons as appropriate. (TextListener) Also handles SOCGameOption.OTYPE_INTBOOL textfield/checkbox combos. Also sets SOCGameOption.userChanged.

Specified by:
textValueChanged in interface java.awt.event.TextListener
Parameters:
e - textevent from gameName, or from a TextField in controlsOpts

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Called when a Choice or Checkbox value changes (ItemListener). Used for these things:

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
e - itemevent from a Choice or Checkbox in controlsOpts

fireUserChangedOptListeners

private final void fireUserChangedOptListeners(SOCGameOption opt,
                                               java.lang.Object ctrl,
                                               boolean newBoolValue,
                                               boolean changeBoolValue)
A game option's value widget was changed by the user. If this game option has a SOCGameOption.ChangeListener, call it with the appropriate old and new values. Call to update opt's value fields: Calls fireOptionChangeListener(soc.game.SOCGameOption.ChangeListener, SOCGameOption, Object, Object) for the Option's boolean and/or int values.

Parameters:
opt - Game option changed
ctrl - The Checkbox or Choice or JComboBox dropdown changed by the user
newBoolValue - New value to set for opt.getBoolValue()
changeBoolValue - True if the user changed the opt's boolean value, false if the opt's int or string value dropdown was changed but boolean wasn't.
Since:
2.0.00

fireOptionChangeListener

private void fireOptionChangeListener(SOCGameOption.ChangeListener cl,
                                      SOCGameOption opt,
                                      java.lang.Object oldValue,
                                      java.lang.Object newValue)
Handle firing a game option's ChangeListener, and refreshing related gameopts' values on-screen if needed. If oldValue.equals(newValue), nothing happens and the ChangeListener is not called.

Parameters:
cl - The ChangeListener; must not be null
opt - The game option
oldValue - Old value, string or boxed primitive
newValue - New value, string or boxed primitive
Since:
1.1.13

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
when an option with a boolValue's label is clicked, toggle its checkbox

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
required stub for MouseListener

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
required stub for MouseListener

Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
required stub for MouseListener

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
required stub for MouseListener

Specified by:
mouseReleased in interface java.awt.event.MouseListener

showScenarioInfoDialog

public static void showScenarioInfoDialog(SOCGame ga,
                                          SOCPlayerClient.GameAwtDisplay cli,
                                          java.awt.Frame parent)
Show a popup window with this game's scenario's description, special rules, and number of victory points to win. Calls EventQueue.invokeLater(Runnable).

Parameters:
ga - Game to display scenario info for; if game option "SC" missing or blank, does nothing.
cli - Player client interface, for NotifyDialog call
parent - Current game's player interface, or another Frame for our parent window, or null to look for cli's Frame as parent
Since:
2.0.00

showScenarioInfoDialog

public static void showScenarioInfoDialog(SOCScenario sc,
                                          java.util.Map<java.lang.String,SOCGameOption> gameOpts,
                                          int vpWinner,
                                          SOCPlayerClient.GameAwtDisplay cli,
                                          java.awt.Frame parent)
Show a popup window with this scenario's description, special rules, and number of victory points to win. Calls EventQueue.invokeLater(Runnable).

Parameters:
sc - A SOCScenario, or null to do nothing
gameOpts - All game options if current game, or null to extract from sc's SOCScenario.scOpts
vpWinner - Number of victory points to win, or SOCGame.VP_WINNER_STANDARD.
cli - Player client interface, required for AskDialog constructor
parent - Current game's player interface, or another Frame for our parent window, or null to look for cli's Frame as parent
Since:
2.0.00