Search in sources :

Example 11 with UILabel

use of org.terasology.nui.widgets.UILabel in project Terasology by MovingBlocks.

the class VideoSettingsScreen method initialise.

@Override
@SuppressWarnings("unchecked")
public void initialise() {
    setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
    UIDropdown<Preset> videoQuality = find("graphicsPreset", UIDropdown.class);
    if (videoQuality != null) {
        videoQuality.setOptionRenderer(new ToStringTextRenderer<>(translationSystem));
        videoQuality.setOptions(Lists.newArrayList(Preset.CUSTOM, Preset.MINIMAL, Preset.LOW, Preset.MEDIUM, Preset.HIGH, Preset.ULTRA));
        videoQuality.bindSelection(new PresetBinding(config.getRendering()));
    }
    UIDropdown<ViewDistance> viewDistance = find("viewDistance", UIDropdown.class);
    if (viewDistance != null) {
        viewDistance.setOptionRenderer(new ToStringTextRenderer<>(translationSystem));
        viewDistance.setOptions(Arrays.asList(ViewDistance.values()));
        viewDistance.bindSelection(BindHelper.bindBeanProperty("viewDistance", config.getRendering(), ViewDistance.class));
    }
    UIDropdown<WaterReflection> waterReflection = find("reflections", UIDropdown.class);
    if (waterReflection != null) {
        waterReflection.setOptionRenderer(new ToStringTextRenderer<>(translationSystem));
        waterReflection.setOptions(Lists.newArrayList(WaterReflection.SKY, WaterReflection.GLOBAL, WaterReflection.LOCAL));
        waterReflection.bindSelection(new WaterReflectionBinding(config.getRendering()));
    }
    UIDropdown<ScreenshotSize> screenshotSize = find("screenshotSize", UIDropdown.class);
    if (screenshotSize != null) {
        screenshotSize.setOptionRenderer(new ToStringTextRenderer<>(translationSystem));
        screenshotSize.setOptions(Arrays.asList(ScreenshotSize.values()));
        screenshotSize.bindSelection(BindHelper.bindBeanProperty("screenshotSize", config.getRendering(), ScreenshotSize.class));
    }
    UIDropdown<String> screenshotFormat = find("screenshotFormat", UIDropdown.class);
    if (screenshotFormat != null) {
        screenshotFormat.setOptions(Arrays.asList(ImageIO.getWriterFileSuffixes()));
        screenshotFormat.bindSelection(BindHelper.bindBeanProperty("screenshotFormat", config.getRendering(), String.class));
    }
    UIDropdown<Integer> blur = find("blur", UIDropdown.class);
    if (blur != null) {
        blur.setOptions(Lists.newArrayList(0, 1, 2, 3));
        blur.bindSelection(BindHelper.bindBeanProperty("blurIntensity", config.getRendering(), Integer.TYPE));
        blur.setOptionRenderer(new StringTextRenderer<Integer>() {

            @Override
            public String getString(Integer value) {
                switch(value) {
                    case 1:
                        return translationSystem.translate("${engine:menu#camera-blur-some}");
                    case 2:
                        return translationSystem.translate("${engine:menu#camera-blur-normal}");
                    case 3:
                        return translationSystem.translate("${engine:menu#camera-blur-max}");
                    default:
                        return translationSystem.translate("${engine:menu#camera-blur-off}");
                }
            }
        });
    }
    UIDropdown<DynamicShadows> dynamicShadows = find("shadows", UIDropdown.class);
    if (dynamicShadows != null) {
        dynamicShadows.setOptionRenderer(new ToStringTextRenderer<>(translationSystem));
        dynamicShadows.setOptions(Arrays.asList(DynamicShadows.values()));
        dynamicShadows.bindSelection(new DynamicShadowsBinding(config.getRendering()));
    }
    final UISlider fovSlider = find("fov", UISlider.class);
    if (fovSlider != null) {
        fovSlider.setIncrement(5.0f);
        fovSlider.setPrecision(0);
        fovSlider.setMinimum(70);
        fovSlider.setRange(50);
        fovSlider.bindValue(BindHelper.bindBeanProperty("fieldOfView", config.getRendering(), Float.TYPE));
    }
    final UISlider chunkLodSlider = find("chunkLods", UISlider.class);
    if (chunkLodSlider != null) {
        chunkLodSlider.setIncrement(1);
        chunkLodSlider.setPrecision(0);
        chunkLodSlider.setMinimum(0);
        chunkLodSlider.setRange(10);
        chunkLodSlider.bindValue(BindHelper.bindBeanProperty("chunkLods", config.getRendering(), Float.TYPE));
    }
    final UISlider billboardLimitSlider = find("billboardLimit", UISlider.class);
    if (billboardLimitSlider != null) {
        billboardLimitSlider.setIncrement(32);
        billboardLimitSlider.setPrecision(0);
        billboardLimitSlider.setMinimum(0);
        billboardLimitSlider.setRange(512);
        // Billboard limit == 0 means no limit
        billboardLimitSlider.setLabelFunction(input -> {
            if (input == 0) {
                return "No limit";
            } else {
                return String.valueOf(input.intValue());
            }
        });
        billboardLimitSlider.bindValue(BindHelper.bindBeanProperty("billboardLimit", config.getRendering(), Float.TYPE));
    }
    final UISlider frameLimitSlider = find("frameLimit", UISlider.class);
    if (frameLimitSlider != null) {
        frameLimitSlider.setIncrement(5.0f);
        frameLimitSlider.setPrecision(0);
        frameLimitSlider.setMinimum(30);
        // Goes up to 205 (which is off)
        frameLimitSlider.setRange(175);
        // Frame limit > 200 is just displayed and treated as "off"
        frameLimitSlider.setLabelFunction(input -> {
            if (input > 200) {
                // Spaces to get wider than "200" (otherwise the display jumps around)
                return " Off ";
            } else {
                return String.valueOf(input.intValue());
            }
        });
        frameLimitSlider.bindValue(new Binding<Float>() {

            @Override
            public Float get() {
                if (config.getRendering().getFrameLimit() == -1) {
                    return 205f;
                } else {
                    return (float) config.getRendering().getFrameLimit();
                }
            }

            @Override
            public void set(Float value) {
                int frameLimit = value.intValue();
                if (frameLimit > 200) {
                    config.getRendering().setFrameLimit(-1);
                } else {
                    config.getRendering().setFrameLimit(frameLimit);
                }
            }
        });
    }
    final UISlider particleEffectLimitSlider = find("particleEffectLimit", UISlider.class);
    if (particleEffectLimitSlider != null) {
        particleEffectLimitSlider.setIncrement(1.0f);
        particleEffectLimitSlider.setPrecision(0);
        particleEffectLimitSlider.setMinimum(0);
        particleEffectLimitSlider.setRange(50);
        particleEffectLimitSlider.setLabelFunction(input -> {
            if (input == 0) {
                return " Off ";
            } else {
                return String.valueOf(input.intValue());
            }
        });
        particleEffectLimitSlider.bindValue(new Binding<Float>() {

            @Override
            public Float get() {
                return (float) config.getRendering().getParticleEffectLimit();
            }

            @Override
            public void set(Float value) {
                int particleEffectLimit = value.intValue();
                config.getRendering().setParticleEffectLimit(particleEffectLimit);
            }
        });
    }
    final UISlider fboScaleSlider = find("fboScale", UISlider.class);
    if (fboScaleSlider != null) {
        fboScaleSlider.setIncrement(5.0f);
        fboScaleSlider.setPrecision(0);
        fboScaleSlider.setMinimum(25);
        fboScaleSlider.setRange(200);
        fboScaleSlider.setLabelFunction(input -> input.intValue() + "%");
        fboScaleSlider.bindValue(new Binding<Float>() {

            @Override
            public Float get() {
                return (float) config.getRendering().getFboScale();
            }

            @Override
            public void set(Float value) {
                config.getRendering().setFboScale(value.intValue());
            }
        });
    }
    final UILabel uiScaleLabel = find("uiScaleLabel", UILabel.class);
    uiScaleLabel.setText(" " + config.getRendering().getUiScale() + "% ");
    WidgetUtil.trySubscribe(this, "uiScaleSmaller", button -> {
        int newScale = Math.max(50, config.getRendering().getUiScale() - 25);
        config.getRendering().setUiScale(newScale);
        uiScaleLabel.setText(" " + config.getRendering().getUiScale() + "% ");
    });
    WidgetUtil.trySubscribe(this, "uiScaleLarger", button -> {
        int newScale = Math.min(250, config.getRendering().getUiScale() + 25);
        config.getRendering().setUiScale(newScale);
        uiScaleLabel.setText(" " + config.getRendering().getUiScale() + "% ");
    });
    UIDropdown<CameraSetting> cameraSetting = find("camera", UIDropdown.class);
    if (cameraSetting != null) {
        cameraSetting.setOptionRenderer(new ToStringTextRenderer<>(translationSystem));
        cameraSetting.setOptions(Arrays.asList(CameraSetting.values()));
        cameraSetting.bindSelection(new CameraSettingBinding(config.getRendering()));
    }
    UIDropdown<DisplayModeSetting> displaySetting = find("displayModeSetting", UIDropdown.class);
    if (displaySetting != null) {
        displaySetting.setOptionRenderer(new ToStringTextRenderer<>(translationSystem));
        displaySetting.setOptions(Arrays.asList(DisplayModeSetting.values()));
        displaySetting.bindSelection(BindHelper.bindBeanProperty("displayModeSetting", displayDevice, DisplayModeSetting.class));
    }
    UIDropdown<Resolution> resolution = find("resolution", UIDropdown.class);
    if (resolution != null) {
        resolution.setOptions(displayDevice.getResolutions());
        resolution.bindSelection(new Binding<Resolution>() {

            @Override
            public Resolution get() {
                return displayDevice.getResolution();
            }

            @Override
            public void set(Resolution value) {
                onResolutionChange(value);
            }
        });
    }
    WidgetUtil.tryBindCheckbox(this, "menu-animations", BindHelper.bindBeanProperty("animatedMenu", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "oculusVrSupport", BindHelper.bindBeanProperty("vrSupport", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "animateGrass", BindHelper.bindBeanProperty("animateGrass", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "animateWater", BindHelper.bindBeanProperty("animateWater", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "volumetricFog", BindHelper.bindBeanProperty("volumetricFog", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "inscattering", BindHelper.bindBeanProperty("inscattering", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "cloudShadow", BindHelper.bindBeanProperty("cloudShadows", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "extraLighting", BindHelper.bindBeanProperty("normalMapping", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "parallax", BindHelper.bindBeanProperty("parallaxMapping", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "filmGrain", BindHelper.bindBeanProperty("filmGrain", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "motionBlur", BindHelper.bindBeanProperty("motionBlur", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "bobbing", BindHelper.bindBeanProperty("cameraBobbing", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "outline", BindHelper.bindBeanProperty("outline", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "vsync", BindHelper.bindBeanProperty("vSync", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "eyeAdaptation", BindHelper.bindBeanProperty("eyeAdaptation", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "ssao", BindHelper.bindBeanProperty("ssao", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "clampLighting", BindHelper.bindBeanProperty("clampLighting", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "bloom", BindHelper.bindBeanProperty("bloom", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "lightShafts", BindHelper.bindBeanProperty("lightShafts", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "vignette", BindHelper.bindBeanProperty("vignette", config.getRendering(), Boolean.TYPE));
    WidgetUtil.tryBindCheckbox(this, "flickeringLight", BindHelper.bindBeanProperty("flickeringLight", config.getRendering(), Boolean.TYPE));
    if (fovSlider != null) {
        WidgetUtil.trySubscribe(this, "fovReset", widget -> fovSlider.setValue(100.0f));
    }
    WidgetUtil.trySubscribe(this, "close", button -> saveSettings());
}
Also used : ViewDistance(org.terasology.engine.rendering.world.viewDistance.ViewDistance) UILabel(org.terasology.nui.widgets.UILabel) UISlider(org.terasology.nui.widgets.UISlider) Resolution(org.terasology.engine.core.subsystem.Resolution)

Example 12 with UILabel

use of org.terasology.nui.widgets.UILabel in project Terasology by MovingBlocks.

the class TelemetryScreen method addTelemetryField.

/**
 * Add a new row in the menu, the new row includes the field name and value.
 *
 * @param type the type(name) of the this field
 * @param value the value of this field
 * @param layout the layout where the new line will be added
 * @param isWithCheckbox whether add a check box in the line
 * @param telemetryCategory the TelemetryCategory that this field belongs to
 */
private void addTelemetryField(String type, Object value, ColumnLayout layout, boolean isWithCheckbox, TelemetryCategory telemetryCategory) {
    RowLayout newRow;
    if (isWithCheckbox) {
        String fieldName = telemetryCategory.id() + ":" + type;
        UICheckbox uiCheckbox = new UICheckbox(fieldName);
        Map<String, Boolean> bindingMap = config.getTelemetryConfig().getMetricsUserPermissionConfig().getBindingMap();
        if (!bindingMap.containsKey(fieldName)) {
            bindingMap.put(fieldName, config.getTelemetryConfig().isTelemetryEnabled());
        }
        Binding<Boolean> binding = getBindingFromBooleanMap(bindingMap, fieldName);
        uiCheckbox.bindChecked(binding);
        uiCheckbox.subscribe((checkbox) -> {
            if (bindingMap.get(fieldName)) {
                bindingMap.put(telemetryCategory.id(), true);
            } else {
                Set<Field> fields = ReflectionUtils.getFields(telemetryCategories.get(telemetryCategory), ReflectionUtils.withAnnotation(TelemetryField.class));
                boolean isOneEnabled = false;
                for (Field field : fields) {
                    isOneEnabled = isOneEnabled || bindingMap.get(telemetryCategory.id() + ":" + field.getName());
                }
                if (!isOneEnabled) {
                    bindingMap.put(telemetryCategory.id(), false);
                }
            }
        });
        newRow = new RowLayout(new UILabel(type), new UILabel(value.toString()), uiCheckbox).setColumnRatios(0.4f, 0.5f, 0.1f).setHorizontalSpacing(horizontalSpacing);
    } else {
        newRow = new RowLayout(new UILabel(type), new UILabel(value.toString())).setColumnRatios(0.4f, 0.5f).setHorizontalSpacing(horizontalSpacing);
    }
    layout.addWidget(newRow);
}
Also used : UILabel(org.terasology.nui.widgets.UILabel) Field(java.lang.reflect.Field) RowLayout(org.terasology.nui.layouts.RowLayout) UICheckbox(org.terasology.nui.widgets.UICheckbox)

Example 13 with UILabel

use of org.terasology.nui.widgets.UILabel in project Terasology by MovingBlocks.

the class TelemetryScreen method addTelemetrySection.

/**
 * Add a new section with represents a new metrics type.
 *
 * @param telemetryCategory the annotation of the new metric
 * @param layout the layout where the new section will be added
 * @param map the map which includes the telemetry field name and value
 */
private void addTelemetrySection(TelemetryCategory telemetryCategory, ColumnLayout layout, Map<String, ?> map) {
    UILabel categoryHeader = new UILabel(translationSystem.translate(telemetryCategory.displayName()));
    categoryHeader.setFamily("subheading");
    UICheckbox uiCheckbox = new UICheckbox(telemetryCategory.id());
    Map<String, Boolean> bindingMap = config.getTelemetryConfig().getMetricsUserPermissionConfig().getBindingMap();
    if (!bindingMap.containsKey(telemetryCategory.id())) {
        bindingMap.put(telemetryCategory.id(), config.getTelemetryConfig().isTelemetryEnabled());
    }
    Binding<Boolean> binding = getBindingFromBooleanMap(bindingMap, telemetryCategory.id());
    uiCheckbox.bindChecked(binding);
    RowLayout newRow = new RowLayout(categoryHeader, new UISpace(), uiCheckbox).setColumnRatios(0.4f, 0.5f, 0.1f).setHorizontalSpacing(horizontalSpacing);
    layout.addWidget(newRow);
    List<Map.Entry<String, ?>> telemetryFields = sortFields(map);
    for (Map.Entry entry : telemetryFields) {
        Object value = entry.getValue();
        if (value == null) {
            value = "Value unknown yet";
        }
        boolean isWithCheckbox = !telemetryCategory.isOneMapMetric();
        if (value instanceof List) {
            List list = (List) value;
            addTelemetryField(entry.getKey().toString(), list, layout, isWithCheckbox, telemetryCategory);
        } else {
            addTelemetryField(entry.getKey().toString(), value, layout, isWithCheckbox, telemetryCategory);
        }
    }
}
Also used : UILabel(org.terasology.nui.widgets.UILabel) UICheckbox(org.terasology.nui.widgets.UICheckbox) RowLayout(org.terasology.nui.layouts.RowLayout) ArrayList(java.util.ArrayList) List(java.util.List) UISpace(org.terasology.nui.widgets.UISpace) Map(java.util.Map)

Example 14 with UILabel

use of org.terasology.nui.widgets.UILabel in project Terasology by MovingBlocks.

the class ObjectLayoutBuilder method populateConstructorParameters.

private void populateConstructorParameters(Binding<T> binding, ColumnLayout parameterLayout, UIButton createInstanceButton, Binding<Constructor<T>> selectedConstructor) {
    parameterLayout.removeAllWidgets();
    Parameter[] parameters = selectedConstructor.get().getParameters();
    List<TypeInfo<?>> parameterTypes = Arrays.stream(parameters).map(Parameter::getParameterizedType).map(parameterType -> ReflectionUtil.resolveType(type.getType(), parameterType)).map(TypeInfo::of).collect(Collectors.toList());
    List<Binding<?>> argumentBindings = parameterTypes.stream().map(parameterType -> new DefaultBinding<>(Defaults.defaultValue(parameterType.getRawType()))).collect(Collectors.toList());
    createInstanceButton.subscribe(widget -> {
        Object[] arguments = argumentBindings.stream().map(Binding::get).toArray();
        try {
            binding.set(selectedConstructor.get().newInstance(arguments));
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    });
    if (argumentBindings.isEmpty()) {
        // TODO: Translate
        parameterLayout.addWidget(new UILabel("Constructor has no parameters"));
        return;
    }
    ColumnLayout parametersExpandableLayout = WidgetUtil.createExpandableLayout(// TODO: Translate
    "Constructor Parameters", this::createDefaultLayout, layout -> {
        for (int i = 0; i < parameterTypes.size(); i++) {
            TypeInfo<?> parameterType = parameterTypes.get(i);
            Binding<?> argumentBinding = argumentBindings.get(i);
            Parameter parameter = parameters[i];
            Optional<UIWidget> optionalWidget = library.getBaseTypeWidget((Binding) argumentBinding, parameterType);
            if (!optionalWidget.isPresent()) {
                LOGGER.warn("Could not create widget for parameter of type {} of constructor {}", parameter, selectedConstructor.get());
                continue;
            }
            UIWidget widget = optionalWidget.get();
            String parameterLabelText = ReflectionUtil.typeToString(parameterType.getType(), true);
            layout.addWidget(WidgetUtil.labelize(widget, parameterLabelText, LABEL_WIDGET_ID));
        }
    }, this::createDefaultLayout);
    parameterLayout.addWidget(parametersExpandableLayout);
}
Also used : NotifyingBinding(org.terasology.nui.databinding.NotifyingBinding) DefaultBinding(org.terasology.nui.databinding.DefaultBinding) Binding(org.terasology.nui.databinding.Binding) Arrays(java.util.Arrays) Defaults(com.google.common.base.Defaults) LoggerFactory(org.slf4j.LoggerFactory) TypeWidgetLibrary(org.terasology.nui.widgets.types.TypeWidgetLibrary) TypeInfo(org.terasology.reflection.TypeInfo) ExpandableLayoutBuilder(org.terasology.nui.widgets.types.builtin.util.ExpandableLayoutBuilder) FieldsWidgetBuilder(org.terasology.nui.widgets.types.builtin.util.FieldsWidgetBuilder) WidgetUtil(org.terasology.nui.WidgetUtil) Constructor(java.lang.reflect.Constructor) UIBox(org.terasology.nui.widgets.UIBox) NotifyingBinding(org.terasology.nui.databinding.NotifyingBinding) DefaultBinding(org.terasology.nui.databinding.DefaultBinding) ColumnLayout(org.terasology.nui.layouts.ColumnLayout) Parameter(java.lang.reflect.Parameter) StringTextRenderer(org.terasology.nui.itemRendering.StringTextRenderer) Binding(org.terasology.nui.databinding.Binding) UIDropdownScrollable(org.terasology.nui.widgets.UIDropdownScrollable) Logger(org.slf4j.Logger) UILabel(org.terasology.nui.widgets.UILabel) ReflectionUtil(org.terasology.engine.utilities.ReflectionUtil) Collectors(java.util.stream.Collectors) InvocationTargetException(java.lang.reflect.InvocationTargetException) UIWidget(org.terasology.nui.UIWidget) List(java.util.List) UIButton(org.terasology.nui.widgets.UIButton) LABEL_WIDGET_ID(org.terasology.nui.widgets.types.TypeWidgetFactory.LABEL_WIDGET_ID) Optional(java.util.Optional) UILabel(org.terasology.nui.widgets.UILabel) DefaultBinding(org.terasology.nui.databinding.DefaultBinding) TypeInfo(org.terasology.reflection.TypeInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) UIWidget(org.terasology.nui.UIWidget) ColumnLayout(org.terasology.nui.layouts.ColumnLayout) Parameter(java.lang.reflect.Parameter)

Example 15 with UILabel

use of org.terasology.nui.widgets.UILabel in project Terasology by MovingBlocks.

the class ObjectLayoutBuilder method populateNullLayout.

private void populateNullLayout(Binding<T> binding, ColumnLayout layout, UILabel nameWidget) {
    // TODO: Translate
    if (MODIFY_LABEL.equals(nameWidget.getText())) {
        nameWidget.setText(NULL_LABEL);
    }
    List<Constructor<T>> constructors = Arrays.stream(type.getRawType().getConstructors()).map(constructor -> (Constructor<T>) constructor).collect(Collectors.toList());
    if (constructors.isEmpty()) {
        // TODO: Translate
        UIBox box = buildErrorWidget("No accessible constructors found");
        layout.addWidget(box);
        return;
    }
    ColumnLayout parameterLayout = createDefaultLayout();
    UIButton createInstanceButton = new UIButton();
    // TODO: Translate
    createInstanceButton.setText("Create Instance");
    UIDropdownScrollable<Constructor<T>> constructorSelection = new UIDropdownScrollable<>();
    Binding<Constructor<T>> selectedConstructor = new NotifyingBinding<Constructor<T>>(constructors.get(0)) {

        @Override
        protected void onSet() {
            populateConstructorParameters(binding, parameterLayout, createInstanceButton, this);
        }
    };
    constructorSelection.setOptions(constructors);
    constructorSelection.bindSelection(selectedConstructor);
    constructorSelection.setOptionRenderer(new StringTextRenderer<Constructor<T>>() {

        @Override
        public String getString(Constructor<T> value) {
            return ReflectionUtil.resolvedMethodToString(type.getType(), value, true);
        }
    });
    // TODO: Translate
    constructorSelection.setTooltip("Select the constructor to use to create the new object");
    layout.addWidget(constructorSelection);
    layout.addWidget(parameterLayout);
    layout.addWidget(createInstanceButton);
}
Also used : Arrays(java.util.Arrays) Defaults(com.google.common.base.Defaults) LoggerFactory(org.slf4j.LoggerFactory) TypeWidgetLibrary(org.terasology.nui.widgets.types.TypeWidgetLibrary) TypeInfo(org.terasology.reflection.TypeInfo) ExpandableLayoutBuilder(org.terasology.nui.widgets.types.builtin.util.ExpandableLayoutBuilder) FieldsWidgetBuilder(org.terasology.nui.widgets.types.builtin.util.FieldsWidgetBuilder) WidgetUtil(org.terasology.nui.WidgetUtil) Constructor(java.lang.reflect.Constructor) UIBox(org.terasology.nui.widgets.UIBox) NotifyingBinding(org.terasology.nui.databinding.NotifyingBinding) DefaultBinding(org.terasology.nui.databinding.DefaultBinding) ColumnLayout(org.terasology.nui.layouts.ColumnLayout) Parameter(java.lang.reflect.Parameter) StringTextRenderer(org.terasology.nui.itemRendering.StringTextRenderer) Binding(org.terasology.nui.databinding.Binding) UIDropdownScrollable(org.terasology.nui.widgets.UIDropdownScrollable) Logger(org.slf4j.Logger) UILabel(org.terasology.nui.widgets.UILabel) ReflectionUtil(org.terasology.engine.utilities.ReflectionUtil) Collectors(java.util.stream.Collectors) InvocationTargetException(java.lang.reflect.InvocationTargetException) UIWidget(org.terasology.nui.UIWidget) List(java.util.List) UIButton(org.terasology.nui.widgets.UIButton) LABEL_WIDGET_ID(org.terasology.nui.widgets.types.TypeWidgetFactory.LABEL_WIDGET_ID) Optional(java.util.Optional) Constructor(java.lang.reflect.Constructor) UIBox(org.terasology.nui.widgets.UIBox) UIDropdownScrollable(org.terasology.nui.widgets.UIDropdownScrollable) ColumnLayout(org.terasology.nui.layouts.ColumnLayout) UIButton(org.terasology.nui.widgets.UIButton) NotifyingBinding(org.terasology.nui.databinding.NotifyingBinding)

Aggregations

UILabel (org.terasology.nui.widgets.UILabel)27 UIButton (org.terasology.nui.widgets.UIButton)7 List (java.util.List)5 RowLayout (org.terasology.nui.layouts.RowLayout)5 Vector2i (org.joml.Vector2i)4 UICheckbox (org.terasology.nui.widgets.UICheckbox)4 UISpace (org.terasology.nui.widgets.UISpace)4 UIText (org.terasology.nui.widgets.UIText)4 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 UIWidget (org.terasology.nui.UIWidget)3 ColumnLayout (org.terasology.nui.layouts.ColumnLayout)3 UISlider (org.terasology.nui.widgets.UISlider)3 Defaults (com.google.common.base.Defaults)2 JsonElement (com.google.gson.JsonElement)2 Constructor (java.lang.reflect.Constructor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Parameter (java.lang.reflect.Parameter)2