Boats are now visualy removed when they leave the lobby.

main
Fan-Wu Yang 8 years ago
parent d92410b9b4
commit df04cdf87c

@ -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<Node> 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()) {

Loading…
Cancel
Save