类 ForgeSlider
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.AbstractSliderButton
net.minecraftforge.client.gui.widget.ForgeSlider
- 所有已实现的接口:
GuiEventListener
,Renderable
,TabOrderedElement
,LayoutElement
,NarratableEntry
,NarrationSupplier
Slider widget implementation which allows inputting values in a certain range with optional step size.
-
嵌套类概要
从接口继承的嵌套类/接口 net.minecraft.client.gui.narration.NarratableEntry
NarratableEntry.NarrationPriority
-
字段概要
字段修饰符和类型字段说明protected boolean
private final DecimalFormat
protected double
protected double
protected Component
protected double
Allows input of discontinuous values with a certain stepprotected Component
从类继承的字段 net.minecraft.client.gui.components.AbstractSliderButton
TEXT_MARGIN, value
从类继承的字段 net.minecraft.client.gui.components.AbstractWidget
active, alpha, height, isHovered, packedFGColor, UNSET_FG_COLOR, visible, width
从接口继承的字段 net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS
-
构造器概要
构造器构造器说明ForgeSlider
(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) Overload withstepSize
set to 1, useful for sliders with whole number values.ForgeSlider
(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) -
方法概要
修饰符和类型方法说明protected void
double
getValue()
int
long
boolean
keyPressed
(int keyCode, int scanCode, int modifiers) void
onClick
(double mouseX, double mouseY) protected void
onDrag
(double mouseX, double mouseY, double dragX, double dragY) void
renderWidget
(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) private void
setSliderValue
(double value) void
setValue
(double value) private void
setValueFromMouse
(double mouseX) private double
snapToNearest
(double value) Snaps the value, so that the displayed value is the nearest multiple ofstepSize
.protected void
从类继承的方法 net.minecraft.client.gui.components.AbstractSliderButton
createNarrationMessage, getHandleSprite, getSprite, onRelease, playDownSound, setFocused, updateWidgetNarration
从类继承的方法 net.minecraft.client.gui.components.AbstractWidget
clearFGColor, defaultButtonNarrationText, getBottom, getFGColor, getHeight, getMessage, getRectangle, getRight, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isMouseOver, isValidClickButton, mouseClicked, mouseDragged, mouseReleased, narrationPriority, nextFocusPath, playButtonClickSound, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setHeight, setMessage, setRectangle, setSize, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessage
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 net.minecraft.client.gui.components.events.GuiEventListener
charTyped, getBorderForArrowNavigation, getCurrentFocusPath, keyReleased, mouseMoved, mouseScrolled
从接口继承的方法 net.minecraft.client.gui.layouts.LayoutElement
setPosition
从接口继承的方法 net.minecraft.client.gui.narration.NarratableEntry
getNarratables
-
字段详细资料
-
prefix
-
suffix
-
minValue
protected double minValue -
maxValue
protected double maxValue -
stepSize
protected double stepSizeAllows input of discontinuous values with a certain step -
drawString
protected boolean drawString -
format
-
-
构造器详细资料
-
ForgeSlider
public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) - 参数:
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
-
ForgeSlider
public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) Overload withstepSize
set to 1, useful for sliders with whole number values.
-
-
方法详细资料
-
getValue
public double getValue()- 返回:
- Current slider value as a double
-
getValueLong
public long getValueLong()- 返回:
- Current slider value as an long
-
getValueInt
public int getValueInt()- 返回:
- Current slider value as an int
-
setValue
public void setValue(double value) - 参数:
value
- The new slider value
-
getValueString
-
onClick
public void onClick(double mouseX, double mouseY) - 覆盖:
onClick
在类中AbstractSliderButton
-
onDrag
protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) - 覆盖:
onDrag
在类中AbstractSliderButton
-
keyPressed
public boolean keyPressed(int keyCode, int scanCode, int modifiers) - 指定者:
keyPressed
在接口中GuiEventListener
- 覆盖:
keyPressed
在类中AbstractSliderButton
-
setValueFromMouse
private void setValueFromMouse(double mouseX) -
setSliderValue
private void setSliderValue(double value) - 参数:
value
- Percentage of slider range
-
snapToNearest
private double snapToNearest(double value) Snaps the value, so that the displayed value is the nearest multiple ofstepSize
. IfstepSize
is 0, no snapping occurs. -
updateMessage
protected void updateMessage()- 指定者:
updateMessage
在类中AbstractSliderButton
-
applyValue
protected void applyValue()- 指定者:
applyValue
在类中AbstractSliderButton
-
renderWidget
- 覆盖:
renderWidget
在类中AbstractSliderButton
-