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 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public class NetworkSettingsControl extends SettingsControl {
|
|||
IView view, GameSettings settings) {
|
||||
super(view, settings);
|
||||
this.connectionControl = connectionControl;
|
||||
view.getSettingsPanel().enableNetworkMode(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,11 @@ public class PlayerSettings implements Serializable {
|
|||
/** */
|
||||
HUMAN,
|
||||
/** */
|
||||
COMPUTER
|
||||
COMPUTER,
|
||||
/** */
|
||||
VACANT,
|
||||
/** */
|
||||
NETWORK
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1963640115089275992L;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
|
@ -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() {
|
||||
|
@ -193,6 +197,11 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
|||
return setVariantChildrenEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent getBackEvent() {
|
||||
return backEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setError(SettingsError error) {
|
||||
switch (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);
|
||||
buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout(new GridBagLayout());
|
||||
add(buttonPanel, c);
|
||||
|
||||
c.weightx = 0;
|
||||
add(Box.createHorizontalStrut(10), c);
|
||||
startButton = createButton("Spiel starten", startGameEvent);
|
||||
|
||||
c.weightx = 1;
|
||||
addButton("Spiel laden...", loadGameEvent, c);
|
||||
loadButton = createButton("Spiel laden...", loadGameEvent);
|
||||
networkButton = createButton("Netzwerkspiel...", networkGameEvent);
|
||||
backButton = createButton("Zur\u00fcck", backEvent);
|
||||
|
||||
c.weightx = 0;
|
||||
add(Box.createHorizontalStrut(10), c);
|
||||
|
||||
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;
|
||||
|
|
Reference in a new issue