2015-06-16 14:38:46 +02:00
|
|
|
package techreborn.client.gui;
|
|
|
|
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
2015-11-08 13:15:45 +01:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
2016-02-21 15:16:55 +01:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-06-16 14:38:46 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-03-13 17:08:30 +01:00
|
|
|
import net.minecraft.util.text.translation.I18n;
|
2015-11-08 13:15:45 +01:00
|
|
|
import reborncore.common.packets.PacketHandler;
|
2016-02-24 22:10:44 +01:00
|
|
|
import reborncore.common.powerSystem.PowerSystem;
|
2015-06-16 14:38:46 +02:00
|
|
|
import techreborn.client.container.ContainerIDSU;
|
2015-06-17 18:01:26 +02:00
|
|
|
import techreborn.packets.PacketIdsu;
|
|
|
|
import techreborn.tiles.idsu.TileIDSU;
|
2015-06-16 14:38:46 +02:00
|
|
|
|
2016-03-13 16:37:55 +01:00
|
|
|
import java.awt.*;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2015-11-08 13:15:45 +01:00
|
|
|
public class GuiIDSU extends GuiContainer {
|
|
|
|
|
|
|
|
private static final ResourceLocation texture = new ResourceLocation(
|
|
|
|
"techreborn", "textures/gui/aesu.png");
|
2015-06-16 14:38:46 +02:00
|
|
|
|
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
TileIDSU idsu;
|
2015-06-16 14:38:46 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
ContainerIDSU containerIDSU;
|
2015-06-16 14:38:46 +02:00
|
|
|
|
2015-06-17 12:14:46 +02:00
|
|
|
|
2015-10-09 23:31:26 +02:00
|
|
|
public GuiIDSU(EntityPlayer player, TileIDSU tileIDSU) {
|
2015-08-09 12:05:32 +02:00
|
|
|
super(new ContainerIDSU(tileIDSU, player));
|
2015-10-09 23:31:26 +02:00
|
|
|
this.xSize = 176;
|
|
|
|
this.ySize = 165;
|
2015-08-09 12:05:32 +02:00
|
|
|
idsu = tileIDSU;
|
|
|
|
this.containerIDSU = (ContainerIDSU) this.inventorySlots;
|
|
|
|
}
|
2015-06-16 14:38:46 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
|
|
|
public void initGui() {
|
|
|
|
super.initGui();
|
|
|
|
this.buttonList.clear();
|
|
|
|
int k = (this.width - this.xSize) / 2;
|
|
|
|
int l = (this.height - this.ySize) / 2;
|
2015-10-09 23:31:26 +02:00
|
|
|
this.buttonList.add(new GuiButton(0, k + 128, l + 5, 15, 15, "++"));
|
|
|
|
this.buttonList.add(new GuiButton(1, k + 128, l + 5 + 20, 15, 15, "+"));
|
|
|
|
this.buttonList.add(new GuiButton(2, k + 128, l + 5 + (20 * 2), 15, 15, "-"));
|
|
|
|
this.buttonList.add(new GuiButton(3, k + 128, l + 5 + (20 * 3), 15, 15, "--"));
|
2015-08-09 12:05:32 +02:00
|
|
|
this.buttonList.add(new GuiButton(4, k + 40, l + 10, 10, 10, "+"));
|
2015-11-08 13:15:45 +01:00
|
|
|
}
|
2015-06-17 18:01:26 +02:00
|
|
|
|
2015-11-08 13:15:45 +01:00
|
|
|
@Override
|
|
|
|
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
|
|
|
|
int p_146976_2_, int p_146976_3_) {
|
2016-02-21 15:16:55 +01:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
2015-11-08 13:15:45 +01:00
|
|
|
this.mc.getTextureManager().bindTexture(texture);
|
|
|
|
int k = (this.width - this.xSize) / 2;
|
|
|
|
int l = (this.height - this.ySize) / 2;
|
|
|
|
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
|
|
|
}
|
2015-06-17 18:01:26 +02:00
|
|
|
|
2015-11-08 13:15:45 +01:00
|
|
|
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
|
|
|
|
int p_146979_2_) {
|
2016-03-13 17:08:30 +01:00
|
|
|
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.idsu.name"), 40, 10, Color.WHITE.getRGB());
|
2016-02-24 22:10:44 +01:00
|
|
|
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.euOut) + "/tick", 10, 20, Color.WHITE.getRGB());
|
|
|
|
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.storedEu), 10, 30, Color.WHITE.getRGB());
|
|
|
|
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.euChange) + " change", 10, 40, Color.WHITE.getRGB());
|
2015-08-09 12:05:32 +02:00
|
|
|
}
|
2015-06-17 18:01:26 +02:00
|
|
|
|
2015-08-09 12:05:32 +02:00
|
|
|
@Override
|
2015-11-23 19:41:29 +01:00
|
|
|
protected void actionPerformed(GuiButton button) throws IOException {
|
2015-08-09 12:05:32 +02:00
|
|
|
super.actionPerformed(button);
|
2015-11-08 13:15:45 +01:00
|
|
|
PacketHandler.sendPacketToServer(new PacketIdsu(button.id, idsu));
|
2015-08-09 12:05:32 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isInteger(String s) {
|
|
|
|
return isInteger(s, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isInteger(String s, int radix) {
|
|
|
|
if (s.isEmpty()) return false;
|
|
|
|
for (int i = 0; i < s.length(); i++) {
|
|
|
|
if (i == 0 && s.charAt(i) == '-') {
|
|
|
|
if (s.length() == 1) return false;
|
|
|
|
else continue;
|
|
|
|
}
|
|
|
|
if (Character.digit(s.charAt(i), radix) < 0) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-06-16 14:38:46 +02:00
|
|
|
|
|
|
|
}
|