aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authornopo <nopotheemail@gmail.com>2023-02-14 16:48:05 +1100
committernopo <nopotheemail@gmail.com>2023-02-14 16:48:05 +1100
commitc93219db518daf2928e02f1e3d1fa1505f0d07ef (patch)
treea2b09673f98775f67b8a30fe8a960a8552bb83e4 /src/main/java
parentcf0b6fc6c7ac827f66488a126ad94b0b540ae5be (diff)
downloadNotEnoughUpdates-c93219db518daf2928e02f1e3d1fa1505f0d07ef.tar.gz
NotEnoughUpdates-c93219db518daf2928e02f1e3d1fa1505f0d07ef.tar.bz2
NotEnoughUpdates-c93219db518daf2928e02f1e3d1fa1505f0d07ef.zip
Add support for the custom tooltips
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java41
2 files changed, 23 insertions, 20 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
index 004cfdfb..a3313090 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
@@ -74,7 +74,7 @@ public class MixinGuiUtils {
List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font, CallbackInfo ci) {
Utils.resetGuiScale();
}
- @Inject(at = @At("HEAD"), method = "drawHoveringText", remap = false)
+ @Inject(at = @At("HEAD"), method = "drawHoveringText")
private static void onDrawHoveringText(
List<String> textLines,
int mouseX,
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 3c856dea..2b7e4b98 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -27,6 +27,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.TooltipTextScrolling;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import net.minecraft.block.Block;
@@ -1562,6 +1563,15 @@ public class Utils {
FontRenderer font
) {
if (!textLines.isEmpty()) {
+ int borderColorStart = 0x505000FF;
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderColours) {
+ if (textLines.size() > 0) {
+ String first = textLines.get(0);
+ borderColorStart = getPrimaryColour(first).getRGB() & 0x00FFFFFF |
+ ((NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderOpacity) << 24);
+ }
+ }
+ TooltipTextScrolling.handleTextLineRendering(textLines);
ScaledResolution scaledResolution = Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale);
if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale != 0) {
mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
@@ -1649,19 +1659,21 @@ public class Utils {
}
//Scrollable tooltips
- if (tooltipHeight + 6 > screenHeight) {
- if (scrollY.getTarget() < 0) {
- scrollY.setTarget(0);
- scrollY.resetTimer();
- } else if (screenHeight - tooltipHeight - 12 + (int) scrollY.getTarget() > 0) {
- scrollY.setTarget(-screenHeight + tooltipHeight + 12);
+ if (!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.scrollableTooltips) {
+ if (tooltipHeight + 6 > screenHeight) {
+ if (scrollY.getTarget() < 0) {
+ scrollY.setTarget(0);
+ scrollY.resetTimer();
+ } else if (screenHeight - tooltipHeight - 12 + (int) scrollY.getTarget() > 0) {
+ scrollY.setTarget(-screenHeight + tooltipHeight + 12);
+ scrollY.resetTimer();
+ }
+ } else {
+ scrollY.setValue(0);
scrollY.resetTimer();
}
- } else {
- scrollY.setValue(0);
- scrollY.resetTimer();
+ scrollY.tick();
}
- scrollY.tick();
if (tooltipY + tooltipHeight + 6 > screenHeight) {
tooltipY = screenHeight - tooltipHeight - 6 + (int) scrollY.getValue();
@@ -1714,15 +1726,6 @@ public class Utils {
backgroundColor,
backgroundColor
);
- //TODO: Coloured Borders
- int borderColorStart = 0x505000FF;
- if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderColours) {
- if (textLines.size() > 0) {
- String first = textLines.get(0);
- borderColorStart = getPrimaryColour(first).getRGB() & 0x00FFFFFF |
- ((NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderOpacity) << 24);
- }
- }
final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
drawGradientRect(
zLevel,