summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-25 23:38:05 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-25 23:38:05 +0200
commitd69fdbacb90427d47400bd2ebe929e77f47e75b7 (patch)
tree05e5411c6fe22ccc29d55d45880acfd1bd7f20d0
parent10e8c1f0e6b0cb687d5d69a44d66347172e110d1 (diff)
downloadJRummikub-d69fdbacb90427d47400bd2ebe929e77f47e75b7.tar
JRummikub-d69fdbacb90427d47400bd2ebe929e77f47e75b7.zip
Added UI for readealing
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@278 72836036-5685-4462-b002-a69064685172
-rw-r--r--mock/jrummikub/view/MockPlayerPanel.java7
-rw-r--r--src/jrummikub/view/IPlayerPanel.java13
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java58
3 files changed, 74 insertions, 4 deletions
diff --git a/mock/jrummikub/view/MockPlayerPanel.java b/mock/jrummikub/view/MockPlayerPanel.java
index 13dbb57..d01c027 100644
--- a/mock/jrummikub/view/MockPlayerPanel.java
+++ b/mock/jrummikub/view/MockPlayerPanel.java
@@ -10,6 +10,8 @@ public class MockPlayerPanel implements IPlayerPanel {
/** */
public MockEvent endTurnEvent = new MockEvent();
/** */
+ public MockEvent redealEvent = new MockEvent();
+ /** */
public MockEvent sortByGroupsEvent = new MockEvent();
/** */
public MockEvent sortByRunsEvent = new MockEvent();
@@ -35,4 +37,9 @@ public class MockPlayerPanel implements IPlayerPanel {
return endTurnEvent;
}
+ @Override
+ public IEvent getRedealEvent() {
+ return redealEvent;
+ }
+
}
diff --git a/src/jrummikub/view/IPlayerPanel.java b/src/jrummikub/view/IPlayerPanel.java
index 3fb8709..f1f8f95 100644
--- a/src/jrummikub/view/IPlayerPanel.java
+++ b/src/jrummikub/view/IPlayerPanel.java
@@ -10,7 +10,7 @@ public interface IPlayerPanel {
* Sets the time the player has left for his turn
*
* @param time
- * the time left
+ * the time left
*/
public void setTimeLeft(int time);
@@ -23,8 +23,8 @@ public interface IPlayerPanel {
public IEvent getSortByGroupsEvent();
/**
- * The sort by runs event is emitted when the player wants to sort his stones
- * by runs
+ * The sort by runs event is emitted when the player wants to sort his
+ * stones by runs
*
* @return the event
*/
@@ -36,4 +36,11 @@ public interface IPlayerPanel {
* @return the event
*/
public IEvent getEndTurnEvent();
+
+ /**
+ * The redeal event is emitted when the player wants to get new stones
+ *
+ * @return the event
+ */
+ IEvent getRedealEvent();
}
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java
index 8a5912d..171e46b 100644
--- a/src/jrummikub/view/impl/PlayerPanel.java
+++ b/src/jrummikub/view/impl/PlayerPanel.java
@@ -45,10 +45,14 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
private JButton handRowDownButton;
private JProgressBar timeBar;
private JButton endTurnButton;
+ private JButton keepStonesButton;
+ private JButton redealButton;
+
private Event sortByGroupsEvent = new Event();
private Event sortByRunsEvent = new Event();
private Event endTurnEvent = new Event();
+ private Event redealEvent = new Event();
HandPanel getHandPanel() {
return hand;
@@ -90,6 +94,11 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
public IEvent getEndTurnEvent() {
return endTurnEvent;
}
+
+ @Override
+ public IEvent getRedealEvent() {
+ return redealEvent;
+ }
private void createLeftPanel() {
leftPanel = new JPanel();
@@ -159,7 +168,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
timeBar.setStringPainted(true);
rightPanel.add(timeBar);
- endTurnButton = new JButton("Zug beenden");
+ endTurnButton = new JButton("---");
endTurnButton.setFont(endTurnButton.getFont().deriveFont(0));
endTurnButton.setMargin(new Insets(0, 0, 0, 0));
endTurnButton.addActionListener(new ActionListener() {
@@ -170,6 +179,30 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
});
rightPanel.add(endTurnButton);
+
+ keepStonesButton = new JButton("<html><center>Steine<br>behalten");
+ keepStonesButton.setFont(keepStonesButton.getFont().deriveFont(0));
+ keepStonesButton.setMargin(new Insets(0, 0, 0, 0));
+ keepStonesButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ endTurnEvent.emit();
+ }
+ });
+
+ rightPanel.add(keepStonesButton);
+
+ redealButton= new JButton("<html><center>Neu<br>geben");
+ redealButton.setFont(redealButton.getFont().deriveFont(0));
+ redealButton.setMargin(new Insets(0, 0, 0, 0));
+ redealButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ redealEvent.emit();
+ }
+ });
+
+ rightPanel.add(redealButton);
rightPanel.addComponentListener(new RightPanelResizeListener());
}
@@ -225,6 +258,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
addComponentListener(rescaleListener);
hand.addComponentListener(rescaleListener);
+
+ setEndTurnMode(true, true);
}
private class LeftPanelResizeListener extends ComponentAdapter {
@@ -276,8 +311,10 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
int firstLineHeight = (int) ((height - SIDE_PANEL_SEPARATOR) * SIDE_PANEL_FIRST_LINE_HEIGHT);
int buttonWidth = width;
+ int smallButtonWidth = (width - SIDE_PANEL_SEPARATOR) / 2;
int buttonHeight = height - SIDE_PANEL_SEPARATOR - firstLineHeight;
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
+ float smallFontSize = (float) Math.sqrt(smallButtonWidth * buttonHeight) / 5;
if (fontSize > MAX_BUTTON_FONT_SIZE)
fontSize = MAX_BUTTON_FONT_SIZE;
@@ -293,6 +330,25 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
endTurnButton.setBounds(x, y + firstLineHeight + SIDE_PANEL_SEPARATOR,
buttonWidth, buttonHeight);
endTurnButton.setFont(endTurnButton.getFont().deriveFont(fontSize));
+
+ redealButton.setBounds(x, y + firstLineHeight + SIDE_PANEL_SEPARATOR, smallButtonWidth, buttonHeight);
+ redealButton.setFont(redealButton.getFont().deriveFont(smallFontSize));
+ keepStonesButton.setBounds(x + smallButtonWidth + SIDE_PANEL_SEPARATOR, y
+ + firstLineHeight + SIDE_PANEL_SEPARATOR, smallButtonWidth, buttonHeight);
+ keepStonesButton.setFont(keepStonesButton.getFont().deriveFont(smallFontSize));
+
+ }
+ }
+
+ public void setEndTurnMode(boolean inspectOnly, boolean mayRedeal) {
+ if (!inspectOnly) {
+ endTurnButton.setText("Zug beenden");
+ } else if (!mayRedeal) {
+ endTurnButton.setText("Nächster Spieler");
}
+ boolean smallButtons = mayRedeal && inspectOnly;
+ endTurnButton.setVisible(!smallButtons);
+ keepStonesButton.setVisible(smallButtons);
+ redealButton.setVisible(smallButtons);
}
}