summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view')
-rw-r--r--src/jrummikub/view/ISettingsPanel.java15
-rw-r--r--src/jrummikub/view/impl/SettingsPanel.java101
2 files changed, 79 insertions, 37 deletions
diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java
index 95381a1..28faec6 100644
--- a/src/jrummikub/view/ISettingsPanel.java
+++ b/src/jrummikub/view/ISettingsPanel.java
@@ -139,4 +139,19 @@ public interface ISettingsPanel {
* initial meld threshold
*/
public void setInitialMeldThreshold(int value);
+
+ /**
+ * Emitted when the joker number is changed
+ *
+ * @return the event
+ */
+ public IEvent1<Integer> getChangeJokerNumberEvent();
+
+ /**
+ * Sets the joker number in the option pane
+ *
+ * @param jokerNumber
+ * the joker number
+ */
+ public void setJokerNumber(int jokerNumber);
} \ No newline at end of file
diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java
index 862aa32..15c6ee4 100644
--- a/src/jrummikub/view/impl/SettingsPanel.java
+++ b/src/jrummikub/view/impl/SettingsPanel.java
@@ -58,8 +58,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private boolean removeButtonsEnabled = true;
private List<PlayerSettingsPanel> playerSettingsPanels = new ArrayList<PlayerSettingsPanel>();
-
+
private JSpinner initialMeldThresholdSpinner;
+ private JSpinner jokerNumberSpinner;
private Event startGameEvent = new Event();
private Event addPlayerEvent = new Event();
@@ -67,6 +68,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private Event2<Integer, Color> changePlayerColorEvent = new Event2<Integer, Color>();
private Event2<Integer, String> changePlayerNameEvent = new Event2<Integer, String>();
private Event1<Integer> changeInitialMeldThresholdEvent = new Event1<Integer>();
+ private Event1<Integer> changeJokerNumberEvent = new Event1<Integer>();
@Override
public IEvent getStartGameEvent() {
@@ -101,16 +103,16 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
@Override
public void setError(SettingsError error) {
switch (error) {
- case NO_ERROR:
- errorMessageLabel.setText(" ");
- break;
- case DUPLICATE_PLAYER_NAME:
- errorMessageLabel
- .setText("Jeder Spielername darf nur einmal verwendet werden.");
- break;
- case NO_PLAYER_NAME:
- errorMessageLabel.setText("Jeder Spieler muss einen Namen haben.");
- break;
+ case NO_ERROR:
+ errorMessageLabel.setText(" ");
+ break;
+ case DUPLICATE_PLAYER_NAME:
+ errorMessageLabel
+ .setText("Jeder Spielername darf nur einmal verwendet werden.");
+ break;
+ case NO_PLAYER_NAME:
+ errorMessageLabel.setText("Jeder Spieler muss einen Namen haben.");
+ break;
}
}
@@ -134,7 +136,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
@Override
public void setGameSettings(GameSettings gameSettings) {
- while (playerSettingsPanels.size() > gameSettings.getPlayerList().size()) {
+ while (playerSettingsPanels.size() > gameSettings.getPlayerList()
+ .size()) {
removePlayerSettingsPanel();
}
@@ -161,8 +164,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
}
private void removePlayerSettingsPanel() {
- PlayerSettingsPanel p = playerSettingsPanels.remove(playerSettingsPanels
- .size() - 1);
+ PlayerSettingsPanel p = playerSettingsPanels
+ .remove(playerSettingsPanels.size() - 1);
playerSettingsViewport.remove(p);
}
@@ -184,7 +187,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
playerSettingsViewport.add(addPlayerPanel);
addPlayerButton = new JButton("+");
- addPlayerButton.setFont(addPlayerButton.getFont().deriveFont(Font.BOLD));
+ addPlayerButton
+ .setFont(addPlayerButton.getFont().deriveFont(Font.BOLD));
addPlayerButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -195,55 +199,68 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
}
private JComponent makeFiller() {
- return new Box.Filler(new Dimension(0, 0), new Dimension(0, 0), new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
+ return new Box.Filler(new Dimension(0, 0), new Dimension(0, 0),
+ new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
}
-
+
private void createOptionsPanel() {
optionsPanel = new JPanel();
GridBagLayout layout = new GridBagLayout();
optionsPanel.setLayout(layout);
-
+
GridBagConstraints labelC = new GridBagConstraints();
GridBagConstraints optionC = new GridBagConstraints();
-
+
labelC.anchor = GridBagConstraints.EAST;
labelC.gridx = 0;
- labelC.insets = new Insets(5,5,5,5);
+ labelC.insets = new Insets(4, 4, 4, 4);
optionC.anchor = GridBagConstraints.WEST;
optionC.gridx = 1;
- optionC.insets = new Insets(5,5,5,5);
-
+ optionC.insets = new Insets(2, 2, 2, 2);
+
JLabel label = new JLabel("Auslegeschranke:");
labelC.gridy = 0;
optionsPanel.add(label, labelC);
-
+
initialMeldThresholdSpinner = new JSpinner();
- initialMeldThresholdSpinner.setModel(new SpinnerNumberModel(1, 1, 999, 1));
- initialMeldThresholdSpinner.setPreferredSize(new Dimension(60, initialMeldThresholdSpinner.getMinimumSize().height));
+ initialMeldThresholdSpinner.setModel(new SpinnerNumberModel(1, 1, 999,
+ 1));
+ initialMeldThresholdSpinner.setPreferredSize(new Dimension(60,
+ initialMeldThresholdSpinner.getMinimumSize().height));
initialMeldThresholdSpinner.addChangeListener(new ChangeListener() {
-
@Override
public void stateChanged(ChangeEvent e) {
- changeInitialMeldThresholdEvent.emit((Integer)initialMeldThresholdSpinner.getValue());
+ changeInitialMeldThresholdEvent
+ .emit((Integer) initialMeldThresholdSpinner.getValue());
}
});
optionC.gridy = 0;
optionsPanel.add(initialMeldThresholdSpinner, optionC);
-
-
- label = new JLabel("Dinge:");
+
+ label = new JLabel("Jokeranzahl:");
labelC.gridx = 0;
labelC.gridy = 1;
optionsPanel.add(label, labelC);
-
+
+ jokerNumberSpinner = new JSpinner();
+ jokerNumberSpinner.setModel(new SpinnerNumberModel(0, 0, 999, 1));
+ jokerNumberSpinner.addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ changeJokerNumberEvent.emit((Integer) jokerNumberSpinner
+ .getValue());
+ }
+ });
+ optionC.gridy = 1;
+ optionsPanel.add(jokerNumberSpinner, optionC);
+
labelC.gridx = 1;
labelC.gridy = 2;
labelC.fill = GridBagConstraints.BOTH;
labelC.weightx = 1;
labelC.weighty = 1;
optionsPanel.add(makeFiller(), labelC);
-
-
+
// TODO Knöpfe für Dinge
}
@@ -279,8 +296,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
});
add(startButton, c);
- setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
- 10, 10, 10, 10)));
+ setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
+ new EmptyBorder(10, 10, 10, 10)));
}
private class PlayerSettingsPanel extends JPanel {
@@ -294,8 +311,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
nameField.setText(settings.getName());
}
- colorButton
- .setIcon(ImageUtil.createColorIcon(settings.getColor(), 16, 2));
+ colorButton.setIcon(ImageUtil.createColorIcon(settings.getColor(),
+ 16, 2));
}
public void enableRemoveButton(boolean enable) {
@@ -420,4 +437,14 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
public void setInitialMeldThreshold(int value) {
initialMeldThresholdSpinner.setValue(value);
}
+
+ @Override
+ public IEvent1<Integer> getChangeJokerNumberEvent() {
+ return changeJokerNumberEvent;
+ }
+
+ @Override
+ public void setJokerNumber(int jokerNumber) {
+ jokerNumberSpinner.setValue(jokerNumber);
+ }
}