Fixed race playback issue, removed obsolete detail from UI.
- Removed race scaling options - Refactored start screen timer formatting for clarity - Removed incomplete countdownTimer override in Streamed Race #story[782]
This commit is contained in:
@@ -20,6 +20,8 @@ import seng302.VisualiserInput;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
@@ -38,10 +40,8 @@ public class StartController extends Controller implements Observer {
|
||||
@FXML private TableColumn<Boat, String> boatCodeColumn;
|
||||
@FXML private Label timeZoneTime;
|
||||
@FXML private Label timer;
|
||||
@FXML private int PRERACE_TIME = 15000;
|
||||
@FXML private int PRERACE_TIME = 10;
|
||||
|
||||
@FXML Button oneMinButton;
|
||||
@FXML Button fiveMinButton;
|
||||
@FXML Button fifteenMinButton;
|
||||
|
||||
private RaceClock raceClock;
|
||||
@@ -51,20 +51,6 @@ public class StartController extends Controller implements Observer {
|
||||
|
||||
private VisualiserInput visualiserInput;
|
||||
|
||||
/**
|
||||
* Begins the race with a scale factor of 15
|
||||
*/
|
||||
public void startRace1Min() {
|
||||
startRace(15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the race with a scale factor of 3
|
||||
*/
|
||||
public void startRace5Min() {
|
||||
startRace(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the race with a scale factor of 1
|
||||
*/
|
||||
@@ -73,9 +59,6 @@ public class StartController extends Controller implements Observer {
|
||||
}
|
||||
|
||||
private void startRace(int raceScale){
|
||||
|
||||
oneMinButton.setDisable(true);
|
||||
fiveMinButton.setDisable(true);
|
||||
fifteenMinButton.setDisable(true);
|
||||
countdownTimer(raceScale);
|
||||
}
|
||||
@@ -118,10 +101,7 @@ public class StartController extends Controller implements Observer {
|
||||
new AnimationTimer() {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long startTime = currentTime + (PRERACE_TIME/scaleFactor);
|
||||
long minutes;
|
||||
long currentTimeInSeconds;
|
||||
long remainingSeconds;
|
||||
long hours;
|
||||
DateFormat timerFormat = new SimpleDateFormat("'Race Clock:' -HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public void handle(long arg0) {
|
||||
@@ -133,12 +113,7 @@ public class StartController extends Controller implements Observer {
|
||||
startWrapper.setVisible(false);
|
||||
|
||||
} else {
|
||||
currentTimeInSeconds = (timeLeft*scaleFactor) / 1000;
|
||||
minutes = currentTimeInSeconds / 60;
|
||||
remainingSeconds = currentTimeInSeconds % 60;
|
||||
hours = minutes / 60;
|
||||
minutes = minutes % 60;
|
||||
updateTime(String.format("Race Clock: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
|
||||
updateTime(timerFormat.format(currentTime));
|
||||
|
||||
}
|
||||
currentTime = System.currentTimeMillis();
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
package seng302.Mock;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.collections.FXCollections;
|
||||
import org.geotools.referencing.GeodeticCalculator;
|
||||
import seng302.*;
|
||||
import seng302.Controllers.RaceController;
|
||||
import seng302.Model.*;
|
||||
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
|
||||
import seng302.Networking.Utils.BoatStatusMessage;
|
||||
import seng302.Networking.Utils.ByteConverter;
|
||||
import seng302.Networking.Utils.Enums.BoatStatus;
|
||||
import seng302.Networking.Utils.BoatLocationMessage;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by jjg64 on 21/04/17.
|
||||
*/
|
||||
@@ -101,39 +92,4 @@ public class StreamedRace extends Race {
|
||||
boat.setCurrentPosition(coordinate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void countdownTimer() {
|
||||
new AnimationTimer() {
|
||||
long minutes;
|
||||
long currentTimeInSeconds;
|
||||
long remainingSeconds;
|
||||
long hours;
|
||||
long timeLeft;
|
||||
|
||||
@Override
|
||||
public void handle(long arg0) {
|
||||
long currentTime = Instant.now().getEpochSecond();
|
||||
long startTime = visualiserInput.getRaceStatus().getExpectedStartTime();
|
||||
timeLeft = startTime - currentTime;
|
||||
System.out.println(timeLeft);
|
||||
|
||||
if (timeLeft <= 0 && controller != null) {
|
||||
updateTime("Race is starting...");
|
||||
stop();
|
||||
simulateRace();
|
||||
} else {
|
||||
currentTimeInSeconds = (timeLeft*scaleFactor) / 1000;
|
||||
minutes = currentTimeInSeconds / 60;
|
||||
remainingSeconds = currentTimeInSeconds % 60;
|
||||
hours = minutes / 60;
|
||||
minutes = minutes % 60;
|
||||
if (controller != null) {
|
||||
updateTime(String.format("Race clock: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
|
||||
}
|
||||
}
|
||||
currentTime = System.currentTimeMillis();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 19/04/2017.
|
||||
@@ -29,6 +30,12 @@ public class RaceClock {
|
||||
setTime(time);
|
||||
}
|
||||
|
||||
public RaceClock(long utcTime, ZoneId zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
this.timeString = new SimpleStringProperty();
|
||||
this.time = (new Date(utcTime)).toInstant().atZone(zoneId);
|
||||
}
|
||||
|
||||
public static ZonedDateTime getCurrentZonedDateTime(GPSCoordinate gpsCoordinate) {
|
||||
TimeZoneLookup timeZoneLookup = new TimeZoneLookup();
|
||||
TimeZoneResult timeZoneResult = timeZoneLookup.getTimeZone(gpsCoordinate.getLatitude(), gpsCoordinate.getLongitude());
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
@@ -24,34 +23,31 @@
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="241.0" minHeight="10.0" prefHeight="116.5" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="383.0" minHeight="10.0" prefHeight="257.5" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="50.5" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="383.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="261.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="38.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="53.5" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to RaceVision" GridPane.columnSpan="5" GridPane.halignment="CENTER">
|
||||
<Text fx:id="raceTitleLabel" strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to RaceVision" GridPane.columnSpan="5" GridPane.halignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button fx:id="oneMinButton" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace1Min" prefWidth="100.0" text="1 Minute" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4">
|
||||
<GridPane.margin>
|
||||
<Insets />
|
||||
</GridPane.margin>
|
||||
</Button>
|
||||
<Button fx:id="fifteenMinButton" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRaceNoScaling" prefWidth="100.0" text="15 Minutes" GridPane.columnIndex="3" GridPane.halignment="LEFT" GridPane.rowIndex="4" />
|
||||
<Button fx:id="fiveMinButton" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace5Min" prefWidth="100.0" text="5 Minutes" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
|
||||
<Label text="Select Race Duration:" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" />
|
||||
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="1">
|
||||
<Button fx:id="fifteenMinButton" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRaceNoScaling" prefWidth="100.0" text="Start" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
|
||||
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="2">
|
||||
<placeholder>
|
||||
<Label text="Initial lineup..." />
|
||||
</placeholder>
|
||||
<columns>
|
||||
<TableColumn fx:id="boatNameColumn" prefWidth="360.0" style="-fx-font-size: 16;" text="Team Name" />
|
||||
<TableColumn fx:id="boatCodeColumn" prefWidth="133.0" style="-fx-font-size: 16;" text="Code" />
|
||||
</columns>
|
||||
</TableView>
|
||||
<Label fx:id="timeZoneTime" contentDisplay="CENTER" text="timeZoneTime" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER" />
|
||||
<Label fx:id="timeZoneTime" contentDisplay="CENTER" text="Local time..." GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER" />
|
||||
<Label fx:id="timer" text=" " GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
|
||||
<Label fx:id="raceStartLabel" text="Starting time..." visible="false" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user