move start menu

This commit is contained in:
Johannes Schmelz 2024-11-24 20:42:07 +01:00
parent c2d5611ab9
commit 75d3bef5c8
2 changed files with 12 additions and 53 deletions

View File

@ -22,6 +22,7 @@ import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.style.BaseStyles; import com.simsilica.lemur.style.BaseStyles;
import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.MonopolyClient;
import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.client.gui.SettingsMenu;
import pp.monopoly.client.gui.StartMenu;
import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.ClientGameLogic;
import pp.monopoly.game.client.ServerConnection; import pp.monopoly.game.client.ServerConnection;
import pp.monopoly.notification.ClientStateEvent; import pp.monopoly.notification.ClientStateEvent;
@ -218,7 +219,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
setupInput(); setupInput();
setupStates(); setupStates();
setupGui(); setupGui();
// serverConnection.connect(); // new StartMenu(this).open();
} }
/** /**

View File

@ -1,4 +1,4 @@
package pp.monopoly.client; package pp.monopoly.client.gui;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
@ -13,8 +13,7 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout; import com.simsilica.lemur.component.SpringGridLayout;
import pp.dialog.Dialog; import pp.dialog.Dialog;
import pp.monopoly.client.gui.CreateGameMenu; import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.gui.SettingsMenu;
/** /**
* Constructs the startup menu dialog for the Monopoly application. * Constructs the startup menu dialog for the Monopoly application.
@ -33,13 +32,7 @@ public class StartMenu extends Dialog {
public StartMenu(MonopolyApp app) { public StartMenu(MonopolyApp app) {
super(app.getDialogManager()); super(app.getDialogManager());
this.app = app; 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 screenWidth = app.getContext().getSettings().getWidth();
int screenHeight = app.getContext().getSettings().getHeight(); 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 background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
app.getGuiNode().attachChild(background); app.getGuiNode().attachChild(background);
createMonopolyLogo(app);
createUnibwLogo(app);
// Center container for title and play button // Center container for title and play button
Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X)); 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.setFontSize(40); // Set the font size for the button text
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
startButton.addClickCommands(source -> startGame(app)); startButton.addClickCommands();
centerMenu.addChild(startButton); centerMenu.addChild(startButton);
// Position the center container in the middle of the screen // 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"); Button quitButton = new Button("Spiel beenden");
quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height) quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
quitButton.setFontSize(18); quitButton.setFontSize(18);
quitButton.addClickCommands(source -> quitGame()); quitButton.addClickCommands(source -> ifTopDialog(app::closeApp));
lowerLeftMenu.addChild(quitButton); lowerLeftMenu.addChild(quitButton);
app.getGuiNode().attachChild(lowerLeftMenu); app.getGuiNode().attachChild(lowerLeftMenu);
@ -89,17 +79,10 @@ public class StartMenu extends Dialog {
Button settingsButton = new Button("Einstellungen"); Button settingsButton = new Button("Einstellungen");
settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height) settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
settingsButton.setFontSize(18); // Increase the font size for the text settingsButton.setFontSize(18); // Increase the font size for the text
settingsButton.addClickCommands(source -> openSettings(app)); settingsButton.addClickCommands(source -> ifTopDialog(this::close));
lowerRightMenu.addChild(settingsButton); lowerRightMenu.addChild(settingsButton);
app.getGuiNode().attachChild(lowerRightMenu); 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 // Load the Monopoly logo as a texture
Texture logoTexture = app.getAssetManager().loadTexture("Pictures/logo-monopoly.png"); 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 // Attach the container to the GUI node
app.getGuiNode().attachChild(logoContainer); 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 // Load the Unibw logo as a texture
Texture unibwTexture = app.getAssetManager().loadTexture("Pictures/logo-unibw.png"); Texture unibwTexture = app.getAssetManager().loadTexture("Pictures/logo-unibw.png");
@ -156,26 +131,9 @@ public class StartMenu extends Dialog {
app.getGuiNode().attachChild(unibwContainer); app.getGuiNode().attachChild(unibwContainer);
} }
/** @Override
* Starts the game by transitioning to the CreateGameMenu. public void escape() {
*/ // TODO Auto-generated method stub
private static void startGame(MonopolyApp app) { super.escape();
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);
} }
} }