Class DropDownWidget<T>

java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.AbstractScrollWidget
com.pixelmonmod.pixelmon.client.gui.npc.widget.DropDownWidget<T>
All Implemented Interfaces:
net.minecraft.client.gui.components.events.GuiEventListener, net.minecraft.client.gui.components.Renderable, net.minecraft.client.gui.components.TabOrderedElement, net.minecraft.client.gui.layouts.LayoutElement, net.minecraft.client.gui.narration.NarratableEntry, net.minecraft.client.gui.narration.NarrationSupplier

public class DropDownWidget<T> extends net.minecraft.client.gui.components.AbstractScrollWidget
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry

    net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected net.minecraft.client.gui.components.EditBox
     
    protected it.unimi.dsi.fastutil.booleans.BooleanConsumer
     
    protected Consumer<T>
     
    static final int
     
    protected Function<T,String>
     
    protected List<T>
     
    protected List<T>
     
    protected T
     

    Fields inherited from class net.minecraft.client.gui.components.AbstractScrollWidget

    scrollAmount, scrolling

    Fields inherited from class net.minecraft.client.gui.components.AbstractWidget

    alpha, focused, height, hoverOrFocusedStartTime, isHovered, message, MIN_SCROLL_PERIOD, packedFGColor, PERIOD_PER_SCROLLED_PIXEL, tabOrderGroup, tooltip, tooltipMsDelay, UNSET_FG_COLOR, wasHoveredOrFocused, width, x, y

    Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    DOUBLE_CLICK_THRESHOLD_MS
  • Constructor Summary

    Constructors
    Constructor
    Description
    DropDownWidget(int width, int height)
     
    DropDownWidget(int x, int y, int width, int height)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    charTyped(char character, int modifiers)
     
    protected String
    convertOption(T option)
     
    protected T
    findElementFor(double mouseX, double mouseY)
    Finds the row in the list that the cursor is hovering over.
    int
     
    protected int
     
    protected int
     
     
    int
     
    boolean
    isMouseOver(double mouseX, double mouseY)
     
    boolean
    keyPressed(int keyCode, int scanCode, int modifiers)
     
    boolean
    mouseClicked(double mouseX, double mouseY, int button)
     
    boolean
    mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
     
    void
    onClick(double mouseX, double mouseY)
     
    protected void
    renderBackground(net.minecraft.client.gui.GuiGraphics graphics)
     
    protected void
    renderContents(net.minecraft.client.gui.GuiGraphics gui, int mouseX, int mouseY, float partialTicks)
    Renders the list of options that opens up (aka that drops-down) upon opening the drop-down.
    protected void
    renderDecorations(net.minecraft.client.gui.GuiGraphics p_283178_)
     
    void
    renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
     
    protected boolean
     
    protected double
     
    void
    setMaxVisibleOptions(int maxNumberOfOptions)
    Sets the maximum number of the drop-down's contents that will be displayed upon opening it up.
    void
    setOnDropDownToggle(it.unimi.dsi.fastutil.booleans.BooleanConsumer onDropDownToggle)
     
    setOnSelected(Consumer<T> onSelected)
     
    setOptionConverter(Function<T,String> optionConverter)
     
    void
    setOptions(List<T> options, T selected)
     
     
    void
    setSelected(T selected)
     
    void
    setWidth(int value)
     
    protected void
    updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput p_259858_)
     

    Methods inherited from class net.minecraft.client.gui.components.AbstractScrollWidget

    innerPadding, mouseReleased, mouseScrolled, renderBorder, scrollAmount, scrollbarWidth, setScrollAmount, totalInnerPadding, withinContentAreaPoint, withinContentAreaTopBottom

    Methods inherited from class net.minecraft.client.gui.components.AbstractWidget

    clearFGColor, clicked, createNarrationMessage, createTooltipPositioner, defaultButtonNarrationText, getFGColor, getMessage, getRectangle, getTabOrderGroup, getTooltip, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isValidClickButton, narrationPriority, nextFocusPath, onDrag, onRelease, playDownSound, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setFocused, setHeight, setMessage, setTabOrderGroup, setTooltip, setTooltipDelay, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessage

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    getCurrentFocusPath, getRectangle, isFocused, keyReleased, mouseMoved, nextFocusPath, setFocused

    Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement

    setPosition

    Methods inherited from interface net.minecraft.client.gui.components.Renderable

    render

    Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement

    getTabOrderGroup
  • Field Details

    • OPTION_HEIGHT

      public static final int OPTION_HEIGHT
      See Also:
    • editBox

      protected net.minecraft.client.gui.components.EditBox editBox
    • originalOptions

      protected List<T> originalOptions
    • options

      protected List<T> options
    • selectedOption

      protected T selectedOption
    • onSelected

      protected Consumer<T> onSelected
    • onDropDownToggle

      protected it.unimi.dsi.fastutil.booleans.BooleanConsumer onDropDownToggle
    • optionConverter

      protected Function<T,String> optionConverter
    • active

      protected boolean active
  • Constructor Details

    • DropDownWidget

      public DropDownWidget(int width, int height)
    • DropDownWidget

      public DropDownWidget(int x, int y, int width, int height)
  • Method Details

    • setOptions

      public void setOptions(List<T> options, T selected)
    • setWidth

      public void setWidth(int value)
      Overrides:
      setWidth in class net.minecraft.client.gui.components.AbstractWidget
    • setSelected

      public void setSelected(T selected)
    • setOptionConverter

      public DropDownWidget<T> setOptionConverter(Function<T,String> optionConverter)
    • setOnSelected

      public DropDownWidget<T> setOnSelected(Consumer<T> onSelected)
    • setOrdered

      public DropDownWidget<T> setOrdered()
    • setOnDropDownToggle

      public void setOnDropDownToggle(it.unimi.dsi.fastutil.booleans.BooleanConsumer onDropDownToggle)
    • getSelected

      public T getSelected()
    • scrollRate

      protected double scrollRate()
      Specified by:
      scrollRate in class net.minecraft.client.gui.components.AbstractScrollWidget
    • renderWidget

      public void renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
      Overrides:
      renderWidget in class net.minecraft.client.gui.components.AbstractScrollWidget
    • renderDecorations

      protected void renderDecorations(net.minecraft.client.gui.GuiGraphics p_283178_)
      Overrides:
      renderDecorations in class net.minecraft.client.gui.components.AbstractScrollWidget
    • findElementFor

      protected T findElementFor(double mouseX, double mouseY)
      Finds the row in the list that the cursor is hovering over.
      Parameters:
      mouseX - The cursor's x coordinates.
      mouseY - The cursor's y coordinates.
      Returns:
      The element in the drop-down's list of options that the cursor is hovering over.
    • renderContents

      protected void renderContents(net.minecraft.client.gui.GuiGraphics gui, int mouseX, int mouseY, float partialTicks)
      Renders the list of options that opens up (aka that drops-down) upon opening the drop-down.
      Specified by:
      renderContents in class net.minecraft.client.gui.components.AbstractScrollWidget
      Parameters:
      gui - The PoseStack matrix
      mouseX - The cursor's x position.
      mouseY - The cursor's y position.
      partialTicks - The number of partial ticks that have elapsed.
    • renderBackground

      protected void renderBackground(net.minecraft.client.gui.GuiGraphics graphics)
      Overrides:
      renderBackground in class net.minecraft.client.gui.components.AbstractScrollWidget
    • mouseClicked

      public boolean mouseClicked(double mouseX, double mouseY, int button)
      Specified by:
      mouseClicked in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      mouseClicked in class net.minecraft.client.gui.components.AbstractScrollWidget
    • onClick

      public void onClick(double mouseX, double mouseY)
      Overrides:
      onClick in class net.minecraft.client.gui.components.AbstractWidget
    • mouseDragged

      public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
      Specified by:
      mouseDragged in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      mouseDragged in class net.minecraft.client.gui.components.AbstractScrollWidget
    • keyPressed

      public boolean keyPressed(int keyCode, int scanCode, int modifiers)
      Specified by:
      keyPressed in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      keyPressed in class net.minecraft.client.gui.components.AbstractScrollWidget
    • charTyped

      public boolean charTyped(char character, int modifiers)
    • updateWidgetNarration

      protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput p_259858_)
      Specified by:
      updateWidgetNarration in class net.minecraft.client.gui.components.AbstractWidget
    • convertOption

      protected String convertOption(T option)
    • getInnerHeight

      protected int getInnerHeight()
      Specified by:
      getInnerHeight in class net.minecraft.client.gui.components.AbstractScrollWidget
    • scrollbarVisible

      protected boolean scrollbarVisible()
      Overrides:
      scrollbarVisible in class net.minecraft.client.gui.components.AbstractScrollWidget
    • getMaxScrollAmount

      protected int getMaxScrollAmount()
      Overrides:
      getMaxScrollAmount in class net.minecraft.client.gui.components.AbstractScrollWidget
    • getHeight

      public int getHeight()
      Specified by:
      getHeight in interface net.minecraft.client.gui.layouts.LayoutElement
      Overrides:
      getHeight in class net.minecraft.client.gui.components.AbstractWidget
    • isMouseOver

      public boolean isMouseOver(double mouseX, double mouseY)
      Specified by:
      isMouseOver in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      isMouseOver in class net.minecraft.client.gui.components.AbstractWidget
    • getWidth

      public int getWidth()
      Specified by:
      getWidth in interface net.minecraft.client.gui.layouts.LayoutElement
      Overrides:
      getWidth in class net.minecraft.client.gui.components.AbstractWidget
    • setMaxVisibleOptions

      public void setMaxVisibleOptions(int maxNumberOfOptions)
      Sets the maximum number of the drop-down's contents that will be displayed upon opening it up.
      Parameters:
      maxNumberOfOptions - The maximum items the drop-down should show.