net.sf.colossus.gui
Class ClientGUI

java.lang.Object
  extended by net.sf.colossus.gui.ClientGUI
All Implemented Interfaces:
IClientGUI, GUICallbacks

public class ClientGUI
extends java.lang.Object
implements IClientGUI, GUICallbacks


Nested Class Summary
private  class ClientGUI.PendingMove
           
 
Field Summary
private  AutoInspector autoInspector
           
private  BattleBoard battleBoard
           
private  java.util.List<GUIBattleChit> battleChits
           
private  MasterBoard board
           
private  CreatureCollectionView caretakerDisplay
           
protected  Client client
           
private static int CONN_CHECK_TIMEOUT
           
private  java.lang.Object connectionCheckMutex
           
private  javax.swing.Timer connectionCheckTimer
           
private  EngagementResults engagementResults
           
private  EventViewer eventViewer
           
private  boolean gameOverMessageAlreadyShown
           
private  long lastConnectionCheckPackageSent
           
private  int legionMoveConfirmationMode
           
private static java.util.logging.Logger LOGGER
           
private  LogWindow logWindow
           
(package private)  java.lang.String message
           
private  MovementDie movementDie
           
private  Legion mover
          Information on the current moving legion.
private  Negotiate negotiate
           
private  int nextSplitClickMode
           
private  Options options
           
protected  IOracle oracle
           
private  java.util.Set<MasterHex> pendingMoveHexes
           
private  java.util.LinkedList<ClientGUI.PendingMove> pendingMoves
           
private  PickCarry pickCarryDialog
           
private  PreferencesWindow preferencesWindow
           
(package private)  boolean quitAlreadyTried
           
private  boolean recoveredFromMoveNak
           
private  int recruitChitMode
           
private  int replayLastTurn
           
private  int replayMaxTurn
           
private  ReplyToProposal replyToProposal
           
private  javax.swing.JFrame secondaryParent
          the parent frame for secondary windows
private  boolean startedByWebClient
           
private  StatusScreen statusScreen
           
private  java.util.List<java.lang.Boolean> tellEngagementResultsAttackerLegionCertainities
           
private  java.util.List<java.lang.String> tellEngagementResultsAttackerStartingContents
           
private  java.util.List<java.lang.Boolean> tellEngagementResultsDefenderLegionCertainities
           
private  java.util.List<java.lang.String> tellEngagementResultsDefenderStartingContents
           
private  java.util.LinkedList<java.lang.Object> undoStack
          Stack of legion marker ID's, to allow multiple levels of undo for splits, moves, and recruits.
private  int viewMode
           
private  WebClient webClient
           
private  WhatNextManager whatNextManager
          The object which handles what to do next when a game is going to end
 
Constructor Summary
ClientGUI(Client client, Options options, WhatNextManager whatNextMgr)
           
 
Method Summary
 void acquireAngelCallback(Legion legion, CreatureType angelType)
           
 void actOnAddCreature(Legion legion, CreatureType creature, java.lang.String reason)
           
 void actOnApplyCarries(BattleHex hex)
           
 void actOnCleanupBattle()
           
 void actOnDidMove(Legion legion, MasterHex startingHex, MasterHex currentHex, boolean teleport, CreatureType teleportingLord, boolean splitLegionHasForcedMove)
           
 void actOnDidRecruit(Legion legion, CreatureType recruit, java.util.List<CreatureType> recruiters, java.lang.String reason)
           
 void actOnDidSplit(int turn, Legion parent, Legion child, MasterHex hex)
           
 void actOnDidSplitPart2(MasterHex hex)
           
 void actOnDoneWithBattleMoves()
           
 void actOnDoneWithMoves()
           
 void actOnDoneWithSplits()
           
 void actOnDoSummon()
           
 void actOnEngagementCompleted()
           
 void actOnGameStarting()
           
 void actOnGameStartingFailed()
           
 void actOnInitBattle()
           
 void actOnMoveNak()
           
 void actOnNoMoreEngagements()
           
 void actOnPlaceNewChit(java.lang.String imageName, BattleUnit battleUnit, BattleHex hex)
           
 void actOnRemoveCreature(Legion legion, CreatureType type, java.lang.String reason)
           
 void actOnRemoveCreaturePart2(Legion legion)
           
 void actOnRemoveLegion(Legion legion)
           
 void actOnSetupBattleFight()
           
 void actOnSetupBattleMove()
           
 void actOnSetupBattleRecruit()
           
 void actOnSetupBattleSummon()
           
 void actOnSetupFight()
           
 void actOnSetupMove()
           
 void actOnSetupMuster()
           
 void actOnSetupSplit()
           
 void actOnTellBattleMove(BattleHex startingHex, BattleHex endingHex, boolean rememberForUndo)
           
 void actOnTellEngagementResults(Legion winner, java.lang.String method, int points, int turns)
           
 void actOnTellGameOver(java.lang.String message, boolean disposeFollows)
          Update Board and Status screen to reflect the new game over state.
 void actOnTellLegionLocation(Legion legion, MasterHex hex)
           
 void actOnTellMovementRoll(int roll)
           
 void actOnTellRedoChange()
           
 void actOnTellReplay(int maxTurn)
           
 void actOnTellStrikeResults(boolean wasCarry, int strikeNumber, java.util.List<java.lang.String> rolls, BattleCritter striker, BattleCritter target)
           
 void actOnTurnOrPlayerChange(Client client, int turnNr, Player player)
           
 void actOnUndidMove(Legion legion, MasterHex formerHex, MasterHex currentHex, boolean splitLegionHasForcedMove, boolean didTeleport)
           
 void actOnUndidRecruitPart(Legion legion, boolean wasReinforcement, int turnNumber)
           
 void actOnUndidSplit(Legion survivor, int turn)
           
private  void addBattleChit(GUIBattleChit battleChit)
           
 void addPossibleRecruitChits(LegionClientSide legion, java.util.Set<MasterHex> hexes)
           
 void alignLegionsMaybe(Legion legion)
           
 void answerConcede(Legion legion, boolean answer)
           
 void answerFlee(Legion ally, boolean answer)
           
 void answerPickColor(PlayerColor color)
           
 void applyCarries(BattleHex hex)
           
(package private)  void askNewCloseQuitCancel(javax.swing.JFrame frame, boolean fromBattleBoard)
           
 void autoInspectorSetDubiousAsBlanks(boolean newValue)
           
 void bringUpPickColorDialog(java.lang.String playerName, java.util.List<PlayerColor> colorsLeft)
           
(package private)  void checkServerConnection()
          When user requests it from File menu, this method here requests the server to send us a confirmation package, to confirm that connection is still alive and ok.
 boolean chooseWhetherToTeleport()
          Present a dialog allowing the player to enter via land or teleport.
private  void cleanupGUI()
           
 void cleanupNegotiationDialogs()
           
private  void clearUndoStack()
           
 void concede()
           
 void createPickMarkerDialog(ClientGUI gui, java.util.Set<java.lang.String> markerIds, Legion parent)
           
 void defaultCursor()
           
 void didSummon(Legion summoner, Legion donor, CreatureType summon)
           
private  void displayNoUndoWhilePendingMovesInfo()
           
private  void disposeBattleBoard()
           
private  void disposeCaretakerDisplay()
           
(package private)  void disposeEngagementResults()
           
private  void disposeEventViewer()
           
 void disposeInspector()
           
private  void disposeLogWindow()
           
private  void disposeMasterBoard()
           
private  void disposeMovementDie()
           
 void disposePickCarryDialog()
           
private  void disposePreferencesWindow()
           
private  void disposeStatusScreen()
           
 void doAcquireAngel(Legion legion, java.util.List<CreatureType> recruits)
           
 void doBattleMove(int tag, BattleHex hex)
           
 void doCleanupGUI()
           
 void doConfirmAndQuit()
           
 boolean doMove(MasterHex hex)
           
private  void doNewBattleBoard()
           
 void doneWithBattleMoves()
           
 void doneWithStrikes()
           
 void doPickCarries(Client client, int carryDamage, java.util.Set<java.lang.String> carryTargetDescriptions)
           
 void doPickColor(java.lang.String playerName, java.util.List<PlayerColor> colorsLeft)
           
 EntrySide doPickEntrySide(MasterHex hex, java.util.Set<EntrySide> entrySides)
           
 void doPickInitialMarker(java.util.Set<java.lang.String> markersAvailable)
           
 CreatureType doPickLord(java.util.List<CreatureType> lords)
           
 CreatureType doPickRecruit(Legion legion, java.lang.String hexDescription)
           
 java.lang.String doPickRecruiter(java.util.List<java.lang.String> recruiters, java.lang.String hexDescription, Legion legion)
           
 java.util.List<CreatureType> doPickSplitLegion(Legion parent, java.lang.String childMarker)
           
 void doPickSplitMarker(Legion parent, java.util.Set<java.lang.String> markersAvailable)
           
 void doPickStrikePenalty(Client client, java.util.List<java.lang.String> choices)
           
 void doPickSummonAngel(Legion legion, java.util.List<Legion> possibleDonors)
           
private  void doSetWhatToDoNext(WhatNextManager.WhatToDoNext whatToDoNext, boolean triggerQuitTimer)
           
private  void doSetWhatToDoNext(WhatNextManager.WhatToDoNext whatToDoNext, java.lang.String loadFile)
           
(package private)  void doShowMessageDialog(java.lang.String message)
           
 void engagementResultsMaybeShow()
           
private  void ensureEdtNewBattleBoard()
           
private  void ensureEdtSetupClientGUI()
          Ensure that setupClientGUI() is run inside the EDT
 void eventViewerCancelReinforcement(CreatureType recruit, int turnNr)
           
 void eventViewerNewSplitEvent(int turn, Legion parent, Legion child)
           
 void eventViewerRevealCreatures(Legion legion, java.util.List<CreatureType> creatures, java.lang.String reason)
           
 void eventViewerSetCreatureDead(BattleUnit battleUnit)
           
 void eventViewerSetVisibleMaybe()
           
 void eventViewerUndoEvent(Legion splitoff, Legion survivor, int turn)
           
private  void finishServerConnectionCheck(boolean success)
          Cleanup everything related to the serverConnectionCheck timer, and show a message telling whether it went ok or not.
private  java.lang.String getBattleUnitDescription(BattleCritter battleUnit)
           
 MasterBoard getBoard()
           
 GUICallbacks getCallbackHandler()
           
 Client getClient()
           
 Game getGame()
           
 GameClientSide getGameClientSide()
           
 GUIBattleChit getGUIBattleChit(BattleHex hex)
           
 java.util.List<GUIBattleChit> getGUIBattleChits()
          Get a list of all GUIBattleChits (on the current BattleMap)
 java.util.List<GUIBattleChit> getGUIBattleChitsInHex(BattleHex hex)
          Find all GUIBattleChits that occupy a specified hex Note that this can be several for the offboard position(s)
 int getLegionMoveConfirmationMode()
           
private  javax.swing.JFrame getMapOrBoardFrame()
           
(package private)  java.lang.String getMessage()
           
(package private)  MovementDie getMovementDie()
           
 Legion getMover()
           
 int getNextSplitClickMode()
           
 IOptions getOptions()
           
 IOracle getOracle()
           
 Player getOwningPlayer()
           
 java.lang.String getOwningPlayerName()
           
 java.util.Set<MasterHex> getPendingMoveHexes()
           
 PickCarry getPickCarryDialog()
           
private  javax.swing.JFrame getPreferredParent()
           
 int getRecruitChitMode()
           
 boolean getStartedByWebClient()
           
 java.util.Set<MasterHex> getStillToMoveHexes()
           
 int getViewMode()
           
 void handlePickCarry(GUIBattleHex hex)
           
private  void handleUndoRecruit(Legion legion)
          This does the actual work for undoing a recruit
 void handleWebClientRestore()
           
 boolean hasBoard()
           
(package private)  void highlightBattleSite(MasterHex battleSite)
           
 void highlightCrittersWithTargets()
           
 void highlightEngagements()
           
 void informSplitRequiredFirstRound()
           
 void initBoard()
           
private  void initEventViewer()
           
private  void initiateConnectionCheck()
           
private  void initPreferencesWindow()
           
 void initShowEngagementResults()
           
 boolean isMyTurn()
           
 boolean isPickCarryOngoing()
           
(package private)  boolean isRedoOngoing()
           
(package private)  boolean isReplayOngoing()
           
private  boolean isUndoStackEmpty()
           
 void leaveCarryMode()
           
 void markLegionAsSkipRecruit(Legion legion)
          TODO This is just a HACK.
private  void markLegionAsSkipSplit(Legion legion)
           
 void menuCloseBoard()
           
 void menuLoadGame(java.lang.String filename)
           
 void menuNewGame()
           
 void menuQuitGame()
           
(package private)  void menuSaveGame(java.lang.String filename)
           
private  void myTurnNotificationActions(Legion ally)
           
(package private)  void negotiateCallback(Proposal proposal, boolean respawn)
           
private  java.lang.Object popUndoStack()
           
private  void postRecruitStuff(Legion legion)
          Do what is needed after recruit (or mark as skip recruit): push to undo stack, update legions left to muster, hightlight remaining ones,
(package private)  void pushUndoStack(java.lang.Object object)
           
 void removeBattleChit(BattleUnit battleUnit)
           
 void repaintAllWindows()
           
 void repaintBattleBoard()
           
 void replayTurnChange(int nowTurn)
           
 void rescaleAllWindows()
          TODO since we are doing Swing nowadays it would probably be much better to replace all this rescaling code with just using AffineTransform on the right Graphics2D instances.
 void resetAllLegionFlags()
           
 void resetStrikeNumbers()
          reset all strike numbers on chits
 void respawnNegotiate()
           
 void revealEngagedCreatures(Legion legion, java.util.List<CreatureType> creatures, boolean isAttacker, java.lang.String reason)
           
 void serverConfirmsConnection()
          Upon request with checkServerConnection, server sends a confirmation.
 void setBoardActive(boolean val)
           
 void setChosenDevice(java.awt.GraphicsDevice chosen)
           
 void setClientInWebClientNull()
           
 void setLookAndFeel(java.lang.String lfName)
           
(package private)  void setMarker(Legion legion, Marker marker)
          Add the marker to the end of the list and to the LegionInfo.
 void setMoveCompleted(Legion mover, MasterHex current, MasterHex target)
           
 void setMovePending(Legion mover, MasterHex currentHex, MasterHex targetHex)
           
 void setMover(Legion legion)
           
 void setMulliganOldRoll(int movementRoll)
           
 void setPreferencesCheckBoxValue(java.lang.String name, boolean value)
           
 void setPreferencesRadioButtonValue(java.lang.String name, boolean value)
           
 void setPreferencesWindowVisible(boolean val)
           
 void setStartedByWebClient(boolean byWebClient)
           
 void setStrikeNumbers(BattleUnit striker, java.util.Set<BattleHex> targetHexes)
           
 void setupClientGUI()
          Called via ensureEdtSetupClientGUI() when server sends all clients the initBoard command.
private  void setupGUIOptionListeners()
           
private  void setupPlayerLabel()
           
 void setWebClient(WebClient wc)
           
private  void setWhatToDoNextForClose()
           
 void showConcede(Client client, Legion ally, Legion enemy)
           
 void showConnectionClosedMessage()
           
 void showFlee(Client client, Legion ally, Legion enemy)
           
 void showHexRecruitTree(GUIMasterHex hex)
           
 void showMarker(Marker marker)
           
 void showMessageDialogAndWait(java.lang.String message)
           
 void showNegotiate(Legion attacker, Legion defender)
           
private  void showOrHideAutoInspector(boolean bval)
           
private  void showOrHideCaretaker(boolean bval)
           
private  void showOrHideLogWindow(boolean show)
           
 void showWebClient()
           
 void strike(int tag, BattleHex hex)
           
 void syncCheckboxes()
          Ensure that Player menu checkboxes reflect the correct state.
 void tellEngagement(Legion attacker, Legion defender, int turnNumber)
           
 void tellProposal(java.lang.String proposalString)
          Inform this player about the other player's proposal.
 void tellWhatsHappening(java.lang.String message)
           
 void timeoutAbortsConnectionCheck()
          Timeout reached.
 void undoAllBattleMoves()
           
 void undoAllMoves()
           
 void undoAllRecruits()
           
(package private)  void undoAllSplits()
           
 void undoBattleMove(BattleHex hex)
           
 void undoLastBattleMove()
           
(package private)  void undoLastMove()
           
(package private)  void undoLastRecruit()
          For the topmost item on undo stack, undo the done recruit, or reset the skipThisTime flag if set.
(package private)  void undoLastSplit()
           
 void undoRecruit(Legion legion)
          For a specific clicked legion, undo the done recruit, or reset the skipThisTime flag if set.
 void updateCreatureCountDisplay()
           
 void updateEverything()
           
private  void updatePendingText()
           
 void updateStatusScreen()
           
private  void updateTreeAndPack(java.awt.Window window)
           
private  void validateLegions()
           
 void waitCursor()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

CONN_CHECK_TIMEOUT

private static final int CONN_CHECK_TIMEOUT
See Also:
Constant Field Values

connectionCheckMutex

private final java.lang.Object connectionCheckMutex

connectionCheckTimer

private javax.swing.Timer connectionCheckTimer

lastConnectionCheckPackageSent

private long lastConnectionCheckPackageSent

board

private MasterBoard board

statusScreen

private StatusScreen statusScreen

caretakerDisplay

private CreatureCollectionView caretakerDisplay

movementDie

private MovementDie movementDie

engagementResults

private EngagementResults engagementResults

autoInspector

private AutoInspector autoInspector

eventViewer

private EventViewer eventViewer

preferencesWindow

private PreferencesWindow preferencesWindow

logWindow

private LogWindow logWindow

pickCarryDialog

private PickCarry pickCarryDialog

negotiate

private Negotiate negotiate

replyToProposal

private ReplyToProposal replyToProposal

battleBoard

private BattleBoard battleBoard

webClient

private WebClient webClient

startedByWebClient

private boolean startedByWebClient

whatNextManager

private final WhatNextManager whatNextManager
The object which handles what to do next when a game is going to end


undoStack

private final java.util.LinkedList<java.lang.Object> undoStack
Stack of legion marker ID's, to allow multiple levels of undo for splits, moves, and recruits. (for battle actions, the Strings are not actually marker ID's, it's battle hex ID's there instead). TODO it would probably be good to have a full Command pattern here, similar to Swing's UndoManager stuff. In the GUI client we could/should probably just use that. A list of objects (which are mostly the string identifiers of something) isn't that safe.


pendingMoves

private final java.util.LinkedList<ClientGUI.PendingMove> pendingMoves

pendingMoveHexes

private final java.util.Set<MasterHex> pendingMoveHexes

recoveredFromMoveNak

private boolean recoveredFromMoveNak

battleChits

private final java.util.List<GUIBattleChit> battleChits

mover

private Legion mover
Information on the current moving legion.


secondaryParent

private javax.swing.JFrame secondaryParent
the parent frame for secondary windows


replayLastTurn

private int replayLastTurn

replayMaxTurn

private int replayMaxTurn

viewMode

private int viewMode

recruitChitMode

private int recruitChitMode

legionMoveConfirmationMode

private int legionMoveConfirmationMode

nextSplitClickMode

private int nextSplitClickMode

gameOverMessageAlreadyShown

private boolean gameOverMessageAlreadyShown

client

protected final Client client

oracle

protected final IOracle oracle

options

private final Options options

quitAlreadyTried

boolean quitAlreadyTried

tellEngagementResultsAttackerStartingContents

private java.util.List<java.lang.String> tellEngagementResultsAttackerStartingContents

tellEngagementResultsDefenderStartingContents

private java.util.List<java.lang.String> tellEngagementResultsDefenderStartingContents

tellEngagementResultsAttackerLegionCertainities

private java.util.List<java.lang.Boolean> tellEngagementResultsAttackerLegionCertainities

tellEngagementResultsDefenderLegionCertainities

private java.util.List<java.lang.Boolean> tellEngagementResultsDefenderLegionCertainities

message

java.lang.String message
Constructor Detail

ClientGUI

public ClientGUI(Client client,
                 Options options,
                 WhatNextManager whatNextMgr)
Method Detail

setStartedByWebClient

public void setStartedByWebClient(boolean byWebClient)
Specified by:
setStartedByWebClient in interface IClientGUI

getStartedByWebClient

public boolean getStartedByWebClient()

setWebClient

public void setWebClient(WebClient wc)
Specified by:
setWebClient in interface IClientGUI

setClientInWebClientNull

public void setClientInWebClientNull()
Specified by:
setClientInWebClientNull in interface IClientGUI

getBoard

public MasterBoard getBoard()

hasBoard

public boolean hasBoard()
Specified by:
hasBoard in interface IClientGUI

getClient

public Client getClient()

getOracle

public IOracle getOracle()

getGame

public Game getGame()

getGameClientSide

public GameClientSide getGameClientSide()

getOptions

public IOptions getOptions()

isReplayOngoing

boolean isReplayOngoing()

isRedoOngoing

boolean isRedoOngoing()

handleWebClientRestore

public void handleWebClientRestore()
Specified by:
handleWebClientRestore in interface IClientGUI

showWebClient

public void showWebClient()
Specified by:
showWebClient in interface IClientGUI

initBoard

public void initBoard()
Specified by:
initBoard in interface IClientGUI

actOnGameStartingFailed

public void actOnGameStartingFailed()
Specified by:
actOnGameStartingFailed in interface IClientGUI

ensureEdtSetupClientGUI

private void ensureEdtSetupClientGUI()
Ensure that setupClientGUI() is run inside the EDT


setupClientGUI

public void setupClientGUI()
Called via ensureEdtSetupClientGUI() when server sends all clients the initBoard command.


setChosenDevice

public void setChosenDevice(java.awt.GraphicsDevice chosen)
Specified by:
setChosenDevice in interface IClientGUI

ensureEdtNewBattleBoard

private void ensureEdtNewBattleBoard()

actOnInitBattle

public void actOnInitBattle()
Specified by:
actOnInitBattle in interface IClientGUI

doNewBattleBoard

private void doNewBattleBoard()

setStrikeNumbers

public void setStrikeNumbers(BattleUnit striker,
                             java.util.Set<BattleHex> targetHexes)

resetStrikeNumbers

public void resetStrikeNumbers()
reset all strike numbers on chits

Specified by:
resetStrikeNumbers in interface IClientGUI

updateStatusScreen

public void updateStatusScreen()
Specified by:
updateStatusScreen in interface IClientGUI

menuCloseBoard

public void menuCloseBoard()
Specified by:
menuCloseBoard in interface IClientGUI

menuQuitGame

public void menuQuitGame()
Specified by:
menuQuitGame in interface IClientGUI

askNewCloseQuitCancel

void askNewCloseQuitCancel(javax.swing.JFrame frame,
                           boolean fromBattleBoard)

checkServerConnection

void checkServerConnection()
When user requests it from File menu, this method here requests the server to send us a confirmation package, to confirm that connection is still alive and ok.


initiateConnectionCheck

private void initiateConnectionCheck()

serverConfirmsConnection

public void serverConfirmsConnection()
Description copied from interface: IClientGUI
Upon request with checkServerConnection, server sends a confirmation. This method here processes the confirmation.

Specified by:
serverConfirmsConnection in interface IClientGUI

timeoutAbortsConnectionCheck

public void timeoutAbortsConnectionCheck()
Description copied from interface: IClientGUI
Timeout reached. Cancel timer and show error message

Specified by:
timeoutAbortsConnectionCheck in interface IClientGUI

finishServerConnectionCheck

private void finishServerConnectionCheck(boolean success)
Cleanup everything related to the serverConnectionCheck timer, and show a message telling whether it went ok or not. Called by either serverConfirmsConnection() or timeoutAbortsConnectionCheck(), which both synchronize on the connectionCheckMutex.


doSetWhatToDoNext

private void doSetWhatToDoNext(WhatNextManager.WhatToDoNext whatToDoNext,
                               boolean triggerQuitTimer)

doSetWhatToDoNext

private void doSetWhatToDoNext(WhatNextManager.WhatToDoNext whatToDoNext,
                               java.lang.String loadFile)

setWhatToDoNextForClose

private void setWhatToDoNextForClose()

menuNewGame

public void menuNewGame()
Specified by:
menuNewGame in interface IClientGUI

menuLoadGame

public void menuLoadGame(java.lang.String filename)
Specified by:
menuLoadGame in interface IClientGUI

menuSaveGame

void menuSaveGame(java.lang.String filename)

setupPlayerLabel

private void setupPlayerLabel()

highlightEngagements

public void highlightEngagements()
Specified by:
highlightEngagements in interface IClientGUI

getPreferredParent

private javax.swing.JFrame getPreferredParent()

getViewMode

public int getViewMode()
Specified by:
getViewMode in interface IClientGUI

getRecruitChitMode

public int getRecruitChitMode()
Specified by:
getRecruitChitMode in interface IClientGUI

getLegionMoveConfirmationMode

public int getLegionMoveConfirmationMode()
Specified by:
getLegionMoveConfirmationMode in interface IClientGUI

getNextSplitClickMode

public int getNextSplitClickMode()
Specified by:
getNextSplitClickMode in interface IClientGUI

addPossibleRecruitChits

public void addPossibleRecruitChits(LegionClientSide legion,
                                    java.util.Set<MasterHex> hexes)
Specified by:
addPossibleRecruitChits in interface IClientGUI

setupGUIOptionListeners

private void setupGUIOptionListeners()

initEventViewer

private void initEventViewer()

eventViewerSetVisibleMaybe

public void eventViewerSetVisibleMaybe()
Specified by:
eventViewerSetVisibleMaybe in interface IClientGUI

autoInspectorSetDubiousAsBlanks

public void autoInspectorSetDubiousAsBlanks(boolean newValue)
Specified by:
autoInspectorSetDubiousAsBlanks in interface IClientGUI

engagementResultsMaybeShow

public void engagementResultsMaybeShow()
Specified by:
engagementResultsMaybeShow in interface IClientGUI

actOnTellLegionLocation

public void actOnTellLegionLocation(Legion legion,
                                    MasterHex hex)
Specified by:
actOnTellLegionLocation in interface IClientGUI

setMarker

void setMarker(Legion legion,
               Marker marker)
Add the marker to the end of the list and to the LegionInfo. If it's already in the list, remove the earlier entry.


actOnDidSplit

public void actOnDidSplit(int turn,
                          Legion parent,
                          Legion child,
                          MasterHex hex)
Specified by:
actOnDidSplit in interface IClientGUI

actOnDidSplitPart2

public void actOnDidSplitPart2(MasterHex hex)
Specified by:
actOnDidSplitPart2 in interface IClientGUI

actOnDoneWithMoves

public void actOnDoneWithMoves()
Specified by:
actOnDoneWithMoves in interface IClientGUI

actOnDoneWithSplits

public void actOnDoneWithSplits()
Specified by:
actOnDoneWithSplits in interface IClientGUI

actOnDidRecruit

public void actOnDidRecruit(Legion legion,
                            CreatureType recruit,
                            java.util.List<CreatureType> recruiters,
                            java.lang.String reason)
Specified by:
actOnDidRecruit in interface IClientGUI

postRecruitStuff

private void postRecruitStuff(Legion legion)
Do what is needed after recruit (or mark as skip recruit): push to undo stack, update legions left to muster, hightlight remaining ones,

Parameters:
legion -

actOnRemoveCreature

public void actOnRemoveCreature(Legion legion,
                                CreatureType type,
                                java.lang.String reason)
Specified by:
actOnRemoveCreature in interface IClientGUI

actOnRemoveCreaturePart2

public void actOnRemoveCreaturePart2(Legion legion)
Specified by:
actOnRemoveCreaturePart2 in interface IClientGUI

actOnAddCreature

public void actOnAddCreature(Legion legion,
                             CreatureType creature,
                             java.lang.String reason)
Specified by:
actOnAddCreature in interface IClientGUI

actOnUndidSplit

public void actOnUndidSplit(Legion survivor,
                            int turn)
Specified by:
actOnUndidSplit in interface IClientGUI

actOnUndidRecruitPart

public void actOnUndidRecruitPart(Legion legion,
                                  boolean wasReinforcement,
                                  int turnNumber)
Specified by:
actOnUndidRecruitPart in interface IClientGUI

chooseWhetherToTeleport

public boolean chooseWhetherToTeleport()
Description copied from interface: IClientGUI
Present a dialog allowing the player to enter via land or teleport. Return true if the player chooses to teleport.

Specified by:
chooseWhetherToTeleport in interface IClientGUI

actOnDidMove

public void actOnDidMove(Legion legion,
                         MasterHex startingHex,
                         MasterHex currentHex,
                         boolean teleport,
                         CreatureType teleportingLord,
                         boolean splitLegionHasForcedMove)
Specified by:
actOnDidMove in interface IClientGUI

actOnUndidMove

public void actOnUndidMove(Legion legion,
                           MasterHex formerHex,
                           MasterHex currentHex,
                           boolean splitLegionHasForcedMove,
                           boolean didTeleport)
Specified by:
actOnUndidMove in interface IClientGUI

actOnNoMoreEngagements

public void actOnNoMoreEngagements()
Specified by:
actOnNoMoreEngagements in interface IClientGUI

alignLegionsMaybe

public void alignLegionsMaybe(Legion legion)
Specified by:
alignLegionsMaybe in interface IClientGUI

actOnRemoveLegion

public void actOnRemoveLegion(Legion legion)
Specified by:
actOnRemoveLegion in interface IClientGUI

actOnDoSummon

public void actOnDoSummon()
Specified by:
actOnDoSummon in interface IClientGUI

setLookAndFeel

public void setLookAndFeel(java.lang.String lfName)
Specified by:
setLookAndFeel in interface IClientGUI

updateEverything

public void updateEverything()
Specified by:
updateEverything in interface IClientGUI

updateTreeAndPack

private void updateTreeAndPack(java.awt.Window window)

replayTurnChange

public void replayTurnChange(int nowTurn)
Specified by:
replayTurnChange in interface IClientGUI

actOnTellReplay

public void actOnTellReplay(int maxTurn)
Specified by:
actOnTellReplay in interface IClientGUI

actOnTellRedoChange

public void actOnTellRedoChange()
Specified by:
actOnTellRedoChange in interface IClientGUI

clearUndoStack

private void clearUndoStack()

popUndoStack

private java.lang.Object popUndoStack()

pushUndoStack

void pushUndoStack(java.lang.Object object)

isUndoStackEmpty

private boolean isUndoStackEmpty()

eventViewerCancelReinforcement

public void eventViewerCancelReinforcement(CreatureType recruit,
                                           int turnNr)
Specified by:
eventViewerCancelReinforcement in interface IClientGUI

eventViewerSetCreatureDead

public void eventViewerSetCreatureDead(BattleUnit battleUnit)
Specified by:
eventViewerSetCreatureDead in interface IClientGUI

eventViewerNewSplitEvent

public void eventViewerNewSplitEvent(int turn,
                                     Legion parent,
                                     Legion child)
Specified by:
eventViewerNewSplitEvent in interface IClientGUI

eventViewerUndoEvent

public void eventViewerUndoEvent(Legion splitoff,
                                 Legion survivor,
                                 int turn)
Specified by:
eventViewerUndoEvent in interface IClientGUI

setPreferencesCheckBoxValue

public void setPreferencesCheckBoxValue(java.lang.String name,
                                        boolean value)
Specified by:
setPreferencesCheckBoxValue in interface IClientGUI

setPreferencesRadioButtonValue

public void setPreferencesRadioButtonValue(java.lang.String name,
                                           boolean value)
Specified by:
setPreferencesRadioButtonValue in interface IClientGUI

initPreferencesWindow

private void initPreferencesWindow()

setPreferencesWindowVisible

public void setPreferencesWindowVisible(boolean val)
Specified by:
setPreferencesWindowVisible in interface IClientGUI

showMarker

public void showMarker(Marker marker)

showOrHideCaretaker

private void showOrHideCaretaker(boolean bval)

showOrHideAutoInspector

private void showOrHideAutoInspector(boolean bval)

showHexRecruitTree

public void showHexRecruitTree(GUIMasterHex hex)

didSummon

public void didSummon(Legion summoner,
                      Legion donor,
                      CreatureType summon)
Specified by:
didSummon in interface IClientGUI

repaintBattleBoard

public void repaintBattleBoard()
Specified by:
repaintBattleBoard in interface IClientGUI

repaintAllWindows

public void repaintAllWindows()
Specified by:
repaintAllWindows in interface IClientGUI

rescaleAllWindows

public void rescaleAllWindows()
Description copied from interface: IClientGUI
TODO since we are doing Swing nowadays it would probably be much better to replace all this rescaling code with just using AffineTransform on the right Graphics2D instances.

Specified by:
rescaleAllWindows in interface IClientGUI

disposeInspector

public void disposeInspector()
Specified by:
disposeInspector in interface IClientGUI

updateCreatureCountDisplay

public void updateCreatureCountDisplay()
Specified by:
updateCreatureCountDisplay in interface IClientGUI

disposeMasterBoard

private void disposeMasterBoard()

disposeBattleBoard

private void disposeBattleBoard()

disposePickCarryDialog

public void disposePickCarryDialog()
Specified by:
disposePickCarryDialog in interface IClientGUI

disposeStatusScreen

private void disposeStatusScreen()

disposeLogWindow

private void disposeLogWindow()

disposeEventViewer

private void disposeEventViewer()

disposePreferencesWindow

private void disposePreferencesWindow()

disposeEngagementResults

void disposeEngagementResults()

disposeCaretakerDisplay

private void disposeCaretakerDisplay()

showNegotiate

public void showNegotiate(Legion attacker,
                          Legion defender)
Specified by:
showNegotiate in interface IClientGUI

respawnNegotiate

public void respawnNegotiate()
Specified by:
respawnNegotiate in interface IClientGUI

showConcede

public void showConcede(Client client,
                        Legion ally,
                        Legion enemy)
Specified by:
showConcede in interface IClientGUI

showFlee

public void showFlee(Client client,
                     Legion ally,
                     Legion enemy)
Specified by:
showFlee in interface IClientGUI

myTurnNotificationActions

private void myTurnNotificationActions(Legion ally)

initShowEngagementResults

public void initShowEngagementResults()
Specified by:
initShowEngagementResults in interface IClientGUI

tellEngagement

public void tellEngagement(Legion attacker,
                           Legion defender,
                           int turnNumber)
Specified by:
tellEngagement in interface IClientGUI

highlightBattleSite

void highlightBattleSite(MasterHex battleSite)

actOnTellEngagementResults

public void actOnTellEngagementResults(Legion winner,
                                       java.lang.String method,
                                       int points,
                                       int turns)
Specified by:
actOnTellEngagementResults in interface IClientGUI

actOnEngagementCompleted

public void actOnEngagementCompleted()
Specified by:
actOnEngagementCompleted in interface IClientGUI

setMulliganOldRoll

public void setMulliganOldRoll(int movementRoll)
Specified by:
setMulliganOldRoll in interface IClientGUI

tellWhatsHappening

public void tellWhatsHappening(java.lang.String message)
Specified by:
tellWhatsHappening in interface IClientGUI

actOnTellMovementRoll

public void actOnTellMovementRoll(int roll)
Specified by:
actOnTellMovementRoll in interface IClientGUI

revealEngagedCreatures

public void revealEngagedCreatures(Legion legion,
                                   java.util.List<CreatureType> creatures,
                                   boolean isAttacker,
                                   java.lang.String reason)
Specified by:
revealEngagedCreatures in interface IClientGUI

eventViewerRevealCreatures

public void eventViewerRevealCreatures(Legion legion,
                                       java.util.List<CreatureType> creatures,
                                       java.lang.String reason)
Specified by:
eventViewerRevealCreatures in interface IClientGUI

showOrHideLogWindow

private void showOrHideLogWindow(boolean show)

syncCheckboxes

public void syncCheckboxes()
Ensure that Player menu checkboxes reflect the correct state. Copied the TODO below from the interface where it's now removed... TODO let the checkboxes have their own listeners instead. Or even better: use a binding framework.


doAcquireAngel

public void doAcquireAngel(Legion legion,
                           java.util.List<CreatureType> recruits)
Specified by:
doAcquireAngel in interface IClientGUI

setBoardActive

public void setBoardActive(boolean val)
Specified by:
setBoardActive in interface IClientGUI

doPickSummonAngel

public void doPickSummonAngel(Legion legion,
                              java.util.List<Legion> possibleDonors)
Specified by:
doPickSummonAngel in interface IClientGUI

doPickSplitLegion

public java.util.List<CreatureType> doPickSplitLegion(Legion parent,
                                                      java.lang.String childMarker)
Specified by:
doPickSplitLegion in interface IClientGUI

markLegionAsSkipSplit

private void markLegionAsSkipSplit(Legion legion)

resetAllLegionFlags

public void resetAllLegionFlags()

isPickCarryOngoing

public boolean isPickCarryOngoing()
Specified by:
isPickCarryOngoing in interface IClientGUI

doPickCarries

public void doPickCarries(Client client,
                          int carryDamage,
                          java.util.Set<java.lang.String> carryTargetDescriptions)
Specified by:
doPickCarries in interface IClientGUI

getPickCarryDialog

public PickCarry getPickCarryDialog()

handlePickCarry

public void handlePickCarry(GUIBattleHex hex)

doPickColor

public void doPickColor(java.lang.String playerName,
                        java.util.List<PlayerColor> colorsLeft)
Specified by:
doPickColor in interface IClientGUI

bringUpPickColorDialog

public void bringUpPickColorDialog(java.lang.String playerName,
                                   java.util.List<PlayerColor> colorsLeft)

doPickSplitMarker

public void doPickSplitMarker(Legion parent,
                              java.util.Set<java.lang.String> markersAvailable)
Specified by:
doPickSplitMarker in interface IClientGUI

doPickInitialMarker

public void doPickInitialMarker(java.util.Set<java.lang.String> markersAvailable)
Specified by:
doPickInitialMarker in interface IClientGUI

createPickMarkerDialog

public void createPickMarkerDialog(ClientGUI gui,
                                   java.util.Set<java.lang.String> markerIds,
                                   Legion parent)

doPickRecruit

public CreatureType doPickRecruit(Legion legion,
                                  java.lang.String hexDescription)
Specified by:
doPickRecruit in interface IClientGUI

markLegionAsSkipRecruit

public void markLegionAsSkipRecruit(Legion legion)
TODO This is just a HACK. PickRecruit calls this to mark a legion as that user wants to not recruit anything this turn. Better would be, if that dialog could return a "NONE" CreatureType and the caller does the work cleanly... (postponed for now because the NONE-CreatureType would be so much work right now...)

Parameters:
legion -

doPickRecruiter

public java.lang.String doPickRecruiter(java.util.List<java.lang.String> recruiters,
                                        java.lang.String hexDescription,
                                        Legion legion)
Specified by:
doPickRecruiter in interface IClientGUI

doPickEntrySide

public EntrySide doPickEntrySide(MasterHex hex,
                                 java.util.Set<EntrySide> entrySides)
Specified by:
doPickEntrySide in interface IClientGUI

doPickLord

public CreatureType doPickLord(java.util.List<CreatureType> lords)
Specified by:
doPickLord in interface IClientGUI

doPickStrikePenalty

public void doPickStrikePenalty(Client client,
                                java.util.List<java.lang.String> choices)
Specified by:
doPickStrikePenalty in interface IClientGUI

tellProposal

public void tellProposal(java.lang.String proposalString)
Description copied from interface: IClientGUI
Inform this player about the other player's proposal.

Specified by:
tellProposal in interface IClientGUI

cleanupNegotiationDialogs

public void cleanupNegotiationDialogs()
Specified by:
cleanupNegotiationDialogs in interface IClientGUI

actOnTurnOrPlayerChange

public void actOnTurnOrPlayerChange(Client client,
                                    int turnNr,
                                    Player player)
Specified by:
actOnTurnOrPlayerChange in interface IClientGUI

actOnGameStarting

public void actOnGameStarting()
Specified by:
actOnGameStarting in interface IClientGUI

actOnSetupSplit

public void actOnSetupSplit()
Specified by:
actOnSetupSplit in interface IClientGUI

validateLegions

private void validateLegions()

actOnSetupMuster

public void actOnSetupMuster()
Specified by:
actOnSetupMuster in interface IClientGUI

actOnSetupMove

public void actOnSetupMove()
Specified by:
actOnSetupMove in interface IClientGUI

actOnSetupFight

public void actOnSetupFight()
Specified by:
actOnSetupFight in interface IClientGUI

actOnSetupBattleFight

public void actOnSetupBattleFight()
Specified by:
actOnSetupBattleFight in interface IClientGUI

actOnSetupBattleMove

public void actOnSetupBattleMove()
Specified by:
actOnSetupBattleMove in interface IClientGUI

actOnTellBattleMove

public void actOnTellBattleMove(BattleHex startingHex,
                                BattleHex endingHex,
                                boolean rememberForUndo)
Specified by:
actOnTellBattleMove in interface IClientGUI

actOnDoneWithBattleMoves

public void actOnDoneWithBattleMoves()
Specified by:
actOnDoneWithBattleMoves in interface IClientGUI

actOnSetupBattleRecruit

public void actOnSetupBattleRecruit()
Specified by:
actOnSetupBattleRecruit in interface IClientGUI

actOnSetupBattleSummon

public void actOnSetupBattleSummon()
Specified by:
actOnSetupBattleSummon in interface IClientGUI

addBattleChit

private void addBattleChit(GUIBattleChit battleChit)

getGUIBattleChits

public java.util.List<GUIBattleChit> getGUIBattleChits()
Get a list of all GUIBattleChits (on the current BattleMap)

Returns:
The list of GUIBattleChits

getGUIBattleChitsInHex

public java.util.List<GUIBattleChit> getGUIBattleChitsInHex(BattleHex hex)
Find all GUIBattleChits that occupy a specified hex Note that this can be several for the offboard position(s)

Parameters:
hex - The hex to give Chits for
Returns:
A List of GUIBattleChits

getGUIBattleChit

public GUIBattleChit getGUIBattleChit(BattleHex hex)

actOnPlaceNewChit

public void actOnPlaceNewChit(java.lang.String imageName,
                              BattleUnit battleUnit,
                              BattleHex hex)
Specified by:
actOnPlaceNewChit in interface IClientGUI

getBattleUnitDescription

private java.lang.String getBattleUnitDescription(BattleCritter battleUnit)

actOnTellStrikeResults

public void actOnTellStrikeResults(boolean wasCarry,
                                   int strikeNumber,
                                   java.util.List<java.lang.String> rolls,
                                   BattleCritter striker,
                                   BattleCritter target)
Specified by:
actOnTellStrikeResults in interface IClientGUI

highlightCrittersWithTargets

public void highlightCrittersWithTargets()
Specified by:
highlightCrittersWithTargets in interface IClientGUI

actOnApplyCarries

public void actOnApplyCarries(BattleHex hex)
Specified by:
actOnApplyCarries in interface IClientGUI

actOnCleanupBattle

public void actOnCleanupBattle()
Specified by:
actOnCleanupBattle in interface IClientGUI

undoLastRecruit

void undoLastRecruit()
For the topmost item on undo stack, undo the done recruit, or reset the skipThisTime flag if set.


undoRecruit

public void undoRecruit(Legion legion)
For a specific clicked legion, undo the done recruit, or reset the skipThisTime flag if set.

Specified by:
undoRecruit in interface IClientGUI
Parameters:
legion - The legion for which to undo the recruit

handleUndoRecruit

private void handleUndoRecruit(Legion legion)
This does the actual work for undoing a recruit

Parameters:
legion - The legion for which to undo the recruit

undoAllSplits

void undoAllSplits()

undoLastSplit

void undoLastSplit()

informSplitRequiredFirstRound

public void informSplitRequiredFirstRound()
Specified by:
informSplitRequiredFirstRound in interface IClientGUI

undoLastMove

void undoLastMove()

undoLastBattleMove

public void undoLastBattleMove()
Specified by:
undoLastBattleMove in interface IClientGUI

undoAllBattleMoves

public void undoAllBattleMoves()
Specified by:
undoAllBattleMoves in interface IClientGUI

undoAllMoves

public void undoAllMoves()
Specified by:
undoAllMoves in interface IClientGUI

undoAllRecruits

public void undoAllRecruits()
Specified by:
undoAllRecruits in interface IClientGUI

displayNoUndoWhilePendingMovesInfo

private void displayNoUndoWhilePendingMovesInfo()

defaultCursor

public void defaultCursor()
Specified by:
defaultCursor in interface IClientGUI

waitCursor

public void waitCursor()
Specified by:
waitCursor in interface IClientGUI

doCleanupGUI

public void doCleanupGUI()
Specified by:
doCleanupGUI in interface IClientGUI

disposeMovementDie

private void disposeMovementDie()

getMovementDie

MovementDie getMovementDie()

cleanupGUI

private void cleanupGUI()

actOnTellGameOver

public void actOnTellGameOver(java.lang.String message,
                              boolean disposeFollows)
Update Board and Status screen to reflect the new game over state. Show the game over message, or store it to be shown later. If dispose will follow soon, don't show message immediately (to avoid having the user to have click two boxes), instead store it for later to be shown then together with the dispose dialog.

Specified by:
actOnTellGameOver in interface IClientGUI
Parameters:
message - The message ("XXXX wins", or "Draw")
disposeFollows - If true, server will send a dispose message soon

getMessage

java.lang.String getMessage()

showMessageDialogAndWait

public void showMessageDialogAndWait(java.lang.String message)
Specified by:
showMessageDialogAndWait in interface IClientGUI

doShowMessageDialog

void doShowMessageDialog(java.lang.String message)

doConfirmAndQuit

public void doConfirmAndQuit()
Specified by:
doConfirmAndQuit in interface IClientGUI

showConnectionClosedMessage

public void showConnectionClosedMessage()
Specified by:
showConnectionClosedMessage in interface IClientGUI

getMapOrBoardFrame

private javax.swing.JFrame getMapOrBoardFrame()

negotiateCallback

void negotiateCallback(Proposal proposal,
                       boolean respawn)

getOwningPlayer

public Player getOwningPlayer()

getOwningPlayerName

public java.lang.String getOwningPlayerName()

isMyTurn

public boolean isMyTurn()

getMover

public Legion getMover()

setMover

public void setMover(Legion legion)

doMove

public boolean doMove(MasterHex hex)

actOnMoveNak

public void actOnMoveNak()
Specified by:
actOnMoveNak in interface IClientGUI

setMovePending

public void setMovePending(Legion mover,
                           MasterHex currentHex,
                           MasterHex targetHex)
Specified by:
setMovePending in interface IClientGUI

updatePendingText

private void updatePendingText()

getPendingMoveHexes

public java.util.Set<MasterHex> getPendingMoveHexes()

getStillToMoveHexes

public java.util.Set<MasterHex> getStillToMoveHexes()

setMoveCompleted

public void setMoveCompleted(Legion mover,
                             MasterHex current,
                             MasterHex target)
Specified by:
setMoveCompleted in interface IClientGUI

removeBattleChit

public void removeBattleChit(BattleUnit battleUnit)
Specified by:
removeBattleChit in interface IClientGUI

getCallbackHandler

public GUICallbacks getCallbackHandler()

answerPickColor

public void answerPickColor(PlayerColor color)

leaveCarryMode

public void leaveCarryMode()
Specified by:
leaveCarryMode in interface GUICallbacks

applyCarries

public void applyCarries(BattleHex hex)
Specified by:
applyCarries in interface GUICallbacks

acquireAngelCallback

public void acquireAngelCallback(Legion legion,
                                 CreatureType angelType)
Specified by:
acquireAngelCallback in interface GUICallbacks

answerFlee

public void answerFlee(Legion ally,
                       boolean answer)
Specified by:
answerFlee in interface GUICallbacks

answerConcede

public void answerConcede(Legion legion,
                          boolean answer)
Specified by:
answerConcede in interface GUICallbacks

doBattleMove

public void doBattleMove(int tag,
                         BattleHex hex)
Specified by:
doBattleMove in interface GUICallbacks

undoBattleMove

public void undoBattleMove(BattleHex hex)
Specified by:
undoBattleMove in interface GUICallbacks

strike

public void strike(int tag,
                   BattleHex hex)
Specified by:
strike in interface GUICallbacks

doneWithBattleMoves

public void doneWithBattleMoves()
Specified by:
doneWithBattleMoves in interface GUICallbacks

doneWithStrikes

public void doneWithStrikes()
Specified by:
doneWithStrikes in interface GUICallbacks

concede

public void concede()
Specified by:
concede in interface GUICallbacks