Fixed a bug where clicking "watch race" before race starts will cause boats to travel in unexpected ways.

#story[923]
This commit is contained in:
Zhi You Tan
2017-05-12 17:41:47 +12:00
parent a23bdd0c53
commit 14d975dce4
@@ -46,7 +46,7 @@ public class Controller implements Initializable {
@FXML @FXML
private Label realTime; private Label realTime;
private XMLParser xmlParser; private boolean switchedToRaceView = false;
private void setContentPane(String jfxUrl){ private void setContentPane(String jfxUrl){
try{ try{
@@ -65,9 +65,6 @@ public class Controller implements Initializable {
@Override @Override
public void initialize(URL location, ResourceBundle resources) { public void initialize(URL location, ResourceBundle resources) {
//DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//format.setTimeZone(TimeZone.getTimeZone("GMT-8"));
//realTime.setText(format.format(new Date()));
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString()); contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
teamList.getStylesheets().add(getClass().getResource("/css/master.css").toString()); teamList.getStylesheets().add(getClass().getResource("/css/master.css").toString());
} }
@@ -77,7 +74,6 @@ public class Controller implements Initializable {
*/ */
public void startStream() { public void startStream() {
if (StreamParser.isStreamStatus()) { if (StreamParser.isStreamStatus()) {
xmlParser = StreamParser.getXmlObject();
streamButton.setVisible(false); streamButton.setVisible(false);
realTime.setVisible(true); realTime.setVisible(true);
timeTillLive.setVisible(true); timeTillLive.setVisible(true);
@@ -89,7 +85,9 @@ public class Controller implements Initializable {
public void run() { public void run() {
Platform.runLater(() -> { Platform.runLater(() -> {
if (StreamParser.isRaceStarted()) { if (StreamParser.isRaceStarted()) {
if (!switchedToRaceView) {
switchToRaceView(); switchToRaceView();
}
timer.cancel(); timer.cancel();
} }
if (StreamParser.isRaceFinished()) { if (StreamParser.isRaceFinished()) {
@@ -132,6 +130,7 @@ public class Controller implements Initializable {
} }
public void switchToRaceView() { public void switchToRaceView() {
switchedToRaceView = true;
setContentPane("/views/RaceView.fxml"); setContentPane("/views/RaceView.fxml");
} }
@@ -152,18 +151,8 @@ public class Controller implements Initializable {
posCol.setCellValueFactory( posCol.setCellValueFactory(
new PropertyValueFactory<>("position") new PropertyValueFactory<>("position")
); );
// if (StreamParser.isRaceStarted()) {
data.addAll(StreamParser.getBoatsPos().values());
// } else {
// for (Yacht boat : StreamParser.getBoats().values()) {
// boat.setPosition("-");
// data.add(boat);
// }
// }
teamList.refresh();
// posCol.setSortType(TableColumn.SortType.ASCENDING); data.addAll(StreamParser.getBoatsPos().values());
// teamList.getSortOrder().add(posCol); teamList.refresh();
// posCol.setSortable(false);
} }
} }