Class GraphicalUserInterface
java.lang.Object
it.polimi.ingsw.eriantys.client.UserInterface
it.polimi.ingsw.eriantys.client.gui.GraphicalUserInterface
- All Implemented Interfaces:
ClientMessageHandler
,Runnable
This class represents the graphical user interface (GUI).
It handles messages received from the server and updates the JavaFX
Application
.-
Field Summary
Fields inherited from class it.polimi.ingsw.eriantys.client.UserInterface
characterCardInfo, client
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
handleMessage
(Accepted message) Handles aAccepted
message.void
handleMessage
(AcceptedJoinLobby message) Handles aAcceptedJoinLobby
message.void
handleMessage
(AcceptedLeaveLobby message) Handles aAcceptedLeaveLobby
message.void
handleMessage
(AcceptedUsername message) Handles aAcceptedUsername
message.void
handleMessage
(AssistantCardUpdate message) Handles aAssistantCardUpdate
message.void
handleMessage
(AvailableLobbies message) Handles aAvailableLobbies
message.void
handleMessage
(BoardUpdate message) Handles aBoardUpdate
message.void
handleMessage
(DisconnectionUpdate message) Handles aDisconnectionUpdate
message.void
handleMessage
(GameOverUpdate message) Handles aGameOverUpdate
message.void
handleMessage
(HelpResponse message) Handles aHelpResponse
message.void
handleMessage
(InitialBoardStatus message) Handles aInitialBoardStatus
message.void
handleMessage
(LobbyUpdate message) Handles aLobbyUpdate
message.void
handleMessage
(UserSelectionUpdate message) Handles aUserSelectionUpdate
message.void
init()
Gets a reference of the runningGraphicalApplication
.void
quit()
Notifies the user that they have been disconnected from the game due to an error.void
run()
Launches the JavaFXApplication
.void
Shows an error alert with the given message.void
Shows an information alert with the given message.Methods inherited from class it.polimi.ingsw.eriantys.client.UserInterface
handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, setClient
-
Constructor Details
-
GraphicalUserInterface
Constructs aGraphicalUserInterface
object.- Throws:
IOException
- if the JSON file with the character cards details cannot be opened
-
-
Method Details
-
showInfo
Shows an information alert with the given message.- Specified by:
showInfo
in classUserInterface
- Parameters:
details
- the message to show
-
showError
Shows an error alert with the given message.- Specified by:
showError
in classUserInterface
- Parameters:
details
- the message to show
-
init
public void init()Gets a reference of the runningGraphicalApplication
. It should be called after therun()
method.- Overrides:
init
in classUserInterface
-
run
public void run()Launches the JavaFXApplication
. -
handleMessage
Handles aAccepted
message. This implementation does nothing.- Parameters:
message
- the received message
-
handleMessage
Handles aAcceptedUsername
message. Saves the selected username and changes the scene toLOBBIES
.- Parameters:
message
- the received message
-
handleMessage
Handles aAcceptedJoinLobby
message. Saves the game id and the reconnection settings. Changes the scene toWAITING_ROOM
.- Parameters:
message
- the received message
-
handleMessage
Handles aAcceptedLeaveLobby
message. Removes reconnection settings. Changes the scene toLOBBIES
.- Parameters:
message
- the received message
-
handleMessage
Handles aHelpResponse
message. This message should not be received in GUI mode.- Parameters:
message
- the received message
-
handleMessage
Handles aAvailableLobbies
message. Updates the list of lobbies callingLobbiesController.updateLobbies(List)
.- Parameters:
message
- the received message
-
handleMessage
Handles aLobbyUpdate
message. Updates the list of players in the lobby callingWaitingRoomController.updatePlayers(List)
.- Parameters:
message
- the received message
-
handleMessage
Handles aAssistantCardUpdate
message. Updates the Assistant Cards popup callingAssistantCardsController.populate(List, Map)
. If the player is the next one to play it shows an info alert.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Overrides:
handleMessage
in classUserInterface
- Parameters:
message
- the received message
-
handleMessage
Handles aBoardUpdate
message. Saves the board status. If the player is the next one to play it shows an info alert.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Overrides:
handleMessage
in classUserInterface
- Parameters:
message
- the received message
-
handleMessage
Handles aUserSelectionUpdate
message. Updates user selections callingWaitingRoomController.updateSelections(Map, Map)
. If the players is the next one to choose, it prompts the selection popup.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Overrides:
handleMessage
in classUserInterface
- Parameters:
message
- the received message
-
handleMessage
Handles aGameOverUpdate
message. Removes reconnection settings. Shows an alert with the username of the winner (or an appropriate message if it was a tie).- Parameters:
message
- the received message
-
handleMessage
Handles aInitialBoardStatus
message. Saves the initial board status. Changes the scene toSCHOOLBOARD
.- Parameters:
message
- the received message
-
handleMessage
Handles aDisconnectionUpdate
message. Shows an info alert with information about the disconnection.- Parameters:
message
- the received message
-
quit
public void quit()Description copied from class:UserInterface
Notifies the user that they have been disconnected from the game due to an error.- Specified by:
quit
in classUserInterface
-