Class GUI

java.lang.Object
javafx.application.Application
it.polimi.ingsw.gc14.View.GUI.GUI
All Implemented Interfaces:
IView

public class GUI extends javafx.application.Application implements IView
JavaFX-based GUI implementation of IView.

Manages the primary stage and switches between the login, totem choice, main game, and leaderboard scenes based on the current game state.

  • Nested Class Summary

    Nested classes/interfaces inherited from class javafx.application.Application

    javafx.application.Application.Parameters
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    When true, the app re-enters fullscreen automatically after ESC is pressed.
    Client controller injected before JavaFX startup.
    Controller for the leaderboard FXML scene.
    Controller for the login FXML scene.
    Controller for the main FXML scene.
    Controller for the totem FXML scene.
    private boolean
    Guards against overlapping fade transitions.
    private javafx.scene.Scene
    The end-of-game leaderboard scene.
    private javafx.fxml.FXMLLoader
    FXML loader for the leaderboard scene.
    private javafx.fxml.FXMLLoader
    FXML loader for the login scene.
    private javafx.fxml.FXMLLoader
    FXML loader for the main game scene.
    private javafx.fxml.FXMLLoader
    FXML loader for the totem selection scene.
    private javafx.scene.Scene
    The login scene.
    private javafx.scene.Scene
    The main game scene.
    private MiniModel
    Latest mini model received from the server.
    private javafx.stage.Stage
    The primary JavaFX stage.
    private javafx.scene.Scene
    The totem selection scene.

    Fields inherited from class javafx.application.Application

    STYLESHEET_CASPIAN, STYLESHEET_MODENA
  • Constructor Summary

    Constructors
    Constructor
    Description
    GUI()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    fadeToScene(javafx.scene.Scene newScene)
    Performs a black-overlay crossfade from the current scene to newScene.
    void
    Re-renders the GUI on the JavaFX application thread, switching to the appropriate scene based on the current game stage.
    void
    Injects the client controller into this GUI.
    void
    setModel(MiniModel miniModel)
    Updates the local mini model reference used by the GUI.
    void
    showError(ErrorType error, String message)
    Displays an error on the JavaFX application thread.
    void
    start(javafx.stage.Stage stage)
    JavaFX entry point: loads all FXML scenes, wires up controllers, configures fullscreen behavior, and shows the login scene.
    private void
    wrapScene(javafx.scene.Scene scene)
    Wraps the current root of scene in a StackPane so that fade overlay rectangles can be layered over it during scene transitions.

    Methods inherited from class javafx.application.Application

    getHostServices, getParameters, getUserAgentStylesheet, init, launch, launch, notifyPreloader, setUserAgentStylesheet, stop

    Methods inherited from class Object

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

    • primaryStage

      private javafx.stage.Stage primaryStage
      The primary JavaFX stage.
    • miniModel

      private volatile MiniModel miniModel
      Latest mini model received from the server.
    • loaderLogin

      private javafx.fxml.FXMLLoader loaderLogin
      FXML loader for the login scene.
    • loginScene

      private javafx.scene.Scene loginScene
      The login scene.
    • controllerLogin

      private LoginFXMLController controllerLogin
      Controller for the login FXML scene.
    • loaderTotem

      private javafx.fxml.FXMLLoader loaderTotem
      FXML loader for the totem selection scene.
    • totemScene

      private javafx.scene.Scene totemScene
      The totem selection scene.
    • controllerTotem

      private TotemFXMLController controllerTotem
      Controller for the totem FXML scene.
    • loaderMain

      private javafx.fxml.FXMLLoader loaderMain
      FXML loader for the main game scene.
    • mainScene

      private javafx.scene.Scene mainScene
      The main game scene.
    • controllerMain

      private MainFXMLController controllerMain
      Controller for the main FXML scene.
    • loaderLeaderboard

      private javafx.fxml.FXMLLoader loaderLeaderboard
      FXML loader for the leaderboard scene.
    • leaderboardScene

      private javafx.scene.Scene leaderboardScene
      The end-of-game leaderboard scene.
    • controllerLeaderboard

      private LeaderboardFXMLController controllerLeaderboard
      Controller for the leaderboard FXML scene.
    • controller

      private ClientController controller
      Client controller injected before JavaFX startup.
    • autoReenterFullscreen

      private boolean autoReenterFullscreen
      When true, the app re-enters fullscreen automatically after ESC is pressed.
    • isFading

      private boolean isFading
      Guards against overlapping fade transitions.
  • Constructor Details

    • GUI

      public GUI()
  • Method Details

    • start

      public void start(javafx.stage.Stage stage) throws Exception
      JavaFX entry point: loads all FXML scenes, wires up controllers, configures fullscreen behavior, and shows the login scene.
      Specified by:
      start in class javafx.application.Application
      Parameters:
      stage - the primary stage provided by the JavaFX runtime.
      Throws:
      Exception - if any FXML resource cannot be loaded.
    • setModel

      public void setModel(MiniModel miniModel)
      Updates the local mini model reference used by the GUI.
      Specified by:
      setModel in interface IView
      Parameters:
      miniModel - the latest mini model received from the server.
    • setController

      public void setController(ClientController controller)
      Injects the client controller into this GUI.
      Parameters:
      controller - the client controller to use.
    • render

      public void render()
      Re-renders the GUI on the JavaFX application thread, switching to the appropriate scene based on the current game stage.
      Specified by:
      render in interface IView
    • wrapScene

      private void wrapScene(javafx.scene.Scene scene)
      Wraps the current root of scene in a StackPane so that fade overlay rectangles can be layered over it during scene transitions.
      Parameters:
      scene - the scene whose root to wrap.
    • fadeToScene

      private void fadeToScene(javafx.scene.Scene newScene)
      Performs a black-overlay crossfade from the current scene to newScene. No-op if already fading or if newScene is already displayed.
      Parameters:
      newScene - the scene to transition to.
    • showError

      public void showError(ErrorType error, String message)
      Displays an error on the JavaFX application thread.

      If the server crashed, returns to the login scene and re-enables the login button. Otherwise, delegates to the active scene's error display.

      Specified by:
      showError in interface IView
      Parameters:
      error - the error type.
      message - a human-readable description of the error.