From 75d3bef5c818d9280a535d213bdca5db968d0478 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sun, 24 Nov 2024 20:42:07 +0100 Subject: [PATCH] move start menu --- .../java/pp/monopoly/client/MonopolyApp.java | 3 +- .../monopoly/client/{ => gui}/StartMenu.java | 62 +++---------------- 2 files changed, 12 insertions(+), 53 deletions(-) rename Projekte/monopoly/client/src/main/java/pp/monopoly/client/{ => gui}/StartMenu.java (77%) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 9dd6a9d..b343379 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -22,6 +22,7 @@ import com.simsilica.lemur.GuiGlobals; import com.simsilica.lemur.style.BaseStyles; import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.client.gui.SettingsMenu; +import pp.monopoly.client.gui.StartMenu; import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.ServerConnection; import pp.monopoly.notification.ClientStateEvent; @@ -218,7 +219,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga setupInput(); setupStates(); setupGui(); - // serverConnection.connect(); + // new StartMenu(this).open(); } /** diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java similarity index 77% rename from Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java rename to Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java index 2ffccb4..1bc7737 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java @@ -1,4 +1,4 @@ -package pp.monopoly.client; +package pp.monopoly.client.gui; import com.jme3.material.Material; import com.jme3.math.Vector3f; @@ -13,8 +13,7 @@ import com.simsilica.lemur.component.QuadBackgroundComponent; import com.simsilica.lemur.component.SpringGridLayout; import pp.dialog.Dialog; -import pp.monopoly.client.gui.CreateGameMenu; -import pp.monopoly.client.gui.SettingsMenu; +import pp.monopoly.client.MonopolyApp; /** * Constructs the startup menu dialog for the Monopoly application. @@ -33,13 +32,7 @@ public class StartMenu extends Dialog { public StartMenu(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - } - - /** - * Creates and displays the Start Menu with buttons for starting the game, - * opening settings, and quitting the application. - */ - public static void createStartMenu(MonopolyApp app) { + int screenWidth = app.getContext().getSettings().getWidth(); int screenHeight = app.getContext().getSettings().getHeight(); @@ -53,9 +46,6 @@ public class StartMenu extends Dialog { background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements app.getGuiNode().attachChild(background); - createMonopolyLogo(app); - createUnibwLogo(app); - // Center container for title and play button Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X)); @@ -64,7 +54,7 @@ public class StartMenu extends Dialog { startButton.setFontSize(40); // Set the font size for the button text startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally - startButton.addClickCommands(source -> startGame(app)); + startButton.addClickCommands(); centerMenu.addChild(startButton); // Position the center container in the middle of the screen @@ -79,7 +69,7 @@ public class StartMenu extends Dialog { Button quitButton = new Button("Spiel beenden"); quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height) quitButton.setFontSize(18); - quitButton.addClickCommands(source -> quitGame()); + quitButton.addClickCommands(source -> ifTopDialog(app::closeApp)); lowerLeftMenu.addChild(quitButton); app.getGuiNode().attachChild(lowerLeftMenu); @@ -89,17 +79,10 @@ public class StartMenu extends Dialog { Button settingsButton = new Button("Einstellungen"); settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height) settingsButton.setFontSize(18); // Increase the font size for the text - settingsButton.addClickCommands(source -> openSettings(app)); + settingsButton.addClickCommands(source -> ifTopDialog(this::close)); lowerRightMenu.addChild(settingsButton); app.getGuiNode().attachChild(lowerRightMenu); - } - /** - * Creates and positions the Monopoly logo container in the center of the screen. - */ - private static void createMonopolyLogo(MonopolyApp app) { - int screenWidth = app.getContext().getSettings().getWidth(); - int screenHeight = app.getContext().getSettings().getHeight(); // Load the Monopoly logo as a texture Texture logoTexture = app.getAssetManager().loadTexture("Pictures/logo-monopoly.png"); @@ -123,14 +106,6 @@ public class StartMenu extends Dialog { // Attach the container to the GUI node app.getGuiNode().attachChild(logoContainer); - } - - /** - * Creates and positions the Unibw logo container in the center of the screen. - */ - private static void createUnibwLogo(MonopolyApp app) { - int screenWidth = app.getContext().getSettings().getWidth(); - int screenHeight = app.getContext().getSettings().getHeight(); // Load the Unibw logo as a texture Texture unibwTexture = app.getAssetManager().loadTexture("Pictures/logo-unibw.png"); @@ -156,26 +131,9 @@ public class StartMenu extends Dialog { app.getGuiNode().attachChild(unibwContainer); } - /** - * Starts the game by transitioning to the CreateGameMenu. - */ - private static void startGame(MonopolyApp app) { - app.getGuiNode().detachAllChildren(); - // app.getServerConnection().connect(); - } - - /** - * Opens the settings menu. - */ - private static void openSettings(MonopolyApp app) { - app.getGuiNode().detachAllChildren(); - new SettingsMenu(app); - } - - /** - * Quits the game application. - */ - private static void quitGame() { - System.exit(0); + @Override + public void escape() { + // TODO Auto-generated method stub + super.escape(); } } \ No newline at end of file