Adding functionality for removing lobby from view. ClientHandler, GuiParameters Client and LoungeView now atleast have
the correspondingly named functions. No functionality tested yet.
This commit is contained in:
parent
d7f12d760d
commit
62992ae84c
@ -402,6 +402,9 @@ public class Client {
|
||||
chatApp.getLoungeSceneViewController().clearLobbyPrint();
|
||||
chatApp.getLoungeSceneViewController().addLobbyPrint(data);
|
||||
break;
|
||||
case GuiParameters.removeLobby:
|
||||
removeLobbyFromGui(data);
|
||||
break;
|
||||
default:
|
||||
notificationTextDisplay(data);
|
||||
//TODO(Sebi,Seraina): should the gameController be in the Application just like the ChatController?
|
||||
@ -414,6 +417,11 @@ public class Client {
|
||||
|
||||
}
|
||||
|
||||
private void removeLobbyFromGui(String data) {
|
||||
loungeSceneViewController.removeLobbyFromView(data);
|
||||
LOGGER.debug("Made it into removeLobbyFromGui()");
|
||||
}
|
||||
|
||||
private void addNewPlayerToGui(String data) {
|
||||
loungeSceneViewController.addClientToList(data);
|
||||
LOGGER.debug("addNewPlayerToGui() seems to have finished");
|
||||
|
||||
@ -50,7 +50,6 @@ public class LoungeSceneViewController implements Initializable {
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private TextFlow highScore;
|
||||
@FXML
|
||||
@ -365,8 +364,8 @@ public class LoungeSceneViewController implements Initializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds players to a lobby
|
||||
* "NMEMB" {@link ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters}
|
||||
* Adds players to a lobby "NMEMB" {@link ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters}
|
||||
*
|
||||
* @param lobbyID the Id the Player belongs to
|
||||
* @param player the player to be added
|
||||
*/
|
||||
@ -430,6 +429,7 @@ public class LoungeSceneViewController implements Initializable {
|
||||
|
||||
/**
|
||||
* Send the joinLobby Protocol message
|
||||
*
|
||||
* @param lobbyID the Lobby to be joinded
|
||||
*/
|
||||
public void joinGame(String lobbyID) {
|
||||
@ -480,6 +480,7 @@ public class LoungeSceneViewController implements Initializable {
|
||||
|
||||
/**
|
||||
* Sould remove a client of a certain name from the ListView
|
||||
*
|
||||
* @param name the name of the client to be removed
|
||||
*/
|
||||
public void removeClientFromList(String name) {
|
||||
@ -490,7 +491,8 @@ public class LoungeSceneViewController implements Initializable {
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
public void removeClientFromLobby(String s) {
|
||||
//todo
|
||||
@ -544,6 +546,7 @@ public class LoungeSceneViewController implements Initializable {
|
||||
|
||||
/**
|
||||
* Adds a String to the highScore Text Flow
|
||||
*
|
||||
* @param data the String to be added
|
||||
*/
|
||||
public void addHighScore(String data) {
|
||||
@ -565,8 +568,9 @@ public class LoungeSceneViewController implements Initializable {
|
||||
|
||||
/**
|
||||
* Adds a String to the lobbyPrint TextFlow
|
||||
*
|
||||
* @param data the String to be added
|
||||
* */
|
||||
*/
|
||||
public void addLobbyPrint(String data) {
|
||||
String[] arguments = data.split("/n");
|
||||
LOGGER.debug(arguments.length);
|
||||
@ -594,5 +598,18 @@ public class LoungeSceneViewController implements Initializable {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void removeLobbyFromView(String data) {
|
||||
Iterator<LobbyListItem> itr = lobbies.iterator();
|
||||
while (itr.hasNext()) {
|
||||
LobbyListItem item = itr.next();
|
||||
if (item.getLobbyID().equals(data)) {
|
||||
itr.remove();
|
||||
LOGGER.debug(
|
||||
"Made it into removeLobbyFromView if clause for lobby w/ ID: " + item.getLobbyID()
|
||||
+ " for data passed: " + data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -96,4 +96,9 @@ public class GuiParameters {
|
||||
* pan out
|
||||
*/
|
||||
public static final String updatePrintLobby = "PRLOBB";
|
||||
|
||||
/**
|
||||
* Tells gui to remove a lobby from view. Form: {@code RMVLBY$<LobbyID>}
|
||||
*/
|
||||
public static final String removeLobby = "RMVLBY";
|
||||
}
|
||||
|
||||
@ -516,6 +516,12 @@ public class ClientHandler implements Runnable {
|
||||
if (l != null) {
|
||||
l.removePlayer(this);
|
||||
Game game = l.getGame();
|
||||
if(l.getAdmin().equals(getClientUserName())){
|
||||
//Lobby closed because admin left. Lobby must be removed from gui view
|
||||
guiUpdateAll(Protocol.printToGUI+"$"+GuiParameters.removeLobby+"$"+l.getLobbyID());
|
||||
}else{
|
||||
//client just leaves lobby
|
||||
}
|
||||
if (game != null) {
|
||||
l.getGame().getGameState().handleClientDisconnect(this);
|
||||
l.removeGameFromRunningGames(game);
|
||||
|
||||
Reference in New Issue
Block a user