From 1a75d6d6a84c39545ee2d23a6cdb303c05dab023 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Mon, 25 Nov 2024 01:51:27 +0100 Subject: [PATCH] buttons now work as intended --- .../main/java/pp/monopoly/client/MonopolyApp.java | 4 ++++ .../java/pp/monopoly/client/gui/CreateGameMenu.java | 13 ++++++++----- .../main/java/pp/monopoly/client/gui/LobbyMenu.java | 10 ++++++---- .../main/java/pp/monopoly/client/gui/StartMenu.java | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) 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 87e350a..f88cc11 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 @@ -434,4 +434,8 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga .build() .open(); } + + public void disconnect() { + serverConnection.disconnect(); + } } 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 7cd1622..a82aaee 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 @@ -68,17 +68,20 @@ public class CreateGameMenu extends Dialog { addChild(input); // "Abbrechen"-Button cancelButton.setPreferredSize(new Vector3f(120, 40, 0)); - cancelButton.addClickCommands(source -> close()); + cancelButton.addClickCommands(s -> ifTopDialog(() -> { + this.close(); + new StartMenu(network.getApp()).open(); + })); addChild(cancelButton); - cancelButton.addClickCommands(s -> new StartMenu(app)); // "Selber hosten"-Button - addChild(serverButton).addClickCommands(s -> startServerInThread()); + serverButton.addClickCommands(s -> ifTopDialog(this::startServerInThread)); + addChild(serverButton); // "Beitreten"-Button joinButton.setPreferredSize(new Vector3f(120, 40, 0)); + joinButton.addClickCommands(s -> ifTopDialog(this::connect)); addChild(joinButton); - joinButton.addClickCommands(s -> connect()); } /** @@ -125,7 +128,7 @@ public class CreateGameMenu extends Dialog { @Override public void escape() { - close(); + new SettingsMenu(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 9d14194..ef055bd 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 @@ -130,10 +130,12 @@ public class LobbyMenu extends Dialog { buttonContainer.setBackground(null); // Lower-left container for "Abbrechen" button lowerLeftMenu = new Container(); - Button cancelButton = new Button("Abbrechen"); + Button cancelButton = new Button("Beenden"); 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 -> close()); // Add functionality + cancelButton.addClickCommands(source -> ifTopDialog( () -> { + app.closeApp(); + })); // Add functionality lowerLeftMenu.addChild(cancelButton); // Position the container near the bottom-left corner @@ -146,7 +148,7 @@ public class LobbyMenu extends Dialog { readyButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image readyButton.setFontSize(18); // Adjust font size readyButton.setBackground(new QuadBackgroundComponent(ColorRGBA.Green)); // Add color to match the style - readyButton.addClickCommands(source -> toggleReady()); // Add functionality + readyButton.addClickCommands(source -> ifTopDialog(this::toggleReady)); // Add functionality lowerRightMenu.addChild(readyButton); // Position the container near the bottom-right corner @@ -210,7 +212,7 @@ public class LobbyMenu extends Dialog { @Override public void escape() { - super.close(); + new SettingsMenu(app).open(); } /** diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java index 5b7bf07..3db87e4 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/StartMenu.java @@ -117,7 +117,7 @@ public class StartMenu extends Dialog { @Override public void escape() { - super.close(); + new SettingsMenu(app).open(); } @Override