diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/IntroVideoPlayer.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/IntroVideoPlayer.java index 2e18c1e..b5e87c5 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/IntroVideoPlayer.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/IntroVideoPlayer.java @@ -6,6 +6,7 @@ import javafx.application.Application; import javafx.application.Platform; import javafx.geometry.Rectangle2D; import javafx.scene.Scene; +import javafx.scene.input.KeyCode; import javafx.scene.layout.StackPane; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; @@ -57,6 +58,16 @@ public class IntroVideoPlayer extends Application { stage.setFullScreen(true); stage.setFullScreenExitHint(""); stage.setScene(scene); + + // Add F11 fullscreen toggle + scene.setOnKeyPressed( + event -> { + if (event.getCode() == KeyCode.F11) { + stage.setFullScreen(!stage.isFullScreen()); + event.consume(); + } + }); + stage.show(); mediaPlayer.setOnEndOfMedia(this::onVideoEnd); diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/CasinoGameUI.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/CasinoGameUI.java index d9a7a1f..09086ec 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/CasinoGameUI.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/CasinoGameUI.java @@ -14,6 +14,7 @@ import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.input.KeyCode; import javafx.stage.Stage; /** @@ -83,7 +84,22 @@ public class CasinoGameUI extends Application { */ @Override public void start(Stage stage) throws IOException { + ensureClientService(); + String effectiveUsername = determineEffectiveUsername(); + logStartInfo(effectiveUsername); + FXMLLoader fxmlLoader = + new FXMLLoader(CasinoGameUI.class.getResource("/ui-structure/Casinogameui.fxml")); + Parent root = fxmlLoader.load(); + CasinoGameController controller = fxmlLoader.getController(); + + configureController(controller, effectiveUsername); + Scene scene = new Scene(root, DEFAULT_WIDTH, DEFAULT_HEIGHT); + configureStage(stage, scene, controller); + controller.start(); + } + + private void ensureClientService() { if (clientService == null) { clientService = ClientApp.getSharedClientService(); } @@ -93,18 +109,21 @@ public class CasinoGameUI extends Application { + "Call CasinoGameUI.setClientService(...)" + " or start via ClientApp with a shared connection."); } + } + private String determineEffectiveUsername() { String effectiveUsername = normalize(username); - if (effectiveUsername == null) { effectiveUsername = normalize(ClientApp.getSharedUsername()); } - if (effectiveUsername == null) { effectiveUsername = "Guest-" + UUID.randomUUID().toString().substring(0, GUEST_ID_LENGTH); } + return effectiveUsername; + } + private void logStartInfo(String effectiveUsername) { LOG.info( "CasinoGameUI starting: effectiveUsername='" + effectiveUsername @@ -114,12 +133,10 @@ public class CasinoGameUI extends Application { + ClientApp.getSharedUsername() + "', hasClientService=" + (clientService != null)); + } - FXMLLoader fxmlLoader = - new FXMLLoader(CasinoGameUI.class.getResource("/ui-structure/Casinogameui.fxml")); - Parent root = fxmlLoader.load(); - CasinoGameController controller = fxmlLoader.getController(); - + private void configureController(CasinoGameController controller, String effectiveUsername) + throws IOException { if (lobbyId <= 0) { throw new IllegalStateException("CasinoGameUI: lobbyId must be set before start()"); } @@ -127,7 +144,6 @@ public class CasinoGameUI extends Application { GameClient gameClient = new GameClient(clientService, lobbyId); GameService gameService = new GameService(gameClient); controller.setGameService(gameService); - controller.setMyPlayerId(PlayerId.of(effectiveUsername)); controller.setChatContext(effectiveUsername, clientService, lobbyId); @@ -139,20 +155,24 @@ public class CasinoGameUI extends Application { } controller.startChat(chatController); + } - Scene scene = new Scene(root, DEFAULT_WIDTH, DEFAULT_HEIGHT); + private void configureStage(Stage stage, Scene scene, CasinoGameController controller) { stage.setTitle("Casono"); - String iconPath = getClass().getResource("/images/logoinverted.png").toExternalForm(); stage.getIcons().add(new javafx.scene.image.Image(iconPath)); - stage.setScene(scene); stage.setFullScreen(true); stage.setFullScreenExitHint(""); stage.setOnHidden(e -> controller.stop()); + scene.setOnKeyPressed( + event -> { + if (event.getCode() == KeyCode.F11) { + stage.setFullScreen(!stage.isFullScreen()); + event.consume(); + } + }); stage.show(); - - controller.start(); } /** diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/TaskbarController.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/TaskbarController.java index aee6ebf..15b7ed3 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/TaskbarController.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/gameui/gameuicomponents/TaskbarController.java @@ -1663,6 +1663,17 @@ public class TaskbarController { newStage.getIcons().add(icon); newStage.setScene(scene); newStage.setFullScreen(true); + newStage.setFullScreenExitHint(""); + + // Add F11 fullscreen toggle + scene.setOnKeyPressed( + event -> { + if (event.getCode() == KeyCode.F11) { + newStage.setFullScreen(!newStage.isFullScreen()); + event.consume(); + } + }); + newStage.show(); } catch (Exception e) { LOGGER.error("Error: starting the lobby UI: {}", e.getMessage(), e); diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/Casinomainui.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/Casinomainui.java index 36baee3..d348b02 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/Casinomainui.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui/Casinomainui.java @@ -6,6 +6,7 @@ import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; +import javafx.scene.input.KeyCode; import javafx.stage.Stage; /** @@ -50,6 +51,16 @@ public class Casinomainui extends Application { stage.setScene(scene); stage.setFullScreen(true); stage.setFullScreenExitHint(""); + + // Add F11 fullscreen toggle + scene.setOnKeyPressed( + event -> { + if (event.getCode() == KeyCode.F11) { + stage.setFullScreen(!stage.isFullScreen()); + event.consume(); + } + }); + stage.show(); }