GuiCheckbox.java
1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* This file is part of LiteLoader.
* Copyright (C) 2012-16 Adam Mummery-Smith
* All Rights Reserved.
*/
package com.mumfrey.liteloader.client.gui;
import static com.mumfrey.liteloader.gl.GL.*;
import com.mumfrey.liteloader.client.api.LiteLoaderBrandingProvider;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
/**
* Super-simple implementation of a checkbox control
*
* @author Adam Mummery-Smith
*/
public class GuiCheckbox extends GuiButton
{
public boolean checked;
public GuiCheckbox(int controlId, int xPosition, int yPosition, String displayString)
{
super(controlId, xPosition, yPosition, Minecraft.getMinecraft().fontRenderer.getStringWidth(displayString) + 16, 12, displayString);
}
@Override
public void func_191745_a(Minecraft minecraft, int mouseX, int mouseY, float partialTicks) // drawButton
{
if (this.visible)
{
minecraft.getTextureManager().bindTexture(LiteLoaderBrandingProvider.ABOUT_TEXTURE);
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x
&& mouseY >= this.y
&& mouseX < this.x + this.width
&& mouseY < this.y + this.height;
this.drawTexturedModalRect(this.x, this.y, this.checked ? 134 : 122, 80, 12, 12);
this.mouseDragged(minecraft, mouseX, mouseY);
int colour = 0xE0E0E0;
if (!this.enabled)
{
colour = 0xA0A0A0;
}
else if (this.hovered)
{
colour = 0xFFFFA0;
}
this.drawString(minecraft.fontRenderer, this.displayString, this.x + 16, this.y + 2, colour);
}
}
}