soc.client
Interface SOCPlayerClient.GameDisplay

All Known Implementing Classes:
SOCPlayerClient.GameAwtDisplay
Enclosing class:
SOCPlayerClient

public static interface SOCPlayerClient.GameDisplay

A facade for the SOCPlayerClient to use to invoke actions in the GUI

Since:
2.0.00

Method Summary
 void addToGameList(boolean cannotJoin, java.lang.String gameName, java.lang.String gameOptsStr, boolean addToSrvList)
          Add a new game to the initial window's list of games.
 void channelCreated(java.lang.String channelName)
           
 void channelDeleted(java.lang.String channelName)
           
 void channelJoined(java.lang.String channelName)
           
 void channelJoined(java.lang.String channelName, java.lang.String nickname)
           
 void channelLeft(java.lang.String channelName)
           
 void channelLeft(java.lang.String channelName, java.lang.String nickname)
           
 void channelList(java.util.Collection<java.lang.String> channelNames, boolean isPractice)
           
 void channelMemberList(java.lang.String channelName, java.util.Collection<java.lang.String> members)
           
 void channelsClosed(java.lang.String message)
           
 void clickPracticeButton()
          Act as if the "practice game" button has been clicked.
 void connect(java.lang.String cpass, java.lang.String cuser)
          Prepare to connect and give feedback by showing a message panel.
 boolean deleteFromGameList(java.lang.String gameName, boolean isPractice)
          Delete a game from the list.
 void enableOptions()
           
 void focusPassword()
          If the password field is currently visible, focus the cursor there for the user to type something.
 PlayerClientListener gameJoined(SOCGame game)
           
 void gameWithOptionsBeginSetup(boolean forPracticeServer, boolean didAuth)
          Want to start a new game, on a server which supports options.
 void initVisualElements()
          Init the visual elements.
 void messageBroadcast(java.lang.String message)
           
 void messageReceived(java.lang.String channelName, java.lang.String nickname, java.lang.String message)
           
 void optionsReceived(ServerGametypeInfo opts, boolean isPractice)
          Server has sent its game option default values for new games.
 void optionsReceived(ServerGametypeInfo opts, boolean isPractice, boolean isDash, boolean hasAllNow)
          Server has sent info about a single game option.
 void optionsRequested()
           
 void practiceGameStarting()
           
 void setMessage(java.lang.String string)
           
 void setPassword(java.lang.String pw)
          Set the contents of the password field.
 void showErrorDialog(java.lang.String errMessage, java.lang.String buttonText)
          Show an error dialog which has one button.
 void showErrorPanel(java.lang.String err, boolean canPractice)
          After network trouble, show a panel with the error message instead of the main user/password/games/channels panel.
 void showStatus(java.lang.String statusText, boolean debugWarn)
          Show server welcome banner or status text.
 void showVersion(int versionNumber, java.lang.String versionString, java.lang.String buildString, SOCServerFeatures feats)
          After connecting, display the remote server's version on main panel, and update display based on its active SOCServerFeatures.
 void updateGameStats(java.lang.String gameName, int[] scores, boolean[] robots)
          Update this game's stats in the game list display.
 

Method Detail

initVisualElements

void initVisualElements()
Init the visual elements. Done before connecting to server, so we don't know its version or active SOCServerFeatures. So, most of the Main Panel elements are initialized here but not laid out or made visible until a later call to showVersion(int, String, String, SOCServerFeatures) when the version and features are known.


connect

void connect(java.lang.String cpass,
             java.lang.String cuser)
Prepare to connect and give feedback by showing a message panel. Stores the given username and password in the user interface.

Does not make a network connection. Call SOCPlayerClient.ClientNetwork.connect(String, int) when ready to make the connection.

User login and authentication don't occur until a game or channel join is requested; at that time, the user interface will read the name and password stored here.

Parameters:
cpass - Password text to put into that TextField (obscured)
cuser - User nickname text to put into that TextField

clickPracticeButton

void clickPracticeButton()
Act as if the "practice game" button has been clicked. Assumes the dialog panels are all initialized.


practiceGameStarting

void practiceGameStarting()

setMessage

void setMessage(java.lang.String string)

showErrorDialog

void showErrorDialog(java.lang.String errMessage,
                     java.lang.String buttonText)
Show an error dialog which has one button.

Parameters:
errMessage - Error message to show
buttonText - Button text, or null for "OK"

showErrorPanel

void showErrorPanel(java.lang.String err,
                    boolean canPractice)
After network trouble, show a panel with the error message instead of the main user/password/games/channels panel.

If we have the startup panel (started as JAR client app, not applet) with buttons to connect to a server or practice, show that instead of the simpler practice-only message panel.

Parameters:
err - Error message to show
canPractice - In current state of client, can we start a practice game?
Since:
1.1.16

enableOptions

void enableOptions()

showVersion

void showVersion(int versionNumber,
                 java.lang.String versionString,
                 java.lang.String buildString,
                 SOCServerFeatures feats)
After connecting, display the remote server's version on main panel, and update display based on its active SOCServerFeatures. Not called for practice server. If we're running a server, display its listening port # instead.

Parameters:
versionNumber - Version number, like 1119, from server's Version.versionNumber()
versionString - Version string, like "1.1.19", from server's Version.version()
buildString - Build number, from server's Version.buildnum()
feats - Active optional server features; never null. If server is older than v1.1.19, use the SOCServerFeatures(true) constructor.

showStatus

void showStatus(java.lang.String statusText,
                boolean debugWarn)
Show server welcome banner or status text. If status during initial connect includes warning that the server's in Debug Mode, show that.

Parameters:
statusText - Status message text from server
debugWarn - True if server has Debug Mode active

focusPassword

void focusPassword()
If the password field is currently visible, focus the cursor there for the user to type something.


setPassword

void setPassword(java.lang.String pw)
Set the contents of the password field.


channelJoined

void channelJoined(java.lang.String channelName)

channelJoined

void channelJoined(java.lang.String channelName,
                   java.lang.String nickname)

channelMemberList

void channelMemberList(java.lang.String channelName,
                       java.util.Collection<java.lang.String> members)

channelCreated

void channelCreated(java.lang.String channelName)

channelLeft

void channelLeft(java.lang.String channelName)

channelLeft

void channelLeft(java.lang.String channelName,
                 java.lang.String nickname)

channelList

void channelList(java.util.Collection<java.lang.String> channelNames,
                 boolean isPractice)

channelDeleted

void channelDeleted(java.lang.String channelName)

channelsClosed

void channelsClosed(java.lang.String message)

messageBroadcast

void messageBroadcast(java.lang.String message)

messageReceived

void messageReceived(java.lang.String channelName,
                     java.lang.String nickname,
                     java.lang.String message)

gameJoined

PlayerClientListener gameJoined(SOCGame game)

gameWithOptionsBeginSetup

void gameWithOptionsBeginSetup(boolean forPracticeServer,
                               boolean didAuth)
Want to start a new game, on a server which supports options. Do we know the valid options already? If so, bring up the options window. If not, ask the server for them. If a NewGameOptionsFrame is already showing, give it focus instead of creating a new one.

For a summary of the flags and variables involved with game options, and the client/server interaction about their values, see ServerGametypeInfo.

Parameters:
forPracticeServer - Ask SOCPlayerClient.ClientNetwork.practiceServer, instead of TCP server?
didAuth - If true, the server has authenticated our username and password; set those input fields read-only.

optionsRequested

void optionsRequested()

optionsReceived

void optionsReceived(ServerGametypeInfo opts,
                     boolean isPractice)
Server has sent its game option default values for new games. Called when ServerGametypeInfo.newGameWaitingForOpts flag was set and has just been cleared. Client should show dialog to create a new game which will have game options.

Parameters:
opts - Client's game option info, tracking the TCP or local practice server
isPractice - True if received from SOCPlayerClient.ClientNetwork.practiceServer, instead of TCP server

optionsReceived

void optionsReceived(ServerGametypeInfo opts,
                     boolean isPractice,
                     boolean isDash,
                     boolean hasAllNow)
Server has sent info about a single game option. If hasAllNow, client should check ServerGametypeInfo.newGameWaitingForOpts and ServerGametypeInfo.gameInfoWaitingForOpts, and if either of these were waiting, show a game info/options dialog for a new game or existing game.

Parameters:
opts - Client's game option info, tracking the TCP or local practice server
isPractice - True if received from SOCPlayerClient.ClientNetwork.practiceServer, instead of TCP server
isDash - True if the game option was "-", indicating the end of the list. If so, no further options will be sent and any running timeout task related to the game options can be cancelled.
hasAllNow - If true, all game option info has now been received by the client

addToGameList

void addToGameList(boolean cannotJoin,
                   java.lang.String gameName,
                   java.lang.String gameOptsStr,
                   boolean addToSrvList)
Add a new game to the initial window's list of games. If client can't join, makes sure the game is marked as unjoinable in the SOCPlayerClient.serverGames list.

Parameters:
cannotJoin - Can we not join this game?
gameName - the game name to add to the list; must not have the prefix SOCGames.MARKER_THIS_GAME_UNJOINABLE.
gameOptsStr - String of packed game options, or null
addToSrvList - Should this game be added to the list of remote-server games? Practice games should not be added.

updateGameStats

void updateGameStats(java.lang.String gameName,
                     int[] scores,
                     boolean[] robots)
Update this game's stats in the game list display.

Parameters:
gameName - Name of game to update
scores - Each player position's score
robots - Is this position a robot?
See Also:
SOCGameStats

deleteFromGameList

boolean deleteFromGameList(java.lang.String gameName,
                           boolean isPractice)
Delete a game from the list. If it's on the list, also remove from SOCPlayerClient.serverGames.

Parameters:
gameName - the game to remove
isPractice - Game is practice, not at tcp server?
Returns:
true if deleted, false if not found in list