Search in sources :

Example 1 with LocaleRenderer

use of org.terasology.rendering.nui.layers.mainMenu.settings.LocaleRenderer in project Terasology by MovingBlocks.

the class NUIEditorSettingsScreen method initialise.

@Override
public void initialise() {
    WidgetUtil.tryBindCheckbox(this, "disableAutosave", BindHelper.bindBeanProperty("disableAutosave", config.getNuiEditor(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "disableIcons", BindHelper.bindBeanProperty("disableIcons", config.getNuiEditor(), Boolean.TYPE));
    WidgetUtil.trySubscribe(this, "close", button -> getManager().closeScreen(ASSET_URI));
    alternativeLocale = find("alternativeLocale", UIDropdownScrollable.class);
    if (alternativeLocale != null) {
        // Build the list of available locales and set the dropdown's options to them.
        TranslationProject menuProject = translationSystem.getProject(new SimpleUri("engine:menu"));
        List<Locale> locales = new ArrayList<>(menuProject.getAvailableLocales());
        Collections.sort(locales, ((Object o1, Object o2) -> (o1.toString().compareTo(o2.toString()))));
        alternativeLocale.setOptions(Lists.newArrayList(locales));
        alternativeLocale.setVisibleOptions(5);
        alternativeLocale.setOptionRenderer(new LocaleRenderer(translationSystem));
        // If an alternative locale has been previously selected, select it; otherwise select the system locale.
        if (config.getNuiEditor().getAlternativeLocale() != null) {
            alternativeLocale.setSelection(config.getNuiEditor().getAlternativeLocale());
        } else {
            alternativeLocale.setSelection(config.getSystem().getLocale());
        }
    }
}
Also used : Locale(java.util.Locale) LocaleRenderer(org.terasology.rendering.nui.layers.mainMenu.settings.LocaleRenderer) TranslationProject(org.terasology.i18n.TranslationProject) UIDropdownScrollable(org.terasology.rendering.nui.widgets.UIDropdownScrollable) SimpleUri(org.terasology.engine.SimpleUri) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 SimpleUri (org.terasology.engine.SimpleUri)1 TranslationProject (org.terasology.i18n.TranslationProject)1 LocaleRenderer (org.terasology.rendering.nui.layers.mainMenu.settings.LocaleRenderer)1 UIDropdownScrollable (org.terasology.rendering.nui.widgets.UIDropdownScrollable)1