This commit is contained in:
hba56
2017-07-25 14:14:49 +12:00
7 changed files with 145 additions and 3 deletions
@@ -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 ;)");
}
}
@@ -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<WindowEvent>() {
@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");