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
This commit is contained in:
Robert 2013-11-09 12:54:57 -05:00
parent a039f46a6f
commit f1376aba74
2 changed files with 78 additions and 0 deletions

View file

@ -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)
{

View file

@ -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);
}
}