summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-21 21:24:26 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-21 21:24:26 +0200
commit82d69635a890c0147804132434a0fc7d45e8425b (patch)
treed2067f6f2e1b87445654af0a11600c5b9e86c7f2 /src/jrummikub/control
parent492ade8cd1b3511ac5d7ae43e664d2bb8b8ac3ae (diff)
downloadJRummikub-82d69635a890c0147804132434a0fc7d45e8425b.tar
JRummikub-82d69635a890c0147804132434a0fc7d45e8425b.zip
Add "Waiting for players" message to GameOfferControl
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@557 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/control')
-rw-r--r--src/jrummikub/control/network/GameOfferControl.java33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/jrummikub/control/network/GameOfferControl.java b/src/jrummikub/control/network/GameOfferControl.java
index b513170..c697647 100644
--- a/src/jrummikub/control/network/GameOfferControl.java
+++ b/src/jrummikub/control/network/GameOfferControl.java
@@ -12,6 +12,7 @@ import jrummikub.util.GameData;
import jrummikub.util.IEvent1;
import jrummikub.util.IListener;
import jrummikub.util.IListener1;
+import jrummikub.view.ISettingsPanel.SettingsError;
import jrummikub.view.ISettingsPanel.SettingsMode;
import jrummikub.view.IView;
@@ -44,19 +45,31 @@ public class GameOfferControl extends AbstractGameBeginControl {
public void handle() {
List<PlayerSettings> players = gameData.getGameSettings()
.getPlayerList();
- for (PlayerSettings s : players) {
- if (s.getType() == Type.NETWORK) {
- startGame();
- return;
- }
+ if (checkPlayers()) {
+ startGame();
}
}
}));
+
+ checkPlayers();
+ }
+
+ private boolean checkPlayers() {
+ for (PlayerSettings s : gameData.getGameSettings().getPlayerList()) {
+ if (s.getType() == Type.NETWORK) {
+ view.getSettingsPanel().setError(SettingsError.NO_ERROR);
+ view.getSettingsPanel().enableStartGameButton(true);
+ return true;
+ }
+ }
+
+ view.getSettingsPanel().setError(SettingsError.WAITING_FOR_PLAYERS);
+ view.getSettingsPanel().enableStartGameButton(false);
+ return false;
}
private void addConnectionControlListeners(
- final IConnectionControl connectionControl,
- final GameSettings settings) {
+ final IConnectionControl connectionControl, final GameSettings settings) {
connections.add(connectionControl.getGameJoinEvent().add(
new IListener1<String>() {
@Override
@@ -65,7 +78,10 @@ public class GameOfferControl extends AbstractGameBeginControl {
if (player.getType() == Type.VACANT) {
player.setName(sender);
player.setType(Type.NETWORK);
+
updateSettingsPanel();
+ checkPlayers();
+
connectionControl.ackJoinGame(sender, true);
connectionControl.offerGame(gameData);
return;
@@ -88,7 +104,10 @@ public class GameOfferControl extends AbstractGameBeginControl {
break;
}
}
+
updateSettingsPanel();
+ checkPlayers();
+
connectionControl.offerGame(gameData);
}
}));