From b622d66942c0b2a49b5da3aa229bdaff13001042 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Fri, 15 Nov 2024 02:28:10 +0100 Subject: [PATCH] =?UTF-8?q?Buttons=20im=20Startmen=C3=BC=20ausgerichtet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pp/monopoly/client/StartMenu.java | 54 ++++++++++++++----- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java index c3893d3..df9090d 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/StartMenu.java @@ -1,14 +1,17 @@ package pp.monopoly.client; import com.jme3.math.Vector3f; +import com.simsilica.lemur.Axis; import com.simsilica.lemur.Button; import com.simsilica.lemur.Container; import com.simsilica.lemur.Label; +import com.simsilica.lemur.component.SpringGridLayout; import pp.dialog.Dialog; import pp.monopoly.client.gui.CreateGameMenu; import pp.monopoly.client.gui.SettingsMenu; + /** * Constructs the startup menu dialog for the Monopoly application. */ @@ -30,28 +33,51 @@ public class StartMenu extends Dialog { * opening settings, and quitting the application. */ public static void createStartMenu(MonopolyApp app) { - Container mainMenu = new Container(); - mainMenu.setLocalTranslation(new Vector3f(300, 300, 0)); // Positionierung des Menüs - // Titel des Hauptmenüs - mainMenu.addChild(new Label("Hauptmenü")); + int screenWidth = app.getContext().getSettings().getWidth(); + int screenHeight = app.getContext().getSettings().getHeight(); - // Schaltfläche "Spielen" - Wechselt zum CreateGameMenu - Button startButton = mainMenu.addChild(new Button("Spielen")); + // Center container for header and play button + Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X)); + centerMenu.setLocalTranslation(new Vector3f(300, 300, 0)); // Position in the center of the screen + + // Title of the main menu + centerMenu.addChild(new Label("Hauptmenü")); + + // "Spielen" button - centered + Button startButton = centerMenu.addChild(new Button("Spielen")); startButton.addClickCommands(source -> startGame(app)); - // Schaltfläche "Einstellungen" - Öffnet das Einstellungsmenü - Button settingsButton = mainMenu.addChild(new Button("Einstellungen")); - settingsButton.addClickCommands(source -> openSettings(app)); + // Position the center container in the middle of the screen + centerMenu.setLocalTranslation(new Vector3f(screenWidth / 2f - centerMenu.getPreferredSize().x / 2f, + screenHeight / 2f + centerMenu.getPreferredSize().y / 2f, + 0)); - // Schaltfläche "Spiel beenden" - Beendet das Spiel - Button quitButton = mainMenu.addChild(new Button("Spiel beenden")); + // Attach the center container to the GUI node + app.getGuiNode().attachChild(centerMenu); + + // Lower-left container for "Spiel beenden" button + Container lowerLeftMenu = new Container(); + lowerLeftMenu.setLocalTranslation(new Vector3f(50, 50, 0)); // Position in the lower-left corner + + // "Spiel beenden" button - lower left corner + Button quitButton = lowerLeftMenu.addChild(new Button("Spiel beenden")); quitButton.addClickCommands(source -> quitGame()); - // Hauptmenü dem Bildschirm hinzufügen - app.getGuiNode().attachChild(mainMenu); - } + // Attach the lower-left container to the GUI node + app.getGuiNode().attachChild(lowerLeftMenu); + // Lower-right container for "Einstellungen" button + Container lowerRightMenu = new Container(); + lowerRightMenu.setLocalTranslation(new Vector3f(screenWidth - 150, 50, 0)); // Position in the lower-right corner + + // "Einstellungen" button - lower right corner + Button settingsButton = lowerRightMenu.addChild(new Button("Einstellungen")); + settingsButton.addClickCommands(source -> openSettings(app)); + + // Attach the lower-right container to the GUI node + app.getGuiNode().attachChild(lowerRightMenu); + } /** * Starts the game by transitioning to the CreateGameMenu. */