Merged onto develop.

#mergre #refactor
This commit is contained in:
Calum
2017-08-17 01:03:14 +12:00
parent 87acce71ea
commit 7b4a70817b
5 changed files with 38 additions and 30 deletions
@@ -14,8 +14,8 @@ import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Pane;
import seng302.gameServer.GameState;
import seng302.gameServer.MainServerThread;
import seng302.gameServer.server.messages.BoatAction;
import seng302.gameServer.server.messages.BoatStatus;
import seng302.gameServer.messages.BoatAction;
import seng302.gameServer.messages.BoatStatus;
import seng302.model.ClientYacht;
import seng302.model.RaceState;
import seng302.model.stream.packets.StreamPacket;
@@ -176,7 +176,9 @@ public class GameClient {
}
private void loadFinishScreenView() {
loadFXMLToHolder("/views/FinishScreenView.fxml");
FXMLLoader fxmlLoader = loadFXMLToHolder("/views/FinishScreenView.fxml");
FinishScreenViewController controller = fxmlLoader.getController();
controller.setFinishers(raceState.getPlayerPositions());
}
private FXMLLoader loadFXMLToHolder(String fxmlLocation) {
@@ -192,8 +194,6 @@ public class GameClient {
} catch (IOException e) {
e.printStackTrace();
}
FinishScreenViewController controller = fxmlLoader.getController();
controller.setFinishers(raceState.getPlayerPositions());
return fxmlLoader;
}
@@ -297,13 +297,10 @@ public class GameClient {
private void updateMarkRounding(MarkRoundingData roundingData) {
if (allXMLReceived()) {
ClientYacht clientYacht = allBoatsMap.get(roundingData.getBoatId());
clientYacht.setMarkRoundingTime(roundingData.getTimeStamp());
clientYacht.updateTimeSinceLastMarkProperty(
raceState.getRaceTime() - roundingData.getTimeStamp());
clientYacht.setLastMarkRounded(
courseData.getCompoundMarks().get(
roundingData.getMarkId()
)
clientYacht.roundMark(
courseData.getCompoundMarks().get(roundingData.getMarkId()),
roundingData.getTimeStamp(),
raceState.getRaceTime() - roundingData.getTimeStamp()
);
}
}
@@ -771,9 +771,6 @@ public class GameView extends Pane {
private void updateMarkArrows (ClientYacht yacht, CompoundMark compoundMark, int legNumber) {
//Only show arrows for this and next leg.
if (legNumber - 2 >= 0) {
CompoundMark lastMark = course.get(Math.max(0, legNumber - 2));
}
if (compoundMark != null) {
for (Mark mark : compoundMark.getMarks()) {
markerObjects.get(mark).showNextExitArrow();
@@ -2,7 +2,6 @@ package seng302.visualiser.controllers;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Timer;
@@ -36,8 +35,8 @@ import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.StringConverter;
import seng302.model.RaceState;
import seng302.model.ClientYacht;
import seng302.model.RaceState;
import seng302.model.mark.CompoundMark;
import seng302.model.mark.Mark;
import seng302.model.stream.xml.parser.RaceXMLData;
@@ -147,14 +146,12 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
gameView.setWindDir(newDirection.doubleValue());
updateWindDirection(newDirection.doubleValue());
});
raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) -> {
updateWindSpeed(newSpeed.doubleValue());
});
updateWindDirection(raceState.windDirectionProperty().doubleValue());
updateWindSpeed(raceState.getWindSpeed());
gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
for (ClientYacht yacht : participants.values()) {
yacht.placingProperty().addListener((obs, oldPlacing, newPlacing) -> {
updateOrder();
updateSparkLine();
});
}
}
/**
@@ -379,10 +376,17 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
* Updates the wind direction arrow and text as from info from the StreamParser
* @param direction the from north angle of the wind.
*/
private void updateWind() {
windDirectionText.setText(String.format("%.1f°", raceState.getWindDirection()));
windArrowText.setRotate(raceState.getWindDirection());
windSpeedText.setText("Speed: " + String.format("%.1f", raceState.getWindSpeed()) + " Knots");
private void updateWindDirection(double direction) {
windDirectionText.setText(String.format("%.1f°", direction));
windArrowText.setRotate(direction);
}
/**
* Updates the speed of the wind as displayed by the info pane.
* @param windSpeed Windspeed in knots.
*/
private void updateWindSpeed(double windSpeed) {
windSpeedText.setText("Speed: " + String.format("%.1f", windSpeed) + " Knots");
}