diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java index 88fe570..ac421ff 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java @@ -9,6 +9,8 @@ import javafx.application.Platform; import javafx.fxml.FXMLLoader; import javafx.geometry.Rectangle2D; import javafx.scene.Scene; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyCombination; import javafx.stage.Screen; import javafx.stage.Stage; @@ -37,6 +39,7 @@ public class GUI extends Application implements IView { private ClientController controller; + private boolean autoReenterFullscreen = true; @Override @@ -83,7 +86,21 @@ public class GUI extends Application implements IView { primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); primaryStage.fullScreenProperty().addListener((obs, was, isNow) -> { - if (!isNow) Platform.runLater(() -> primaryStage.setFullScreen(true)); + if (!isNow && autoReenterFullscreen) { + Platform.runLater(() -> primaryStage.setFullScreen(true)); + } + }); + + primaryStage.addEventFilter(KeyEvent.KEY_PRESSED, e -> { + if (e.getCode() == KeyCode.ESCAPE) { + autoReenterFullscreen = false; + primaryStage.setFullScreen(false); + e.consume(); + } else if (e.getCode() == KeyCode.F11) { + autoReenterFullscreen = true; + primaryStage.setFullScreen(true); + e.consume(); + } }); primaryStage.setTitle("Mesos"); @@ -130,6 +147,7 @@ public class GUI extends Application implements IView { public void showError(ErrorType error,String message) { Platform.runLater(() -> { if (error == ErrorType.SERVER_CRASHED) { + controllerLogin.updateLoginButton(true); primaryStage.setScene(loginScene); controllerLogin.showError(error); } else {