summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-29 15:31:58 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-29 15:31:58 +0200
commit7f89a1ce1067ec4ad31e0496bd679f70939aca10 (patch)
tree1cb657232dce8af662a1f7f5fd71230f94b75678
parentffbfc751c95b483f72bbb9ff47e4f04eef2c83cb (diff)
downloadJRummikub-7f89a1ce1067ec4ad31e0496bd679f70939aca10.tar
JRummikub-7f89a1ce1067ec4ad31e0496bd679f70939aca10.zip
Added options UI
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@294 72836036-5685-4462-b002-a69064685172
-rw-r--r--mock/jrummikub/view/MockSettingsPanel.java6
-rw-r--r--src/jrummikub/view/ISettingsPanel.java22
-rw-r--r--src/jrummikub/view/impl/SettingsPanel.java73
3 files changed, 89 insertions, 12 deletions
diff --git a/mock/jrummikub/view/MockSettingsPanel.java b/mock/jrummikub/view/MockSettingsPanel.java
index 55090b5..e029520 100644
--- a/mock/jrummikub/view/MockSettingsPanel.java
+++ b/mock/jrummikub/view/MockSettingsPanel.java
@@ -23,6 +23,7 @@ public class MockSettingsPanel implements ISettingsPanel {
public boolean addPlayerButtonEnabled = true;
public boolean removePlayerButtonsEnabled = false;
public GameSettings gameSettings = new GameSettings();
+ public int initialMeldThreshold;
@Override
public IEvent getAddPlayerEvent() {
@@ -84,4 +85,9 @@ public class MockSettingsPanel implements ISettingsPanel {
}
+ @Override
+ public void setInitialMeldThreshold(int value) {
+ initialMeldThreshold = value;
+ }
+
}
diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java
index e2d5eff..95381a1 100644
--- a/src/jrummikub/view/ISettingsPanel.java
+++ b/src/jrummikub/view/ISettingsPanel.java
@@ -33,8 +33,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
*/
@@ -83,7 +83,7 @@ public interface ISettingsPanel {
* Sets an error to display
*
* @param error
- * the kind of error
+ * the kind of error
*/
public void setError(SettingsError error);
@@ -91,7 +91,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);
@@ -99,7 +99,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);
@@ -107,7 +107,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);
@@ -116,7 +116,7 @@ public interface ISettingsPanel {
* Sets the game settings to display
*
* @param gameSettings
- * the settings
+ * the settings
*/
public void setGameSettings(GameSettings gameSettings);
@@ -131,4 +131,12 @@ public interface ISettingsPanel {
/** A player has an empty name */
NO_PLAYER_NAME
}
+
+ /**
+ * Sets the initial meld threshold in the option pane
+ *
+ * @param value
+ * initial meld threshold
+ */
+ public void setInitialMeldThreshold(int value);
} \ No newline at end of file
diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java
index e96b19d..862aa32 100644
--- a/src/jrummikub/view/impl/SettingsPanel.java
+++ b/src/jrummikub/view/impl/SettingsPanel.java
@@ -8,6 +8,7 @@ import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
+import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
@@ -15,18 +16,24 @@ import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
+import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JButton;
+import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
+import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
+import javax.swing.SpinnerNumberModel;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@@ -44,13 +51,15 @@ import jrummikub.view.ISettingsPanel;
class SettingsPanel extends JPanel implements ISettingsPanel {
private JPanel playerSetupPanel;
private JPanel playerSettingsViewport;
- private JPanel ruleSetupPanel;
+ private JPanel optionsPanel;
private JButton addPlayerButton;
private JLabel errorMessageLabel;
private JButton startButton;
private boolean removeButtonsEnabled = true;
private List<PlayerSettingsPanel> playerSettingsPanels = new ArrayList<PlayerSettingsPanel>();
+
+ private JSpinner initialMeldThresholdSpinner;
private Event startGameEvent = new Event();
private Event addPlayerEvent = new Event();
@@ -185,8 +194,57 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
addPlayerPanel.add(addPlayerButton);
}
- private void createRuleSetupPanel() {
- ruleSetupPanel = new JPanel();
+ private JComponent makeFiller() {
+ 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);
+ optionC.anchor = GridBagConstraints.WEST;
+ optionC.gridx = 1;
+ optionC.insets = new Insets(5,5,5,5);
+
+ 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.addChangeListener(new ChangeListener() {
+
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ changeInitialMeldThresholdEvent.emit((Integer)initialMeldThresholdSpinner.getValue());
+ }
+ });
+ optionC.gridy = 0;
+ optionsPanel.add(initialMeldThresholdSpinner, optionC);
+
+
+ label = new JLabel("Dinge:");
+ labelC.gridx = 0;
+ labelC.gridy = 1;
+ optionsPanel.add(label, labelC);
+
+ 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
}
SettingsPanel() {
@@ -197,8 +255,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
createPlayerSetupPanel();
tabbedPane.addTab("Spieler", playerSetupPanel);
- createRuleSetupPanel();
- tabbedPane.addTab("Regeln", ruleSetupPanel);
+ createOptionsPanel();
+ tabbedPane.addTab("Optionen", optionsPanel);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
@@ -357,4 +415,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
}
}
}
+
+ @Override
+ public void setInitialMeldThreshold(int value) {
+ initialMeldThresholdSpinner.setValue(value);
+ }
}