Package it.polimi.ingsw.Client
Class GUI
java.lang.Object
javafx.application.Application
it.polimi.ingsw.Client.GUI
public class GUI
extends javafx.application.Application
This class define game's GUI
-
Nested Class Summary
Nested classes/interfaces inherited from class javafx.application.Application
javafx.application.Application.Parameters
-
Field Summary
Modifier and TypeFieldDescriptionstatic ClassicLock
Menu's lockstatic ClassicLock
Identifier's lockstatic ClassicLock
Login's lockstatic ClassicLock
Move's lockstatic ClassicLock
Scoreboard's lockprivate final int
Board cells' dimensionprivate final double
Board's dimensionprivate final ArrayList<javafx.scene.layout.HBox>
Board rows' pointersprivate static final ArrayList<ArrayList<CellDataModel>>
Board cells' pointersprivate final double
Border's dimension valueprivate final javafx.scene.layout.BorderWidths
Border's dimensionprivate final double
CGC points card's resolutionprivate final double
Common goal card's width resolutionprivate final double
Common goal card's height resolutionprivate static javafx.scene.Scene
Credits' sceneprivate static final double
End game card's resolutionprivate static javafx.scene.image.ImageView
First common goal card available points' ImageView attributeprivate static javafx.scene.image.ImageView
First common goal card's ImageView attributeprivate static javafx.scene.image.ImageView
First common goal card points' ImageView attributeprivate static String
Game'IDprivate final int
Game's width resolutionprivate final int
Game's height resolutionprivate static javafx.scene.Scene
Game's sceneprivate static boolean
Attribute that allow or not shelf's columns selectionprivate static javafx.scene.Scene
Loading's sceneprivate static final int
Game's login width resolutionprivate static final int
Game's login height resolutionprivate static javafx.scene.Scene
Login's sceneprivate final int
Game's menu' width resolutionprivate final int
Game's menu' height resolutionprivate static javafx.scene.Scene
Main menu's sceneprivate static javafx.stage.Stage
Game's main stageprivate static boolean
Valued to true if the client is joining a new matchprivate static String
Player's nicknameprivate static javafx.scene.text.Text
Player's nickname Text attributeprivate static String
Game's number of playersprivate static javafx.scene.text.Text
Attribute that indicate the textArea to insert player's numberprivate static javafx.scene.control.TextArea
TextArea used to insert number of playersprivate static javafx.scene.image.ImageView
Personal goal card ImageView attributeprivate final double
Personal goal card's resolutionSupport array with board cell's positionprivate static javafx.scene.layout.AnchorPane
Game rootPane's attributeprivate static javafx.scene.layout.AnchorPane
ScoreBoard rootPane's attributeprivate static javafx.scene.Scene
Scoreboard's sceneprivate final double
Score card's resolutionprivate static javafx.scene.image.ImageView
Second common goal card available points' ImageView attributeprivate static javafx.scene.image.ImageView
Second common goal card's ImageView attributeprivate static javafx.scene.image.ImageView
Second common goal card points' ImageView attributeprivate static ArrayList<CellDataModel>
Selected cells' pointers attributeprivate static int
Selected column's numberprivate final int
Shelf cells' dimensionprivate final ArrayList<javafx.scene.layout.VBox>
Shelf columns' pointersShelf cells' pointersprivate final double
Shelf's dimensionSelected cells' x positionsSelected cells' y positionsprivate static final javafx.scene.text.Text
Attribute that indicate if is player's turnFields inherited from class javafx.application.Application
STYLESHEET_CASPIAN, STYLESHEET_MODENA
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
boardCellEvents
(CellDataModel cell) This method defines board cell's eventsprivate void
This method builds the board's GUIprivate void
This method builds board grid's GUIprivate void
This method instantiates board cells' positionsprivate void
This method builds shelf's cellsprivate void
This method builds common goal cards' GUIprivate void
This method builds cgc points cards' GUIprivate void
buildCredits
(javafx.scene.layout.AnchorPane rootPane) This method builds credits' GUIstatic void
This method builds end game card's GUIprivate void
This method builds first CGC available points' GUIprivate void
This method builds game button's GUIprivate static void
buildLoading
(javafx.scene.layout.AnchorPane rootPane) This method builds loading scene's GUIprivate void
buildLogin
(javafx.scene.layout.AnchorPane rootPane) This method builds login's GUIprivate void
buildMenu
(javafx.scene.layout.AnchorPane rootPane) This method builds game menu's GUIprivate void
This method builds nickname's GUIprivate void
This method builds personal goal card's GUIprivate void
This method builds board's cellsstatic void
buildScoreBoard
(Map<String, Integer> scoreboard) This method build score board's GUIprivate void
This method builds second CGC available points' GUIprivate void
This method builds the shelf's GUIprivate void
This method builds shelf grid's GUIprivate boolean
checkLoginID
(String gameID) This method makes identifier input's checksprivate boolean
checkLoginInputs
(String nickname, String numOfPlayers) This method makes login input's checksprivate void
creditsButtonEvent
(javafx.scene.control.Button creditsButton) static void
errorMessage
(String errorText) This method builds error messagesstatic void
errorMessageConfirm
(String errorText) This method builds error messages waiting for user confirmationprivate void
gameButtonsEvents
(javafx.scene.control.Button exitButton) This method defines game buttons' eventsstatic String
Getter method for the game's IDstatic String
Getter method for player's nicknamestatic String
Getter method for game's number of playersstatic int
Getter method for selected columngetX()
Getter method for x selected cells coordinatesgetY()
Getter method for x selected cells coordinatesstatic void
infoMessage
(String mexText) This method builds information messagesprivate void
loginButtonEvent
(javafx.scene.control.Button connectOrStartButton, javafx.scene.control.Button gobackButton, javafx.scene.control.Button confirmIDButton, javafx.scene.control.TextArea gameIDTextArea, javafx.scene.control.TextArea playerNickTextArea) This method defines login buttons' eventsstatic void
Launch GUIprivate void
mainMenuButtonsEvents
(javafx.scene.control.Button startGameButton, javafx.scene.control.Button creditsButton, javafx.scene.control.Button closeGameButton) This method defines main menu buttons' eventsstatic void
This method cleans the insertion's attributesprivate static void
scoreboardButtonEvent
(javafx.scene.control.Button gobackButton) This method defines score board button's eventsstatic void
setMyTurn
(boolean myTurn) Setter method for boolean attribute "myTurn"static void
setNewMatch
(boolean isVisible) Sets visibility of nickname/number of players text areasstatic void
setNicknameText
(String text) Setter method for nickname's TextArea attributestatic void
This method changes game's current sceneprivate void
shelfGridEvents
(javafx.scene.layout.VBox shelfColumn0, javafx.scene.layout.VBox shelfColumn1, javafx.scene.layout.VBox shelfColumn2, javafx.scene.layout.VBox shelfColumn3, javafx.scene.layout.VBox shelfColumn4) This method defines shelf columns' eventsvoid
start
(javafx.stage.Stage stage) This method instantiates game's GUI componentstatic void
updateBoard
(BoardInterface board) This method is used to update game's boardstatic void
updateCGCScoredPoints
(ArrayList<Integer> scoreCards) This method updates common goal cards score's cardsstatic void
updateCommonGoalCards
(CommonGoalCardInterface firstCGC, CommonGoalCardInterface secondCGC) This method is used to update common goal cardsstatic void
This method is used to update personal goal cardsstatic void
updateShelf
(ShelfInterface shelf) This method is used to update game's shelfMethods inherited from class javafx.application.Application
getHostServices, getParameters, getUserAgentStylesheet, init, launch, launch, notifyPreloader, setUserAgentStylesheet, stop
-
Field Details
-
loginRESX
private static final int loginRESXGame's login width resolution- See Also:
-
loginRESY
private static final int loginRESYGame's login height resolution- See Also:
-
egcRES
private static final double egcRESEnd game card's resolution- See Also:
-
shelfColumnsCells
Shelf cells' pointers -
boardRowsCells
Board cells' pointers -
positions
Support array with board cell's position -
yourTurnText
private static final javafx.scene.text.Text yourTurnTextAttribute that indicate if is player's turn -
allowExitMenu
Menu's lock -
allowLogin
Login's lock -
allowMove
Move's lock -
allowScoreboard
Scoreboard's lock -
allowIdentifier
Identifier's lock -
mainStage
private static javafx.stage.Stage mainStageGame's main stage -
mainMenuScene
private static javafx.scene.Scene mainMenuSceneMain menu's scene -
loginScene
private static javafx.scene.Scene loginSceneLogin's scene -
creditsScene
private static javafx.scene.Scene creditsSceneCredits' scene -
gameScene
private static javafx.scene.Scene gameSceneGame's scene -
scoreboardScene
private static javafx.scene.Scene scoreboardSceneScoreboard's scene -
loadingScene
private static javafx.scene.Scene loadingSceneLoading's scene -
secondCGCAvailablePointsImageView
private static javafx.scene.image.ImageView secondCGCAvailablePointsImageViewSecond common goal card available points' ImageView attribute -
firstCGCAvailablePointsImageView
private static javafx.scene.image.ImageView firstCGCAvailablePointsImageViewFirst common goal card available points' ImageView attribute -
firstCGCPImageView
private static javafx.scene.image.ImageView firstCGCPImageViewFirst common goal card points' ImageView attribute -
secondCGCPImageView
private static javafx.scene.image.ImageView secondCGCPImageViewSecond common goal card points' ImageView attribute -
pgcImageView
private static javafx.scene.image.ImageView pgcImageViewPersonal goal card ImageView attribute -
firstCGCImageView
private static javafx.scene.image.ImageView firstCGCImageViewFirst common goal card's ImageView attribute -
secondCGCImageView
private static javafx.scene.image.ImageView secondCGCImageViewSecond common goal card's ImageView attribute -
sbRootPane
private static javafx.scene.layout.AnchorPane sbRootPaneScoreBoard rootPane's attribute -
rootPane
private static javafx.scene.layout.AnchorPane rootPaneGame rootPane's attribute -
nicknameText
private static javafx.scene.text.Text nicknameTextPlayer's nickname Text attribute -
numPlayer
private static javafx.scene.text.Text numPlayerAttribute that indicate the textArea to insert player's number -
numPlayerTextArea
private static javafx.scene.control.TextArea numPlayerTextAreaTextArea used to insert number of players -
selectedCells
Selected cells' pointers attribute -
isMyTurn
private static boolean isMyTurnAttribute that allow or not shelf's columns selection -
selectedColumn
private static int selectedColumnSelected column's number -
x
Selected cells' x positions -
y
Selected cells' y positions -
gameID
Game'ID -
numOfPlayers
Game's number of players -
nickname
Player's nickname -
newMatch
private static boolean newMatchValued to true if the client is joining a new match -
GameRESX
private final int GameRESXGame's width resolution- See Also:
-
GameRESY
private final int GameRESYGame's height resolution- See Also:
-
mainMenuRESX
private final int mainMenuRESXGame's menu' width resolution- See Also:
-
mainMenuRESY
private final int mainMenuRESYGame's menu' height resolution- See Also:
-
borderDimension
private final double borderDimensionBorder's dimension value- See Also:
-
borderWidths
private final javafx.scene.layout.BorderWidths borderWidthsBorder's dimension -
boardRES
private final double boardRESBoard's dimension -
shelfRES
private final double shelfRESShelf's dimension -
cgcRESX
private final double cgcRESXCommon goal card's width resolution -
cgcRESY
private final double cgcRESYCommon goal card's height resolution -
pgcRES
private final double pgcRESPersonal goal card's resolution -
cgcPointsRES
private final double cgcPointsRESCGC points card's resolution -
scRES
private final double scRESScore card's resolution- See Also:
-
shelfColumns
Shelf columns' pointers -
shelfCellDim
private final int shelfCellDimShelf cells' dimension- See Also:
-
boardRows
Board rows' pointers -
boardCellDim
private final int boardCellDimBoard cells' dimension- See Also:
-
-
Constructor Details
-
GUI
public GUI()
-
-
Method Details
-
buildEndGameCard
public static void buildEndGameCard()This method builds end game card's GUI -
resetSelection
public static void resetSelection()This method cleans the insertion's attributes -
setNewMatch
public static void setNewMatch(boolean isVisible) Sets visibility of nickname/number of players text areas- Parameters:
isVisible
- to turn visibility on
-
buildScoreBoard
This method build score board's GUI- Parameters:
scoreboard
- map received from the server
-
scoreboardButtonEvent
private static void scoreboardButtonEvent(javafx.scene.control.Button gobackButton) This method defines score board button's events- Parameters:
gobackButton
- button
-
buildLoading
private static void buildLoading(javafx.scene.layout.AnchorPane rootPane) This method builds loading scene's GUI- Parameters:
rootPane
- root AnchorPane
-
errorMessage
This method builds error messages- Parameters:
errorText
- text to visualize
-
errorMessageConfirm
This method builds error messages waiting for user confirmation- Parameters:
errorText
- text to visualize
-
infoMessage
This method builds information messages- Parameters:
mexText
- text to visualize
-
updateBoard
This method is used to update game's board- Parameters:
board
- game's board- Throws:
Exception
- related to Model management
-
updateShelf
This method is used to update game's shelf- Parameters:
shelf
- game's shelf
-
updatePersonalGoalCard
This method is used to update personal goal cards- Parameters:
pgCard
- game's personal goal card- Throws:
RemoteException
- related to server
-
updateCommonGoalCards
public static void updateCommonGoalCards(CommonGoalCardInterface firstCGC, CommonGoalCardInterface secondCGC) throws RemoteException This method is used to update common goal cards- Parameters:
firstCGC
- game's first common goal cardsecondCGC
- game's second common goal card- Throws:
RemoteException
- related to server
-
updateCGCScoredPoints
This method updates common goal cards score's cards- Parameters:
scoreCards
- List with gained points- Throws:
RemoteException
- related to server
-
setScene
This method changes game's current scene- Parameters:
scene
- scene to set
-
getGameID
Getter method for the game's ID- Returns:
- game's ID
-
getNumOfPlayers
Getter method for game's number of players- Returns:
- game's number of players
-
getNickname
Getter method for player's nickname- Returns:
- player's nickname
-
getSelectedColumn
public static int getSelectedColumn()Getter method for selected column- Returns:
- selected column
-
getX
Getter method for x selected cells coordinates- Returns:
- x coordinates
-
getY
Getter method for x selected cells coordinates- Returns:
- y coordinates
-
setMyTurn
public static void setMyTurn(boolean myTurn) Setter method for boolean attribute "myTurn"- Parameters:
myTurn
- value to set
-
setNicknameText
Setter method for nickname's TextArea attribute- Parameters:
text
- text to set
-
main
Launch GUI- Parameters:
args
- arguments
-
start
public void start(javafx.stage.Stage stage) This method instantiates game's GUI component- Specified by:
start
in classjavafx.application.Application
- Parameters:
stage
- game's stage
-
buildBoard
private void buildBoard()This method builds the board's GUI -
buildShelf
private void buildShelf()This method builds the shelf's GUI -
buildCommonGoalCards
private void buildCommonGoalCards()This method builds common goal cards' GUI -
buildPersonalGoalCard
private void buildPersonalGoalCard()This method builds personal goal card's GUI -
buildCommonGoalCardsPointCards
private void buildCommonGoalCardsPointCards()This method builds cgc points cards' GUI -
buildFirstCGCAvailablePoints
private void buildFirstCGCAvailablePoints()This method builds first CGC available points' GUI -
buildSecondCGCAvailablePoints
private void buildSecondCGCAvailablePoints()This method builds second CGC available points' GUI -
buildGameButtons
private void buildGameButtons()This method builds game button's GUI -
buildNickname
private void buildNickname()This method builds nickname's GUI -
buildShelfGrid
private void buildShelfGrid()This method builds shelf grid's GUI -
buildBoardGrid
private void buildBoardGrid()This method builds board grid's GUI -
buildBoardPositions
private void buildBoardPositions()This method instantiates board cells' positions -
buildRowsCells
private void buildRowsCells()This method builds board's cells -
buildColumCells
private void buildColumCells()This method builds shelf's cells -
boardCellEvents
This method defines board cell's events- Parameters:
cell
- for which to define effects
-
shelfGridEvents
private void shelfGridEvents(javafx.scene.layout.VBox shelfColumn0, javafx.scene.layout.VBox shelfColumn1, javafx.scene.layout.VBox shelfColumn2, javafx.scene.layout.VBox shelfColumn3, javafx.scene.layout.VBox shelfColumn4) This method defines shelf columns' events- Parameters:
shelfColumn0
- first columnshelfColumn1
- second columnshelfColumn2
- third columnshelfColumn3
- fourth columnshelfColumn4
- fifth column
-
gameButtonsEvents
private void gameButtonsEvents(javafx.scene.control.Button exitButton) This method defines game buttons' events- Parameters:
exitButton
- button
-
buildMenu
private void buildMenu(javafx.scene.layout.AnchorPane rootPane) This method builds game menu's GUI- Parameters:
rootPane
- root AnchorPane
-
buildLogin
private void buildLogin(javafx.scene.layout.AnchorPane rootPane) This method builds login's GUI- Parameters:
rootPane
- root AnchorPane
-
buildCredits
private void buildCredits(javafx.scene.layout.AnchorPane rootPane) This method builds credits' GUI- Parameters:
rootPane
- root AnchorPane
-
creditsButtonEvent
private void creditsButtonEvent(javafx.scene.control.Button creditsButton) -
loginButtonEvent
private void loginButtonEvent(javafx.scene.control.Button connectOrStartButton, javafx.scene.control.Button gobackButton, javafx.scene.control.Button confirmIDButton, javafx.scene.control.TextArea gameIDTextArea, javafx.scene.control.TextArea playerNickTextArea) This method defines login buttons' events- Parameters:
connectOrStartButton
- buttongobackButton
- buttongameIDTextArea
- buttonplayerNickTextArea
- button
-
mainMenuButtonsEvents
private void mainMenuButtonsEvents(javafx.scene.control.Button startGameButton, javafx.scene.control.Button creditsButton, javafx.scene.control.Button closeGameButton) This method defines main menu buttons' events- Parameters:
startGameButton
- buttoncreditsButton
- buttoncloseGameButton
- button
-
checkLoginInputs
This method makes login input's checks- Parameters:
nickname
- player's nicknamenumOfPlayers
- game's number of players- Returns:
- true if OK, false if KO
-
checkLoginID
This method makes identifier input's checks- Parameters:
gameID
- game's identifier- Returns:
- true if OK, false if KO
-