aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
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-10 19:58:00 +0200
commita9361c757a636c9d62bbc180a5c0468f649784ba (patch)
tree3e6af5014ae06121f93192492883cd641f642c1d /src/main/java/io
parentef2d9351241cdc082f281961a6a5544afdecf4fe (diff)
downloadLibGui-a9361c757a636c9d62bbc180a5c0468f649784ba.tar.gz
LibGui-a9361c757a636c9d62bbc180a5c0468f649784ba.tar.bz2
LibGui-a9361c757a636c9d62bbc180a5c0468f649784ba.zip
Add text hover rendering to WText
Diffstat (limited to 'src/main/java/io')
-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