use of org.terasology.engine.rendering.nui.layers.mainMenu.settings.LocaleRenderer in project Terasology by MovingBlocks.
the class LocaleConstraintWidgetFactory method buildWidget.
@Override
protected Optional<UIWidget> buildWidget() {
Setting<Locale> setting = getSetting();
Binding<Locale> binding = new Binding<Locale>() {
@Override
public Locale get() {
return setting.get();
}
@Override
public void set(Locale value) {
setting.set(value);
}
};
UIDropdownScrollable<Locale> dropdownScrollable = new UIDropdownScrollable<>();
ResourceUrn menuUrn = new ResourceUrn("engine:menu");
TranslationProject menuProject = translationSystem.getProject(menuUrn);
List<Locale> locales = new ArrayList<>(menuProject.getAvailableLocales());
for (Locale languageExcluded : languagesExcluded) {
locales.remove(languageExcluded);
}
Collections.sort(locales, (Comparator.comparing((Function<Object, String>) Object::toString)));
dropdownScrollable.setOptions(Lists.newArrayList(locales));
// Set maximum number of options visible for scrolling
dropdownScrollable.setVisibleOptions(5);
dropdownScrollable.bindSelection(binding);
dropdownScrollable.setOptionRenderer(new LocaleRenderer(translationSystem));
return Optional.of(dropdownScrollable);
}
use of org.terasology.engine.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 ResourceUrn("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(systemConfig.locale.get());
}
}
}
Aggregations