Class ClientGUI

    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • connectionCheckMutex

        private final java.lang.Object connectionCheckMutex
      • connectionCheckTimer

        private javax.swing.Timer connectionCheckTimer
      • lastConnectionCheckPackageSent

        private long lastConnectionCheckPackageSent
      • pickCarryDialog

        private PickCarry pickCarryDialog
      • 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.
      • 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
    • Method Detail

      • getStartedByWebClient

        public boolean getStartedByWebClient()
      • getClient

        public Client getClient()
      • getOracle

        public IOracle getOracle()
      • getGame

        public Game getGame()
      • getOptions

        public IOptions getOptions()
      • isReplayOngoing

        boolean isReplayOngoing()
      • isRedoOngoing

        boolean isRedoOngoing()
      • 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()
      • 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
      • 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.
      • setWhatToDoNextForClose

        private void setWhatToDoNextForClose()
      • 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()
      • getPreferredParent

        private javax.swing.JFrame getPreferredParent()
      • setupGUIOptionListeners

        private void setupGUIOptionListeners()
      • initEventViewer

        private void initEventViewer()
      • 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.
      • 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 -
      • 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
      • setLookAndFeel

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

        private void updateTreeAndPack​(java.awt.Window window)
      • makeBoardRecreateMarkers

        public void makeBoardRecreateMarkers()
      • clearUndoStack

        private void clearUndoStack()
      • popUndoStack

        private java.lang.Object popUndoStack()
      • pushUndoStack

        void pushUndoStack​(java.lang.Object object)
      • isUndoStackEmpty

        private boolean isUndoStackEmpty()
      • initPreferencesWindow

        private void initPreferencesWindow()
      • showMarker

        public void showMarker​(Marker marker)
      • showOrHideCaretaker

        private void showOrHideCaretaker​(boolean bval)
      • showOrHideAutoInspector

        private void showOrHideAutoInspector​(boolean bval)
      • showHexRecruitTree

        public void showHexRecruitTree​(GUIMasterHex hex)
      • 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
      • disposeMasterBoard

        private void disposeMasterBoard()
      • disposeBattleBoard

        private void disposeBattleBoard()
      • disposePickCarryDialog

        public void disposePickCarryDialog()
        Dispose the PickCarryDialog, make sure that that is done inside the EDT (caused GUI to hang in 1.6.0_39 whereas in 1.6.0_38 it worked )-;
        Specified by:
        disposePickCarryDialog in interface IClientGUI
      • actualDisposePickCarryDialog

        public void actualDisposePickCarryDialog()
      • disposeStatusScreen

        private void disposeStatusScreen()
      • disposeLogWindow

        private void disposeLogWindow()
      • disposeConnectionLogWindow

        private void disposeConnectionLogWindow()
      • disposeEventViewer

        private void disposeEventViewer()
      • disposePreferencesWindow

        private void disposePreferencesWindow()
      • disposeEngagementResults

        void disposeEngagementResults()
      • disposeCaretakerDisplay

        private void disposeCaretakerDisplay()
      • myTurnNotificationActions

        private void myTurnNotificationActions​(Legion ally)
      • highlightBattleSite

        void highlightBattleSite​(MasterHex battleSite)
      • tellWhatsHappening

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

        private void showOrHideLogWindow​(boolean show)
      • showOrHideConnectionLogWindow

        private void showOrHideConnectionLogWindow​(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.
      • markLegionAsSkipSplit

        private void markLegionAsSkipSplit​(Legion legion)
      • resetAllLegionFlags

        public void resetAllLegionFlags()
      • 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)
      • 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
      • 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
      • validateLegions

        private void validateLegions()
      • 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
      • getBattleUnitDescription

        private java.lang.String getBattleUnitDescription​(BattleCritter battleUnit)
      • 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()
      • undoLastMove

        void undoLastMove()
      • displayNoUndoWhilePendingMovesInfo

        private void displayNoUndoWhilePendingMovesInfo()
      • disposeMovementDie

        private void disposeMovementDie()
      • 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()
      • doShowMessageDialog

        void doShowMessageDialog​(java.lang.String message)
      • showConnectionClosedMessage

        public void showConnectionClosedMessage()
        This is for permanent, non-reversible closed connections
        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)
      • updatePendingText

        private void updatePendingText()
      • getPendingMoveHexes

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

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

        public GUICallbacks getCallbackHandler()
      • answerPickColor

        public void answerPickColor​(PlayerColor color)