Class SliderWidget
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.AbstractSliderButton
net.minecraftforge.client.gui.widget.ForgeSlider
com.pixelmonmod.pixelmon.client.gui.npc.widget.SliderWidget
- 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 SliderWidget
extends net.minecraftforge.client.gui.widget.ForgeSlider
Slider Widget implementation allowing for Consumer actions upon setting values.
A slider looks like the FOV option in the settings menu.
-
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.minecraftforge.client.gui.widget.ForgeSlider
drawString, maxValue, minValue, prefix, stepSize, suffix
Fields inherited from class net.minecraft.client.gui.components.AbstractSliderButton
TEXT_MARGIN, value
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
ConstructorDescriptionSliderWidget
(int x, int y, int width, int height, net.minecraft.network.chat.Component prefix, net.minecraft.network.chat.Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) Overload withstepSize
set to 1, useful for sliders with whole number values.SliderWidget
(int x, int y, int width, int height, net.minecraft.network.chat.Component prefix, net.minecraft.network.chat.Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) -
Method Summary
Modifier and TypeMethodDescriptionboolean
keyPressed
(int keyCode, int scanCode, int modifiers) void
onClick
(double mouseX, double mouseY) protected void
onDrag
(double mouseX, double mouseY, double dragX, double dragY) setOnSelected
(Consumer<Double> onSelected) void
setSelected
(Double selected) protected void
setSliderValue
(double value) void
setValue
(double value) protected void
setValueFromMouse
(double mouseX) protected double
snapToNearest
(double value) Snaps the value, so that the displayed value is the nearest multiple ofstepSize
.Methods inherited from class net.minecraftforge.client.gui.widget.ForgeSlider
applyValue, getValue, getValueInt, getValueLong, getValueString, renderWidget, updateMessage
Methods inherited from class net.minecraft.client.gui.components.AbstractSliderButton
createNarrationMessage, getHandleSprite, getSprite, onRelease, playDownSound, setFocused, 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, isMouseOver, isValidClickButton, mouseClicked, mouseDragged, mouseReleased, narrationPriority, nextFocusPath, 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
charTyped, getCurrentFocusPath, keyReleased, mouseMoved, mouseScrolled
Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPosition
-
Field Details
-
onSelected
-
-
Constructor Details
-
SliderWidget
public SliderWidget(int x, int y, int width, int height, net.minecraft.network.chat.Component prefix, net.minecraft.network.chat.Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) - Parameters:
x
- x position of upper left cornery
- y position of upper left cornerwidth
- Width of the widgetheight
- Height of the widgetprefix
-Component
displayed before the value stringsuffix
-Component
displayed after the value stringminValue
- Minimum (left) value of slidermaxValue
- Maximum (right) value of slidercurrentValue
- Starting value when widget is first displayedstepSize
- Size of step used. Precision will automatically be calculated based on this value if this value is not 0.precision
- Only used whenstepSize
is 0. Limited to a maximum of 4 (inclusive).drawString
- Should text be displayed on the widget
-
SliderWidget
public SliderWidget(int x, int y, int width, int height, net.minecraft.network.chat.Component prefix, net.minecraft.network.chat.Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) Overload withstepSize
set to 1, useful for sliders with whole number values.
-
-
Method Details
-
setValue
public void setValue(double value) - Overrides:
setValue
in classnet.minecraftforge.client.gui.widget.ForgeSlider
- Parameters:
value
- The new slider value
-
onClick
public void onClick(double mouseX, double mouseY) - Overrides:
onClick
in classnet.minecraftforge.client.gui.widget.ForgeSlider
-
onDrag
protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) - Overrides:
onDrag
in classnet.minecraftforge.client.gui.widget.ForgeSlider
-
setValueFromMouse
protected void setValueFromMouse(double mouseX) -
keyPressed
public boolean keyPressed(int keyCode, int scanCode, int modifiers) - Specified by:
keyPressed
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
keyPressed
in classnet.minecraftforge.client.gui.widget.ForgeSlider
-
setSliderValue
protected void setSliderValue(double value) - Parameters:
value
- Percentage of slider range
-
snapToNearest
protected double snapToNearest(double value) Snaps the value, so that the displayed value is the nearest multiple ofstepSize
. IfstepSize
is 0, no snapping occurs. -
setSelected
-
setOnSelected
-