diff options
Diffstat (limited to 'src/jrummikub/view')
-rw-r--r-- | src/jrummikub/view/ISettingsPanel.java | 24 | ||||
-rw-r--r-- | src/jrummikub/view/impl/SettingsPanel.java | 38 |
2 files changed, 51 insertions, 11 deletions
diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java index 5c83f47..1d030fe 100644 --- a/src/jrummikub/view/ISettingsPanel.java +++ b/src/jrummikub/view/ISettingsPanel.java @@ -1,9 +1,11 @@ package jrummikub.view; import java.awt.Color; +import java.util.Set; import jrummikub.control.turn.TurnControlFactory; import jrummikub.model.GameSettings; +import jrummikub.model.StoneColor; import jrummikub.util.IEvent; import jrummikub.util.IEvent1; import jrummikub.util.IEvent2; @@ -34,8 +36,8 @@ public interface ISettingsPanel { }; /** - * The add player event is emitted when the user wants to add a player to - * the player list + * The add player event is emitted when the user wants to add a player to the + * player list * * @return the event */ @@ -80,9 +82,15 @@ public interface ISettingsPanel { * @return the event */ public IEvent1<Integer> getChangeInitialMeldThresholdEvent(); - + public IEvent1<Integer> getChangeStoneSetNumberEvent(); + public IEvent1<Integer> getChangeNumberOfStonesDealtEvent(); + + public IEvent1<Integer> getChangeHighestValueEvent(); + + public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent(); + /** * the start game event is emitted when the user wants to start the game * @@ -94,7 +102,7 @@ public interface ISettingsPanel { * Sets an error to display * * @param error - * the kind of error + * the kind of error */ public void setError(SettingsError error); @@ -102,7 +110,7 @@ public interface ISettingsPanel { * Enables or disables the start game button * * @param enable - * specifies if the button is to be enabled or disabled + * specifies if the button is to be enabled or disabled */ public void enableStartGameButton(boolean enable); @@ -110,7 +118,7 @@ public interface ISettingsPanel { * Enables or disables the add player button * * @param enable - * specifies if the button is to be enabled or disabled + * specifies if the button is to be enabled or disabled */ public void enableAddPlayerButton(boolean enable); @@ -118,7 +126,7 @@ public interface ISettingsPanel { * Enables or disables the remove player buttons * * @param enable - * specifies if the buttons are to be enabled or disabled + * specifies if the buttons are to be enabled or disabled */ public void enableRemovePlayerButtons(boolean enable); @@ -127,7 +135,7 @@ public interface ISettingsPanel { * Sets the game settings to display * * @param gameSettings - * the settings + * the settings */ public void setGameSettings(GameSettings gameSettings); diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java index 5eb82fb..95089a3 100644 --- a/src/jrummikub/view/impl/SettingsPanel.java +++ b/src/jrummikub/view/impl/SettingsPanel.java @@ -17,6 +17,7 @@ import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Set; import javax.swing.Box; import javax.swing.BoxLayout; @@ -44,6 +45,7 @@ import jrummikub.control.turn.TurnControlFactory; import jrummikub.control.turn.TurnControlFactory.Type; import jrummikub.model.GameSettings; import jrummikub.model.PlayerSettings; +import jrummikub.model.StoneColor; import jrummikub.util.Event; import jrummikub.util.Event1; import jrummikub.util.Event2; @@ -66,6 +68,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel { private JSpinner initialMeldThresholdSpinner; private JSpinner stoneSetNumberSpinner; + private JSpinner highestValueSpinner; + private JSpinner numberOfStonesDealtSpinner; private JSpinner jokerNumberSpinner; private Event startGameEvent = new Event(); @@ -77,6 +81,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel { private Event1<Integer> changeInitialMeldThresholdEvent = new Event1<Integer>(); private Event1<Integer> changeJokerNumberEvent = new Event1<Integer>(); private Event1<Integer> changeStoneSetNumberEvent = new Event1<Integer>(); + private Event1<Integer> changeNumberOfStonesDealtEvent = new Event1<Integer>(); + private Event1<Integer> changeHighestValueEvent = new Event1<Integer>(); + private Event1<Set<StoneColor>> changeStoneColorsEvent = new Event1<Set<StoneColor>>(); @Override public IEvent getStartGameEvent() { @@ -114,6 +121,21 @@ class SettingsPanel extends JPanel implements ISettingsPanel { } @Override + public IEvent1<Integer> getChangeNumberOfStonesDealtEvent() { + return changeNumberOfStonesDealtEvent; + } + + @Override + public IEvent1<Integer> getChangeHighestValueEvent() { + return changeHighestValueEvent; + } + + @Override + public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent() { + return changeStoneColorsEvent; + } + + @Override public void setError(SettingsError error) { switch (error) { case NO_ERROR: @@ -178,6 +200,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel { initialMeldThresholdSpinner.setValue(gameSettings .getInitialMeldThreshold()); stoneSetNumberSpinner.setValue(gameSettings.getStoneSetNumber()); + highestValueSpinner.setValue(gameSettings.getHighestValue()); + numberOfStonesDealtSpinner.setValue(gameSettings.getNumberOfStonesDealt()); jokerNumberSpinner.setValue(gameSettings.getJokerNumber()); playerSettingsViewport.revalidate(); @@ -251,13 +275,21 @@ class SettingsPanel extends JPanel implements ISettingsPanel { stoneSetNumberSpinner = makeOptionSpinner(1, 1, 999, 1, changeStoneSetNumberEvent); - makeOptionLabel(2, "Jokeranzahl:"); - jokerNumberSpinner = makeOptionSpinner(2, 1, 999, 1, + makeOptionLabel(2, "H\u00f6chster Steinwert:"); + highestValueSpinner = makeOptionSpinner(2, 3, 99, 1, + changeHighestValueEvent); + + makeOptionLabel(3, "Anzahl Startsteine:"); + numberOfStonesDealtSpinner = makeOptionSpinner(3, 1, 999, 1, + changeNumberOfStonesDealtEvent); + + makeOptionLabel(4, "Jokeranzahl:"); + jokerNumberSpinner = makeOptionSpinner(4, 1, 999, 1, changeJokerNumberEvent); GridBagConstraints c = new GridBagConstraints(); c.gridx = 1; - c.gridy = 3; + c.gridy = 5; c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; |