mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 19:59:58 +00:00
#1731 Add progression percentage tooltip to machines
This commit is contained in:
1 parent
a201b48dc0
commit
e8ca0c1067
8 files changed
+116
-65
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package crazypants.enderio.machine.alloy;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -20,35 +21,21 @@ import crazypants.vecmath.Vector4f;
|
||||
|
||||
public class GuiAlloySmelter extends GuiPoweredMachineBase<TileAlloySmelter> {
|
||||
|
||||
private IconButton vanillaFurnaceButton;
|
||||
private final IconButton vanillaFurnaceButton;
|
||||
private final GuiToolTip vanillaFurnaceTooltip;
|
||||
|
||||
protected static final int SMELT_MODE_BUTTON_ID = 76;
|
||||
|
||||
public GuiAlloySmelter(InventoryPlayer par1InventoryPlayer, TileAlloySmelter furnaceInventory) {
|
||||
super(furnaceInventory, new ContainerAlloySmelter(par1InventoryPlayer, furnaceInventory));
|
||||
|
||||
addToolTip(new GuiToolTip(new Rectangle(0, 0, 0, 0), "") {
|
||||
vanillaFurnaceButton = new IconButton(getFontRenderer(), SMELT_MODE_BUTTON_ID, 0, 0, null, RenderUtil.BLOCK_TEX);
|
||||
vanillaFurnaceButton.setSize(BUTTON_SIZE, BUTTON_SIZE);
|
||||
|
||||
@Override
|
||||
protected void updateText() {
|
||||
text.clear();
|
||||
text.add(Lang.localize("gui.alloy.mode.heading"));
|
||||
String txt = Lang.localize("gui.alloy.mode.all");
|
||||
if(getTileEntity().getMode() == Mode.ALLOY) {
|
||||
txt = Lang.localize("gui.alloy.mode.alloy");
|
||||
} else if(getTileEntity().getMode() == Mode.FURNACE) {
|
||||
txt = Lang.localize("gui.alloy.mode.furnace");
|
||||
}
|
||||
text.add(txt);
|
||||
}
|
||||
vanillaFurnaceTooltip = new GuiToolTip(new Rectangle(xSize - 5 - BUTTON_SIZE, 62, BUTTON_SIZE, BUTTON_SIZE), (String[])null);
|
||||
|
||||
@Override
|
||||
public void onTick(int mouseX, int mouseY) {
|
||||
bounds.setBounds(xSize - 5 - BUTTON_SIZE, 60, BUTTON_SIZE, BUTTON_SIZE);
|
||||
super.onTick(mouseX, mouseY);
|
||||
}
|
||||
|
||||
});
|
||||
addProgressTooltip(55, 35, 14, 14);
|
||||
addProgressTooltip(103, 35, 14, 14);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -56,13 +43,13 @@ public class GuiAlloySmelter extends GuiPoweredMachineBase<TileAlloySmelter> {
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
int x = guiLeft + xSize - 5 - BUTTON_SIZE;
|
||||
int y = guiTop + 62;
|
||||
|
||||
vanillaFurnaceButton = new IconButton(getFontRenderer(), SMELT_MODE_BUTTON_ID, x, y, getIconForMode(), RenderUtil.BLOCK_TEX);
|
||||
vanillaFurnaceButton.setSize(BUTTON_SIZE, BUTTON_SIZE);
|
||||
vanillaFurnaceButton.xPosition = guiLeft + vanillaFurnaceTooltip.getBounds().x;
|
||||
vanillaFurnaceButton.yPosition = guiTop + vanillaFurnaceTooltip.getBounds().y;
|
||||
|
||||
buttonList.add(vanillaFurnaceButton);
|
||||
addToolTip(vanillaFurnaceTooltip);
|
||||
|
||||
updateVanillaFurnaceButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,21 +65,27 @@ public class GuiAlloySmelter extends GuiPoweredMachineBase<TileAlloySmelter> {
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id == SMELT_MODE_BUTTON_ID) {
|
||||
getTileEntity().setMode(getTileEntity().getMode().next());
|
||||
vanillaFurnaceButton.setIcon(getIconForMode());
|
||||
updateVanillaFurnaceButton();
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketClientState(getTileEntity()));
|
||||
} else {
|
||||
super.actionPerformed(par1GuiButton);
|
||||
}
|
||||
}
|
||||
|
||||
private IIcon getIconForMode() {
|
||||
private void updateVanillaFurnaceButton() {
|
||||
IIcon icon = EnderIO.blockAlloySmelter.vanillaSmeltingOn;
|
||||
String unlocText = "gui.alloy.mode.all";
|
||||
if(getTileEntity().getMode() == Mode.ALLOY) {
|
||||
icon = EnderIO.blockAlloySmelter.vanillaSmeltingOff;
|
||||
unlocText = "gui.alloy.mode.alloy";
|
||||
} else if(getTileEntity().getMode() == Mode.FURNACE) {
|
||||
icon = EnderIO.blockAlloySmelter.vanillaSmeltingOnly;
|
||||
unlocText = "gui.alloy.mode.furnace";
|
||||
}
|
||||
return icon;
|
||||
vanillaFurnaceButton.setIcon(icon);
|
||||
vanillaFurnaceTooltip.setToolTipText(
|
||||
Lang.localize("gui.alloy.mode.heading"),
|
||||
Lang.localize(unlocText));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,15 +96,13 @@ public class GuiAlloySmelter extends GuiPoweredMachineBase<TileAlloySmelter> {
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/alloySmelter.png");
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
int sx = guiLeft;
|
||||
int sy = guiTop;
|
||||
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int scaled;
|
||||
|
||||
if(getTileEntity().getProgress() < 1 && getTileEntity().getProgress() > 0) {
|
||||
scaled = getTileEntity().getProgressScaled(14) + 1;
|
||||
if(shouldRenderProgress()) {
|
||||
int scaled = getTileEntity().getProgressScaled(14) + 1;
|
||||
drawTexturedModalRect(sx + 55, sy + 49 - scaled, 176, 14 - scaled, 14, scaled);
|
||||
drawTexturedModalRect(sx + 103, sy + 49 - scaled, 176, 14 - scaled, 14, scaled);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ public class GuiCrusher extends GuiPoweredMachineBase<TileCrusher> {
|
||||
text.add(getTileEntity().getBallDurationScaled(100) + "%");
|
||||
}
|
||||
});
|
||||
|
||||
addProgressTooltip(79, 31, 18, 24);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,15 +34,15 @@ public class GuiCrusher extends GuiPoweredMachineBase<TileCrusher> {
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/crusher.png");
|
||||
int guiLeft = (width - xSize) / 2;
|
||||
int guiTop = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int barHeight = getTileEntity().getProgressScaled(24);
|
||||
drawTexturedModalRect(guiLeft + 79, guiTop + 31, 200, 0, 18, barHeight + 1);
|
||||
if(shouldRenderProgress()) {
|
||||
int barHeight = getTileEntity().getProgressScaled(24);
|
||||
drawTexturedModalRect(guiLeft + 79, guiTop + 31, 200, 0, 18, barHeight + 1);
|
||||
}
|
||||
|
||||
barHeight = getTileEntity().getBallDurationScaled(16);
|
||||
int barHeight = getTileEntity().getBallDurationScaled(16);
|
||||
if(barHeight > 0) {
|
||||
drawTexturedModalRect(guiLeft + 142, guiTop + 23 + (16 - barHeight), 186, 31, 4, barHeight);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package crazypants.enderio.machine.gui;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -16,6 +21,7 @@ import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.gui.GuiContainerBase;
|
||||
import crazypants.gui.GuiToolTip;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Lang;
|
||||
@@ -30,22 +36,23 @@ public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends Gu
|
||||
private static final int CONFIG_ID = 8962349;
|
||||
private static final int RECIPE_ID = CONFIG_ID + 1;
|
||||
|
||||
private T tileEntity;
|
||||
private final T tileEntity;
|
||||
|
||||
protected RedstoneModeButton redstoneButton;
|
||||
|
||||
private GuiOverlayIoConfig configOverlay;
|
||||
private final GuiOverlayIoConfig configOverlay;
|
||||
|
||||
protected ToggleButtonEIO configB;
|
||||
|
||||
protected IconButtonEIO recipeButton;
|
||||
|
||||
protected List<GuiToolTip> progressTooltips;
|
||||
protected int lastProgressTooltipValue = -1;
|
||||
|
||||
protected GuiMachineBase(T machine, Container par1Container) {
|
||||
super(par1Container);
|
||||
tileEntity = machine;
|
||||
|
||||
xSize = getXSize();
|
||||
ySize = getYSize();
|
||||
int x = getXSize() - 5 - BUTTON_SIZE;
|
||||
int y = 5;
|
||||
redstoneButton = new RedstoneModeButton(this, -1, x, y, tileEntity, new BlockCoord(tileEntity));
|
||||
@@ -151,4 +158,45 @@ public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends Gu
|
||||
protected T getTileEntity() {
|
||||
return tileEntity;
|
||||
}
|
||||
|
||||
protected void addProgressTooltip(int x, int y, int w, int h) {
|
||||
if(progressTooltips == null) {
|
||||
progressTooltips = new ArrayList<GuiToolTip>();
|
||||
}
|
||||
|
||||
GuiToolTip tt = new GuiToolTip(new Rectangle(x, y, w, h), (String[])null);
|
||||
progressTooltips.add(tt);
|
||||
addToolTip(tt);
|
||||
}
|
||||
|
||||
private void updateProgressTooltips(int progress) {
|
||||
if(lastProgressTooltipValue == progress || progressTooltips == null) {
|
||||
return;
|
||||
}
|
||||
lastProgressTooltipValue = progress;
|
||||
|
||||
if(progress < 0) {
|
||||
for(GuiToolTip tt : progressTooltips) {
|
||||
tt.setVisible(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = MessageFormat.format(Lang.localize("gui.progress"), progress);
|
||||
for(GuiToolTip tt : progressTooltips) {
|
||||
tt.setToolTipText(msg);
|
||||
tt.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldRenderProgress() {
|
||||
float progress = tileEntity.getProgress();
|
||||
if(progress > 0 && progress < 1) {
|
||||
updateProgressTooltips((int)(progress * 100));
|
||||
return true;
|
||||
} else {
|
||||
updateProgressTooltips(-1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.gui.GuiPoweredMachineBase;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
@@ -16,6 +15,8 @@ public class GuiPainter extends GuiPoweredMachineBase<TileEntityPainter> {
|
||||
|
||||
public GuiPainter(InventoryPlayer par1InventoryPlayer, TileEntityPainter te) {
|
||||
super(te, new PainterContainer(par1InventoryPlayer, te));
|
||||
|
||||
addProgressTooltip(88, 34, 24, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,14 +27,15 @@ public class GuiPainter extends GuiPoweredMachineBase<TileEntityPainter> {
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/painter.png");
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
int k = guiLeft;
|
||||
int l = guiTop;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i1;
|
||||
|
||||
i1 = getTileEntity().getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 88, l + 34, 176, 14, i1 + 1, 16);
|
||||
if(shouldRenderProgress()) {
|
||||
int scaled = getTileEntity().getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 88, l + 34, 176, 14, scaled + 1, 16);
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ public class GuiSliceAndSplice extends GuiPoweredMachineBase<TileSliceAndSplice>
|
||||
|
||||
public GuiSliceAndSplice(InventoryPlayer par1InventoryPlayer, TileSliceAndSplice te) {
|
||||
super(te, new ContainerSliceAndSplice(par1InventoryPlayer, te));
|
||||
|
||||
addProgressTooltip(101, 46, 24, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,14 +23,15 @@ public class GuiSliceAndSplice extends GuiPoweredMachineBase<TileSliceAndSplice>
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/sliceAndSplice.png");
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
int k = guiLeft;
|
||||
int l = guiTop;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i1;
|
||||
|
||||
i1 = getTileEntity().getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 101, l + 46, 176, 14, i1 + 1, 16);
|
||||
if(shouldRenderProgress()) {
|
||||
int scaled = getTileEntity().getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 101, l + 46, 176, 14, scaled + 1, 16);
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
|
||||
@@ -20,13 +20,15 @@ public class GuiSoulBinder extends GuiPoweredMachineBase<TileSoulBinder> {
|
||||
|
||||
private static final int PLAYER_XP_ID = 985162394;
|
||||
|
||||
private IconButtonEIO usePlayerXP;
|
||||
private final IconButtonEIO usePlayerXP;
|
||||
|
||||
public GuiSoulBinder(InventoryPlayer par1InventoryPlayer, TileSoulBinder te) {
|
||||
super(te, new ContainerSoulBinder(par1InventoryPlayer, te));
|
||||
usePlayerXP = new IconButtonEIO(this, PLAYER_XP_ID, 125, 57, IconEIO.XP);
|
||||
usePlayerXP.visible = false;
|
||||
usePlayerXP.setToolTip("Use Player XP");
|
||||
|
||||
addProgressTooltip(80, 34, 24, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,18 +57,20 @@ public class GuiSoulBinder extends GuiPoweredMachineBase<TileSoulBinder> {
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/soulFuser.png");
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
int k = guiLeft;
|
||||
int l = guiTop;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
int i1;
|
||||
|
||||
TileSoulBinder binder = getTileEntity();
|
||||
|
||||
i1 = binder.getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 80, l + 34, 176, 14, i1 + 1, 16);
|
||||
if(shouldRenderProgress()) {
|
||||
i1 = binder.getProgressScaled(24);
|
||||
drawTexturedModalRect(k + 80, l + 34, 176, 14, i1 + 1, 16);
|
||||
}
|
||||
|
||||
boolean needsXp = getTileEntity().getCurrentlyRequiredLevel() > 0 && binder.getCurrentlyRequiredLevel() > binder.getContainer().getExperienceLevel();
|
||||
boolean needsXp = binder.getCurrentlyRequiredLevel() > 0 && binder.getCurrentlyRequiredLevel() > binder.getContainer().getExperienceLevel();
|
||||
usePlayerXP.visible = needsXp;
|
||||
|
||||
ExperienceBarRenderer.render(this, getGuiLeft() + 56, getGuiTop() + 68, 65, binder.getContainer(), binder.getCurrentlyRequiredLevel());
|
||||
|
||||
@@ -26,7 +26,7 @@ public class GuiVat extends GuiPoweredMachineBase<TileVat> {
|
||||
|
||||
private static final String GUI_TEXTURE = "enderio:textures/gui/vat.png";
|
||||
|
||||
private IconButtonEIO dump1, dump2;
|
||||
private final IconButtonEIO dump1, dump2;
|
||||
|
||||
public GuiVat(InventoryPlayer inventory, TileVat te) {
|
||||
super(te, new ContainerVat(inventory, te));
|
||||
@@ -65,6 +65,8 @@ public class GuiVat extends GuiPoweredMachineBase<TileVat> {
|
||||
dump1.setToolTip(Lang.localize("gui.machine.vat.dump.1"));
|
||||
dump2 = new IconButtonEIO(this, 2, 131, 62, IconEIO.REDSTONE_MODE_NEVER);
|
||||
dump2.setToolTip(Lang.localize("gui.machine.vat.dump.2"));
|
||||
|
||||
addProgressTooltip(81, 63, 14, 14);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,12 +99,10 @@ public class GuiVat extends GuiPoweredMachineBase<TileVat> {
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture(GUI_TEXTURE);
|
||||
int guiLeft = (width - xSize) / 2;
|
||||
int guiTop = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
TileVat vat = getTileEntity();
|
||||
|
||||
if(vat.getProgress() < 1 && vat.getProgress() > 0) {
|
||||
if(shouldRenderProgress()) {
|
||||
int scaled = vat.getProgressScaled(14) + 1;
|
||||
drawTexturedModalRect(guiLeft + 81, guiTop + 77 - scaled, 176, 14 - scaled, 14, scaled);
|
||||
|
||||
|
||||
Reference in new issue
Block a user