summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view')
-rw-r--r--src/jrummikub/view/ISettingsPanel.java5
-rw-r--r--src/jrummikub/view/impl/SettingsPanel.java81
2 files changed, 70 insertions, 16 deletions
diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java
index e5a73ed..2e482f0 100644
--- a/src/jrummikub/view/ISettingsPanel.java
+++ b/src/jrummikub/view/ISettingsPanel.java
@@ -35,6 +35,8 @@ public interface ISettingsPanel {
new Color(1.0f, 1.0f, 1.0f), // white
};
+ public void enableNetworkMode(boolean enable);
+
/**
* The add player event is emitted when the user wants to add a player to
* the player list
@@ -198,6 +200,8 @@ public interface ISettingsPanel {
*/
public IEvent getSetVariantChildrenEvent();
+ public IEvent getBackEvent();
+
/**
* Specifies the different kinds of settings errors that can be displayed
*/
@@ -219,4 +223,5 @@ public interface ISettingsPanel {
/** Only computer players added */
COMPUTER_PLAYERS_ONLY_WARNING
}
+
} \ No newline at end of file
diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java
index cc34a35..bd410ac 100644
--- a/src/jrummikub/view/impl/SettingsPanel.java
+++ b/src/jrummikub/view/impl/SettingsPanel.java
@@ -47,7 +47,6 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
-import jrummikub.control.turn.TurnControlFactory;
import jrummikub.model.GameSettings;
import jrummikub.model.PlayerSettings;
import jrummikub.model.PlayerSettings.Type;
@@ -82,6 +81,10 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private JSpinner jokerNumberSpinner;
private JSpinner timeSpinner;
private JCheckBox noLimitsBox;
+ private JButton loadButton;
+ private JButton networkButton;
+ private JButton backButton;
+ private JPanel buttonPanel;
private JPanel colorSelectionPanel;
private Map<StoneColor, JToggleButton> colorButtons = new HashMap<StoneColor, JToggleButton>();
@@ -104,6 +107,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private Event1<Boolean> changeNoLimitsEvent = new Event1<Boolean>();
private Event setVariantDefaultEvent = new Event();
private Event setVariantChildrenEvent = new Event();
+ private Event backEvent = new Event();
@Override
public IEvent getStartGameEvent() {
@@ -194,6 +198,11 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
}
@Override
+ public IEvent getBackEvent() {
+ return backEvent;
+ }
+
+ @Override
public void setError(SettingsError error) {
switch (error) {
case NO_ERROR:
@@ -506,6 +515,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
optionsPanel.add(label, c);
}
+ // TODO wiederfinden
SettingsPanel() {
setLayout(new GridBagLayout());
@@ -531,21 +541,17 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
c.weighty = 0;
add(errorMessageLabel, c);
- c.gridwidth = 1;
- startButton = addButton("Spiel starten", startGameEvent, c);
-
- c.weightx = 0;
- add(Box.createHorizontalStrut(10), c);
+ buttonPanel = new JPanel();
+ buttonPanel.setLayout(new GridBagLayout());
+ add(buttonPanel, c);
- c.weightx = 1;
- addButton("Spiel laden...", loadGameEvent, c);
+ startButton = createButton("Spiel starten", startGameEvent);
- c.weightx = 0;
- add(Box.createHorizontalStrut(10), c);
+ loadButton = createButton("Spiel laden...", loadGameEvent);
+ networkButton = createButton("Netzwerkspiel...", networkGameEvent);
+ backButton = createButton("Zur\u00fcck", backEvent);
- c.weightx = 1;
- c.gridwidth = GridBagConstraints.REMAINDER;
- addButton("Netzwerkspiel...", networkGameEvent, c);
+ addDefaultButtons();
setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
new EmptyBorder(10, 10, 10, 10)));
@@ -555,8 +561,43 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
tabbedPane.setSelectedIndex(0);
}
- private JButton addButton(String title, final Event event,
- GridBagConstraints c) {
+ private void addDefaultButtons() {
+ buttonPanel.removeAll();
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+ c.gridwidth = 1;
+ c.weightx = 1;
+ c.weighty = 1;
+
+ buttonPanel.add(startButton, c);
+ c.weightx = 0;
+ buttonPanel.add(Box.createHorizontalStrut(10), c);
+ c.weightx = 1;
+ buttonPanel.add(loadButton, c);
+ c.weightx = 0;
+ buttonPanel.add(Box.createHorizontalStrut(10), c);
+ c.weightx = 1;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ buttonPanel.add(networkButton, c);
+ }
+
+ private void addNetworkButtons() {
+ buttonPanel.removeAll();
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+ c.gridwidth = 1;
+ c.weightx = 1;
+ c.weighty = 1;
+
+ buttonPanel.add(startButton, c);
+ c.weightx = 0;
+ buttonPanel.add(Box.createHorizontalStrut(10), c);
+ c.weightx = 1;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ buttonPanel.add(backButton, c);
+ }
+
+ private JButton createButton(String title, final Event event) {
JButton button = new JButton(title);
button.addActionListener(new ActionListener() {
@Override
@@ -564,10 +605,18 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
event.emit();
}
});
- add(button, c);
return button;
}
+ @Override
+ public void enableNetworkMode(boolean enable) {
+ if (enable) {
+ addNetworkButtons();
+ } else {
+ addDefaultButtons();
+ }
+ }
+
private class PlayerSettingsPanel extends JPanel {
private int playerNumber;
private JButton colorButton;