mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 23:59:44 +01:00
Buttons im Startmenü ausgerichtet
This commit is contained in:
parent
853b52b52d
commit
b622d66942
@ -1,14 +1,17 @@
|
|||||||
package pp.monopoly.client;
|
package pp.monopoly.client;
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.simsilica.lemur.Axis;
|
||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
|
|
||||||
|
import com.simsilica.lemur.component.SpringGridLayout;
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.gui.CreateGameMenu;
|
import pp.monopoly.client.gui.CreateGameMenu;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the startup menu dialog for the Monopoly application.
|
* Constructs the startup menu dialog for the Monopoly application.
|
||||||
*/
|
*/
|
||||||
@ -30,28 +33,51 @@ public class StartMenu extends Dialog {
|
|||||||
* opening settings, and quitting the application.
|
* opening settings, and quitting the application.
|
||||||
*/
|
*/
|
||||||
public static void createStartMenu(MonopolyApp app) {
|
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
|
int screenWidth = app.getContext().getSettings().getWidth();
|
||||||
mainMenu.addChild(new Label("Hauptmenü"));
|
int screenHeight = app.getContext().getSettings().getHeight();
|
||||||
|
|
||||||
// Schaltfläche "Spielen" - Wechselt zum CreateGameMenu
|
// Center container for header and play button
|
||||||
Button startButton = mainMenu.addChild(new Button("Spielen"));
|
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));
|
startButton.addClickCommands(source -> startGame(app));
|
||||||
|
|
||||||
// Schaltfläche "Einstellungen" - Öffnet das Einstellungsmenü
|
// Position the center container in the middle of the screen
|
||||||
Button settingsButton = mainMenu.addChild(new Button("Einstellungen"));
|
centerMenu.setLocalTranslation(new Vector3f(screenWidth / 2f - centerMenu.getPreferredSize().x / 2f,
|
||||||
settingsButton.addClickCommands(source -> openSettings(app));
|
screenHeight / 2f + centerMenu.getPreferredSize().y / 2f,
|
||||||
|
0));
|
||||||
|
|
||||||
// Schaltfläche "Spiel beenden" - Beendet das Spiel
|
// Attach the center container to the GUI node
|
||||||
Button quitButton = mainMenu.addChild(new Button("Spiel beenden"));
|
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());
|
quitButton.addClickCommands(source -> quitGame());
|
||||||
|
|
||||||
// Hauptmenü dem Bildschirm hinzufügen
|
// Attach the lower-left container to the GUI node
|
||||||
app.getGuiNode().attachChild(mainMenu);
|
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.
|
* Starts the game by transitioning to the CreateGameMenu.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user