Class LoginFXMLController

java.lang.Object
it.polimi.ingsw.gc14.View.GUI.LoginFXMLController

public class LoginFXMLController extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    private final javafx.css.PseudoClass
    CSS pseudo-class applied to the active protocol label.
    private javafx.scene.image.ImageView
    Background image displayed behind the login form.
    private javafx.scene.control.Button
    Button that submits the login form.
    private javafx.scene.control.TextField
    Text field for the server IP address.
    private javafx.scene.control.TextField
    Text field for the player's username.
    private javafx.scene.control.TextField
    Text field for the desired number of players.
    Client controller used to initiate the connection.
    private javafx.scene.layout.VBox
    VBox containing the login form controls.
    private boolean
    true when RMI is selected; false for TCP.
    private javafx.scene.control.Label
    Label used to show error or success messages.
    private javafx.scene.control.Label
    Label for the RMI side of the protocol toggle.
    private javafx.scene.control.Label
    Label for the TCP side of the protocol toggle.
    private javafx.scene.layout.StackPane
    Toggle container for switching between RMI and TCP.
    private javafx.scene.layout.Region
    Sliding thumb inside the protocol toggle.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    connect(String nome, String ip, int numPlayers, String localInterface)
    Connects to the server using the selected protocol and transitions to the waiting state on success.
    void
    Initializes the scene: loads background, sets up animations, and binds input listeners.
    private void
    Validates form input and starts a background thread to connect to the server.
    void
    Injects the client controller into this FXML controller.
    void
    showError(ErrorType errorType)
    Displays an error from an ErrorType constant in the login form label.
    void
    Displays an arbitrary error message in the login form label.
    private void
    Displays a success message in green in the login form label.
    private void
    Toggles the selected protocol between RMI and TCP, animating the toggle thumb and updating label styles.
    void
    updateLoginButton(boolean enabled)
    Enables or disables the login button and updates its visual style.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • backgroundImage

      private javafx.scene.image.ImageView backgroundImage
      Background image displayed behind the login form.
    • campoNome

      private javafx.scene.control.TextField campoNome
      Text field for the player's username.
    • campoNumPlayers

      private javafx.scene.control.TextField campoNumPlayers
      Text field for the desired number of players.
    • campoIP

      private javafx.scene.control.TextField campoIP
      Text field for the server IP address.
    • btnAccedi

      private javafx.scene.control.Button btnAccedi
      Button that submits the login form.
    • labelErrore

      private javafx.scene.control.Label labelErrore
      Label used to show error or success messages.
    • formPanel

      private javafx.scene.layout.VBox formPanel
      VBox containing the login form controls.
    • protocolToggle

      private javafx.scene.layout.StackPane protocolToggle
      Toggle container for switching between RMI and TCP.
    • toggleThumb

      private javafx.scene.layout.Region toggleThumb
      Sliding thumb inside the protocol toggle.
    • labelRMI

      private javafx.scene.control.Label labelRMI
      Label for the RMI side of the protocol toggle.
    • labelTCP

      private javafx.scene.control.Label labelTCP
      Label for the TCP side of the protocol toggle.
    • isRMI

      private boolean isRMI
      true when RMI is selected; false for TCP.
    • controller

      private ClientController controller
      Client controller used to initiate the connection.
    • activeProtocolPseudo

      private final javafx.css.PseudoClass activeProtocolPseudo
      CSS pseudo-class applied to the active protocol label.
  • Constructor Details

    • LoginFXMLController

      public LoginFXMLController()
  • Method Details

    • setController

      public void setController(ClientController controller)
      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 - true to enable the button, false to disable it.
    • connect

      private void connect(String nome, String ip, int numPlayers, String localInterface)
      Connects to the server using the selected protocol and transitions to the waiting state on success.
    • showError

      public void showError(ErrorType errorType)
      Displays an error from an ErrorType constant in the login form label.
      Parameters:
      errorType - the error to display.
    • showError

      public void showError(String msg)
      Displays an arbitrary error message in the login form label.
      Parameters:
      msg - the error message to display.
    • showSuccess

      private void showSuccess(String msg)
      Displays a success message in green in the login form label.