From f1376aba74e36fa59f7a69f3dc2837491bd9a909 Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 9 Nov 2013 12:54:57 -0500 Subject: [PATCH] Started on a power bar GUI component Should be a simple and fast way for any GUI to create a power bar on the screen --- src/dark/core/client/gui/GuiMachineBase.java | 56 ++++++++++++++++++++ src/dark/core/prefab/invgui/GuiPowerBar.java | 22 ++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/dark/core/prefab/invgui/GuiPowerBar.java diff --git a/src/dark/core/client/gui/GuiMachineBase.java b/src/dark/core/client/gui/GuiMachineBase.java index 7cf8fc6a..3fc5c684 100644 --- a/src/dark/core/client/gui/GuiMachineBase.java +++ b/src/dark/core/client/gui/GuiMachineBase.java @@ -1,6 +1,12 @@ package dark.core.client.gui; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import dark.core.common.DarkMain; import dark.core.prefab.invgui.GuiBase; +import dark.core.prefab.invgui.GuiButtonImage; +import dark.core.prefab.machine.TileEntityMachine; /** To be used with all machine that have a gui to allow generic settings and feature all all devices * @@ -8,6 +14,56 @@ import dark.core.prefab.invgui.GuiBase; public class GuiMachineBase extends GuiBase { + public static final ResourceLocation TEXTURE = new ResourceLocation(DarkMain.getInstance().DOMAIN, DarkMain.GUI_DIRECTORY + "gui_base_machine.png"); + + protected static final int MAX_BUTTON_ID = 3; + protected TileEntityMachine tileEntity; + protected EntityPlayer entityPlayer; + + public GuiMachineBase(EntityPlayer player, TileEntityMachine tileEntity) + { + this.tileEntity = tileEntity; + this.entityPlayer = player; + this.guiSize.y = 380 / 2; + } + + @Override + public void initGui() + { + super.initGui(); + this.buttonList.clear(); + // Inventory, Should be the Gui the machine opens to unless it has no inventory + this.buttonList.add(new GuiButtonImage(0, (this.width - this.guiSize.intX()) / 2 - 22, (this.height - this.guiSize.intY()) / 2 + 0, 3)); + // Machine settings + this.buttonList.add(new GuiButtonImage(1, (this.width - this.guiSize.intX()) / 2 - 22, (this.height - this.guiSize.intY()) / 2 + 22, 0)); + // About page, should display information about the machines power needs, help information, and tips + this.buttonList.add(new GuiButtonImage(2, (this.width - this.guiSize.intX()) / 2 - 22, (this.height - this.guiSize.intY()) / 2 + 44, 2)); + + } + + @Override + protected void actionPerformed(GuiButton button) + { + switch (button.id) + { + case 0: + { + //TODO open main GUI + break; + } + case 1: + { + //TODO open second GUI + break; + } + case 2: + { + //TODO open third GUI + break; + } + } + } + @Override protected void drawForegroundLayer(int var2, int var3, float var1) { diff --git a/src/dark/core/prefab/invgui/GuiPowerBar.java b/src/dark/core/prefab/invgui/GuiPowerBar.java new file mode 100644 index 00000000..876489f4 --- /dev/null +++ b/src/dark/core/prefab/invgui/GuiPowerBar.java @@ -0,0 +1,22 @@ +package dark.core.prefab.invgui; + +import universalelectricity.core.vector.Vector2; +import net.minecraft.client.gui.Gui; + +/** When done should be a prefab that can be used to render a power bar on the screen + * + * @author DarkGuardsman */ +public class GuiPowerBar extends Gui +{ + float currentLevel = 0; + float maxLevel = 10; + + protected Vector2 size; + protected Vector2 position; + + public GuiPowerBar(int xx, int yy, int width, int height) + { + this.size = new Vector2(width, height); + this.position = new Vector2(xx, yy); + } +}