Add a parameter for mousewheel scrolling and helper functions for slider

This commit is contained in:
Bernhard Bonigl committed 2015-11-18 18:42:35 +01:00
1 parent 97931ac9f0
commit 94bf46a187
2 files changed
+25 -8

No files matched your search

@@ -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<Slot>)inventorySlots.inventorySlots) {
if(parent.isMouseOverSlot(slot, mouseX, mouseY) && slot.getHasStack()) {
return true;
}
}
return false;
}
/*
public void updateDragged(boolean dragSplitting, Set draggedSlots) {
this.dragSplitting = dragSplitting;
@@ -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