package net.minecraft.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiOptionSlider extends GuiButton
{
private float sliderValue;
public boolean dragging;
private GameSettings.Options options;
private final float field_146132_r;
private final float field_146131_s;
private static final String __OBFID = "CL_00000680";
public GuiOptionSlider(int p_i45016_1_, int p_i45016_2_, int p_i45016_3_, GameSettings.Options p_i45016_4_)
{
this(p_i45016_1_, p_i45016_2_, p_i45016_3_, p_i45016_4_, 0.0F, 1.0F);
}
public GuiOptionSlider(int p_i45017_1_, int p_i45017_2_, int p_i45017_3_, GameSettings.Options p_i45017_4_, float p_i45017_5_, float p_i45017_6_)
{
super(p_i45017_1_, p_i45017_2_, p_i45017_3_, 150, 20, "");
this.sliderValue = 1.0F;
this.options = p_i45017_4_;
this.field_146132_r = p_i45017_5_;
this.field_146131_s = p_i45017_6_;
Minecraft minecraft = Minecraft.getMinecraft();
this.sliderValue = p_i45017_4_.normalizeValue(minecraft.gameSettings.getOptionFloatValue(p_i45017_4_));
this.displayString = minecraft.gameSettings.getKeyBinding(p_i45017_4_);
}
/**
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over
* this button.
*/
public int getHoverState(boolean mouseOver)
{
return 0;
}
/**
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
*/
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
if (this.dragging)
{
this.sliderValue = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
if (this.sliderValue < 0.0F)
{
this.sliderValue = 0.0F;
}
if (this.sliderValue > 1.0F)
{
this.sliderValue = 1.0F;
}
float f = this.options.denormalizeValue(this.sliderValue);
mc.gameSettings.setOptionFloatValue(this.options, f);
this.sliderValue = this.options.normalizeValue(f);
this.displayString = mc.gameSettings.getKeyBinding(this.options);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.xPosition + (int)(this.sliderValue * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20);
this.drawTexturedModalRect(this.xPosition + (int)(this.sliderValue * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
}
}
/**
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent
* e).
*/
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if (super.mousePressed(mc, mouseX, mouseY))
{
this.sliderValue = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
if (this.sliderValue < 0.0F)
{
this.sliderValue = 0.0F;
}
if (this.sliderValue > 1.0F)
{
this.sliderValue = 1.0F;
}
mc.gameSettings.setOptionFloatValue(this.options, this.options.denormalizeValue(this.sliderValue));
this.displayString = mc.gameSettings.getKeyBinding(this.options);
this.dragging = true;
return true;
}
else
{
return false;
}
}
/**
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
*/
public void mouseReleased(int mouseX, int mouseY)
{
this.dragging = false;
}
}