Class LoginFXMLController
java.lang.Object
it.polimi.ingsw.gc14.View.GUI.LoginFXMLController
FXML controller for the login scene.
Handles username/IP/player-count input, protocol selection (TCP/RMI), and initiates the connection to the server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final javafx.css.PseudoClassCSS pseudo-class applied to the active protocol label.private javafx.scene.image.ImageViewBackground image displayed behind the login form.private javafx.scene.control.ButtonButton that submits the login form.private javafx.scene.control.TextFieldText field for the server IP address.private javafx.scene.control.TextFieldText field for the player's username.private javafx.scene.control.TextFieldText field for the desired number of players.private ClientControllerClient controller used to initiate the connection.private javafx.scene.layout.VBoxVBox containing the login form controls.private booleantruewhen RMI is selected;falsefor TCP.private javafx.scene.control.LabelLabel used to show error or success messages.private javafx.scene.control.LabelLabel for the RMI side of the protocol toggle.private javafx.scene.control.LabelLabel for the TCP side of the protocol toggle.private javafx.scene.layout.StackPaneToggle container for switching between RMI and TCP.private javafx.scene.layout.RegionSliding thumb inside the protocol toggle. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidConnects to the server using the selected protocol and transitions to the waiting state on success.voidInitializes the scene: loads background, sets up animations, and binds input listeners.private voidValidates form input and starts a background thread to connect to the server.voidsetController(ClientController controller) Injects the client controller into this FXML controller.voidDisplays an error from anErrorTypeconstant in the login form label.voidDisplays an arbitrary error message in the login form label.private voidshowSuccess(String msg) Displays a success message in green in the login form label.private voidToggles the selected protocol between RMI and TCP, animating the toggle thumb and updating label styles.voidupdateLoginButton(boolean enabled) Enables or disables the login button and updates its visual style.
-
Field Details
-
backgroundImage
private javafx.scene.image.ImageView backgroundImageBackground image displayed behind the login form. -
campoNome
private javafx.scene.control.TextField campoNomeText field for the player's username. -
campoNumPlayers
private javafx.scene.control.TextField campoNumPlayersText field for the desired number of players. -
campoIP
private javafx.scene.control.TextField campoIPText field for the server IP address. -
btnAccedi
private javafx.scene.control.Button btnAccediButton that submits the login form. -
labelErrore
private javafx.scene.control.Label labelErroreLabel used to show error or success messages. -
formPanel
private javafx.scene.layout.VBox formPanelVBox containing the login form controls. -
protocolToggle
private javafx.scene.layout.StackPane protocolToggleToggle container for switching between RMI and TCP. -
toggleThumb
private javafx.scene.layout.Region toggleThumbSliding thumb inside the protocol toggle. -
labelRMI
private javafx.scene.control.Label labelRMILabel for the RMI side of the protocol toggle. -
labelTCP
private javafx.scene.control.Label labelTCPLabel for the TCP side of the protocol toggle. -
isRMI
private boolean isRMItruewhen RMI is selected;falsefor TCP. -
controller
Client controller used to initiate the connection. -
activeProtocolPseudo
private final javafx.css.PseudoClass activeProtocolPseudoCSS pseudo-class applied to the active protocol label.
-
-
Constructor Details
-
LoginFXMLController
public LoginFXMLController()
-
-
Method Details
-
setController
Injects the client controller into this FXML controller.- Parameters:
controller- the client controller to use.
-
initialize
public void initialize()Initializes the scene: loads background, sets up animations, and binds input listeners. -
switchProtocol
private void switchProtocol()Toggles the selected protocol between RMI and TCP, animating the toggle thumb and updating label styles. -
onAccediClick
private void onAccediClick()Validates form input and starts a background thread to connect to the server. -
updateLoginButton
public void updateLoginButton(boolean enabled) Enables or disables the login button and updates its visual style.- Parameters:
enabled-trueto enable the button,falseto disable it.
-
connect
-
showError
-
showError
Displays an arbitrary error message in the login form label.- Parameters:
msg- the error message to display.
-
showSuccess
Displays a success message in green in the login form label.
-