mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-08-03 18:14:18 +02:00
lock button when not active
This commit is contained in:
@@ -16,6 +16,7 @@ import pp.monopoly.game.server.PlayerHandler;
|
||||
import pp.monopoly.message.client.EndTurn;
|
||||
import pp.monopoly.message.client.RollDice;
|
||||
import pp.monopoly.notification.DiceRollEvent;
|
||||
import pp.monopoly.notification.ButtonStatusEvent;
|
||||
import pp.monopoly.notification.GameEventListener;
|
||||
import pp.monopoly.notification.Sound;
|
||||
import pp.monopoly.notification.UpdatePlayerView;
|
||||
@@ -29,6 +30,10 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
private Container overviewContainer;
|
||||
private Container accountContainer;
|
||||
private PlayerHandler playerHandler;
|
||||
private Button diceButton;
|
||||
private Button tradeButton;
|
||||
private Button propertyMenuButton;
|
||||
private Button endTurnButton;
|
||||
private volatile boolean animatingDice = false;
|
||||
private volatile DiceRollEvent latestDiceRollEvent = null;
|
||||
|
||||
@@ -83,9 +88,10 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
diceContainer.addChild(horizontalContainer);
|
||||
|
||||
// Würfeln-Button
|
||||
Button diceButton = new Button("Würfeln");
|
||||
diceButton = new Button("Würfeln");
|
||||
diceButton.setPreferredSize(new Vector3f(200, 50, 0));
|
||||
diceButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
diceButton.setEnabled(false);
|
||||
startDiceAnimation();
|
||||
app.getGameLogic().send(new RollDice());
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
@@ -103,7 +109,7 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
}
|
||||
|
||||
private Button addTradeMenuButton() {
|
||||
Button tradeButton = new Button("Handeln");
|
||||
tradeButton = new Button("Handeln");
|
||||
tradeButton.setPreferredSize(new Vector3f(150, 50, 0));
|
||||
tradeButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
@@ -113,7 +119,7 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
}
|
||||
|
||||
private Button addPropertyMenuButton() {
|
||||
Button propertyMenuButton = new Button("Grundstücke");
|
||||
propertyMenuButton = new Button("Grundstücke");
|
||||
propertyMenuButton.setPreferredSize(new Vector3f(150, 50, 0));
|
||||
propertyMenuButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
@@ -123,11 +129,12 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
}
|
||||
|
||||
private Button addEndTurnButton() {
|
||||
Button endTurnButton = new Button("Zug beenden");
|
||||
endTurnButton = new Button("Zug beenden");
|
||||
endTurnButton.setPreferredSize(new Vector3f(150, 50, 0));
|
||||
endTurnButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||
app.getGameLogic().playSound(Sound.BUTTON);
|
||||
app.getGameLogic().send(new EndTurn());
|
||||
receivedEvent(new ButtonStatusEvent(false));
|
||||
}));
|
||||
return endTurnButton;
|
||||
}
|
||||
@@ -259,4 +266,12 @@ public class Toolbar extends Dialog implements GameEventListener {
|
||||
public void escape() {
|
||||
new SettingsMenu(app).open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receivedEvent(ButtonStatusEvent event) {
|
||||
propertyMenuButton.setEnabled(event.buttonsEnabled());
|
||||
diceButton.setEnabled(event.buttonsEnabled());
|
||||
endTurnButton.setEnabled(event.buttonsEnabled());
|
||||
tradeButton.setEnabled(event.buttonsEnabled());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user