Fix: Game UI action locking and improve taskbar controller responsiveness

This commit is contained in:
Julian Kropff
2026-05-14 18:00:11 +02:00
parent 310cb59fe6
commit 46919a064d
@@ -11,6 +11,7 @@ import ch.unibas.dmi.dbis.cs108.casono.client.ui.lobbyui.Casinomainui;
import ch.unibas.dmi.dbis.cs108.casono.ui.sound.SoundManager;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.UnaryOperator;
@@ -989,6 +990,11 @@ public class TaskbarController {
return;
}
if (gameService.isActionInProgress()) {
LOGGER.info("Action {} blocked: another action is in progress", actionType);
return;
}
GameState state = ensureLatestStateForAction(actionType.name().toLowerCase());
if (state == null || isHandFinished(state)) {
if (state != null) {
@@ -1014,6 +1020,8 @@ public class TaskbarController {
return;
}
disableAllActionButtons();
executeAction(state, targetBet, actionType);
if (targetBet > 0) {
@@ -1021,7 +1029,36 @@ public class TaskbarController {
}
taskbarInput.clear();
refreshGame();
javafx.application.Platform.runLater(() -> {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
refreshGame();
});
}
/**
* Disables all action buttons to prevent multiple concurrent action submissions.
*/
private void disableAllActionButtons() {
if (betButton != null) {
betButton.setDisable(true);
}
if (callButton != null) {
callButton.setDisable(true);
}
if (raiseButton != null) {
raiseButton.setDisable(true);
}
if (foldButton != null) {
foldButton.setDisable(true);
}
if (taskbarInput != null) {
taskbarInput.setDisable(true);
}
}
/**
@@ -1391,14 +1428,14 @@ public class TaskbarController {
}
try (var iconStream = TaskbarController.class.getResourceAsStream(LOGO_PATH);
var mainLogoStream = TaskbarController.class.getResourceAsStream(LOGO_PATH_MAIN)) {
var mainLogoStream = TaskbarController.class.getResourceAsStream(LOGO_PATH_MAIN)) {
if (iconStream != null) {
Image icon = new Image(iconStream);
if (!icon.isError()
&& alert.getDialogPane() != null
&& alert.getDialogPane().getScene() != null
&& alert.getDialogPane().getScene().getWindow()
instanceof javafx.stage.Stage stage) {
instanceof javafx.stage.Stage stage) {
stage.getIcons().add(icon);
}
}