mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Fixed broken race timer and timer now using stream timer data.
#story[818]
This commit is contained in:
@@ -12,6 +12,7 @@ import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
import seng302.models.Boat;
|
||||
@@ -19,6 +20,7 @@ import seng302.models.Event;
|
||||
import seng302.models.Race;
|
||||
import seng302.models.TimelineInfo;
|
||||
import seng302.models.parsers.ConfigParser;
|
||||
import seng302.models.parsers.StreamParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
@@ -65,7 +67,7 @@ public class RaceViewController extends Thread{
|
||||
|
||||
includedCanvasController.setup(this);
|
||||
includedCanvasController.initializeCanvas();
|
||||
//initializeTimer();
|
||||
initializeTimer();
|
||||
initializeSettings();
|
||||
|
||||
//set wind direction!!!!!!! can't find another place to put my code --haoming
|
||||
@@ -102,12 +104,11 @@ public class RaceViewController extends Thread{
|
||||
timerTimeline.getKeyFrames().add(
|
||||
new KeyFrame(Duration.seconds(1),
|
||||
event -> {
|
||||
// Stop timer if race is finished
|
||||
if (this.race.isRaceFinished()) {
|
||||
this.timerTimeline.stop();
|
||||
if (StreamParser.isRaceFinished()) {
|
||||
timerLabel.setFill(Color.RED);
|
||||
timerLabel.setText("Race Finished!");
|
||||
} else {
|
||||
timerLabel.setText(convertTimeToMinutesSeconds(race.getRaceTime()));
|
||||
this.race.incrementRaceTime();
|
||||
timerLabel.setText(currentTimer());
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -262,6 +263,20 @@ public class RaceViewController extends Thread{
|
||||
return String.format("%02d:%02d", time / 60, time % 60);
|
||||
}
|
||||
|
||||
private String currentTimer() {
|
||||
String timerString = "0:00 minutes";
|
||||
if (StreamParser.getTimeSinceStart() > 0 && StreamParser.getTimeSinceStart() % 10 == 0) {
|
||||
Long timerMinute = StreamParser.getTimeSinceStart() / 60;
|
||||
Long timerSecond = StreamParser.getTimeSinceStart() % 60;
|
||||
timerString = "-" + timerMinute + "." + timerSecond + " minutes";
|
||||
} else if (StreamParser.getTimeSinceStart() % 10 == 0) {
|
||||
Long timerMinute = -1 * StreamParser.getTimeSinceStart() / 60;
|
||||
Long timerSecond = -1 * StreamParser.getTimeSinceStart() % 60;
|
||||
timerString = timerMinute + "." + timerSecond + " minutes";
|
||||
}
|
||||
return timerString;
|
||||
}
|
||||
|
||||
public void stopTimer() {
|
||||
timerTimeline.stop();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
@@ -12,7 +17,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<GridPane prefHeight="1080.0" prefWidth="1920.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.RaceViewController">
|
||||
<GridPane prefHeight="1080.0" prefWidth="1920.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.RaceViewController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints maxWidth="246.0" minWidth="246.0" prefWidth="246.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1034.0" />
|
||||
@@ -47,7 +52,7 @@
|
||||
<children>
|
||||
<Text fx:id="timerLabel" layoutX="6.0" layoutY="37.0" strokeType="OUTSIDE" strokeWidth="0.0" text="00:00" textAlignment="CENTER" wrappingWidth="181.0">
|
||||
<font>
|
||||
<Font size="34.0" />
|
||||
<Font size="25.0" />
|
||||
</font>
|
||||
</Text>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user