2014-04-29 10:54:20 +10:00
|
|
|
package codechicken.nei;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2023-09-25 00:35:24 +02:00
|
|
|
|
2014-04-29 10:54:20 +10:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
2022-06-24 12:32:13 +01:00
|
|
|
public class GuiNEIButton extends GuiButton {
|
2023-01-28 17:55:51 -08:00
|
|
|
|
2019-12-30 20:19:16 -08:00
|
|
|
protected static final ResourceLocation guiTex = new ResourceLocation("textures/gui/widgets.png");
|
2022-06-24 12:32:13 +01:00
|
|
|
|
|
|
|
|
public GuiNEIButton(int i, int j, int k, int l, int i1, String s) {
|
2014-04-29 10:54:20 +10:00
|
|
|
super(i, j, k, l, i1, s);
|
|
|
|
|
}
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2024-11-17 17:31:10 +02:00
|
|
|
public void drawButton(Minecraft minecraft, int x, int y) {
|
2022-06-24 12:32:13 +01:00
|
|
|
if (!visible) return;
|
2014-04-29 10:54:20 +10:00
|
|
|
|
|
|
|
|
minecraft.renderEngine.bindTexture(guiTex);
|
|
|
|
|
GL11.glColor4f(1, 1, 1, 1);
|
2024-11-17 17:31:10 +02:00
|
|
|
boolean mouseOver = x >= xPosition && y >= yPosition && x < xPosition + width && y < yPosition + height;
|
|
|
|
|
int k = getHoverState(mouseOver);
|
2022-06-24 12:32:13 +01:00
|
|
|
drawTexturedModalRect(xPosition, yPosition, 0, 46 + k * 20, width / 2, height / 2); // top left
|
|
|
|
|
drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height / 2); // top
|
|
|
|
|
// right
|
|
|
|
|
drawTexturedModalRect(
|
|
|
|
|
xPosition,
|
|
|
|
|
yPosition + height / 2,
|
|
|
|
|
0,
|
|
|
|
|
46 + k * 20 + 20 - height / 2,
|
|
|
|
|
width / 2,
|
|
|
|
|
height / 2); // bottom left
|
|
|
|
|
drawTexturedModalRect(
|
|
|
|
|
xPosition + width / 2,
|
|
|
|
|
yPosition + height / 2,
|
|
|
|
|
200 - width / 2,
|
|
|
|
|
46 + k * 20 + 20 - height / 2,
|
|
|
|
|
width / 2,
|
|
|
|
|
height / 2); // bottom right
|
2024-11-17 17:31:10 +02:00
|
|
|
mouseDragged(minecraft, x, y);
|
2022-06-24 12:32:13 +01:00
|
|
|
|
2024-11-17 17:31:10 +02:00
|
|
|
drawContent(minecraft, x, y, mouseOver);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected int getTextColour(boolean mouseOver) {
|
|
|
|
|
int color = 0xe0e0e0;
|
|
|
|
|
|
|
|
|
|
if (!enabled) {
|
|
|
|
|
color = 0xffa0a0a0;
|
|
|
|
|
} else if (mouseOver) {
|
|
|
|
|
color = 0xffffa0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void drawContent(Minecraft minecraft, int y, int x, boolean mouseOver) {
|
|
|
|
|
FontRenderer fontrenderer = minecraft.fontRenderer;
|
|
|
|
|
int color = getTextColour(mouseOver);
|
|
|
|
|
|
|
|
|
|
drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, color);
|
2014-04-29 10:54:20 +10:00
|
|
|
}
|
|
|
|
|
}
|