package lumaceon.mods.clockworkphase2.client.gui.components;
import lumaceon.mods.clockworkphase2.api.MainspringMetalRegistry;
import lumaceon.mods.clockworkphase2.api.assembly.ContainerAssemblyTable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
public class GuiButtonMainspring extends GuiButton
{
private ContainerAssemblyTable containerAssemblyTable;
public GuiButtonMainspring(int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, int p_i1021_4_, int p_i1021_5_, ContainerAssemblyTable container) {
super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, "+");
this.containerAssemblyTable = container;
}
public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_)
{
if (this.visible)
{
FontRenderer fontrenderer = p_146112_1_.fontRendererObj;
//p_146112_1_.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height;
int k = this.getHoverState(this.hovered);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
this.mouseDragged(p_146112_1_, p_146112_2_, p_146112_3_);
int l = 14737632;
if (packedFGColour != 0)
{
l = packedFGColour;
}
else if (!this.enabled)
{
l = 10526880;
}
else if (this.hovered)
{
l = 16777120;
}
int metalAddition = 0;
for(int n = 0; n < containerAssemblyTable.componentInventory.getSizeInventory(); n++)
metalAddition += MainspringMetalRegistry.getValue(containerAssemblyTable.componentInventory.getStackInSlot(n));
this.drawCenteredString(fontrenderer, this.displayString + metalAddition + " Tension", this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
}
}
}