diff options
author | isXander <isxander@users.noreply.github.com> | 2022-09-19 19:11:13 +0100 |
---|---|---|
committer | isXander <isxander@users.noreply.github.com> | 2022-09-19 19:11:13 +0100 |
commit | de1c8a317226b58fe03497027136eaed1adfd808 (patch) | |
tree | 5f97d6d91bc37f83d8de8c6f4a335d06a014cee0 /src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java | |
parent | 904e4d61b6cf84c807a99e66fc70527b01ae6fcc (diff) | |
download | YetAnotherConfigLib-de1c8a317226b58fe03497027136eaed1adfd808.tar.gz YetAnotherConfigLib-de1c8a317226b58fe03497027136eaed1adfd808.tar.bz2 YetAnotherConfigLib-de1c8a317226b58fe03497027136eaed1adfd808.zip |
1.4.0
improved tooltips
`ButtonOption` now consumes itself, so you can access it when building.
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java')
-rw-r--r-- | src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java index 0f34e61..e59c06c 100644 --- a/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java @@ -1,19 +1,13 @@ package dev.isxander.yacl.gui; -import dev.isxander.yacl.impl.YACLConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.MultilineText; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.OrderedText; import net.minecraft.text.Text; -import java.util.List; - public class TooltipButtonWidget extends ButtonWidget { - protected float hoveredTicks = 0; - protected int prevMouseX, prevMouseY; protected final Screen screen; protected MultilineText wrappedDescription; @@ -24,27 +18,13 @@ public class TooltipButtonWidget extends ButtonWidget { setTooltip(tooltip); } - @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { - super.render(matrices, mouseX, mouseY, delta); - - if (isHovered() && (!YACLConstants.HOVER_MOUSE_RESET || (prevMouseX == mouseX && prevMouseY == mouseY))) { - hoveredTicks += delta; - } else { - hoveredTicks = 0; - } - - prevMouseX = mouseX; - prevMouseY = mouseY; - } - - public void renderHoveredTooltip(MatrixStack matrices, int mouseX, int mouseY) { - if (hoveredTicks >= YACLConstants.HOVER_TICKS) { - YACLScreen.renderMultilineTooltip(matrices, MinecraftClient.getInstance().textRenderer, wrappedDescription, mouseX, mouseY, screen.width, screen.height); + public void renderHoveredTooltip(MatrixStack matrices) { + if (isHovered()) { + YACLScreen.renderMultilineTooltip(matrices, MinecraftClient.getInstance().textRenderer, wrappedDescription, x + width / 2, y - 4, y + height + 4, screen.width, screen.height); } } public void setTooltip(Text tooltip) { - wrappedDescription = MultilineText.create(MinecraftClient.getInstance().textRenderer, tooltip, screen.width / 2); + wrappedDescription = MultilineText.create(MinecraftClient.getInstance().textRenderer, tooltip, screen.width / 3); } } |