From 823ef9d4fe63cb14a114dd01fda54387998071d5 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Sat, 18 Jun 2011 04:39:16 +0200 Subject: Feedback git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@461 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/StartTurnPanel.java | 33 +++++++++- src/jrummikub/view/impl/StoneCollectionPanel.java | 9 +-- src/jrummikub/view/impl/TablePanel.java | 2 +- src/jrummikub/view/impl/View.java | 79 +++++++++++++++-------- 4 files changed, 90 insertions(+), 33 deletions(-) (limited to 'src/jrummikub/view/impl') diff --git a/src/jrummikub/view/impl/StartTurnPanel.java b/src/jrummikub/view/impl/StartTurnPanel.java index 6d6e1b5..9418a3b 100644 --- a/src/jrummikub/view/impl/StartTurnPanel.java +++ b/src/jrummikub/view/impl/StartTurnPanel.java @@ -13,6 +13,7 @@ import javax.swing.border.EmptyBorder; import jrummikub.util.Event; import jrummikub.util.IEvent; +import jrummikub.view.IView.BottomPanelType; /** * A panel that is displayed before a player's turn @@ -29,6 +30,9 @@ class StartTurnPanel extends JPanel { private JButton startTurnButton; private Event startTurnEvent = new Event(); + private Event acknowledgeInvalidEvent = new Event(); + + private Event buttonEvent = startTurnEvent; /** * Creates a new StartTurnPanel @@ -50,7 +54,7 @@ class StartTurnPanel extends JPanel { startTurnButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { - startTurnEvent.emit(); + buttonEvent.emit(); } }); add(startTurnButton); @@ -66,10 +70,22 @@ class StartTurnPanel extends JPanel { void setCurrentPlayerName(String playerName) { startTurnLabel.setText(playerName + " ist jetzt an der Reihe."); } + + void setInitialMeldError(int points) { + startTurnLabel.setText("Es wurden weniger als " + points + " Punkte ausgelegt."); + } + + void setInitialMeldFirstError() { + startTurnLabel.setText("Vor dem Rauskommen darf nicht angelegt werden."); + } IEvent getStartTurnEvent() { return startTurnEvent; } + + IEvent getAcknowledgeInvalidEvent() { + return acknowledgeInvalidEvent; + } private void rescale() { Insets insets = getInsets(); @@ -93,4 +109,19 @@ class StartTurnPanel extends JPanel { buttonWidth, buttonHeight); startTurnButton.setFont(startTurnButton.getFont().deriveFont(fontSize)); } + + public void setType(BottomPanelType type) { + switch (type) { + case START_TURN_PANEL: + startTurnButton.setText("Zug beginnen"); + buttonEvent = startTurnEvent; + break; + case INVALID_TURN_PANEL: + startTurnLabel.setText("Es liegen ung\u00FCltige Serien auf dem Tisch."); + startTurnButton.setText("N\u00E4chster Spieler"); + buttonEvent = acknowledgeInvalidEvent; + break; + } + + } } diff --git a/src/jrummikub/view/impl/StoneCollectionPanel.java b/src/jrummikub/view/impl/StoneCollectionPanel.java index c742522..5b08f51 100644 --- a/src/jrummikub/view/impl/StoneCollectionPanel.java +++ b/src/jrummikub/view/impl/StoneCollectionPanel.java @@ -37,7 +37,7 @@ class StoneCollectionPanel extends AbstractStonePanel implements private Event1 otherClickEvent = new Event1(); - private boolean pauseMode = false; + private boolean hidden = false; /** * Creates a new StoneCollection instance @@ -123,7 +123,7 @@ class StoneCollectionPanel extends AbstractStonePanel implements } } - if (pauseMode) { + if (hidden) { return; } @@ -155,8 +155,9 @@ class StoneCollectionPanel extends AbstractStonePanel implements } } - void enablePauseMode(boolean enable) { - pauseMode = enable; + @Override + public void setHidden(boolean enable) { + hidden = enable; repaint(); } } diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java index a06eae7..1e8a2b6 100644 --- a/src/jrummikub/view/impl/TablePanel.java +++ b/src/jrummikub/view/impl/TablePanel.java @@ -381,7 +381,7 @@ class TablePanel extends AbstractStonePanel implements ITablePanel { } void enablePauseMode(boolean enable) { - stoneCollection.enablePauseMode(enable); + stoneCollection.setHidden(enable); pauseMode = enable; setScale(); diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java index c18d3b3..83ca40b 100644 --- a/src/jrummikub/view/impl/View.java +++ b/src/jrummikub/view/impl/View.java @@ -154,7 +154,8 @@ public class View extends JFrame implements IView { showSettingsPanel(false); showLoginPanel(false); showGameListPanel(false); - getHandPanel().setStones(Collections.> emptyList()); + getHandPanel().setStones( + Collections.> emptyList()); getTablePanel().setStoneSets( Collections.> emptyList()); setSelectedStones(Collections. emptyList()); @@ -305,8 +306,8 @@ public class View extends JFrame implements IView { mainLayer.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)); mainLayer.add(playerPanel); startTurnPanel = new StartTurnPanel(); @@ -397,6 +398,16 @@ public class View extends JFrame implements IView { startTurnPanel.setCurrentPlayerName(playerName); pausePanel.setCurrentPlayerName(playerName); } + + @Override + public void setInitialMeldError(int points) { + startTurnPanel.setInitialMeldError(points); + } + + @Override + public void setInitialMeldFirstError() { + startTurnPanel.setInitialMeldFirstError(); + } @Override public void setCurrentPlayerColor(Color color) { @@ -413,6 +424,11 @@ public class View extends JFrame implements IView { return startTurnPanel.getStartTurnEvent(); } + @Override + public IEvent getAcknowledgeInvalidEvent() { + return startTurnPanel.getAcknowledgeInvalidEvent(); + } + @Override public IEvent getNewRoundEvent() { return winPanel.getNewRoundEvent(); @@ -430,24 +446,24 @@ public class View extends JFrame implements IView { @SuppressWarnings("unchecked") private List> createDecorationStones() { - Pair stoneJ = new Pair(new Stone(-'J', - StoneColor.BLACK), new Position(2.5f, 0)); - Pair stoneR = new Pair(new Stone(-'R', - StoneColor.ORANGE), new Position(3.5f, 0)); - Pair stoneu1 = new Pair(new Stone(-'u', - StoneColor.BLUE), new Position(4.5f, 0)); - Pair stonem1 = new Pair(new Stone(-'m', - StoneColor.RED), new Position(5.5f, 0)); - Pair stonem2 = new Pair(new Stone(-'m', - StoneColor.GREEN), new Position(6.5f, 0)); - Pair stonei = new Pair(new Stone(-'i', - StoneColor.VIOLET), new Position(7.5f, 0)); - Pair stonek = new Pair(new Stone(-'k', - StoneColor.AQUA), new Position(8.5f, 0)); - Pair stoneu2 = new Pair(new Stone(-'u', - StoneColor.GRAY), new Position(9.5f, 0)); - Pair stoneb = new Pair(new Stone(-'b', - StoneColor.BLACK), new Position(10.5f, 0)); + Pair stoneJ = new Pair(new Stone( + -'J', StoneColor.BLACK), new Position(2.5f, 0)); + Pair stoneR = new Pair(new Stone( + -'R', StoneColor.ORANGE), new Position(3.5f, 0)); + Pair stoneu1 = new Pair(new Stone( + -'u', StoneColor.BLUE), new Position(4.5f, 0)); + Pair stonem1 = new Pair(new Stone( + -'m', StoneColor.RED), new Position(5.5f, 0)); + Pair stonem2 = new Pair(new Stone( + -'m', StoneColor.GREEN), new Position(6.5f, 0)); + Pair stonei = new Pair(new Stone( + -'i', StoneColor.VIOLET), new Position(7.5f, 0)); + Pair stonek = new Pair(new Stone( + -'k', StoneColor.AQUA), new Position(8.5f, 0)); + Pair stoneu2 = new Pair(new Stone( + -'u', StoneColor.GRAY), new Position(9.5f, 0)); + Pair stoneb = new Pair(new Stone( + -'b', StoneColor.BLACK), new Position(10.5f, 0)); Pair stone1 = new Pair(new Stone( StoneColor.RED), new Position(2, 1)); @@ -462,9 +478,9 @@ public class View extends JFrame implements IView { Pair stone6 = new Pair(new Stone( StoneColor.BLACK), new Position(11, 1)); - return Arrays - .asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, stonek, - stoneu2, stoneb, stone1, stone2, stone3, stone4, stone5, stone6); + return Arrays.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, + stonek, stoneu2, stoneb, stone1, stone2, stone3, stone4, + stone5, stone6); } @Override @@ -475,17 +491,26 @@ public class View extends JFrame implements IView { } private void doSetBottomPanel(BottomPanelType type) { - startTurnPanel.setVisible(type == BottomPanelType.START_TURN_PANEL); + boolean showStartTurnPanel = type == BottomPanelType.START_TURN_PANEL + || type == BottomPanelType.INVALID_TURN_PANEL; + startTurnPanel.setVisible(showStartTurnPanel); + startTurnPanel.setType(type); winPanel.setVisible(type == BottomPanelType.WIN_PANEL); - playerPanel.setVisible(type != BottomPanelType.START_TURN_PANEL + playerPanel.setVisible((!showStartTurnPanel) && type != BottomPanelType.WIN_PANEL && type != null); if (type == BottomPanelType.START_GAME_PANEL) { - table.setStoneSets(Collections.> emptyList()); + table.setStoneSets(Collections + .> emptyList()); playerPanel.getHandPanel().setStones(createDecorationStones()); } playerPanel.showButtons(type != BottomPanelType.START_GAME_PANEL); playerPanel.enableButtons(type != BottomPanelType.COMPUTER_HAND_PANEL); } + + @Override + public void setStoneCollectionHidden(boolean enable) { + table.getStoneCollectionPanel().setHidden(enable); + } } -- cgit v1.2.3