Merge remote-tracking branch 'origin/NewUI_merge' into NewUI_merge

This commit is contained in:
Alistair McIntyre
2017-09-12 16:54:55 +12:00
7 changed files with 96 additions and 88 deletions
@@ -735,4 +735,8 @@ public class GameView3D {
// }); // });
// playerYacht.addMarkRoundingListener(this::updateMarkArrows); // playerYacht.addMarkRoundingListener(this::updateMarkArrows);
} }
public void setWindDir(double windDir) {
this.windDir = windDir;
}
} }
@@ -88,8 +88,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
@FXML @FXML
private AnchorPane rvAnchorPane; private AnchorPane rvAnchorPane;
@FXML @FXML
private Text windDirectionText;
@FXML
private AnchorPane windArrowHolder; private AnchorPane windArrowHolder;
@FXML @FXML
private Slider annotationSlider; private Slider annotationSlider;
@@ -100,9 +98,11 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
@FXML @FXML
private Text fpsDisplay; private Text fpsDisplay;
@FXML @FXML
private Text windSpeedText;
@FXML
private ImageView windImageView; private ImageView windImageView;
@FXML
private Label windDirectionLabel;
@FXML
private Label windSpeedLabel;
//Race Data //Race Data
private Map<Integer, ClientYacht> participants; private Map<Integer, ClientYacht> participants;
@@ -216,12 +216,12 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
// raceState.addCollisionListener(gameView::drawCollision); // raceState.addCollisionListener(gameView::drawCollision);
raceState.windDirectionProperty().addListener((obs, oldDirection, newDirection) -> { raceState.windDirectionProperty().addListener((obs, oldDirection, newDirection) -> {
// gameView.setWindDir(newDirection.doubleValue()); gameView.setWindDir(newDirection.doubleValue());
Platform.runLater(() -> updateWindDirection(newDirection.doubleValue())); Platform.runLater(() -> updateWindDirection(newDirection.doubleValue()));
}); });
// raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) -> raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) ->
// Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue())) Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue()))
// ); );
Platform.runLater(() -> { Platform.runLater(() -> {
updateWindDirection(raceState.windDirectionProperty().doubleValue()); updateWindDirection(raceState.windDirectionProperty().doubleValue());
updateWindSpeed(raceState.getWindSpeed()); updateWindSpeed(raceState.getWindSpeed());
@@ -473,8 +473,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
* @param direction the from north angle of the wind. * @param direction the from north angle of the wind.
*/ */
private void updateWindDirection(double direction) { private void updateWindDirection(double direction) {
// windDirectionText.setText(String.format("%.1f°", direction)); windDirectionLabel.setText(String.format("%.1f°", direction));
// windArrowText.setRotate(direction); windImageView.setRotate(direction);
} }
/** /**
@@ -482,7 +482,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
* @param windSpeed Windspeed in knots. * @param windSpeed Windspeed in knots.
*/ */
private void updateWindSpeed(double windSpeed) { private void updateWindSpeed(double windSpeed) {
// windSpeedText.setText("Speed: " + String.format("%.1f", windSpeed) + " Knots"); windSpeedLabel.setText(String.format("%.1f", windSpeed) + " Knots");
} }
@@ -70,4 +70,7 @@ public class ChatHistory extends ScrollPane {
} }
} }
} }
+35 -48
View File
@@ -14,38 +14,28 @@
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?> <?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane fx:id="rvAnchorPane" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" <AnchorPane fx:id="rvAnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1200.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController">
prefWidth="1200.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="seng302.visualiser.controllers.RaceViewController">
<children> <children>
<StackPane fx:id="contentAnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="800.0" prefWidth="1200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <StackPane fx:id="contentAnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="800.0" prefWidth="1200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
</StackPane> </StackPane>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" <GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="800.0" prefWidth="1200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
prefHeight="800.0" prefWidth="1200.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="250.0" minWidth="250.0" <ColumnConstraints hgrow="SOMETIMES" maxWidth="250.0" minWidth="250.0" prefWidth="250.0" />
prefWidth="250.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="400.0" <ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="400.0" prefWidth="400.0" />
prefWidth="400.0"/>
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="70.0" minHeight="70.0" prefHeight="70.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="70.0" minHeight="70.0" prefHeight="70.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="1.7976931348623157E308" vgrow="SOMETIMES" /> <RowConstraints maxHeight="1.7976931348623157E308" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="200.0" prefHeight="200.0" <RowConstraints maxHeight="200.0" minHeight="200.0" prefHeight="200.0" vgrow="SOMETIMES" />
vgrow="SOMETIMES"/>
</rowConstraints> </rowConstraints>
<children> <children>
<GridPane id="timerGrid" fx:id="timerGrid" prefWidth="192.0" styleClass=".timer"> <GridPane id="timerGrid" fx:id="timerGrid" prefWidth="192.0" styleClass=".timer">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="50.0" minWidth="50.0" <ColumnConstraints hgrow="SOMETIMES" maxWidth="50.0" minWidth="50.0" prefWidth="50.0" />
prefWidth="50.0"/> <ColumnConstraints hgrow="SOMETIMES" maxWidth="130.0" minWidth="130.0" prefWidth="130.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="130.0" minWidth="130.0"
prefWidth="130.0"/>
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
@@ -86,19 +76,15 @@
</GridPane> </GridPane>
<GridPane fx:id="chatGridPane" GridPane.columnIndex="2" GridPane.rowIndex="2"> <GridPane fx:id="chatGridPane" GridPane.columnIndex="2" GridPane.rowIndex="2">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" <ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="300.0" prefWidth="300.0" />
minWidth="300.0" prefWidth="300.0"/> <ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="100.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="100.0"
prefWidth="100.0"/>
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="1.7976931348623157E308" vgrow="SOMETIMES" /> <RowConstraints maxHeight="1.7976931348623157E308" vgrow="SOMETIMES" />
<RowConstraints maxHeight="50.0" minHeight="50.0" prefHeight="50.0" <RowConstraints maxHeight="50.0" minHeight="50.0" prefHeight="50.0" vgrow="SOMETIMES" />
vgrow="SOMETIMES"/>
</rowConstraints> </rowConstraints>
<children> <children>
<Pane fx:id="chatHistoryHolder" prefHeight="200.0" prefWidth="200.0" <Pane fx:id="chatHistoryHolder" prefHeight="200.0" prefWidth="200.0" GridPane.columnSpan="2" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
GridPane.columnSpan="2" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
<GridPane.margin> <GridPane.margin>
<Insets /> <Insets />
</GridPane.margin> </GridPane.margin>
@@ -106,44 +92,45 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding> </padding>
</Pane> </Pane>
<JFXButton fx:id="chatSend" alignment="CENTER" buttonType="RAISED" <JFXButton fx:id="chatSend" alignment="CENTER" buttonType="RAISED" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="40.0" text="SEND" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="40.0" text="SEND" GridPane.columnIndex="1"
GridPane.halignment="CENTER" GridPane.rowIndex="1"
GridPane.valignment="CENTER">
<GridPane.margin> <GridPane.margin>
<Insets left="10.0" right="10.0" /> <Insets left="10.0" right="10.0" />
</GridPane.margin> </GridPane.margin>
</JFXButton> </JFXButton>
<JFXTextField fx:id="chatInput" maxHeight="35.0" minHeight="-Infinity" <JFXTextField fx:id="chatInput" maxHeight="35.0" minHeight="-Infinity" prefHeight="35.0" GridPane.rowIndex="1">
prefHeight="35.0" GridPane.rowIndex="1">
<GridPane.margin> <GridPane.margin>
<Insets left="10.0" /> <Insets left="10.0" />
</GridPane.margin> </GridPane.margin>
</JFXTextField> </JFXTextField>
</children> </children>
</GridPane> </GridPane>
<GridPane GridPane.halignment="CENTER" GridPane.rowIndex="2" <GridPane GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="BOTTOM">
GridPane.valignment="BOTTOM">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/> <ColumnConstraints hgrow="SOMETIMES" maxWidth="110.0" minWidth="110.0" prefWidth="110.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/> <ColumnConstraints hgrow="SOMETIMES" maxWidth="132.0" minWidth="10.0" prefWidth="132.0" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="100.0" minHeight="100.0" prefHeight="100.0" <RowConstraints maxHeight="100.0" minHeight="100.0" prefHeight="100.0" vgrow="SOMETIMES" />
vgrow="SOMETIMES"/> <RowConstraints maxHeight="90.0" minHeight="90.0" prefHeight="90.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="100.0" minHeight="100.0" prefHeight="100.0" <RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0"
vgrow="SOMETIMES"/>
</rowConstraints> </rowConstraints>
<children> <children>
<ImageView fx:id="windImageView" fitHeight="92.0" fitWidth="109.0" <ImageView fx:id="windImageView" fitHeight="92.0" fitWidth="109.0" pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" <Label fx:id="windDirectionLabel" text="180.0°" GridPane.halignment="LEFT" GridPane.rowIndex="2" GridPane.valignment="CENTER">
GridPane.rowIndex="1" GridPane.valignment="CENTER"/> <GridPane.margin>
<Label fx:id="windLabel" text="112d 11.5knot" GridPane.halignment="CENTER" <Insets left="5.0" />
GridPane.rowIndex="2" GridPane.valignment="CENTER"/> </GridPane.margin></Label>
<Label fx:id="windSpeedLabel" text="0.0 Knots" GridPane.halignment="RIGHT" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<GridPane.margin>
<Insets right="5.0" />
</GridPane.margin></Label>
</children> </children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<GridPane.margin>
<Insets bottom="10.0" left="10.0" />
</GridPane.margin>
</GridPane> </GridPane>
</children> </children>
</GridPane> </GridPane>
@@ -68,9 +68,11 @@ public class ChatCommandsTest {
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
ie.printStackTrace(); ie.printStackTrace();
} }
mst.terminate();
host = null; host = null;
client = null; client = null;
mst = null; mst = null;
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} }
@@ -86,6 +88,11 @@ public class ChatCommandsTest {
new GameState("localhost"); new GameState("localhost");
mst = new MainServerThread(); mst = new MainServerThread();
host = null; host = null;
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
try { try {
host = new ClientToServerThread("localhost", 4942); host = new ClientToServerThread("localhost", 4942);
} catch (IOException ioe) { } catch (IOException ioe) {
@@ -97,7 +104,7 @@ public class ChatCommandsTest {
ie.printStackTrace(); ie.printStackTrace();
} }
mst.startGame(); mst.startGame();
host.sendChatterMessage("[time_prefix] <name_prefix> >speed 5.0"); host.sendChatterMessage("[time_prefix] <name_prefix> >speed 5");
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
@@ -106,7 +113,7 @@ public class ChatCommandsTest {
Assert.assertEquals(5.0, GameState.getSpeedMultiplier(), 0.00001); Assert.assertEquals(5.0, GameState.getSpeedMultiplier(), 0.00001);
mst.terminate(); mst.terminate();
try { try {
Thread.sleep(2000); Thread.sleep(200);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
ie.printStackTrace(); ie.printStackTrace();
} }
+6
View File
@@ -5,6 +5,7 @@ import cucumber.api.java.en.Then;
import cucumber.api.java.en.When; import cucumber.api.java.en.When;
import javafx.util.Pair; import javafx.util.Pair;
import org.junit.Assert; import org.junit.Assert;
import seng302.gameServer.GameState;
import seng302.gameServer.MainServerThread; import seng302.gameServer.MainServerThread;
import seng302.model.stream.packets.StreamPacket; import seng302.model.stream.packets.StreamPacket;
import seng302.utilities.StreamParser; import seng302.utilities.StreamParser;
@@ -24,6 +25,11 @@ public class SendChatSteps {
@Given("^There are two games running$") @Given("^There are two games running$")
public void the_are_two_games_running() throws Throwable { public void the_are_two_games_running() throws Throwable {
mst = new MainServerThread(); mst = new MainServerThread();
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
host = new ClientToServerThread("localhost", 4942); host = new ClientToServerThread("localhost", 4942);
try { try {
Thread.sleep(100); Thread.sleep(100);
+18 -17
View File
@@ -23,31 +23,32 @@ public class ToggleSailSteps {
@Given("^The game is running$") @Given("^The game is running$")
public void the_game_is_running() throws Throwable { public void the_game_is_running() throws Throwable {
// mst = new MainServerThread(); mst = new MainServerThread();
// client = new ClientToServerThread("localhost", 4942); client = new ClientToServerThread("localhost", 4942);
// GameState.setCurrentStage(GameStages.RACING); GameState.setCurrentStage(GameStages.RACING);
// Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other
// ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0);
// Assert.assertFalse(yacht.getSailIn()); Assert.assertFalse(yacht.getSailIn());
} }
@When("^the user has pressed \"([^\"]*)\"$") @When("^the user has pressed \"([^\"]*)\"$")
public void the_user_has_pressed(String arg1) throws Throwable { public void the_user_has_pressed(String arg1) throws Throwable {
// startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
// if (arg1 == "shift") { if (arg1 == "shift") {
// client.sendBoatAction(BoatAction.SAILS_IN); client.sendBoatAction(BoatAction.SAILS_IN);
// } }
} }
@Then("^the sails are \"([^\"]*)\"$") @Then("^the sails are \"([^\"]*)\"$")
public void the_sails_are(String arg1) throws Throwable { public void the_sails_are(String arg1) throws Throwable {
// Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other
// ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0);
// if (arg1 == "in") { if (arg1 == "in") {
// Assert.assertTrue(yacht.getSailIn()); Assert.assertTrue(yacht.getSailIn());
// } else { } else {
// Assert.assertFalse(yacht.getSailIn()); Assert.assertFalse(yacht.getSailIn());
// } }
mst.terminate();
} }
} }