summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/SettingsControl.java50
1 files changed, 32 insertions, 18 deletions
diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java
index 4351c59..4ad30ce 100644
--- a/src/jrummikub/control/SettingsControl.java
+++ b/src/jrummikub/control/SettingsControl.java
@@ -34,9 +34,9 @@ public class SettingsControl {
* Create a new settings control
*
* @param view
- * the view to use
+ * the view to use
* @param settings
- * initial game settings
+ * initial game settings
*/
public SettingsControl(IView view, GameSettings settings) {
this.view = view;
@@ -44,8 +44,8 @@ public class SettingsControl {
}
/**
- * the start game event is emitted when the user wants to start a game and
- * the settings made are valid
+ * the start game event is emitted when the user wants to start a game and the
+ * settings made are valid
*
* @return the event
*/
@@ -78,8 +78,7 @@ public class SettingsControl {
private void addOptionListeners1() {
connections.add(view.getSettingsPanel()
- .getChangeInitialMeldThresholdEvent()
- .add(new IListener1<Integer>() {
+ .getChangeInitialMeldThresholdEvent().add(new IListener1<Integer>() {
@Override
public void handle(Integer value) {
settings.setInitialMeldThreshold(value);
@@ -104,8 +103,7 @@ public class SettingsControl {
update();
}
}));
- connections.add(view.getSettingsPanel()
- .getChangeNumberOfStonesDealtEvent()
+ connections.add(view.getSettingsPanel().getChangeNumberOfStonesDealtEvent()
.add(new IListener1<Integer>() {
@Override
public void handle(Integer value) {
@@ -149,6 +147,26 @@ public class SettingsControl {
update();
}
}));
+ connections.add(view.getSettingsPanel().getSetVariantDefaultEvent()
+ .add(new IListener() {
+ @Override
+ public void handle() {
+ settings.reset();
+ update();
+ }
+ }));
+ connections.add(view.getSettingsPanel().getSetVariantChildrenEvent()
+ .add(new IListener() {
+ @Override
+ public void handle() {
+ settings.reset();
+ settings.setHighestValue(10);
+ settings.setJokerNumber(6);
+ settings.setTime(120);
+ settings.setInitialMeldThreshold(20);
+ update();
+ }
+ }));
}
private void addPlayerSettingsListeners() {
@@ -221,8 +239,7 @@ public class SettingsControl {
break;
}
- settings.getPlayerList().add(
- new PlayerSettings("Spieler " + num, color));
+ settings.getPlayerList().add(new PlayerSettings("Spieler " + num, color));
update();
}
@@ -263,9 +280,8 @@ public class SettingsControl {
protected void update() {
view.getSettingsPanel().enableRemovePlayerButtons(
settings.getPlayerList().size() > 2);
- view.getSettingsPanel()
- .enableAddPlayerButton(
- settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length);
+ view.getSettingsPanel().enableAddPlayerButton(
+ settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length);
checkSettings();
@@ -286,9 +302,8 @@ public class SettingsControl {
for (int j = i + 1; j < settings.getPlayerList().size(); ++j) {
if (settings.getPlayerList().get(j).getName().equals(name)) {
- view.getSettingsPanel()
- .setError(
- ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR);
+ view.getSettingsPanel().setError(
+ ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR);
view.getSettingsPanel().enableStartGameButton(false);
return false;
}
@@ -297,8 +312,7 @@ public class SettingsControl {
int totalStonesDealt = settings.getNumberOfStonesDealt()
* settings.getPlayerList().size();
- int totalStones = settings.getHighestValue()
- * settings.getStoneSetNumber()
+ int totalStones = settings.getHighestValue() * settings.getStoneSetNumber()
* settings.getStoneColors().size() + settings.getJokerNumber();
if (totalStones <= totalStonesDealt) {