diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java new file mode 100644 index 0000000000000000000000000000000000000000..256f30686e6616e7ee84022b52351ba018ff57b0 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/IntroController.java @@ -0,0 +1,64 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.scene.media.Media; +import javafx.scene.media.MediaPlayer; +import javafx.scene.media.MediaView; +import javafx.stage.Stage; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.Objects; +import java.util.ResourceBundle; + +public class IntroController implements Initializable { + + @FXML + public MediaView introMediaView; + @FXML + public BorderPane introParent; + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + introParent.setStyle("-fx-background-color: black;"); + File file = new File("src/main/resources/textures/videos/monke.mp4"); + Media media = new Media(file.toURI().toString()); + MediaPlayer mediaPlayer = new MediaPlayer(media); + introMediaView.setMediaPlayer(mediaPlayer); + +// resizing once the scenes has been loaded to get width and height property + mediaPlayer.setOnReady(() -> { + introMediaView.fitWidthProperty().bind(introParent.getScene().widthProperty()); + introMediaView.fitHeightProperty().bind(introParent.getScene().heightProperty()); + }); + + mediaPlayer.setVolume(1); + mediaPlayer.setAutoPlay(true); + +// TODO: make any button pressed work + introParent.setOnMouseClicked((mouseEvent) -> { + mediaPlayer.dispose(); + videoEnd(); + }); + mediaPlayer.setOnEndOfMedia(this::videoEnd); + } + + // TODO: maybe look into using SceneLoader class + private void videoEnd() { + try { + Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml"))); + Stage stage = (Stage) introParent.getScene().getWindow(); + Scene scene = new Scene(root); + scene.getStylesheets().add(Objects.requireNonNull(this.getClass().getResource("/styles/style.css")).toExternalForm()); + stage.setScene(scene); + } catch (IOException e) { + throw new RuntimeException(); + } + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java index d634b051c6aa5c5b9606e6cc6401db3218a8c98e..afafe0e6ad2fadb9bcea2213f6e5414f3889d3bc 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/MenuBorderPaneController.java @@ -12,6 +12,7 @@ import java.net.URL; import java.util.ResourceBundle; public class MenuBorderPaneController implements Initializable { +// TODO: change FXML variables to private. Don't know why it's not working when they're private @FXML public BorderPane parent; @FXML diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java b/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java index d8d3fe7116bb17fb8754dcb174eccffae16eb80c..29ff931d24602d9c611410d5e51eeb99ac4b7880 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Main/Main.java @@ -2,9 +2,11 @@ package de.hdm_stuttgart.battlearena.Main; import javafx.application.Application; import javafx.fxml.FXMLLoader; +import javafx.geometry.Rectangle2D; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.text.Font; +import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.StageStyle; @@ -16,6 +18,7 @@ import java.util.Objects; public class Main extends Application { private static final Logger log = LogManager.getLogger(Main.class); + Rectangle2D screen = Screen.getPrimary().getVisualBounds(); public static void main(String[] args) { launch(args); @@ -26,16 +29,17 @@ public class Main extends Application { // loading font in start() because CSS can't handle whitespace in folder names Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 20); - Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MenuBorderPane.fxml"))); + Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/Intro.fxml"))); Scene scene = new Scene(root); - scene.getStylesheets().add(Objects.requireNonNull(this.getClass().getResource("/styles/style.css")).toExternalForm()); stage.setTitle("BattleArena"); stage.setScene(scene); stage.minHeightProperty().setValue(400); stage.minWidthProperty().setValue(600); stage.setMaximized(true); + stage.setWidth(screen.getWidth()); + stage.setHeight(screen.getHeight()); stage.initStyle(StageStyle.UNDECORATED); stage.show(); diff --git a/src/main/resources/fxml/Intro.fxml b/src/main/resources/fxml/Intro.fxml new file mode 100644 index 0000000000000000000000000000000000000000..19c2296ff80ed40c2a26abc7c9799d31d1178559 --- /dev/null +++ b/src/main/resources/fxml/Intro.fxml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.media.MediaView?> + + +<BorderPane fx:id="introParent" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.IntroController"> + <center> + <MediaView fx:id="introMediaView" fitHeight="200.0" fitWidth="200.0" BorderPane.alignment="CENTER" /> + </center> +</BorderPane> diff --git a/src/main/resources/fxml/MenuBorderPane.fxml b/src/main/resources/fxml/MenuBorderPane.fxml index 3e3e83810c000e6332babc2de813c108c4a50d4d..164bd6c9283570c62e029f9f80790dd7df2cb4fe 100644 --- a/src/main/resources/fxml/MenuBorderPane.fxml +++ b/src/main/resources/fxml/MenuBorderPane.fxml @@ -4,17 +4,15 @@ <?import javafx.scene.image.Image?> <?import javafx.scene.image.ImageView?> <?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.media.MediaView?> -<BorderPane fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" - prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" - fx:controller="de.hdm_stuttgart.battlearena.Controller.MenuBorderPaneController"> +<BorderPane id="mainMenu" fx:id="parent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MenuBorderPaneController"> <right> - <Button fx:id="btnRight" mnemonicParsing="false" onAction="#easterEgg" prefWidth="111.0" - BorderPane.alignment="BOTTOM_CENTER"> + <Button fx:id="btnRight" mnemonicParsing="false" onAction="#easterEgg" prefWidth="111.0" BorderPane.alignment="BOTTOM_CENTER"> <graphic> - <ImageView fx:id="imgRight" fitHeight="500.0" fitWidth="500.0" pickOnBounds="true" preserveRatio="true"> + <ImageView fx:id="imgRight" fitHeight="246.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true"> <image> - <Image url="@../textures/images/gear_with_shadow.png"/> + <Image url="@../textures/images/gear_with_shadow.png" /> </image> </ImageView> </graphic> @@ -23,12 +21,15 @@ <left> <Button mnemonicParsing="false" BorderPane.alignment="BOTTOM_CENTER"> <graphic> - <ImageView fx:id="imgLeft" fitHeight="500.0" fitWidth="500.0" pickOnBounds="true" preserveRatio="true"> + <ImageView fx:id="imgLeft" fitHeight="328.0" fitWidth="163.0" pickOnBounds="true" preserveRatio="true"> <image> - <Image url="@../textures/images/dont_delete_or_ui_will_break.png"/> + <Image url="@../textures/images/dont_delete_or_ui_will_break.png" /> </image> </ImageView> </graphic> </Button> </left> + <center> + <MediaView fx:id="introMediaView" fitHeight="200.0" fitWidth="200.0" BorderPane.alignment="CENTER" /> + </center> </BorderPane> diff --git a/src/main/resources/styles/style.css b/src/main/resources/styles/style.css index 8c729eee1112a02a16781874bf10d5da3247562e..6b84fc002425a9939bd87a2d5f17ad09f3e1ec81 100644 --- a/src/main/resources/styles/style.css +++ b/src/main/resources/styles/style.css @@ -5,12 +5,14 @@ .root { -fx-font-family: "Starship Shadow"; - -fx-background-color: -fx-dark-brown; -fx-text-fill: -fx-brown; -fx-font-size: 50; + -fx-background-color: black; +} + +#mainMenu{ -fx-background-image: url("../textures/images/background.png"); -fx-background-size: cover; - -fx-effect: dropshadow(three-pass-box, black, 30, 0.5, 0, 0); } #gameTitle { diff --git a/src/main/resources/textures/videos/monke.mp4 b/src/main/resources/textures/videos/monke.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c6d5f3c2e7f390276d22b26e46f462bb1e281d98 Binary files /dev/null and b/src/main/resources/textures/videos/monke.mp4 differ diff --git a/src/main/resources/textures/videos/pepe.mp4 b/src/main/resources/textures/videos/pepe.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..8879485f00eac8380ad92344496ecae392562fd2 Binary files /dev/null and b/src/main/resources/textures/videos/pepe.mp4 differ