Make it so human player has prompt disabled while other human player has an input active

This commit is contained in:
drdev
2014-09-25 10:14:33 +00:00
parent c7ec4d9c64
commit e47ad1eeed
3 changed files with 17 additions and 1 deletions

View File

@@ -232,6 +232,18 @@ public class MatchUtil {
} }
} }
public static LocalGameView getOtherGameView() {
//return other game view besides current game view
if (gameViews.size() < 2) {
return null;
}
LocalGameView gameView = getGameView();
if (gameView == gameViews.get(0)) {
return gameViews.get(1);
}
return gameViews.get(0);
}
public static InputQueue getInputQueue() { public static InputQueue getInputQueue() {
LocalGameView gameView = getGameView(); LocalGameView gameView = getGameView();
if (gameView != null) { if (gameView != null) {

View File

@@ -100,7 +100,10 @@ public abstract class InputBase implements java.io.Serializable, Input {
awaitNextInputTimer.schedule(awaitNextInputTask, 250); awaitNextInputTimer.schedule(awaitNextInputTask, 250);
} }
public static void waitForHumanOpponent(final LocalGameView gameView) { public static void waitForOtherPlayer() {
final LocalGameView gameView = MatchUtil.getOtherGameView();
if (gameView == null) { return; }
cancelAwaitNextInput(); cancelAwaitNextInput();
FThreads.invokeInEdtNowOrLater(gameView.getGui(), new Runnable() { FThreads.invokeInEdtNowOrLater(gameView.getGui(), new Runnable() {
@Override @Override

View File

@@ -92,6 +92,7 @@ public class InputQueue extends Observable {
activeInput = input; activeInput = input;
inputStack.push(input); inputStack.push(input);
inputLock.setGui(input.getGui()); inputLock.setGui(input.getGui());
InputBase.waitForOtherPlayer();
syncPoint(); syncPoint();
updateObservers(); updateObservers();
} }