Don't show last player when a round has ended
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@340 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
acc7d3f11f
commit
eea3cb2188
2 changed files with 8 additions and 33 deletions
|
@ -188,7 +188,6 @@ public class View extends JFrame implements IView {
|
||||||
public void setCurrentPlayerName(String playerName) {
|
public void setCurrentPlayerName(String playerName) {
|
||||||
playerPanel.setCurrentPlayerName(playerName);
|
playerPanel.setCurrentPlayerName(playerName);
|
||||||
startTurnPanel.setCurrentPlayerName(playerName);
|
startTurnPanel.setCurrentPlayerName(playerName);
|
||||||
winPanel.setCurrentPlayerName(playerName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.awt.event.ComponentAdapter;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
@ -25,7 +24,6 @@ class WinPanel extends JPanel {
|
||||||
private final static int PANEL_MAX_WIDTH = 180;
|
private final static int PANEL_MAX_WIDTH = 180;
|
||||||
private final static float MAX_BUTTON_FONT_SIZE = 12;
|
private final static float MAX_BUTTON_FONT_SIZE = 12;
|
||||||
|
|
||||||
private JLabel winLabel;
|
|
||||||
private JButton newRoundButton;
|
private JButton newRoundButton;
|
||||||
private JButton newGameButton;
|
private JButton newGameButton;
|
||||||
private JButton endProgramButton;
|
private JButton endProgramButton;
|
||||||
|
@ -42,13 +40,6 @@ class WinPanel extends JPanel {
|
||||||
setBorder(new EmptyBorder(PANEL_INSET, PANEL_INSET, PANEL_INSET,
|
setBorder(new EmptyBorder(PANEL_INSET, PANEL_INSET, PANEL_INSET,
|
||||||
PANEL_INSET));
|
PANEL_INSET));
|
||||||
|
|
||||||
winLabel = new JLabel();
|
|
||||||
winLabel.setHorizontalAlignment(JLabel.CENTER);
|
|
||||||
winLabel.setHorizontalTextPosition(JLabel.CENTER);
|
|
||||||
winLabel.setVerticalAlignment(JLabel.CENTER);
|
|
||||||
winLabel.setVerticalTextPosition(JLabel.CENTER);
|
|
||||||
add(winLabel);
|
|
||||||
|
|
||||||
newRoundButton = new JButton("Neue Runde");
|
newRoundButton = new JButton("Neue Runde");
|
||||||
newRoundButton.addActionListener(new ActionListener() {
|
newRoundButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,16 +75,6 @@ class WinPanel extends JPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the name of the current player
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* the player name
|
|
||||||
*/
|
|
||||||
void setCurrentPlayerName(String name) {
|
|
||||||
winLabel.setText("Du hast gewonnen, " + name + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The new round event is emitted when the player wants to start a new round
|
* The new round event is emitted when the player wants to start a new round
|
||||||
*
|
*
|
||||||
|
@ -119,34 +100,29 @@ class WinPanel extends JPanel {
|
||||||
private void rescale() {
|
private void rescale() {
|
||||||
Insets insets = getInsets();
|
Insets insets = getInsets();
|
||||||
int x = insets.left, y = insets.top, width = getWidth() - insets.left
|
int x = insets.left, y = insets.top, width = getWidth() - insets.left
|
||||||
- insets.right, height = getHeight() - insets.top
|
- insets.right, height = getHeight() - insets.top - insets.bottom;
|
||||||
- insets.bottom;
|
|
||||||
|
|
||||||
if (width > PANEL_MAX_WIDTH) {
|
if (width > PANEL_MAX_WIDTH) {
|
||||||
x += (width - PANEL_MAX_WIDTH) / 4;
|
x += (width - PANEL_MAX_WIDTH) / 4;
|
||||||
width = width / 2 + PANEL_MAX_WIDTH / 2;
|
width = width / 2 + PANEL_MAX_WIDTH / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int firstLineHeight = (int) ((height - PANEL_SEPARATOR) * PANEL_FIRST_LINE_HEIGHT);
|
|
||||||
int buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
|
int buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
|
||||||
int buttonHeight = height - PANEL_SEPARATOR - firstLineHeight;
|
int buttonHeight = height;
|
||||||
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
|
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
|
||||||
if (fontSize > MAX_BUTTON_FONT_SIZE)
|
if (fontSize > MAX_BUTTON_FONT_SIZE)
|
||||||
fontSize = MAX_BUTTON_FONT_SIZE;
|
fontSize = MAX_BUTTON_FONT_SIZE;
|
||||||
|
|
||||||
winLabel.setBounds(x, y, width, firstLineHeight);
|
newRoundButton.setBounds(x, y, buttonWidth, buttonHeight);
|
||||||
newRoundButton.setBounds(x, y + firstLineHeight + PANEL_SEPARATOR,
|
|
||||||
buttonWidth, buttonHeight);
|
|
||||||
newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
|
newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
|
||||||
|
|
||||||
newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y
|
newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y, buttonWidth,
|
||||||
+ firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight);
|
buttonHeight);
|
||||||
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
||||||
|
|
||||||
endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR), y
|
endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR), y,
|
||||||
+ firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight);
|
buttonWidth, buttonHeight);
|
||||||
endProgramButton.setFont(endProgramButton.getFont()
|
endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
|
||||||
.deriveFont(fontSize));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue