hba56 9 years ago
commit 913946265d

@ -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");

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.TitleController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Pane prefHeight="20.0" prefWidth="20.0" style="-fx-background-color: #0061ff;" GridPane.columnSpan="4" GridPane.rowIndex="4" GridPane.rowSpan="2">
<children>
<Text fx:id="txtTitle" layoutX="167.0" layoutY="136.0" strokeType="OUTSIDE" strokeWidth="0.0" text="The Boat Game!">
<font>
<Font name="Comic Sans MS" size="64.0" />
</font>
</Text>
<Text layoutX="636.0" layoutY="78.0" strokeType="OUTSIDE" strokeWidth="0.0" text="TM">
<font>
<Font name="Comic Sans MS" size="12.0" />
</font>
</Text>
</children>
</Pane>
<Pane prefHeight="20.0" prefWidth="20.0" style="-fx-background-color: #6be6ff;" GridPane.columnSpan="4" GridPane.rowSpan="4">
<children>
<ImageView fx:id="imgBoat" fitHeight="404.0" fitWidth="296.0" layoutX="268.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/boat.png" />
</image>
</ImageView>
<ImageView fx:id="imgCloud1" fitHeight="291.0" fitWidth="307.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/cloud.png" />
</image>
</ImageView>
<ImageView fx:id="imgWhale" fitHeight="113.0" fitWidth="98.0" layoutX="68.0" layoutY="257.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/whale.png" />
</image>
</ImageView>
<ImageView fx:id="imgCloud2" fitHeight="291.0" fitWidth="307.0" layoutX="501.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/cloud.png" />
</image>
</ImageView>
<ImageView fx:id="imgSun" fitHeight="154.0" fitWidth="145.0" layoutX="701.0" layoutY="-39.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/sun.png" />
</image>
</ImageView>
<Button fx:id="btnJoin" layoutX="78.0" layoutY="149.0" mnemonicParsing="false" onAction="#joinAGame" prefHeight="31.0" prefWidth="130.0" text="Join a Game">
<font>
<Font name="Comic Sans MS Bold" size="16.0" />
</font>
</Button>
<Button layoutX="578.0" layoutY="150.0" mnemonicParsing="false" onAction="#hostAGame" prefHeight="31.0" prefWidth="130.0" text="Host a Game">
<font>
<Font name="Comic Sans MS Bold" size="16.0" />
</font>
</Button>
</children>
</Pane>
</children>
</GridPane>
Loading…
Cancel
Save