Halbfertige Dinge für seeHandSize

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@519 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Ida Massow 2011-06-21 00:32:17 +02:00
parent b0fedc9808
commit a0573a5928
3 changed files with 74 additions and 33 deletions

View file

@ -28,6 +28,7 @@ public class GameSettings implements Serializable {
private int totalTime; private int totalTime;
private boolean noLimits; private boolean noLimits;
private HashSet<StoneColor> stoneColors; private HashSet<StoneColor> stoneColors;
private boolean seeHandSize;
/** /**
* Creates new GameSettings with default values * Creates new GameSettings with default values
@ -48,6 +49,7 @@ public class GameSettings implements Serializable {
numberOfStonesDealt = 14; numberOfStonesDealt = 14;
totalTime = 60; totalTime = 60;
noLimits = false; noLimits = false;
seeHandSize = false;
stoneColors = new HashSet<StoneColor>(Arrays.asList(BLACK, BLUE, stoneColors = new HashSet<StoneColor>(Arrays.asList(BLACK, BLUE,
ORANGE, RED)); ORANGE, RED));
} }
@ -184,6 +186,10 @@ public class GameSettings implements Serializable {
return noLimits; return noLimits;
} }
public boolean doSeeHandSize() {
return seeHandSize;
}
/** /**
* Set whether "No-Limits" rules are used * Set whether "No-Limits" rules are used
* *
@ -194,6 +200,10 @@ public class GameSettings implements Serializable {
this.noLimits = noLimits; this.noLimits = noLimits;
} }
public void setSeeHandSize(boolean see) {
seeHandSize = see;
}
/** /**
* Get stone colors used * Get stone colors used
* *

View file

@ -245,6 +245,8 @@ public interface ISettingsPanel {
*/ */
public void setPlayerColors(Set<Color> colors); public void setPlayerColors(Set<Color> colors);
public IEvent1<Boolean> getChangeSeeHandSize();
/** /**
* Specifies the different kinds of settings errors that can be displayed * Specifies the different kinds of settings errors that can be displayed
*/ */

View file

@ -96,6 +96,7 @@ 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 JCheckBox seeHandSizeBox;
private JPanel colorSelectionPanel; private JPanel colorSelectionPanel;
private Map<StoneColor, JToggleButton> colorButtons = new HashMap<StoneColor, JToggleButton>(); private Map<StoneColor, JToggleButton> colorButtons = new HashMap<StoneColor, JToggleButton>();
private JPanel colorLabelPanel; private JPanel colorLabelPanel;
@ -107,6 +108,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private JLabel jokerNumberLabel; private JLabel jokerNumberLabel;
private JLabel timeLabel; private JLabel timeLabel;
private JLabel noLimitsLabel; private JLabel noLimitsLabel;
private JLabel seeHandSizeLabel;
private JButton loadButton; private JButton loadButton;
private JButton networkButton; private JButton networkButton;
@ -131,6 +133,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private Event1<Set<StoneColor>> changeStoneColorsEvent = new Event1<Set<StoneColor>>(); private Event1<Set<StoneColor>> changeStoneColorsEvent = new Event1<Set<StoneColor>>();
private Event1<Integer> changeTimeEvent = new Event1<Integer>(); private Event1<Integer> changeTimeEvent = new Event1<Integer>();
private Event1<Boolean> changeNoLimitsEvent = new Event1<Boolean>(); private Event1<Boolean> changeNoLimitsEvent = new Event1<Boolean>();
private Event1<Boolean> changeSeeHandSizeEvent = new Event1<Boolean>();
private Event setVariantDefaultEvent = new Event(); private Event setVariantDefaultEvent = new Event();
private Event setVariantChildrenEvent = new Event(); private Event setVariantChildrenEvent = new Event();
@ -212,6 +215,11 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
return changeNoLimitsEvent; return changeNoLimitsEvent;
} }
@Override
public IEvent1<Boolean> getChangeSeeHandSize() {
return changeSeeHandSizeEvent;
}
@Override @Override
public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent() { public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent() {
return changeStoneColorsEvent; return changeStoneColorsEvent;
@ -320,7 +328,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
@Override @Override
public void setGameSettings(GameSettings gameSettings) { public void setGameSettings(GameSettings gameSettings) {
while (playerSettingsPanels.size() > gameSettings.getPlayerList().size()) { while (playerSettingsPanels.size() > gameSettings.getPlayerList()
.size()) {
removePlayerSettingsPanel(); removePlayerSettingsPanel();
} }
@ -329,21 +338,25 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
if (i < playerTypeChoices.size()) { if (i < playerTypeChoices.size()) {
choices = playerTypeChoices.get(i); choices = playerTypeChoices.get(i);
} }
updatePlayerSettingsPanel(i, gameSettings.getPlayerList().get(i), choices); updatePlayerSettingsPanel(i, gameSettings.getPlayerList().get(i),
choices);
} }
setInitialSettingsValue(gameSettings); setInitialSettingsValue(gameSettings);
initialMeldThresholdLabel.setText(gameSettings.getInitialMeldThreshold() initialMeldThresholdLabel.setText(gameSettings
+ " Punkte"); .getInitialMeldThreshold() + " Punkte");
stoneSetNumberLabel.setText(Integer.toString(gameSettings stoneSetNumberLabel.setText(Integer.toString(gameSettings
.getStoneSetNumber())); .getStoneSetNumber()));
highestValueLabel.setText(Integer.toString(gameSettings.getHighestValue())); highestValueLabel.setText(Integer.toString(gameSettings
.getHighestValue()));
numberOfStonesDealtLabel.setText(Integer.toString(gameSettings numberOfStonesDealtLabel.setText(Integer.toString(gameSettings
.getNumberOfStonesDealt())); .getNumberOfStonesDealt()));
jokerNumberLabel.setText(Integer.toString(gameSettings.getJokerNumber())); jokerNumberLabel
.setText(Integer.toString(gameSettings.getJokerNumber()));
timeLabel.setText(gameSettings.getTotalTime() + " Sekunden"); timeLabel.setText(gameSettings.getTotalTime() + " Sekunden");
noLimitsLabel.setText(gameSettings.isNoLimits() ? "An" : "Aus"); noLimitsLabel.setText(gameSettings.isNoLimits() ? "An" : "Aus");
//seeHandSizeLabel.setText(gameSettings.doSeeHandSize() ? "An" : "Aus");
colorLabelPanel.removeAll(); colorLabelPanel.removeAll();
@ -362,14 +375,16 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
} }
private void setInitialSettingsValue(GameSettings gameSettings) { private void setInitialSettingsValue(GameSettings gameSettings) {
initialMeldThresholdSpinner initialMeldThresholdSpinner.setValue(gameSettings
.setValue(gameSettings.getInitialMeldThreshold()); .getInitialMeldThreshold());
stoneSetNumberSpinner.setValue(gameSettings.getStoneSetNumber()); stoneSetNumberSpinner.setValue(gameSettings.getStoneSetNumber());
highestValueSpinner.setValue(gameSettings.getHighestValue()); highestValueSpinner.setValue(gameSettings.getHighestValue());
numberOfStonesDealtSpinner.setValue(gameSettings.getNumberOfStonesDealt()); numberOfStonesDealtSpinner.setValue(gameSettings
.getNumberOfStonesDealt());
jokerNumberSpinner.setValue(gameSettings.getJokerNumber()); jokerNumberSpinner.setValue(gameSettings.getJokerNumber());
timeSpinner.setValue(gameSettings.getTotalTime()); timeSpinner.setValue(gameSettings.getTotalTime());
noLimitsBox.setSelected(gameSettings.isNoLimits()); noLimitsBox.setSelected(gameSettings.isNoLimits());
seeHandSizeBox.setSelected(gameSettings.doSeeHandSize());
} }
private void updatePlayerSettingsPanel(int i, PlayerSettings settings, private void updatePlayerSettingsPanel(int i, PlayerSettings settings,
@ -384,8 +399,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private void addPlayerSettingsPanel(int i, PlayerSettings settings, private void addPlayerSettingsPanel(int i, PlayerSettings settings,
List<Type> choices) { List<Type> choices) {
PlayerSettingsPanel panel = new PlayerSettingsPanel(i, settings, choices, PlayerSettingsPanel panel = new PlayerSettingsPanel(i, settings,
settingsMode != SettingsMode.NETWORK_OFFER choices, settingsMode != SettingsMode.NETWORK_OFFER
&& settingsMode != SettingsMode.NETWORK_JOIN); && settingsMode != SettingsMode.NETWORK_JOIN);
playerSettingsPanels.add(panel); playerSettingsPanels.add(panel);
playerSettingsViewport.add(panel, playerSettingsViewport.add(panel,
@ -395,8 +410,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
} }
private void removePlayerSettingsPanel() { private void removePlayerSettingsPanel() {
PlayerSettingsPanel p = playerSettingsPanels.remove(playerSettingsPanels PlayerSettingsPanel p = playerSettingsPanels
.size() - 1); .remove(playerSettingsPanels.size() - 1);
playerSettingsViewport.remove(p); playerSettingsViewport.remove(p);
} }
@ -418,7 +433,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
playerSettingsViewport.add(addPlayerPanel); playerSettingsViewport.add(addPlayerPanel);
addPlayerButton = new JButton("+"); addPlayerButton = new JButton("+");
addPlayerButton.setFont(addPlayerButton.getFont().deriveFont(Font.BOLD)); addPlayerButton
.setFont(addPlayerButton.getFont().deriveFont(Font.BOLD));
addPlayerButton.addActionListener(new ActionListener() { addPlayerButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -467,7 +483,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
makeOptionLabel(row++, "H\u00f6chster Steinwert:"); makeOptionLabel(row++, "H\u00f6chster Steinwert:");
highestValueLabel = new JLabel(); highestValueLabel = new JLabel();
highestValueSpinner = createOptionSpinner(3, 99, 1, changeHighestValueEvent); highestValueSpinner = createOptionSpinner(3, 99, 1,
changeHighestValueEvent);
makeOptionLabel(row++, "Anzahl Startsteine:"); makeOptionLabel(row++, "Anzahl Startsteine:");
numberOfStonesDealtLabel = new JLabel(); numberOfStonesDealtLabel = new JLabel();
@ -476,7 +493,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
makeOptionLabel(row++, "Jokeranzahl:"); makeOptionLabel(row++, "Jokeranzahl:");
jokerNumberLabel = new JLabel(); jokerNumberLabel = new JLabel();
jokerNumberSpinner = createOptionSpinner(0, 999, 1, changeJokerNumberEvent); jokerNumberSpinner = createOptionSpinner(0, 999, 1,
changeJokerNumberEvent);
makeOptionLabel(row++, "Zeit f\u00fcr Spielzug:"); makeOptionLabel(row++, "Zeit f\u00fcr Spielzug:");
timeLabel = new JLabel(); timeLabel = new JLabel();
@ -485,6 +503,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
makeOptionLabel(row++, "No Limits:"); makeOptionLabel(row++, "No Limits:");
noLimitsLabel = new JLabel(); noLimitsLabel = new JLabel();
noLimitsBox = createOptionCheckbox(changeNoLimitsEvent); noLimitsBox = createOptionCheckbox(changeNoLimitsEvent);
seeHandSizeBox = createOptionCheckbox(changeSeeHandSizeEvent);
makeOptionLabel(row++, "Steinanzahl anzeigen");
makeOptionLabel(row, "Steinfarben:"); makeOptionLabel(row, "Steinfarben:");
createColorSelectionPanel(); createColorSelectionPanel();
@ -510,6 +531,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
optionsPanel.remove(timeLabel); optionsPanel.remove(timeLabel);
optionsPanel.remove(noLimitsBox); optionsPanel.remove(noLimitsBox);
optionsPanel.remove(noLimitsLabel); optionsPanel.remove(noLimitsLabel);
optionsPanel.remove(seeHandSizeBox);
optionsPanel.remove(colorSelectionPanel); optionsPanel.remove(colorSelectionPanel);
optionsPanel.remove(colorLabelPanel); optionsPanel.remove(colorLabelPanel);
@ -528,6 +550,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
addOptionPanelComponent(jokerNumberSpinner, false, row++); addOptionPanelComponent(jokerNumberSpinner, false, row++);
addOptionPanelComponent(timeSpinner, false, row++); addOptionPanelComponent(timeSpinner, false, row++);
addOptionPanelComponent(noLimitsBox, false, row++); addOptionPanelComponent(noLimitsBox, false, row++);
addOptionPanelComponent(seeHandSizeBox, false, row++);
addOptionPanelComponent(colorSelectionPanel, false, row++); addOptionPanelComponent(colorSelectionPanel, false, row++);
} }
@ -542,6 +565,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
addOptionPanelComponent(jokerNumberLabel, false, row++); addOptionPanelComponent(jokerNumberLabel, false, row++);
addOptionPanelComponent(timeLabel, false, row++); addOptionPanelComponent(timeLabel, false, row++);
addOptionPanelComponent(noLimitsLabel, false, row++); addOptionPanelComponent(noLimitsLabel, false, row++);
addOptionPanelComponent(seeHandSizeBox, false, row++);
addOptionPanelComponent(colorLabelPanel, false, row++); addOptionPanelComponent(colorLabelPanel, false, row++);
} }
@ -629,8 +653,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
final Event1<Integer> targetEvent) { final Event1<Integer> targetEvent) {
final JSpinner spinner = new JSpinner(); final JSpinner spinner = new JSpinner();
spinner.setModel(new SpinnerNumberModel(min, min, max, step)); spinner.setModel(new SpinnerNumberModel(min, min, max, step));
spinner spinner.setPreferredSize(new Dimension(60,
.setPreferredSize(new Dimension(60, spinner.getMinimumSize().height)); spinner.getMinimumSize().height));
spinner.addChangeListener(new ChangeListener() { spinner.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
@ -691,8 +715,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
addDefaultButtons(); addDefaultButtons();
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder( setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
10, 10, 10, 10))); new EmptyBorder(10, 10, 10, 10)));
} }
void resetTabbedPane() { void resetTabbedPane() {
@ -820,7 +844,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private JLabel typeLabel; private JLabel typeLabel;
public void setSettings(PlayerSettings settings) { public void setSettings(PlayerSettings settings) {
if (nameField != null && !nameField.getText().equals(settings.getName())) { if (nameField != null
&& !nameField.getText().equals(settings.getName())) {
nameField.setText(settings.getName()); nameField.setText(settings.getName());
} }
if (nameLabel != null) { if (nameLabel != null) {
@ -837,8 +862,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
if (typeLabel != null) { if (typeLabel != null) {
typeLabel.setText(getTypeLabel(settings.getType())); typeLabel.setText(getTypeLabel(settings.getType()));
} }
colorButton colorButton.setIcon(ImageUtil.createColorIcon(settings.getColor(),
.setIcon(ImageUtil.createColorIcon(settings.getColor(), 16, 2)); 16, 2));
colorChangable = !((settingsMode == SettingsMode.NETWORK_JOIN | settingsMode == SettingsMode.NETWORK_OFFER) & settings colorChangable = !((settingsMode == SettingsMode.NETWORK_JOIN | settingsMode == SettingsMode.NETWORK_OFFER) & settings
.getType() != Type.HUMAN); .getType() != Type.HUMAN);
@ -932,7 +957,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
c.gridy = 0; c.gridy = 0;
add(colorButton, c); add(colorButton, c);
nameField.getDocument().addDocumentListener(new NameChangeListener()); nameField.getDocument().addDocumentListener(
new NameChangeListener());
c2.gridy = 0; c2.gridy = 0;
c2.weightx = 1; c2.weightx = 1;
c2.fill = GridBagConstraints.HORIZONTAL; c2.fill = GridBagConstraints.HORIZONTAL;
@ -947,8 +973,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
}); });
playerType.setPreferredSize(new Dimension(120, playerType playerType.setPreferredSize(new Dimension(120, playerType
.getPreferredSize().height)); .getPreferredSize().height));
playerType.setMinimumSize(new Dimension(120, playerType.setMinimumSize(new Dimension(120, playerType
playerType.getMinimumSize().height)); .getMinimumSize().height));
add(playerType, c); add(playerType, c);
removeButton = new JButton("\u00d7"); removeButton = new JButton("\u00d7");
@ -991,8 +1017,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
typeLabel.setBorder(new EmptyBorder(3, 7, 3, 7)); typeLabel.setBorder(new EmptyBorder(3, 7, 3, 7));
typeLabel.setPreferredSize(new Dimension(120, typeLabel typeLabel.setPreferredSize(new Dimension(120, typeLabel
.getPreferredSize().height)); .getPreferredSize().height));
typeLabel.setMinimumSize(new Dimension(120, typeLabel.setMinimumSize(new Dimension(120, typeLabel
typeLabel.getMinimumSize().height)); .getMinimumSize().height));
add(typeLabel, c); add(typeLabel, c);
} }
@ -1000,8 +1026,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension preferredSize = super.getPreferredSize(); Dimension preferredSize = super.getPreferredSize();
for (Component component : this.getComponents()) { for (Component component : this.getComponents()) {
preferredSize preferredSize.setSize(
.setSize(preferredSize.width, Math.max(preferredSize.height, preferredSize.width,
Math.max(preferredSize.height,
component.getPreferredSize().height)); component.getPreferredSize().height));
} }
return preferredSize; return preferredSize;
@ -1011,8 +1038,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
public Dimension getMaximumSize() { public Dimension getMaximumSize() {
Dimension preferredSize = super.getPreferredSize(); Dimension preferredSize = super.getPreferredSize();
for (Component component : this.getComponents()) { for (Component component : this.getComponents()) {
preferredSize preferredSize.setSize(
.setSize(Integer.MAX_VALUE, Math.max(preferredSize.height, Integer.MAX_VALUE,
Math.max(preferredSize.height,
component.getPreferredSize().height)); component.getPreferredSize().height));
} }
return preferredSize; return preferredSize;
@ -1046,7 +1074,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
add(new ColorButton(c, menu)); add(new ColorButton(c, menu));
} else { } else {
add(new JLabel(ImageUtil.createColorIcon( add(new JLabel(ImageUtil.createColorIcon(
UIManager.getColor("PopupMenu.background"), 16, 0))); UIManager.getColor("PopupMenu.background"), 16,
0)));
} }
} }