Fix: Game UI action locking and improve taskbar controller responsiveness
This commit is contained in:
+40
-3
@@ -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 ch.unibas.dmi.dbis.cs108.casono.ui.sound.SoundManager;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
@@ -989,6 +990,11 @@ public class TaskbarController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gameService.isActionInProgress()) {
|
||||||
|
LOGGER.info("Action {} blocked: another action is in progress", actionType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GameState state = ensureLatestStateForAction(actionType.name().toLowerCase());
|
GameState state = ensureLatestStateForAction(actionType.name().toLowerCase());
|
||||||
if (state == null || isHandFinished(state)) {
|
if (state == null || isHandFinished(state)) {
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
@@ -1014,6 +1020,8 @@ public class TaskbarController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disableAllActionButtons();
|
||||||
|
|
||||||
executeAction(state, targetBet, actionType);
|
executeAction(state, targetBet, actionType);
|
||||||
|
|
||||||
if (targetBet > 0) {
|
if (targetBet > 0) {
|
||||||
@@ -1021,7 +1029,36 @@ public class TaskbarController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
taskbarInput.clear();
|
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);
|
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) {
|
if (iconStream != null) {
|
||||||
Image icon = new Image(iconStream);
|
Image icon = new Image(iconStream);
|
||||||
if (!icon.isError()
|
if (!icon.isError()
|
||||||
&& alert.getDialogPane() != null
|
&& alert.getDialogPane() != null
|
||||||
&& alert.getDialogPane().getScene() != null
|
&& alert.getDialogPane().getScene() != null
|
||||||
&& alert.getDialogPane().getScene().getWindow()
|
&& alert.getDialogPane().getScene().getWindow()
|
||||||
instanceof javafx.stage.Stage stage) {
|
instanceof javafx.stage.Stage stage) {
|
||||||
stage.getIcons().add(icon);
|
stage.getIcons().add(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user