mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 02:44:50 +00:00
UI (#96)
* added localization options //todo add all the strings * broken push * merge to UI * broken push * Alpha rebase complete, added asset loader for UI branch * merge to UI * UI now uses assetmanager * added NL and EN for all strings currently in UI * fix small merge error * Removed no more needed files. * JDK25 * Removed files no longer in use * Removed need for manual typecast * Added ability to load in BundledResource for localization * Docs and easy font loading. Added interfaces for PreloadResource's --------- Co-authored-by: Ticho Hidding <tichohidding@gmail.com> Co-authored-by: ramollia <@>
This commit is contained in:
committed by
GitHub
parent
9b17a4ba7f
commit
258adbb627
@@ -8,6 +8,8 @@ import javafx.application.Application;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.toop.framework.asset.AssetManager;
|
||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -18,8 +20,8 @@ public class App extends Application {
|
||||
private static Scene scene;
|
||||
private static StackPane root;
|
||||
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle("Localization", currentLocale);
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private LocalizationAsset loc = AssetManager.get("localization.properties");
|
||||
|
||||
public static void run(String[] args) {
|
||||
launch(args);
|
||||
@@ -30,7 +32,7 @@ public class App extends Application {
|
||||
final StackPane root = new StackPane(new MainMenu().getPane());
|
||||
final Scene scene = new Scene(root);
|
||||
|
||||
stage.setTitle(resourceBundle.getString("windowTitle"));
|
||||
stage.setTitle(loc.getString("windowTitle", currentLocale));
|
||||
stage.setMinWidth(1080);
|
||||
stage.setMinHeight(720);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.toop.app.menu;
|
||||
|
||||
import org.toop.framework.asset.AssetManager;
|
||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -7,7 +9,7 @@ import java.util.ResourceBundle;
|
||||
|
||||
public final class CreditsMenu extends Menu {
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle("Localization", currentLocale);
|
||||
private LocalizationAsset loc = AssetManager.get("localization.properties");
|
||||
public CreditsMenu() {
|
||||
}
|
||||
}
|
||||
@@ -4,31 +4,33 @@ import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.*;
|
||||
import org.toop.local.AppContext;
|
||||
import javafx.scene.text.Font;
|
||||
import org.toop.framework.asset.resources.FontAsset;
|
||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import org.toop.framework.asset.AssetManager;
|
||||
import org.toop.framework.asset.resources.CssAsset;
|
||||
import org.toop.framework.asset.resources.ImageAsset;
|
||||
|
||||
public final class MainMenu extends Menu {
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle("Localization", currentLocale);
|
||||
private final Locale currentLocale = Locale.of("nl");
|
||||
private final LocalizationAsset loc = AssetManager.get("localization.properties");
|
||||
|
||||
public MainMenu() {
|
||||
final Button tictactoe = createButton(resourceBundle.getString("mainMenuSelectTicTacToe"), () -> {});
|
||||
final Button reversi = createButton(resourceBundle.getString("mainMenuSelectReversi"), () -> {});
|
||||
final Button sudoku = createButton(resourceBundle.getString("mainMenuSelectSudoku"), () -> {});
|
||||
final Button battleship = createButton(resourceBundle.getString("mainMenuSelectBattleship"), () -> {});
|
||||
final Button other = createButton(resourceBundle.getString("mainMenuSelectOther"), () -> {});
|
||||
|
||||
final Button tictactoe = createButton(loc.getString("mainMenuSelectTicTacToe", currentLocale), () -> {});
|
||||
final Button reversi = createButton(loc.getString("mainMenuSelectReversi", currentLocale), () -> {});
|
||||
final Button sudoku = createButton(loc.getString("mainMenuSelectSudoku", currentLocale), () -> {});
|
||||
final Button battleship = createButton(loc.getString("mainMenuSelectBattleship", currentLocale), () -> {});
|
||||
final Button other = createButton(loc.getString("mainMenuSelectOther", currentLocale), () -> {});
|
||||
|
||||
final VBox gamesBox = new VBox(tictactoe, reversi, sudoku, battleship, other);
|
||||
gamesBox.setAlignment(Pos.TOP_CENTER);
|
||||
|
||||
final Button credits = createButton(resourceBundle.getString("mainMenuSelectCredits"), () -> {});
|
||||
final Button options = createButton(resourceBundle.getString("mainMenuSelectOptions"), () -> {});
|
||||
final Button quit = createButton(resourceBundle.getString("mainMenuSelectQuit"), () -> {});
|
||||
final Button credits = createButton(loc.getString("mainMenuSelectCredits", currentLocale), () -> {});
|
||||
final Button options = createButton(loc.getString("mainMenuSelectOptions", currentLocale), () -> {});
|
||||
final Button quit = createButton(loc.getString("mainMenuSelectQuit", currentLocale), () -> {});
|
||||
|
||||
final VBox creditsBox = new VBox(credits, options, quit);
|
||||
creditsBox.setAlignment(Pos.BOTTOM_CENTER);
|
||||
@@ -43,7 +45,7 @@ public final class MainMenu extends Menu {
|
||||
background.fitHeightProperty().bind(grid.heightProperty());
|
||||
|
||||
pane = new StackPane(background, grid);
|
||||
CssAsset css = (CssAsset) AssetManager.getByName("main.css").getResource();
|
||||
CssAsset css = AssetManager.get("main.css");
|
||||
pane.getStylesheets().add(css.getUrl());
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,19 @@ import javafx.animation.FadeTransition;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.util.Duration;
|
||||
import org.toop.framework.asset.Asset;
|
||||
import org.toop.framework.asset.AssetManager;
|
||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public abstract class Menu {
|
||||
protected Pane pane;
|
||||
public Pane getPane() { return pane; }
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle("Localization", currentLocale);
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private LocalizationAsset loc = AssetManager.get("localization.properties");
|
||||
|
||||
public void fadeBackgroundImage(String imagePath, float from, float to, float milliseconds) {
|
||||
final FadeTransition fade = new FadeTransition(Duration.millis(milliseconds), App.getRoot());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.toop.app.menu;
|
||||
|
||||
import org.toop.framework.asset.AssetManager;
|
||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -7,7 +9,7 @@ import java.util.ResourceBundle;
|
||||
|
||||
public final class OptionsMenu extends Menu {
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle("Localization", currentLocale);
|
||||
private LocalizationAsset loc = AssetManager.get("localization.properties");
|
||||
public OptionsMenu() {
|
||||
}
|
||||
}
|
||||
@@ -10,29 +10,30 @@ import javafx.scene.text.Text;
|
||||
import org.toop.app.App;
|
||||
import org.toop.framework.asset.AssetManager;
|
||||
import org.toop.framework.asset.resources.CssAsset;
|
||||
import org.toop.framework.asset.resources.LocalizationAsset;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public final class QuitMenu extends Menu {
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle("Localization", currentLocale);
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private LocalizationAsset loc = AssetManager.get("localization.properties");
|
||||
public QuitMenu() {
|
||||
final Region background = new Region();
|
||||
background.getStyleClass().add("quit-background");
|
||||
background.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
||||
|
||||
final Text sure = new Text(resourceBundle.getString("quitMenuTextSure"));
|
||||
final Text sure = new Text(loc.getString("quitMenuTextSure", currentLocale));
|
||||
sure.getStyleClass().add("quit-text");
|
||||
|
||||
final Button yes = new Button(resourceBundle.getString("quitMenuButtonYes"));
|
||||
final Button yes = new Button(loc.getString("quitMenuButtonYes", currentLocale));
|
||||
yes.getStyleClass().add("quit-button");
|
||||
yes.setOnAction(_ -> {
|
||||
App.quit();
|
||||
});
|
||||
|
||||
final Button no = new Button(resourceBundle.getString("quitMenuButtonNo"));
|
||||
final Button no = new Button(loc.getString("quitMenuButtonNo", currentLocale));
|
||||
no.getStyleClass().add("quit-button");
|
||||
no.setOnAction(_ -> {
|
||||
App.pop();
|
||||
@@ -51,7 +52,7 @@ public final class QuitMenu extends Menu {
|
||||
StackPane.setAlignment(box, Pos.CENTER);
|
||||
|
||||
pane = modalContainer;
|
||||
CssAsset css = (CssAsset) AssetManager.getByName("quit.css").getResource();
|
||||
CssAsset css = AssetManager.get("quit.css");
|
||||
pane.getStylesheets().add(css.getUrl());
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/resources/assets/fonts/GroovyManiac.ttf
Normal file
BIN
app/src/main/resources/assets/fonts/GroovyManiac.ttf
Normal file
Binary file not shown.
BIN
app/src/main/resources/assets/fonts/Roboto-Regular.ttf
Normal file
BIN
app/src/main/resources/assets/fonts/Roboto-Regular.ttf
Normal file
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
# Window title
|
||||
windowTitle=ISY Games Selector
|
||||
|
||||
# Main Menu buttons
|
||||
mainMenuSelectTicTacToe=Tic Tac Toe
|
||||
mainMenuSelectReversi=Reversi
|
||||
mainMenuSelectSudoku=Sudoku
|
||||
mainMenuSelectBattleship=Battleship
|
||||
mainMenuSelectOther=Other
|
||||
mainMenuSelectCredits=Credits
|
||||
mainMenuSelectOptions=Options
|
||||
mainMenuSelectQuit=Quit
|
||||
|
||||
# Quit Menu text and buttons
|
||||
quitMenuTextSure=Are you sure?
|
||||
quitMenuButtonYes=Yes
|
||||
quitMenuButtonNo=No
|
||||
@@ -0,0 +1,17 @@
|
||||
# Window title
|
||||
windowTitle=ISY Spellen Kiezer
|
||||
|
||||
# Main Menu buttons
|
||||
mainMenuSelectTicTacToe=Boter Kaas En Eieren
|
||||
mainMenuSelectReversi=Reversi
|
||||
mainMenuSelectSudoku=Sudoku
|
||||
mainMenuSelectBattleship=Zeeslag
|
||||
mainMenuSelectOther=Anders
|
||||
mainMenuSelectCredits=Credits
|
||||
mainMenuSelectOptions=Opties
|
||||
mainMenuSelectQuit=Afsluiten
|
||||
|
||||
# Quit Menu text and buttons
|
||||
quitMenuTextSure=Weet je het zeker?
|
||||
quitMenuButtonYes=Ja
|
||||
quitMenuButtonNo=Nee
|
||||
@@ -1,6 +1,5 @@
|
||||
.main-button {
|
||||
-fx-background-color: transparent;
|
||||
-fx-background-image: url("card-default.jpg"); /* fallback image */
|
||||
-fx-background-size: cover;
|
||||
-fx-background-position: center;
|
||||
-fx-pref-width: 250px;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
-fx-fill: white;
|
||||
-fx-font-size: 28px;
|
||||
-fx-font-weight: 600;
|
||||
-fx-font-family: "Segoe UI", sans-serif;
|
||||
-fx-font-family: "Groovy Maniac Demo", sans-serif;
|
||||
}
|
||||
|
||||
.quit-button {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 189 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 15 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.0 KiB |
@@ -1,33 +0,0 @@
|
||||
.main-button {
|
||||
-fx-background-color: transparent;
|
||||
-fx-background-image: url("card-default.jpg"); /* fallback image */
|
||||
-fx-background-size: cover;
|
||||
-fx-background-position: center;
|
||||
-fx-pref-width: 250px;
|
||||
-fx-pref-height: 180px;
|
||||
-fx-border-radius: 15;
|
||||
-fx-background-radius: 15;
|
||||
-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.3), 15, 0.4, 0, 4);
|
||||
-fx-cursor: hand;
|
||||
-fx-padding: 0;
|
||||
}
|
||||
|
||||
.card-label {
|
||||
-fx-background-color: rgba(0, 0, 0, 0.5);
|
||||
-fx-font-size: 20px;
|
||||
-fx-font-weight: bold;
|
||||
-fx-text-fill: white;
|
||||
-fx-padding: 10px;
|
||||
-fx-alignment: top-center;
|
||||
-fx-background-radius: 15 15 0 0;
|
||||
-fx-opacity: 0;
|
||||
-fx-transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.main-button:hover {
|
||||
-fx-effect: dropshadow(gaussian, #00ffff, 15, 0.5, 0, 0);
|
||||
}
|
||||
|
||||
.main-button:hover .card-label {
|
||||
-fx-opacity: 1;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
.quit-background {
|
||||
-fx-background-color: rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
.quit-box {
|
||||
-fx-background-color: rgba(30, 30, 30, 0.95);
|
||||
-fx-background-radius: 15;
|
||||
-fx-padding: 30;
|
||||
-fx-effect: dropshadow(gaussian, black, 20, 0.6, 0, 4);
|
||||
}
|
||||
|
||||
.quit-text {
|
||||
-fx-fill: white;
|
||||
-fx-font-size: 28px;
|
||||
-fx-font-weight: 600;
|
||||
-fx-font-family: "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
.quit-button {
|
||||
-fx-font-size: 16px;
|
||||
-fx-text-fill: white;
|
||||
-fx-background-color: transparent;
|
||||
-fx-border-color: white;
|
||||
-fx-border-radius: 5;
|
||||
-fx-padding: 8 20;
|
||||
-fx-cursor: hand;
|
||||
}
|
||||
|
||||
.quit-button:hover {
|
||||
-fx-text-fill: #00ffff;
|
||||
-fx-border-color: #00ffff;
|
||||
-fx-effect: dropshadow(gaussian, #00ffff, 8, 0.5, 0, 0);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
.root {
|
||||
-fx-background-color: #2d2d2d;
|
||||
|
||||
-fx-font-size: 28px;
|
||||
-fx-font-weight: 600;
|
||||
-fx-font-family: "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
.button {
|
||||
-fx-background-color: transparent;
|
||||
-fx-text-fill: white;
|
||||
-fx-border-color: transparent;
|
||||
-fx-padding: 10 20;
|
||||
-fx-cursor: hand;
|
||||
-fx-effect: null;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
-fx-effect: dropshadow(gaussian, #00ffff, 10, 0.3, 0, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user