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
This commit is contained in:
parent
70d6ae6d74
commit
56797840e2
6 changed files with 89 additions and 18 deletions
|
@ -72,6 +72,7 @@ public class MockSettingsPanel implements ISettingsPanel {
|
||||||
public int highestValue;
|
public int highestValue;
|
||||||
/** */
|
/** */
|
||||||
public Set<StoneColor> stoneColors;
|
public Set<StoneColor> stoneColors;
|
||||||
|
private MockEvent backEvent = new MockEvent();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getAddPlayerEvent() {
|
public IEvent getAddPlayerEvent() {
|
||||||
|
@ -186,4 +187,15 @@ public class MockSettingsPanel implements ISettingsPanel {
|
||||||
public IEvent getSetVariantChildrenEvent() {
|
public IEvent getSetVariantChildrenEvent() {
|
||||||
return setVariantChildrenEvent;
|
return setVariantChildrenEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enableNetworkMode(boolean enable) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEvent getBackEvent() {
|
||||||
|
return backEvent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class SettingsControl {
|
||||||
public SettingsControl(IView view, GameSettings settings) {
|
public SettingsControl(IView view, GameSettings settings) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
view.getSettingsPanel().enableNetworkMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +72,6 @@ public class SettingsControl {
|
||||||
startGame();
|
startGame();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
view.showSettingsPanel(true);
|
view.showSettingsPanel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class NetworkSettingsControl extends SettingsControl {
|
||||||
IView view, GameSettings settings) {
|
IView view, GameSettings settings) {
|
||||||
super(view, settings);
|
super(view, settings);
|
||||||
this.connectionControl = connectionControl;
|
this.connectionControl = connectionControl;
|
||||||
|
view.getSettingsPanel().enableNetworkMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,7 +16,11 @@ public class PlayerSettings implements Serializable {
|
||||||
/** */
|
/** */
|
||||||
HUMAN,
|
HUMAN,
|
||||||
/** */
|
/** */
|
||||||
COMPUTER
|
COMPUTER,
|
||||||
|
/** */
|
||||||
|
VACANT,
|
||||||
|
/** */
|
||||||
|
NETWORK
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 1963640115089275992L;
|
private static final long serialVersionUID = 1963640115089275992L;
|
||||||
|
|
|
@ -35,6 +35,8 @@ public interface ISettingsPanel {
|
||||||
new Color(1.0f, 1.0f, 1.0f), // white
|
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 add player event is emitted when the user wants to add a player to
|
||||||
* the player list
|
* the player list
|
||||||
|
@ -198,6 +200,8 @@ public interface ISettingsPanel {
|
||||||
*/
|
*/
|
||||||
public IEvent getSetVariantChildrenEvent();
|
public IEvent getSetVariantChildrenEvent();
|
||||||
|
|
||||||
|
public IEvent getBackEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the different kinds of settings errors that can be displayed
|
* Specifies the different kinds of settings errors that can be displayed
|
||||||
*/
|
*/
|
||||||
|
@ -219,4 +223,5 @@ public interface ISettingsPanel {
|
||||||
/** Only computer players added */
|
/** Only computer players added */
|
||||||
COMPUTER_PLAYERS_ONLY_WARNING
|
COMPUTER_PLAYERS_ONLY_WARNING
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -47,7 +47,6 @@ 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;
|
||||||
|
|
||||||
import jrummikub.control.turn.TurnControlFactory;
|
|
||||||
import jrummikub.model.GameSettings;
|
import jrummikub.model.GameSettings;
|
||||||
import jrummikub.model.PlayerSettings;
|
import jrummikub.model.PlayerSettings;
|
||||||
import jrummikub.model.PlayerSettings.Type;
|
import jrummikub.model.PlayerSettings.Type;
|
||||||
|
@ -82,6 +81,10 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
private JSpinner jokerNumberSpinner;
|
private JSpinner jokerNumberSpinner;
|
||||||
private JSpinner timeSpinner;
|
private JSpinner timeSpinner;
|
||||||
private JCheckBox noLimitsBox;
|
private JCheckBox noLimitsBox;
|
||||||
|
private JButton loadButton;
|
||||||
|
private JButton networkButton;
|
||||||
|
private JButton backButton;
|
||||||
|
private JPanel buttonPanel;
|
||||||
|
|
||||||
private JPanel colorSelectionPanel;
|
private JPanel colorSelectionPanel;
|
||||||
private Map<StoneColor, JToggleButton> colorButtons = new HashMap<StoneColor, JToggleButton>();
|
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 Event1<Boolean> changeNoLimitsEvent = new Event1<Boolean>();
|
||||||
private Event setVariantDefaultEvent = new Event();
|
private Event setVariantDefaultEvent = new Event();
|
||||||
private Event setVariantChildrenEvent = new Event();
|
private Event setVariantChildrenEvent = new Event();
|
||||||
|
private Event backEvent = new Event();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getStartGameEvent() {
|
public IEvent getStartGameEvent() {
|
||||||
|
@ -193,6 +197,11 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
return setVariantChildrenEvent;
|
return setVariantChildrenEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEvent getBackEvent() {
|
||||||
|
return backEvent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setError(SettingsError error) {
|
public void setError(SettingsError error) {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
|
@ -506,6 +515,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
optionsPanel.add(label, c);
|
optionsPanel.add(label, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO wiederfinden
|
||||||
SettingsPanel() {
|
SettingsPanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
@ -531,21 +541,17 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
c.weighty = 0;
|
c.weighty = 0;
|
||||||
add(errorMessageLabel, c);
|
add(errorMessageLabel, c);
|
||||||
|
|
||||||
c.gridwidth = 1;
|
buttonPanel = new JPanel();
|
||||||
startButton = addButton("Spiel starten", startGameEvent, c);
|
buttonPanel.setLayout(new GridBagLayout());
|
||||||
|
add(buttonPanel, c);
|
||||||
|
|
||||||
c.weightx = 0;
|
startButton = createButton("Spiel starten", startGameEvent);
|
||||||
add(Box.createHorizontalStrut(10), c);
|
|
||||||
|
|
||||||
c.weightx = 1;
|
loadButton = createButton("Spiel laden...", loadGameEvent);
|
||||||
addButton("Spiel laden...", loadGameEvent, c);
|
networkButton = createButton("Netzwerkspiel...", networkGameEvent);
|
||||||
|
backButton = createButton("Zur\u00fcck", backEvent);
|
||||||
|
|
||||||
c.weightx = 0;
|
addDefaultButtons();
|
||||||
add(Box.createHorizontalStrut(10), c);
|
|
||||||
|
|
||||||
c.weightx = 1;
|
|
||||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
||||||
addButton("Netzwerkspiel...", networkGameEvent, c);
|
|
||||||
|
|
||||||
setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
|
setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
|
||||||
new EmptyBorder(10, 10, 10, 10)));
|
new EmptyBorder(10, 10, 10, 10)));
|
||||||
|
@ -555,8 +561,43 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
tabbedPane.setSelectedIndex(0);
|
tabbedPane.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JButton addButton(String title, final Event event,
|
private void addDefaultButtons() {
|
||||||
GridBagConstraints c) {
|
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);
|
JButton button = new JButton(title);
|
||||||
button.addActionListener(new ActionListener() {
|
button.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -564,10 +605,18 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
event.emit();
|
event.emit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(button, c);
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enableNetworkMode(boolean enable) {
|
||||||
|
if (enable) {
|
||||||
|
addNetworkButtons();
|
||||||
|
} else {
|
||||||
|
addDefaultButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class PlayerSettingsPanel extends JPanel {
|
private class PlayerSettingsPanel extends JPanel {
|
||||||
private int playerNumber;
|
private int playerNumber;
|
||||||
private JButton colorButton;
|
private JButton colorButton;
|
||||||
|
|
Reference in a new issue