From c65df0fd370f2f5e7188bea7a6e4102339673937 Mon Sep 17 00:00:00 2001 From: Per Eric Trapnes Date: Fri, 15 May 2026 23:26:22 +0200 Subject: [PATCH] fix major popup bugs with pane in desktop view --- .claude/settings.local.json | 0 .claude/worktrees/nostalgic-liskov-9129de | 1 - .../gruppe42/Controller/PopupsController.java | 26 ++++--- .../DesktopViewController.java | 45 ++--------- .../gruppe42/View/Apps/AppStoreApp.java | 17 +++- .../idatt2003/gruppe42/View/Apps/MailApp.java | 62 ++++++++++++++- .../gruppe42/View/Apps/WarningApp.java | 17 ++-- .../idi/idatt2003/gruppe42/View/Popup.java | 17 ++-- .../gruppe42/View/Views/DesktopView.java | 77 ++++++++++++------- src/main/resources/css/desktop.css | 1 - 10 files changed, 164 insertions(+), 99 deletions(-) delete mode 100644 .claude/settings.local.json delete mode 160000 .claude/worktrees/nostalgic-liskov-9129de diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index e69de29..0000000 diff --git a/.claude/worktrees/nostalgic-liskov-9129de b/.claude/worktrees/nostalgic-liskov-9129de deleted file mode 160000 index 6064d35..0000000 --- a/.claude/worktrees/nostalgic-liskov-9129de +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6064d35b7a76e13c2733d65f3152f2433881bb17 diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java index 292d091..57231d7 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java @@ -6,10 +6,9 @@ import edu.ntnu.idi.idatt2003.gruppe42.View.Popup; import java.util.List; import java.util.Optional; - +import javafx.geometry.Point2D; import javafx.scene.control.Button; import javafx.scene.layout.Pane; -import javafx.scene.layout.StackPane; /** Manages popup behavior. */ public final class PopupsController { @@ -59,22 +58,29 @@ public void bindOpenButton(Button button, App type) { } private void makeDraggable(Popup popup) { - StackPane root = popup.getRoot(); + Pane root = popup.getRoot(); double[] offset = new double[2]; - double[] maxXY = new double[2]; popup.getHeader().setOnMousePressed(event -> { - offset[0] = event.getSceneX() - root.getLayoutX(); - offset[1] = event.getSceneY() - root.getLayoutY(); if (root.getParent() instanceof Pane parent) { - maxXY[0] = parent.getWidth() - root.getWidth(); - maxXY[1] = parent.getHeight() - root.getHeight(); + Point2D local = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); + offset[0] = local.getX() - root.getLayoutX(); + offset[1] = local.getY() - root.getLayoutY(); } + event.consume(); }); popup.getHeader().setOnMouseDragged(event -> { - root.setLayoutX(Math.max(0, Math.min(event.getSceneX() - offset[0], maxXY[0]))); - root.setLayoutY(Math.max(0, Math.min(event.getSceneY() - offset[1], maxXY[1]))); + if (root.getParent() instanceof Pane parent) { + Point2D local = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); + double newX = local.getX() - offset[0]; + double newY = local.getY() - offset[1]; + double maxX = parent.getWidth() - root.getWidth(); + double maxY = parent.getHeight() - root.getHeight(); + root.setLayoutX(Math.max(0, Math.min(newX, maxX))); + root.setLayoutY(Math.max(0, Math.min(newY, maxY))); + } + event.consume(); }); } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java index c51015b..621fe43 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java @@ -38,7 +38,7 @@ import javafx.scene.input.ClipboardContent; import javafx.scene.input.Dragboard; import javafx.scene.input.TransferMode; -import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; @@ -55,7 +55,7 @@ public final class DesktopViewController { private final TimeAndWeatherController timeAndWeatherController; private final MarketController marketController; private final StockAppController stockAppController; - private final SettingsAppController settingsAppController; // ← added + private final SettingsAppController settingsAppController; private final WeekendRapportApp weekendRapportApp = new WeekendRapportApp(); private final WarningApp warningApp = new WarningApp(); private final GameOverApp gameOverApp = new GameOverApp(); @@ -97,7 +97,7 @@ public DesktopViewController( settingsAppController.setLoggedIn(true); settingsAppController.setOnGradientChanged(cfg -> - desktopView.getRoot().setStyle( + desktopView.getDesktopPane().setStyle( SettingsApp.buildCssGradient(cfg.colorA(), cfg.colorB(), cfg.direction()))); settingsAppController.setOnPlayerNameChanged(name -> player.setName(name)); @@ -112,7 +112,6 @@ public DesktopViewController( popups.add(newsApp); popups.add(bankApp); - this.popupsController = popupsController; this.popupsController.addPopups(popups); @@ -126,11 +125,13 @@ public DesktopViewController( this.desktopView = new DesktopView(this); setupListeners(); - BorderPane root = desktopView.getRoot(); + + Pane root = desktopView.getRoot(); + Pane overlay = desktopView.getPopupOverlay(); for (Popup p : popupsController.getPopups()) { desktopView.registerPopup(p.getRoot()); - root.getChildren().add(p.getRoot()); + overlay.getChildren().add(p.getRoot()); } weekendRapportApp.centerInParent(); @@ -141,7 +142,7 @@ public DesktopViewController( desktopView.registerModal(ModalLayer.WARNING, warningApp.getRoot()); desktopView.registerModal(ModalLayer.GAME_OVER, gameOverApp.getRoot()); - root.getChildren().addAll( + overlay.getChildren().addAll( desktopView.getOverlay(ModalLayer.RAPPORT), weekendRapportApp.getRoot(), desktopView.getOverlay(ModalLayer.WARNING), warningApp.getRoot(), desktopView.getOverlay(ModalLayer.GAME_OVER), gameOverApp.getRoot() @@ -169,7 +170,6 @@ public DesktopViewController( stockAppController.setWeekend(startDay == SATURDAY_INDEX || startDay == SUNDAY_INDEX); } - private void setupListeners() { timeAndWeatherController.hourProperty().addListener((o, ov, nv) -> desktopView.updateClock(timeAndWeatherController.getTimeString())); @@ -191,7 +191,6 @@ private void setupListeners() { player.getNameProperty().addListener((obs, ov, nv) -> desktopView.updatePlayerName(nv)); - // Initial sync desktopView.updateClock(timeAndWeatherController.getTimeString()); String startDay = timeAndWeatherController.getDayOfWeekString(); desktopView.updateDay(startDay, startDay.equals("SUN")); @@ -201,9 +200,6 @@ private void setupListeners() { desktopView.updatePlayerName(player.getName()); } - /** - * Shows the weekend rapport at the end of the week. - */ private void showWeekendRapport() { int week = timeAndWeatherController.weekIndexProperty().get(); List transactions = player.getTransactionArchive().getTransactions(week); @@ -218,9 +214,6 @@ private void showWeekendRapport() { desktopView.enterLayer(ModalLayer.RAPPORT); } - /** - * Wires the weekend rapport buttons. - */ private void wireWeekendRapport() { weekendRapportApp.getContinueButton().setOnAction(event -> { weekendRapportApp.getRoot().setVisible(false); @@ -229,10 +222,6 @@ private void wireWeekendRapport() { }); } - - /** - * Handles the request to advance to the next week. - */ private void handleAdvanceWeek() { if (player.isInDebt()) { showDebtWarning(); @@ -241,16 +230,11 @@ private void handleAdvanceWeek() { } } - /** - * Performs the actual week advancement. - */ private void doAdvanceWeek() { marketController.advanceWeek(); timeAndWeatherController.advanceWeek(); } - - /** Shows debt warning. */ private void showDebtWarning() { warningApp.configure( "💔", @@ -272,7 +256,6 @@ private void showDebtWarning() { showWarning(); } - /** Shows market closed warning. */ private void showMarketClosedWarning() { warningApp.configure( "🔒", @@ -284,7 +267,6 @@ private void showMarketClosedWarning() { showWarning(); } - /** Shows insufficient funds warning. */ private void showInsufficientFundsWarning() { warningApp.configure( "\uD83E\uDD7A", @@ -296,26 +278,21 @@ private void showInsufficientFundsWarning() { showWarning(); } - /** Displays warning modal. */ private void showWarning() { warningApp.show(); desktopView.enterLayer(ModalLayer.WARNING); } - /** Dismisses the warning. */ private void dismissWarning() { warningApp.getRoot().setVisible(false); desktopView.exitLayer(ModalLayer.WARNING); } - - /** Shows the game over screen. */ private void showGameOver() { gameOverApp.show(); desktopView.enterLayer(ModalLayer.GAME_OVER); } - /** Wires game over buttons. */ private void wireGameOver() { gameOverApp.getStartOverButton().setOnAction(event -> { if (onGameOver != null) onGameOver.run(); @@ -327,13 +304,10 @@ public void setOnGameOver(final Runnable callback) { this.onGameOver = callback; } - - /** Handles logout action. */ private void handleLogout() { if (onGameOver != null) onGameOver.run(); } - /** Creates an app button. */ public Button createAppButton(final App type) { Button button = new Button(type.getDisplayName()); @@ -394,7 +368,6 @@ public void configureCellAsDropTarget(final StackPane cell) { }); } - /** @return the player model. */ public Player getPlayer() { return player; @@ -410,8 +383,6 @@ public DesktopView getDesktopView() { return desktopView; } - - /** Calculates net income. */ private static BigDecimal calculateNetIncome(final List transactions) { BigDecimal net = BigDecimal.ZERO; for (Transaction t : transactions) { diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/AppStoreApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/AppStoreApp.java index 9eeeaad..a0629c4 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/AppStoreApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/AppStoreApp.java @@ -2,6 +2,17 @@ import edu.ntnu.idi.idatt2003.gruppe42.Model.App; import edu.ntnu.idi.idatt2003.gruppe42.View.Popup; +import javafx.geometry.Insets; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; +import javafx.scene.layout.HBox; +import javafx.scene.control.Button; +import javafx.scene.layout.Priority; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import javafx.scene.paint.Color; +import javafx.geometry.Pos; +import javafx.scene.shape.Rectangle; /** * A popup for the app store app. @@ -12,8 +23,10 @@ public class AppStoreApp extends Popup { * Constructs a new app store popup. */ public AppStoreApp() { - super(400, 300, 100, 100, App.APPSTORE); - // Add App store specific content here + super(500, 450, 100, 100, App.APPSTORE); + buildContent(); } + private void buildContent() { + } } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java index b1a2609..b11ed7a 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java @@ -2,14 +2,72 @@ import edu.ntnu.idi.idatt2003.gruppe42.Model.App; import edu.ntnu.idi.idatt2003.gruppe42.View.Popup; +import javafx.geometry.Insets; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; +import javafx.scene.layout.HBox; +import javafx.scene.paint.Color; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import javafx.geometry.Pos; +import javafx.scene.shape.Circle; /** Mail app popup. */ public class MailApp extends Popup { /** Constructs the Mail app. */ public MailApp() { - super(400, 300, 140, 140, App.MAIL); - // Add Mail specific content here + super(450, 400, 140, 140, App.MAIL); + buildContent(); + } + + private void buildContent() { + content.setPadding(new Insets(20)); + content.setSpacing(15); + + Label title = new Label("Inbox"); + title.setFont(Font.font("System", FontWeight.BOLD, 22)); + content.getChildren().add(title); + + VBox mailList = new VBox(10); + mailList.getChildren().addAll( + createMailItem("System", "Welcome to the Matrix", "Your journey begins now. Stay focused.", "10:24 AM"), + createMailItem("HR", "Onboarding Documents", "Please sign the attached NDA.", "Yesterday"), + createMailItem("Bank", "Account Security Alert", "A new login was detected from Dubai.", "2 days ago") + ); + content.getChildren().add(mailList); + } + + private VBox createMailItem(String sender, String subject, String preview, String time) { + VBox item = new VBox(5); + item.setPadding(new Insets(12)); + item.setStyle("-fx-background-color: #ffffff; -fx-border-color: #eeeeee; -fx-border-radius: 8; -fx-background-radius: 8;"); + + HBox top = new HBox(10); + top.setAlignment(Pos.CENTER_LEFT); + + Circle avatar = new Circle(15, Color.web("#007AFF")); + Label senderLabel = new Label(sender); + senderLabel.setFont(Font.font("System", FontWeight.BOLD, 14)); + + javafx.scene.layout.Region spacer = new javafx.scene.layout.Region(); + HBox.setHgrow(spacer, javafx.scene.layout.Priority.ALWAYS); + + Label timeLabel = new Label(time); + timeLabel.setTextFill(Color.GRAY); + timeLabel.setFont(Font.font(12)); + + top.getChildren().addAll(avatar, senderLabel, spacer, timeLabel); + + Label subLabel = new Label(subject); + subLabel.setFont(Font.font("System", FontWeight.MEDIUM, 13)); + + Label prevLabel = new Label(preview); + prevLabel.setTextFill(Color.GRAY); + prevLabel.setWrapText(true); + + item.getChildren().addAll(top, subLabel, prevLabel); + return item; } } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java index b2f39f6..e1dc39d 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java @@ -9,8 +9,8 @@ import javafx.scene.control.ScrollPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; +import javafx.scene.text.TextAlignment; -/** Compact, reusable warning popup. */ public final class WarningApp extends Popup { private final Label iconLabel = new Label(); @@ -18,7 +18,6 @@ public final class WarningApp extends Popup { private final Label messageLabel = new Label(); private final Button primaryButton = new Button(); private final Button secondaryButton = new Button(); - private final HBox buttons; public WarningApp() { @@ -30,10 +29,14 @@ public WarningApp() { titleLabel.getStyleClass().add("warning-title"); titleLabel.setWrapText(true); titleLabel.setAlignment(Pos.CENTER); + titleLabel.setTextAlignment(TextAlignment.CENTER); + titleLabel.setMaxWidth(Double.MAX_VALUE); messageLabel.getStyleClass().add("warning-message"); messageLabel.setWrapText(true); messageLabel.setAlignment(Pos.CENTER); + messageLabel.setTextAlignment(TextAlignment.CENTER); + messageLabel.setMaxWidth(Double.MAX_VALUE); ScrollPane messageScroll = new ScrollPane(messageLabel); messageScroll.setFitToWidth(true); @@ -60,7 +63,6 @@ public WarningApp() { content.getChildren().setAll(inner); } - /** Configures for single-button scenario. */ public void configure( final String icon, final String title, @@ -80,7 +82,6 @@ public void configure( getCloseButton().setOnAction(event -> primaryButton.fire()); } - /** Configures for two-button scenario. */ public void configure( final String icon, final String title, @@ -102,18 +103,10 @@ public void configure( getCloseButton().setOnAction(event -> secondaryButton.fire()); } - /** Shows the app. */ - @Override - public void show() { - super.show(); - } - - /** @return primary button. */ public Button getPrimaryButton() { return primaryButton; } - /** @return secondary button. */ public Button getSecondaryButton() { return secondaryButton; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java index 7946f71..b842f8a 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java @@ -15,7 +15,6 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; -import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; @@ -31,7 +30,7 @@ public abstract class Popup { private final int height; private final App type; - private final StackPane wrapper; + private final Pane wrapper; private final BorderPane root; private final HBox header; private final Button closeButton; @@ -64,7 +63,12 @@ protected Popup(int width, int height, int x, int y, App type) { Rectangle borderOverlay = buildBorderOverlay(); - wrapper = new StackPane(root, borderOverlay); + wrapper = new Pane(root, borderOverlay); + // Bind wrapper size to root's size so centering logic works + wrapper.prefWidthProperty().bind(root.widthProperty()); + wrapper.prefHeightProperty().bind(root.heightProperty()); + borderOverlay.widthProperty().bind(root.widthProperty()); + borderOverlay.heightProperty().bind(root.heightProperty()); wrapper.setLayoutX(x); wrapper.setLayoutY(y); wrapper.setManaged(false); @@ -188,10 +192,11 @@ private String resource(final String path) { public void centerInParent() { Runnable bind = () -> { if (wrapper.getParent() instanceof Pane pane) { + // Use root.widthProperty/heightProperty for centering wrapper.layoutXProperty().bind( - pane.widthProperty().subtract(wrapper.widthProperty()).divide(2)); + pane.widthProperty().subtract(root.widthProperty()).divide(2)); wrapper.layoutYProperty().bind( - pane.heightProperty().subtract(wrapper.heightProperty()).divide(2)); + pane.heightProperty().subtract(root.heightProperty()).divide(2)); } }; bind.run(); @@ -215,7 +220,7 @@ public App getType() { } /** @return the root wrapper. */ - public StackPane getRoot() { + public Pane getRoot() { return wrapper; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java index bf93450..9bd87e0 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java @@ -1,6 +1,5 @@ package edu.ntnu.idi.idatt2003.gruppe42.View.Views; -import edu.ntnu.idi.idatt2003.gruppe42.Controller.TimeAndWeatherController; import edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers.DesktopViewController; import edu.ntnu.idi.idatt2003.gruppe42.Model.App; import edu.ntnu.idi.idatt2003.gruppe42.Model.Player; @@ -36,9 +35,6 @@ public final class DesktopView { private static final boolean DEV_CSS_RELOAD = true; - /** - * The different modal layers that can be active on the desktop. - */ public enum ModalLayer { RAPPORT, WARNING, GAME_OVER } private static final int COLS = 10; @@ -47,7 +43,9 @@ public enum ModalLayer { RAPPORT, WARNING, GAME_OVER } private static final double BACKDROP_BLUR = 8.0; private final DesktopViewController controller; - private final BorderPane root; + private final BorderPane desktopPane; + private final Pane popupOverlay; + private Pane sceneRoot; private final Pane rapportOverlay = createOverlayPane(); private final Pane warningOverlay = createOverlayPane(); @@ -76,26 +74,44 @@ public enum ModalLayer { RAPPORT, WARNING, GAME_OVER } /** Constructs the desktop view. */ public DesktopView(final DesktopViewController controller) { this.controller = controller; - this.root = new BorderPane(); + this.desktopPane = new BorderPane(); + this.popupOverlay = new Pane(); + this.popupOverlay.setPickOnBounds(false); + this.popupOverlay.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); } - /** @return the root node. */ - public BorderPane getRoot() { - if (root.getCenter() == null) { + /** @return the scene root containing the desktop and popup overlay. */ + public Pane getRoot() { + if (sceneRoot == null) { gridArea = createGrid(); bottomBar = createBottomBar(); - root.setCenter(gridArea); - root.setBottom(bottomBar); - root.getStyleClass().add("desktop-root"); + + // Ensure the popup overlay is in a pane that allows x,y positioning, + // and then place that pane in the center of the BorderPane. + Pane centerArea = new Pane(gridArea, popupOverlay); + if (gridArea instanceof Region region) { + region.prefWidthProperty().bind(centerArea.widthProperty()); + region.prefHeightProperty().bind(centerArea.heightProperty()); + } + popupOverlay.prefWidthProperty().bind(centerArea.widthProperty()); + popupOverlay.prefHeightProperty().bind(centerArea.heightProperty()); + + desktopPane.setCenter(centerArea); + desktopPane.setBottom(bottomBar); + desktopPane.getStyleClass().add("desktop-root"); + + sceneRoot = new Pane(desktopPane); + desktopPane.prefWidthProperty().bind(sceneRoot.widthProperty()); + desktopPane.prefHeightProperty().bind(sceneRoot.heightProperty()); loadStylesheets(); if (DEV_CSS_RELOAD) { - root.setFocusTraversable(true); - root.sceneProperty().addListener((obs, oldScene, newScene) -> { - if (newScene != null) root.requestFocus(); + sceneRoot.setFocusTraversable(true); + sceneRoot.sceneProperty().addListener((obs, oldScene, newScene) -> { + if (newScene != null) sceneRoot.requestFocus(); }); - root.setOnKeyPressed(event -> { + sceneRoot.setOnKeyPressed(event -> { if (event.getCode() == KeyCode.R) { loadStylesheets(); System.out.println("[CSS] Stylesheets reloaded"); @@ -103,15 +119,25 @@ public BorderPane getRoot() { }); } } - return root; + return sceneRoot; + } + + /** @return the inner BorderPane for gradient/style targeting. */ + public BorderPane getDesktopPane() { + return desktopPane; + } + + /** @return the overlay pane that holds popups and modals. */ + public Pane getPopupOverlay() { + return popupOverlay; } private void loadStylesheets() { - root.getStylesheets().clear(); + sceneRoot.getStylesheets().clear(); try { if (DEV_CSS_RELOAD) { String projectDir = System.getProperty("user.dir"); - root.getStylesheets().addAll( + sceneRoot.getStylesheets().addAll( devCopyToTemp(projectDir + "/src/main/resources/css/global.css"), devCopyToTemp(projectDir + "/src/main/resources/css/desktop.css"), devCopyToTemp(projectDir + "/src/main/resources/css/components.css"), @@ -124,7 +150,7 @@ private void loadStylesheets() { devCopyToTemp(projectDir + "/src/main/resources/css/warning.css") ); } else { - root.getStylesheets().addAll( + sceneRoot.getStylesheets().addAll( resource("/css/global.css"), resource("/css/desktop.css"), resource("/css/components.css"), @@ -150,7 +176,6 @@ private String devCopyToTemp(final String sourcePath) throws Exception { return tmp.toUri().toString(); } - /** Registers a popup root. */ public void registerPopup(final Node popupRoot) { popupRoots.add(popupRoot); @@ -165,7 +190,7 @@ public void registerModal(final ModalLayer layer, final Node modalRoot) { } } - /** @return the overlay pane. */ + /** @return the overlay pane for the given layer. */ public Pane getOverlay(final ModalLayer layer) { return switch (layer) { case RAPPORT -> rapportOverlay; @@ -198,7 +223,7 @@ private void recompute() { setLocked(bottomBar, anyModal); for (Node p : popupRoots) { - if (p instanceof StackPane wrapper && !wrapper.getChildren().isEmpty()) { + if (p instanceof Pane wrapper && !wrapper.getChildren().isEmpty()) { Node content = wrapper.getChildren().get(0); if (content.getStyleClass().contains("popup-root")) { setLocked(content, anyModal); @@ -254,7 +279,6 @@ private static Pane createOverlayPane() { return pane; } - private GridPane createGrid() { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); @@ -291,10 +315,9 @@ private static boolean isDesktopApp(final App app) { && app != App.WARNING && app != App.GAMEOVER && app != App.SETTINGS - && app != App.FILEPICKER; + && app != App.FILEPICKER; } - private HBox createBottomBar() { settingsButton = new Button("⚙"); settingsButton.getStyleClass().add("desktop-settings-button"); @@ -352,7 +375,6 @@ private HBox buildHeartsBox(final Player player) { return box; } - private HBox createStatusBox() { weatherLabel = styledLabel("desktop-label"); tempLabel = styledLabel("desktop-label"); @@ -366,7 +388,6 @@ private HBox createStatusBox() { return box; } - private Label styledLabel(final String styleClass) { Label l = new Label(); l.getStyleClass().add(styleClass); diff --git a/src/main/resources/css/desktop.css b/src/main/resources/css/desktop.css index f870240..04f6c5d 100644 --- a/src/main/resources/css/desktop.css +++ b/src/main/resources/css/desktop.css @@ -6,7 +6,6 @@ .desktop-bottom-bar { -fx-background-color: rgba(0, 0, 0, 0.7); - -fx-background-radius: 0; } .desktop-settings-button {