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

View File

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