diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java index 4c74a460b..9e823e536 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiQuestLog.java @@ -236,8 +236,10 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, final float SMOOTHING_FACTOR = 0.1F; // Adjust this value for smoother or faster scrolling int maxScroll = Math.max(0, this.sideButtons.size() - 9) * 22; - this.destSideButtonScroll = ValueUtil.clamp(this.destSideButtonScroll - Math.signum(this.mouseWheel) * 22, -maxScroll, 0); - + // Adjust scrolling only if the mouse is in the scroll zone + if (isMouseInScrollZone(i, j)) { + this.destSideButtonScroll = ValueUtil.clamp(this.destSideButtonScroll - Math.signum(this.mouseWheel) * 22, -maxScroll, 0); + } // Apply smoothing to the scroll transition this.sideButtonScroll += (this.destSideButtonScroll - this.sideButtonScroll) * SMOOTHING_FACTOR; @@ -418,4 +420,13 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener, } } + + public boolean isMouseInScrollZone(int x, int y) { + int scrollZoneLeft = guiLeft - 69; // Left boundary of the scroll zone + int scrollZoneRight = guiLeft - 69 + 70; // Right boundary of the scroll zone + int scrollZoneTop = guiTop + 2; // Top boundary of the scroll zone + int scrollZoneBottom = guiTop + 2 + 8 * 21; // Bottom boundary of the scroll zone + + return x >= scrollZoneLeft && x <= scrollZoneRight && y >= scrollZoneTop && y <= scrollZoneBottom; + } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java index f2b1f581b..aae79e6a6 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java @@ -82,6 +82,7 @@ public class GuiCustomScroll extends GuiScreen public void drawScreen(int i, int j, float f, int mouseScrolled){ if(!visible) return; + drawGradientRect(guiLeft, guiTop, xSize+guiLeft ,ySize+guiTop, 0xc0101010, 0xd0101010); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resource); @@ -96,6 +97,8 @@ public class GuiCustomScroll extends GuiScreen GL11.glTranslatef(guiLeft, guiTop, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + boolean isMouseOverComponent = isMouseOver(i, j); + if(selectable) hover = getMouseOver(i,j); @@ -140,7 +143,7 @@ public class GuiCustomScroll extends GuiScreen } } - if(mouseScrolled != 0){ + if(mouseScrolled != 0 && isMouseOverComponent){ scrollY += mouseScrolled > 0?-14:14; if(scrollY > maxScrollY) scrollY = maxScrollY;