/*
* Decompiled with CFR 0.153-SNAPSHOT (d6f6758-dirty).
*/
package im.geassclient.ui.dropdown.components.settings;
import im.geassclient.functions.settings.impl.SliderSetting;
import im.geassclient.ui.dropdown.impl.Component;
import im.geassclient.utils.math.MathUtil;
import im.geassclient.utils.render.ColorUtils;
import im.geassclient.utils.render.Cursors;
import im.geassclient.utils.render.DisplayUtils;
import im.geassclient.utils.render.font.Fonts;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
import org.lwjgl.glfw.GLFW;
public class SliderComponent
extends Component {
private final SliderSetting setting;
private float anim;
private boolean drag;
private boolean hovered = false;
public SliderComponent(SliderSetting setting) {
this.setting = setting;
this.setHeight(18.0f);
}
[USER=1367676]@override[/USER]
public void render(MatrixStack stack, float mouseX, float mouseY) {
super.render(stack, mouseX, mouseY);
Fonts.montserrat.drawText(stack, this.setting.getName(), this.getX() + 5.0f, this.getY() + 2.25f + 1.0f, ColorUtils.rgb(160, 163, 175), 5.5f, 0.05f);
Fonts.montserrat.drawText(stack, String.valueOf(this.setting.get()), this.getX() + this.getWidth() - 5.0f - Fonts.montserrat.getWidth(String.valueOf(this.setting.get()), 5.5f), this.getY() + 2.25f + 1.0f, ColorUtils.rgb(160, 163, 175), 5.5f, 0.05f);
DisplayUtils.drawRoundedRect(this.getX() + 5.0f, this.getY() + 11.0f, this.getWidth() - 10.0f, 2.0f, 0.6f, ColorUtils.rgb(28, 28, 31));
float sliderWidth = this.anim = MathUtil.fast(this.anim, (this.getWidth() - 10.0f) * (((Float)this.setting.get()).floatValue() - this.setting.min) / (this.setting.max - this.setting.min), 20.0f);
DisplayUtils.drawRoundedRect(this.getX() + 5.0f, this.getY() + 11.0f, sliderWidth, 2.0f, 0.6f, ColorUtils.rgb(128, 132, 150));
DisplayUtils.drawCircle(this.getX() + 5.0f + sliderWidth, this.getY() + 12.0f, 5.0f, ColorUtils.rgb(128, 132, 150));
DisplayUtils.drawShadowCircle(this.getX() + 5.0f + sliderWidth, this.getY() + 12.0f, 6.0f, ColorUtils.rgba(128, 132, 150, 64));
if (this.drag) {
GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.glfwCreateStandardCursor(221189));
this.setting.set(Float.valueOf((float)MathHelper.clamp(MathUtil.round((mouseX - this.getX() - 5.0f) / (this.getWidth() - 10.0f) * (this.setting.max - this.setting.min) + this.setting.min, this.setting.increment), (double)this.setting.min, (double)this.setting.max)));
}
if (this.isHovered(mouseX, mouseY)) {
if (MathUtil.isInRegion(mouseX, mouseY, this.getX() + 5.0f, this.getY() + 10.0f, this.getWidth() - 10.0f, 3.0f)) {
if (!this.hovered) {
GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.RESIZEH);
this.hovered = true;
}
} else if (this.hovered) {
GLFW.glfwSetCursor(Minecraft.getInstance().getMainWindow().getHandle(), Cursors.ARROW);
this.hovered = false;
}
}
}
[USER=1367676]@override[/USER]
public void mouseClick(float mouseX, float mouseY, int mouse) {
if (MathUtil.isInRegion(mouseX, mouseY, this.getX() + 5.0f, this.getY() + 10.0f, this.getWidth() - 10.0f, 3.0f)) {
this.drag = true;
}
super.mouseClick(mouseX, mouseY, mouse);
}
[USER=1367676]@override[/USER]
public void mouseRelease(float mouseX, float mouseY, int mouse) {
this.drag = false;
super.mouseRelease(mouseX, mouseY, mouse);
}
[USER=1367676]@override[/USER]
public boolean isVisible() {
return (Boolean)this.setting.visible.get();
}
}