Class TConfigPanelBuilder<T extends TConfigPanelBuilder<T>>

java.lang.Object
io.github.thecsdev.tcdcommons.api.client.gui.config.TConfigPanelBuilder<T>

public class TConfigPanelBuilder<T extends TConfigPanelBuilder<T>> extends Object
A utility for creating config GUIs in TPanelElements.
  • 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

      protected final Map<TElement,Consumer<?>> applyActions
      Holds Consumer actions that are to be invoked for each TElement that was added to the targetPanel.
    • onSave

      @Nullable protected @Nullable Runnable onSave
    • targetPanel

      protected final TPanelElement targetPanel
    • lastAddedElement

      @Nullable protected @Nullable TElement lastAddedElement
  • Constructor Details

  • Method Details

    • self

      protected final T self()
    • builder

      public static TConfigPanelBuilder<?> builder(TPanelElement target)
      Creates a new TConfigPanelBuilder instance and returns it.
      Parameters:
      target - The TPanelElement onto which the config GUI will be built.
    • build

      public final T build(@Nullable @Nullable Runnable onSave)
      This method's name may be a bit misleading, as all it does is call setOnSave(Runnable).
      Parameters:
      onSave - See setOnSave(Runnable).
    • getTargetPanel

      public final TPanelElement getTargetPanel()
      Returns the targetPanel onto which the config GUI is being built.
    • getLastAddedElement

      @Nullable public final @Nullable TElement getLastAddedElement()
      Returns the TElement that was last added via this TConfigPanelBuilder.
    • setOnSave

      public final void setOnSave(@Nullable @Nullable Runnable onSave)
      Sets the onSave Runnable action that will be invoked once saveChanges() is called, and all the config changes are applied.
    • saveChanges

      public final void saveChanges()
      Iterates over entries in the applyActions 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

      public final T addLabel(net.minecraft.text.Text text)
    • addLabelB

      public TLabelElement addLabelB(net.minecraft.text.Text text)
    • 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

      public static final int nextPanelBottomY(TPanelElement panel)
      Returns the next free (global) Y coordinate at which to place the next TElement that will be added to a given TPanelElement.
    • nextPanelVerticalRect

      public static final Rectangle nextPanelVerticalRect(TPanelElement panel)
      Returns the next free (global-coordinate) space in the vertical direction for the next TElement that will be added to a given TPanelElement.