From d7df4002da45c28b738df26f0fbb87539213b954 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sun, 24 Nov 2024 21:01:57 +0100 Subject: [PATCH] lobby menu --- .../monopoly/client/gui/CreateGameMenu.java | 2 +- .../pp/monopoly/client/gui/LobbyMenu.java | 28 ++++++++----------- .../monopoly/game/client/ClientGameLogic.java | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java index 7a34bce..a7cd723 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CreateGameMenu.java @@ -146,7 +146,7 @@ public class CreateGameMenu extends SimpleDialog { connectionFuture = null; progressDialog.close(); this.close(); - network.getApp().setInfoText(lookup("wait.for.an.opponent")); + new LobbyMenu(network.getApp()).open(); } /** diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java index 6408bda..fcdfe00 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/LobbyMenu.java @@ -22,11 +22,14 @@ import com.simsilica.lemur.component.SpringGridLayout; import com.simsilica.lemur.core.VersionedList; import com.simsilica.lemur.core.VersionedReference; import com.simsilica.lemur.style.ElementId; + +import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.message.client.PlayerReady; import java.util.Set; -public class LobbyMenu { +public class LobbyMenu extends Dialog { private final MonopolyApp app; private final Container menuContainer; @@ -36,6 +39,7 @@ public class LobbyMenu { private Container lowerRightMenu; public LobbyMenu(MonopolyApp app) { + super(app.getDialogManager()); this.app = app; // Entfernt das CreateGameMenu (inklusive Hintergrund) @@ -64,7 +68,7 @@ public class LobbyMenu { spacerBeforeInput.setPreferredSize(new Vector3f(20, 1, 0)); // Width of the spacer // Add an input field (TextField) - TextField startingCapital = horizontalContainer.addChild(new TextField("15 000")); + TextField startingCapital = horizontalContainer.addChild(new TextField("15000")); startingCapital.setPreferredWidth(100); // Set the width of the input field startingCapital.setPreferredSize(new Vector3f(150, 50, 0)); startingCapital.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding around the text inside the field @@ -129,7 +133,7 @@ public class LobbyMenu { Button cancelButton = new Button("Abbrechen"); cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image cancelButton.setFontSize(18); // Adjust font size - cancelButton.addClickCommands(source -> goBackToCreateGame()); // Add functionality + cancelButton.addClickCommands(source -> close()); // Add functionality lowerLeftMenu.addChild(cancelButton); // Position the container near the bottom-left corner @@ -201,20 +205,12 @@ public class LobbyMenu { * Schaltet den "Bereit"-Status um. */ private void toggleReady(Label playersLabel) { - // Beispiel-Logik für das Umschalten des Status - playersLabel.setText("Spielerstatus aktualisiert."); // Beispieltext + app.getGameLogic().send(new PlayerReady(true, "Test", "flugzeug", 15000));; } - /** - * Geht zurück zum CreateGameMenu. - */ - private void goBackToCreateGame() { - app.getGuiNode().detachChild(menuContainer); - app.getGuiNode().detachChild(background); - app.getGuiNode().detachChild(circle); - app.getGuiNode().detachChild(lowerLeftMenu); - app.getGuiNode().detachChild(lowerRightMenu); - // app.getServerConnection().connect(); + @Override + public void close() { + super.close(); } /** @@ -269,7 +265,7 @@ public class LobbyMenu { System.out.println("Gamma selected"); break; case "[3]": - goBackToCreateGame(); + close(); break; default: System.out.println("Unknown selection"); diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java index e6ef7e4..bf16bc9 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/client/ClientGameLogic.java @@ -139,7 +139,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker { * * @param msg the message to be sent */ - void send(ClientMessage msg) { + public void send(ClientMessage msg) { if (clientSender == null) { LOGGER.log(Level.ERROR, "trying to send {0} with sender==null", msg); //NON-NLS } else {