diff --git a/src/main/java/com/enderio/core/client/gui/GuiContainerBase.java b/src/main/java/com/enderio/core/client/gui/GuiContainerBase.java index 32b9e2c..0b22fe2 100644 --- a/src/main/java/com/enderio/core/client/gui/GuiContainerBase.java +++ b/src/main/java/com/enderio/core/client/gui/GuiContainerBase.java @@ -300,12 +300,25 @@ public abstract class GuiContainerBase extends GuiContainer ghostSlotClicked(slot, x, y, delta < 0 ? -1 : -2); } } + for (Object obj : buttonList) { + if (obj instanceof IconButton) { + IconButton btn = (IconButton) obj; + if (btn.mouseScrolled(mc, x, y, delta)) { + btn.func_146113_a(this.mc.getSoundHandler()); + actionPerformedWheel(btn, delta); + } + } + } } protected void actionPerformedButton(IconButton btn, int mouseButton) { actionPerformed(btn); } + protected void actionPerformedWheel(IconButton btn, int scrollDelta) { + actionPerformed(btn); + } + public void addOverlay(IGuiOverlay overlay) { overlays.add(overlay); } diff --git a/src/main/java/com/enderio/core/client/gui/button/ColorButton.java b/src/main/java/com/enderio/core/client/gui/button/ColorButton.java index 763fdab..9fdd5b9 100644 --- a/src/main/java/com/enderio/core/client/gui/button/ColorButton.java +++ b/src/main/java/com/enderio/core/client/gui/button/ColorButton.java @@ -38,6 +38,21 @@ public class ColorButton extends IconButton { return result; } + @Override + public boolean mouseScrolled(Minecraft mc, int x, int y, int scrollDelta) { + if (super.checkMousePress(mc, x, y)) { + if (scrollDelta > 0) { + nextColor(); + } else if (scrollDelta < 0) { + prevColor(); + } else { + return false; + } + return true; + } + return false; + } + public String getTooltipPrefix() { return tooltipPrefix; } diff --git a/src/main/java/com/enderio/core/client/gui/button/CycleButton.java b/src/main/java/com/enderio/core/client/gui/button/CycleButton.java index 1f6cd27..d3cd46a 100644 --- a/src/main/java/com/enderio/core/client/gui/button/CycleButton.java +++ b/src/main/java/com/enderio/core/client/gui/button/CycleButton.java @@ -56,6 +56,21 @@ public class CycleButton & ICycleEnum> extends IconButton { return result; } + @Override + public boolean mouseScrolled(Minecraft mc, int x, int y, int scrollDelta) { + if (super.checkMousePress(mc, x, y)) { + if (scrollDelta > 0) { + nextMode(); + } else if (scrollDelta < 0) { + prevMode(); + } else { + return false; + } + return true; + } + return false; + } + private void nextMode() { setMode(modes[(mode.ordinal() + 1) % modes.length]); } diff --git a/src/main/java/com/enderio/core/client/gui/button/IconButton.java b/src/main/java/com/enderio/core/client/gui/button/IconButton.java index 44159d0..cfd7b7b 100644 --- a/src/main/java/com/enderio/core/client/gui/button/IconButton.java +++ b/src/main/java/com/enderio/core/client/gui/button/IconButton.java @@ -62,6 +62,19 @@ public class IconButton extends TooltipButton { return super.mousePressed(mc, x, y); } + /** + * Override this to handle scrolling when the mouse is hovering over the button + * + * @param mc The MC instance + * @param x X coordinate of mouse click + * @param y Y coordinate of mouse click + * @param scrollDelta the amount by which was scrolled + * @return true if the mouse scroll is handled + */ + public boolean mouseScrolled(Minecraft mc, int x, int y, int scrollDelta) { + return false; + } + /** * Draws this button to the screen. */