diff --git a/racevisionGame/src/main/java/visualiser/Controllers/TitleController.java b/racevisionGame/src/main/java/visualiser/Controllers/TitleController.java new file mode 100644 index 00000000..0fd1b545 --- /dev/null +++ b/racevisionGame/src/main/java/visualiser/Controllers/TitleController.java @@ -0,0 +1,53 @@ +package visualiser.Controllers; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.image.Image; +import javafx.stage.Stage; + +import java.io.IOException; + +/** + * Controller for the opening title window. + * Has two initial buttons for a user to decide how to play their game. Has a + * burger-boat and comic sans styling to allure and entice users into playing + * the game. + */ +public class TitleController { + @FXML Button btnJoin; + + /** + * Method called when the 'host a game' button is pressed. + * Opens the next window allowing a user to host their own game. + * Currently used to run the RaceVision mock. + * @throws IOException if main has problems + */ + public void hostAGame() throws IOException { + // load up the main window + Stage stage = new Stage(); + FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml")); + Parent root = loader.load(); + Scene scene = new Scene(root, 1200, 800); + scene.getStylesheets().add("/css/nightMode.css"); + + stage.setScene(scene); + stage.setTitle("RaceVision - Team 7"); + stage.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("images/SailIcon.png"))); + stage.show(); + + // close title screen + Stage stageOld = (Stage)btnJoin.getScene().getWindow(); + stageOld.close(); + } + + /** + * To be implemented at a later date- will open the next scene displaying + * games a player can join. Place holder method for now! + */ + public void joinAGame() { + System.out.println("You can't join a game yet ;)"); + } +} diff --git a/racevisionGame/src/main/java/visualiser/app/App.java b/racevisionGame/src/main/java/visualiser/app/App.java index 801cbe06..1bc0a222 100644 --- a/racevisionGame/src/main/java/visualiser/app/App.java +++ b/racevisionGame/src/main/java/visualiser/app/App.java @@ -21,6 +21,11 @@ public class App extends Application { launch(args); } + /** + * Method that displays the visualiser, starting with the title screen. + * @param stage the stage to be displayed + * @throws Exception if something wrong with title screen + */ public void start(Stage stage) throws Exception { stage.setOnCloseRequest(new EventHandler() { @Override @@ -29,10 +34,11 @@ public class App extends Application { System.exit(0); } }); - FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml")); + FXMLLoader loader = new FXMLLoader(getClass().getResource + ("/visualiser/scenes/titleScreen.fxml")); Parent root = loader.load(); - Scene scene = new Scene(root, 1200, 800); - scene.getStylesheets().add("/css/nightMode.css"); + stage.setResizable(false); + Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("RaceVision - Team 7"); diff --git a/racevisionGame/src/main/resources/visualiser/images/boat.png b/racevisionGame/src/main/resources/visualiser/images/boat.png new file mode 100644 index 00000000..90de3fc8 Binary files /dev/null and b/racevisionGame/src/main/resources/visualiser/images/boat.png differ diff --git a/racevisionGame/src/main/resources/visualiser/images/cloud.png b/racevisionGame/src/main/resources/visualiser/images/cloud.png new file mode 100644 index 00000000..6269d545 Binary files /dev/null and b/racevisionGame/src/main/resources/visualiser/images/cloud.png differ diff --git a/racevisionGame/src/main/resources/visualiser/images/sun.png b/racevisionGame/src/main/resources/visualiser/images/sun.png new file mode 100644 index 00000000..a33900a6 Binary files /dev/null and b/racevisionGame/src/main/resources/visualiser/images/sun.png differ diff --git a/racevisionGame/src/main/resources/visualiser/images/whale.png b/racevisionGame/src/main/resources/visualiser/images/whale.png new file mode 100644 index 00000000..b001ccd4 Binary files /dev/null and b/racevisionGame/src/main/resources/visualiser/images/whale.png differ diff --git a/racevisionGame/src/main/resources/visualiser/scenes/titleScreen.fxml b/racevisionGame/src/main/resources/visualiser/scenes/titleScreen.fxml new file mode 100644 index 00000000..86be67ef --- /dev/null +++ b/racevisionGame/src/main/resources/visualiser/scenes/titleScreen.fxml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +