Removed more referencec to ListView and added some threads in the hope of making the gameplay smoother

This commit is contained in:
Seraina 2022-05-16 21:41:16 +02:00
parent f0566cbf37
commit 216c9004e7
3 changed files with 14 additions and 43 deletions

View File

@ -378,9 +378,6 @@ public class Client {
chatApp.getGameController().clearAllNoiseDisplay();
dayNightChangeListener.setNoiseButtonInvisible(true);
break;
case GuiParameters.getMembersInLobby:
updateLobbyMembers(data);
break;
case GuiParameters.viewChangeToGame:
chatApp.getLoungeSceneViewController().addGameView();
gameStateModel.setGameOver(false);
@ -418,42 +415,6 @@ public class Client {
}
private void removeLobbyFromGui(String data) {
loungeSceneViewController.removeLobbyFromView(data);
LOGGER.debug("Made it into removeLobbyFromGui()");
}
private void makeNewLobby(String data) {
String[] params = data.split(":");
loungeSceneViewController.newLobby(params[0], params[1]);
LOGGER.debug("makeNewLobby() seems to have finished");
}
private void addPlayerToLobby(String data) {
String[] params = data.split(":");
loungeSceneViewController.addPlayerToLobby(params[0], params[1]);
LOGGER.debug("addPlayerToLobby() seems to have finished");
}
private void updateLobbyMembers(String data) {
String[] dataArr = data.split(":");
String lobbyID = dataArr[0];
String adminName = dataArr[1];
}
private void updateListOfLobbies(String data) {
String[] arr = data.split(":");
ObservableList<SimpleStringProperty> list = new SimpleListProperty<>();
int n = arr.length;
for (int i = 0; i < n; i = i + 2) {
list.add(new SimpleStringProperty(arr[i]));
//ChatController.getClient().addLobbyToList(new SimpleStringProperty(arr[i]));
}
//TODO
}
/**
* Starts a new thread, thad adds a message to notificationText in the gameController, waits 3
* seconds and deletes it again.

View File

@ -51,11 +51,16 @@ public class ListOfLobbiesController implements Initializable {
public void updateList() {
new Thread(new Runnable() {
@Override
public void run() {
clearVBox();
for (LobbyModel lobby : LobbyDisplayHandler.getLobbies()) {
newTreeView(lobby.getId(), lobby.getAdmin(), chatApp.getcModel().getUsername(), lobby.getMembers());
}
}
}).start();
}
/**
* Creates one new TreeView for one Lobby

View File

@ -31,6 +31,9 @@ public class LobbyDisplayHandler {
}
public void updateLobbies(String data) {
new Thread(new Runnable() {
@Override
public void run() {
try {
for (LobbyModel model : lobbies) {
model.setHasBeenVisited(false);
@ -57,6 +60,8 @@ public class LobbyDisplayHandler {
LOGGER.info("empty list");
}
}
}).start();
}
private void addLobbyFromString(int id, String admin, boolean isOpen, String[] oneLobby) {
//System.out.println("add Lobby");