diff --git a/app/src/main/java/org/toop/app/menu/CreditsMenu.java b/app/src/main/java/org/toop/app/menu/CreditsMenu.java index 4b1b81f..31c093a 100644 --- a/app/src/main/java/org/toop/app/menu/CreditsMenu.java +++ b/app/src/main/java/org/toop/app/menu/CreditsMenu.java @@ -1,6 +1,16 @@ package org.toop.app.menu; +import javafx.animation.Interpolator; +import javafx.animation.PauseTransition; +import javafx.animation.TranslateTransition; import javafx.application.Platform; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.layout.Region; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import javafx.util.Duration; +import org.toop.app.App; import org.toop.framework.asset.ResourceManager; import org.toop.framework.asset.resources.LocalizationAsset; import org.toop.framework.eventbus.EventFlow; @@ -9,10 +19,46 @@ import org.toop.local.LocalizationEvents; import java.util.Locale; -public final class CreditsMenu extends Menu { +public final class CreditsMenu extends Menu { ; private Locale currentLocale = AppContext.getLocale(); private LocalizationAsset loc = ResourceManager.get("localization_en_us.properties"); + + String[] credits = { + "Scrum Master: Stef", + "Product Owner: Omar", + "Merge Commander: Bas", + "Localization: Ticho", + "AI: Michiel", + "Developers: Michiel, Bas, Stef, Omar, Ticho", + "Moral Support: Wesley (voor 1 week)", + "OpenGL: Omar" + }; + + double scrollDuration = 20.0; + double lineHeight = 40.0; + public CreditsMenu() { + VBox creditsBox = new VBox(lineHeight / 2); + for (int i = credits.length - 1; i >= 0; i--) { + creditsBox.getChildren().add(createText(credits[i])); + creditsBox.setAlignment(Pos.CENTER); + } + + Button exit = new Button("<"); + exit.setStyle( + "-fx-background-color: transparent;" + + "-fx-text-fill: white;" + + "-fx-font-size: 72px;" + + "-fx-padding: 10 20 10 20;" + ); + exit.setOnAction(e -> App.pop()); + + final Region background = createBackground(); + StackPane.setAlignment(exit, Pos.TOP_LEFT); + pane = new StackPane(background, creditsBox, exit); + + Platform.runLater(() -> playCredits(creditsBox, 800)); + try { new EventFlow() .listen(this::handleChangeLanguage); @@ -21,13 +67,34 @@ public final class CreditsMenu extends Menu { System.out.println("Something went wrong while trying to change the language."); throw e; } + } + public void playCredits(VBox creditsBox, double sceneLength) { + double height = (credits.length * lineHeight); + double startY = -sceneLength; + double endY = height; + + creditsBox.setTranslateY(startY); + + TranslateTransition scrollCredits = new TranslateTransition(); + scrollCredits.setNode(creditsBox); + scrollCredits.setFromY(startY); + scrollCredits.setToY(endY / 2 - 200); + scrollCredits.setDuration(Duration.seconds(scrollDuration)); + scrollCredits.setInterpolator(Interpolator.LINEAR); + + scrollCredits.setOnFinished(e -> { + PauseTransition pauseCredits = new PauseTransition(Duration.seconds(5)); + pauseCredits.setOnFinished(a -> playCredits(creditsBox, sceneLength)); + pauseCredits.play(); + }); + + scrollCredits.play(); } private void handleChangeLanguage(LocalizationEvents.LanguageHasChanged event) { Platform.runLater(() -> { currentLocale = AppContext.getLocale(); //credits.setText(loc.getString("credits",currentLocale)); }); - } } \ No newline at end of file diff --git a/app/src/main/resources/assets/style/credits.css b/app/src/main/resources/assets/style/credits.css new file mode 100644 index 0000000..be920fe --- /dev/null +++ b/app/src/main/resources/assets/style/credits.css @@ -0,0 +1,18 @@ +.credit-text { + -fx-fill: #ffffff; + -fx-font-size: 24px; + -fx-font-family: "Arial"; + -fx-font-weight: bold; + -fx-effect: dropshadow(gaussian, rgba(0,0,0,0.7), 4, 0, 2, 2); +} + +.button.exit-button { + -fx-background-color: #3498db; + -fx-text-fill: white; + -fx-font-size: 72px; + -fx-padding: 10 20 10 20; + -fx-background-radius: 5; +} +.button.exit-button:hover { + -fx-background-color: #2980b9; +}