diff --git a/dedicatedServer/src/main/java/app/App.java b/dedicatedServer/src/main/java/app/App.java index 34ee2c5b..3b36c43e 100644 --- a/dedicatedServer/src/main/java/app/App.java +++ b/dedicatedServer/src/main/java/app/App.java @@ -21,7 +21,7 @@ public class App extends Application { public void start(Stage primaryStage) { try { //TODO should read a configuration file to configure server? - Event raceEvent = new Event(false); + Event raceEvent = new Event(false, 0); } catch (Exception e) { diff --git a/racevisionGame/src/main/java/mock/app/Event.java b/racevisionGame/src/main/java/mock/app/Event.java index 703686bc..98476ac1 100644 --- a/racevisionGame/src/main/java/mock/app/Event.java +++ b/racevisionGame/src/main/java/mock/app/Event.java @@ -18,6 +18,7 @@ import shared.exceptions.InvalidRegattaDataException; import shared.exceptions.XMLReaderException; import shared.model.Bearing; import shared.model.Constants; +import shared.xml.XMLUtilities; import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; @@ -79,9 +80,24 @@ public class Event { * @param singlePlayer Whether or not to create a single player event. * @throws EventConstructionException Thrown if we cannot create an Event for any reason. */ - public Event(boolean singlePlayer) throws EventConstructionException { + public Event(boolean singlePlayer, int mapIndex) throws EventConstructionException { + +// System.out.println(XMLUtilities.validateXML(this.getClass().getClassLoader().getResource("mock/mockXML/iMapLayout.xml").toString() +// , this.getClass().getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd"))); + + String raceXMLFile; + switch (mapIndex){ + case 0:raceXMLFile = "mock/mockXML/raceSixPlayers.xml"; + break; + case 1:raceXMLFile = "mock/mockXML/oMapLayout.xml"; + break; + case 2: raceXMLFile = "mock/mockXML/iMapLayout.xml"; + break; + case 3: raceXMLFile = "mock/mockXML/mMapLayout.xml"; + break; + default: raceXMLFile = "mock/mockXML/raceSixPlayers.xml"; - String raceXMLFile = "mock/mockXML/raceTest.xml"; + } String boatsXMLFile = "mock/mockXML/boatTest.xml"; String regattaXMLFile = "mock/mockXML/regattaTest.xml"; diff --git a/racevisionGame/src/main/java/mock/model/SourceIdAllocator.java b/racevisionGame/src/main/java/mock/model/SourceIdAllocator.java index 17a7e85f..f590d9b7 100644 --- a/racevisionGame/src/main/java/mock/model/SourceIdAllocator.java +++ b/racevisionGame/src/main/java/mock/model/SourceIdAllocator.java @@ -42,6 +42,7 @@ public class SourceIdAllocator { } List allocatedIDs = mockRace.getRaceDataSource().getParticipants(); + List allIDs = new ArrayList<>(mockRace.getBoatDataSource().getBoats().keySet()); //Get list of unallocated ids. diff --git a/racevisionGame/src/main/java/shared/model/Constants.java b/racevisionGame/src/main/java/shared/model/Constants.java index 18a2aaed..7a5e2820 100644 --- a/racevisionGame/src/main/java/shared/model/Constants.java +++ b/racevisionGame/src/main/java/shared/model/Constants.java @@ -46,7 +46,7 @@ public class Constants { * The race preparatory time, in milliseconds. 1 minute. */ // public static final long RacePreparatoryTime = 60 * 1000; - public static final long RacePreparatoryTime = 3 * 1000; + public static final long RacePreparatoryTime = 1 * 60 * 1000; diff --git a/racevisionGame/src/main/java/visualiser/Controllers/HostController.java b/racevisionGame/src/main/java/visualiser/Controllers/HostController.java index 10bc9dbe..71bb7223 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/HostController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/HostController.java @@ -1,26 +1,28 @@ package visualiser.Controllers; -import com.interactivemesh.jfx.importer.stl.StlMeshImporter; -import javafx.animation.AnimationTimer; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; import javafx.fxml.FXML; -import javafx.scene.control.Alert; -import javafx.scene.control.ButtonType; -import javafx.scene.control.SplitPane; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.GridPane; -import javafx.scene.shape.MeshView; +import javafx.stage.Stage; import mock.app.Event; +import org.xml.sax.SAXException; import mock.exceptions.EventConstructionException; -import visualiser.layout.Subject3D; -import visualiser.layout.View3D; +import shared.exceptions.InvalidBoatDataException; +import shared.exceptions.InvalidRaceDataException; +import shared.exceptions.InvalidRegattaDataException; +import shared.exceptions.XMLReaderException; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.net.Socket; import java.net.URL; -import java.util.Optional; +import java.util.ArrayList; +import java.util.Arrays; import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; @@ -31,69 +33,48 @@ import java.util.logging.Logger; public class HostController extends Controller { -// @FXML -// TextField gameNameField; -// -// @FXML -// TextField hostNameField; - @FXML - private ImageView imageView; + TextField gameNameField; @FXML - AnchorPane hostWrapper; + TextField hostNameField; @FXML - AnchorPane imagePane; + AnchorPane hostWrapper; @FXML - SplitPane splitPane; + Button previousButton; @FXML - AnchorPane specPane; + Button nextButton; @FXML - GridPane playerContainer; + ImageView mapImage; private Event game; - private View3D view3D; - - @Override - public void initialize(URL location, ResourceBundle resources) { - ObservableList subjects = FXCollections.observableArrayList(); - - view3D = new View3D(); - view3D.setItems(subjects); - playerContainer.add(view3D, 0,0); + private ArrayList listOfMaps; + private int currentMapIndex = 0; - URL asset = HostController.class.getClassLoader().getResource("assets/V1.2 Complete Boat.stl"); - StlMeshImporter importer = new StlMeshImporter(); - importer.read(asset); - Subject3D subject = new Subject3D(new MeshView(importer.getImport())); - - subjects.add(subject); - - view3D.setDistance(50); - view3D.setYaw(45); - view3D.setPitch(20); - - AnimationTimer rotate = new AnimationTimer() { - @Override - public void handle(long now) { - subject.setHeading(subject.getHeading().getAngle() + 0.1); - } - }; - rotate.start(); + @Override + public void initialize(URL location, ResourceBundle resources){ + Image ac35Map = new Image(getClass().getClassLoader().getResourceAsStream("images/AC35_Racecourse_MAP.png")); + Image oMap = new Image(getClass().getClassLoader().getResourceAsStream("images/oMapLayout.png")); + Image iMap = new Image(getClass().getClassLoader().getResourceAsStream("images/iMapLayout.png")); + Image mMap = new Image(getClass().getClassLoader().getResourceAsStream("images/mMapLayout.png")); + + listOfMaps = new ArrayList(Arrays.asList(ac35Map, oMap, iMap, mMap)); + mapImage.setImage(listOfMaps.get(currentMapIndex)); } /** * Hosts a game + * @throws IOException if socket cannot be connected to */ - public void hostGamePressed() { + public void hostGamePressed() throws IOException{ try { - this.game = new Event(false); + this.game = new Event(false, currentMapIndex); connectSocket("localhost", 4942); } catch (EventConstructionException e) { Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e); @@ -126,34 +107,30 @@ public class HostController extends Controller { * Hosts a game. */ public void hostGame(){ - splitPane.setResizableWithParent(specPane, false); - splitPane.lookupAll(".split-pane-divider").stream().forEach(div -> div.setMouseTransparent(true)); - imageView.fitWidthProperty().bind(imagePane.widthProperty()); - imageView.fitHeightProperty().bind(imagePane.heightProperty()); + mapImage.fitWidthProperty().bind(((Stage) mapImage.getScene().getWindow()).widthProperty().multiply(0.6)); hostWrapper.setVisible(true); } - /** - * Menu button pressed. Prompt alert then return to menu - */ public void menuBtnPressed(){ - Alert alert = new Alert(Alert.AlertType.CONFIRMATION); - alert.setTitle("Quitting race"); - alert.setContentText("Do you wish to quit the race?"); - alert.setHeaderText("You are about to quit the race"); - Optional result = alert.showAndWait(); - if(result.get() == ButtonType.OK){ - hostWrapper.setVisible(false); - parent.enterTitle(); - } + hostWrapper.setVisible(false); + parent.enterTitle(); } - /** - * Start button pressed. Currently only prints out start - */ - public void startBtnPressed(){ - //System.out.println("Should start the race. This button is only visible for the host"); - hostGamePressed(); + public void nextImage(){ + increaseIndex(); + mapImage.setImage(listOfMaps.get(currentMapIndex)); + } + + public void previousImage(){ + decreaseIndex(); + mapImage.setImage(listOfMaps.get(currentMapIndex)); + } + private void increaseIndex(){ + currentMapIndex = (currentMapIndex + 1)%listOfMaps.size(); + } + + private void decreaseIndex(){ + currentMapIndex = ((((currentMapIndex - 1)%listOfMaps.size())+listOfMaps.size())%listOfMaps.size()); } } diff --git a/racevisionGame/src/main/resources/css/dayMode.css b/racevisionGame/src/main/resources/css/dayMode.css index aa14c68b..b62f8391 100644 --- a/racevisionGame/src/main/resources/css/dayMode.css +++ b/racevisionGame/src/main/resources/css/dayMode.css @@ -53,5 +53,39 @@ } #arrowImage { - -fx-image: url("/visualiser/images/arrow.png"); + -fx-graphic: url("/visualiser/images/arrow.png"); +} + +#nextButton { + -fx-background-image: url("/visualiser/images/ArrowRoundRight.png"); + -fx-background-size: 60px; + -fx-background-repeat: no-repeat; + -fx-background-position: center center; + -fx-focus-color: transparent; + -fx-background-color: transparent; +} +#nextButton:pressed { + -fx-background-image: url("/visualiser/images/ArrowRoundRightClicked.png"); + -fx-background-size: 60px; + -fx-background-repeat: no-repeat; + -fx-background-position: center center; + -fx-focus-color: transparent; + -fx-background-color: transparent; +} + +#previousButton { + -fx-background-image: url("/visualiser/images/ArrowRoundLeft.png"); + -fx-background-size: 60px; + -fx-background-repeat: no-repeat; + -fx-background-position: center center; + -fx-focus-color: transparent; + -fx-background-color: transparent; +} +#previousButton:pressed { + -fx-background-image: url("/visualiser/images/ArrowRoundLeftClicked.png"); + -fx-background-size: 60px; + -fx-background-repeat: no-repeat; + -fx-background-position: center center; + -fx-focus-color: transparent; + -fx-background-color: transparent; } diff --git a/racevisionGame/src/main/resources/css/nightMode.css b/racevisionGame/src/main/resources/css/nightMode.css index 7fe6a67b..deefa51a 100644 --- a/racevisionGame/src/main/resources/css/nightMode.css +++ b/racevisionGame/src/main/resources/css/nightMode.css @@ -57,3 +57,37 @@ #arrowImage { -fx-image: url("/visualiser/images/arrowLight.png"); } + +#nextButton { + -fx-background-image: url("/visualiser/images/ArrowRoundRight.png"); + -fx-background-size: 60px; + -fx-background-repeat: no-repeat; + -fx-background-position: center center; + -fx-focus-color: transparent; + -fx-background-color: transparent; +} +#nextButton:pressed { + -fx-background-image: url("/visualiser/images/ArrowRoundRightClicked.png"); + -fx-background-size: 60px; + -fx-background-repeat: no-repeat; + -fx-background-position: center center; + -fx-focus-color: transparent; + -fx-background-color: transparent; +} + +#previousButton { + -fx-background-image: url("/visualiser/images/ArrowRoundLeft.png"); + -fx-background-size: 60px; + -fx-background-repeat: no-repeat; + -fx-background-position: center center; + -fx-focus-color: transparent; + -fx-background-color: transparent; +} +#previousButton:pressed { + -fx-background-image: url("/visualiser/images/ArrowRoundLeftClicked.png"); + -fx-background-size: 60px; + -fx-background-repeat: no-repeat; + -fx-background-position: center center; + -fx-focus-color: transparent; + -fx-background-color: transparent; +} diff --git a/racevisionGame/src/main/resources/images/AC35_Racecourse_MAP.png b/racevisionGame/src/main/resources/images/AC35_Racecourse_MAP.png new file mode 100644 index 00000000..1b5e39ca Binary files /dev/null and b/racevisionGame/src/main/resources/images/AC35_Racecourse_MAP.png differ diff --git a/racevisionGame/src/main/resources/images/iMapLayout.png b/racevisionGame/src/main/resources/images/iMapLayout.png new file mode 100644 index 00000000..5932a60d Binary files /dev/null and b/racevisionGame/src/main/resources/images/iMapLayout.png differ diff --git a/racevisionGame/src/main/resources/images/mMapLayout.png b/racevisionGame/src/main/resources/images/mMapLayout.png new file mode 100644 index 00000000..fa0af51f Binary files /dev/null and b/racevisionGame/src/main/resources/images/mMapLayout.png differ diff --git a/racevisionGame/src/main/resources/images/oMapLayout.png b/racevisionGame/src/main/resources/images/oMapLayout.png new file mode 100644 index 00000000..ca520959 Binary files /dev/null and b/racevisionGame/src/main/resources/images/oMapLayout.png differ diff --git a/racevisionGame/src/main/resources/mock/mockXML/iMapLayout.xml b/racevisionGame/src/main/resources/mock/mockXML/iMapLayout.xml new file mode 100644 index 00000000..ca914b12 --- /dev/null +++ b/racevisionGame/src/main/resources/mock/mockXML/iMapLayout.xml @@ -0,0 +1,53 @@ + + + 5326 + FLEET + RACE_CREATION_TIME + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/racevisionGame/src/main/resources/mock/mockXML/mMapLayout.xml b/racevisionGame/src/main/resources/mock/mockXML/mMapLayout.xml new file mode 100644 index 00000000..ce715ba6 --- /dev/null +++ b/racevisionGame/src/main/resources/mock/mockXML/mMapLayout.xml @@ -0,0 +1,43 @@ + + + 5326 + FLEET + RACE_CREATION_TIME + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/racevisionGame/src/main/resources/mock/mockXML/oMapLayout.xml b/racevisionGame/src/main/resources/mock/mockXML/oMapLayout.xml new file mode 100644 index 00000000..5021bbba --- /dev/null +++ b/racevisionGame/src/main/resources/mock/mockXML/oMapLayout.xml @@ -0,0 +1,49 @@ + + + 5326 + FLEET + RACE_CREATION_TIME + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/racevisionGame/src/main/resources/mock/mockXML/raceTest.xml b/racevisionGame/src/main/resources/mock/mockXML/raceSixPlayers.xml similarity index 100% rename from racevisionGame/src/main/resources/mock/mockXML/raceTest.xml rename to racevisionGame/src/main/resources/mock/mockXML/raceSixPlayers.xml diff --git a/racevisionGame/src/main/resources/mock/mockXML/raceThreePlayers.xml b/racevisionGame/src/main/resources/mock/mockXML/raceThreePlayers.xml deleted file mode 100644 index e0b81837..00000000 --- a/racevisionGame/src/main/resources/mock/mockXML/raceThreePlayers.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - 5326 - FLEET - RACE_CREATION_TIME - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/racevisionGame/src/main/resources/visualiser/images/ArrowRoundLeft.png b/racevisionGame/src/main/resources/visualiser/images/ArrowRoundLeft.png new file mode 100644 index 00000000..ea4f4d64 Binary files /dev/null and b/racevisionGame/src/main/resources/visualiser/images/ArrowRoundLeft.png differ diff --git a/racevisionGame/src/main/resources/visualiser/images/ArrowRoundLeftClicked.png b/racevisionGame/src/main/resources/visualiser/images/ArrowRoundLeftClicked.png new file mode 100644 index 00000000..794ba57c Binary files /dev/null and b/racevisionGame/src/main/resources/visualiser/images/ArrowRoundLeftClicked.png differ diff --git a/racevisionGame/src/main/resources/visualiser/images/ArrowRoundRight.png b/racevisionGame/src/main/resources/visualiser/images/ArrowRoundRight.png new file mode 100644 index 00000000..751698cb Binary files /dev/null and b/racevisionGame/src/main/resources/visualiser/images/ArrowRoundRight.png differ diff --git a/racevisionGame/src/main/resources/visualiser/images/ArrowRoundRightClicked.png b/racevisionGame/src/main/resources/visualiser/images/ArrowRoundRightClicked.png new file mode 100644 index 00000000..10c1b53b Binary files /dev/null and b/racevisionGame/src/main/resources/visualiser/images/ArrowRoundRightClicked.png differ diff --git a/racevisionGame/src/main/resources/visualiser/scenes/hostgame.fxml b/racevisionGame/src/main/resources/visualiser/scenes/hostgame.fxml index ab14abaf..0767dd44 100644 --- a/racevisionGame/src/main/resources/visualiser/scenes/hostgame.fxml +++ b/racevisionGame/src/main/resources/visualiser/scenes/hostgame.fxml @@ -1,44 +1,61 @@ - + - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/racevisionGame/src/main/resources/visualiser/scenes/main.fxml b/racevisionGame/src/main/resources/visualiser/scenes/main.fxml index 7aff44c0..074a9b31 100644 --- a/racevisionGame/src/main/resources/visualiser/scenes/main.fxml +++ b/racevisionGame/src/main/resources/visualiser/scenes/main.fxml @@ -7,7 +7,7 @@ - +