summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/control/RoundControl.java5
-rw-r--r--src/jrummikub/view/ISidePanel.java4
-rw-r--r--src/jrummikub/view/impl/SidePanel.java65
-rw-r--r--src/jrummikub/view/impl/View.java57
4 files changed, 95 insertions, 36 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index f209f3e..285980a 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -203,12 +203,15 @@ public class RoundControl {
}
void deal() {
+ view.getSidePanel().setHeapCapacity(roundState.getGameHeap().getSize());
for (int i = 0; i < roundState.getPlayerCount(); i++) {
IHand hand = roundState.getNthNextPlayer(i).getHand();
for (int j = 0; j < roundState.getGameSettings().getNumberOfStonesDealt(); j++) {
hand.drop(roundState.getGameHeap().drawStone(), new Position(0, 0));
}
}
+ view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
+
}
private boolean laidOutValidPoints() {
@@ -392,6 +395,8 @@ public class RoundControl {
hand.drop(roundState.getGameHeap().drawStone(), new Position(
Hand.WIDTH - 1, rowCount - 1));
}
+
+ view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
}
private void dealStone() {
diff --git a/src/jrummikub/view/ISidePanel.java b/src/jrummikub/view/ISidePanel.java
index 6b55a1a..9b3bf43 100644
--- a/src/jrummikub/view/ISidePanel.java
+++ b/src/jrummikub/view/ISidePanel.java
@@ -6,4 +6,8 @@ public interface ISidePanel {
public void setGameSettings(GameSettings settings);
+ void setHeapCapacity(int capacity);
+
+ void setHeapSize(int size);
+
} \ No newline at end of file
diff --git a/src/jrummikub/view/impl/SidePanel.java b/src/jrummikub/view/impl/SidePanel.java
index 9e83c91..b895701 100644
--- a/src/jrummikub/view/impl/SidePanel.java
+++ b/src/jrummikub/view/impl/SidePanel.java
@@ -22,9 +22,11 @@ import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.JProgressBar;
import javax.swing.JScrollBar;
import javax.swing.JViewport;
import javax.swing.SwingConstants;
+import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.MatteBorder;
@@ -33,9 +35,9 @@ import jrummikub.view.ISidePanel;
@SuppressWarnings("serial")
class SidePanel extends JPanel implements ISidePanel {
- InfoPanel infoPanel;
- PlayerListPanel playerListPanel;
- BottomScrollPane playerListScrollPane;
+ //private InfoPanel infoPanel;
+ private PlayerListPanel playerListPanel;
+ private BottomScrollPane playerListScrollPane;
private JLabel initialMeldLabel;
private JLabel setNumberLabel;
private JLabel highestValueLabel;
@@ -43,18 +45,19 @@ class SidePanel extends JPanel implements ISidePanel {
private JLabel jokerLabel;
private JLabel noLimitsLabel;
private JLabel colorLabel;
+ private JProgressBar heapBar;
public SidePanel() {
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
- infoPanel = new InfoPanel(createRuleInfoPanel());
+ InfoPanel infoPanel = new InfoPanel(createGameInfoPanel(), createRuleInfoPanel());
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
c.fill = GridBagConstraints.BOTH;
- infoPanel.setBorder(new MatteBorder(0, 0, 1, 1, Color.BLACK));
+ infoPanel.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY));
add(infoPanel, c);
playerListPanel = new PlayerListPanel();
@@ -65,8 +68,6 @@ class SidePanel extends JPanel implements ISidePanel {
c.fill = GridBagConstraints.BOTH;
playerListScrollPane = new BottomScrollPane(playerListPanel);
- playerListScrollPane
- .setBorder(new MatteBorder(0, 0, 0, 1, Color.BLACK));
add(playerListScrollPane, c);
@@ -82,6 +83,43 @@ class SidePanel extends JPanel implements ISidePanel {
colorLabel.setText("" + settings.getStoneColors().size());
noLimitsLabel.setVisible(settings.isNoLimits());
}
+
+ @Override
+ public void setHeapCapacity(int capacity) {
+ heapBar.setMaximum(capacity);
+ }
+
+ @Override
+ public void setHeapSize(int size) {
+ heapBar.setValue(size);
+ if (size > 0) {
+ heapBar.setString("" + size);
+ } else {
+ heapBar.setIndeterminate(true);
+ heapBar.setString("leer");
+ }
+ }
+
+ private JPanel createGameInfoPanel() {
+ JPanel panel = new JPanel();
+ panel.setLayout(new GridBagLayout());
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = 0;
+ c.gridy = 0;
+ c.anchor = GridBagConstraints.WEST;
+ panel.add(new JLabel("Stapel: "), c);
+ c.gridx = 1;
+ c.weightx = 1;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ heapBar = new JProgressBar();
+ heapBar.setPreferredSize(new Dimension(16,16));
+ panel.add(heapBar, c);
+
+ heapBar.setStringPainted(true);
+
+ return panel;
+ }
private JPanel createRuleInfoPanel() {
JPanel panel = new JPanel();
@@ -193,18 +231,25 @@ class SidePanel extends JPanel implements ISidePanel {
static class InfoPanel extends JPanel {
JPanel ruleInfoPanel;
+ JPanel gameInfoPanel;
JCheckBox showRules;
+ JProgressBar heapBar;
- public InfoPanel(JPanel ruleInfo) {
+ public InfoPanel(JPanel gameInfo, JPanel ruleInfo) {
ruleInfoPanel = ruleInfo;
+ gameInfoPanel = gameInfo;
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
- showRules = new JCheckBox("Regeln");
- showRules.setSelected(true);
c.gridx = 0;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
+
+ c.insets = new Insets(4, 8, 4, 8);
+ add(gameInfoPanel, c);
+
+ showRules = new JCheckBox("Regeln");
+ showRules.setSelected(true);
setupTriangleIcons(showRules);
c.insets = new Insets(0, 4, 0, 4);
add(showRules, c);
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index 042421f..b367b65 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -22,6 +22,7 @@ import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.border.CompoundBorder;
import javax.swing.border.MatteBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
@@ -186,7 +187,8 @@ public class View extends JFrame implements IView {
showSettingsPanel(false);
showLoginPanel(false);
showGameListPanel(false);
- getHandPanel().setStones(Collections.<Pair<Stone, Position>> emptyList());
+ getHandPanel().setStones(
+ Collections.<Pair<Stone, Position>> emptyList());
getTablePanel().setStoneSets(
Collections.<Pair<StoneSet, Position>> emptyList());
setSelectedStones(Collections.<Stone> emptyList());
@@ -366,7 +368,8 @@ public class View extends JFrame implements IView {
table = new TablePanel();
mainLayer.add(table);
- table.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0, Color.BLACK));
+ table.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
+ Color.BLACK));
playerPanel = new PlayerPanel();
mainLayer.add(playerPanel);
@@ -390,8 +393,9 @@ public class View extends JFrame implements IView {
sidePanel = new SidePanel();
sidePanel.setVisible(false);
mainLayer.add(sidePanel);
- sidePanel.setBorder(new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
- Color.BLACK));
+ sidePanel.setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1,
+ Color.BLACK), new MatteBorder(0, 0, TABLE_BORDER_WIDTH, 0,
+ Color.GRAY)));
}
@Override
@@ -556,24 +560,24 @@ public class View extends JFrame implements IView {
@SuppressWarnings("unchecked")
private List<Pair<Stone, Position>> createDecorationStones() {
- Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(-'J',
- StoneColor.BLACK), new Position(2.5f, 0));
- Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(-'R',
- StoneColor.ORANGE), new Position(3.5f, 0));
- Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(-'u',
- StoneColor.BLUE), new Position(4.5f, 0));
- Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(-'m',
- StoneColor.RED), new Position(5.5f, 0));
- Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(-'m',
- StoneColor.GREEN), new Position(6.5f, 0));
- Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(-'i',
- StoneColor.VIOLET), new Position(7.5f, 0));
- Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(-'k',
- StoneColor.AQUA), new Position(8.5f, 0));
- Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(-'u',
- StoneColor.GRAY), new Position(9.5f, 0));
- Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(-'b',
- StoneColor.BLACK), new Position(10.5f, 0));
+ Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(
+ -'J', StoneColor.BLACK), new Position(2.5f, 0));
+ Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(
+ -'R', StoneColor.ORANGE), new Position(3.5f, 0));
+ Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(
+ -'u', StoneColor.BLUE), new Position(4.5f, 0));
+ Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(
+ -'m', StoneColor.RED), new Position(5.5f, 0));
+ Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(
+ -'m', StoneColor.GREEN), new Position(6.5f, 0));
+ Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(
+ -'i', StoneColor.VIOLET), new Position(7.5f, 0));
+ Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(
+ -'k', StoneColor.AQUA), new Position(8.5f, 0));
+ Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(
+ -'u', StoneColor.GRAY), new Position(9.5f, 0));
+ Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(
+ -'b', StoneColor.BLACK), new Position(10.5f, 0));
Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone(
StoneColor.RED), new Position(2, 1));
@@ -588,9 +592,9 @@ public class View extends JFrame implements IView {
Pair<Stone, Position> stone6 = new Pair<Stone, Position>(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
@@ -610,7 +614,8 @@ public class View extends JFrame implements IView {
&& type != BottomPanelType.WIN_PANEL && type != null);
if (type == BottomPanelType.START_GAME_PANEL) {
- table.setStoneSets(Collections.<Pair<StoneSet, Position>> emptyList());
+ table.setStoneSets(Collections
+ .<Pair<StoneSet, Position>> emptyList());
playerPanel.getHandPanel().setStones(createDecorationStones());
}