Fix some GUI bugs in network related panels
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@439 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
99c3d48f10
commit
c84bebceb7
5 changed files with 59 additions and 63 deletions
|
@ -30,6 +30,7 @@ public class NetworkControl {
|
|||
private GameOfferControl gameOfferControl;
|
||||
private GameJoinControl gameJoinControl;
|
||||
|
||||
private List<UUID> games = new ArrayList<UUID>();
|
||||
private Map<UUID, GameData> gameMap = new HashMap<UUID, GameData>();
|
||||
|
||||
/**
|
||||
|
@ -107,29 +108,30 @@ public class NetworkControl {
|
|||
connections.add(connectionControl.getGameOfferEvent().add(
|
||||
new IListener1<GameData>() {
|
||||
@Override
|
||||
public void handle(GameData value) {
|
||||
GameData game = gameMap.get(value.getGameID());
|
||||
public void handle(GameData gameData) {
|
||||
UUID uuid = gameData.getGameID();
|
||||
|
||||
GameData game = gameMap.get(uuid);
|
||||
|
||||
if (game == null) {
|
||||
game = value;
|
||||
gameMap.put(value.getGameID(), value);
|
||||
game = gameData;
|
||||
gameMap.put(uuid, gameData);
|
||||
games.add(uuid);
|
||||
} else {
|
||||
game.setGameSettings(value.getGameSettings());
|
||||
game.setGameSettings(gameData.getGameSettings());
|
||||
}
|
||||
|
||||
view.getGameListPanel().addGame(game);
|
||||
updateGameList();
|
||||
}
|
||||
}));
|
||||
connections.add(connectionControl.getGameWithdrawalEvent().add(
|
||||
new IListener1<UUID>() {
|
||||
@Override
|
||||
public void handle(UUID value) {
|
||||
GameData game = gameMap.get(value);
|
||||
public void handle(UUID uuid) {
|
||||
games.remove(uuid);
|
||||
gameMap.remove(uuid);
|
||||
|
||||
if (game != null) {
|
||||
view.getGameListPanel().removeGame(game);
|
||||
gameMap.remove(value);
|
||||
}
|
||||
updateGameList();
|
||||
}
|
||||
}));
|
||||
connections.add(connectionControl.getGameJoinAckEvent().add(
|
||||
|
@ -147,6 +149,16 @@ public class NetworkControl {
|
|||
}));
|
||||
}
|
||||
|
||||
private void updateGameList() {
|
||||
List<GameData> gameList = new ArrayList<GameData>();
|
||||
|
||||
for (UUID uuid : games) {
|
||||
gameList.add(gameMap.get(uuid));
|
||||
}
|
||||
|
||||
view.getGameListPanel().setGameList(gameList);
|
||||
}
|
||||
|
||||
private void createGameJoinControl(UUID uuid) {
|
||||
if (gameJoinControl != null) {
|
||||
return;
|
||||
|
|
Reference in a new issue