Class ConfigurationScreen.ConfigurationListScreen<T>
- All Implemented Interfaces:
ContainerEventHandler,GuiEventListener,Renderable,TabOrderedElement
- Enclosing class:
ConfigurationScreen
This class is automatically used if you use NeoForge's generic configuration UI, see ConfigurationScreen.
If you have special needs, you can subclass this class to achieve the desired behaviour. For example:
- To change how the label and buttons for the individual elements look, override
createListLabel(int). - To use another UI element, override the matching
create*Value()method and return your new UI element wrapped in aConfigurationScreen.ConfigurationSectionScreen.Element. - To add additional (synthetic) config values, override
rebuild()and add them tolist. (ConfigurationScreen.ConfigurationSectionScreen.createSyntheticValues()is not used for lists). - To be notified on each changed value instead of getting one
ModConfigEventat the end, overrideonChanged(String)on theConfigurationScreen, not here. The list will only be updated in theModConfigSpec.ConfigValuewhen this screen is closed. - To limit the number of elements in a list, pass a
ModConfigSpec.RangetoModConfigSpec.Builder.defineList(List, Supplier, Supplier, Predicate, Range).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA widget to be used as a label in a list of configuration values.Nested classes/interfaces inherited from class net.neoforged.neoforge.client.gui.ConfigurationScreen.ConfigurationSectionScreen
ConfigurationScreen.ConfigurationSectionScreen.Context, ConfigurationScreen.ConfigurationSectionScreen.Custom<T>, ConfigurationScreen.ConfigurationSectionScreen.Element, ConfigurationScreen.ConfigurationSectionScreen.FilterNested classes/interfaces inherited from class net.minecraft.client.gui.screens.Screen
Screen.NarratableSearchResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final ModConfigSpec.ListValueSpecprotected final ModConfigSpec.ConfigValue<List<T>> Fields inherited from class net.neoforged.neoforge.client.gui.ConfigurationScreen.ConfigurationSectionScreen
changed, context, doneButton, MAX_SLIDER_SIZE, needsRestart, resetButton, sectionCache, undoButton, undoManagerFields inherited from class net.minecraft.client.gui.screens.options.OptionsSubScreen
lastScreen, layout, list, optionsFields inherited from class net.minecraft.client.gui.screens.Screen
CUBE_MAP, font, FOOTER_SEPARATOR, HEADER_SEPARATOR, height, INWORLD_FOOTER_SEPARATOR, INWORLD_HEADER_SEPARATOR, MENU_BACKGROUND, minecraft, narratorButton, PANORAMA, renderables, screenExecutor, title, widthFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
ConstructorsConstructorDescriptionConfigurationListScreen(ConfigurationScreen.ConfigurationSectionScreen.Context context, String key, Component title, ModConfigSpec.ListValueSpec spec, ModConfigSpec.ConfigValue<List<T>> valueList) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanaddUndoListener(boolean simulate, List<T> values) protected voidCreates a button to add a new element to the end of the list and adds it to the UI.protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.ElementcreateBooleanListValue(int idx, Boolean value) protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.ElementcreateDoubleListValue(int idx, Double value) protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.ElementcreateIntegerListValue(int idx, Integer value) protected AbstractWidgetcreateListLabel(int idx) Creates a new widget to label a list value and provide manipulation buttons for it.protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.ElementcreateLongListValue(int idx, Long value) protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.ElementcreateOtherValue(int idx, T entry) Called when a list element is found that has an unknown or unsupported data type.protected voidprotected @Nullable ConfigurationScreen.ConfigurationSectionScreen.ElementcreateStringListValue(int idx, String value) protected booleandel(int idx, boolean simulate) Remove the given element.protected booleanprotected voidThis is called whenever a value is changed and the change is submitted to the appropriateConfigSpec.voidonClose()rebuild()voidrender(GuiGraphics graphics, int p_281550_, int p_282878_, float p_282465_) Neo: mixins targeting this method won't fire for container screens asAbstractContainerScreen.render(net.minecraft.client.gui.GuiGraphics, int, int, float)replicates this method in place of a super call to insert an eventprotected booleanswap(int idx, boolean simulate) Swap the given element with the next one.Methods inherited from class net.neoforged.neoforge.client.gui.ConfigurationScreen.ConfigurationSectionScreen
addFooter, addOptions, createBooleanValue, createDoubleValue, createEnumValue, createIntegerValue, createList, createLongValue, createNumberBox, createOtherSection, createOtherValue, createSection, createSlider, createStringValue, createSyntheticValues, createUndoButton, getComment, getTooltip, getTooltipComponent, getTranslationComponent, getTranslationKey, getValueSpec, isNonDefault, isPartialNumber, setResetButtonstate, setUndoButtonstateMethods inherited from class net.minecraft.client.gui.screens.options.OptionsSubScreen
addContents, addTitle, init, removed, repositionElementsMethods inherited from class net.minecraft.client.gui.screens.Screen
added, addRenderableOnly, addRenderableWidget, addWidget, afterKeyboardAction, afterMouseAction, afterMouseMove, changeFocus, children, clearFocus, clearTooltipForNextRenderPass, clearWidgets, fillCrashDetails, findNarratableWidget, getBackgroundMusic, getFont, getMinecraft, getNarrationMessage, getRectangle, getTitle, getTooltipFromItem, getUsageNarration, handleComponentClicked, handleDelayedNarration, hasAltDown, hasControlDown, hasShiftDown, init, insertText, isCopy, isCut, isMouseOver, isPaste, isPauseScreen, isSelectAll, isValidCharacterForName, keyPressed, onFilesDrop, rebuildWidgets, removeWidget, renderBackground, renderBlurredBackground, renderMenuBackground, renderMenuBackground, renderMenuBackgroundTexture, renderPanorama, renderTransparentBackground, renderWithTooltip, resize, setInitialFocus, setInitialFocus, setTooltipForNextRenderPass, setTooltipForNextRenderPass, setTooltipForNextRenderPass, setTooltipForNextRenderPass, shouldCloseOnEsc, shouldNarrateNavigation, showsActiveEffects, tick, triggerImmediateNarration, updateNarratedWidget, updateNarrationState, updateNarratorStatusMethods inherited from class net.minecraft.client.gui.components.events.AbstractContainerEventHandler
getFocused, isDragging, setDragging, setFocusedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.ContainerEventHandler
charTyped, getChildAt, getCurrentFocusPath, isFocused, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, nextFocusPath, setFocusedMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getBorderForArrowNavigation, mouseMovedMethods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Field Details
-
key
-
spec
-
valueList
-
cfgList
-
-
Constructor Details
-
ConfigurationListScreen
public ConfigurationListScreen(ConfigurationScreen.ConfigurationSectionScreen.Context context, String key, Component title, ModConfigSpec.ListValueSpec spec, ModConfigSpec.ConfigValue<List<T>> valueList)
-
-
Method Details
-
rebuild
- Overrides:
rebuildin classConfigurationScreen.ConfigurationSectionScreen
-
isAnyNondefault
protected boolean isAnyNondefault()- Overrides:
isAnyNondefaultin classConfigurationScreen.ConfigurationSectionScreen
-
createAddElementButton
protected void createAddElementButton()Creates a button to add a new element to the end of the list and adds it to the UI.Override this if you want a different button or want to add more elements.
-
createListLabel
Creates a new widget to label a list value and provide manipulation buttons for it.Override this if you want different labels/buttons.
- Parameters:
idx- The index into the list.- Returns:
- An
AbstractWidgetto be rendered in the left column of the options screen
-
createOtherValue
@Nullable protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.Element createOtherValue(int idx, T entry) Called when a list element is found that has an unknown or unsupported data type. Override this to produce whatever UI elements are appropriate for this object.Note that all types of elements that can be read from the config file as part of a list are already supported. You only need this if you manipulate the contents of the list after it has been loaded.
If this returns null, no row will be shown on the screen, but the up/down buttons will still see your element. Which means that the user will see no change when moving another element over the hidden line. Consider returning a
StringWidgetas a placeholder instead.Do not capture
cfgListhere or in another create*Value() method. The undo/reset system will replace the list, so you need to always access the field. You can (and should) capture the index.- Parameters:
idx- The index into the list.entry- The entry itself.- Returns:
- null if this element should be skipped or an
ConfigurationScreen.ConfigurationSectionScreen.Elementto be added to the UI.
-
createStringListValue
@Nullable protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.Element createStringListValue(int idx, String value) -
createDoubleListValue
@Nullable protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.Element createDoubleListValue(int idx, Double value) -
createLongListValue
@Nullable protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.Element createLongListValue(int idx, Long value) -
createIntegerListValue
@Nullable protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.Element createIntegerListValue(int idx, Integer value) -
createBooleanListValue
@Nullable protected @Nullable ConfigurationScreen.ConfigurationSectionScreen.Element createBooleanListValue(int idx, Boolean value) -
swap
protected boolean swap(int idx, boolean simulate) Swap the given element with the next one. Should be called by the list label widget to manipulate the list. -
del
protected boolean del(int idx, boolean simulate) Remove the given element. Should be called by the list label widget to manipulate the list. -
addUndoListener
-
onClose
public void onClose()- Overrides:
onClosein classConfigurationScreen.ConfigurationSectionScreen
-
render
Description copied from class:ScreenNeo: mixins targeting this method won't fire for container screens asAbstractContainerScreen.render(net.minecraft.client.gui.GuiGraphics, int, int, float)replicates this method in place of a super call to insert an event- Specified by:
renderin interfaceRenderable- Overrides:
renderin classConfigurationScreen.ConfigurationSectionScreen- Parameters:
graphics- the GuiGraphics object used for rendering.p_281550_- the x-coordinate of the mouse cursor.p_282878_- the y-coordinate of the mouse cursor.p_282465_- the partial tick time.
-
onChanged
Description copied from class:ConfigurationScreen.ConfigurationSectionScreenThis is called whenever a value is changed and the change is submitted to the appropriateConfigSpec.- Overrides:
onChangedin classConfigurationScreen.ConfigurationSectionScreen- Parameters:
key- The key of the changed configuration. To get an absolute key, useConfigurationScreen.ConfigurationSectionScreen.Context.makeKeyList(String).
-
createResetButton
protected void createResetButton()- Overrides:
createResetButtonin classConfigurationScreen.ConfigurationSectionScreen
-