Refactor: improve CasinoGameUI structure

Refs #52
This commit is contained in:
Julian Kropff
2026-04-10 20:34:49 +02:00
parent 644c3e93fc
commit a2d176f13c
@@ -1,5 +1,6 @@
package ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui; package ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui;
import ch.unibas.dmi.dbis.cs108.casono.client.network.ClientService;
import java.io.IOException; import java.io.IOException;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
@@ -9,21 +10,27 @@ import javafx.stage.Stage;
/** /**
* Main class for the Casono Game UI. * Main class for the Casono Game UI.
* *
* <p>Starts the JavaFX application, loads the graphical user interface from the FXML file, and * Starts the JavaFX application, loads the graphical user interface from the FXML file, and
* initializes the main stage for the game. * initializes the main stage for the game.
* *
* <p>Tasks: - Loads the FXML interface "/ui-structure/Casinogameui.fxml". - Loads the application * Tasks: - Loads the FXML interface "/ui-structure/Casinogameui.fxml". - Loads the application
* icon from "/images/logoinverted.png". - Starts the application in full-screen mode. * icon from "/images/logoinverted.png". - Starts the application in full-screen mode.
*/ */
public class CasinoGameUI extends Application { public class CasinoGameUI extends Application {
private static ClientService clientService;
private static final int DEFAULT_WIDTH = 1200;
private static final int DEFAULT_HEIGHT = 800;
/** default constructor */ /** default constructor */
public CasinoGameUI() { public CasinoGameUI() {
// default no-arg constructor // default no-arg constructor
} }
private static final int DEFAULT_WIDTH = 1200; public static void setClientService(ClientService clientService) {
private static final int DEFAULT_HEIGHT = 800; CasinoGameUI.clientService = clientService;
}
/** /**
* Starts the main stage of the application. * Starts the main stage of the application.
@@ -36,7 +43,7 @@ public class CasinoGameUI extends Application {
FXMLLoader fxmlLoader = FXMLLoader fxmlLoader =
new FXMLLoader(CasinoGameUI.class.getResource("/ui-structure/Casinogameui.fxml")); new FXMLLoader(CasinoGameUI.class.getResource("/ui-structure/Casinogameui.fxml"));
Scene scene = new Scene(fxmlLoader.load(), DEFAULT_WIDTH, DEFAULT_HEIGHT); Scene scene = new Scene(fxmlLoader.load(), DEFAULT_WIDTH, DEFAULT_HEIGHT);
stage.setTitle("Casono (GAME)"); stage.setTitle("Casono");
String iconPath = getClass().getResource("/images/logoinverted.png").toExternalForm(); String iconPath = getClass().getResource("/images/logoinverted.png").toExternalForm();
stage.getIcons().add(new javafx.scene.image.Image(iconPath)); stage.getIcons().add(new javafx.scene.image.Image(iconPath));