"The Commit that properly implements the disabling of Gui Elements"

Added enabled Field to DelegatingElement, which every instance can handle itself
Made isEnabled Field in GuiAdvancedTextField protected for subclasses to access
Made GuiDraggingNumberInput only draggable while enabled
Made GuiDropdown check enabled field before accepting mouse clicks
Properly tints GuiTexturedButton if disabled
This commit is contained in:
CrushedPixel
2015-07-10 03:33:39 +02:00
parent 59e6b87935
commit 5828b04596
5 changed files with 18 additions and 6 deletions

View File

@@ -5,6 +5,8 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import java.awt.*;
public class GuiTexturedButton extends GuiAdvancedButton implements GuiElement {
private final ResourceLocation texture;
private final int u, v;
@@ -23,11 +25,16 @@ public class GuiTexturedButton extends GuiAdvancedButton implements GuiElement {
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (visible) {
hovered = isHovering(mouseX, mouseY);
hovered = isHovering(mouseX, mouseY) && enabled;
if(!enabled) {
GlStateManager.color(Color.GRAY.getRed() / 255f, Color.GRAY.getGreen() / 255f, Color.GRAY.getBlue() / 255f, 1f);
} else {
GlStateManager.color(1f, 1f, 1f);
}
mc.renderEngine.bindTexture(texture);
GlStateManager.color(1, 1, 1);
int u = this.u + (hovered ? width : 0);
Gui.drawModalRectWithCustomSizedTexture(xPosition, yPosition, u, v, width, height, textureWidth, textureHeight);
}