aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java12
3 files changed, 31 insertions, 1 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java b/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java
index ccb28dd6..fa721e1e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/TooltipTextScrolling.java
@@ -33,7 +33,7 @@ import java.util.Objects;
public class TooltipTextScrolling {
static List<String> lastRenderedTooltip = null;
static int scrollOffset = 0;
- static boolean didRenderTooltip = false;
+ public static boolean didRenderTooltip = false;
public static List<String> handleTextLineRendering(List<String> tooltip) {
didRenderTooltip = true;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java
index e9bff8f6..a6a61b34 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java
@@ -181,6 +181,24 @@ public class ArrowPagesUtils {
return false;
}
+ public static boolean onPageSwitchScroll(
+ int currentPage,
+ int totalPages,
+ Consumer<Integer> pageChange
+ ) {
+ if (Mouse.getEventDWheel() > 0) {
+ int newPage = currentPage - 1;
+ pageChange.accept(MathHelper.clamp_int(newPage, 0, totalPages - 1));
+ return true;
+ } else if (Mouse.getEventDWheel() < 0) {
+ int newPage = currentPage + 1;
+ pageChange.accept(MathHelper.clamp_int(newPage, 0, totalPages - 1));
+ return true;
+ }
+
+ return false;
+ }
+
private static boolean isWithinRect(int x, int y, int topLeftX, int topLeftY, int width, int height) {
return topLeftX <= x && x < topLeftX + width
&& topLeftY <= y && y < topLeftY + height;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
index 3627a94e..6dc64ab6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
@@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.miscgui;
import com.google.common.collect.ImmutableList;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.TooltipTextScrolling;
import io.github.moulberry.notenoughupdates.core.util.ArrowPagesUtils;
import io.github.moulberry.notenoughupdates.recipes.NeuRecipe;
import io.github.moulberry.notenoughupdates.recipes.RecipeHistory;
@@ -336,6 +337,17 @@ public class GuiItemRecipe extends GuiScreen {
int mouseY = scaledResolution.getScaledHeight() -
Mouse.getY() * scaledResolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1;
getCurrentRecipe().genericMouseInput(mouseX, mouseY);
+
+
+ // Allow Paging with Scroll-Wheel
+
+ // Block scrolling while Tooltip is displayed
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.scrollableTooltips &&
+ TooltipTextScrolling.didRenderTooltip) return;
+
+ if (Mouse.getEventDWheel() != 0) {
+ ArrowPagesUtils.onPageSwitchScroll(currentIndex, getCurrentRecipeList().size(), pageChange -> changeRecipe(currentTab, pageChange));
+ }
}
public void arrowKeyboardInput() {