From ea1391e0c6f0db863bbb61511eb6e9acb57a5968 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Wed, 19 Aug 2020 12:16:12 +1000 Subject: 1.1.5 --- .../moulberry/notenoughupdates/util/Utils.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 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 73c15a7b..428a43b2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -619,7 +619,12 @@ public class Utils { return new Color(colourInt).darker(); } - //private static List + public static void scrollTooltip(int dY) { + scrollY.setTarget(scrollY.getTarget()+dY/10f); + scrollY.resetTimer(); + } + + private static LerpingFloat scrollY = new LerpingFloat(0, 100); public static void drawHoveringText(List textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font, boolean coloured) { if (!textLines.isEmpty()) { @@ -713,9 +718,24 @@ 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); + scrollY.resetTimer(); + } + } else { + scrollY.setValue(0); + scrollY.resetTimer(); + } + scrollY.tick(); + if (tooltipY + tooltipHeight + 6 > screenHeight) { - tooltipY = screenHeight - tooltipHeight - 6; + tooltipY = screenHeight - tooltipHeight - 6 + (int)scrollY.getValue(); } final int zLevel = 300; -- cgit