Updated FXMLs to add depleting tomato

- Tab view now contains health column
- BoatStateCommand now fails silently if command is received before race state is set up

#story[1291]
This commit is contained in:
Connor Taylor-Brown
2017-09-20 18:22:14 +12:00
parent 23040ecff4
commit b0bc7f50f2
4 changed files with 37 additions and 24 deletions
@@ -24,7 +24,7 @@ public class BoatStateCommand implements Command {
VisualiserBoat boat = visualiserRace.getBoat(boatState.getSourceID());
boat.setHealth(boatState.getBoatHealth());
} catch (BoatNotFoundException e) {
e.printStackTrace();
// Fail silently
}
}
}
@@ -85,14 +85,15 @@ public class RaceViewController extends Controller {
private @FXML Label timeZone;
private @FXML CheckBox showFPS;
private @FXML TableView<VisualiserBoat> boatInfoTable;
private @FXML TableColumn<VisualiserBoat, String> boatPlacingColumn;
private @FXML TableColumn<VisualiserBoat, String> boatTeamColumn;
private @FXML TableColumn<VisualiserBoat, Leg> boatMarkColumn;
private @FXML TableColumn<VisualiserBoat, Number> boatSpeedColumn;
private @FXML TableColumn<VisualiserBoat, Number> boatHealthColumn;
private @FXML LineChart<Number, Number> sparklineChart;
private @FXML Label tutorialText;
private @FXML AnchorPane infoWrapper;
private @FXML AnchorPane lineChartWrapper;
private @FXML GridPane playerHealthContainer;
/**
* Displays a specified race.
@@ -334,12 +335,9 @@ public class RaceViewController extends Controller {
boat.legProperty().addListener((o, prev, curr) -> Platform.runLater(() -> swapColours(curr)));
boat.hasCollidedProperty().addListener((o, prev, curr) -> Platform.runLater(() -> showCollision(boat, shockwave)));
boat.healthProperty().addListener((o, prev, curr) -> {
System.out.println("Tab view: " + curr);
});
if(boat.getSourceID() == race.getVisualiserRaceState().getPlayerBoatID()) {
boat.healthProperty().addListener((o, prev, curr) -> {
System.out.println("Tomato: " + curr);
System.out.println(curr);
});
}
}
@@ -529,13 +527,17 @@ public class RaceViewController extends Controller {
// set table data
boatInfoTable.setItems(sortedBoats);
boatTeamColumn.setCellValueFactory(
cellData -> cellData.getValue().nameProperty());
cellData -> cellData.getValue().nameProperty()
);
boatSpeedColumn.setCellValueFactory(
cellData -> cellData.getValue().currentSpeedProperty());
cellData -> cellData.getValue().currentSpeedProperty()
);
boatMarkColumn.setCellValueFactory(
cellData -> cellData.getValue().legProperty());
boatPlacingColumn.setCellValueFactory(
cellData -> cellData.getValue().placingProperty());
cellData -> cellData.getValue().legProperty()
);
boatHealthColumn.setCellValueFactory(
cellData -> cellData.getValue().healthProperty()
);
//Kind of ugly, but allows for formatting an observed speed.
boatSpeedColumn.setCellFactory(