Class TConfigPanelBuilder<T extends TConfigPanelBuilder<T>>
java.lang.Object
io.github.thecsdev.tcdcommons.api.client.gui.config.TConfigPanelBuilder<T>
A utility for creating config GUIs in
TPanelElement
s.-
Field Summary
Modifier and TypeFieldDescriptionprotected @Nullable TElement
protected @Nullable Runnable
protected final TPanelElement
static final net.minecraft.text.Text
static final net.minecraft.text.Text
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal T
addCheckbox
(net.minecraft.text.Text text, boolean value, Consumer<TCheckboxWidget> applyValue) addCheckboxB
(net.minecraft.text.Text text, boolean value, Consumer<TCheckboxWidget> applyValue) final T
addLabel
(net.minecraft.text.Text text) addLabelB
(net.minecraft.text.Text text) final T
This method's name may be a bit misleading, as all it does is callsetOnSave(Runnable)
.static TConfigPanelBuilder
<?> builder
(TPanelElement target) Creates a newTConfigPanelBuilder
instance and returns it.final @Nullable TElement
Returns theTElement
that was last added via thisTConfigPanelBuilder
.final TPanelElement
Returns thetargetPanel
onto which the config GUI is being built.static final int
nextPanelBottomY
(TPanelElement panel) Returns the next free (global) Y coordinate at which to place the nextTElement
that will be added to a givenTPanelElement
.static final Rectangle
Returns the next free (global-coordinate) space in the vertical direction for the nextTElement
that will be added to a givenTPanelElement
.final void
Iterates over entries in theapplyActions
Map
, and uses them to apply and save any changes made by the user.protected final T
self()
final void
Sets theonSave
Runnable
action that will be invoked oncesaveChanges()
is called, and all the config changes are applied.protected int
vMargin()
Returns the "vertical margin" that should be applied next.
-
Field Details
-
TEXT_SAVE
public static final net.minecraft.text.Text TEXT_SAVE -
TEXT_CANCEL
public static final net.minecraft.text.Text TEXT_CANCEL -
applyActions
-
onSave
-
targetPanel
-
lastAddedElement
-
-
Constructor Details
-
TConfigPanelBuilder
- Throws:
NullPointerException
-
-
Method Details
-
self
-
builder
Creates a newTConfigPanelBuilder
instance and returns it.- Parameters:
target
- TheTPanelElement
onto which the config GUI will be built.
-
build
This method's name may be a bit misleading, as all it does is callsetOnSave(Runnable)
.- Parameters:
onSave
- SeesetOnSave(Runnable)
.
-
getTargetPanel
Returns thetargetPanel
onto which the config GUI is being built. -
getLastAddedElement
Returns theTElement
that was last added via thisTConfigPanelBuilder
. -
setOnSave
Sets theonSave
Runnable
action that will be invoked oncesaveChanges()
is called, and all the config changes are applied. -
saveChanges
public final void saveChanges()Iterates over entries in theapplyActions
Map
, and uses them to apply and save any changes made by the user. -
vMargin
protected int vMargin()Returns the "vertical margin" that should be applied next. -
addLabel
-
addLabelB
-
addCheckbox
public final T addCheckbox(net.minecraft.text.Text text, boolean value, Consumer<TCheckboxWidget> applyValue) -
addCheckboxB
public TCheckboxWidget addCheckboxB(net.minecraft.text.Text text, boolean value, Consumer<TCheckboxWidget> applyValue) -
nextPanelBottomY
Returns the next free (global) Y coordinate at which to place the nextTElement
that will be added to a givenTPanelElement
. -
nextPanelVerticalRect
Returns the next free (global-coordinate) space in the vertical direction for the nextTElement
that will be added to a givenTPanelElement
.
-