Visualiser:
Fixed the issue where a boat's time since last mark started counting from when the race screen loaded. It now starts counting when the race actually starts.
This commit is contained in:
@@ -185,9 +185,7 @@ public class StreamedRace implements Runnable {
|
|||||||
|
|
||||||
System.setProperty("javafx.animation.fullspeed", "true");
|
System.setProperty("javafx.animation.fullspeed", "true");
|
||||||
|
|
||||||
for (Boat boat : startingBoats) {
|
|
||||||
boat.setStarted(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
new AnimationTimer() {
|
new AnimationTimer() {
|
||||||
|
|
||||||
@@ -199,19 +197,28 @@ public class StreamedRace implements Runnable {
|
|||||||
public void handle(long arg0) {
|
public void handle(long arg0) {
|
||||||
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
|
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
|
||||||
|
|
||||||
for (Boat boat : startingBoats) {
|
|
||||||
if (boat != null && !boat.isFinished()) {
|
|
||||||
updatePosition(boat);
|
|
||||||
checkPosition(boat, totalTimeElapsed);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//Check if the race has actually started.
|
||||||
|
if (visualiserInput.getRaceStatus().isStarted()) {
|
||||||
|
//Set all boats to started.
|
||||||
|
for (Boat boat : startingBoats) {
|
||||||
|
boat.setStarted(true);
|
||||||
}
|
}
|
||||||
for (Marker mark: boatMarkers){
|
}
|
||||||
if (mark != null){
|
|
||||||
updateMarker(mark);
|
for (Boat boat : startingBoats) {
|
||||||
}
|
if (boat != null && !boat.isFinished()) {
|
||||||
|
updatePosition(boat);
|
||||||
|
checkPosition(boat, totalTimeElapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
for (Marker mark: boatMarkers){
|
||||||
|
if (mark != null){
|
||||||
|
updateMarker(mark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (visualiserInput.getRaceStatus().isFinished()) {
|
if (visualiserInput.getRaceStatus().isFinished()) {
|
||||||
controller.finishRace(startingBoats);
|
controller.finishRace(startingBoats);
|
||||||
stop();
|
stop();
|
||||||
|
|||||||
@@ -328,6 +328,12 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
if (Duration.between(boat.getTimeSinceLastMark(), raceClock.getTime()).getSeconds() < 0) {
|
if (Duration.between(boat.getTimeSinceLastMark(), raceClock.getTime()).getSeconds() < 0) {
|
||||||
boat.setTimeSinceLastMark(raceClock.getTime());
|
boat.setTimeSinceLastMark(raceClock.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If the race hasn't started, we set the time since last mark to the current time, to ensure we don't start counting until the race actually starts.
|
||||||
|
if (boat.isStarted() == false) {
|
||||||
|
boat.setTimeSinceLastMark(raceClock.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getFormattedEstTime(), boat.getTimeSinceLastMark());
|
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getFormattedEstTime(), boat.getTimeSinceLastMark());
|
||||||
//TODO this needs to be fixed.
|
//TODO this needs to be fixed.
|
||||||
drawTrack(boat, boatColours.get(sourceID));
|
drawTrack(boat, boatColours.get(sourceID));
|
||||||
|
|||||||
Reference in New Issue
Block a user