summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view')
-rw-r--r--src/jrummikub/view/IPlayerPanel.java2
-rw-r--r--src/jrummikub/view/ISettingsPanel.java4
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java22
-rw-r--r--src/jrummikub/view/impl/SettingsPanel.java38
4 files changed, 43 insertions, 23 deletions
diff --git a/src/jrummikub/view/IPlayerPanel.java b/src/jrummikub/view/IPlayerPanel.java
index 75dbc60..6994456 100644
--- a/src/jrummikub/view/IPlayerPanel.java
+++ b/src/jrummikub/view/IPlayerPanel.java
@@ -13,7 +13,7 @@ public interface IPlayerPanel {
* @param time
* the time left
*/
- public void setTimeLeft(int time);
+ public void setTime(int time, int totalTime);
/**
* The sort by groups event is emitted when the player wants to sort his
diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java
index a67d8b7..a63b3d1 100644
--- a/src/jrummikub/view/ISettingsPanel.java
+++ b/src/jrummikub/view/ISettingsPanel.java
@@ -6,6 +6,7 @@ import java.util.Set;
import jrummikub.control.turn.TurnControlFactory;
import jrummikub.model.GameSettings;
import jrummikub.model.StoneColor;
+import jrummikub.util.Event1;
import jrummikub.util.IEvent;
import jrummikub.util.IEvent1;
import jrummikub.util.IEvent2;
@@ -169,6 +170,8 @@ public interface ISettingsPanel {
* @return the event
*/
public IEvent1<Integer> getChangeJokerNumberEvent();
+
+ public Event1<Integer> getChangeTimeEvent();
/**
* Specifies the different kinds of settings errors that can be displayed
@@ -191,4 +194,5 @@ public interface ISettingsPanel {
/** Only computer players added */
COMPUTER_PLAYERS_ONLY_WARNING
}
+
} \ No newline at end of file
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java
index d69323f..77a493c 100644
--- a/src/jrummikub/view/impl/PlayerPanel.java
+++ b/src/jrummikub/view/impl/PlayerPanel.java
@@ -69,7 +69,7 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
* Sets the current player name
*
* @param playerName
- * the player name
+ * the player name
*/
void setCurrentPlayerName(String playerName) {
currentPlayerNameLabel.setText(playerName);
@@ -88,7 +88,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
}
@Override
- public void setTimeLeft(int time) {
+ public void setTime(int time, int totalTime) {
+ timeBar.setMaximum(totalTime);
timeBar.setValue(time);
timeBar.setString(Integer.toString(time / 60) + ":"
+ secondFormat.format(time % 60));
@@ -140,7 +141,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
leftPanel.add(hasLaidOutLabel);
sortByGroupsButton = createButton(leftPanel,
- "<html><center>Nach Sammlungen sortieren", new ActionListener() {
+ "<html><center>Nach Sammlungen sortieren",
+ new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
sortByGroupsEvent.emit();
@@ -161,8 +163,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
private void createRightPanel() {
rightPanel = new JPanel();
rightPanel.setLayout(null);
- rightPanel.setBorder(new EmptyBorder(SIDE_PANEL_INSET, SIDE_PANEL_INSET,
- SIDE_PANEL_INSET, SIDE_PANEL_INSET));
+ rightPanel.setBorder(new EmptyBorder(SIDE_PANEL_INSET,
+ SIDE_PANEL_INSET, SIDE_PANEL_INSET, SIDE_PANEL_INSET));
handRowUpButton = createButton(rightPanel, "<html><center>\u25B2",
new ActionListener() {
@@ -234,7 +236,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
private void rescale() {
Insets insets = getInsets();
int x = insets.left, y = insets.top, width = getWidth() - insets.left
- - insets.right, height = getHeight() - insets.top - insets.bottom;
+ - insets.right, height = getHeight() - insets.top
+ - insets.bottom;
int boardWidth = hand.getWidth();
int handButtonWidth = (int) (width * HAND_ROW_BUTTON_RATIO);
int meanPanelWidth = (width - boardWidth) / 2;
@@ -243,8 +246,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
leftPanel.setBounds(x, y, leftPanelWidth, height);
hand.setBounds(x + leftPanelWidth, y, boardWidth, height);
- rightPanel.setBounds(x + leftPanelWidth + boardWidth, y, rightPanelWidth,
- height);
+ rightPanel.setBounds(x + leftPanelWidth + boardWidth, y,
+ rightPanelWidth, height);
leftPanel.validate();
rightPanel.validate();
@@ -252,7 +255,8 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
void updateButtons() {
handRowUpButton.setEnabled(hand.canRowUp());
- handRowUpButton.setForeground(hand.canRowUp() ? Color.BLACK : Color.GRAY);
+ handRowUpButton.setForeground(hand.canRowUp() ? Color.BLACK
+ : Color.GRAY);
handRowDownButton.setEnabled(hand.canRowDown());
handRowDownButton.setForeground(hand.canRowDown() ? Color.BLACK
: Color.GRAY);
diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java
index adacd79..8864b7b 100644
--- a/src/jrummikub/view/impl/SettingsPanel.java
+++ b/src/jrummikub/view/impl/SettingsPanel.java
@@ -75,6 +75,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private JSpinner highestValueSpinner;
private JSpinner numberOfStonesDealtSpinner;
private JSpinner jokerNumberSpinner;
+ private JSpinner timeSpinner;
private JPanel colorSelectionPanel;
private Map<StoneColor, JToggleButton> colorButtons = new HashMap<StoneColor, JToggleButton>();
@@ -91,7 +92,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
private Event1<Integer> changeNumberOfStonesDealtEvent = new Event1<Integer>();
private Event1<Integer> changeHighestValueEvent = new Event1<Integer>();
private Event1<Set<StoneColor>> changeStoneColorsEvent = new Event1<Set<StoneColor>>();
-
+ private Event1<Integer> changeTimeEvent = new Event1<Integer>();
+
@Override
public IEvent getStartGameEvent() {
return startGameEvent;
@@ -136,6 +138,21 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
public IEvent1<Integer> getChangeHighestValueEvent() {
return changeHighestValueEvent;
}
+
+ @Override
+ public IEvent1<Integer> getChangeJokerNumberEvent() {
+ return changeJokerNumberEvent;
+ }
+
+ @Override
+ public IEvent2<Integer, Type> getChangePlayerTypeEvent() {
+ return changePlayerTypeEvent;
+ }
+
+ @Override
+ public Event1<Integer> getChangeTimeEvent() {
+ return changeTimeEvent;
+ }
@Override
public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent() {
@@ -214,6 +231,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
highestValueSpinner.setValue(gameSettings.getHighestValue());
numberOfStonesDealtSpinner.setValue(gameSettings.getNumberOfStonesDealt());
jokerNumberSpinner.setValue(gameSettings.getJokerNumber());
+ timeSpinner.setValue(gameSettings.getTime());
for (StoneColor color : StoneColor.values()) {
colorButtons.get(color).getModel()
@@ -300,13 +318,16 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
makeOptionLabel(4, "Jokeranzahl:");
jokerNumberSpinner = makeOptionSpinner(4, 1, 999, 1, changeJokerNumberEvent);
+
+ makeOptionLabel(5, "Zeit für Spielzug:");
+ timeSpinner = makeOptionSpinner(5, 1, 999, 1, changeTimeEvent);
- makeOptionLabel(5, "Steinfarben:");
- createColorSelectionPanel(5);
+ makeOptionLabel(6, "Steinfarben:");
+ createColorSelectionPanel(6);
GridBagConstraints c = new GridBagConstraints();
c.gridx = 1;
- c.gridy = 6;
+ c.gridy = 7;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
@@ -601,13 +622,4 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
}
}
- @Override
- public IEvent1<Integer> getChangeJokerNumberEvent() {
- return changeJokerNumberEvent;
- }
-
- @Override
- public IEvent2<Integer, Type> getChangePlayerTypeEvent() {
- return changePlayerTypeEvent;
- }
}