aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-02-13 12:47:20 +0100
committernea <nea@nea.moe>2023-02-13 12:48:56 +0100
commit550277f9452bbb79bb070942e31a9c4b9be80713 (patch)
treed9a789a8fd3e4625bfa84eccca62da9067525522
parentda23f837ccb622d76034c476845e008e8a0ba1e9 (diff)
downloadNotEnoughUpdates-550277f9452bbb79bb070942e31a9c4b9be80713.tar.gz
NotEnoughUpdates-550277f9452bbb79bb070942e31a9c4b9be80713.tar.bz2
NotEnoughUpdates-550277f9452bbb79bb070942e31a9c4b9be80713.zip
Reverse scrolling
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java (renamed from src/main/java/io/github/moulberry/notenoughupdates/SomeClass.java)11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java8
3 files changed, 19 insertions, 4 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/SomeClass.java b/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java
index 7f20a44d..3261cc17 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/SomeClass.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java
@@ -30,7 +30,7 @@ import java.util.List;
import java.util.Objects;
@NEUAutoSubscribe
-public class SomeClass {
+public class TooltipTextScrolling {
static List<String> lastRenderedTooltip = null;
static int scrollOffset = 0;
static boolean didRenderTooltip = false;
@@ -46,12 +46,19 @@ public class SomeClass {
for (int i = 0; i < scrollOffset && tooltip.size() > 1; i++) {
tooltip.remove(0);
}
+ for (int i = 0; i < -scrollOffset && tooltip.size() > 1; i++) {
+ tooltip.remove(tooltip.size() - 1);
+ }
}
@SubscribeEvent
public void onMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
+ if (!NotEnoughUpdates.INSTANCE.config.misc.scrollableTooltips) return;
if (Mouse.getEventDWheel() < 0) {
- scrollOffset = Math.max(0, scrollOffset - 1);
+ scrollOffset = Math.max(
+ lastRenderedTooltip == null ? 0 : -Math.max(lastRenderedTooltip.size() - 1, 0)
+ , scrollOffset - 1
+ );
} else if (Mouse.getEventDWheel() > 0) {
scrollOffset = Math.min(
lastRenderedTooltip == null ? 0 : Math.max(lastRenderedTooltip.size() - 1, 0),
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 74a072b2..6176b22f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiUtils.java
@@ -20,7 +20,7 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.SomeClass;
+import io.github.moulberry.notenoughupdates.TooltipTextScrolling;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -80,6 +80,6 @@ public class MixinGuiUtils {
FontRenderer font,
CallbackInfo ci
) {
- SomeClass.handleTextLineRendering(textLines);
+ TooltipTextScrolling.handleTextLineRendering(textLines);
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
index 47e51eec..6b524dd0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
@@ -311,4 +311,12 @@ public class Misc {
@ConfigEditorBoolean
public boolean dungeonGroupsPV = true;
+ @Expose
+ @ConfigOption(
+ name = "Scrollable Tooltips",
+ desc = "Make tooltips text scrollable, by making some text lines disappear when using the mouse while hovering over an item."
+ )
+ @ConfigEditorBoolean
+ public boolean scrollableTooltips = false;
+
}