From 9568ea5118b9100b3375a6bd2153042506b0d5d1 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sun, 14 May 2023 01:46:56 -0400 Subject: Finish css and menus --- src/gui/Driver.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/gui/Driver.java') diff --git a/src/gui/Driver.java b/src/gui/Driver.java index f9449cd..77fe0b0 100644 --- a/src/gui/Driver.java +++ b/src/gui/Driver.java @@ -38,25 +38,27 @@ public class Driver extends Application value.minHeightProperty().bind(primaryStage.heightProperty()); } - primaryPane.getChildren().add(menus.get("MainMenu")); - primaryPane.minWidthProperty().bind(primaryStage.widthProperty()); - primaryPane.minHeightProperty().bind(primaryStage.heightProperty()); - setBackground("assets/water.png"); - Scene primaryScene = new Scene(primaryPane, 800, 600); primaryScene.getStylesheets().add("gui/style.css"); primaryStage.setScene(primaryScene); primaryStage.setTitle("NPE Hero"); + + setMenu("MainMenu"); + setBackground("assets/water.png"); + primaryStage.show(); - primaryStage.setFullScreen(true); } - public static void switchMenu(String name) + public static void setMenu(String name) { - primaryPane.getChildren().remove(0); + if (! primaryPane.getChildren().isEmpty()) + { + primaryPane.getChildren().remove(0); + } primaryPane.getChildren().add(menus.get(name)); + primaryPane.requestFocus(); } public static void setBackground(String url) -- cgit v1.2.3 From 228091f5594c4c20e6c51682e487d8325a8a3230 Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 16 May 2023 07:08:18 -0400 Subject: unfinnished commit --- src/gui/Driver.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/gui/Driver.java') diff --git a/src/gui/Driver.java b/src/gui/Driver.java index 77fe0b0..59002c2 100644 --- a/src/gui/Driver.java +++ b/src/gui/Driver.java @@ -17,6 +17,7 @@ import javafx.stage.Stage; public class Driver extends Application { + static Stage primaryStage; static HashMap menus = new HashMap(); static Pane primaryPane = new Pane(); @@ -26,8 +27,9 @@ public class Driver extends Application } @Override - public void start(Stage primaryStage) + public void start(Stage newPrimaryStage) { + primaryStage = newPrimaryStage; menus.put("MainMenu", new MainMenu()); menus.put("LevelSelector", new LevelSelector()); menus.put("Settings", new Settings()); @@ -61,6 +63,18 @@ public class Driver extends Application primaryPane.requestFocus(); } + public static void setCustomMenu(Pane pane) + { + if (! primaryPane.getChildren().isEmpty()) + { + primaryPane.getChildren().remove(0); + } + pane.minWidthProperty().bind(primaryStage.widthProperty()); + pane.minHeightProperty().bind(primaryStage.heightProperty()); + primaryPane.getChildren().add(pane); + primaryPane.requestFocus(); + } + public static void setBackground(String url) { primaryPane.setBackground(new Background( -- cgit v1.2.3