From c990e7b5625c52a3aa93f4ee67594928ec01f95e Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Mon, 25 Nov 2024 01:50:52 +0100 Subject: [PATCH] added button sounds --- .../monopoly/client/gui/CreateGameMenu.java | 16 +++++++++++--- .../pp/monopoly/client/gui/LobbyMenu.java | 12 +++++++++-- .../pp/monopoly/client/gui/SettingsMenu.java | 13 +++++++++--- .../java/pp/monopoly/client/gui/Toolbar.java | 21 +++++++++++++++---- 4 files changed, 50 insertions(+), 12 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 7cd1622..cb73d3c 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 @@ -23,6 +23,7 @@ import static pp.monopoly.Resources.lookup; import pp.monopoly.client.MonopolyApp; import pp.monopoly.client.NetworkSupport; +import pp.monopoly.notification.Sound; import pp.monopoly.server.MonopolyServer; import pp.dialog.Dialog; import pp.dialog.DialogBuilder; @@ -70,15 +71,24 @@ public class CreateGameMenu extends Dialog { cancelButton.setPreferredSize(new Vector3f(120, 40, 0)); cancelButton.addClickCommands(source -> close()); addChild(cancelButton); - cancelButton.addClickCommands(s -> new StartMenu(app)); + cancelButton.addClickCommands(s -> ifTopDialog(() -> { + new StartMenu(app); + app.getGameLogic().playSound(Sound.BUTTON); + })); // "Selber hosten"-Button - addChild(serverButton).addClickCommands(s -> startServerInThread()); + addChild(serverButton).addClickCommands(s -> ifTopDialog(() -> { + startServerInThread(); + app.getGameLogic().playSound(Sound.BUTTON); + })); // "Beitreten"-Button joinButton.setPreferredSize(new Vector3f(120, 40, 0)); addChild(joinButton); - joinButton.addClickCommands(s -> connect()); + joinButton.addClickCommands(s -> ifTopDialog(() -> { + app.connect(); + app.getGameLogic().playSound(Sound.BUTTON); + })); } /** 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..022ad05 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 @@ -26,6 +26,7 @@ import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; import pp.monopoly.message.client.PlayerReady; +import pp.monopoly.notification.Sound; import java.util.Set; @@ -133,7 +134,10 @@ public class LobbyMenu extends Dialog { 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 -> close()); // Add functionality + cancelButton.addClickCommands(s -> ifTopDialog(() -> { + this.close(); + app.getGameLogic().playSound(Sound.BUTTON); + })); lowerLeftMenu.addChild(cancelButton); // Position the container near the bottom-left corner @@ -146,7 +150,10 @@ 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(s -> ifTopDialog(() -> { + toggleReady(); + app.getGameLogic().playSound(Sound.BUTTON); + })); lowerRightMenu.addChild(readyButton); // Position the container near the bottom-right corner @@ -254,6 +261,7 @@ public class LobbyMenu extends Dialog { */ private void onDropdownSelectionChanged(String selected) { System.out.println("Selected: " + selected); + app.getGameLogic().playSound(Sound.BUTTON); switch (selected) { case "[0]": figure = "Laptop"; diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java index e847b5b..f0faeb5 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java @@ -20,6 +20,8 @@ import pp.monopoly.client.GameSound; import pp.monopoly.client.MonopolyApp; import pp.dialog.Dialog; import pp.dialog.StateCheckboxModel; +import pp.monopoly.notification.Sound; + import static pp.util.PreferencesUtils.getPreferences; /** @@ -56,9 +58,14 @@ public class SettingsMenu extends Dialog { addChild(musicSlider); - addChild(new Button("Zurück zum Spiel", new ElementId("button"))).addClickCommands(s -> ifTopDialog(this::close)); - addChild(new Button("Beenden", new ElementId("button"))).addClickCommands(s -> ifTopDialog(app::closeApp)); - + addChild(new Button("Zurück zum Spiel", new ElementId("button"))).addClickCommands(s -> ifTopDialog(() -> { + this.close(); // Close the StartMenu dialog + app.getGameLogic().playSound(Sound.BUTTON); + })); + addChild(new Button("Beenden", new ElementId("button"))).addClickCommands(s -> ifTopDialog(() -> { + app.getGameLogic().playSound(Sound.BUTTON); + app.closeApp(); + })); update(); } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index bd49ccf..85c4e07 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -14,6 +14,7 @@ import com.simsilica.lemur.component.SpringGridLayout; import com.simsilica.lemur.style.ElementId; import pp.dialog.Dialog; import pp.monopoly.client.MonopolyApp; +import pp.monopoly.notification.Sound; /** * Toolbar Klasse, die am unteren Rand der Szene angezeigt wird. @@ -135,7 +136,10 @@ public class Toolbar extends Dialog { private Button addDiceRollButton() { Button diceButton = new Button("Würfeln"); diceButton.setPreferredSize(new Vector3f(50, 20, 0)); - diceButton.addClickCommands(source -> rollDice()); + diceButton.addClickCommands(s -> ifTopDialog(() -> { + rollDice(); + app.getGameLogic().playSound(Sound.BUTTON); + })); toolbarContainer.addChild(diceButton); return diceButton; } @@ -143,21 +147,30 @@ public class Toolbar extends Dialog { private void addTradeMenuButton() { Button diceButton = new Button("Handeln"); diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons - diceButton.addClickCommands(source -> rollDice()); + diceButton.addClickCommands(s -> ifTopDialog(() -> { + rollDice(); + app.getGameLogic().playSound(Sound.BUTTON); + })); toolbarContainer.addChild(diceButton); } private void addEndTurnButton() { Button diceButton = new Button("Grundstücke"); diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons - diceButton.addClickCommands(source -> rollDice()); + diceButton.addClickCommands(s -> ifTopDialog(() -> { + rollDice(); + app.getGameLogic().playSound(Sound.BUTTON); + })); toolbarContainer.addChild(diceButton); } private void addPropertyMenuButton() { Button diceButton = new Button("Zug beenden"); diceButton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons - diceButton.addClickCommands(source -> rollDice()); + diceButton.addClickCommands(s -> ifTopDialog(() -> { + rollDice(); + app.getGameLogic().playSound(Sound.BUTTON); + })); toolbarContainer.addChild(diceButton); }