mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
credits toegevoegd
This commit is contained in:
@@ -1,6 +1,16 @@
|
|||||||
package org.toop.app.menu;
|
package org.toop.app.menu;
|
||||||
|
|
||||||
|
import javafx.animation.Interpolator;
|
||||||
|
import javafx.animation.PauseTransition;
|
||||||
|
import javafx.animation.TranslateTransition;
|
||||||
import javafx.application.Platform;
|
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.ResourceManager;
|
||||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||||
import org.toop.framework.eventbus.EventFlow;
|
import org.toop.framework.eventbus.EventFlow;
|
||||||
@@ -9,10 +19,46 @@ import org.toop.local.LocalizationEvents;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public final class CreditsMenu extends Menu {
|
public final class CreditsMenu extends Menu { ;
|
||||||
private Locale currentLocale = AppContext.getLocale();
|
private Locale currentLocale = AppContext.getLocale();
|
||||||
private LocalizationAsset loc = ResourceManager.get("localization_en_us.properties");
|
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() {
|
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 {
|
try {
|
||||||
new EventFlow()
|
new EventFlow()
|
||||||
.listen(this::handleChangeLanguage);
|
.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.");
|
System.out.println("Something went wrong while trying to change the language.");
|
||||||
throw e;
|
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) {
|
private void handleChangeLanguage(LocalizationEvents.LanguageHasChanged event) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
currentLocale = AppContext.getLocale();
|
currentLocale = AppContext.getLocale();
|
||||||
//credits.setText(loc.getString("credits",currentLocale));
|
//credits.setText(loc.getString("credits",currentLocale));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
18
app/src/main/resources/assets/style/credits.css
Normal file
18
app/src/main/resources/assets/style/credits.css
Normal file
@@ -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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user