diff options
Diffstat (limited to 'src/jrummikub/control/turn/AbstractTurnControl.java')
-rw-r--r-- | src/jrummikub/control/turn/AbstractTurnControl.java | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/jrummikub/control/turn/AbstractTurnControl.java b/src/jrummikub/control/turn/AbstractTurnControl.java index ae1e155..84c478a 100644 --- a/src/jrummikub/control/turn/AbstractTurnControl.java +++ b/src/jrummikub/control/turn/AbstractTurnControl.java @@ -16,7 +16,6 @@ import jrummikub.view.IView; * Abstract base class for TurnControls */ public abstract class AbstractTurnControl implements ITurnControl { - protected Event endOfTurnEvent = new Event(); protected Event redealEvent = new Event(); protected TurnInfo turnInfo; @@ -24,8 +23,7 @@ public abstract class AbstractTurnControl implements ITurnControl { protected IView view; protected ITurnTimer timer; protected List<Connection> connections = new ArrayList<Connection>(); - - + @Override public IEvent getEndOfTurnEvent() { return endOfTurnEvent; @@ -35,7 +33,17 @@ public abstract class AbstractTurnControl implements ITurnControl { public IEvent getRedealEvent() { return redealEvent; } - + + private void pauseTurn() { + timer.stopTimer(); + view.enablePauseMode(true); + } + + private void resumeTurn() { + timer.startTimer(); + view.enablePauseMode(false); + } + protected abstract void timeOut(); @Override @@ -52,15 +60,27 @@ public abstract class AbstractTurnControl implements ITurnControl { timeOut(); } })); + connections.add(view.getPauseEvent().add(new IListener() { + @Override + public void handle() { + pauseTurn(); + } + })); + connections.add(view.getEndPauseEvent().add(new IListener() { + @Override + public void handle() { + resumeTurn(); + } + })); } - + protected void cleanUp() { timer.stopTimer(); for (Connection c : connections) { c.remove(); } } - + public void abortTurn() { cleanUp(); } |