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,net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension
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, textShadowFields inherited from class net.minecraft.client.gui.components.AbstractWidget
active, alpha, height, isHovered, packedFGColor, UNSET_FG_COLOR, visible, width, x, yFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
ConstructorsConstructorDescriptionTabCompleteTranslateableTextField(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 TypeMethodDescriptionbooleancharTyped(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 voidcreateCompletionsFor(String leftOfCursor) voidcreateCompletionsForDropDown(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.voidfillDropDownWithCompletions(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.intintgetIndexOfDropDownOptionMouseIsOver(double mouseX, double mouseY) intbooleangetValue()voidinsertText(String newText) booleankeyPressed(int key, int scanCode, int modifiers) booleanmouseReleased(double mouseX, double mouseY, int button) voidonValueChange(String p_94175_) intrenderCompletionAsString(net.minecraft.client.gui.GuiGraphics graphics, int optionIndex, int dropDownOptionTextStartX, int dropDownOptionTextStartY) Render one of the completions without any fancy formatting or extra info.intrenderCompletionWithExtraInfoAsString(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.voidrenderEditBoxAsDropDown(net.minecraft.client.gui.GuiGraphics graphics) Renders an Edit Box larger to fit extra info.voidrenderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) voidrenderWidgetWithDropDown(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) voidsetDropDownOptionAmount(int amount) Sets the maximum amount of completions that this widget will render to the user.voidsetFocused(boolean focus) voidsetMinHeightPerDropDownOption(int amount) voidsetShowDropDown(boolean show) Turns on or off the rendering of the edit box as a large dropdown showing completions for the typed textvoidMethods inherited from class net.minecraft.client.gui.components.EditBox
canConsumeInput, createNarrationMessage, deleteChars, deleteCharsToPos, deleteWords, getCursorPosition, getHighlighted, getInnerWidth, getMaxLength, getScreenX, getTextShadow, getWordPosition, isBordered, isVisible, moveCursor, moveCursorTo, moveCursorToEnd, moveCursorToStart, onClick, playDownSound, renderHighlight, setBordered, setCanLoseFocus, setCursorPosition, setEditable, setFilter, setFormatter, setHighlightPos, setHint, setMaxLength, setResponder, setSuggestion, setTextColor, setTextColorUneditable, setTextShadow, setValue, setVisible, updateWidgetNarrationMethods inherited from class net.minecraft.client.gui.components.AbstractWidget
clearFGColor, clicked, defaultButtonNarrationText, getBottom, getFGColor, getHeight, getMessage, getRectangle, getRight, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isMouseOver, isValidClickButton, mouseClicked, mouseDragged, narrationPriority, nextFocusPath, onDrag, onRelease, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setHeight, setMessage, setRectangle, setSize, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getCurrentFocusPath, keyReleased, mouseMoved, mouseScrolledMethods inherited from interface net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension
onClickMethods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPositionMethods 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:
keyPressedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
keyPressedin classnet.minecraft.client.gui.components.EditBox
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button) - Specified by:
mouseReleasedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
mouseReleasedin classnet.minecraft.client.gui.components.AbstractWidget
-
getIndexOfDropDownOptionMouseIsOver
public int getIndexOfDropDownOptionMouseIsOver(double mouseX, double mouseY) -
getValue
- Overrides:
getValuein 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:
charTypedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
charTypedin classnet.minecraft.client.gui.components.EditBox- Parameters:
typedChar-keyCode-
-
createCompletionsFor
-
insertText
- Overrides:
insertTextin classnet.minecraft.client.gui.components.EditBox
-
onValueChange
-
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:
setFocusedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
setFocusedin classnet.minecraft.client.gui.components.EditBox
-
renderWidget
public void renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) - Overrides:
renderWidgetin 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
-