diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/SceneLoader.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SceneLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..0d5a04ef5789505821f173c05997a43313b8b33d --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/SceneLoader.java @@ -0,0 +1,35 @@ +package de.hdm_stuttgart.battlearena.Controller; + +import javafx.fxml.FXMLLoader; +import javafx.scene.layout.Pane; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.net.URL; + +public class SceneLoader { + + private static final Logger log = LogManager.getLogger(SceneLoader.class); + + private Pane view; + + //helper method for loading fxml files in the scene + public Pane loadScene(String fileName) { + try { + URL filePath = getClass().getResource("/fxml/" + fileName + ".fxml"); + + if (filePath == null) { + throw new java.io.FileNotFoundException(fileName + " not found"); + } + + new FXMLLoader(); + view = FXMLLoader.load(filePath); + + } catch (Exception e) { + log.debug("Scene " + fileName + " not found"); + } + return view; + } + +} \ No newline at end of file diff --git a/src/main/resources/fxml/GameScene.fxml b/src/main/resources/fxml/GameScene.fxml new file mode 100644 index 0000000000000000000000000000000000000000..b8a97acf0ac20383de9eb2086ae9b0c3e6e370a3 --- /dev/null +++ b/src/main/resources/fxml/GameScene.fxml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.layout.AnchorPane?> + + +<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController"> + +</AnchorPane>