java.lang.Object
view.ConnectionController
-
Constructor Summary
ConstructorsConstructorDescriptionThe ConnectionController function is the controller for the ConnectionView.fxml file, which allows users to choose a dictionary from a list of dictionaries and connect to it. -
Method Summary
Modifier and TypeMethodDescriptionvoidBack()The Back function is used to return the user to the main menu.voidThe checkOrCreateCalculationServer function checks if the calculation server is running.voidThe connectToServer function is called when the user clicks on the "Connect" button.voidThe loadGuestForm function is used to load the GuestPage.fxml file, which contains the GUI for a guest user.voidThe loadHomePage function is used to load the HomePage.fxml file into the main window of our application.voidThe loadHostForm function is called when the user clicks on the "Host" button.voidThe loadScene function is used to load a new scene into the stage.voidThe loadWaitingHostRoom function loads the WaitingHostRoom scene.voidsetViewSharedData(ViewSharedData viewSharedData) The setViewSharedData function is used to set the viewSharedData variable.voidThe StartAsGuest function is called when the user clicks on the "Start as Guest" button.voidThe StartAsHost function is called when the user clicks on the "Start as Host" button.voidThe StartGame function is called when the user clicks on the "Start Game" button.booleanThe validIp function takes a string as an argument and returns true if the string is a valid IP address.booleanThe validName function checks to see if the name entered by the user is valid.booleanThe validPort function checks to see if the port number is valid.
-
Constructor Details
-
ConnectionController
public ConnectionController()The ConnectionController function is the controller for the ConnectionView.fxml file, which allows users to choose a dictionary from a list of dictionaries and connect to it. The function also contains an event handler that handles when the user clicks on "Connect" in order to connect them with their chosen dictionary. It also has an event handler that handles when the user clicks on "Cancel" in order to cancel out of this view and return back to MainMenuView.fxml without connecting with any dictionary at all (i.e., they will not be able to play any games). This function
-
-
Method Details
-
StartAsHost
The StartAsHost function is called when the user clicks on the "Start as Host" button. It checks if all the fields are valid, and if they are it initializes a host server with the port number that was entered by the user. It then connects to this server and loads up a waiting room for other players to join in on. If any of these fields were invalid, an error message will be displayed next to them.- Throws:
IOException
-
checkOrCreateCalculationServer
public void checkOrCreateCalculationServer()The checkOrCreateCalculationServer function checks if the calculation server is running. If it isn't, then it creates a new calculation server and starts it. -
StartAsGuest
The StartAsGuest function is called when the user clicks on the "Start as Guest" button. It checks if all the fields are valid, and if they are it connects to a server and loads a new scene where it waits for a host to start the game. If any of them aren't valid, then an error message appears next to that field.- Throws:
IOException
-
connectToServer
public void connectToServer()The connectToServer function is called when the user clicks on the "Connect" button. It takes in a String ip, an int port, and a String name from their respective text fields. It then creates a new Client object with those parameters and sets it as the playerClient in viewSharedData. Then it creates a new GameModelReceiver object with those parameters and sets that as gameModelReceiver in viewSharedData. -
validPort
The validPort function checks to see if the port number is valid.- Parameters:
port- port Check if the port number is valid- Returns:
- A boolean value
-
validIp
The validIp function takes a string as an argument and returns true if the string is a valid IP address.- Parameters:
ip- ip Check if the ip address is valid- Returns:
- True if the input string is a valid ip address
-
validName
The validName function checks to see if the name entered by the user is valid.- Parameters:
name- name Check if the name is valid- Returns:
- True if the name parameter is a valid name
-
loadScene
The loadScene function is used to load a new scene into the stage. It takes in a string that represents the name of the scene to be loaded, and then loads it. The function also initializes all controllers for each page, and sets their viewSharedData variable to this class's viewSharedData variable.- Parameters:
sceneName- sceneName Load the corresponding fxml file- Throws:
IOException
-
Back
The Back function is used to return the user to the main menu.- Throws:
IOException
-
StartGame
The StartGame function is called when the user clicks on the "Start Game" button. It loads a new scene, which is defined in StartGame.fxml and controlled by StartGameController.- Throws:
IOException
-
loadHostForm
The loadHostForm function is called when the user clicks on the "Host" button. It loads a new scene, which is the HostPage.fxml file, and sets it as the current scene.- Throws:
IOException
-
loadHomePage
The loadHomePage function is used to load the HomePage.fxml file into the main window of our application. This function is called when a user clicks on the "Home" button in our application's menu bar, and it will display all the information that we have stored about each student in our database. It also allows us to add new students, edit existing students' information, or delete any student from our database entirely.- Throws:
IOException
-
loadGuestForm
The loadGuestForm function is used to load the GuestPage.fxml file, which contains the GUI for a guest user. This function is called when a guest user clicks on the "Guest" button in the LoginPage.fxml file, and it loads up all of their information into an object that can be passed around throughout this program's various GUIs and controllers so that they can access their data at any time without having to re-enter it again.- Throws:
IOException
-
loadWaitingHostRoom
The loadWaitingHostRoom function loads the WaitingHostRoom scene.- Throws:
IOException