Users can select between 1 minute, 5 minute, or non scaled races
- Current implementation is a bit messy I think, with 3 different start race methods for the three options - Considering letting users choose from a dropdown, so that the chosen value can be easily found from a single method for starting the race #implement #story[16]
This commit is contained in:
@@ -22,6 +22,7 @@ import seng302.Model.ResizableRaceCanvas;
|
||||
import seng302.Model.*;
|
||||
import seng302.RaceMap;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -86,10 +87,23 @@ public class RaceController extends Controller{
|
||||
|
||||
|
||||
@FXML
|
||||
public void startRace() {
|
||||
public void startRace1Min() {
|
||||
startRace(15);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void startRace5Min() {
|
||||
startRace(3);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void startRaceNoScaling() {
|
||||
startRace(1);
|
||||
}
|
||||
|
||||
|
||||
private void startRace(int scaleFactor) {
|
||||
BoatInRace[] boats = generateAC35Competitors();
|
||||
|
||||
raceMap = new ResizableRaceCanvas();
|
||||
raceMap.widthProperty().bind(canvasBase.widthProperty());
|
||||
raceMap.heightProperty().bind(canvasBase.heightProperty());
|
||||
@@ -100,7 +114,7 @@ public class RaceController extends Controller{
|
||||
startScreen.setVisible(false);
|
||||
|
||||
ArrayList<Leg> legs = generateBermudaCourseLegs();
|
||||
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, this);
|
||||
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, this, scaleFactor);
|
||||
raceMap.setVisible(true);
|
||||
(new Thread(race)).start();
|
||||
}
|
||||
|
||||
@@ -22,8 +22,9 @@ public class ConstantVelocityRace extends Race {
|
||||
* @see Leg
|
||||
*/
|
||||
|
||||
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks, RaceController controller) {
|
||||
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks, RaceController controller, int scaleFactor) {
|
||||
super(startingBoats, marks, controller);
|
||||
setScaleFactor(scaleFactor);
|
||||
}
|
||||
|
||||
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks) {
|
||||
|
||||
@@ -15,17 +15,26 @@
|
||||
<Label fx:id="timer" layoutX="45.0" layoutY="146.0" text="0:0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" />
|
||||
<GridPane fx:id="startScreen" prefHeight="600.0" prefWidth="780.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="189.0" minWidth="10.0" prefWidth="93.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="372.0" minWidth="10.0" prefWidth="184.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="394.0" minWidth="10.0" prefWidth="192.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="416.0" minWidth="10.0" prefWidth="273.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="416.0" minWidth="10.0" prefWidth="57.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="241.0" minHeight="10.0" prefHeight="215.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="213.0" minHeight="10.0" prefHeight="213.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="241.0" minHeight="10.0" prefHeight="79.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="383.0" minHeight="10.0" prefHeight="178.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="194.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="149.0" minHeight="10.0" prefHeight="149.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Select Your Race Duration" />
|
||||
<Button mnemonicParsing="false" onAction="#startRace" text="1 min" GridPane.rowIndex="1" />
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Select Your Race Duration:" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||
<font>
|
||||
<Font size="23.0" />
|
||||
</font></Text>
|
||||
<Button mnemonicParsing="false" onAction="#startRace1Min" text="1 minutes" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<Button mnemonicParsing="false" onAction="#startRaceNoScaling" text="Real time" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
||||
<Button mnemonicParsing="false" onAction="#startRace5Min" text="5 minutes" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||
</children>
|
||||
</GridPane>
|
||||
</children></AnchorPane>
|
||||
|
||||
Reference in New Issue
Block a user