From 94bf46a187d0568ff7d2c2708c3ab352a259f9e2 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 18 Nov 2015 18:42:35 +0100 Subject: [PATCH] Add a parameter for mousewheel scrolling and helper functions for slider --- .../mantle/client/gui/GuiModule.java | 15 +++++++++++++++ .../mantle/client/gui/GuiWidgetSlider.java | 18 ++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java index 3880520..21e2e4c 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java @@ -7,6 +7,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.io.IOException; +import java.util.List; // a sub-gui. Mostly the same as a separate GuiContainer, but doesn't do the calls that affect the game as if this were the only gui @SideOnly(Side.CLIENT) @@ -67,6 +68,20 @@ public abstract class GuiModule extends GuiContainer { return true; } + public boolean isMouseInModule(int mouseX, int mouseY) { + return mouseX >= this.guiLeft && mouseX < this.guiRight() && + mouseY >= this.guiTop && mouseY < this.guiBottom(); + } + + public boolean isMouseOverFullSlot(int mouseX, int mouseY) { + for(Slot slot : (List)inventorySlots.inventorySlots) { + if(parent.isMouseOverSlot(slot, mouseX, mouseY) && slot.getHasStack()) { + return true; + } + } + return false; + } + /* public void updateDragged(boolean dragSplitting, Set draggedSlots) { this.dragSplitting = dragSplitting; diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java index a3fb1dc..c0940ba 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java @@ -129,7 +129,7 @@ public class GuiWidgetSlider extends GuiWidget { } } - public void update(int mouseX, int mouseY) { + public void update(int mouseX, int mouseY, boolean useMouseWheel) { if(!enabled || hidden) { return; } @@ -137,13 +137,15 @@ public class GuiWidgetSlider extends GuiWidget { boolean mouseDown = Mouse.isButtonDown(0); // left mouse button int wheel = Mouse.getDWheel(); - if(wheel > 0) { - decrement(); - return; - } - else if(wheel < 0) { - increment(); - return; + if(useMouseWheel) { + if(wheel > 0) { + decrement(); + return; + } + else if(wheel < 0) { + increment(); + return; + } } // relative position inside the widget