java.lang.Object
View.MainPageController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe editParameters function allows the user to edit their nickname, IP address and port number.static MainPageControllerThe getMainPage function is a static function that returns the singleton instance of the MainPageController class.javafx.scene.ScenegetScene()The getScene function is used to load the main-page.fxml file and return a Scene object that can be used in the Main class to set up the stage for this scene.voidhostGame()The hostGame function is called when the host button is clicked.voidjoinGame()The joinGame function is called when the user clicks on the "Join Game" button.voidsetPage(javafx.stage.Stage stage) The setPage function is used to set the stage of the current page.
-
Constructor Details
-
MainPageController
public MainPageController()
-
-
Method Details
-
getMainPage
The getMainPage function is a static function that returns the singleton instance of the MainPageController class. This function is used to ensure that only one instance of this class exists at any given time, and it also allows for easy access to this object from other classes. The getMainPage function takes no parameters and returns an object of type MainPageController. If there are no instances of the MainPageController class currently in existence, then a new one will be created before being returned by this method.- Returns:
- A mainpagecontroller object
- Throws:
IOException
-
getScene
The getScene function is used to load the main-page.fxml file and return a Scene object that can be used in the Main class to set up the stage for this scene.- Returns:
- A scene object
- Throws:
IOException
-
joinGame
The joinGame function is called when the user clicks on the "Join Game" button. It creates a new GuestModel object, which will attempt to connect to a server at the IP address and port number specified by the user in their respective text fields.- Throws:
IOException
-
hostGame
The hostGame function is called when the host button is clicked. It creates a new HostModel object, which will be used to create a ScrabbleViewModel object. The ScrabbleViewModel object will then be used to swap scenes and start the game.- Throws:
IOException
-
editParameters
public void editParameters()The editParameters function allows the user to edit their nickname, IP address and port number. The function is called when the "EDIT" button is clicked. When this happens, all three text fields are set to be editable by the user. If they click on "SAVE", then all three text fields are no longer editable by the user and their changes will be saved in those respective variables for future use. -
setPage
public void setPage(javafx.stage.Stage stage) The setPage function is used to set the stage of the current page.- Parameters:
stage- Set the stage for the scene
-