mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-25 22:34:29 +00:00
Add a parameter for mousewheel scrolling and helper functions for slider
This commit is contained in:
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
|
||||
|
||||
Reference in new issue
Block a user