|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Frame soc.client.SOCPlayerInterface
public class SOCPlayerInterface
Window with interface for a player in one game of Settlers of Catan.
Contains board
, client's and other players' hands
,
chat interface, game message window, and the building/buying panel
.
Players' hands
start with player 0 at top-left, and go clockwise;
see doLayout()
for details.
When we join a game, the client will update visible game state by calling methods here like
addPlayer(String, int)
; when all this activity is complete, and the interface is
ready for interaction, the client calls began(Vector)
.
A separate SOCPlayerClient
window holds the list of current games and channels.
Nested Class Summary | |
---|---|
private class |
SOCPlayerInterface.ChooseMoveRobberOrPirateDialog
Modal dialog to ask whether to move the robber or the pirate ship. |
private class |
SOCPlayerInterface.ChooseRobClothOrResourceDialog
Modal dialog to ask whether to rob cloth or a resource from the victim. |
private static class |
SOCPlayerInterface.ClientBridge
Client Bridge to translate interface to SOCPlayerInterface methods. |
private static class |
SOCPlayerInterface.PIWindowAdapter
React to window closing or losing focus (deactivation). |
protected static class |
SOCPlayerInterface.ResetBoardConfirmDialog
This is the modal dialog to confirm resetting the board after a practice game. |
protected static class |
SOCPlayerInterface.ResetBoardVoteDialog
This is the modal dialog to vote on another player's board reset request. |
private static class |
SOCPlayerInterface.SOCPIDiscardOrPickMsgTask
When timer fires, show discard message or picking-resource message for any other player (not client player) who must discard or pick. |
private class |
SOCPlayerInterface.SOCPITextDisplaysLargerTask
For 6-player board, make the text displays larger/smaller when mouse enters/exits them. |
private static class |
SOCPlayerInterface.SOCPITextfieldListener
Used for chat textfield setting/clearing initial prompt text (TEXTINPUT_INITIAL_PROMPT_MSG). |
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 | |
---|---|
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. |
private boolean |
chatDisplayHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp . |
protected SOCChoosePlayerDialog |
choosePlayerDialog
the dialog for choosing a player from which to steal |
protected SOCPlayerClient |
client
|
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. |
private SOCPlayerInterface.ClientBridge |
clientListener
|
private boolean |
didGameScenarioPopupCheck
True if we've already shown game 's scenario's
descriptive text in a popup window when the client joined,
or if the game has no scenario. |
protected SOCDiscardOrGainResDialog |
discardOrGainDialog
The dialog for getting what resources the player wants to discard or gain. |
protected SOCGame |
game
the game associated with this interface |
protected SOCPlayerClient.GameAwtDisplay |
gameDisplay
the display that spawned us |
protected boolean |
gameIsStarting
Flag to ensure interface is updated, when the first actual turn begins (state changes from SOCGame.START2B or SOCGame.START3B
to SOCGame.PLAY ). |
private SOCGameStatistics |
gameStats
|
protected SOCHandPanel[] |
hands
the display for the players' hands. |
private boolean |
is6player
Is this game using the 6-player board? Checks SOCGame.maxPlayers . |
private boolean |
knowsGameState
If true, updateAtGameState() has been called at least once,
or the constructor was called with a non-zero SOCGame.getGameState() . |
private boolean |
layoutNotReadyYet
For perf/display-bugs during component layout (OSX firefox), show only background color in update(Graphics) when true. |
protected SOCMonopolyDialog |
monopolyDialog
the dialog for choosing a resource to monopolize |
protected int |
ncols
number of columns in the text output area |
private boolean |
needRepaintBorders
Have we resized the board, and thus need to repaint the borders between panels? Determined in doLayout() . |
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 java.awt.Dimension |
prevSize
Size of our window from Component.getSize() , not excluding insets. |
private boolean |
sbFixBHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp
and sbFixNeeded . |
private boolean |
sbFixLHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp
and sbFixNeeded . |
private boolean |
sbFixNeeded
In 6-player games, text areas temporarily zoom when the mouse is over them. |
private boolean |
sbFixRHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp
and sbFixNeeded . |
private boolean |
showingPlayerDiscardOrPick
Is one or more SOCHandPanel (of other players) showing a
"Discarding..." or "Picking resource..." message? |
private java.lang.Object |
showingPlayerDiscardOrPick_lock
Synchronize access to showingPlayerDiscardOrPick
and showingPlayerDiscardOrPick_task |
private SOCPlayerInterface.SOCPIDiscardOrPickMsgTask |
showingPlayerDiscardOrPick_task
May be null if not showingPlayerDiscardOrPick . |
private static boolean |
SOCPI_isPlatformWindows
Are we running on the Windows platform, according to SOCPI_osName ? |
private static java.lang.String |
SOCPI_osName
System property os.name; For use by SOCPI_isPlatformWindows . |
private static SOCStringManager |
strings
i18n text strings |
protected SnippingTextArea |
textDisplay
where text is displayed. |
private boolean |
textDisplayHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp . |
private boolean |
textDisplaysLargerTemp
In the 6-player layout, the text display fields
(textDisplay , chatDisplay ) aren't as large. |
private boolean |
textDisplaysLargerTemp_needsLayout
When set, must return text display field sizes to normal in doLayout()
after a previous textDisplaysLargerTemp flag set. |
private long |
textDisplaysLargerWhen
If any text area is clicked in a 6-player game, give focus to the text input box; for use with mouseClicked(MouseEvent) . |
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 |
private boolean |
textInputHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp . |
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. |
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 | |
---|---|
SOCPlayerInterface(java.lang.String title,
SOCPlayerClient.GameAwtDisplay gd,
SOCGame ga)
Create and show 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(java.util.Vector<java.lang.String> members)
start the game interface: 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)
|
(package private) void |
clearTradeMsg(int pn)
If the player's trade-offer panel is showing a message (not a trade offer), clear and hide it. |
boolean |
clientIsCurrentPlayer()
Is the client player active in this game, and the current player? Assertion: If this returns true, getClientHand() will return non-null. |
private void |
discardOrPickTimerClear()
Cancel any "discarding..." or "picking resources..." timer, and clear the message if showing. |
private void |
discardOrPickTimerSet(boolean isDiscard)
Gamestate just became SOCGame.WAITING_FOR_DISCARDS
or SOCGame.WAITING_FOR_PICK_GOLD_RESOURCE . |
void |
doLayout()
Arrange the custom layout. |
private boolean |
doLocalCommand(java.lang.String cmd)
Handle local client commands for games. |
void |
gameEvent(SOCGame ga,
SOCScenarioGameEvent evt,
java.lang.Object detail)
Listener callback for scenario events on the large sea board which affect the game or board, not a specific player. |
SOCBoardPanel |
getBoardPanel()
|
SOCBuildingPanel |
getBuildingPanel()
|
SOCPlayerClient |
getClient()
|
SOCHandPanel |
getClientHand()
The client player's SOCHandPanel interface, if active in a game. |
PlayerClientListener |
getClientListener()
Provide access to the client listener in case this class does not directly implement it. |
int |
getClientPlayerNumber()
If client player is active in game, their player number. |
java.util.Timer |
getEventTimer()
|
SOCGame |
getGame()
|
SOCPlayerClient.GameAwtDisplay |
getGameDisplay()
|
SOCGameStatistics |
getGameStats()
|
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 |
protected boolean |
isClientPlayer(SOCPlayer p)
|
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 |
mouseClicked(java.awt.event.MouseEvent e)
If any text area is clicked in a 6-player game, give focus to the text input box for ease-of-use. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Track TextField mouse cursor entry on 6-player board (MouseListener). |
void |
mouseExited(java.awt.event.MouseEvent e)
Track TextField mouse cursor exit on 6-player board (MouseListener). |
void |
mousePressed(java.awt.event.MouseEvent e)
Stub for MouseListener. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Stub for MouseListener. |
void |
over(java.lang.String s)
an error occurred, stop playing |
void |
paint(java.awt.Graphics g)
Paint each component, after (if needRepaintBorders ) clearing stray pixels
from the borders between the components. |
private void |
paintBorders(java.awt.Graphics g)
Paint the borders after a resize, and set needRepaintBorders false. |
private void |
paintBordersHandColumn(java.awt.Graphics g,
SOCHandPanel middlePanel)
Paint the borders of one column of handpanels. |
void |
playerEvent(SOCGame ga,
SOCPlayer pl,
SOCScenarioPlayerEvent evt,
boolean flagsChanged,
java.lang.Object obj)
Listener callback for per-player scenario events on the large sea board. |
void |
print(java.lang.String s)
print text in the text window, followed by a new line ('\n'). |
void |
printKeyed(java.lang.String key)
Get and print a localized string (having no parameters) in the text window, followed by a new line ('\n'). |
void |
printKeyed(java.lang.String key,
java.lang.Object... params)
Get and print a localized string (with parameters) in the text window, followed by a new line ('\n'). |
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(boolean confirmDialogFirst)
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. |
(package private) void |
setDebugFreePlacementMode(boolean setOn)
Switch the game's Debug Paint Piece Mode
on or off, as directed by the server. |
(package private) void |
setDebugFreePlacementPlayer(int pn)
Set the board's 'client player' for the Debug Paint Piece Mode. |
void |
showChoosePlayerDialog(int count,
int[] pnums,
boolean allowChooseNone)
show the SOCChoosePlayerDialog to choose a player for robbery. |
void |
showChooseRobClothOrResourceDialog(int vpn)
Show the SOCPlayerInterface.ChooseRobClothOrResourceDialog to choose what to rob from a player. |
void |
showDiceResult(SOCPlayer cp,
int roll)
Server has just sent a dice result message. |
void |
showDiscardOrGainDialog(int nd,
boolean isDiscard)
Show the discard dialog or the gain-resources dialog. |
void |
showMonopolyDialog()
show the Monopoly dialog box |
void |
showScenarioInfoDialog()
If this game has a scenario (game option "SC" ), show the scenario
description, special rules, and number of victory points to win. |
void |
startGame()
Game play is starting (leaving state SOCGame.NEW ). |
private void |
textDisplaysLargerSetResizeTimer()
For 6-player board, make the text displays larger/smaller when mouse enters/exits them. |
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 |
updateAtClientPlayerResources()
The client player's available resources have changed. |
void |
updateAtGameState()
Update interface after game state has changed. |
void |
updateAtNewBoard()
Update interface after the server sends us a new board layout. |
void |
updateAtOver(int[] finalScores)
Game is over; server has sent us the revealed scores for each player. |
void |
updateAtPieceRemoved(SOCPlayer player,
int pieceCoordinate,
int pieceType)
A player's piece has been removed from the board. |
void |
updateAtPiecesChanged()
Handle updates after pieces have changed on the board. |
void |
updateAtPutPiece(int mesPn,
int coord,
int pieceType,
boolean isMove,
int moveToCoord)
Handle updates after putting a piece on the board, or moving a ship that was already placed. |
void |
updateAtRollPrompt()
A player is being asked to roll (or play a card) at the start of their turn. |
void |
updateAtSVPText(java.lang.String plName,
int svp,
java.lang.String desc)
A player has been awarded Special Victory Points (SVP), so announce those details. |
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. |
private void |
updatePlayerLimitDisplay(boolean show,
boolean isGameStart,
int playerLeaving)
Show the maximum and available number of player positions, if game parameter "PL" is less than SOCGame.maxPlayers . |
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, dispose, 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, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, 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, 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, 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 |
---|
private static final SOCStringManager strings
private static final java.lang.String SOCPI_osName
SOCPI_isPlatformWindows
.
private static final boolean SOCPI_isPlatformWindows
SOCPI_osName
?
protected SOCBoardPanel boardPanel
protected boolean boardIsScaled
doLayout()
?
SOCBoardPanel.isScaled()
private boolean is6player
SOCGame.maxPlayers
.
private boolean layoutNotReadyYet
update(Graphics)
when true.
private boolean didGameScenarioPopupCheck
game
's scenario's
descriptive text in a popup window when the client joined,
or if the game has no scenario.
Checked in doLayout()
.
Shown just once, not shown again at resetBoard(SOCGame, int, int)
.
protected java.awt.TextField textInput
protected boolean textInputIsInitial
textInput
,
TEXTINPUT_INITIAL_PROMPT_MSG
protected boolean textInputHasSent
textInput
,
TEXTINPUT_INITIAL_PROMPT_MSG
protected int textInputGreyCountdown
textInput
,
textInputGreyCountFrom
protected static int textInputGreyCountFrom
textInputGreyCountdown
public static final java.lang.String TEXTINPUT_INITIAL_PROMPT_MSG
textInput
protected SOCPlayerInterface.SOCPITextfieldListener textInputListener
textInput
protected SnippingTextArea textDisplay
textDisplaysLargerTemp
protected SnippingTextArea chatDisplay
textDisplaysLargerTemp
private long textDisplaysLargerWhen
mouseClicked(MouseEvent)
.
This is for ease-of-use because these boxes move/expand in
the 6-player board just as the mouse is near them, so it's
more difficult to click on the text input box.
If the user actually wants to click in the text box instead, they can click there again 1 second after the text displays are made larger.
When the text fields are un-expanded because the mouse moves away from them, that timer is reset to 0, and the next click will again give focus to the input text box.
private boolean textDisplaysLargerTemp
6-player
layout, the text display fields
(textDisplay
, chatDisplay
) aren't as large.
When this flag is set, they've temporarily been made larger.
SOCPlayerInterface.SOCPITextDisplaysLargerTask
,
textDisplaysLargerWhen
private boolean textDisplaysLargerTemp_needsLayout
doLayout()
after a previous textDisplaysLargerTemp
flag set.
private boolean textInputHasMouse
textDisplaysLargerTemp
.
Set/cleared in mouseEntered(MouseEvent)
, mouseExited(MouseEvent)
.
SOCPlayerInterface.SOCPITextDisplaysLargerTask
private boolean textDisplayHasMouse
textDisplaysLargerTemp
.
Set/cleared in mouseEntered(MouseEvent)
, mouseExited(MouseEvent)
.
SOCPlayerInterface.SOCPITextDisplaysLargerTask
private boolean chatDisplayHasMouse
textDisplaysLargerTemp
.
Set/cleared in mouseEntered(MouseEvent)
, mouseExited(MouseEvent)
.
SOCPlayerInterface.SOCPITextDisplaysLargerTask
private boolean sbFixNeeded
textDisplaysLargerTemp
,
sbFixBHasMouse
private boolean sbFixLHasMouse
textDisplaysLargerTemp
and sbFixNeeded
. Used only on platforms (windows) where the scrollbar isn't
considered part of the textarea and triggers a mouseExited.
Set/cleared in mouseEntered(MouseEvent)
, mouseExited(MouseEvent)
.
SOCPlayerInterface.SOCPITextDisplaysLargerTask
private boolean sbFixRHasMouse
textDisplaysLargerTemp
and sbFixNeeded
. Used only on platforms (windows) where the scrollbar isn't
considered part of the textarea and triggers a mouseExited.
Set/cleared in mouseEntered(MouseEvent)
, mouseExited(MouseEvent)
.
SOCPlayerInterface.SOCPITextDisplaysLargerTask
private boolean sbFixBHasMouse
textDisplaysLargerTemp
and sbFixNeeded
. Used only on platforms (windows) where the scrollbar isn't
considered part of the textarea and triggers a mouseExited.
Set/cleared in mouseEntered(MouseEvent)
, mouseExited(MouseEvent)
.
SOCPlayerInterface.SOCPITextDisplaysLargerTask
protected SOCBuildingPanel buildingPanel
protected SOCHandPanel[] hands
clientHand
protected SOCHandPanel clientHand
hands[]
, if we are
active in a game. Null otherwise.
Set by SOCHandPanel
's removePlayer() and addPlayer() methods
by calling setClientHand(SOCHandPanel)
.
clientHandPlayerNum
private int clientHandPlayerNum
clientHand
, or -1.
Set by SOCHandPanel
's removePlayer() and addPlayer() methods
by calling setClientHand(SOCHandPanel)
.
protected java.awt.Color[] playerColors
SOCGame.maxPlayers
- 1.
Initialized in constructor.
getPlayerColor(int, boolean)
protected java.awt.Color[] playerColorsGhost
SOCGame.maxPlayers
- 1.
Initialized in constructor.
getPlayerColor(int, boolean)
protected SOCPlayerClient.GameAwtDisplay gameDisplay
protected SOCPlayerClient client
protected SOCGame game
private boolean knowsGameState
updateAtGameState()
has been called at least once,
or the constructor was called with a non-zero SOCGame.getGameState()
.
If false, the 'known' game state (from the constructor) is 0.
protected boolean gameIsStarting
SOCGame.START2B
or SOCGame.START3B
to SOCGame.PLAY
).
Initially set in startGame()
.
Checked/cleared in updateAtGameState()
;
protected SOCHandPanel boardResetRequester
SOCServer.resetBoardAndNotify(String, int)
protected SOCPlayerInterface.ResetBoardVoteDialog boardResetVoteDia
private boolean showingPlayerDiscardOrPick
SOCHandPanel
(of other players) showing a
"Discarding..." or "Picking resource..." message?
private java.lang.Object showingPlayerDiscardOrPick_lock
showingPlayerDiscardOrPick
and showingPlayerDiscardOrPick_task
private SOCPlayerInterface.SOCPIDiscardOrPickMsgTask showingPlayerDiscardOrPick_task
showingPlayerDiscardOrPick
.
protected int ncols
protected int npix
private java.awt.Dimension prevSize
Component.getSize()
, not excluding insets.
Determined in doLayout()
, or null.
private boolean needRepaintBorders
doLayout()
.
protected SOCDiscardOrGainResDialog discardOrGainDialog
protected SOCChoosePlayerDialog choosePlayerDialog
protected SOCMonopolyDialog monopolyDialog
private SOCGameStatistics gameStats
private final SOCPlayerInterface.ClientBridge clientListener
Constructor Detail |
---|
public SOCPlayerInterface(java.lang.String title, SOCPlayerClient.GameAwtDisplay gd, SOCGame ga)
SOCScenario
description, it will be shown now in a popup
by showScenarioInfoDialog()
.
title
- title for this interface - game namegd
- the player display that spawned usga
- the game associated with this interface; must not be null
Method Detail |
---|
public PlayerClientListener getClientListener()
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.
For performance and display-bug avoidance, checks layoutNotReadyYet
flag.
update
in class java.awt.Container
public void paint(java.awt.Graphics g)
needRepaintBorders
) clearing stray pixels
from the borders between the components.
paint
in class java.awt.Window
private void paintBorders(java.awt.Graphics g)
needRepaintBorders
false.
prevSize
should be set before calling.
g
- Graphics as passed to update()private final void paintBordersHandColumn(java.awt.Graphics g, SOCHandPanel middlePanel)
prevSize
must be set before calling.
g
- Graphics as passed to update()middlePanel
- The middle handpanel (6-player) or the bottom (4-player) in this columnpublic SOCPlayerClient getClient()
public SOCPlayerClient.GameAwtDisplay getGameDisplay()
public SOCGame getGame()
public SOCGameStatistics getGameStats()
public java.awt.Color getPlayerColor(int pn)
pn
- the player number
public java.awt.Color getPlayerColor(int pn, boolean isGhost)
pn
- the player numberisGhost
- Do we want the "ghosted" color, not the normal color?
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()
See also SOCPlayerInterface.ClientBridge.simpleAction(int, int, int, int)
with SOCSimpleAction.DEVCARD_BOUGHT
.
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 noneprivate void updatePlayerLimitDisplay(boolean show, boolean isGameStart, int playerLeaving)
SOCGame.maxPlayers
.
Also, if show, and isGameStart
, check for game-is-full,
and hide or show "sit down" buttons if necessary.
If the game has already started, and the client is playing in this game,
will not show this display (it overlays the board, which is in use).
It will still hide/show sit-here buttons if needed.
show
- show the text, or clear the display (at game start)?isGameStart
- True if calling from startGame()
; will be set true if gameState is SOCGame.NEW
playerLeaving
- The player number if a player is leaving the game, otherwise -1.void clearTradeMsg(int pn)
pn
- Player number, or -1 for all playersSOCHandPanel.clearTradeMsg()
void setDebugFreePlacementMode(boolean setOn)
Debug Paint Piece Mode
on or off, as directed by the server.
setOn
- Should the mode be turned on?setDebugFreePlacementPlayer(int)
void setDebugFreePlacementPlayer(int pn)
setDebugPaintPieceMode(false)
is called.
pn
- Player numberpublic SOCBuildingPanel getBuildingPanel()
public SOCHandPanel getClientHand()
clientIsCurrentPlayer()
,
isClientPlayer(SOCPlayer)
public void setClientHand(SOCHandPanel h)
h
- The SOCHandPanel for us, or null if none (leaving).public boolean clientIsCurrentPlayer()
getClientHand()
will return non-null.
getClientPlayerNumber()
,
isClientPlayer(SOCPlayer)
public int getClientPlayerNumber()
clientIsCurrentPlayer()
,
getClientHand()
public void showDiceResult(SOCPlayer cp, int roll)
cp
- Current player who rolledroll
- The roll result, or 0public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
private boolean doLocalCommand(java.lang.String cmd)
Before 2.0.00, this was SOCPlayerClient.doLocalCommand(SOCGame, String).
cmd
- Local client command string, which starts with \
SOCPlayerClient.GameAwtDisplay.doLocalCommand(String, String)
public void leaveGame()
public void resetBoardRequest(boolean confirmDialogFirst)
Board reset was added in version 1.1.00. Older servers won't support it. If this happens, give user a message.
Before resetting a practice game, have the user confirm the reset with a dialog box. This is to prevent surprises if they click the "Restart" button at the end of a practice game, which is the same button as the "Done" button at the end of a turn.
confirmDialogFirst
- If true, a practice game is over and the user should confirm the reset
with a dialog box created and shown here. If the game is just starting, no need to confirm.
If true, assumes resetBoardRequest is being called from the AWT event thread.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 printKeyed(java.lang.String key) throws java.util.MissingResourceException
print
("* " + strings.get
(key
)).
key
- Key to use for string retrieval
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeExceptionpublic void printKeyed(java.lang.String key, java.lang.Object... params) throws java.util.MissingResourceException
print
("* " + strings.get
(key, params
)).
key
- Key to use for string retrievalparams
- Objects to use with {0}, {1}, etc in the localized string by
calling SOCStringManager.get(key, params...)
; the localized string should not
contain the leading "* " or the ending \n, those are added here.
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeExceptionpublic void print(java.lang.String s)
s
- the text; you don't need to include "\n".chatPrint(String)
,
printKeyed(String)
,
printKeyed(String, Object...)
public void chatPrint(java.lang.String s)
s
- the textprint(String)
public void over(java.lang.String s)
s
- an error messagepublic void began(java.util.Vector<java.lang.String> members)
If this game has observers, list them in the textDisplay now.
members
- Game member names from SOCGameMembers.getMembers()
(added in 1.1.12)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)
SOCGame.removePlayer(String)
.
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.
Call SOCGame.setGameState(int)
before calling this method.
Call this method before calling updateAtGameState()
.
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()public void updateAtRollPrompt()
If the client is the current player, calls SOCHandPanel.autoRollOrPromptPlayer()
.
public void updateAtClientPlayerResources()
If any trade offers are currently showing, show or hide the offer Accept button depending on the updated set of available resources.
public void updateAtSVPText(java.lang.String plName, int svp, java.lang.String desc)
SOCPlayer.addSpecialVPInfo(int, String)
.
plName
- Player namesvp
- Number of SVP awardeddesc
- Description of player's action that led to SVP; example: "settling a new island"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_MSG
public void showDiscardOrGainDialog(int nd, boolean isDiscard)
nd
- the number of resources to discard or gainisDiscard
- True for discard (after 7), false for gain (after gold hex)public void showChoosePlayerDialog(int count, int[] pnums, boolean allowChooseNone)
SOCChoosePlayerDialog
to choose a player for robbery.
Before v2.0.00, this was choosePlayer.
count
- the number of players to choose frompnums
- the player ids of those players; length of this
array may be larger than count (may be SOCGame.maxPlayers
).
Only the first count elements will be used.
If allowChooseNone, pnums.length must be at least count + 1
to leave room for "no player".allowChooseNone
- if true, player can choose to rob no one (game scenario SC_PIRI)SOCPlayerClient.GameManager.choosePlayer(SOCGame, int)
,
showChooseRobClothOrResourceDialog(int)
public void showChooseRobClothOrResourceDialog(int vpn)
SOCPlayerInterface.ChooseRobClothOrResourceDialog
to choose what to rob from a player.
vpn
- Victim player numbershowChoosePlayerDialog(int, int[], boolean)
public void showMonopolyDialog()
public void showScenarioInfoDialog()
"SC"
), show the scenario
description, special rules, and number of victory points to win.
Shown automatically when the SOCPlayerInterface is first shown.
public void updateAtNewBoard()
SOCBoardPanel.flushBoardLayoutAndRepaint()
.
Updates display of board-related counters, such as SOCBoardLarge.getCloth()
.
Not needed if calling resetBoard(SOCGame, int, int)
.
public void updateAtGameState()
discardOrPickTimerSet(boolean)
.
Please call SOCGame.setGameState(int)
first.
If the game is now starting, please call in this order:
game.setGameState(newState);
playerInterface.
startGame()
;
playerInterface.updateAtGameState();
public void updateAtPiecesChanged()
SOCGameOption.K_SC_PIRI
converts players' ships to warships, changes the strength
of a pirate fortress, etc.
Call after updating game state. This is different than
updateAtPutPiece(int, int, int, boolean, int)
which
updates both the SOCGame
and the board.
Currently, hand panels aren't updated (piece counts or VP total), only SOCBoardPanel
.
public void updateAtPutPiece(int mesPn, int coord, int pieceType, boolean isMove, int moveToCoord)
SOCGame
and visually on our SOCBoardPanel
.
mesPn
- The piece's player numbercoord
- The piece's coordinate. If isMove, the coordinate to move from.pieceType
- Piece type, like SOCPlayingPiece.CITY
isMove
- If true, it's a move, not a new placement; valid only for ships.moveToCoord
- If isMove, the coordinate to move to. Otherwise ignored.updateAtPiecesChanged()
public void updateAtPieceRemoved(SOCPlayer player, int pieceCoordinate, int pieceType)
updateAtPiecesChanged()
.
Currently, only ships can be removed, in game scenario _SC_PIRI
.
Other pieceType
s are ignored.
player
- Player who owns the shippieceCoordinate
- Ship's node coordinatepieceType
- The piece type identifier SOCPlayingPiece.SHIP
public void gameEvent(SOCGame ga, SOCScenarioGameEvent evt, java.lang.Object detail)
Threads: The game's treater thread handles incoming client messages and calls
game methods that change state. Those same game methods will trigger the scenario events;
so, the treater thread will also run this gameEvent callback.
GUI code should use EventQueue.invokeLater(Runnable)
.
gameEvent
in interface SOCScenarioEventListener
ga
- Gameevt
- Event codedetail
- Game piece, coordinate, or other data about the event, or null, depending on evtplayerEvent(SOCGame, SOCPlayer, SOCScenarioPlayerEvent, boolean, Object)
public void playerEvent(SOCGame ga, SOCPlayer pl, SOCScenarioPlayerEvent evt, boolean flagsChanged, java.lang.Object obj)
playerEvent
in interface SOCScenarioEventListener
ga
- Gamepl
- Playerevt
- Event codeflagsChanged
- True if this event changed SOCPlayer.getScenarioPlayerEvents()
,
SOCPlayer.getSpecialVP()
, or another flag documented for evt in
SOCScenarioPlayerEvent
obj
- Object related to the event, or null; documented for evt in SOCScenarioPlayerEvent
.
Example: The SOCVillage
for SOCScenarioPlayerEvent.CLOTH_TRADE_ESTABLISHED_VILLAGE
.gameEvent(SOCGame, SOCScenarioGameEvent, Object)
private void discardOrPickTimerSet(boolean isDiscard)
SOCGame.WAITING_FOR_DISCARDS
or SOCGame.WAITING_FOR_PICK_GOLD_RESOURCE
.
Set up a timer to wait 1 second before showing "Discarding..."
or "Picking Resources..." balloons in players' handpanels.
Uses SOCPlayerInterface.SOCPIDiscardOrPickMsgTask
.
isDiscard
- True for discard, false for picking gold-hex resourcesprivate void discardOrPickTimerClear()
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()
Container.invalidate()
and call this again, because SOCHandPanel
sizes will change.
Also, on first call, resets mouse cursor to normal, in case it was WAIT_CURSOR.
On first call, if the game options have a SOCScenario
with any long description,
it will be shown in a popup via showScenarioInfoDialog()
.
doLayout
in class java.awt.Container
private void textDisplaysLargerSetResizeTimer()
mouseExited(MouseEvent)
/mouseEntered(MouseEvent)
events
(such as moving mouse from textDisplay
to chatDisplay
).
public void mouseEntered(java.awt.event.MouseEvent e)
is6player
.
For use by textDisplay
, chatDisplay
, textInput
.
Calls textDisplaysLargerSetResizeTimer()
.
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseEntered(MouseEvent)
.
mouseExited
in interface java.awt.event.MouseListener
public void mouseClicked(java.awt.event.MouseEvent e)
textDisplaysLargerWhen
javadoc.
mouseClicked
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
protected boolean isClientPlayer(SOCPlayer p)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |