From ef13de8d006bdcc418dba3a156b709240344874a Mon Sep 17 00:00:00 2001 From: LeStegii Date: Tue, 27 Feb 2024 09:57:41 +0100 Subject: [PATCH] feat(ludo): Add titles --- ludo/src/main/java/de/uniks/ludo/App.java | 3 +++ .../java/de/uniks/ludo/controller/GameOverController.java | 8 ++++++++ .../java/de/uniks/ludo/controller/IngameController.java | 4 ++++ .../java/de/uniks/ludo/controller/SetupController.java | 8 ++++++++ .../main/resources/de/uniks/ludo/lang/lang_de.properties | 3 +++ .../main/resources/de/uniks/ludo/lang/lang_en.properties | 3 +++ 6 files changed, 29 insertions(+) diff --git a/ludo/src/main/java/de/uniks/ludo/App.java b/ludo/src/main/java/de/uniks/ludo/App.java index 0909b28c..884910f0 100644 --- a/ludo/src/main/java/de/uniks/ludo/App.java +++ b/ludo/src/main/java/de/uniks/ludo/App.java @@ -43,6 +43,9 @@ public void start(Stage primaryStage) { } }); + // Setting the title pattern of the application. The %s will be replaced with the title of the view + setTitlePattern("Ludo - %s"); + // Setting the resource path to the resources folder of the project (required for reloading in dev) // If the resource path is not set, the framework will use the default resource path (src/main/resources) setResourcesPath(Path.of("ludo/src/main/resources/")); diff --git a/ludo/src/main/java/de/uniks/ludo/controller/GameOverController.java b/ludo/src/main/java/de/uniks/ludo/controller/GameOverController.java index 791b8fb7..514f37e6 100644 --- a/ludo/src/main/java/de/uniks/ludo/controller/GameOverController.java +++ b/ludo/src/main/java/de/uniks/ludo/controller/GameOverController.java @@ -3,17 +3,25 @@ import javafx.fxml.FXML; import javafx.scene.control.Label; import org.fulib.fx.annotation.controller.Controller; +import org.fulib.fx.annotation.controller.Resource; +import org.fulib.fx.annotation.controller.Title; import org.fulib.fx.annotation.event.onRender; import org.fulib.fx.annotation.param.Param; import javax.inject.Inject; +import java.util.ResourceBundle; +@Title("%gameover.title") @Controller public class GameOverController { @FXML private Label playerWonLabel; + @Resource + @Inject + ResourceBundle bundle; + @Inject public GameOverController() { } diff --git a/ludo/src/main/java/de/uniks/ludo/controller/IngameController.java b/ludo/src/main/java/de/uniks/ludo/controller/IngameController.java index 130fad89..a9bca38b 100644 --- a/ludo/src/main/java/de/uniks/ludo/controller/IngameController.java +++ b/ludo/src/main/java/de/uniks/ludo/controller/IngameController.java @@ -20,7 +20,9 @@ import javafx.scene.shape.Circle; import javafx.scene.shape.StrokeType; import org.fulib.fx.annotation.controller.Controller; +import org.fulib.fx.annotation.controller.Resource; import org.fulib.fx.annotation.controller.SubComponent; +import org.fulib.fx.annotation.controller.Title; import org.fulib.fx.annotation.event.onDestroy; import org.fulib.fx.annotation.event.onInit; import org.fulib.fx.annotation.event.onRender; @@ -30,6 +32,7 @@ import javax.inject.Inject; import java.util.*; +@Title("%ingame.title") @Controller public class IngameController { @@ -42,6 +45,7 @@ public class IngameController { GameService gameService; @Inject Subscriber subscriber; + @Resource @Inject ResourceBundle bundle; @Inject diff --git a/ludo/src/main/java/de/uniks/ludo/controller/SetupController.java b/ludo/src/main/java/de/uniks/ludo/controller/SetupController.java index 0db513f1..9a23c75c 100644 --- a/ludo/src/main/java/de/uniks/ludo/controller/SetupController.java +++ b/ludo/src/main/java/de/uniks/ludo/controller/SetupController.java @@ -4,16 +4,24 @@ import javafx.fxml.FXML; import javafx.scene.control.Slider; import org.fulib.fx.annotation.controller.Controller; +import org.fulib.fx.annotation.controller.Resource; +import org.fulib.fx.annotation.controller.Title; import javax.inject.Inject; import java.util.Map; +import java.util.ResourceBundle; +@Title("%setup.title") @Controller public class SetupController { @FXML private Slider playerAmountSlider; + @Resource + @Inject + ResourceBundle bundle; + @Inject App app; diff --git a/ludo/src/main/resources/de/uniks/ludo/lang/lang_de.properties b/ludo/src/main/resources/de/uniks/ludo/lang/lang_de.properties index c652469e..43eecc03 100644 --- a/ludo/src/main/resources/de/uniks/ludo/lang/lang_de.properties +++ b/ludo/src/main/resources/de/uniks/ludo/lang/lang_de.properties @@ -1,3 +1,6 @@ ingame.current.player=Momentaner Spieler: %s +ingame.title=Mensch ärgere dich nicht setup.select.player.amount=Spieleranzahl setup.start.game=Spiel starten +setup.title=Spiel einrichten +gameover.title=Spiel vorbei \ No newline at end of file diff --git a/ludo/src/main/resources/de/uniks/ludo/lang/lang_en.properties b/ludo/src/main/resources/de/uniks/ludo/lang/lang_en.properties index eb732162..e48349f6 100644 --- a/ludo/src/main/resources/de/uniks/ludo/lang/lang_en.properties +++ b/ludo/src/main/resources/de/uniks/ludo/lang/lang_en.properties @@ -1,3 +1,6 @@ ingame.current.player=Current player: %s +ingame.title=Ludo setup.select.player.amount=Player amount setup.start.game=Start game +setup.title=Set up the game +gameover.title=Game over!