summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/SettingsControl.java8
-rw-r--r--src/jrummikub/control/TurnTimer.java11
-rw-r--r--src/jrummikub/control/turn/AbstractTurnControl.java2
3 files changed, 16 insertions, 5 deletions
diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java
index 8a8fd62..2589d88 100644
--- a/src/jrummikub/control/SettingsControl.java
+++ b/src/jrummikub/control/SettingsControl.java
@@ -121,6 +121,14 @@ public class SettingsControl {
update();
}
}));
+ connections.add(view.getSettingsPanel().getChangeTimeEvent()
+ .add(new IListener1<Integer>() {
+ @Override
+ public void handle(Integer value) {
+ settings.setTime(value);
+ update();
+ }
+ }));
connections.add(view.getSettingsPanel().getChangeStoneColorsEvent()
.add(new IListener1<Set<StoneColor>>() {
@Override
diff --git a/src/jrummikub/control/TurnTimer.java b/src/jrummikub/control/TurnTimer.java
index 77c5b55..e64bc57 100644
--- a/src/jrummikub/control/TurnTimer.java
+++ b/src/jrummikub/control/TurnTimer.java
@@ -14,7 +14,8 @@ import jrummikub.view.IView;
*/
public class TurnTimer implements ActionListener, ITurnTimer {
private IView view;
- private int timeLeft = 60;
+ private int timeLeft;
+ private int totalTime;
private Timer timer;
private Event timeRunOutEvent = new Event();
@@ -24,12 +25,14 @@ public class TurnTimer implements ActionListener, ITurnTimer {
* @param view
* view to display
*/
- public TurnTimer(IView view) {
+ public TurnTimer(IView view, int totalTime) {
this.view = view;
+ timeLeft = totalTime;
+ this.totalTime = totalTime;
timer = new Timer(1000, this);
timer.setRepeats(true);
timer.setCoalesce(false);
- view.getPlayerPanel().setTimeLeft(timeLeft);
+ view.getPlayerPanel().setTime(timeLeft, totalTime);
}
@Override
@@ -45,7 +48,7 @@ public class TurnTimer implements ActionListener, ITurnTimer {
@Override
public void actionPerformed(ActionEvent arg0) {
timeLeft--;
- view.getPlayerPanel().setTimeLeft(timeLeft);
+ view.getPlayerPanel().setTime(timeLeft, totalTime);
if (timeLeft == 0) {
timer.stop();
timeRunOutEvent.emit();
diff --git a/src/jrummikub/control/turn/AbstractTurnControl.java b/src/jrummikub/control/turn/AbstractTurnControl.java
index 84c478a..4838a08 100644
--- a/src/jrummikub/control/turn/AbstractTurnControl.java
+++ b/src/jrummikub/control/turn/AbstractTurnControl.java
@@ -52,7 +52,7 @@ public abstract class AbstractTurnControl implements ITurnControl {
this.settings = settings;
this.view = view;
if (timer == null) {
- timer = new TurnTimer(view);
+ timer = new TurnTimer(view, settings.getTime());
}
connections.add(timer.getTimeRunOutEvent().add(new IListener() {
@Override