summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl')
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java58
1 files changed, 57 insertions, 1 deletions
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);
}
}