Class TabCompleteTranslateableTextField<T extends ITranslatable>
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.EditBox
com.pixelmonmod.pixelmon.client.gui.widgets.TabCompleteTranslateableTextField<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 TabCompleteTranslateableTextField<T extends ITranslatable>
extends net.minecraft.client.gui.components.EditBox
Created by Jay113355 on 3/31/2020.
-
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 inherited from class net.minecraft.client.gui.components.EditBox
BACKWARDS, bordered, canLoseFocus, CURSOR_APPEND_CHARACTER, CURSOR_BLINK_INTERVAL_MS, CURSOR_INSERT_COLOR, CURSOR_INSERT_WIDTH, cursorPos, DEFAULT_TEXT_COLOR, displayPos, filter, focusedTime, font, formatter, FORWARDS, highlightPos, hint, isEditable, maxLength, responder, SPRITES, suggestion, textColor, textColorUneditable
Fields inherited from class net.minecraft.client.gui.components.AbstractWidget
active, alpha, focused, height, hoverOrFocusedStartTime, isHovered, message, MIN_SCROLL_PERIOD, packedFGColor, PERIOD_PER_SCROLLED_PIXEL, tabOrderGroup, tooltip, tooltipMsDelay, UNSET_FG_COLOR, visible, wasHoveredOrFocused, width, x, y
Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS
-
Constructor Summary
ConstructorDescriptionTabCompleteTranslateableTextField
(int componentId, net.minecraft.client.gui.Font fontrendererObj, int x, int y, int par5Width, int par6Height) TabCompleteTranslateableTextField
(int componentId, net.minecraft.client.gui.Font fontrendererObj, int x, int y, int par5Width, int par6Height, Pokemon pokemon) -
Method Summary
Modifier and TypeMethodDescriptionboolean
charTyped
(char typedChar, int keyCode) Call this method from your GuiScreen to process the keys into the textboxList<net.minecraft.network.chat.MutableComponent>
Creates the extra info for the Ability completion that is generated.protected void
createCompletionsFor
(String leftOfCursor) void
createCompletionsForDropDown
(String leftOfCursor) Adds the completions generated to a separate list that will only hold an amount set bysetDropDownOptionAmount(int)
.List<net.minecraft.network.chat.MutableComponent>
createImmutableAttackCompletionExtraInfoText
(ImmutableAttack immutableAttack) Creates the extra info for the Immutable Attack completion that is generated.List<net.minecraft.network.chat.MutableComponent>
Creates the extra info for the Species completion that is generated.void
fillDropDownWithCompletions
(net.minecraft.client.gui.GuiGraphics graphics) Holds the values that keep track of where the y position of the next auto-completion text should render.int
int
getIndexOfDropDownOptionMouseIsOver
(double mouseX, double mouseY) int
boolean
getValue()
void
insertText
(String newText) boolean
keyPressed
(int key, int scanCode, int modifiers) boolean
mouseReleased
(double mouseX, double mouseY, int button) int
renderCompletionAsString
(net.minecraft.client.gui.GuiGraphics graphics, int optionIndex, int dropDownOptionTextStartX, int dropDownOptionTextStartY) Render one of the completions without any fancy formatting or extra info.int
renderCompletionWithExtraInfoAsString
(net.minecraft.client.gui.GuiGraphics graphics, int dropDownOptionTextStartX, int dropDownOptionTextStartY, net.minecraft.network.chat.MutableComponent dropDownOptionText, List<net.minecraft.network.chat.MutableComponent> listOfDropDownOptionExtraInfoTextComponents) Renders the text for the one of the completions for the auto-complete/dropdown portion of this widget.void
renderEditBoxAsDropDown
(net.minecraft.client.gui.GuiGraphics graphics) Renders an Edit Box larger to fit extra info.void
renderWidget
(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) void
renderWidgetWithDropDown
(net.minecraft.client.gui.GuiGraphics graphics) Literally a duplicate ofEditBox.renderWidget(GuiGraphics, int, int, float)
except that the typed text is not centered and instead kept at the top of the edit box.setCompletions
(Collection<T> completions) void
setDropDownOptionAmount
(int amount) Sets the maximum amount of completions that this widget will render to the user.void
setFocused
(boolean focus) void
setMinHeightPerDropDownOption
(int amount) void
setShowDropDown
(boolean show) Turns on or off the rendering of the edit box as a large dropdown showing completions for the typed textvoid
Methods inherited from class net.minecraft.client.gui.components.EditBox
canConsumeInput, createNarrationMessage, deleteChars, deleteWords, getCursorPosition, getHighlighted, getInnerWidth, getMaxLength, getScreenX, getWordPosition, isBordered, isMouseOver, isVisible, moveCursor, moveCursorTo, moveCursorToEnd, moveCursorToStart, nextFocusPath, onClick, playDownSound, renderHighlight, setBordered, setCanLoseFocus, setCursorPosition, setEditable, setFilter, setFormatter, setHighlightPos, setHint, setMaxLength, setResponder, setSuggestion, setTextColor, setTextColorUneditable, setValue, setVisible, updateWidgetNarration
Methods inherited from class net.minecraft.client.gui.components.AbstractWidget
clearFGColor, clicked, createTooltipPositioner, defaultButtonNarrationText, getFGColor, getHeight, getMessage, getRectangle, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isValidClickButton, mouseClicked, mouseDragged, narrationPriority, onDrag, onRelease, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setHeight, setMessage, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, 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, keyReleased, mouseMoved, mouseScrolled
Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPosition
Methods inherited from interface net.minecraft.client.gui.components.Renderable
render
-
Constructor Details
-
TabCompleteTranslateableTextField
public TabCompleteTranslateableTextField(int componentId, net.minecraft.client.gui.Font fontrendererObj, int x, int y, int par5Width, int par6Height) -
TabCompleteTranslateableTextField
public TabCompleteTranslateableTextField(int componentId, net.minecraft.client.gui.Font fontrendererObj, int x, int y, int par5Width, int par6Height, Pokemon pokemon)
-
-
Method Details
-
setCompletions
-
keyPressed
public boolean keyPressed(int key, int scanCode, int modifiers) - Specified by:
keyPressed
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
keyPressed
in classnet.minecraft.client.gui.components.EditBox
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button) - Specified by:
mouseReleased
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
mouseReleased
in classnet.minecraft.client.gui.components.AbstractWidget
-
getIndexOfDropDownOptionMouseIsOver
public int getIndexOfDropDownOptionMouseIsOver(double mouseX, double mouseY) -
getValue
- Overrides:
getValue
in classnet.minecraft.client.gui.components.EditBox
-
getTranslatableValue
-
setValue
-
charTyped
public boolean charTyped(char typedChar, int keyCode) Call this method from your GuiScreen to process the keys into the textbox- Specified by:
charTyped
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
charTyped
in classnet.minecraft.client.gui.components.EditBox
- Parameters:
typedChar
-keyCode
-
-
createCompletionsFor
-
insertText
- Overrides:
insertText
in classnet.minecraft.client.gui.components.EditBox
-
getShowDropDown
public boolean getShowDropDown() -
setShowDropDown
public void setShowDropDown(boolean show) Turns on or off the rendering of the edit box as a large dropdown showing completions for the typed text- Parameters:
show
- true or false
-
getDropDownOptionAmount
public int getDropDownOptionAmount() -
setDropDownOptionAmount
public void setDropDownOptionAmount(int amount) Sets the maximum amount of completions that this widget will render to the user.- Parameters:
amount
- an integer
-
getMinHeightPerDropDownOption
public int getMinHeightPerDropDownOption() -
setMinHeightPerDropDownOption
public void setMinHeightPerDropDownOption(int amount) -
getDropDownOptions
-
setFocused
public void setFocused(boolean focus) - Specified by:
setFocused
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
setFocused
in classnet.minecraft.client.gui.components.EditBox
-
renderWidget
public void renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) - Overrides:
renderWidget
in classnet.minecraft.client.gui.components.EditBox
-
renderWidgetWithDropDown
public void renderWidgetWithDropDown(net.minecraft.client.gui.GuiGraphics graphics) Literally a duplicate ofEditBox.renderWidget(GuiGraphics, int, int, float)
except that the typed text is not centered and instead kept at the top of the edit box.- Parameters:
graphics
- The PoseStack matrix
-
renderEditBoxAsDropDown
public void renderEditBoxAsDropDown(net.minecraft.client.gui.GuiGraphics graphics) Renders an Edit Box larger to fit extra info.Gets the sprite for the Edit Box and then increases its size vertically so that it can fit the completions that this widget is generating for what the user is typing.
- Parameters:
graphics
- The PoseStack matrix
-
createCompletionsForDropDown
Adds the completions generated to a separate list that will only hold an amount set bysetDropDownOptionAmount(int)
.- Parameters:
leftOfCursor
- The text in the widget
-
fillDropDownWithCompletions
public void fillDropDownWithCompletions(net.minecraft.client.gui.GuiGraphics graphics) Holds the values that keep track of where the y position of the next auto-completion text should render. Calls a render function for the allowed amount of options to display the text for each auto-complete option.- Parameters:
graphics
- The PoseStack matrix
-
renderCompletionAsString
public int renderCompletionAsString(net.minecraft.client.gui.GuiGraphics graphics, int optionIndex, int dropDownOptionTextStartX, int dropDownOptionTextStartY) Render one of the completions without any fancy formatting or extra info.- Parameters:
graphics
- The PoseStack matrixoptionIndex
- which number completion this is, meaning we've rendered optionIndex-1 completions so fardropDownOptionTextStartX
- The starting x position of the textdropDownOptionTextStartY
- The starting y position of the text- Returns:
- the starting y position for the next completion text to render in the drop-down
-
renderCompletionWithExtraInfoAsString
public int renderCompletionWithExtraInfoAsString(net.minecraft.client.gui.GuiGraphics graphics, int dropDownOptionTextStartX, int dropDownOptionTextStartY, net.minecraft.network.chat.MutableComponent dropDownOptionText, List<net.minecraft.network.chat.MutableComponent> listOfDropDownOptionExtraInfoTextComponents) Renders the text for the one of the completions for the auto-complete/dropdown portion of this widget.- Parameters:
graphics
- The PoseStack matrixdropDownOptionTextStartX
- The starting x position of the textdropDownOptionTextStartY
- The starting y position of the textdropDownOptionText
- The text to display that is a completion that the user can tab to auto complete.listOfDropDownOptionExtraInfoTextComponents
- The extra info provided about the completion.- Returns:
- the starting y position for the next completion text to render in the drop down
-
createImmutableAttackCompletionExtraInfoText
public List<net.minecraft.network.chat.MutableComponent> createImmutableAttackCompletionExtraInfoText(ImmutableAttack immutableAttack) Creates the extra info for the Immutable Attack completion that is generated.Generates a list of components that are each one piece of extra info on the given attack. These will all be info on how the Pokemon for this widget could potentially learn the given attack.
- Parameters:
immutableAttack
- an attack that the user could potentially auto-complete via pressing tab- Returns:
- A list of components that are each a bit of extra info for the given attack
-
createSpeciesCompletionExtraInfoText
public List<net.minecraft.network.chat.MutableComponent> createSpeciesCompletionExtraInfoText(Species species) Creates the extra info for the Species completion that is generated.Generates a list of components that are each one piece of extra info on the given species.
- Parameters:
species
- a species of Pokémon that the user could potentially auto-complete via pressing tab- Returns:
- A list of components that are each a bit of extra info for the given species
-
createAbilityCompletionExtraInfoText
public List<net.minecraft.network.chat.MutableComponent> createAbilityCompletionExtraInfoText(Ability ability) Creates the extra info for the Ability completion that is generated.Generates a list of components that are each one piece of extra info on the given ability.
- Parameters:
ability
- an ability that the user could potentially auto-complete via pressing tab- Returns:
- A list of components that are each a bit of extra info for the given species
-