diff options
author | Aidan Ross <aross02@fairport.org> | 2023-05-16 19:45:01 -0400 |
---|---|---|
committer | Aidan Ross <aross02@fairport.org> | 2023-05-16 19:45:01 -0400 |
commit | d2f14ec456a3a3a5b5725af74929c2b58f07bb91 (patch) | |
tree | fe4b43898fbe6a9411ab119ff6405ce032c0bbc4 /src/gui/Driver.java | |
parent | d7392b8ba11517117c25f6fc139da84873cb7cac (diff) | |
parent | f6685e0c93ed1f9ea5aab85f17d64ce93ffae6a9 (diff) | |
download | NPEhero-d2f14ec456a3a3a5b5725af74929c2b58f07bb91.tar.gz NPEhero-d2f14ec456a3a3a5b5725af74929c2b58f07bb91.tar.bz2 NPEhero-d2f14ec456a3a3a5b5725af74929c2b58f07bb91.zip |
Merge branch 'main' of https://gitlab.sowgro.net/guitarheros/guitarhero into main
Diffstat (limited to 'src/gui/Driver.java')
-rw-r--r-- | src/gui/Driver.java | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/gui/Driver.java b/src/gui/Driver.java index f9449cd..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<String,Pane> menus = new HashMap<String,Pane>(); 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()); @@ -38,25 +40,39 @@ 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 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) |