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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleMessage(Accepted message) Handles aAcceptedmessage.voidhandleMessage(AcceptedJoinLobby message) Handles aAcceptedJoinLobbymessage.voidhandleMessage(AcceptedLeaveLobby message) Handles aAcceptedLeaveLobbymessage.voidhandleMessage(AcceptedUsername message) Handles aAcceptedUsernamemessage.voidhandleMessage(AssistantCardUpdate message) Handles aAssistantCardUpdatemessage.voidhandleMessage(AvailableLobbies message) Handles aAvailableLobbiesmessage.voidhandleMessage(BoardUpdate message) Handles aBoardUpdatemessage.voidhandleMessage(DisconnectionUpdate message) Handles aDisconnectionUpdatemessage.voidhandleMessage(GameOverUpdate message) Handles aGameOverUpdatemessage.voidhandleMessage(HelpResponse message) Handles aHelpResponsemessage.voidhandleMessage(InitialBoardStatus message) Handles aInitialBoardStatusmessage.voidhandleMessage(LobbyUpdate message) Handles aLobbyUpdatemessage.voidhandleMessage(UserSelectionUpdate message) Handles aUserSelectionUpdatemessage.voidinit()Gets a reference of the runningGraphicalApplication.voidquit()Notifies the user that they have been disconnected from the game due to an error.voidrun()Launches the JavaFXApplication.voidShows an error alert with the given message.voidShows 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 aGraphicalUserInterfaceobject.- 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:
showInfoin classUserInterface- Parameters:
details- the message to show
-
showError
Shows an error alert with the given message.- Specified by:
showErrorin 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:
initin classUserInterface
-
run
public void run()Launches the JavaFXApplication. -
handleMessage
Handles aAcceptedmessage. This implementation does nothing.- Parameters:
message- the received message
-
handleMessage
Handles aAcceptedUsernamemessage. Saves the selected username and changes the scene toLOBBIES.- Parameters:
message- the received message
-
handleMessage
Handles aAcceptedJoinLobbymessage. Saves the game id and the reconnection settings. Changes the scene toWAITING_ROOM.- Parameters:
message- the received message
-
handleMessage
Handles aAcceptedLeaveLobbymessage. Removes reconnection settings. Changes the scene toLOBBIES.- Parameters:
message- the received message
-
handleMessage
Handles aHelpResponsemessage. This message should not be received in GUI mode.- Parameters:
message- the received message
-
handleMessage
Handles aAvailableLobbiesmessage. Updates the list of lobbies callingLobbiesController.updateLobbies(List).- Parameters:
message- the received message
-
handleMessage
Handles aLobbyUpdatemessage. Updates the list of players in the lobby callingWaitingRoomController.updatePlayers(List).- Parameters:
message- the received message
-
handleMessage
Handles aAssistantCardUpdatemessage. 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:
handleMessagein interfaceClientMessageHandler- Overrides:
handleMessagein classUserInterface- Parameters:
message- the received message
-
handleMessage
Handles aBoardUpdatemessage. Saves the board status. If the player is the next one to play it shows an info alert.- Specified by:
handleMessagein interfaceClientMessageHandler- Overrides:
handleMessagein classUserInterface- Parameters:
message- the received message
-
handleMessage
Handles aUserSelectionUpdatemessage. Updates user selections callingWaitingRoomController.updateSelections(Map, Map). If the players is the next one to choose, it prompts the selection popup.- Specified by:
handleMessagein interfaceClientMessageHandler- Overrides:
handleMessagein classUserInterface- Parameters:
message- the received message
-
handleMessage
Handles aGameOverUpdatemessage. 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 aInitialBoardStatusmessage. Saves the initial board status. Changes the scene toSCHOOLBOARD.- Parameters:
message- the received message
-
handleMessage
Handles aDisconnectionUpdatemessage. Shows an info alert with information about the disconnection.- Parameters:
message- the received message
-
quit
public void quit()Description copied from class:UserInterfaceNotifies the user that they have been disconnected from the game due to an error.- Specified by:
quitin classUserInterface
-