mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Merge remote-tracking branch 'origin/121-settings-menu' into UI
# Conflicts: # app/src/main/java/org/toop/app/menu/OptionsMenu.java # app/src/main/resources/assets/localization/localization_de.properties # app/src/main/resources/assets/localization/localization_en_US.properties # app/src/main/resources/assets/localization/localization_es.properties # app/src/main/resources/assets/localization/localization_fr.properties # app/src/main/resources/assets/localization/localization_it.properties # app/src/main/resources/assets/localization/localization_nl.properties # app/src/main/resources/assets/localization/localization_zh.properties
This commit is contained in:
@@ -11,7 +11,7 @@ import java.util.Locale;
|
||||
|
||||
public final class CreditsMenu extends Menu {
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private LocalizationAsset loc = ResourceManager.get("localization.properties");
|
||||
private LocalizationAsset loc = ResourceManager.get("localization_en_us.properties");
|
||||
public CreditsMenu() {
|
||||
try {
|
||||
new EventFlow()
|
||||
|
||||
@@ -14,10 +14,14 @@ import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.local.AppContext;
|
||||
import org.toop.local.LocalizationEvents;
|
||||
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class OptionsMenu extends Menu {
|
||||
private Locale currentLocale = AppContext.getLocale();
|
||||
private LocalizationAsset loc = ResourceManager.get("localization");
|
||||
|
||||
private final LocalizationAsset loc = ResourceManager.get("localization.properties");
|
||||
private Text chooseLang;
|
||||
private Button english,dutch,german,french,italian,spanish,chinese;
|
||||
@@ -65,5 +69,65 @@ public final class OptionsMenu extends Menu {
|
||||
chinese.setText(loc.getString("languageChinese",currentLocale));
|
||||
});
|
||||
|
||||
}
|
||||
final Region background = createBackground();
|
||||
|
||||
GraphicsDevice currentScreen = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0];
|
||||
|
||||
LocalizationAsset locFiles = ResourceManager.get(LocalizationAsset.class, "localization");
|
||||
final Label selectLanguageLabel = new Label(loc.getString("optionsMenuLabelSelectLanguage", currentLocale));
|
||||
final ChoiceBox<Locale> selectLanguage = new ChoiceBox<>();
|
||||
selectLanguage.setValue(currentLocale);
|
||||
for (Locale locFile : locFiles.getAvailableLocales()) {
|
||||
selectLanguage.getItems().add(locFile);
|
||||
}
|
||||
|
||||
selectLanguage.setOnAction((event) -> {
|
||||
Locale selectedLocale = selectLanguage.getSelectionModel().getSelectedItem();
|
||||
AppContext.setLocale(selectedLocale);
|
||||
App.pop();
|
||||
App.push(new OptionsMenu());
|
||||
});
|
||||
|
||||
// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// GraphicsDevice[] devices = ge.getScreenDevices();
|
||||
// final ChoiceBox<GraphicsDevice> selectScreen = new ChoiceBox<>();
|
||||
// for (GraphicsDevice screen : devices) {
|
||||
// selectScreen.getItems().add(screen);
|
||||
// }
|
||||
//
|
||||
// selectScreen.setOnAction((event) -> {
|
||||
// int selectedIndex = selectScreen.getSelectionModel().getSelectedIndex();
|
||||
// Object selectedItem = selectScreen.getSelectionModel().getSelectedItem();
|
||||
//
|
||||
// System.out.println("Selection made: [" + selectedIndex + "] " + selectedItem);
|
||||
// System.out.println(" ChoiceBox.getValue(): " + selectScreen.getValue());
|
||||
// });
|
||||
//
|
||||
// final ChoiceBox<DisplayMode> selectWindowSize = new ChoiceBox<>();
|
||||
// for (DisplayMode displayMode : currentScreen.getDisplayModes()) {
|
||||
// selectWindowSize.getItems().add(displayMode);
|
||||
// }
|
||||
//
|
||||
//// if (currentScreen.isFullScreenSupported()) {}
|
||||
// final CheckBox setFullscreen = new CheckBox("Fullscreen");
|
||||
|
||||
final VBox optionsBox = new VBox(10, selectLanguageLabel, selectLanguage);
|
||||
optionsBox.setAlignment(Pos.CENTER);
|
||||
optionsBox.setPickOnBounds(false);
|
||||
optionsBox.setTranslateY(50);
|
||||
optionsBox.setTranslateX(25);
|
||||
|
||||
final Button credits = createButton("Credits", () -> { App.push(new CreditsMenu()); });
|
||||
final Button options = createButton("Exit Options", () -> { App.push(new MainMenu()); });
|
||||
final Button quit = createButton("Quit", () -> { App.quitPopup(); });
|
||||
|
||||
final VBox controlBox = new VBox(10, credits, options, quit);
|
||||
controlBox.setAlignment(Pos.BOTTOM_LEFT);
|
||||
controlBox.setPickOnBounds(false);
|
||||
controlBox.setTranslateY(-50);
|
||||
controlBox.setTranslateX(25);
|
||||
|
||||
pane = new StackPane(background, optionsBox, controlBox);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,10 @@ import java.util.Locale;
|
||||
public class AppContext {
|
||||
private static Locale currentLocale = Locale.getDefault();
|
||||
|
||||
public static void setLocale(Locale locale) {
|
||||
currentLocale = locale;
|
||||
}
|
||||
|
||||
public static void setCurrentLocale(Locale locale) {
|
||||
currentLocale = locale;
|
||||
new EventFlow().addPostEvent(new LocalizationEvents.LanguageHasChanged(locale.getLanguage())).asyncPostEvent();
|
||||
|
||||
Reference in New Issue
Block a user