|
||||||||||
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.Panel soc.client.SOCHandPanel
public class SOCHandPanel
This panel displays a player's information. If the player is us, then more information is displayed than in another player's hand panel.
To update most of the values shown in the handpanel,
call updateValue(PlayerClientListener.UpdateType)
after receiving
a SOCPlayerElement
message or after something
else changes the game state.
Custom layout: see doLayout()
.
To set this panel's position or size, please use setBounds(int, int, int, int)
,
because it is overridden to also update getBlankStandIn()
.
Nested Class Summary | |
---|---|
protected class |
SOCHandPanel.HandPanelAutoRollTask
Used for countdown before auto-roll of the current player. |
protected static class |
SOCHandPanel.ResourceTradeMenuItem
Menu item for right-click on resource square to trade with bank/port. |
(package private) static class |
SOCHandPanel.ResourceTradePopupMenu
Menu for right-click on resource square to trade with bank/port. |
(package private) static class |
SOCHandPanel.ResourceTradeTypeMenu
Menu for right-click on resource square to trade one resource type with bank/port. |
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
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 static java.lang.String |
AUTOROLL_COUNTDOWN
|
static int |
AUTOROLL_TIME
Auto-roll timer countdown, 5 seconds unless changed at program start. |
protected java.util.TimerTask |
autoRollTimerTask
|
protected static java.lang.String |
BANK
|
private static java.lang.String |
BANK_UNDO
|
protected java.awt.Button |
bankBut
Trade resources with the bank or port |
private SOCResourceSet |
bankGet
Bank or port trade's give/get resource info; used for Undo. |
private SOCResourceSet |
bankGive
Bank or port trade's give/get resource info; used for Undo. |
protected java.awt.Button |
bankUndoBut
Undo previous trade with the bank or port |
private ColorSquare |
blankStandIn
Blank area which is normally hidden, except during addPlayer when handpanel is hidden. |
private boolean |
canCancelInvItemPlay
Flag for playCardBut in state SOCGame.PLACING_INV_ITEM . |
private static java.lang.String |
CANCEL
"Cancel" button label text, used temporarily in some game states |
private static java.lang.String |
CARD
" Play Card " button label text for playCardBut |
protected javax.swing.JLabel |
cityLab
|
protected ColorSquare |
citySq
|
protected java.awt.Label |
clayLab
|
protected ColorSquare |
claySq
|
protected static java.lang.String |
CLEAR
|
protected java.awt.Button |
clearOfferBut
Clear the current trade offer at client and server |
protected SOCPlayerClient |
client
|
protected javax.swing.JLabel |
clothLab
|
protected ColorSquare |
clothSq
Cloth count, for scenario _SC_CLVI ; null otherwise. |
protected static java.awt.Color |
COLOR_FOREGROUND
Panel text color, and player name color when not current player |
private java.awt.Label |
createColorSqRetLbl
Color square label created by most recent call to createAndAddResourceColorSquare(Color, String) . |
private ColorSquare |
createColorSqRetSq
Color square created by most recent call to createAndAddResourceColorSquare(Color, String) . |
private static java.lang.String |
DEVCARD_NEW
Dev card list prefix "*NEW* " - includes trailing space |
protected java.awt.Label |
developmentLab
|
protected ColorSquare |
developmentSq
Development card count |
private static boolean |
didSwingTooltipDefaults
If true, our constructor has set the Swing tooltip default font/foreground/background. |
protected static java.lang.String |
DONE
|
protected static java.lang.String |
DONE_RESTART
Text of Done button at end of game becomes Restart button. |
protected java.awt.Button |
doneBut
"Done" with turn during play; also "Restart" for board reset at end of game |
protected boolean |
doneButIsRestart
True when doneBut 's label is Restart (DONE_RESTART ) |
protected SOCFaceButton |
faceImg
Face icon; can right-click/triple-click for face chooser popup. |
protected SOCGame |
game
|
protected static java.lang.String |
GET
|
protected java.awt.Label |
getLab
|
protected static java.lang.String |
GIVE
|
protected java.awt.Label |
giveLab
|
protected boolean |
inPlay
Do we have any seated player? Set by addPlayer(String) , cleared by removePlayer() . |
protected boolean |
interactive
When this flag is true, the panel is interactive. |
protected java.awt.List |
inventory
Player's development card/inventory item names, from inventoryItems ; updated frequently by updateDevCards(boolean) |
private java.util.ArrayList<SOCInventoryItem> |
inventoryItems
Player's development cards/inventory items, in same order as inventory ; updated frequently by updateDevCards(boolean) |
protected javax.swing.JLabel |
knightsLab
Label for knightsSq . |
protected ColorSquare |
knightsSq
Soldier/Knight count |
static int |
LARGESTARMY
Items to update via updateValue(PlayerClientListener.UpdateType) ;
for items not appearing in SOCPlayerElement . |
protected javax.swing.JLabel |
larmyLab
Largest Army label, usually invisible; placed to left of lroadLab |
protected static java.lang.String |
LOCKSEAT
|
private static java.lang.String |
LOCKSEATTIP
|
static int |
LONGESTROAD
Items to update via updateValue(PlayerClientListener.UpdateType) ;
for items not appearing in SOCPlayerElement . |
protected javax.swing.JLabel |
lroadLab
Longest Road label, usually invisible; placed to right of larmyLab |
static int |
NUMDEVCARDS
Items to update via updateValue(PlayerClientListener.UpdateType) ;
for items not appearing in SOCPlayerElement . |
static int |
NUMRESOURCES
Items to update via updateValue(PlayerClientListener.UpdateType) ;
for items not appearing in SOCPlayerElement . |
protected TradeOfferPanel |
offer
Display other players' trade offers and related messages. |
protected java.awt.Button |
offerBut
"Offer" button for player trading: send offer to server |
protected AWTToolTip |
offerButTip
Hint for "Offer" button; non-null only if interactive and if playerTradingDisabled == false. |
private static java.lang.String |
OFFERBUTTIP_DIS
|
private static java.lang.String |
OFFERBUTTIP_ENA
|
private boolean |
offerCounterHidesFace
If true, the handpanel isn't tall enough, so when the offer message panel
is showing something, we must hide other controls. |
private boolean |
offerCounterHidingFace
When handpanel isn't tall enough, are we currently in the situation described at offerHidesControls or offerCounterHidesFace ? |
private boolean |
offerHidesControls
If true, the handpanel isn't tall enough, so when the offer message panel
is showing something, we must hide other controls. |
private boolean |
offerHidingControls
When handpanel isn't tall enough, are we currently in the situation described at offerHidesControls or offerCounterHidesFace ? |
private boolean |
offerIsDiscardOrPickMessage
Board-reset voting: If true, offer is holding a discard message
(TRADEMSG_DISCARD ) or a gold hex pick-resources message
(TRADEMSG_PICKING ). |
protected boolean |
offerIsMessageWasTrade
Board-reset voting: If true, offer was holding an active trade offer
before offerIsResetMessage or offerIsDiscardOrPickMessage was set. |
protected boolean |
offerIsResetMessage
Board-reset voting: If true, offer is holding a message related to a board-reset vote. |
protected java.awt.Label |
oreLab
|
protected ColorSquare |
oreSq
|
protected java.awt.Button |
playCardBut
Play Card button for inventory . |
protected SOCPlayer |
player
|
protected SOCPlayerInterface |
playerInterface
|
protected boolean |
playerIsClient
Does this panel represent our client's own hand? If true, implies interactive . |
protected boolean |
playerIsCurrent
Is this panel's player the game's current player? Used for hilight - set in updateAtTurn() |
private int |
playerNumber
Our player number. |
protected ColorSquare[] |
playerSend
Checkboxes to send to the other 3 or 5 players. |
private boolean[] |
playerSendForPrevTrade
The playerSend checkboxes selected during the
previous trade offer; if no previous offer, all are selected. |
protected int[] |
playerSendMap
Three player numbers to send trade offers to. |
protected boolean |
playerTradingDisabled
Game option NT: If true, only bank trading is allowed, trading between players is disabled. |
protected java.awt.Label |
pname
|
protected java.awt.Color |
pnameActiveBG
Player name background color when current player (foreground does not change) |
protected static java.lang.String |
QUIT
|
protected java.awt.Button |
quitBut
|
protected java.awt.Label |
resourceLab
|
private static java.lang.String |
RESOURCES
|
private static java.lang.String |
RESOURCES_TOTAL
|
protected ColorSquare |
resourceSq
Resource card count |
protected ColorSquare |
resourceSqDivLine
|
protected int[] |
resourceTradeCost
For right-click resource to trade - If playerIsClient, track cost of bank/port trade per resource. |
protected SOCHandPanel.ResourceTradeTypeMenu[] |
resourceTradeMenu
For right-click resource to trade - If playerIsClient, popup menus to bank/port trade resources. |
protected javax.swing.JLabel |
roadLab
|
protected ColorSquare |
roadSq
|
protected static java.lang.String |
ROBOT
|
protected java.awt.Button |
robotBut
|
private static java.lang.String |
ROBOTLOCKBUT_L
|
private static java.lang.String |
ROBOTLOCKBUT_M
|
private static java.lang.String |
ROBOTLOCKBUT_U
|
protected AWTToolTip |
robotLockButTip
Hint for "Lock/Unlock" button ( sittingRobotLockBut ;
non-null only if a robot is sitting there. |
private static java.lang.String |
ROBOTLOCKBUTTIP_L
|
private static java.lang.String |
ROBOTLOCKBUTTIP_L_OLD
|
private static java.lang.String |
ROBOTLOCKBUTTIP_M
|
private static java.lang.String |
ROBOTLOCKBUTTIP_U
|
private static java.lang.String |
ROBOTLOCKBUTTIP_U_OLD
|
protected static java.lang.String |
ROLL
|
protected static java.lang.String |
ROLL_OR_PLAY_CARD
|
protected java.awt.Button |
rollBut
|
protected java.awt.Label |
rollPromptCountdownLab
displays auto-roll countdown, or prompts to roll/play card. |
protected boolean |
rollPromptInUse
|
private static java.lang.String |
SEAT_LOCKED
|
protected static java.lang.String |
SEND
|
protected javax.swing.JLabel |
settlementLab
|
protected ColorSquare |
settlementSq
|
protected java.awt.Label |
sheepLab
|
protected ColorSquare |
sheepSq
|
protected javax.swing.JLabel |
shipLab
|
protected ColorSquare |
shipSq
shipSq = the number of ships remaining, or null if not SOCGame.hasSeaBoard . |
protected static java.lang.String |
SIT
|
protected java.awt.Button |
sitBut
When player has joined but not sat, the "Sit Here" button. |
protected boolean |
sitButIsLock
When true, the game is still forming, player has chosen a seat; "Sit Here" button is labeled as "Lock" or "Unlock". |
private AWTToolTip |
sitButTip
Hint for "Lock/Unlock" button before game starts ( sitBut ;
non-null only if sitButIsLock . |
protected static java.lang.String |
SITLOCKED
Before game starts, use pname to show if a seat is no-robots-allowed. |
protected java.awt.Button |
sittingRobotLockBut
Seat lock/unlock shown in robot handpanels during game play, to prevent/allow humans to join and take over a robot's seat. |
static int |
SPECIALVICTORYPOINTS
Items to update via updateValue(PlayerClientListener.UpdateType) ;
for items not appearing in SOCPlayerElement . |
protected SquaresPanel |
sqPanel
Trade offer resource squares; visible only for client's own player |
protected static java.lang.String |
START
|
protected java.awt.Button |
startBut
|
private static SOCStringManager |
strings
i18n text strings. |
private java.awt.Label |
svpLab
Label for Special Victory Points. |
private ColorSquare |
svpSq
Special Victory Points, if > 0. |
protected static java.lang.String |
TAKEOVER
|
protected java.awt.Button |
takeOverBut
|
private static java.lang.String |
TRADEMSG_DISCARD
Show that a non-client player is discarding resources after 7 is rolled. |
private static java.lang.String |
TRADEMSG_PICKING
Show that a non-client player is picking resources for the gold hex. |
protected static java.lang.String |
UNLOCKSEAT
|
private static java.lang.String |
UNLOCKSEATTIP
|
static int |
VICTORYPOINTS
Items to update via updateValue(PlayerClientListener.UpdateType) ;
for items not appearing in SOCPlayerElement . |
protected java.awt.Label |
vpLab
|
protected ColorSquare |
vpSq
|
protected java.awt.Label |
wheatLab
|
protected ColorSquare |
wheatSq
|
static int |
WIDTH_MIN
Minimum desired width, in pixels |
private javax.swing.JLabel |
wonderLab
Wonder Level label, for scenario _SC_WOND ; null otherwise. |
protected java.awt.Label |
woodLab
|
protected ColorSquare |
woodSq
|
protected static int[] |
zero
Array of five zeroes, one per resource type; for sqPanel . |
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 | |
---|---|
SOCHandPanel(SOCPlayerInterface pi,
SOCPlayer pl)
make a new hand panel |
|
SOCHandPanel(SOCPlayerInterface pi,
SOCPlayer pl,
boolean in)
make a new hand panel |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
handle interaction |
void |
addPlayer(java.lang.String name)
Add a player (human or robot) at this currently-vacant seat position. |
void |
addRobotButton()
DOCUMENT ME! |
void |
addSitButton(boolean clientHasSatAlready)
Add the "Sit Here" button. |
void |
addSittingRobotLockBut()
Add the "lock" button for when a robot is currently playing in this position. |
void |
addTakeOverBut()
DOCUMENT ME! |
void |
autoRollOrPromptPlayer()
If the player (client) has no playable cards, begin auto-roll countdown, Otherwise, prompt them to roll or pick a card. |
protected void |
autoRollSetupTimer()
Player is client, is current, and has no playable cards, so begin auto-roll countdown. |
void |
changeFace(int id)
Change the face image |
void |
clearDiscardOrPickMsg()
Clear the "discarding..." or "picking resources..." message in the trade panel. |
void |
clearOffer(boolean updateSendCheckboxes)
Clear the current offer. |
void |
clearTradeMsg()
If the trade-offer panel is showing a message (not a trade offer), clear and hide it. |
void |
clickPlayCardButton()
Handle a click on the "play card" button, or double-click on an item in the inventory/list of cards held. |
private void |
clickPlayInventorySpecialItem(SOCInventoryItem item)
Handle a click on a special inventory item (not a SOCDevCard ). |
private void |
clickRobotSeatLockButton(SOCGame.SeatLockState current)
During game play, handle a click on a sitting robot's Lock/Unlock/Mark button, ask the server to advance to the next seat lock state. |
void |
clickRollButton()
Handle a click on the roll button. |
private void |
createAndAddResourceColorSquare(java.awt.Color rc,
java.lang.String rtxtkey)
Create a ColorSquare and its Label, with the given text key, and add them to the layout. |
private void |
createSendBankTradeRequest(SOCGame game,
int[] give,
int[] get)
Create and send a bank/port trade request. |
protected void |
creation(SOCPlayerInterface pi,
SOCPlayer pl,
boolean in)
Stuff to do when a SOCHandPanel is created. |
void |
destroy()
Remove elements to clean up this panel. |
void |
disableBankUndoButton()
Disable the bank/port trade undo button. |
void |
doLayout()
Custom layout for player hand panel. |
ColorSquare |
getBlankStandIn()
For SOCPlayerInterface 's use, to set its size and position |
SOCPlayerClient |
getClient()
|
SOCGame |
getGame()
|
SOCPlayer |
getPlayer()
|
SOCPlayerInterface |
getPlayerInterface()
|
private void |
hideTradeMsgShowOthers(boolean hideTradeMsg)
If handpanel isn't tall enough, when the offer
message panel is showing, we must hide other controls. |
boolean |
isClientAndCurrentlyCanRoll()
Is this panel showing the client's player, and is that player the game's current player, and are they able to roll the dice right now? |
boolean |
isClientAndCurrentPlayer()
Is this panel showing the client's player, and is that player the game's current player? |
boolean |
isClientPlayer()
Is this panel showing the client's player? |
void |
mouseClicked(java.awt.event.MouseEvent e)
Handle clicks on svpSq or svpLab to get more info. |
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 |
void |
offerCounterOfferVisibleChanged(boolean counterVisible)
Callback from TradeOfferPanel . |
protected void |
pnameCalcColors()
During this player's first turn, calculate the player name label's background color for current player. |
void |
rejectOfferAtClient()
Client is rejecting the current offer from another player. |
void |
rejectOfferShowNonClient()
Show that this player (who isn't the client) has rejected another player's offer. |
void |
removePlayer()
remove this player. |
void |
removeRobotBut()
DOCUMENT ME! |
void |
removeSitBut()
Remove the sit-here / lockout-robot button. |
void |
removeSitLockoutBut()
Remove the sit-here/lockout-robot button, only if its label is currently "lockout". |
void |
removeSittingRobotLockBut()
Remove the "lock" button seen when a robot is currently playing in this position. |
void |
removeStartBut()
Internal mechanism to remove start button (if visible) and add VP label. |
void |
removeTakeOverBut()
DOCUMENT ME! |
void |
renameSitButLock()
If game is still forming (state NEW), and player has just chosen a seat, can lock empty seats for a game with fewer players/robots. |
void |
resetBoardSetMessage(java.lang.String message)
Show or hide a message related to board-reset voting. |
void |
setBounds(int x,
int y,
int width,
int height)
Overriden to also update getBlankStandIn() bounds. |
(package private) void |
setCanCancelInvItemPlay(boolean canCancel)
This player is playing or placing a special SOCInventoryItem , such as a gift
trade port in scenario _SC_FTRI . |
boolean |
setDiscardOrPickMsg(boolean isDiscard)
Show the "discarding..." or "picking resources..." message in the trade panel. |
protected void |
setLArmy(boolean haveIt)
turn the "largest army" label on or off |
protected void |
setLRoad(boolean haveIt)
Turn the "longest road" label on or off. |
protected void |
setRollPrompt(java.lang.String prompt,
boolean cancelTimer)
Set or clear the roll prompt / auto-roll countdown display. |
void |
sqPanelZerosChange(boolean notAllZero)
If trade offer is set/cleared, enable/disable buttons accordingly. |
private void |
tradeSetMessage(java.lang.String message)
Show or hide a message in the trade-panel. |
(package private) void |
updateAtOurGameState()
Client is current player; state changed. |
void |
updateAtTurn()
Handpanel interface updates at start of each turn (not just our turn). |
private void |
updateButtonsAtAdd()
Enable,disable the proper buttons when the client (player) is added to a game. |
void |
updateCurrentOffer(boolean resourcesOnly)
Display or update this player's trade offer, or hide if none. |
void |
updateDevCards(boolean addedPlayable)
Update the displayed list of player's development cards and other inventory items, and enable or disable the "Play Card" button. |
void |
updatePickGoldHexResources()
This player must pick this many gold hex resources, or no longer needs to pick them. |
void |
updateResourcesVP()
Re-read player's resource info and victory points, update the display and resource trade costs and resourceTradeMenu text. |
void |
updateResourceTradeCosts(boolean doInit)
If playerIsClient, update cost of bank/port trade per resource. |
private void |
updateRollDoneBankButtons()
Client is current player; enable or disable buttons according to game state: rollBut , doneBut , bankBut . |
void |
updateSeatLockButton()
update the seat lock button so that it allows a player to lock an unlocked seat and vice versa. |
void |
updateTakeOverButton()
update the takeover button so that it only allows takover when it's not the robot's turn |
void |
updateValue(PlayerClientListener.UpdateType utype)
update the value of a player element. |
Methods inherited from class java.awt.Panel |
---|
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, 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, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int WIDTH_MIN
public static final int NUMRESOURCES
updateValue(PlayerClientListener.UpdateType)
;
for items not appearing in SOCPlayerElement
.
All these item numbers are negative, so they won't
conflict with any SOCPlayerElement element type.
NUMDEVCARDS won't appear in the client's handpanel, only in other players'.
public static final int NUMDEVCARDS
updateValue(PlayerClientListener.UpdateType)
;
for items not appearing in SOCPlayerElement
.
All these item numbers are negative, so they won't
conflict with any SOCPlayerElement element type.
NUMDEVCARDS won't appear in the client's handpanel, only in other players'.
public static final int VICTORYPOINTS
updateValue(PlayerClientListener.UpdateType)
;
for items not appearing in SOCPlayerElement
.
All these item numbers are negative, so they won't
conflict with any SOCPlayerElement element type.
NUMDEVCARDS won't appear in the client's handpanel, only in other players'.
public static final int LONGESTROAD
updateValue(PlayerClientListener.UpdateType)
;
for items not appearing in SOCPlayerElement
.
All these item numbers are negative, so they won't
conflict with any SOCPlayerElement element type.
NUMDEVCARDS won't appear in the client's handpanel, only in other players'.
public static final int LARGESTARMY
updateValue(PlayerClientListener.UpdateType)
;
for items not appearing in SOCPlayerElement
.
All these item numbers are negative, so they won't
conflict with any SOCPlayerElement element type.
NUMDEVCARDS won't appear in the client's handpanel, only in other players'.
public static final int SPECIALVICTORYPOINTS
updateValue(PlayerClientListener.UpdateType)
;
for items not appearing in SOCPlayerElement
.
All these item numbers are negative, so they won't
conflict with any SOCPlayerElement element type.
NUMDEVCARDS won't appear in the client's handpanel, only in other players'.
public static int AUTOROLL_TIME
protected static final int[] zero
sqPanel
.
private static final SOCStringManager strings
protected static final java.lang.String SITLOCKED
pname
to show if a seat is no-robots-allowed.
protected static final java.lang.String SIT
protected static final java.lang.String START
protected static final java.lang.String ROBOT
protected static final java.lang.String TAKEOVER
private static final java.lang.String SEAT_LOCKED
protected static final java.lang.String LOCKSEAT
protected static final java.lang.String UNLOCKSEAT
private static final java.lang.String LOCKSEATTIP
private static final java.lang.String UNLOCKSEATTIP
protected static final java.lang.String ROLL
protected static final java.lang.String QUIT
protected static final java.lang.String DONE
protected static final java.lang.String DONE_RESTART
doneButIsRestart
.
protected static final java.lang.String CLEAR
protected static final java.lang.String SEND
protected static final java.lang.String BANK
private static final java.lang.String BANK_UNDO
private static final java.lang.String CARD
playCardBut
private static final java.lang.String CANCEL
protected static final java.lang.String GIVE
protected static final java.lang.String GET
private static final java.lang.String DEVCARD_NEW
private static final java.lang.String RESOURCES
private static final java.lang.String RESOURCES_TOTAL
protected static final java.lang.String AUTOROLL_COUNTDOWN
protected static final java.lang.String ROLL_OR_PLAY_CARD
private static final java.lang.String OFFERBUTTIP_ENA
private static final java.lang.String OFFERBUTTIP_DIS
private static final java.lang.String ROBOTLOCKBUT_U
private static final java.lang.String ROBOTLOCKBUT_L
private static final java.lang.String ROBOTLOCKBUT_M
private static final java.lang.String ROBOTLOCKBUTTIP_L
private static final java.lang.String ROBOTLOCKBUTTIP_U
private static final java.lang.String ROBOTLOCKBUTTIP_M
private static final java.lang.String ROBOTLOCKBUTTIP_L_OLD
private static final java.lang.String ROBOTLOCKBUTTIP_U_OLD
private static final java.lang.String TRADEMSG_DISCARD
setDiscardOrPickMsg(boolean)
to show.
Same methods are used by discard and by TRADEMSG_PICKING
.
private static final java.lang.String TRADEMSG_PICKING
TRADEMSG_DISCARD
:
offerIsDiscardOrPickMessage
, setDiscardOrPickMsg(boolean)
, etc.
protected static final java.awt.Color COLOR_FOREGROUND
private static boolean didSwingTooltipDefaults
protected java.awt.Color pnameActiveBG
private ColorSquare blankStandIn
SOCPlayerInterface.initInterfaceElements(boolean)
.
protected java.awt.Button sitBut
LOCKSEAT
/ UNLOCKSEAT
, when sitButIsLock
true.)
Disappears when the game begins.
renameSitButLock()
,
sittingRobotLockBut
private AWTToolTip sitButTip
sitBut
;
non-null only if sitButIsLock
.
LOCKSEATTIP
,
UNLOCKSEATTIP
protected java.awt.Button robotBut
protected java.awt.Button startBut
protected java.awt.Button takeOverBut
protected java.awt.Button sittingRobotLockBut
sitBut
.
Labels are ROBOTLOCKBUT_U
, ROBOTLOCKBUT_L
, ROBOTLOCKBUT_M
.
Tooltip is robotLockButTip
.
Click method is clickRobotSeatLockButton(soc.game.SOCGame.SeatLockState)
.
sitBut
protected boolean sitButIsLock
Set by renameSitButLock()
, cleared elsewhere.
This affects sitBut
and not sittingRobotLockBut
.
addPlayer(String)
,
updateSeatLockButton()
protected SOCFaceButton faceImg
protected java.awt.Label pname
protected java.awt.Label vpLab
protected ColorSquare vpSq
private java.awt.Label svpLab
SOCPlayer.getSpecialVP()
is 0.
Null unless SOCGame.hasSeaBoard
.
private ColorSquare svpSq
SOCGame.hasSeaBoard
.
protected javax.swing.JLabel larmyLab
lroadLab
protected javax.swing.JLabel lroadLab
larmyLab
protected ColorSquare claySq
protected ColorSquare oreSq
protected ColorSquare sheepSq
protected ColorSquare wheatSq
protected ColorSquare woodSq
protected ColorSquare resourceSqDivLine
protected java.awt.Label clayLab
protected java.awt.Label oreLab
protected java.awt.Label sheepLab
protected java.awt.Label wheatLab
protected java.awt.Label woodLab
protected int[] resourceTradeCost
SOCResourceConstants.CLAY
, etc. Highest index is 5.
Null, unless playerIsClient and addPlayer has been called.
protected SOCHandPanel.ResourceTradeTypeMenu[] resourceTradeMenu
SOCResourceConstants.CLAY
, etc. Highest index is 5.
Null, unless playerIsClient and addPlayer has been called.
protected ColorSquare settlementSq
protected ColorSquare citySq
protected ColorSquare roadSq
protected ColorSquare shipSq
SOCGame.hasSeaBoard
. @since 2.0.00
protected javax.swing.JLabel settlementLab
protected javax.swing.JLabel cityLab
protected javax.swing.JLabel roadLab
protected javax.swing.JLabel shipLab
protected ColorSquare resourceSq
protected java.awt.Label resourceLab
protected ColorSquare developmentSq
protected java.awt.Label developmentLab
protected ColorSquare knightsSq
protected javax.swing.JLabel knightsLab
knightsSq
. This and related labels (settlements, cities, ...) are transparent-background
JLabels to avoid z-order overlap problems between the labels' padding and the count squares next to them
(seen during v2.0.00 development).
protected java.awt.List inventory
inventoryItems
; updated frequently by updateDevCards(boolean)
private java.util.ArrayList<SOCInventoryItem> inventoryItems
inventory
; updated frequently by updateDevCards(boolean)
protected java.awt.Button playCardBut
inventory
.
v2.0.00+: In state SOCGame.PLACING_INV_ITEM
only, this button's label
becomes CANCEL
, and inventory
is disabled, while the player
places an item on the board. They can hit Cancel to return the item to their
inventory instead. In any other state, label text is CARD
.
Updated in updateRollDoneBankButtons()
which checks canCancelInvItemPlay
.
private boolean canCancelInvItemPlay
playCardBut
in state SOCGame.PLACING_INV_ITEM
.
Checked in updateRollDoneBankButtons()
.
For details, see setCanCancelInvItemPlay(boolean)
.
protected SquaresPanel sqPanel
protected ColorSquare clothSq
_SC_CLVI
; null otherwise.
Appears in same area as wonderLab
.
protected javax.swing.JLabel clothLab
private javax.swing.JLabel wonderLab
_SC_WOND
; null otherwise.
Blank ("") if player has no current wonder level.
Appears in same areas as clothLab
and clothSq
.
protected boolean playerTradingDisabled
protected java.awt.Label giveLab
protected java.awt.Label getLab
protected java.awt.Button offerBut
protected AWTToolTip offerButTip
OFFERBUTTIP_DIS
,
OFFERBUTTIP_ENA
,
interactive
protected AWTToolTip robotLockButTip
sittingRobotLockBut
;
non-null only if a robot is sitting there.
ROBOTLOCKBUTTIP_L
,
ROBOTLOCKBUTTIP_U
,
ROBOTLOCKBUTTIP_M
protected java.awt.Button clearOfferBut
protected java.awt.Button bankBut
private SOCResourceSet bankGive
private SOCResourceSet bankGet
protected java.awt.Button bankUndoBut
protected ColorSquare[] playerSend
clearOffer(boolean)
.
This is null if playerTradingDisabled
.
playerSendMap
,
playerSendForPrevTrade
private boolean[] playerSendForPrevTrade
playerSend
checkboxes selected during the
previous trade offer; if no previous offer, all are selected.
This is null if playerTradingDisabled
, because playerSend
is null.
protected java.awt.Label rollPromptCountdownLab
setRollPrompt(String, boolean)
protected boolean rollPromptInUse
protected java.util.TimerTask autoRollTimerTask
protected java.awt.Button rollBut
protected java.awt.Button doneBut
protected boolean doneButIsRestart
doneBut
's label is Restart (DONE_RESTART
)
protected java.awt.Button quitBut
protected SOCPlayerInterface playerInterface
protected SOCPlayerClient client
protected SOCGame game
protected SOCPlayer player
private int playerNumber
creation(SOCPlayerInterface, SOCPlayer, boolean)
to player
.getPlayerNumber()
protected boolean playerIsClient
interactive
.
protected boolean playerIsCurrent
protected boolean inPlay
addPlayer(String)
, cleared by removePlayer()
.
protected int[] playerSendMap
playerTradingDisabled
.
playerSend
protected TradeOfferPanel offer
SpeechBalloon
.
If the handpanel is not tall enough, other controls will be obscured by this one.
This low height is indicated by offerHidesControls
and possibly offerCounterHidesFace
.
offerIsResetMessage
,
offerIsDiscardOrPickMessage
private boolean offerHidesControls
offer
message panel
is showing something, we must hide other controls.
Does not apply to client's hand panel.
hideTradeMsgShowOthers(boolean)
private boolean offerCounterHidesFace
offer
message panel
is showing something, we must hide other controls.
Does not apply to client's hand panel.
hideTradeMsgShowOthers(boolean)
private boolean offerHidingControls
offerHidesControls
or offerCounterHidesFace
?
private boolean offerCounterHidingFace
offerHidesControls
or offerCounterHidesFace
?
protected boolean offerIsResetMessage
offer
is holding a message related to a board-reset vote.
offerIsDiscardOrPickMessage
private boolean offerIsDiscardOrPickMessage
offer
is holding a discard message
(TRADEMSG_DISCARD
) or a gold hex pick-resources message
(TRADEMSG_PICKING
).
Set by setDiscardOrPickMsg(boolean)
,
cleared by clearDiscardOrPickMsg()
.
offerIsResetMessage
protected boolean offerIsMessageWasTrade
offer
was holding an active trade offer
before offerIsResetMessage
or offerIsDiscardOrPickMessage
was set.
protected boolean interactive
playerIsClient
true, implies interactive.
private java.awt.Label createColorSqRetLbl
createAndAddResourceColorSquare(Color, String)
.
private ColorSquare createColorSqRetSq
createAndAddResourceColorSquare(Color, String)
.
Constructor Detail |
---|
public SOCHandPanel(SOCPlayerInterface pi, SOCPlayer pl, boolean in)
pi
- the interface that this panel is a part ofpl
- the player associated with this panelin
- the interactive flag settingpublic SOCHandPanel(SOCPlayerInterface pi, SOCPlayer pl)
pi
- the interface that this panel is a part ofpl
- the player associated with this panelMethod Detail |
---|
protected void creation(SOCPlayerInterface pi, SOCPlayer pl, boolean in)
removePlayer()
as part of creation.
pi
- player interfacepl
- the player data, cannot be nullin
- the interactive flag settingprivate final void createAndAddResourceColorSquare(java.awt.Color rc, java.lang.String rtxtkey)
createColorSqRetSq
and createColorSqRetLbl
fields.
rc
- Color for the square, such as ColorSquare.CLAY
rtxtkey
- Text key for i18n, such as "resources.clay"
.
If this key gives the text "Clay", the label will be "Clay:" and the
tooltip will be "Right-click to trade clay".public SOCPlayerInterface getPlayerInterface()
public SOCPlayer getPlayer()
public SOCPlayerClient getClient()
public SOCGame getGame()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public void mouseClicked(java.awt.event.MouseEvent e)
svpSq
or svpLab
to get more info.
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
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
private void createSendBankTradeRequest(SOCGame game, int[] give, int[] get)
game
- Our gamegive
- Resources to give, same format as SOCResourceSet.SOCResourceSet(int[])
get
- Resources to get, same format as SOCResourceSet.SOCResourceSet(int[])
public void disableBankUndoButton()
private final void clickRobotSeatLockButton(SOCGame.SeatLockState current)
actionPerformed(ActionEvent)
.
current
- Current lock state/button labelpublic void clickPlayCardButton()
Inventory items are almost always SOCDevCard
s.
Some scenarios may place other items in the player's inventory,
such as a "gift" port being moved in _SC_FTRI
.
If one of these is chosen, this method calls clickPlayInventorySpecialItem(SOCInventoryItem)
.
Called from actionPerformed()
private final void clickPlayInventorySpecialItem(SOCInventoryItem item)
SOCDevCard
).
Used only in certain scenarios.
item
- Special item picked by playerpublic void clickRollButton()
public void addSittingRobotLockBut()
sitBut
with a different label.
This method was addSeatLockBut() before 1.1.07.
public void addTakeOverBut()
public void addSitButton(boolean clientHasSatAlready)
If the game's already started (state SOCGame.START2A
or later),
the player can't sit there; this method will hide the Sit button
if ! clientHasSatAlready
.
Note: Does not check if the seat is vacant (in case we're
removing a player, and game state is not yet updated);
please call SOCGame.isSeatVacant(int)
before calling this.
clientHasSatAlready
- Is the client seated in this game?
If so, button label should be "lock"/"unlock" (about robots).
(Added in 1.1.07)renameSitButLock()
public void addRobotButton()
public void changeFace(int id)
id
- the id of the imagepublic void removePlayer()
SOCGame.removePlayer(String)
.
Also called from constructor, before doLayout()
.
addPlayer(String)
public void destroy()
public void addPlayer(java.lang.String name)
playerInterface
this way:
Remove all of the sit and take over buttons.
If game still forming, can lock seats (for fewer players/robots).
name
- Name of player to addremovePlayer()
protected void autoRollSetupTimer()
autoRollOrPromptPlayer()
public void updateAtTurn()
updateTakeOverButton()
, and checks if current player (for hilight).
Called from client when server sends SOCMessage.TURN
.
Called also at start of game by SOCPlayerInterface.updateAtGameState()
,
because the server sends no TURN between the last road (gamestate START2B)
and the first player's turn (state PLAY).
void updateAtOurGameState()
Should not be called except by client's playerinterface. Call only when if player is client and is current player.
Before 2.0.00, this was updateAtPlay1().
private void updateButtonsAtAdd()
playerIsClient
.
protected void pnameCalcColors()
public void sqPanelZerosChange(boolean notAllZero)
public void offerCounterOfferVisibleChanged(boolean counterVisible)
TradeOfferPanel
.
For players who aren't the client:
If our TradeOfferPanel
shows/hides the counter offer,
may need to rearrange or hide controls under it.
This should be called when in TradeOfferPanel.OFFER_MODE
,
not in TradeOfferPanel.MESSAGE_MODE
.
counterVisible
- Is the counter-offer showing?public void autoRollOrPromptPlayer()
Call only if panel's player is the client, and the game's current player.
Called when server sends a
ROLLDICEPROMPT
message.
updateAtTurn()
,
autoRollSetupTimer()
public void updateDevCards(boolean addedPlayable)
Enables the "Play Card" button for PLAYABLE
cards,
and also for KEPT
cards (VP cards) so the user can
pick those and get a message that that they've already been played, instead of
wondering why they're listed but can't be played.
Updates inventory
and inventoryItems
to keep them in sync.
addedPlayable
- True if the update added a dev card or item that's playable nowpublic void removeSittingRobotLockBut()
This method was removeSeatLockBut() before 1.1.07.
addSittingRobotLockBut()
,
removeSitBut()
public void removeTakeOverBut()
public void removeSitBut()
renameSitButLock()
,
addSittingRobotLockBut()
public void removeSitLockoutBut()
public void renameSitButLock()
addSitButton(boolean)
,
updateSeatLockButton()
public void removeRobotBut()
public void removeStartBut()
public void updateCurrentOffer(boolean resourcesOnly)
offer
). In that case
the trade offer will be refreshed after the reset is cancelled.
Does not display if playerIsClient.
resourcesOnly
- If true, instead of updating the entire offer,
only show or hide "Accept" button based on the client player's resources.
Calls TradeOfferPanel.updateOfferButtons()
.
If no offer is currently visible, does nothing.public void rejectOfferShowNonClient()
SOCGame.hasTradeOffers()
, because the bots
will sometimes reject another player's offer after a bank trade.
public void rejectOfferAtClient()
public void clearTradeMsg()
tradeSetMessage(String)
private void hideTradeMsgShowOthers(boolean hideTradeMsg)
offer
message panel is showing, we must hide other controls.
This method does not hide/show the trade offer; other methods do that, and then call this method to show/hide the controls that would be obscured by it.
If offerCounterHidesFace
, will check TradeOfferPanel.isCounterOfferMode()
and redo layout (to hide/move) if needed.
hideTradeMsg
- Are we hiding, or showing, the trade offer message panel?tradeSetMessage(String)
,
clearTradeMsg()
,
offerHidesControls
public void clearOffer(boolean updateSendCheckboxes)
updateSendCheckboxes
- If true, and player is client, update the
selection checkboxes for which opponents are sent the offer.
If it's currently our turn, check all boxes where the seat isn't empty.
Otherwise, check only the box for the opponent whose turn it is.private void tradeSetMessage(java.lang.String message)
message
- Message to show, or null to hide (and return tradepanel to previous display, if any)public void resetBoardSetMessage(java.lang.String message) throws java.lang.IllegalStateException
message
- Message to show, or null to hide
java.lang.IllegalStateException
- if offerIsDiscardMessage true when calledpublic boolean setDiscardOrPickMsg(boolean isDiscard)
Normally, this will be cleared by updateValue(PlayerClientListener.UpdateType)
for NUMRESOURCES,
because that's what the server sends all other players on the player's discard or pick.
isDiscard
- True to show TRADEMSG_DISCARD
, false for TRADEMSG_PICKING
.
clearDiscardOrPickMsg()
,
SOCPlayerInterface.discardOrPickTimerSet(boolean)
public void clearDiscardOrPickMsg()
setDiscardOrPickMsg(boolean)
public void updateTakeOverButton()
private void updateRollDoneBankButtons()
rollBut
, doneBut
, bankBut
.
Call only if playerIsCurrent
and playerIsClient
.
v2.0.00+: In game state SOCGame.PLACING_INV_ITEM
, the Play Card button's label
becomes CANCEL
, and inventory
is disabled, while the player places
an item on the board. They can hit Cancel to return the item to their inventory instead.
(Checks the flag set in setCanCancelInvItemPlay(boolean)
.)
Once that state is over, button and inventory return to normal.
public void updateSeatLockButton()
protected void setLArmy(boolean haveIt)
haveIt
- true if this player has the largest armyprotected void setLRoad(boolean haveIt)
haveIt
- true if this player has the longest roadvoid setCanCancelInvItemPlay(boolean canCancel)
SOCInventoryItem
, such as a gift
trade port in scenario _SC_FTRI
. Set a flag that
indicates if this play or placement can be canceled (returned to player's inventory).
Should be called only for our own client player, not other players.
Should be called before entering game state PLACING_INV_ITEM
.
In that state, updateRollDoneBankButtons()
checks this flag to see if the
"Cancel" button should be enabled.
canCancel
- True if SOCInventoryItem.canCancelPlay
public void updateValue(PlayerClientListener.UpdateType utype)
If VICTORYPOINTS
is updated, and game state is SOCGame.OVER
, check for winner
and update (player name label, victory-points tooltip, disable bank/trade btn)
utype
- the type of value update, such as VICTORYPOINTS
or PlayerClientListener.UpdateType.Sheep
.public void updatePickGoldHexResources()
SOCPlayer.setNeedToPickGoldHexResources(int)
.
Informational only: do not display a SOCDiscardOrGainResDialog
.
"Clear" is handled here (has picked, numPick == 0, no longer needs to pick some).
"Set" (numPick > 0) is handled in SOCPlayerInterface.updateAtGameState()
which will display "Picking resources..." in the handpanel for any non-client
players who need to pick.
public void updateResourcesVP()
public void updateResourceTradeCosts(boolean doInit)
doInit
- If true, fill resourceTradeMenu[] with newly constructed menus.public boolean isClientPlayer()
isClientAndCurrentPlayer()
,
SOCPlayerInterface.getClientHand()
public boolean isClientAndCurrentPlayer()
Note that because of the order of network messages,
after this player's turn, there's a brief time when
the state becomes PLAY again, before the current player
is changed to the next player. So, it appears that
this player can roll again, but they cannot.
To guard against this, use isClientAndCurrentlyCanRoll()
instead.
public boolean isClientAndCurrentlyCanRoll()
protected void setRollPrompt(java.lang.String prompt, boolean cancelTimer)
prompt
- The message to display, or null to clear it.cancelTimer
- Cancel autoRollTimerTask
, for use with null promptpublic ColorSquare getBlankStandIn()
SOCPlayerInterface
's use, to set its size and position
setBounds(int, int, int, int)
public void setBounds(int x, int y, int width, int height)
getBlankStandIn()
bounds.
setBounds
in class java.awt.Component
public void doLayout()
doLayout
in class java.awt.Container
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |