Added untranslated hoverKey property to GuiTexturedButton which is to be displayed when hovering over the Button

Implemented hoverKey feature in GuiReplayOverlay (doesn't display properly yet)
This commit is contained in:
CrushedPixel
2015-05-31 18:13:01 +02:00
parent 74fb08368b
commit 53bb338d1b
3 changed files with 42 additions and 13 deletions

View File

@@ -1,23 +1,35 @@
package eu.crushedpixel.replaymod.gui.elements;
import eu.crushedpixel.replaymod.ReplayMod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import java.awt.*;
public class GuiTexturedButton extends GuiButton {
private final ResourceLocation texture;
private final int u, v;
private final int textureWidth, textureHeight;
private final String hoverKey;
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
int u, int v, int textureWidth, int textureHeight) {
this(buttonId, x, y, width, height, texture, u, v, textureWidth, textureHeight, null);
}
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
int u, int v, int textureWidth, int textureHeight, String hoverKey) {
super(buttonId, x, y, width, height, "");
this.texture = texture;
this.u = u;
this.v = v;
this.textureWidth = textureWidth;
this.textureHeight = textureHeight;
this.hoverKey = hoverKey;
}
@Override
@@ -33,6 +45,10 @@ public class GuiTexturedButton extends GuiButton {
GlStateManager.color(1, 1, 1);
int u = this.u + (hovered ? width : 0);
Gui.drawModalRectWithCustomSizedTexture(xPosition, yPosition, u, v, width, height, textureWidth, textureHeight);
if(hovered && hoverKey != null) {
ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format(hoverKey), null, Color.WHITE.getRGB());
}
}
}
}