From 93cdc3e03c3654f560204c23017fbf1e9f720a6c Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Tue, 4 Apr 2023 20:37:03 +0200 Subject: Scrollable Tooltips a la text line removal. (#613) * scrolling * Reverse scrolling * change trophy fish pv page to use the same tooltip system as the rest of the pv pages * Added the ability to use neu's tooltips instead of vanilla * Move config option * Add support for the custom tooltips * Fixed equipment overlay breaking * Fixed some guis going no * Use a new arraylist instead of modifying the old one (achievments) * fix merge conflict --------- Co-authored-by: nopo --- .../moulberry/notenoughupdates/util/Utils.java | 100 +++++++++------------ 1 file changed, 40 insertions(+), 60 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java') 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 49caa2b6..e3d52fe7 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; @@ -1521,20 +1522,6 @@ public class Utils { Minecraft.getMinecraft().fontRendererObj ); } - - @Deprecated - public static void drawHoveringText( - List textLines, - final int mouseX, - final int mouseY, - final int screenWidth, - final int screenHeight, - final int maxTextWidth, - FontRenderer font - ) { - drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true); - } - public static JsonObject getConstant(String constant, Gson gson) { return getConstant(constant, gson, JsonObject.class); } @@ -1668,39 +1655,38 @@ public class Utils { scrollY.resetTimer(); } - public static void drawHoveringText( - List textLines, - final int mouseX, - final int mouseY, - final int screenWidth, - final int screenHeight, - final int maxTextWidth, - boolean coloured - ) { - drawHoveringText( - textLines, - mouseX, - mouseY, - screenWidth, - screenHeight, - maxTextWidth, - Minecraft.getMinecraft().fontRendererObj, - coloured - ); - } - @Deprecated public static void drawHoveringText( List textLines, - final int mouseX, - final int mouseY, - final int screenWidth, - final int screenHeight, + int mouseX, + int mouseY, + int screenWidth, + int screenHeight, final int maxTextWidth, - FontRenderer font, - boolean coloured + 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); + } + } + textLines = TooltipTextScrolling.handleTextLineRendering(textLines); + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale != 0) { + ScaledResolution scaledResolution = Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale); + mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth; + + mouseY = scaledResolution.getScaledHeight() - + Mouse.getY() * scaledResolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight; + + screenWidth = scaledResolution.getScaledWidth(); + + screenHeight = scaledResolution.getScaledHeight(); + } + GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableLighting(); @@ -1776,19 +1762,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(); @@ -1841,15 +1829,6 @@ public class Utils { backgroundColor, backgroundColor ); - //TODO: Coloured Borders - int borderColorStart = 0x505000FF; - if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderColours && coloured) { - 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, @@ -1904,6 +1883,7 @@ public class Utils { GlStateManager.enableDepth(); RenderHelper.enableStandardItemLighting(); GlStateManager.enableRescaleNormal(); + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.guiScale != 0) Utils.pushGuiScale(0); } GlStateManager.disableLighting(); } -- cgit