summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-13 18:22:57 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-13 18:22:57 +0200
commit56797840e2c16913627bfa57f2a49d1788443727 (patch)
tree21b46da744bb434bd783543986a2e0c4b8641b2a
parent70d6ae6d749d11ced007fa781ce65c6e27229007 (diff)
downloadJRummikub-56797840e2c16913627bfa57f2a49d1788443727.tar
JRummikub-56797840e2c16913627bfa57f2a49d1788443727.zip
Buttons im Settings panel sind richtig im netzwerk und außerhalb
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@421 72836036-5685-4462-b002-a69064685172
-rw-r--r--mock/jrummikub/view/MockSettingsPanel.java12
-rw-r--r--src/jrummikub/control/SettingsControl.java2
-rw-r--r--src/jrummikub/control/network/NetworkSettingsControl.java1
-rw-r--r--src/jrummikub/model/PlayerSettings.java6
-rw-r--r--src/jrummikub/view/ISettingsPanel.java5
-rw-r--r--src/jrummikub/view/impl/SettingsPanel.java81
6 files changed, 89 insertions, 18 deletions
diff --git a/mock/jrummikub/view/MockSettingsPanel.java b/mock/jrummikub/view/MockSettingsPanel.java
index 7689672..e6f9803 100644
--- a/mock/jrummikub/view/MockSettingsPanel.java
+++ b/mock/jrummikub/view/MockSettingsPanel.java
@@ -72,6 +72,7 @@ public class MockSettingsPanel implements ISettingsPanel {
public int highestValue;
/** */
public Set<StoneColor> stoneColors;
+ private MockEvent backEvent = new MockEvent();
@Override
public IEvent getAddPlayerEvent() {
@@ -186,4 +187,15 @@ public class MockSettingsPanel implements ISettingsPanel {
public IEvent getSetVariantChildrenEvent() {
return setVariantChildrenEvent;
}
+
+ @Override
+ public void enableNetworkMode(boolean enable) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public IEvent getBackEvent() {
+ return backEvent;
+ }
}
diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java
index 0da2f19..4103a38 100644
--- a/src/jrummikub/control/SettingsControl.java
+++ b/src/jrummikub/control/SettingsControl.java
@@ -40,6 +40,7 @@ public class SettingsControl {
public SettingsControl(IView view, GameSettings settings) {
this.view = view;
this.settings = settings;
+ view.getSettingsPanel().enableNetworkMode(false);
}
/**
@@ -71,7 +72,6 @@ public class SettingsControl {
startGame();
}
}));
-
view.showSettingsPanel(true);
}
diff --git a/src/jrummikub/control/network/NetworkSettingsControl.java b/src/jrummikub/control/network/NetworkSettingsControl.java
index 0c06df4..9459986 100644
--- a/src/jrummikub/control/network/NetworkSettingsControl.java
+++ b/src/jrummikub/control/network/NetworkSettingsControl.java
@@ -28,6 +28,7 @@ public class NetworkSettingsControl extends SettingsControl {
IView view, GameSettings settings) {
super(view, settings);
this.connectionControl = connectionControl;
+ view.getSettingsPanel().enableNetworkMode(true);
}
@Override
diff --git a/src/jrummikub/model/PlayerSettings.java b/src/jrummikub/model/PlayerSettings.java
index afa610c..2a152ad 100644
--- a/src/jrummikub/model/PlayerSettings.java
+++ b/src/jrummikub/model/PlayerSettings.java
@@ -16,7 +16,11 @@ public class PlayerSettings implements Serializable {
/** */
HUMAN,
/** */
- COMPUTER
+ COMPUTER,
+ /** */
+ VACANT,
+ /** */
+ NETWORK
}
private static final long serialVersionUID = 1963640115089275992L;
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;