summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/View.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl/View.java')
-rw-r--r--src/jrummikub/view/impl/View.java37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index e3d58ea..6300109 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -23,6 +23,7 @@ public class View extends JFrame implements IView {
private TablePanel table;
private PlayerPanel playerPanel;
private StartTurnPanel startTurnPanel;
+ private WinPanel winPanel;
private final static float PLAYER_PANEL_RATIO = 0.14f;
private final static int PLAYER_PANEL_BORDER_WIDTH = 1;
@@ -56,14 +57,18 @@ public class View extends JFrame implements IView {
add(table);
playerPanel = new PlayerPanel();
- playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0, 0,
- Color.BLACK));
+ playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0,
+ 0, Color.BLACK));
add(playerPanel);
startTurnPanel = new StartTurnPanel();
startTurnPanel.setVisible(false);
add(startTurnPanel);
+ winPanel = new WinPanel();
+ winPanel.setVisible(false);
+ add(winPanel);
+
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
@@ -71,8 +76,9 @@ public class View extends JFrame implements IView {
int width = getWidth() - insets.left - insets.right, height = getHeight()
- insets.top - insets.bottom;
- int playerPanelHeight = even(Math.pow((double) width * width * height,
- 1 / 3.0) * PLAYER_PANEL_RATIO)
+ int playerPanelHeight = even(Math.pow((double) width * width
+ * height, 1 / 3.0)
+ * PLAYER_PANEL_RATIO)
+ PLAYER_PANEL_BORDER_WIDTH;
if (playerPanelHeight > PLAYER_PANEL_MAX_HEIGHT)
playerPanelHeight = PLAYER_PANEL_MAX_HEIGHT;
@@ -82,7 +88,9 @@ public class View extends JFrame implements IView {
table.setBounds(0, 0, width, tableHeight);
table.validate();
playerPanel.setBounds(0, tableHeight, width, playerPanelHeight);
- startTurnPanel.setBounds(0, tableHeight, width, playerPanelHeight);
+ startTurnPanel.setBounds(0, tableHeight, width,
+ playerPanelHeight);
+ winPanel.setBounds(0, tableHeight, width, playerPanelHeight);
}
});
@@ -99,6 +107,14 @@ public class View extends JFrame implements IView {
public void enableStartTurnPanel(boolean enable) {
playerPanel.setVisible(!enable);
startTurnPanel.setVisible(enable);
+ winPanel.setVisible(!enable);
+ }
+
+ @Override
+ public void enableWinPanel(boolean enable) {
+ playerPanel.setVisible(!enable);
+ startTurnPanel.setVisible(!enable);
+ winPanel.setVisible(enable);
}
@Override
@@ -111,4 +127,15 @@ public class View extends JFrame implements IView {
public IEvent getStartTurnEvent() {
return startTurnPanel.getStartTurnEvent();
}
+
+ @Override
+ public IEvent getNewGameEvent() {
+ return winPanel.getNewGameEvent();
+ }
+
+ @Override
+ public IEvent getQuitEvent() {
+ return winPanel.getQuitEvent();
+ }
+
}