From df04cdf87ccb807b54f9598486951318f9483a1c Mon Sep 17 00:00:00 2001 From: Fan-Wu Yang Date: Mon, 11 Sep 2017 19:54:43 +1200 Subject: [PATCH] Boats are now visualy removed when they leave the lobby. --- .../Controllers/InGameLobbyController.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/racevisionGame/src/main/java/visualiser/Controllers/InGameLobbyController.java b/racevisionGame/src/main/java/visualiser/Controllers/InGameLobbyController.java index e2f0f787..7cc40eeb 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/InGameLobbyController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/InGameLobbyController.java @@ -8,6 +8,7 @@ import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.geometry.Insets; +import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; @@ -95,12 +96,28 @@ public class InGameLobbyController extends Controller { importer.read(asset); } + private void resetLobby(){ + int count = 0; + for (Label label: allPlayerLabels){ + label.setText("Player " + count + 1); + count ++; + } + List nodeCopy = new ArrayList(playerContainer.getChildren()); + for (Node node: nodeCopy){ + if (node instanceof View3D){ + playerContainer.getChildren().remove(node); + } + } + } + private void populatePlayers(ListChangeListener.Change change){ + Platform.runLater( () -> { while (change.next()){ - if (change.wasAdded()){ + if (change.wasAdded() || change.wasRemoved() || change.wasUpdated() || change.wasPermutated()){ try{ + resetLobby(); int count = 0; int row = 0; for (VisualiserBoat boat :this.visualiserRaceEvent.getVisualiserRaceState().getBoats()) {