From 38e2fd5651968a23b4eb8fbb9b5250ac8aee328c Mon Sep 17 00:00:00 2001 From: ThisIsALegitUsername <73719631+ThisIsALegitUsername@users.noreply.github.com> Date: Sat, 4 Mar 2023 15:32:42 -0500 Subject: [PATCH] fix crash & set slider offset --- src/main/java/dev/resent/visual/ui/ClickGUI.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/resent/visual/ui/ClickGUI.java b/src/main/java/dev/resent/visual/ui/ClickGUI.java index 1ed3e4f6..b4c9fc6f 100644 --- a/src/main/java/dev/resent/visual/ui/ClickGUI.java +++ b/src/main/java/dev/resent/visual/ui/ClickGUI.java @@ -233,25 +233,28 @@ public class ClickGUI extends GuiScreen { fr.drawStringWithShadow(s.name, this.x + 24, height +43 + var, -1); var += 3; } - - NumberSetting ss = ((NumberSetting)s); if(s instanceof NumberSetting) { + NumberSetting ss = ((NumberSetting)s); fr.drawStringWithShadow(s.name + ": sof " + sliderOffset + ", val: " + ((NumberSetting)s).getValue(), this.x+24, height+41+var, -1); drawRect(width-150, height+43+var, width-45, height+47+var, -1); RenderUtils.drawRoundedRect(width-150+sliderOffset, height+41+var, width-141+sliderOffset, height+50+var, 4, Color.RED.getRGB()); if(dragging) { - sliderOffset = mouseX-(width-150); + sliderOffset = mouseX-(width-150); ss.setValue(sliderOffset*(ss.max/100)); } + if(!dragging) { + sliderOffset = (int) ((ss.getValue() * 100)/ss.max); + } + if(sliderOffset < 0) { dragging = false; sliderOffset = 0; } - if(width-141+sliderOffset > width-45) { + if(width-141+sliderOffset > width-50) { dragging = false; sliderOffset = 100; }