Added a pretty title screen to the application.
- Created a GUI title screen - Drew images to be display on the title - Created controller for the title - Changed visualiser main to initially display title - Added functionality for host button #story[1087]
This commit is contained in:
@@ -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 ;)");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user