Added options UI
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@294 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
ffbfc751c9
commit
7f89a1ce10
3 changed files with 89 additions and 12 deletions
|
@ -23,6 +23,7 @@ public class MockSettingsPanel implements ISettingsPanel {
|
||||||
public boolean addPlayerButtonEnabled = true;
|
public boolean addPlayerButtonEnabled = true;
|
||||||
public boolean removePlayerButtonsEnabled = false;
|
public boolean removePlayerButtonsEnabled = false;
|
||||||
public GameSettings gameSettings = new GameSettings();
|
public GameSettings gameSettings = new GameSettings();
|
||||||
|
public int initialMeldThreshold;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getAddPlayerEvent() {
|
public IEvent getAddPlayerEvent() {
|
||||||
|
@ -84,4 +85,9 @@ public class MockSettingsPanel implements ISettingsPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialMeldThreshold(int value) {
|
||||||
|
initialMeldThreshold = value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ public interface ISettingsPanel {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The add player event is emitted when the user wants to add a player to the
|
* The add player event is emitted when the user wants to add a player to
|
||||||
* player list
|
* the player list
|
||||||
*
|
*
|
||||||
* @return the event
|
* @return the event
|
||||||
*/
|
*/
|
||||||
|
@ -83,7 +83,7 @@ public interface ISettingsPanel {
|
||||||
* Sets an error to display
|
* Sets an error to display
|
||||||
*
|
*
|
||||||
* @param error
|
* @param error
|
||||||
* the kind of error
|
* the kind of error
|
||||||
*/
|
*/
|
||||||
public void setError(SettingsError error);
|
public void setError(SettingsError error);
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public interface ISettingsPanel {
|
||||||
* Enables or disables the start game button
|
* Enables or disables the start game button
|
||||||
*
|
*
|
||||||
* @param enable
|
* @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);
|
public void enableStartGameButton(boolean enable);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public interface ISettingsPanel {
|
||||||
* Enables or disables the add player button
|
* Enables or disables the add player button
|
||||||
*
|
*
|
||||||
* @param enable
|
* @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);
|
public void enableAddPlayerButton(boolean enable);
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public interface ISettingsPanel {
|
||||||
* Enables or disables the remove player buttons
|
* Enables or disables the remove player buttons
|
||||||
*
|
*
|
||||||
* @param enable
|
* @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);
|
public void enableRemovePlayerButtons(boolean enable);
|
||||||
|
@ -116,7 +116,7 @@ public interface ISettingsPanel {
|
||||||
* Sets the game settings to display
|
* Sets the game settings to display
|
||||||
*
|
*
|
||||||
* @param gameSettings
|
* @param gameSettings
|
||||||
* the settings
|
* the settings
|
||||||
*/
|
*/
|
||||||
public void setGameSettings(GameSettings gameSettings);
|
public void setGameSettings(GameSettings gameSettings);
|
||||||
|
|
||||||
|
@ -131,4 +131,12 @@ public interface ISettingsPanel {
|
||||||
/** A player has an empty name */
|
/** A player has an empty name */
|
||||||
NO_PLAYER_NAME
|
NO_PLAYER_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the initial meld threshold in the option pane
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* initial meld threshold
|
||||||
|
*/
|
||||||
|
public void setInitialMeldThreshold(int value);
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ import java.awt.Font;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
|
@ -15,18 +16,24 @@ import java.awt.event.MouseEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
import javax.swing.border.CompoundBorder;
|
import javax.swing.border.CompoundBorder;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
|
@ -44,7 +51,7 @@ import jrummikub.view.ISettingsPanel;
|
||||||
class SettingsPanel extends JPanel implements ISettingsPanel {
|
class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
private JPanel playerSetupPanel;
|
private JPanel playerSetupPanel;
|
||||||
private JPanel playerSettingsViewport;
|
private JPanel playerSettingsViewport;
|
||||||
private JPanel ruleSetupPanel;
|
private JPanel optionsPanel;
|
||||||
private JButton addPlayerButton;
|
private JButton addPlayerButton;
|
||||||
private JLabel errorMessageLabel;
|
private JLabel errorMessageLabel;
|
||||||
private JButton startButton;
|
private JButton startButton;
|
||||||
|
@ -52,6 +59,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
private boolean removeButtonsEnabled = true;
|
private boolean removeButtonsEnabled = true;
|
||||||
private List<PlayerSettingsPanel> playerSettingsPanels = new ArrayList<PlayerSettingsPanel>();
|
private List<PlayerSettingsPanel> playerSettingsPanels = new ArrayList<PlayerSettingsPanel>();
|
||||||
|
|
||||||
|
private JSpinner initialMeldThresholdSpinner;
|
||||||
|
|
||||||
private Event startGameEvent = new Event();
|
private Event startGameEvent = new Event();
|
||||||
private Event addPlayerEvent = new Event();
|
private Event addPlayerEvent = new Event();
|
||||||
private Event1<Integer> removePlayerEvent = new Event1<Integer>();
|
private Event1<Integer> removePlayerEvent = new Event1<Integer>();
|
||||||
|
@ -185,8 +194,57 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
addPlayerPanel.add(addPlayerButton);
|
addPlayerPanel.add(addPlayerButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createRuleSetupPanel() {
|
private JComponent makeFiller() {
|
||||||
ruleSetupPanel = new JPanel();
|
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() {
|
SettingsPanel() {
|
||||||
|
@ -197,8 +255,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
createPlayerSetupPanel();
|
createPlayerSetupPanel();
|
||||||
tabbedPane.addTab("Spieler", playerSetupPanel);
|
tabbedPane.addTab("Spieler", playerSetupPanel);
|
||||||
|
|
||||||
createRuleSetupPanel();
|
createOptionsPanel();
|
||||||
tabbedPane.addTab("Regeln", ruleSetupPanel);
|
tabbedPane.addTab("Optionen", optionsPanel);
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.BOTH;
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
@ -357,4 +415,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialMeldThreshold(int value) {
|
||||||
|
initialMeldThresholdSpinner.setValue(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue