mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
AbstractGuiGame: only create Timer when needed, and destroy again after game end
This commit is contained in:
@@ -1025,6 +1025,7 @@ public final class CMatchUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterGameEnd() {
|
public void afterGameEnd() {
|
||||||
|
super.afterGameEnd();
|
||||||
Singletons.getView().getLpnDocument().remove(targetingOverlay.getPanel());
|
Singletons.getView().getLpnDocument().remove(targetingOverlay.getPanel());
|
||||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
|
|||||||
@@ -445,6 +445,7 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterGameEnd() {
|
public void afterGameEnd() {
|
||||||
|
super.afterGameEnd();
|
||||||
Forge.back();
|
Forge.back();
|
||||||
//view = null;
|
//view = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,12 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(spectator!=null) { //workaround fix!! this is needed on above code or it will
|
if(spectator!=null) { //workaround fix!! this is needed on above code or it will
|
||||||
gameControllers.remove(spectator); //bug the UI! remove spectator here since its must not be here...
|
for (Map.Entry<PlayerView, IGameController> e : gameControllers.entrySet()) {
|
||||||
|
if (e.getValue().equals(spectator)) {
|
||||||
|
gameControllers.remove(e.getKey());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
@@ -368,11 +373,14 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
return autoPassUntilEndOfTurn.contains(player);
|
return autoPassUntilEndOfTurn.contains(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Timer awaitNextInputTimer = new Timer();
|
private Timer awaitNextInputTimer;
|
||||||
private TimerTask awaitNextInputTask;
|
private TimerTask awaitNextInputTask;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void awaitNextInput() {
|
public final void awaitNextInput() {
|
||||||
|
if (awaitNextInputTimer == null) {
|
||||||
|
awaitNextInputTimer = new Timer("awaitNextInputTimer Game:" + this.gameView.getId() + " Player:" + this.currentPlayer.getLobbyPlayerName());
|
||||||
|
}
|
||||||
//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
|
||||||
@@ -400,6 +408,9 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void cancelAwaitNextInput() {
|
public final void cancelAwaitNextInput() {
|
||||||
|
if (awaitNextInputTimer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
synchronized (awaitNextInputTimer) { //ensure task doesn't reset awaitNextInputTask during this block
|
synchronized (awaitNextInputTimer) { //ensure task doesn't reset awaitNextInputTask during this block
|
||||||
if (awaitNextInputTask != null) {
|
if (awaitNextInputTask != null) {
|
||||||
try {
|
try {
|
||||||
@@ -725,5 +736,13 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
|||||||
public void handleLandPlayed(Card land, Zone zone) {
|
public void handleLandPlayed(Card land, Zone zone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterGameEnd() {
|
||||||
|
if (awaitNextInputTimer != null) {
|
||||||
|
awaitNextInputTimer.cancel();
|
||||||
|
awaitNextInputTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
// End of Choice code
|
// End of Choice code
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user