Class DropDown<T>
java.lang.Object
com.pixelmonmod.pixelmon.client.gui.widgets.DropDown<T>
A drop-down menu used to select a certain option in a list.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The height of one option in the menu. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if an option was selected in the current mouse press.Gets the currently selected option.int
Gets the index of the currently selected option.int
getTop()
Gets the y coordinate of the top of the menu when inactive.boolean
returns true if this textbox is visibleboolean
isMouseOver
(int mouseX, int mouseY) Gets the index of the element that the cursor is currently over.void
render
(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks, DropDown active) Draws the list to the screen.setGetOptionString
(Function<T, String> getOptionString) Sets the function used to convert an option to a string.setInactiveHeight
(int height) Sets the height of the menu when inactive.setInactiveTop
(int top) Sets the top of the menu when inactive.setOnSelected
(Consumer<T> onSelected) Sets a method to call when an option is selected.setOnSelectedIndex
(Consumer<Integer> onSelectedIndex) Sets a method to call when an option is selected.void
setOptions
(List<T> options, T selected) Sets the options in the list.Sorts the options in the menu by name.void
setSelected
(int selected) Sets the currently selected option.void
setSelected
(T selected) Sets the currently selected option.setTextAlign
(TextAlignment align) Sets the alignment of text in the menu.void
setVisible
(boolean isVisible) Sets whether or not this textbox is visible
-
Field Details
-
OPTION_HEIGHT
public static final int OPTION_HEIGHTThe height of one option in the menu.- See Also:
-
-
Constructor Details
-
DropDown
Initializes the menu.- Parameters:
options
- The options that can be selected in the list.selected
- The index of the currently selected option.left
- The x coordinate of the left side of the slot.top
- The y coordinate of the top of the slot.width
- The width of the slot.height
- The height of the slot.
-
DropDown
public DropDown(List<T> options, int selected, int left, int top, int width, int height, int dropDownWidth) Initializes the menu.- Parameters:
options
- The options that can be selected in the list.selected
- The index of the currently selected option.left
- The x coordinate of the left side of the slot.top
- The y coordinate of the top of the slot.width
- The width of the slot.height
- The height of the slot.dropDownWidth
- The width of the dropdown box
-
DropDown
Initializes the menu.- Parameters:
options
- The options that can be selected in the list.selected
- The currently selected option.left
- The x coordinate of the left side of the slot.top
- The y coordinate of the top of the slot.width
- The width of the slot.height
- The height of the slot.
-
DropDown
public DropDown(List<T> options, T selected, int left, int top, int width, int height, int dropDownWidth) Initializes the menu with extended dropdown width- Parameters:
options
- The options that can be selected in the list.selected
- The currently selected option.left
- The x coordinate of the left side of the slot.top
- The y coordinate of the top of the slot.width
- The width of the slot.height
- The height of the slot.
-
-
Method Details
-
setOptions
Sets the options in the list.- Parameters:
options
- The options that can be selected in the list.selected
- The index of the currently selected option.
-
setSelected
Sets the currently selected option.- Parameters:
selected
- The currently selected option.
-
setSelected
public void setSelected(int selected) Sets the currently selected option.- Parameters:
selected
- The index of the currently selected option.
-
setInactiveTop
Sets the top of the menu when inactive.- Parameters:
top
- The y coordinate of the top of the menu when inactive.- Returns:
- The menu instance.
-
setInactiveHeight
Sets the height of the menu when inactive.- Parameters:
height
- The y coordinate of the top of the menu when inactive.- Returns:
- The menu instance.
-
setTextAlign
Sets the alignment of text in the menu.- Parameters:
align
- The alignment of text in the menu.- Returns:
- The menu instance.
-
setGetOptionString
Sets the function used to convert an option to a string.- Parameters:
getOptionString
- The function used to convert an option to a string.- Returns:
- The menu instance.
-
setOnSelected
Sets a method to call when an option is selected.- Parameters:
onSelected
- The method to call when an option is selected.- Returns:
- The menu instance.
-
setOnSelectedIndex
Sets a method to call when an option is selected.- Parameters:
onSelectedIndex
- The method to call when an option is selected.- Returns:
- The menu instance.
-
setOrdered
Sorts the options in the menu by name.- Returns:
- The menu instance.
-
getSelected
Gets the currently selected option.- Returns:
- The currently selected option.
-
render
public void render(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks, DropDown active) Draws the list to the screen.- Parameters:
mouseX
- The x coordinate of the mouse.mouseY
- The y coordinate of the mouse.partialTicks
- The current number of partial ticks.
-
isMouseOver
public boolean isMouseOver(int mouseX, int mouseY) Gets the index of the element that the cursor is currently over.- Parameters:
mouseX
- The x coordinate of the cursor.mouseY
- The y coordinate of the cursor.- Returns:
- The index of the element that the cursor is currently over, or -1 if the cursor is not over the list.
-
getLastSelected
public boolean getLastSelected()Checks if an option was selected in the current mouse press.- Returns:
- Whether an option was selected in the current mouse press.
-
getTop
public int getTop()Gets the y coordinate of the top of the menu when inactive.- Returns:
- The y coordinate of the top of the menu when inactive.
-
getSelectedIndex
public int getSelectedIndex()Gets the index of the currently selected option.- Returns:
- The index of the currently selected option.
-
getVisible
public boolean getVisible()returns true if this textbox is visible -
setVisible
public void setVisible(boolean isVisible) Sets whether or not this textbox is visible
-