mirror of
https://github.com/GTNewHorizons/EnderCore.git
synced 2026-11-25 06:14:33 +00:00
Enable scrolling over Color and Cycle buttons (#15)
* Update buildscript, dependencies, and gradle wrapper * Enable scrolling on Color and Cycle buttons
This commit is contained in:
1 parent
6a493f790c
commit
0a2879271d
6 files changed
+60
-3
No files matched your search
Vendored
BIN
Binary file not shown.
@@ -85,9 +85,6 @@ done
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,21 @@ public class CycleButton<T extends Enum<T> & 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]);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user