summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-21 19:16:16 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-21 19:16:16 +0200
commit5d0d5932971c456b85b142f9e483f0226dfefc2b (patch)
tree809b9b02de61fc92f8abd54b1651765f4d6b2547 /src/jrummikub/view
parentd09041304bee53b86c3ddd098a6ff39db85889f3 (diff)
downloadJRummikub-5d0d5932971c456b85b142f9e483f0226dfefc2b.tar
JRummikub-5d0d5932971c456b85b142f9e483f0226dfefc2b.zip
Make starting new rounds on network mode work
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@553 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view')
-rw-r--r--src/jrummikub/view/IView.java4
-rw-r--r--src/jrummikub/view/impl/View.java13
-rw-r--r--src/jrummikub/view/impl/WinPanel.java61
3 files changed, 62 insertions, 16 deletions
diff --git a/src/jrummikub/view/IView.java b/src/jrummikub/view/IView.java
index a88d002..6394ee0 100644
--- a/src/jrummikub/view/IView.java
+++ b/src/jrummikub/view/IView.java
@@ -366,6 +366,8 @@ public interface IView {
/** */
NONHUMAN_HAND_PANEL,
/** */
- WIN_PANEL
+ WIN_PANEL,
+ /** */
+ NETWORK_WIN_PANEL
}
}
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index 0f279ab..2829b1b 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -643,13 +643,16 @@ public class View extends JFrame implements IView {
}
private void doSetBottomPanel(BottomPanelType type) {
- boolean showStartTurnPanel = type == BottomPanelType.START_TURN_PANEL
- || type == BottomPanelType.INVALID_TURN_PANEL;
- startTurnPanel.setVisible(showStartTurnPanel);
+ boolean showStartTurnPanel = (type == BottomPanelType.START_TURN_PANEL || type == BottomPanelType.INVALID_TURN_PANEL);
startTurnPanel.setType(type);
- winPanel.setVisible(type == BottomPanelType.WIN_PANEL);
+ startTurnPanel.setVisible(showStartTurnPanel);
+
+ boolean showWinPanel = (type == BottomPanelType.WIN_PANEL || type == BottomPanelType.NETWORK_WIN_PANEL);
+ winPanel.setType(type);
+ winPanel.setVisible(showWinPanel);
+
playerPanel.setVisible((!showStartTurnPanel)
- && type != BottomPanelType.WIN_PANEL && type != null);
+ && (!showWinPanel) && type != null);
if (type == BottomPanelType.START_GAME_PANEL) {
table.setStoneSets(Collections.<Pair<StoneSet, Position>> emptyList());
diff --git a/src/jrummikub/view/impl/WinPanel.java b/src/jrummikub/view/impl/WinPanel.java
index 2134a8e..d274b19 100644
--- a/src/jrummikub/view/impl/WinPanel.java
+++ b/src/jrummikub/view/impl/WinPanel.java
@@ -7,11 +7,13 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JButton;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import jrummikub.util.Event;
import jrummikub.util.IEvent;
+import jrummikub.view.IView.BottomPanelType;
/**
* A panel that is displayed when a player has won
@@ -25,6 +27,7 @@ class WinPanel extends JPanel {
private final static int PANEL_MAX_WIDTH = 180;
private final static float MAX_BUTTON_FONT_SIZE = 12;
+ private JLabel waitingLabel;
private JButton newRoundButton;
private JButton newGameButton;
private JButton endProgramButton;
@@ -32,6 +35,7 @@ class WinPanel extends JPanel {
private Event endProgramEvent = new Event();
private Event newGameEvent = new Event();
private Event newRoundEvent = new Event();
+ private BottomPanelType type;
/**
* Creates a new WinPanel
@@ -41,6 +45,11 @@ class WinPanel extends JPanel {
setBorder(new EmptyBorder(PANEL_INSET, PANEL_INSET, PANEL_INSET,
PANEL_INSET));
+ waitingLabel = new JLabel("Warte auf Host...");
+ waitingLabel.setHorizontalAlignment(JLabel.CENTER);
+ waitingLabel.setVerticalAlignment(JLabel.CENTER);
+ add(waitingLabel);
+
newRoundButton = new JButton("Neue Runde");
newRoundButton.addActionListener(new ActionListener() {
@Override
@@ -108,22 +117,54 @@ class WinPanel extends JPanel {
width = width / 2 + PANEL_MAX_WIDTH / 2;
}
- int buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
- int buttonHeight = height;
+ int buttonWidth;
+ int buttonHeight;
+ int buttonY;
+ if (type == BottomPanelType.WIN_PANEL) {
+ buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
+ buttonHeight = height;
+ buttonY = y;
+ } else {
+ buttonWidth = (width - PANEL_SEPARATOR) / 2;
+ buttonHeight = height * 2 / 3 - PANEL_SEPARATOR;
+ buttonY = y + height - buttonHeight;
+ }
+ int labelHeight = height - buttonHeight - PANEL_SEPARATOR;
+
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
if (fontSize > MAX_BUTTON_FONT_SIZE)
fontSize = MAX_BUTTON_FONT_SIZE;
- newRoundButton.setBounds(x, y, buttonWidth, buttonHeight);
- newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
+ if (type == BottomPanelType.WIN_PANEL) {
+ waitingLabel.setVisible(false);
+ newRoundButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
+ newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
+ newRoundButton.setVisible(true);
+
+ newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, buttonY,
+ buttonWidth, buttonHeight);
+ newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
- newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y, buttonWidth,
- buttonHeight);
- newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
+ endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR),
+ buttonY, buttonWidth, buttonHeight);
+ endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
+ } else if (type == BottomPanelType.NETWORK_WIN_PANEL) {
+ waitingLabel.setBounds(x, y, width, labelHeight);
+ waitingLabel.setVisible(true);
- endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR), y,
- buttonWidth, buttonHeight);
- endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
+ newRoundButton.setVisible(false);
+
+ newGameButton.setBounds(x, buttonY, buttonWidth, buttonHeight);
+ newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
+
+ endProgramButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, buttonY,
+ buttonWidth, buttonHeight);
+ endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
+ }
+ }
+ void setType(BottomPanelType type) {
+ this.type = type;
+ rescale();
}
}