diff options
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r-- | src/jrummikub/control/AbstractSettingsControl.java | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/src/jrummikub/control/AbstractSettingsControl.java b/src/jrummikub/control/AbstractSettingsControl.java index ff43ce2..79f8274 100644 --- a/src/jrummikub/control/AbstractSettingsControl.java +++ b/src/jrummikub/control/AbstractSettingsControl.java @@ -17,6 +17,10 @@ import jrummikub.util.IListener2; import jrummikub.view.ISettingsPanel; import jrummikub.view.IView; +/** + * Abstract control class managing joined methods and attributes of all + * different (network, default...) settings controls + */ public abstract class AbstractSettingsControl { protected IView view; protected List<Connection> connections = new ArrayList<Connection>(); @@ -45,15 +49,15 @@ public abstract class AbstractSettingsControl { } private void addPlayerSettingsListeners() { - connections.add(view.getSettingsPanel().getAddPlayerEvent() - .add(new IListener() { + connections.add(view.getSettingsPanel().getAddPlayerEvent().add( + new IListener() { @Override public void handle() { addPlayer(); } })); - connections.add(view.getSettingsPanel().getRemovePlayerEvent() - .add(new IListener1<Integer>() { + connections.add(view.getSettingsPanel().getRemovePlayerEvent().add( + new IListener1<Integer>() { @Override public void handle(Integer i) { removePlayer(i); @@ -66,32 +70,32 @@ public abstract class AbstractSettingsControl { setPlayerColor(i, color); } })); - connections.add(view.getSettingsPanel().getChangePlayerNameEvent() - .add(new IListener2<Integer, String>() { + connections.add(view.getSettingsPanel().getChangePlayerNameEvent().add( + new IListener2<Integer, String>() { @Override public void handle(Integer i, String name) { setPlayerName(i, name); } })); - connections.add(view.getSettingsPanel().getChangePlayerTypeEvent() - .add(new IListener2<Integer, Type>() { + connections.add(view.getSettingsPanel().getChangePlayerTypeEvent().add( + new IListener2<Integer, Type>() { @Override public void handle(Integer i, Type type) { setPlayerType(i, type); } })); } - + private void addOptionListeners1() { connections.add(view.getSettingsPanel() - .getChangeInitialMeldThresholdEvent() - .add(new IListener1<Integer>() { - @Override - public void handle(Integer value) { - settings.setInitialMeldThreshold(value); - update(); - } - })); + .getChangeInitialMeldThresholdEvent().add( + new IListener1<Integer>() { + @Override + public void handle(Integer value) { + settings.setInitialMeldThreshold(value); + update(); + } + })); connections.add(view.getSettingsPanel().getChangeJokerNumberEvent() .add(new IListener1<Integer>() { @@ -111,14 +115,14 @@ public abstract class AbstractSettingsControl { } })); connections.add(view.getSettingsPanel() - .getChangeNumberOfStonesDealtEvent() - .add(new IListener1<Integer>() { - @Override - public void handle(Integer value) { - settings.setNumberOfStonesDealt(value); - update(); - } - })); + .getChangeNumberOfStonesDealtEvent().add( + new IListener1<Integer>() { + @Override + public void handle(Integer value) { + settings.setNumberOfStonesDealt(value); + update(); + } + })); } private void addOptionListeners2() { @@ -130,8 +134,8 @@ public abstract class AbstractSettingsControl { update(); } })); - connections.add(view.getSettingsPanel().getChangeTimeEvent() - .add(new IListener1<Integer>() { + connections.add(view.getSettingsPanel().getChangeTimeEvent().add( + new IListener1<Integer>() { @Override public void handle(Integer value) { settings.setTotalTime(value); @@ -147,8 +151,8 @@ public abstract class AbstractSettingsControl { } })); - connections.add(view.getSettingsPanel().getChangeNoLimitsEvent() - .add(new IListener1<Boolean>() { + connections.add(view.getSettingsPanel().getChangeNoLimitsEvent().add( + new IListener1<Boolean>() { @Override public void handle(Boolean value) { settings.setNoLimits(value); @@ -182,7 +186,7 @@ public abstract class AbstractSettingsControl { } })); } - + /** * Start the operation of the settings control */ @@ -231,7 +235,7 @@ public abstract class AbstractSettingsControl { settings.getPlayerList().remove(i); update(); } - + protected boolean checkSettings() { if (!checkName()) { return false; @@ -269,7 +273,8 @@ public abstract class AbstractSettingsControl { for (int j = i + 1; j < settings.getPlayerList().size(); ++j) { PlayerSettings player2 = settings.getPlayerList().get(j); if (player2.getName().equals(name) && player2.getType() == type) { - view.getSettingsPanel() + view + .getSettingsPanel() .setError( ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR); view.getSettingsPanel().enableStartGameButton(false); @@ -325,7 +330,7 @@ public abstract class AbstractSettingsControl { return; } } - + /** * Abort settings control once settings are set */ |