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; package eu.crushedpixel.replaymod.gui.elements;
import eu.crushedpixel.replaymod.ReplayMod;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import java.awt.*;
public class GuiTexturedButton extends GuiButton { public class GuiTexturedButton extends GuiButton {
private final ResourceLocation texture; private final ResourceLocation texture;
private final int u, v; private final int u, v;
private final int textureWidth, textureHeight; private final int textureWidth, textureHeight;
private final String hoverKey;
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture, public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
int u, int v, int textureWidth, int textureHeight) { 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, ""); super(buttonId, x, y, width, height, "");
this.texture = texture; this.texture = texture;
this.u = u; this.u = u;
this.v = v; this.v = v;
this.textureWidth = textureWidth; this.textureWidth = textureWidth;
this.textureHeight = textureHeight; this.textureHeight = textureHeight;
this.hoverKey = hoverKey;
} }
@Override @Override
@@ -33,6 +45,10 @@ public class GuiTexturedButton extends GuiButton {
GlStateManager.color(1, 1, 1); GlStateManager.color(1, 1, 1);
int u = this.u + (hovered ? width : 0); int u = this.u + (hovered ? width : 0);
Gui.drawModalRectWithCustomSizedTexture(xPosition, yPosition, u, v, width, height, textureWidth, textureHeight); 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());
}
} }
} }
} }

View File

@@ -46,8 +46,8 @@ public class GuiReplayOverlay extends Gui {
public static final int TEXTURE_SIZE = 128; public static final int TEXTURE_SIZE = 128;
private static final float ZOOM_STEPS = 0.05f; private static final float ZOOM_STEPS = 0.05f;
private static GuiTexturedButton texturedButton(int x, int y, int u, int v, int size) { private static GuiTexturedButton texturedButton(int x, int y, int u, int v, int size, String hoverKey) {
return new GuiTexturedButton(0, x, y, size, size, replay_gui, u, v, TEXTURE_SIZE, TEXTURE_SIZE); return new GuiTexturedButton(0, x, y, size, size, replay_gui, u, v, TEXTURE_SIZE, TEXTURE_SIZE, hoverKey);
} }
private final int displayWidth = mc.displayWidth; private final int displayWidth = mc.displayWidth;
@@ -73,16 +73,16 @@ public class GuiReplayOverlay extends Gui {
private final int TIMELINE_REAL_X = BUTTON_TIME_X + 25; private final int TIMELINE_REAL_X = BUTTON_TIME_X + 25;
private final int TIMELINE_REAL_WIDTH = WIDTH - 14 - 11 - TIMELINE_REAL_X; private final int TIMELINE_REAL_WIDTH = WIDTH - 14 - 11 - TIMELINE_REAL_X;
private final GuiButton buttonPlay = texturedButton(BUTTON_PLAY_PAUSE_X, TOP_ROW, 0, 0, 20); private final GuiButton buttonPlay = texturedButton(BUTTON_PLAY_PAUSE_X, TOP_ROW, 0, 0, 20, "replaymod.gui.ingame.menu.unpause");
private final GuiButton buttonPause = texturedButton(BUTTON_PLAY_PAUSE_X, TOP_ROW, 0, 20, 20); private final GuiButton buttonPause = texturedButton(BUTTON_PLAY_PAUSE_X, TOP_ROW, 0, 20, 20, "replaymod.gui.ingame.menu.pause");
private final GuiButton buttonExport = texturedButton(BUTTON_EXPORT_X, BOTTOM_ROW, 40, 0, 20); private final GuiButton buttonExport = texturedButton(BUTTON_EXPORT_X, BOTTOM_ROW, 40, 0, 20, "replaymod.gui.ingame.menu.renderpath");
private final GuiButton buttonPlayPath = texturedButton(BUTTON_PLAY_PATH_X, BOTTOM_ROW, 0, 0, 20); private final GuiButton buttonPlayPath = texturedButton(BUTTON_PLAY_PATH_X, BOTTOM_ROW, 0, 0, 20, "replaymod.gui.ingame.menu.playpath");
private final GuiButton buttonPlace = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 0, 40, 20); private final GuiButton buttonPlace = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 0, 40, 20, "replaymod.gui.ingame.menu.addposkeyframe");
private final GuiButton buttonPlaceSelected = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 0, 60, 20); private final GuiButton buttonPlaceSelected = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 0, 60, 20, "replaymod.gui.ingame.menu.removeposkeyframe");
private final GuiButton buttonTime = texturedButton(BUTTON_TIME_X, BOTTOM_ROW, 0, 80, 20); private final GuiButton buttonTime = texturedButton(BUTTON_TIME_X, BOTTOM_ROW, 0, 80, 20, "replaymod.gui.ingame.menu.addtimekeyframe");
private final GuiButton buttonTimeSelected = texturedButton(BUTTON_TIME_X, BOTTOM_ROW, 0, 100, 20); private final GuiButton buttonTimeSelected = texturedButton(BUTTON_TIME_X, BOTTOM_ROW, 0, 100, 20, "replaymod.gui.ingame.menu.removetimekeyframe");
private final GuiButton buttonZoomIn = texturedButton(WIDTH - 14 - 9, BOTTOM_ROW, 40, 20, 9); private final GuiButton buttonZoomIn = texturedButton(WIDTH - 14 - 9, BOTTOM_ROW, 40, 20, 9, "replaymod.gui.ingame.menu.zoomin");
private final GuiButton buttonZoomOut = texturedButton(WIDTH - 14 - 9, BOTTOM_ROW + 11, 40, 30, 9); private final GuiButton buttonZoomOut = texturedButton(WIDTH - 14 - 9, BOTTOM_ROW + 11, 40, 30, 9, "replaymod.gui.ingame.menu.zoomout");
private final GuiTimeline timeline = new GuiTimeline(TIMELINE_X, TOP_ROW - 1, WIDTH - 14 - TIMELINE_X); private final GuiTimeline timeline = new GuiTimeline(TIMELINE_X, TOP_ROW - 1, WIDTH - 14 - TIMELINE_X);
private final GuiKeyframeTimeline timelineReal = new GuiKeyframeTimeline(TIMELINE_REAL_X, BOTTOM_ROW - 1, TIMELINE_REAL_WIDTH); private final GuiKeyframeTimeline timelineReal = new GuiKeyframeTimeline(TIMELINE_REAL_X, BOTTOM_ROW - 1, TIMELINE_REAL_WIDTH);

View File

@@ -274,4 +274,17 @@ replaymod.gui.rendering.resume=Resume Rendering
replaymod.gui.rendering.cancel=Cancel Rendering replaymod.gui.rendering.cancel=Cancel Rendering
replaymod.gui.rendering.cancel.callback=Are you sure? replaymod.gui.rendering.cancel.callback=Are you sure?
replaymod.gui.rendering.preview=Show Preview (Performance might suffer) replaymod.gui.rendering.preview=Show Preview (Performance might suffer)
replaymod.gui.rendering.progress=Frames rendered: %1$d / %2$d replaymod.gui.rendering.progress=Frames rendered: %1$d / %2$d
#Ingame Menu
replaymod.gui.ingame.menu.addposkeyframe=Add Position Keyframe
replaymod.gui.ingame.menu.removeposkeyframe=Remove Position Keyframe
replaymod.gui.ingame.menu.addtimekeyframe=Add Time Keyframe
replaymod.gui.ingame.menu.removetimekeyframe=Remove Time Keyframe
replaymod.gui.ingame.menu.pause=Pause Replay
replaymod.gui.ingame.menu.unpause=Unpause Replay
replaymod.gui.ingame.menu.renderpath=Render Camera Path
replaymod.gui.ingame.menu.playpath=Play Camera Path
replaymod.gui.ingame.menu.pausepath=Pause Camera Path
replaymod.gui.ingame.menu.zoomin=Zoom in
replaymod.gui.ingame.menu.zoomout=Zoom out