Merge branch 'fix_time_since_last_marker' into 'sprint4_master'
Fix time since last marker 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. See merge request !13
This commit is contained in:
@@ -69,7 +69,7 @@ public class Race implements Runnable {
|
|||||||
* Frame periods are multiplied by this to get the amount of time a single frame represents.
|
* Frame periods are multiplied by this to get the amount of time a single frame represents.
|
||||||
* E.g., frame period = 20ms, scale = 5, frame represents 20 * 5 = 100ms, and so boats are simulated for 100ms, even though only 20ms actually occurred.
|
* E.g., frame period = 20ms, scale = 5, frame represents 20 * 5 = 100ms, and so boats are simulated for 100ms, even though only 20ms actually occurred.
|
||||||
*/
|
*/
|
||||||
private int scaleFactor = 15;
|
private int scaleFactor = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The race ID of the course.
|
* The race ID of the course.
|
||||||
|
|||||||
@@ -51,5 +51,10 @@ public class MainController extends Controller {
|
|||||||
AnchorPane.setBottomAnchor(connectionController.startWrapper(), 0.0);
|
AnchorPane.setBottomAnchor(connectionController.startWrapper(), 0.0);
|
||||||
AnchorPane.setLeftAnchor(connectionController.startWrapper(), 0.0);
|
AnchorPane.setLeftAnchor(connectionController.startWrapper(), 0.0);
|
||||||
AnchorPane.setRightAnchor(connectionController.startWrapper(), 0.0);
|
AnchorPane.setRightAnchor(connectionController.startWrapper(), 0.0);
|
||||||
|
|
||||||
|
AnchorPane.setTopAnchor(finishController.finishWrapper, 0.0);
|
||||||
|
AnchorPane.setBottomAnchor(finishController.finishWrapper, 0.0);
|
||||||
|
AnchorPane.setLeftAnchor(finishController.finishWrapper, 0.0);
|
||||||
|
AnchorPane.setRightAnchor(finishController.finishWrapper, 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,6 +197,15 @@ public class StreamedRace implements Runnable {
|
|||||||
public void handle(long arg0) {
|
public void handle(long arg0) {
|
||||||
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
|
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
|
||||||
|
|
||||||
|
|
||||||
|
//Check if the race has actually started.
|
||||||
|
if (visualiserInput.getRaceStatus().isStarted()) {
|
||||||
|
//Set all boats to started.
|
||||||
|
for (Boat boat : startingBoats) {
|
||||||
|
boat.setStarted(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Boat boat : startingBoats) {
|
for (Boat boat : startingBoats) {
|
||||||
if (boat != null && !boat.isFinished()) {
|
if (boat != null && !boat.isFinished()) {
|
||||||
updatePosition(boat);
|
updatePosition(boat);
|
||||||
|
|||||||
@@ -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