diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java index a43103b..ffb4470 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java @@ -29,7 +29,7 @@ package cc.polyfrost.oneconfig.gui.elements; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; -import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.InputHandler; public class Slider extends BasicElement { private final float min, max; @@ -47,8 +47,8 @@ public class Slider extends BasicElement { } @Override - public void draw(long vg, float x, float y) { - if(!disabled) update(x, y); + public void draw(long vg, float x, float y, InputHandler inputHandler) { + if(!disabled) update(x, y, inputHandler); else RenderManager.setAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x, y + 2, width, height - 4, Colors.GRAY_300, 3f); RenderManager.drawRoundedRect(vg, x, y + 2, width * value, height - 4, Colors.PRIMARY_500, 3f); @@ -58,18 +58,18 @@ public class Slider extends BasicElement { } - public void update(float x, float y) { - super.update(x, y); + public void update(float x, float y, InputHandler inputHandler) { + super.update(x, y, inputHandler); boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0); - boolean hovered = InputUtils.isAreaHovered(x - 6, y - 3, width + 12, height + 6); + boolean hovered = inputHandler.isAreaHovered(x - 6, y - 3, width + 12, height + 6); if (hovered && isMouseDown && !mouseWasDown) dragging = true; mouseWasDown = isMouseDown; if (dragging) { - value = (InputUtils.mouseX() - x) / width; + value = (inputHandler.mouseX() - x) / width; } - if (dragging && InputUtils.isClicked(true)) { + if (dragging && inputHandler.isClicked(true)) { dragging = false; - value = (InputUtils.mouseX() - x) / width; + value = (inputHandler.mouseX() - x) / width; } if (value < 0) value = 0; |