boop
This commit is contained in:
parent
5981e5ce50
commit
3de1c7130a
13 changed files with 107 additions and 43 deletions
|
@ -1,8 +1,6 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import me.kawaiizenbo.moonlight.util.MathUtils;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -28,6 +26,7 @@ public class DoubleSetting extends Setting
|
|||
public void render(MatrixStack matrices, int x, int y, int mouseX, int mouseY)
|
||||
{
|
||||
super.render(matrices, x, y, mouseX, mouseY);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(name), x+2, y+2, 0xFFFFFF);
|
||||
double diff = Math.min(100, Math.max(0, (mouseX - x)/1.9));
|
||||
|
||||
if (sliding)
|
||||
|
@ -38,12 +37,12 @@ public class DoubleSetting extends Setting
|
|||
}
|
||||
else
|
||||
{
|
||||
double newValue = round(((diff / 100) * (max - min) + min), roundingPlace);
|
||||
double newValue = MathUtils.round(((diff / 100) * (max - min) + min), roundingPlace);
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
String valueString = ""+round(value, roundingPlace);
|
||||
String valueString = ""+MathUtils.round(value, roundingPlace);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(valueString), (x+190)-textRenderer.getWidth(valueString), y+2, 0xFFFFFF);
|
||||
DrawableHelper.fill(matrices, x+2, y+16, x+190, y+18, 0xFF666666);
|
||||
int scaledValue = (int)((value/max)*190);
|
||||
|
@ -51,15 +50,6 @@ public class DoubleSetting extends Setting
|
|||
DrawableHelper.fill(matrices, x+2+(scaledValue-1), y+14, x+2+(scaledValue+1), y+20, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
private static double round(double value, int places)
|
||||
{
|
||||
if (places < 0) throw new IllegalArgumentException();
|
||||
|
||||
BigDecimal bd = new BigDecimal(Double.toString(value));
|
||||
bd = bd.setScale(places, RoundingMode.HALF_UP);
|
||||
return bd.doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue