Finished Arrow, Title and StartController scene splitting
- scenes do not load in at the same time - scenes do not rely upon previous abstract controller class - scenes are not a part of previous main controller class - unecessary functions and code removed #story[1261]
This commit is contained in:
@@ -26,7 +26,6 @@ import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.stage.WindowEvent;
|
||||
import javafx.util.Duration;
|
||||
import visualiser.Controllers.MainController;
|
||||
import visualiser.gameController.Keys.KeyFactory;
|
||||
|
||||
public class App extends Application {
|
||||
@@ -42,7 +41,6 @@ public class App extends Application {
|
||||
|
||||
/**
|
||||
* Entry point for running the programme
|
||||
*
|
||||
* @param args for starting the programme
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
@@ -79,10 +77,10 @@ public class App extends Application {
|
||||
|
||||
/**
|
||||
* Method that sets up and displays the splash screen
|
||||
* @param initStage the inital stage
|
||||
* @param stage the inital stage
|
||||
* @throws Exception if something wrong with title screen.
|
||||
*/
|
||||
public void start(Stage initStage) throws Exception {
|
||||
public void start(Stage stage) throws Exception {
|
||||
final Task<ObservableList<String>> boatTask = new Task<ObservableList<String>>() {
|
||||
@Override
|
||||
protected ObservableList<String> call() throws InterruptedException {
|
||||
@@ -111,11 +109,11 @@ public class App extends Application {
|
||||
};
|
||||
|
||||
showSplash(
|
||||
initStage,
|
||||
stage,
|
||||
boatTask,
|
||||
() -> {
|
||||
try {
|
||||
showMainStage(new Stage());
|
||||
loadTitleScreen();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -126,45 +124,26 @@ public class App extends Application {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get main stage
|
||||
* @return main stage
|
||||
* Get the main stage to be shared for all regular game play scenes.
|
||||
* @return shared stage
|
||||
*/
|
||||
public static Stage getStage() {
|
||||
return App.stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set main stage
|
||||
* @param stage stage to set main stage
|
||||
*/
|
||||
public static void setStage(Stage stage) {
|
||||
App.stage = stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the main stage after the splash screen
|
||||
* @param stage main stage for application
|
||||
* @throws Exception Throws an exception on error
|
||||
*/
|
||||
public void showMainStage(Stage stage) throws Exception {
|
||||
App.stage = stage;
|
||||
App.app = this;
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml"));
|
||||
public void loadTitleScreen() throws Exception {
|
||||
stage = new Stage();
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource
|
||||
("/visualiser/scenes/titleScreen.fxml"));
|
||||
Parent root = loader.load();
|
||||
stage.setResizable(false);
|
||||
MainController mc = (MainController) loader.getController();
|
||||
mc.enterTitle();
|
||||
Scene scene = new Scene(root);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("RaceVision - Team 7");
|
||||
stage.setTitle("The Boat Game - Burgers & Boats");
|
||||
stage.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("images/SailIcon.png")));
|
||||
mc.startCss();
|
||||
setStage(stage);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||
@Override
|
||||
public void handle(WindowEvent event) {
|
||||
@Override public void handle(WindowEvent event) {
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user