Skip to content

Commit

Permalink
Add a parameter for mousewheel scrolling and helper functions for slider
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Nov 18, 2015
1 parent 97931ac commit 94bf46a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
15 changes: 15 additions & 0 deletions src/main/java/slimeknights/mantle/client/gui/GuiModule.java
Expand Up @@ -7,6 +7,7 @@
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)
Expand Down Expand Up @@ -67,6 +68,20 @@ public boolean shouldDrawSlot(Slot slot) {
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;
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java
Expand Up @@ -129,21 +129,23 @@ else if(isHighlighted) {
}
}

public void update(int mouseX, int mouseY) {
public void update(int mouseX, int mouseY, boolean useMouseWheel) {
if(!enabled || hidden) {
return;
}

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
Expand Down

0 comments on commit 94bf46a

Please sign in to comment.