mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
check awaitNextInputTimer
This commit is contained in:
@@ -461,17 +461,13 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void awaitNextInput() {
|
public final void awaitNextInput() {
|
||||||
if (awaitNextInputTimer == null) {
|
checkAwaitNextInputTimer();
|
||||||
String name = "?";
|
|
||||||
if (this.currentPlayer != null)
|
|
||||||
name = this.currentPlayer.getLobbyPlayerName();
|
|
||||||
awaitNextInputTimer = new Timer("awaitNextInputTimer Game:" + this.gameView.getId() + " Player:" + name);
|
|
||||||
}
|
|
||||||
//delay updating prompt to await next input briefly so buttons don't flicker disabled then enabled
|
//delay updating prompt to await next input briefly so buttons don't flicker disabled then enabled
|
||||||
awaitNextInputTask = new TimerTask() {
|
awaitNextInputTask = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FThreads.invokeInEdtLater(() -> {
|
FThreads.invokeInEdtLater(() -> {
|
||||||
|
checkAwaitNextInputTimer();
|
||||||
synchronized (awaitNextInputTimer) {
|
synchronized (awaitNextInputTimer) {
|
||||||
if (awaitNextInputTask != null) {
|
if (awaitNextInputTask != null) {
|
||||||
updatePromptForAwait(getCurrentPlayer());
|
updatePromptForAwait(getCurrentPlayer());
|
||||||
@@ -483,6 +479,14 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
};
|
};
|
||||||
awaitNextInputTimer.schedule(awaitNextInputTask, 250);
|
awaitNextInputTimer.schedule(awaitNextInputTask, 250);
|
||||||
}
|
}
|
||||||
|
private void checkAwaitNextInputTimer() {
|
||||||
|
if (awaitNextInputTimer == null) {
|
||||||
|
String name = "?";
|
||||||
|
if (this.currentPlayer != null)
|
||||||
|
name = this.currentPlayer.getLobbyPlayerName();
|
||||||
|
awaitNextInputTimer = new Timer("awaitNextInputTimer Game:" + this.gameView.getId() + " Player:" + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected final void updatePromptForAwait(final PlayerView playerView) {
|
protected final void updatePromptForAwait(final PlayerView playerView) {
|
||||||
showPromptMessage(playerView, Localizer.getInstance().getMessage("lblWaitingForOpponent"));
|
showPromptMessage(playerView, Localizer.getInstance().getMessage("lblWaitingForOpponent"));
|
||||||
|
|||||||
Reference in New Issue
Block a user