mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Fixed leaderboard on start screen and race view to show all boats correctly during pre-race.
#story[923]
This commit is contained in:
@@ -2,7 +2,6 @@ package seng302.controllers;
|
|||||||
|
|
||||||
import seng302.models.Race;
|
import seng302.models.Race;
|
||||||
import seng302.models.Yacht;
|
import seng302.models.Yacht;
|
||||||
import seng302.models.parsers.ConfigParser;
|
|
||||||
import seng302.models.parsers.CourseParser;
|
import seng302.models.parsers.CourseParser;
|
||||||
import seng302.models.parsers.StreamParser;
|
import seng302.models.parsers.StreamParser;
|
||||||
|
|
||||||
@@ -18,6 +17,7 @@ import java.util.Random;
|
|||||||
* the CanvasController then uses the event data to make the animations
|
* the CanvasController then uses the event data to make the animations
|
||||||
*/
|
*/
|
||||||
public class RaceController {
|
public class RaceController {
|
||||||
|
|
||||||
Race race = null;
|
Race race = null;
|
||||||
|
|
||||||
public void initializeRace() {
|
public void initializeRace() {
|
||||||
@@ -39,24 +39,13 @@ public class RaceController {
|
|||||||
|
|
||||||
public Race createRace(String configFile, String teamsConfigFile) throws Exception {
|
public Race createRace(String configFile, String teamsConfigFile) throws Exception {
|
||||||
Race race = new Race();
|
Race race = new Race();
|
||||||
// StreamParser.xmlObject
|
|
||||||
// Read team names from file
|
|
||||||
// TeamsParser tp = new TeamsParser(teamsConfigFile);
|
|
||||||
|
|
||||||
// Read course from file
|
|
||||||
// ConfigParser config = new ConfigParser(configFile);
|
|
||||||
|
|
||||||
ArrayList<String> boatNames = new ArrayList<>();
|
ArrayList<String> boatNames = new ArrayList<>();
|
||||||
// ArrayList<Boat> teams = tp.getBoats();
|
|
||||||
Map<Long, Yacht> teams = StreamParser.getBoatsPos();
|
Map<Long, Yacht> teams = StreamParser.getBoatsPos();
|
||||||
|
|
||||||
//get race size
|
//get race size
|
||||||
int numberOfBoats = teams.size();
|
int numberOfBoats = teams.size();
|
||||||
|
|
||||||
//get time scale
|
|
||||||
// double timeScale = config.getTimeScale();
|
|
||||||
// race.setTimeScale(timeScale);
|
|
||||||
|
|
||||||
for (Yacht boat : teams.values()) {
|
for (Yacht boat : teams.values()) {
|
||||||
boatNames.add(boat.getBoatName());
|
boatNames.add(boat.getBoatName());
|
||||||
race.addBoat(boat);
|
race.addBoat(boat);
|
||||||
|
|||||||
@@ -251,21 +251,31 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
positionVbox.getChildren().removeAll();
|
positionVbox.getChildren().removeAll();
|
||||||
positionVbox.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
positionVbox.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||||
|
|
||||||
for (Yacht boat : StreamParser.getBoatsPos().values()) {
|
if (StreamParser.isRaceStarted()) {
|
||||||
if (boat.getBoatStatus() == 3) { // 3 is finish status
|
for (Yacht boat : StreamParser.getBoatsPos().values()) {
|
||||||
Text textToAdd = new Text(boat.getPosition() + ". " +
|
if (boat.getBoatStatus() == 3) { // 3 is finish status
|
||||||
boat.getShortName() + " (Finished)");
|
Text textToAdd = new Text(boat.getPosition() + ". " +
|
||||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
boat.getShortName() + " (Finished)");
|
||||||
positionVbox.getChildren().add(textToAdd);
|
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||||
|
positionVbox.getChildren().add(textToAdd);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Text textToAdd = new Text(boat.getPosition() + ". " +
|
||||||
|
boat.getShortName() + " ");
|
||||||
|
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||||
|
textToAdd.setStyle("");
|
||||||
|
positionVbox.getChildren().add(textToAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (Yacht boat : StreamParser.getBoats().values()) {
|
||||||
Text textToAdd = new Text(boat.getPosition() + ". " +
|
Text textToAdd = new Text(boat.getPosition() + ". " +
|
||||||
boat.getShortName() + " ");
|
boat.getShortName() + " ");
|
||||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||||
textToAdd.setStyle("");
|
textToAdd.setStyle("");
|
||||||
positionVbox.getChildren().add(textToAdd);
|
positionVbox.getChildren().add(textToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import seng302.models.Yacht;
|
|||||||
import seng302.models.parsers.StreamParser;
|
import seng302.models.parsers.StreamParser;
|
||||||
|
|
||||||
public class StartScreenController implements Initializable {
|
public class StartScreenController implements Initializable {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private GridPane gridPane;
|
private GridPane gridPane;
|
||||||
@FXML
|
@FXML
|
||||||
@@ -48,19 +49,18 @@ public class StartScreenController implements Initializable {
|
|||||||
|
|
||||||
private boolean switchedToRaceView = false;
|
private boolean switchedToRaceView = false;
|
||||||
|
|
||||||
private void setContentPane(String jfxUrl){
|
private void setContentPane(String jfxUrl) {
|
||||||
try{
|
try {
|
||||||
// get the main controller anchor pane (MainView.fxml)
|
// get the main controller anchor pane (MainView.fxml)
|
||||||
AnchorPane contentPane = (AnchorPane) gridPane.getParent();
|
AnchorPane contentPane = (AnchorPane) gridPane.getParent();
|
||||||
contentPane.getChildren().removeAll();
|
contentPane.getChildren().removeAll();
|
||||||
contentPane.getChildren().clear();
|
contentPane.getChildren().clear();
|
||||||
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||||
contentPane.getChildren().addAll((Pane) FXMLLoader.load(getClass().getResource(jfxUrl)));
|
contentPane.getChildren()
|
||||||
}
|
.addAll((Pane) FXMLLoader.load(getClass().getResource(jfxUrl)));
|
||||||
catch(javafx.fxml.LoadException e){
|
} catch (javafx.fxml.LoadException e) {
|
||||||
System.err.println(e.getCause());
|
System.err.println(e.getCause());
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch(IOException e){
|
|
||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,8 @@ public class StartScreenController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Running a timer to update the livestream status on welcome screen. Update interval is 1 second.
|
* Running a timer to update the livestream status on welcome screen. Update interval is 1
|
||||||
|
* second.
|
||||||
*/
|
*/
|
||||||
public void startStream() {
|
public void startStream() {
|
||||||
if (StreamParser.isStreamStatus()) {
|
if (StreamParser.isStreamStatus()) {
|
||||||
@@ -102,8 +103,10 @@ public class StartScreenController implements Initializable {
|
|||||||
updateTeamList();
|
updateTeamList();
|
||||||
timeTillLive.setTextFill(Color.RED);
|
timeTillLive.setTextFill(Color.RED);
|
||||||
switchToRaceViewButton.setDisable(false);
|
switchToRaceViewButton.setDisable(false);
|
||||||
String timerMinute = Long.toString(StreamParser.getTimeSinceStart() / 60);
|
String timerMinute = Long
|
||||||
String timerSecond = Long.toString(StreamParser.getTimeSinceStart() % 60);
|
.toString(StreamParser.getTimeSinceStart() / 60);
|
||||||
|
String timerSecond = Long
|
||||||
|
.toString(StreamParser.getTimeSinceStart() % 60);
|
||||||
if (timerSecond.length() == 1) {
|
if (timerSecond.length() == 1) {
|
||||||
timerSecond = "0" + timerSecond;
|
timerSecond = "0" + timerSecond;
|
||||||
}
|
}
|
||||||
@@ -114,8 +117,10 @@ public class StartScreenController implements Initializable {
|
|||||||
updateTeamList();
|
updateTeamList();
|
||||||
timeTillLive.setTextFill(Color.BLACK);
|
timeTillLive.setTextFill(Color.BLACK);
|
||||||
switchToRaceViewButton.setDisable(false);
|
switchToRaceViewButton.setDisable(false);
|
||||||
String timerMinute = Long.toString(-1 * StreamParser.getTimeSinceStart() / 60);
|
String timerMinute = Long
|
||||||
String timerSecond = Long.toString(-1 * StreamParser.getTimeSinceStart() % 60);
|
.toString(-1 * StreamParser.getTimeSinceStart() / 60);
|
||||||
|
String timerSecond = Long
|
||||||
|
.toString(-1 * StreamParser.getTimeSinceStart() % 60);
|
||||||
if (timerSecond.length() == 1) {
|
if (timerSecond.length() == 1) {
|
||||||
timerSecond = "0" + timerSecond;
|
timerSecond = "0" + timerSecond;
|
||||||
}
|
}
|
||||||
@@ -142,19 +147,23 @@ public class StartScreenController implements Initializable {
|
|||||||
teamList.setItems(data);
|
teamList.setItems(data);
|
||||||
|
|
||||||
boatNameCol.setCellValueFactory(
|
boatNameCol.setCellValueFactory(
|
||||||
new PropertyValueFactory<>("boatName")
|
new PropertyValueFactory<>("boatName")
|
||||||
);
|
);
|
||||||
shortNameCol.setCellValueFactory(
|
shortNameCol.setCellValueFactory(
|
||||||
new PropertyValueFactory<>("shortName")
|
new PropertyValueFactory<>("shortName")
|
||||||
);
|
);
|
||||||
countryCol.setCellValueFactory(
|
countryCol.setCellValueFactory(
|
||||||
new PropertyValueFactory<>("country")
|
new PropertyValueFactory<>("country")
|
||||||
);
|
);
|
||||||
posCol.setCellValueFactory(
|
posCol.setCellValueFactory(
|
||||||
new PropertyValueFactory<>("position")
|
new PropertyValueFactory<>("position")
|
||||||
);
|
);
|
||||||
|
|
||||||
data.addAll(StreamParser.getBoatsPos().values());
|
if (StreamParser.isRaceStarted()) {
|
||||||
|
data.addAll(StreamParser.getBoatsPos().values());
|
||||||
|
} else {
|
||||||
|
data.addAll(StreamParser.getBoats().values());
|
||||||
|
}
|
||||||
teamList.refresh();
|
teamList.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ import java.text.SimpleDateFormat;
|
|||||||
* Yacht class for the racing boat.
|
* Yacht class for the racing boat.
|
||||||
*
|
*
|
||||||
* Class created to store more variables (eg. boat statuses) compared to the XMLParser boat class,
|
* Class created to store more variables (eg. boat statuses) compared to the XMLParser boat class,
|
||||||
* also done outside Boat class because some old variables are not used anymore.
|
* also done outside Boat class because some old variables are not used anymore.
|
||||||
*/
|
*/
|
||||||
public class Yacht {
|
public class Yacht {
|
||||||
|
|
||||||
// Used in boat group
|
// Used in boat group
|
||||||
private Color colour;
|
private Color colour;
|
||||||
private double velocity;
|
private double velocity;
|
||||||
@@ -38,25 +39,27 @@ public class Yacht {
|
|||||||
*
|
*
|
||||||
* @param boatName Create a yacht object with name.
|
* @param boatName Create a yacht object with name.
|
||||||
*/
|
*/
|
||||||
public Yacht (String boatName) {
|
public Yacht(String boatName) {
|
||||||
this.boatName = boatName;
|
this.boatName = boatName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in BoatGroupTest.
|
* Used in BoatGroupTest.
|
||||||
*
|
*
|
||||||
* @param boatName The name of the team sailing the boat
|
* @param boatName The name of the team sailing the boat
|
||||||
* @param boatVelocity The speed of the boat in meters/second
|
* @param boatVelocity The speed of the boat in meters/second
|
||||||
* @param shortName A shorter version of the teams name
|
* @param shortName A shorter version of the teams name
|
||||||
*/
|
*/
|
||||||
public Yacht(String boatName, double boatVelocity, String shortName, int id) {
|
public Yacht(String boatName, double boatVelocity, String shortName, int id) {
|
||||||
this.boatName = boatName;
|
this.boatName = boatName;
|
||||||
this.velocity = boatVelocity;
|
this.velocity = boatVelocity;
|
||||||
this.shortName = shortName;
|
this.shortName = shortName;
|
||||||
this.sourceID = id;
|
this.sourceID = id;
|
||||||
|
this.position = "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Yacht(String boatType, Integer sourceID, String hullID, String shortName, String boatName, String country) {
|
public Yacht(String boatType, Integer sourceID, String hullID, String shortName,
|
||||||
|
String boatName, String country) {
|
||||||
this.boatType = boatType;
|
this.boatType = boatType;
|
||||||
this.sourceID = sourceID;
|
this.sourceID = sourceID;
|
||||||
this.hullID = hullID;
|
this.hullID = hullID;
|
||||||
@@ -68,18 +71,23 @@ public class Yacht {
|
|||||||
public String getBoatType() {
|
public String getBoatType() {
|
||||||
return boatType;
|
return boatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getSourceID() {
|
public Integer getSourceID() {
|
||||||
return sourceID;
|
return sourceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHullID() {
|
public String getHullID() {
|
||||||
return hullID;
|
return hullID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getShortName() {
|
public String getShortName() {
|
||||||
return shortName;
|
return shortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBoatName() {
|
public String getBoatName() {
|
||||||
return boatName;
|
return boatName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCountry() {
|
public String getCountry() {
|
||||||
return country;
|
return country;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user