aboutsummaryrefslogtreecommitdiff
path: root/src/gui/Driver.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2023-05-12 02:03:30 -0400
committersowgro <tpoke.ferrari@gmail.com>2023-05-12 02:03:30 -0400
commit7f4070564af6cc9ba1eb79f3730eb0213eea3b11 (patch)
tree3e3b65e3335c973bc8c1f05827237146c0a2e649 /src/gui/Driver.java
parentad89ab07efd535dc0df280e982139db774558503 (diff)
downloadNPEhero-7f4070564af6cc9ba1eb79f3730eb0213eea3b11.tar.gz
NPEhero-7f4070564af6cc9ba1eb79f3730eb0213eea3b11.tar.bz2
NPEhero-7f4070564af6cc9ba1eb79f3730eb0213eea3b11.zip
big gui stuff
Diffstat (limited to 'src/gui/Driver.java')
-rw-r--r--src/gui/Driver.java55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/gui/Driver.java b/src/gui/Driver.java
index a01498e..f9449cd 100644
--- a/src/gui/Driver.java
+++ b/src/gui/Driver.java
@@ -1,10 +1,25 @@
package gui;
+import java.util.HashMap;
+
import javafx.application.Application;
+import javafx.geometry.Side;
+import javafx.scene.Scene;
+import javafx.scene.image.Image;
+import javafx.scene.layout.Background;
+import javafx.scene.layout.BackgroundImage;
+import javafx.scene.layout.BackgroundPosition;
+import javafx.scene.layout.BackgroundRepeat;
+import javafx.scene.layout.BackgroundSize;
+import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class Driver extends Application
{
+
+ static HashMap<String,Pane> menus = new HashMap<String,Pane>();
+ static Pane primaryPane = new Pane();
+
public static void main(String[] args)
{
launch(args);
@@ -13,7 +28,45 @@ public class Driver extends Application
@Override
public void start(Stage primaryStage)
{
- primaryStage.setScene(new MainMenu(primaryStage));
+ menus.put("MainMenu", new MainMenu());
+ menus.put("LevelSelector", new LevelSelector());
+ menus.put("Settings", new Settings());
+ menus.put("Leaderboard", new Leaderboard());
+
+ for (Pane value : menus.values()) {
+ value.minWidthProperty().bind(primaryStage.widthProperty());
+ 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");
primaryStage.show();
+ primaryStage.setFullScreen(true);
+ }
+
+
+ public static void switchMenu(String name)
+ {
+ primaryPane.getChildren().remove(0);
+ primaryPane.getChildren().add(menus.get(name));
+ }
+
+ public static void setBackground(String url)
+ {
+ primaryPane.setBackground(new Background(
+ new BackgroundImage(
+ new Image(url),
+ BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT,
+ new BackgroundPosition(Side.LEFT, 0, true, Side.BOTTOM, 0, true),
+ new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, false, true)
+ )));
}
}