Add "Waiting for players" message to GameOfferControl
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@557 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
492ade8cd1
commit
82d69635a8
3 changed files with 138 additions and 125 deletions
|
@ -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);
|
||||
}
|
||||
}));
|
||||
|
|
Reference in a new issue