From 4879b7b93eaff1f80056d78e19271d6418ec6534 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 14 Jun 2011 02:43:55 +0200 Subject: Display open games correctly git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@433 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/GameListPanel.java | 18 ++++++++++++++---- src/jrummikub/view/impl/SettingsPanel.java | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/jrummikub/view') diff --git a/src/jrummikub/view/impl/GameListPanel.java b/src/jrummikub/view/impl/GameListPanel.java index d22dc02..7324559 100644 --- a/src/jrummikub/view/impl/GameListPanel.java +++ b/src/jrummikub/view/impl/GameListPanel.java @@ -21,6 +21,8 @@ import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; +import jrummikub.model.PlayerSettings; +import jrummikub.model.PlayerSettings.Type; import jrummikub.util.Event; import jrummikub.util.Event1; import jrummikub.util.GameData; @@ -188,13 +190,21 @@ class GameListPanel extends JPanel implements IGameListPanel { int index, boolean isSelected, boolean cellHasFocus) { String host = "", playerCount = ""; - if (value instanceof GameData && ((GameData)value).getGameSettings() != null) { + if (value instanceof GameData + && ((GameData) value).getGameSettings() != null) { GameData gameData = (GameData) value; host = gameData.getHost(); - /*playerCount = gameData.getCurrentPlayerCount() + "/" - + gameData.getMaxPlayerCount();*/ - playerCount = String.valueOf(gameData.getGameSettings().getPlayerList().size()); + int total = gameData.getGameSettings().getPlayerList().size(); + int occupied = total; + + for (PlayerSettings player : gameData.getGameSettings().getPlayerList()) { + if (player.getType() == Type.VACANT) { + occupied--; + } + } + + playerCount = occupied + "/" + total; } else { host = String.valueOf(value); } diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java index 60fe20c..8ec9d3e 100644 --- a/src/jrummikub/view/impl/SettingsPanel.java +++ b/src/jrummikub/view/impl/SettingsPanel.java @@ -275,6 +275,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel { @Override public void enableStartGameButton(boolean enable) { startButton.setEnabled(enable); + offerButton.setEnabled(enable); } @Override @@ -861,6 +862,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel { case HUMAN: return "Mensch"; case NETWORK: + case VACANT: return "Netzwerk"; } -- cgit v1.2.3