From 09a8d00d33282b12e92c2875f68ebce2449c8834 Mon Sep 17 00:00:00 2001 From: rubenpirreram Date: Sun, 24 May 2026 16:55:04 +0200 Subject: [PATCH] Fixed?: maximize and no resizable, and popup --- .../it/polimi/ingsw/gc14/View/GUI/GUI.java | 10 +++++-- .../gc14/View/GUI/MainFXMLController.java | 30 +++++++++---------- src/main/resources/GUIScene/main.fxml | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) 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 65a19c1..550d582 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 @@ -49,7 +49,6 @@ public class GUI extends Application implements IView { @Override public void start(Stage stage) throws Exception { this.primaryStage = stage; - primaryStage.setResizable(false); loaderLogin = new FXMLLoader(getClass().getResource("/GUIScene/login.fxml")); loginScene = new Scene(loaderLogin.load()); controllerLogin = loaderLogin.getController(); @@ -81,7 +80,6 @@ public class GUI extends Application implements IView { showLogin(); primaryStage.setTitle("Mesos"); - primaryStage.setMaximized(true); primaryStage.setOnCloseRequest(e -> { Platform.exit(); System.exit(0); @@ -113,8 +111,14 @@ public class GUI extends Application implements IView { primaryStage.setScene(leaderboardScene); controllerLeaderboard.render(); } else { + double w = primaryStage.getWidth(); + double h = primaryStage.getHeight(); primaryStage.setScene(mainScene); - controllerMain.initPopup(mainScene); + primaryStage.setWidth(w); + primaryStage.setHeight(h); + primaryStage.setMinHeight(h); + primaryStage.setMinWidth(w); + primaryStage.setResizable(false); controllerMain.render(); } } diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java index e762e21..3c6efce 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java @@ -78,13 +78,23 @@ public class MainFXMLController { popup = new Popup(); mainHBox.sceneProperty().addListener((obs, oldScene, newScene) -> { if (newScene != null) { - newScene.getRoot().applyCss(); newScene.addEventFilter(MouseEvent.MOUSE_PRESSED, e -> { if (popup.isShowing()) popup.hide(); }); + newScene.getRoot().applyCss(); + newScene.windowProperty().addListener((o2, ow, nw) -> { + if (nw != null) { + nw.focusedProperty().addListener((o3, wf, nf) -> { + if (!nf) popup.hide(); + }); + } + }); + } + else { + popup.hide(); } }); - + initPopup(); renderBackground(); isError=false; } @@ -272,7 +282,7 @@ public class MainFXMLController { private void renderPlayer(Player player,VBox target) { VBox card = new VBox(3); - VBox.setMargin(card, new Insets(0,15,0,15)); + VBox.setMargin(card, new Insets(8,15,8,15)); card.getStyleClass().add("player-card"); card.setPadding(new Insets(4)); @@ -544,7 +554,7 @@ public class MainFXMLController { addHoverZoom(skipBtn); addHoverZoom(detailsBtn); - VBox playerList = new VBox(17); + VBox playerList = new VBox(); playerList.setFillWidth(true); for (Player p : controller.miniModel.players.values()) { renderPlayer(p, playerList); @@ -553,7 +563,7 @@ public class MainFXMLController { } // ==== POPUP ==== - public void initPopup(Scene mainScene) { + public void initPopup() { popupCards = new HBox(10); popupCards.setAlignment(Pos.CENTER); popupCards.setPadding(new Insets(10)); @@ -572,16 +582,6 @@ public class MainFXMLController { popup.getScene().setFill(Color.TRANSPARENT); } }); - mainScene.getWindow().focusedProperty().addListener((obs, wasFocused, isNowFocused) -> { - if(!isNowFocused) - popup.hide(); - }); - mainScene.getWindow().sceneProperty().addListener((obs, oldScene, newScene) -> { - if(newScene!=mainScene) - { - popup.hide(); - } - }); } private void showPopup() { diff --git a/src/main/resources/GUIScene/main.fxml b/src/main/resources/GUIScene/main.fxml index e621d4c..324e2ef 100644 --- a/src/main/resources/GUIScene/main.fxml +++ b/src/main/resources/GUIScene/main.fxml @@ -19,7 +19,7 @@ fillWidth="false" maxHeight="Infinity" maxWidth="Infinity" - HBox.hgrow="NEVER"> + HBox.hgrow="ALWAYS">