diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-22 03:08:37 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-22 03:08:37 +0200 |
commit | d6c4da62243310b85a82e73e55249de9af7fdb11 (patch) | |
tree | ecdb215533c41a9d6f02c0770ea76a38f8b4867b /src/jrummikub/view/impl | |
parent | 62a55c0a918b1d91338a68ee89211006e11785bf (diff) | |
download | JRummikub-d6c4da62243310b85a82e73e55249de9af7fdb11.tar JRummikub-d6c4da62243310b85a82e73e55249de9af7fdb11.zip |
Show in start turn panel if a player has redealed or drawn the last stone
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@570 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl')
-rw-r--r-- | src/jrummikub/view/impl/StartTurnPanel.java | 99 | ||||
-rw-r--r-- | src/jrummikub/view/impl/View.java | 14 |
2 files changed, 89 insertions, 24 deletions
diff --git a/src/jrummikub/view/impl/StartTurnPanel.java b/src/jrummikub/view/impl/StartTurnPanel.java index 4c895b5..d3f139d 100644 --- a/src/jrummikub/view/impl/StartTurnPanel.java +++ b/src/jrummikub/view/impl/StartTurnPanel.java @@ -23,17 +23,23 @@ import jrummikub.view.IView.BottomPanelType; class StartTurnPanel extends JPanel {
private final static int PANEL_INSET = 15;
private final static int PANEL_SEPARATOR = 10;
- private final static float PANEL_FIRST_LINE_HEIGHT = 0.375f;
+ private final static float PANEL_FIRST_LINE_HEIGHT = 0.2f;
private final static int PANEL_MAX_WIDTH = 180;
private final static float MAX_BUTTON_FONT_SIZE = 12;
private JLabel startTurnLabel;
+ private JLabel extraLabel;
private JButton startTurnButton;
private Event startTurnEvent = new Event();
private Event acknowledgeInvalidEvent = new Event();
private Event buttonEvent = startTurnEvent;
+ private BottomPanelType type;
+ private Color currentPlayerColor;
+ private String currentPlayerName;
+ private String redealedPlayerName;
+ private String lastStonePlayerName;
/**
* Creates a new StartTurnPanel
@@ -49,6 +55,12 @@ class StartTurnPanel extends JPanel { startTurnLabel.putClientProperty("html.disable", Boolean.TRUE);
add(startTurnLabel);
+ extraLabel = new JLabel();
+ extraLabel.setHorizontalAlignment(JLabel.CENTER);
+ extraLabel.setVerticalAlignment(JLabel.CENTER);
+ extraLabel.putClientProperty("html.disable", Boolean.TRUE);
+ add(extraLabel);
+
startTurnButton = new JButton("Zug beginnen");
startTurnButton.addActionListener(new ActionListener() {
@Override
@@ -66,14 +78,6 @@ class StartTurnPanel extends JPanel { });
}
- void setCurrentPlayerName(String playerName) {
- startTurnLabel.setText(playerName + " ist jetzt an der Reihe.");
- }
-
- void setCurrentPlayerColor(Color color) {
- startTurnLabel.setIcon(ImageUtil.createColorIcon(color, 12, 1));
- }
-
void setInitialMeldError(int points) {
startTurnLabel.setIcon(null);
startTurnLabel.setText("Es wurden weniger als " + points
@@ -105,34 +109,83 @@ class StartTurnPanel extends JPanel { int firstLineHeight = (int) ((height - PANEL_SEPARATOR) * PANEL_FIRST_LINE_HEIGHT);
int buttonWidth = width;
- int buttonHeight = height - PANEL_SEPARATOR - firstLineHeight;
+ int buttonHeight = height - 2 * PANEL_SEPARATOR - 2 * firstLineHeight;
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
if (fontSize > MAX_BUTTON_FONT_SIZE)
fontSize = MAX_BUTTON_FONT_SIZE;
- startTurnLabel.setBounds(x, y, width, firstLineHeight);
- startTurnButton.setBounds(x, y + firstLineHeight + PANEL_SEPARATOR,
+ if (type == BottomPanelType.START_REDEAL_TURN_PANEL
+ || type == BottomPanelType.START_LAST_TURN_PANEL) {
+ startTurnLabel.setBounds(x, y, width, firstLineHeight);
+ extraLabel.setBounds(x, y + firstLineHeight + PANEL_SEPARATOR, width,
+ firstLineHeight);
+ extraLabel.setVisible(true);
+ } else {
+ startTurnLabel.setBounds(x, y, width, 2 * firstLineHeight
+ + PANEL_SEPARATOR);
+ extraLabel.setVisible(false);
+ }
+ startTurnButton.setBounds(x, y + 2 * firstLineHeight + 2 * PANEL_SEPARATOR,
buttonWidth, buttonHeight);
startTurnButton.setFont(startTurnButton.getFont().deriveFont(fontSize));
}
- public void setType(BottomPanelType type) {
+ void setCurrentPlayerName(String playerName) {
+ currentPlayerName = playerName;
+ update();
+ }
+
+ void setCurrentPlayerColor(Color color) {
+ currentPlayerColor = color;
+ update();
+ }
+
+ void setRedealedPlayerName(String name) {
+ redealedPlayerName = name;
+ update();
+ }
+
+ void setLastStonePlayerName(String name) {
+ lastStonePlayerName = name;
+ update();
+ }
+
+ void setType(BottomPanelType type) {
+ this.type = type;
+ update();
+ }
+
+ private void update() {
if (type == null) {
return;
}
+ startTurnLabel
+ .setIcon(ImageUtil.createColorIcon(currentPlayerColor, 12, 1));
+ startTurnLabel.setText(currentPlayerName + " ist jetzt an der Reihe.");
+ extraLabel.setText("");
+ startTurnButton.setText("Zug beginnen");
+ buttonEvent = startTurnEvent;
+
switch (type) {
- case START_TURN_PANEL:
- startTurnButton.setText("Zug beginnen");
- buttonEvent = startTurnEvent;
- break;
- case INVALID_TURN_PANEL:
- startTurnLabel.setIcon(null);
- startTurnLabel.setText("Es liegen ung\u00FCltige Serien auf dem Tisch.");
- startTurnButton.setText("N\u00E4chster Spieler");
- buttonEvent = acknowledgeInvalidEvent;
- break;
+ case START_REDEAL_TURN_PANEL:
+ extraLabel.setText(redealedPlayerName + " hat neu geben lassen.");
+ break;
+
+ case START_LAST_TURN_PANEL:
+ extraLabel.setText(lastStonePlayerName
+ + " hat den letzten Stein gezogen.");
+ break;
+
+ case INVALID_TURN_PANEL:
+ startTurnLabel.setIcon(null);
+ startTurnLabel
+ .setText("Es liegen ung\u00FCltige Serien auf dem Tisch.");
+ startTurnButton.setText("N\u00E4chster Spieler");
+ buttonEvent = acknowledgeInvalidEvent;
+ break;
}
+ rescale();
}
}
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index fe2c1eb..4940999 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -582,6 +582,16 @@ public class View extends JFrame implements IView { } @Override + public void setRedealedPlayerName(String name) { + startTurnPanel.setRedealedPlayerName(name); + } + + @Override + public void setLastStonePlayerName(String name) { + startTurnPanel.setLastStonePlayerName(name); + } + + @Override public void setCurrentPlayerHasLaidOut(boolean hasLaidOut) { playerPanel.setHasLaidOut(hasLaidOut); } @@ -657,7 +667,9 @@ public class View extends JFrame implements IView { } private void doSetBottomPanel(BottomPanelType type) { - boolean showStartTurnPanel = (type == BottomPanelType.START_TURN_PANEL || type == BottomPanelType.INVALID_TURN_PANEL); + boolean showStartTurnPanel = (type == BottomPanelType.START_TURN_PANEL + || type == BottomPanelType.START_REDEAL_TURN_PANEL + || type == BottomPanelType.START_LAST_TURN_PANEL || type == BottomPanelType.INVALID_TURN_PANEL); startTurnPanel.setType(type); startTurnPanel.setVisible(showStartTurnPanel); |