all button sounds now

This commit is contained in:
Johannes Schmelz 2024-11-25 03:35:32 +01:00
parent 4a9eba255b
commit f90ce5aa81
2 changed files with 17 additions and 5 deletions

View File

@ -28,6 +28,7 @@ import pp.monopoly.game.client.ServerConnection;
import pp.monopoly.notification.ClientStateEvent; import pp.monopoly.notification.ClientStateEvent;
import pp.monopoly.notification.GameEventListener; import pp.monopoly.notification.GameEventListener;
import pp.monopoly.notification.InfoTextEvent; import pp.monopoly.notification.InfoTextEvent;
import pp.monopoly.notification.Sound;
import pp.dialog.DialogBuilder; import pp.dialog.DialogBuilder;
import pp.dialog.DialogManager; import pp.dialog.DialogManager;
import pp.graphics.Draw; import pp.graphics.Draw;
@ -416,8 +417,11 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
DialogBuilder.simple(dialogManager) DialogBuilder.simple(dialogManager)
.setTitle(lookup("dialog.question")) .setTitle(lookup("dialog.question"))
.setText(question) .setText(question)
.setOkButton(lookup("button.yes"), yesAction) .setOkButton(lookup("button.yes"), d -> {
.setNoButton(lookup("button.no")) getGameLogic().playSound(Sound.BUTTON); // Play sound
yesAction.run(); // Execute the original yesAction
})
.setNoButton(lookup("button.no"), d -> getGameLogic().playSound(Sound.BUTTON))
.build() .build()
.open(); .open();
} }
@ -431,7 +435,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
DialogBuilder.simple(dialogManager) DialogBuilder.simple(dialogManager)
.setTitle(lookup("dialog.error")) .setTitle(lookup("dialog.error"))
.setText(errorMessage) .setText(errorMessage)
.setOkButton(lookup("button.ok")) .setOkButton(lookup("button.ok"), d -> getGameLogic().playSound(Sound.BUTTON))
.build() .build()
.open(); .open();
} }

View File

@ -28,6 +28,7 @@ import static pp.monopoly.Resources.lookup;
import com.simsilica.lemur.style.ElementId; import com.simsilica.lemur.style.ElementId;
import pp.monopoly.client.MonopolyApp; import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.NetworkSupport; import pp.monopoly.client.NetworkSupport;
import pp.monopoly.notification.Sound;
import pp.monopoly.server.MonopolyServer; import pp.monopoly.server.MonopolyServer;
import pp.dialog.Dialog; import pp.dialog.Dialog;
import pp.dialog.DialogBuilder; import pp.dialog.DialogBuilder;
@ -89,18 +90,25 @@ public class CreateGameMenu extends Dialog {
// "Abbrechen"-Button // "Abbrechen"-Button
cancelButton.setPreferredSize(new Vector3f(120, 40, 0)); cancelButton.setPreferredSize(new Vector3f(120, 40, 0));
cancelButton.addClickCommands(s -> ifTopDialog(() -> { cancelButton.addClickCommands(s -> ifTopDialog(() -> {
app.getGameLogic().playSound(Sound.BUTTON);
this.close(); this.close();
new StartMenu(network.getApp()).open(); new StartMenu(network.getApp()).open();
})); }));
addChild(cancelButton); addChild(cancelButton);
// "Selber hosten"-Button // "Selber hosten"-Button
serverButton.addClickCommands(s -> ifTopDialog(this::startServerInThread)); serverButton.addClickCommands(s -> ifTopDialog( () -> {
network.getApp().getGameLogic().playSound(Sound.BUTTON);
startServerInThread();
} ));
addChild(serverButton); addChild(serverButton);
// "Beitreten"-Button // "Beitreten"-Button
joinButton.setPreferredSize(new Vector3f(120, 40, 0)); joinButton.setPreferredSize(new Vector3f(120, 40, 0));
joinButton.addClickCommands(s -> ifTopDialog(this::connect)); joinButton.addClickCommands(s -> ifTopDialog( () -> {
app.getGameLogic().playSound(Sound.BUTTON);
connect();
}));
addChild(joinButton); addChild(joinButton);
} }