aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2020-03-10 19:58:00 +0200
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2020-03-19 20:34:08 +0200
commitbbdb7a75fdd43847ab64f5d8aa6cb33d454d717e (patch)
treed30d5f0c6e4f580c4d0682dff80292dd2513a308 /src
parent3353f966f279994c4f0a2d48198b92a43c7b03c0 (diff)
downloadLibGui-bbdb7a75fdd43847ab64f5d8aa6cb33d454d717e.tar.gz
LibGui-bbdb7a75fdd43847ab64f5d8aa6cb33d454d717e.tar.bz2
LibGui-bbdb7a75fdd43847ab64f5d8aa6cb33d454d717e.zip
Add text hover rendering to WText
(cherry picked from commit a9361c757a636c9d62bbc180a5c0468f649784ba)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
index 7e90b39..64a7c3e 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java
@@ -2,12 +2,14 @@ package io.github.cottonmc.cotton.gui.widget;
import io.github.cottonmc.cotton.gui.client.LibGuiClient;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
+import io.github.cottonmc.cotton.gui.client.TextHoverRendererScreen;
import io.github.cottonmc.cotton.gui.widget.data.Alignment;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.Texts;
import net.minecraft.text.Text;
@@ -80,6 +82,14 @@ public class WText extends WWidget {
ScreenDrawing.drawString(str, alignment, x, y + i * font.fontHeight, width, c);
}
+
+ Text hoveredText = getTextAt(mouseX, mouseY);
+ if (hoveredText != null) {
+ Screen screen = MinecraftClient.getInstance().currentScreen;
+ if (screen instanceof TextHoverRendererScreen) {
+ ((TextHoverRendererScreen) screen).renderTextHover(hoveredText, x + mouseX, y + mouseY);
+ }
+ }
}
@Override