mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 10:01:31 +01:00
New Slider
This commit is contained in:
parent
97c4dbacc8
commit
c8297dbdb9
@ -117,7 +117,7 @@ public class ModSettings extends SilentScreen {
|
|||||||
|
|
||||||
if(RegularSlider.isDrag(mouseX, mouseY, 3, settingY, 144) && (System.currentTimeMillis() - initTime) > 500) {
|
if(RegularSlider.isDrag(mouseX, mouseY, 3, settingY, 144) && (System.currentTimeMillis() - initTime) > 500) {
|
||||||
double diff = setting.getMax() - setting.getMin();
|
double diff = setting.getMax() - setting.getMin();
|
||||||
double mouse = MathHelper.clamp_double((mouseX - 3) / 90D, 0, 1);
|
double mouse = MathHelper.clamp_double((mouseX - 3) / 144D, 0, 1);
|
||||||
double newVal = setting.getMin() + mouse * diff;
|
double newVal = setting.getMin() + mouse * diff;
|
||||||
if(newVal != setting.getValDouble()) {
|
if(newVal != setting.getValDouble()) {
|
||||||
setting.setValDouble(newVal);
|
setting.setValDouble(newVal);
|
||||||
|
@ -3,7 +3,6 @@ package net.silentclient.client.gui.modmenu;
|
|||||||
import net.silentclient.client.Client;
|
import net.silentclient.client.Client;
|
||||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||||
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
|
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
|
||||||
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
|
||||||
import net.silentclient.client.gui.util.RenderUtil;
|
import net.silentclient.client.gui.util.RenderUtil;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
@ -14,16 +13,16 @@ public class RegularSlider {
|
|||||||
public static void render(float x, float y, int width, String name, double max, double value) {
|
public static void render(float x, float y, int width, String name, double max, double value) {
|
||||||
Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE);
|
Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE);
|
||||||
|
|
||||||
RenderUtil.drawRoundedRect(x, y + 15, 100, 9, 3, Color.black.getRGB());
|
RenderUtil.drawRoundedRect(x, y + 15, 144, 9, 3, Color.black.getRGB());
|
||||||
if(value != 0) {
|
if(value != 0) {
|
||||||
RenderUtil.drawRoundedRect(x, y + 15, 100F * (float) (value / max), 9, 3, -1);
|
RenderUtil.drawRoundedRect(x, y + 15, 144F * (float) (value / max), 9, 3, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
float textLeft = x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE);
|
float textLeft = x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE);
|
||||||
Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y + 14, 12, SilentFontRenderer.FontType.TITLE);
|
Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y, 12, SilentFontRenderer.FontType.TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDrag(int mouseX, int mouseY, float x, float y, int width) {
|
public static boolean isDrag(int mouseX, int mouseY, float x, float y, int width) {
|
||||||
return MouseUtils.isInside(mouseX, mouseY, x, y + 15, 100, 9) && Mouse.isButtonDown(0);
|
return MouseUtils.isInside(mouseX, mouseY, x, y + 15, 144, 9) && Mouse.isButtonDown(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user