diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-24 23:15:21 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-24 23:15:21 +0200 |
commit | 6df3d5fe32be5493560cd4995ab91c2a4cef42fc (patch) | |
tree | b8b88731ecb9572e966871d9944e5604ec45c62e | |
parent | 79bffeba5d42a5b228c52f69b9e0b4e88f2e60e8 (diff) | |
download | JRummikub-6df3d5fe32be5493560cd4995ab91c2a4cef42fc.tar JRummikub-6df3d5fe32be5493560cd4995ab91c2a4cef42fc.zip |
Moved displaying of win panel in game control
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@270 72836036-5685-4462-b002-a69064685172
-rw-r--r-- | mock/jrummikub/view/MockView.java | 8 | ||||
-rw-r--r-- | src/jrummikub/control/GameControl.java | 24 | ||||
-rw-r--r-- | src/jrummikub/control/RoundControl.java | 1 | ||||
-rw-r--r-- | src/jrummikub/view/IView.java | 6 | ||||
-rw-r--r-- | src/jrummikub/view/impl/View.java | 8 | ||||
-rw-r--r-- | src/jrummikub/view/impl/WinPanel.java | 42 | ||||
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 1 |
7 files changed, 50 insertions, 40 deletions
diff --git a/mock/jrummikub/view/MockView.java b/mock/jrummikub/view/MockView.java index 1f8c9a8..95996a4 100644 --- a/mock/jrummikub/view/MockView.java +++ b/mock/jrummikub/view/MockView.java @@ -32,7 +32,7 @@ public class MockView implements IView { /** */ public MockEvent quitEvent = new MockEvent(); /** */ - public MockEvent newGameEvent = new MockEvent(); + public MockEvent newRoundEvent = new MockEvent(); @Override public MockTablePanel getTablePanel() { @@ -75,13 +75,13 @@ public class MockView implements IView { } @Override - public IEvent getQuitEvent() { + public IEvent getFinalScoreEvent() { return quitEvent; } @Override - public IEvent getNewGameEvent() { - return newGameEvent; + public IEvent getNewRoundEvent() { + return newRoundEvent; } }
\ No newline at end of file diff --git a/src/jrummikub/control/GameControl.java b/src/jrummikub/control/GameControl.java index 1d50bc6..9690bb4 100644 --- a/src/jrummikub/control/GameControl.java +++ b/src/jrummikub/control/GameControl.java @@ -1,9 +1,13 @@ package jrummikub.control; +import java.util.ArrayList; +import java.util.List; + import jrummikub.model.GameSettings; import jrummikub.model.GameState; import jrummikub.model.IRoundState; import jrummikub.model.RoundState; +import jrummikub.util.Connection; import jrummikub.util.IListener; import jrummikub.view.IView; @@ -15,6 +19,7 @@ public class GameControl { private IView view; private RoundControl roundControl; private GameState gameState; + private List<Connection> connections = new ArrayList<Connection>(); /** * Constructor @@ -31,18 +36,18 @@ public class GameControl { gameState = new GameState(); gameState.setFirstRoundFirstPlayer((int)(Math.random() * gameSettings.getPlayerList().size())); - view.getNewGameEvent().add(new IListener() { + connections.add(view.getNewRoundEvent().add(new IListener() { @Override public void handle() { startRound(); } - }); - view.getQuitEvent().add(new IListener() { + })); + connections.add(view.getFinalScoreEvent().add(new IListener() { @Override public void handle() { - quitProgram(); + finalScore(); } - }); + })); } /** @@ -67,14 +72,19 @@ public class GameControl { @Override public void handle() { - roundControl = null; + endOfRound(); } }); roundControl.startRound(); } + + private void endOfRound() { + roundControl = null; + view.enableWinPanel(true); + } - private void quitProgram() { + private void finalScore() { System.exit(0); } diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index 440e581..1829725 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -242,7 +242,6 @@ public class RoundControl { c.remove(); } endOfRoundEvent.emit(); - view.enableWinPanel(true); roundFinished = true; } } diff --git a/src/jrummikub/view/IView.java b/src/jrummikub/view/IView.java index 5828edd..8514c21 100644 --- a/src/jrummikub/view/IView.java +++ b/src/jrummikub/view/IView.java @@ -72,12 +72,12 @@ public interface IView { * * @return the event */ - IEvent getQuitEvent(); + IEvent getFinalScoreEvent(); /** - * The new game event is emitted when the player wants to start a new game + * The new round event is emitted when the player wants to start a new round * * @return the event */ - IEvent getNewGameEvent(); + IEvent getNewRoundEvent(); } diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index 9290b60..74c6d54 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -136,13 +136,13 @@ public class View extends JFrame implements IView { } @Override - public IEvent getNewGameEvent() { - return winPanel.getNewGameEvent(); + public IEvent getNewRoundEvent() { + return winPanel.getNewRoundEvent(); } @Override - public IEvent getQuitEvent() { - return winPanel.getQuitEvent(); + public IEvent getFinalScoreEvent() { + return winPanel.getFinalScoreEvent(); } } diff --git a/src/jrummikub/view/impl/WinPanel.java b/src/jrummikub/view/impl/WinPanel.java index 07c3535..13a7eb4 100644 --- a/src/jrummikub/view/impl/WinPanel.java +++ b/src/jrummikub/view/impl/WinPanel.java @@ -26,11 +26,11 @@ class WinPanel extends JPanel { private final static float MAX_BUTTON_FONT_SIZE = 12; private JLabel winLabel; - private JButton newGameButton; - private JButton quitButton; + private JButton newRoundButton; + private JButton finalScoreButton; - private Event quitEvent = new Event(); - private Event newGameEvent = new Event(); + private Event finalScoreEvent = new Event(); + private Event newRoundEvent = new Event(); /** * Creates a new WinPanel @@ -47,23 +47,23 @@ class WinPanel extends JPanel { winLabel.setVerticalTextPosition(JLabel.CENTER); add(winLabel); - newGameButton = new JButton("Neues Spiel"); - newGameButton.addActionListener(new ActionListener() { + newRoundButton = new JButton("Neue Runde"); + newRoundButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { - newGameEvent.emit(); + newRoundEvent.emit(); } }); - add(newGameButton); + add(newRoundButton); - quitButton = new JButton("Beenden"); - quitButton.addActionListener(new ActionListener() { + finalScoreButton = new JButton("Endauswertung"); + finalScoreButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { - quitEvent.emit(); + finalScoreEvent.emit(); } }); - add(quitButton); + add(finalScoreButton); addComponentListener(new ComponentAdapter() { @Override @@ -84,12 +84,12 @@ class WinPanel extends JPanel { } /** - * The new game event is emitted when the player wants to start a new game + * The new round event is emitted when the player wants to start a new round * * @return the event */ - IEvent getNewGameEvent() { - return newGameEvent; + IEvent getNewRoundEvent() { + return newRoundEvent; } /** @@ -97,8 +97,8 @@ class WinPanel extends JPanel { * * @return the event */ - IEvent getQuitEvent() { - return quitEvent; + IEvent getFinalScoreEvent() { + return finalScoreEvent; } private void rescale() { @@ -119,12 +119,12 @@ class WinPanel extends JPanel { fontSize = MAX_BUTTON_FONT_SIZE; winLabel.setBounds(x, y, width, firstLineHeight); - newGameButton.setBounds(x, y + firstLineHeight + PANEL_SEPARATOR, + newRoundButton.setBounds(x, y + firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight); - newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize)); + newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize)); - quitButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y + firstLineHeight + finalScoreButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y + firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight); - quitButton.setFont(quitButton.getFont().deriveFont(fontSize)); + finalScoreButton.setFont(finalScoreButton.getFont().deriveFont(fontSize)); } } diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 369ca7b..e3b11cb 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -155,6 +155,7 @@ public class RoundControlTest { assertEquals(14 + 6, hand.getSize()); } + /** */ @Test public void laidOutValidUnchanged() { roundControl.startRound(); |