Package org.moddingx.libx.config.gui
Interface ConfigEditor<T>
- Type Parameters:
T
-
public interface ConfigEditor<T>
A config editor provides the logic on how to display a config value in a GUI. The config
editor may not store additional state, as the same editor can be used for multiple entries.
However, the
widgets
created by an editor can store state.-
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.client.gui.components.AbstractWidget
createWidget
(net.minecraft.client.gui.screens.Screen screen, T initialValue, WidgetProperties<T> properties) Creates a widget for a given initial value.static <T> ConfigEditor<T>
custom
(T defaultValue, Function<T, ConfigScreenContent<T>> contentFactory) Creates a config editor with a button that will then open a sub-screen based on the givencontent
.Gets the default value for places where elements with this editor are created that have no value set.static ConfigEditor<String>
input()
Creates a new text input editor.static <T> ConfigEditor<T>
input
(InputProperties<T> input) Creates a new text input editor.static <T> ConfigEditor<T>
input
(InputProperties<T> input, ValidatorInfo<?> validator) Creates a new text input editor.static ConfigEditor<String>
input
(ValidatorInfo<?> validator) Creates a new text input editor.static <T> ConfigEditor<Optional<T>>
option
(ConfigEditor<T> editor) Creates a new editor that represents an option of another editor by adding a checkbox to select whether a value is set or not.static <T> ConfigEditor<T>
Creates a new editor for a slider.static <T> ConfigEditor<T>
Creates a toggle editor for a set of elements.static <T> ConfigEditor<T>
Creates a toggle editor for a set of elements.static <T> ConfigEditor<T>
unsupported
(T defaultValue) Creates a new editor that states, that a value can't be edited through the GUI.net.minecraft.client.gui.components.AbstractWidget
updateWidget
(net.minecraft.client.gui.screens.Screen screen, net.minecraft.client.gui.components.AbstractWidget old, WidgetProperties<T> properties) Updates a previously created widget, for example, after a screen resize.
-
Method Details
-
defaultValue
T defaultValue()Gets the default value for places where elements with this editor are created that have no value set. -
createWidget
net.minecraft.client.gui.components.AbstractWidget createWidget(net.minecraft.client.gui.screens.Screen screen, T initialValue, WidgetProperties<T> properties) Creates a widget for a given initial value.- Parameters:
screen
- The screen used for display. This screen must be used if the widget wants to draw tooltips, or they won't work correctly.initialValue
- The initial value for the created widget.properties
- Additional properties for the widget.
-
updateWidget
net.minecraft.client.gui.components.AbstractWidget updateWidget(net.minecraft.client.gui.screens.Screen screen, net.minecraft.client.gui.components.AbstractWidget old, WidgetProperties<T> properties) Updates a previously created widget, for example, after a screen resize.- Parameters:
screen
- The screen used for display. This screen must be used if the widget wants to draw tooltips, or they won't work correctly.old
- The old widget that was created before, either bycreateWidget(net.minecraft.client.gui.screens.Screen, T, org.moddingx.libx.config.gui.WidgetProperties<T>)
or by this method.properties
- Additional properties for the widget.
-
unsupported
Creates a new editor that states, that a value can't be edited through the GUI.- Parameters:
defaultValue
- The value that should be used as the default value.
-
option
Creates a new editor that represents an option of another editor by adding a checkbox to select whether a value is set or not. -
toggle
Creates a toggle editor for a set of elements. This can be a single button that cycles on click or a sub screen so select the element, depending on the number of elements given. -
toggle
static <T> ConfigEditor<T> toggle(List<T> elems, Function<T, net.minecraft.network.chat.Component> name) Creates a toggle editor for a set of elements. This can be a single button that cycles on click or a sub screen so select the element, depending on the number of elements given.- Parameters:
name
- A function that defines how to convert elements into aComponent
for display.
-
input
Creates a new text input editor. -
input
Creates a new text input editor.- Parameters:
validator
- Validator information used. This causes the widget to go red when invalid values are entered.
-
input
Creates a new text input editor.- Parameters:
input
- Information on which input to allow and how to process that input.
-
input
Creates a new text input editor.- Parameters:
input
- Information on which input to allow and how to process that input.validator
- Validator information used. This causes the widget to go red when invalid values are entered.
-
slider
Creates a new editor for a slider. -
custom
static <T> ConfigEditor<T> custom(T defaultValue, Function<T, ConfigScreenContent<T>> contentFactory) Creates a config editor with a button that will then open a sub-screen based on the givencontent
.- Parameters:
contentFactory
- A function that creates a new screen content from a given initial value.
-