Auto-pause playback if mouse down anywhere above prompt or if device pauses game

This commit is contained in:
drdev
2014-05-27 00:21:16 +00:00
parent 1f4c5ef2e8
commit 0bdf7e83f1
4 changed files with 48 additions and 20 deletions

View File

@@ -6,7 +6,6 @@ import forge.FThreads;
import forge.GuiBase;
import forge.game.event.*;
import forge.match.input.InputPlaybackControl;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -173,5 +172,4 @@ public class FControlGamePlayback extends IGameEventVisitor.Base<Void> {
public void setSpeed(boolean isFast) {
fasterPlayback = isFast;
}
}

View File

@@ -8,14 +8,10 @@ public class InputPlaybackControl extends InputSyncronizedBase implements InputS
private static final long serialVersionUID = 7979208993306642072L;
FControlGamePlayback control;
private boolean isPaused = false;
private boolean isFast = false;
/**
* TODO: Write javadoc for Constructor.
* @param fControlGamePlayback
*/
public InputPlaybackControl(FControlGamePlayback fControlGamePlayback) {
control = fControlGamePlayback;
}
@@ -28,43 +24,49 @@ public class InputPlaybackControl extends InputSyncronizedBase implements InputS
setPause(false);
ButtonUtil.enableAllFocusOk();
}
private void setPause(boolean pause) {
isPaused = pause;
if ( isPaused )
if (isPaused) {
ButtonUtil.setButtonText("Resume", "Step");
else {
}
else {
ButtonUtil.setButtonText("Pause", isFast ? "1x Speed" : "10x Faster");
showMessage("Press pause to pause game.");
}
}
public void onGamePaused() {
showMessage(getTurnPhasePriorityMessage(GuiBase.getInterface().getGame()));
}
public void pause() {
if (isPaused) { return; }
control.pause();
setPause(true);
}
@Override
protected void onOk() {
if ( isPaused ) {
if (isPaused) {
control.resume();
setPause(false);
} else {
}
else {
control.pause();
setPause(true);
}
}
@Override
protected void onCancel() {
if ( isPaused ) {
if (isPaused) {
control.singleStep();
} else {
}
else {
isFast = !isFast;
control.setSpeed(isFast);
setPause(isPaused); // update message
}
}
}