|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
soc.client.SOCPlayerInterface
Window with interface for a player in one game of Settlers of Catan. Contains board, client and other players' hands, chat interface, game message window, and building/buying panel.
A separate SOCPlayerClient window holds the list of current games and channels.
| Nested Class Summary | |
private static class |
SOCPlayerInterface.MyWindowAdapter
|
protected static class |
SOCPlayerInterface.ResetBoardVoteDialog
This is the dialog to vote on another player's board reset request. |
private static class |
SOCPlayerInterface.SOCPIDiscardMsgTask
When timer fires, show discard message in any other player (not client player) who must discard. |
private static class |
SOCPlayerInterface.SOCPITextfieldListener
Used for chat textfield setting/clearing initial prompt text (TEXTINPUT_INITIAL_PROMPT_MSG). |
| Nested classes inherited from class java.awt.Frame |
java.awt.Frame.AccessibleAWTFrame |
| Nested classes inherited from class java.awt.Window |
java.awt.Window.AccessibleAWTWindow |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
protected boolean |
boardIsScaled
Is the boardpanel stretched beyond normal size in doLayout()? |
protected SOCBoardPanel |
boardPanel
the board display |
protected SOCHandPanel |
boardResetRequester
this other player has requested a board reset; voting is under way. |
protected SOCPlayerInterface.ResetBoardVoteDialog |
boardResetVoteDia
Board reset voting: If voting is active and we haven't yet voted, track our dialog; this lets us dispose of it if voting is cancelled. |
protected SOCBuildingPanel |
buildingPanel
interface for building pieces |
protected SnippingTextArea |
chatDisplay
where chat text is displayed |
protected SOCChoosePlayerDialog |
choosePlayerDialog
the dialog for choosing a player from which to steal |
protected SOCPlayerClient |
client
the client that spawned us |
protected SOCHandPanel |
clientHand
Tracks our own hand within hands[], if we are active in a game. |
private int |
clientHandPlayerNum
Player ID of clientHand, or -1. |
protected SOCDiscardDialog |
discardDialog
the dialog for getting what resources the player wants to discard |
protected SOCDiscoveryDialog |
discoveryDialog
the dialog for choosing 2 resources to discover |
protected java.util.Timer |
eventTimer
Utility for time-driven events in the interface. |
protected SOCGame |
game
the game associated with this interface |
protected boolean |
gameIsStarting
Flag to ensure interface is updated, when the first actual turn begins (state changes from SOCGame.START2B
to SOCGame.PLAY). |
protected SOCHandPanel[] |
hands
the display for the players' hands |
protected SOCMonopolyDialog |
monopolyDialog
the dialog for choosing a resource to monopolize |
protected int |
ncols
number of columns in the text output area |
protected int |
npix
width of text output area in pixels |
protected java.awt.Color[] |
playerColors
the player colors. |
protected java.awt.Color[] |
playerColorsGhost
the player colors. |
private boolean |
showingPlayerDiscards
Is one or more handpanel (of other players) showing a "Discarding..." message? |
private java.lang.Object |
showingPlayerDiscards_lock
Synchronize access to showingPlayerDiscards
and showingPlayerDiscardsTask |
private SOCPlayerInterface.SOCPIDiscardMsgTask |
showingPlayerDiscardsTask
May be null if not active. |
protected SnippingTextArea |
textDisplay
where text is displayed |
protected int |
textDisplayRollExpected
To reduce text clutter: server has just sent a dice result message. |
protected java.awt.TextField |
textInput
where the player types in text |
static java.lang.String |
TEXTINPUT_INITIAL_PROMPT_MSG
Not yet typed-in; display prompt message. |
protected int |
textInputGreyCountdown
Number of change-of-turns during game, after which the initial prompt message fades to light grey. |
protected static int |
textInputGreyCountFrom
Initial value (20 turns) for textInputGreyCountdown |
protected boolean |
textInputHasSent
At least one text chat line has been sent by the player. |
protected boolean |
textInputIsInitial
Not yet typed-in; display prompt message. |
protected SOCPlayerInterface.SOCPITextfieldListener |
textInputListener
Used for responding to textfield changes by setting/clearing prompt message. |
static java.lang.String |
TITLEBAR_GAME
Titlebar text for game in progress |
static java.lang.String |
TITLEBAR_GAME_OVER
Titlebar text for game when over |
| 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.Window |
|
| Fields inherited from class java.awt.Container |
|
| 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 | |
SOCPlayerInterface(java.lang.String title,
SOCPlayerClient cl,
SOCGame ga)
create a new player interface |
|
| Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
send the message that was just typed in |
void |
addPlayer(java.lang.String n,
int pn)
a player has sat down to play |
void |
began()
start the game interface: add "sit" buttons, set chat input (textInput) to initial prompt. |
void |
changeFace(int pn,
int id)
set the face icon for a player |
void |
chatPrint(java.lang.String s)
print text in the chat window |
void |
chatPrintDebug(java.lang.String debugMsg)
if debug is enabled, print this in the chat display. |
void |
chatPrintStackTrace(java.lang.Throwable th)
if debug is enabled, print this exception's stack trace in the chat display. |
private void |
chatPrintStackTrace(java.lang.Throwable th,
boolean isNested)
|
void |
choosePlayer(int count,
int[] pnums)
show the choose player dialog box |
boolean |
clientIsCurrentPlayer()
Is the client player active in this game, and the current player? |
private void |
discardTimerClear()
|
private void |
discardTimerSet()
Gamestate just became SOCGame.WAITING_FOR_DISCARDS. |
void |
doLayout()
do the layout |
SOCBoardPanel |
getBoardPanel()
|
SOCBuildingPanel |
getBuildingPanel()
|
SOCPlayerClient |
getClient()
|
SOCHandPanel |
getClientHand()
The client player's SOCHandPanel interface, if active in a game. |
int |
getClientPlayerNumber()
If client player is active in game, their player number. |
java.util.Timer |
getEventTimer()
|
SOCGame |
getGame()
|
java.awt.Color |
getPlayerColor(int pn)
|
java.awt.Color |
getPlayerColor(int pn,
boolean isGhost)
|
SOCHandPanel |
getPlayerHandPanel(int pn)
|
protected void |
initInterfaceElements(boolean firstCall)
Setup the interface elements |
void |
leaveGame()
leave this game |
static java.awt.Color |
makeGhostColor(java.awt.Color srcColor)
Calculate a color towards gray, for a hilight or the robber ghost. |
void |
over(java.lang.String s)
an error occured, stop editing |
void |
print(java.lang.String s)
print text in the text window |
void |
removePlayer(int pn)
remove a player from the game |
void |
resetBoard(SOCGame newGame,
int rejoinPlayerNumber,
int requesterNumber)
Handle board reset (new game with same players, same game name). |
void |
resetBoardAskVote(int pnRequester)
Creates and shows a new ResetBoardVoteDialog. |
private void |
resetBoardClearDia()
Callback from ResetBoardVoteDialog, to clear our reference when button is clicked and dialog is going away. |
void |
resetBoardRejected()
Voting complete, board reset was rejected. |
void |
resetBoardRequest()
Player wants to request to reset the board (same players, new game, new layout). |
void |
resetBoardVoted(int pn,
boolean vyes)
Another player has voted on a board reset request. |
void |
setClientHand(SOCHandPanel h)
Update the client player's SOCHandPanel interface, for joining or leaving a game. |
void |
setTextDisplayRollExpected(int roll)
To reduce text clutter: server has just sent a dice result message. |
void |
showDiscardDialog(int nd)
show the discard dialog |
void |
showDiscoveryDialog()
show the Discovery dialog box |
void |
showMonopolyDialog()
show the Monopoly dialog box |
void |
startGame()
Game play is starting (leaving state SOCGame.NEW). |
protected void |
textInputSetToInitialPrompt(boolean setToInitial)
Set or clear the chat text input's initial prompt. |
void |
update(java.awt.Graphics g)
Overriden so the peer isn't painted, which clears background. |
void |
updateAtGameState()
Update interface after game state has changed. |
void |
updateAtOver(int[] finalScores)
Game is over; server has sent us the revealed scores for each player. |
void |
updateAtPlay1()
Client is current player; state changed from PLAY to PLAY1. |
void |
updateAtTurn(int pnum)
Game's current player has changed. |
void |
updateDevCardCount()
The game's count of development cards remaining has changed. |
void |
updateLongestLargest(boolean isRoadNotArmy,
SOCPlayer oldp,
SOCPlayer newp)
The game's longest road or largest army may have changed. |
| Methods inherited from class java.awt.Frame |
addNotify, finalize, 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, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, 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, getBackground, 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, 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, isOpaque, 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, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.awt.MenuContainer |
getFont, postEvent |
| Field Detail |
protected SOCBoardPanel boardPanel
protected boolean boardIsScaled
doLayout()?
SOCBoardPanel.isScaled()protected java.awt.TextField textInput
protected boolean textInputIsInitial
textInput,
TEXTINPUT_INITIAL_PROMPT_MSGprotected boolean textInputHasSent
textInput,
TEXTINPUT_INITIAL_PROMPT_MSGprotected int textInputGreyCountdown
textInput,
textInputGreyCountFromprotected static int textInputGreyCountFrom
textInputGreyCountdownpublic static final java.lang.String TEXTINPUT_INITIAL_PROMPT_MSG
textInput,
Constant Field Valuespublic static final java.lang.String TITLEBAR_GAME
public static final java.lang.String TITLEBAR_GAME_OVER
protected SOCPlayerInterface.SOCPITextfieldListener textInputListener
textInputprotected SnippingTextArea textDisplay
protected SnippingTextArea chatDisplay
protected SOCBuildingPanel buildingPanel
protected SOCHandPanel[] hands
protected SOCHandPanel clientHand
private int clientHandPlayerNum
protected java.awt.Color[] playerColors
SOCGame.MAXPLAYERS - 1.
protected java.awt.Color[] playerColorsGhost
SOCGame.MAXPLAYERS - 1.
protected SOCPlayerClient client
protected SOCGame game
protected boolean gameIsStarting
SOCGame.START2B
to SOCGame.PLAY).
Initially set in startGame().
Checked/cleared in updateAtGameState();
protected SOCHandPanel boardResetRequester
SOCServer.resetBoardAndNotify(String, int)protected SOCPlayerInterface.ResetBoardVoteDialog boardResetVoteDia
private boolean showingPlayerDiscards
private java.lang.Object showingPlayerDiscards_lock
showingPlayerDiscards
and showingPlayerDiscardsTask
private SOCPlayerInterface.SOCPIDiscardMsgTask showingPlayerDiscardsTask
protected int ncols
protected int npix
protected int textDisplayRollExpected
Set to 0 at most times.
Set to the roll result when roll text is expected.
Will be cleared to 0 in print(String).
Whenever this field is nonzero, textmessages from the server
will be scanned for " rolled a ".
protected java.util.Timer eventTimer
getEventTimer() for some users.
protected SOCDiscardDialog discardDialog
protected SOCChoosePlayerDialog choosePlayerDialog
protected SOCDiscoveryDialog discoveryDialog
protected SOCMonopolyDialog monopolyDialog
| Constructor Detail |
public SOCPlayerInterface(java.lang.String title,
SOCPlayerClient cl,
SOCGame ga)
title - title for this interface - game namecl - the player client that spawned usga - the game associated with this interface| Method Detail |
protected void initInterfaceElements(boolean firstCall)
firstCall - First setup call for this window; do global things
such as windowListeners, not just component-specific things.public void update(java.awt.Graphics g)
Component.repaint() instead.
public SOCPlayerClient getClient()
public SOCGame getGame()
public java.awt.Color getPlayerColor(int pn)
pn - the player number
public java.awt.Color getPlayerColor(int pn,
boolean isGhost)
pn - the player number
public SOCHandPanel getPlayerHandPanel(int pn)
pn - the player's seat number
getClientHand()public SOCBoardPanel getBoardPanel()
public java.util.Timer getEventTimer()
SOCHandPanel.autoRollSetupTimer(),
SOCBoardPanel.popupSetBuildRequest(int, int)public void updateDevCardCount()
public void updateLongestLargest(boolean isRoadNotArmy,
SOCPlayer oldp,
SOCPlayer newp)
Call this only after updating the SOCGame objects.
isRoadNotArmy - Longest-road, not largest-army, has just changedoldp - Previous player with longest/largest, or null if nonenewp - New player with longest/largest, or null if nonepublic SOCBuildingPanel getBuildingPanel()
public SOCHandPanel getClientHand()
public void setClientHand(SOCHandPanel h)
h - The SOCHandPanel for us, or null if none (leaving).public boolean clientIsCurrentPlayer()
getClientPlayerNumber()public int getClientPlayerNumber()
clientIsCurrentPlayer()public void setTextDisplayRollExpected(int roll)
Set to 0 at most times.
Set to the roll result when roll text is expected.
Will be cleared to 0 in print(String).
Whenever this field is nonzero, textmessages from the server will be scanned for " rolled a ".
roll - The expected roll result, or 0.public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenerpublic void leaveGame()
public void resetBoardRequest()
Board reset was added in version 1.1.00. Older servers won't support it. If this happens, give user a message.
public void resetBoardVoted(int pn,
boolean vyes)
public void resetBoardRejected()
public void resetBoardAskVote(int pnRequester)
If we are the requester, we update local game state but don't vote.
pnRequester - Player number of the player requesting the board resetprivate void resetBoardClearDia()
public void print(java.lang.String s)
s - the textpublic void chatPrint(java.lang.String s)
s - the textpublic void over(java.lang.String s)
s - an error messagepublic void began()
public void addPlayer(java.lang.String n,
int pn)
n - the name of the playerpn - the seat number of the playerpublic void removePlayer(int pn)
pn - the number of the playerpublic void startGame()
SOCGame.NEW).
Remove the start buttons and robot-lockout buttons.
Next move is for players to make their starting placements.
public void updateAtOver(int[] finalScores)
finalScores - Final score for each player positionpublic void updateAtTurn(int pnum)
pnum - New current player number; should match game.getCurrentPlayerNumber()
protected void textInputSetToInitialPrompt(boolean setToInitial)
throws java.lang.IllegalStateException
setToInitial - If false, clear initial-prompt status, and
clear contents (if they are the initial-prompt message);
If true, set initial-prompt status, and set the prompt
(if contents are blank when trimmed).
java.lang.IllegalStateException - if setInitial true, but player
already sent chat text (textInputHasSent).TEXTINPUT_INITIAL_PROMPT_MSGpublic void showDiscardDialog(int nd)
nd - the number of discards
public void choosePlayer(int count,
int[] pnums)
count - the number of players to choose frompnums - the player ids of those playerspublic void showDiscoveryDialog()
public void showMonopolyDialog()
public void updateAtPlay1()
public void updateAtGameState()
SOCGame.setGameState(int).
If the game is now starting, please call in this order:
playerInterface.startGame();
game.setGameState(newState);
playerInterface.updateAtGameState();
private void discardTimerSet()
SOCGame.WAITING_FOR_DISCARDS.
Set up a timer to wait 1 second before showing "Discarding..."
balloons in players' handpanels.
private void discardTimerClear()
public void resetBoard(SOCGame newGame,
int rejoinPlayerNumber,
int requesterNumber)
newGame - New game objectrejoinPlayerNumber - Sanity check - must be our correct player number in this gamerequesterNumber - Player who requested the board resetSOCServer.resetBoardAndNotify(String, int)
public void changeFace(int pn,
int id)
pn - the number of the playerid - the id of the face imagepublic void chatPrintDebug(java.lang.String debugMsg)
public void chatPrintStackTrace(java.lang.Throwable th)
private void chatPrintStackTrace(java.lang.Throwable th,
boolean isNested)
public static java.awt.Color makeGhostColor(java.awt.Color srcColor)
srcColor - The color to ghost from
public void doLayout()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||