aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/craftgui/minecraft/control
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
commit869c206c4fcc8001bd2e1d66f704290331813835 (patch)
tree96735ce8fe4665e2759c3374221d6f06f4527df2 /src/Java/binnie/craftgui/minecraft/control
parentec2c72827f01dd4bb2174137f1ab162f9ddaab62 (diff)
downloadGT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.gz
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.bz2
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.zip
Initial Commit
Diffstat (limited to 'src/Java/binnie/craftgui/minecraft/control')
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java161
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java113
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlHelp.java41
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java25
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlImage.java25
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlInfo.java38
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java98
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java223
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java14
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java108
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java39
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlProgress.java30
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java100
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlide.java113
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlot.java221
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java76
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java77
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java43
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java47
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlUser.java41
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java28
21 files changed, 1661 insertions, 0 deletions
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java b/src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java
new file mode 100644
index 0000000000..0337b154c1
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java
@@ -0,0 +1,161 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.Machine;
+import binnie.core.machines.TileEntityMachine;
+import binnie.core.machines.power.IPoweredMachine;
+import binnie.core.machines.power.IProcess;
+import binnie.core.machines.power.PowerInfo;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+import binnie.craftgui.minecraft.MinecraftTooltip;
+import binnie.craftgui.minecraft.MinecraftTooltip.Type;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import net.minecraft.inventory.IInventory;
+import org.lwjgl.opengl.GL11;
+
+public class ControlEnergyBar
+ extends Control
+ implements ITooltip
+{
+ public static boolean isError;
+ private Position direction;
+
+ public ControlEnergyBar(IWidget parent, int x, int y, int width, int height, Position direction)
+ {
+ super(parent, x, y, width, height);
+ this.direction = direction;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public IPoweredMachine getClientPower()
+ {
+ IInventory inventory = Window.get(this).getInventory();
+ TileEntityMachine machine = (TileEntityMachine)((inventory instanceof TileEntityMachine) ? inventory : null);
+ if (machine == null) {
+ return null;
+ }
+ IPoweredMachine clientPower = (IPoweredMachine)machine.getMachine().getInterface(IPoweredMachine.class);
+ return clientPower;
+ }
+
+ public float getPercentage()
+ {
+ float percentage = 100.0F * getStoredEnergy() / getMaxEnergy();
+ if (percentage > 100.0F) {
+ percentage = 100.0F;
+ }
+ return percentage;
+ }
+
+ private float getStoredEnergy()
+ {
+ return Window.get(this).getContainer().getPowerInfo().getStoredEnergy();
+ }
+
+ private float getMaxEnergy()
+ {
+ return Window.get(this).getContainer().getPowerInfo().getMaxEnergy();
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.add((int)getPercentage() + "% charged");
+
+ tooltip.add(getStoredEnergy() + "/" + getMaxEnergy() + " RF");
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ tooltip.add("Energy Bar");
+ tooltip.add("Current: " + getStoredEnergy() + " RF (" + (int)getPercentage() + "%)");
+ tooltip.add("Capacity: " + getMaxEnergy() + " RF");
+
+ IProcess process = (IProcess)Machine.getInterface(IProcess.class, Window.get(this).getInventory());
+ if (process != null) {
+ tooltip.add("Usage: " + (int)process.getEnergyPerTick() + " RF");
+ }
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.EnergyBarBack, getArea());
+
+ float percentage = getPercentage() / 100.0F;
+
+ CraftGUI.Render.colour(getColourFromPercentage(percentage));
+
+ IArea area = getArea();
+ switch (1.$SwitchMap$binnie$craftgui$core$geometry$Position[this.direction.ordinal()])
+ {
+ case 1:
+ case 2:
+ float height = area.size().y() * percentage;
+ area.setSize(new IPoint(area.size().x(), height));
+
+ break;
+ case 3:
+ case 4:
+ float width = area.size().x() * percentage;
+ area.setSize(new IPoint(width, area.size().y()));
+ }
+ if ((isMouseOver()) && (Window.get(this).getGui().isHelpMode()))
+ {
+ int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
+ CraftGUI.Render.gradientRect(getArea().inset(1), c, c);
+ }
+ else if (isError)
+ {
+ int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
+ CraftGUI.Render.gradientRect(getArea().inset(1), c, c);
+ }
+ CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlow, area);
+
+ GL11.glColor3d(1.0D, 1.0D, 1.0D);
+
+ CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlass, getArea());
+ }
+
+ public void onRenderForeground()
+ {
+ if ((isMouseOver()) && (Window.get(this).getGui().isHelpMode()))
+ {
+ IArea area = getArea();
+ CraftGUI.Render.colour(MinecraftTooltip.getOutline(Tooltip.Type.Help));
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ else if (isError)
+ {
+ IArea area = getArea();
+ CraftGUI.Render.colour(MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error));
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ }
+
+ public int getColourFromPercentage(float percentage)
+ {
+ int colour = 16777215;
+ if (percentage > 0.5D)
+ {
+ int r = (int)((1.0D - 2.0D * (percentage - 0.5D)) * 255.0D);
+ colour = (r << 16) + 65280;
+ }
+ else
+ {
+ int g = (int)(255.0F * (2.0F * percentage));
+ colour = 16711680 + (g << 8);
+ }
+ return colour;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java b/src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java
new file mode 100644
index 0000000000..6027371297
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java
@@ -0,0 +1,113 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.power.ErrorState;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.CustomSlot;
+import binnie.craftgui.minecraft.MinecraftTooltip;
+import binnie.craftgui.minecraft.MinecraftTooltip.Type;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import java.util.List;
+import java.util.Map;
+import net.minecraft.entity.player.InventoryPlayer;
+
+public class ControlErrorState
+ extends Control
+ implements ITooltip
+{
+ private ErrorState errorState;
+
+ public void onRenderBackground()
+ {
+ Object texture = CraftGUITexture.StateWarning;
+ if (this.errorState == null) {
+ texture = CraftGUITexture.StateNone;
+ } else if (this.type == 0) {
+ texture = CraftGUITexture.StateError;
+ }
+ CraftGUI.Render.texture(texture, IPoint.ZERO);
+
+ super.onRenderBackground();
+ }
+
+ public ErrorState getError()
+ {
+ return Window.get(this).getContainer().getErrorState();
+ }
+
+ public final void onUpdateClient()
+ {
+ this.errorState = getError();
+ this.type = Window.get(this).getContainer().getErrorType();
+
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Error)).clear();
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Warning)).clear();
+ ControlLiquidTank.tankError.clear();
+ ControlEnergyBar.isError = false;
+ if ((!isMouseOver()) || (this.errorState == null)) {
+ return;
+ }
+ ControlEnergyBar.isError = this.errorState.isPowerError();
+ if (this.errorState.isItemError()) {
+ for (int slot : this.errorState.getData())
+ {
+ int id = -1;
+ for (CustomSlot cslot : Window.get(this).getContainer().getCustomSlots()) {
+ if ((!(cslot.inventory instanceof InventoryPlayer)) && (cslot.getSlotIndex() == slot)) {
+ id = cslot.slotNumber;
+ }
+ }
+ if (id >= 0) {
+ if (this.type == 0) {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Error)).add(Integer.valueOf(id));
+ } else {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Warning)).add(Integer.valueOf(id));
+ }
+ }
+ }
+ }
+ if (this.errorState.isTankError()) {
+ for (int slot : this.errorState.getData()) {
+ ControlLiquidTank.tankError.add(Integer.valueOf(slot));
+ }
+ }
+ }
+
+ private int type = 0;
+
+ public ControlErrorState(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void getTooltip(Tooltip tooltipOrig)
+ {
+ MinecraftTooltip tooltip = (MinecraftTooltip)tooltipOrig;
+ if (this.errorState != null)
+ {
+ if (this.type == 0) {
+ tooltip.setType(MinecraftTooltip.Type.Error);
+ } else {
+ tooltip.setType(MinecraftTooltip.Type.Warning);
+ }
+ tooltip.add(this.errorState.toString());
+ if (this.errorState.getTooltip().length() > 0) {
+ tooltip.add(this.errorState.getTooltip());
+ }
+ }
+ }
+
+ public ErrorState getErrorState()
+ {
+ return this.errorState;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlHelp.java b/src/Java/binnie/craftgui/minecraft/control/ControlHelp.java
new file mode 100644
index 0000000000..d2027747f2
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlHelp.java
@@ -0,0 +1,41 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlHelp
+ extends Control
+ implements ITooltip
+{
+ public ControlHelp(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.HelpButton, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.setType(Tooltip.Type.Help);
+ tooltip.add("Help");
+ tooltip.add("To activate help tooltips,");
+ tooltip.add("hold down the tab key and");
+ tooltip.add("mouse over controls.");
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ getTooltip(tooltip);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java b/src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java
new file mode 100644
index 0000000000..071e8ee888
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java
@@ -0,0 +1,25 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import net.minecraft.util.IIcon;
+
+public class ControlIconDisplay
+ extends Control
+{
+ private IIcon icon = null;
+
+ public ControlIconDisplay(IWidget parent, float x, float y, IIcon icon)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ this.icon = icon;
+ }
+
+ public void onRenderForeground()
+ {
+ CraftGUI.Render.iconItem(IPoint.ZERO, this.icon);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlImage.java b/src/Java/binnie/craftgui/minecraft/control/ControlImage.java
new file mode 100644
index 0000000000..0d08626852
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlImage.java
@@ -0,0 +1,25 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.Texture;
+
+public class ControlImage
+ extends Control
+{
+ private Object key = null;
+
+ public ControlImage(IWidget parent, float x, float y, Texture text)
+ {
+ super(parent, x, y, text.w(), text.h());
+ this.key = text;
+ }
+
+ public void onRenderForeground()
+ {
+ CraftGUI.Render.texture(this.key, IPoint.ZERO);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlInfo.java b/src/Java/binnie/craftgui/minecraft/control/ControlInfo.java
new file mode 100644
index 0000000000..8d9c8e95b6
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlInfo.java
@@ -0,0 +1,38 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlInfo
+ extends Control
+ implements ITooltip
+{
+ private String info;
+
+ public ControlInfo(IWidget parent, float x, float y, String info)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ this.info = info;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.InfoButton, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.setType(Tooltip.Type.Information);
+ tooltip.add("Info");
+ tooltip.add(this.info);
+ tooltip.setMaxWidth(200);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java b/src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java
new file mode 100644
index 0000000000..8db438bcc3
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java
@@ -0,0 +1,98 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.BinnieCore;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.Window;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+import org.lwjgl.opengl.GL11;
+
+public class ControlItemDisplay
+ extends Control
+ implements ITooltip
+{
+ private ItemStack itemStack = null;
+ public boolean hastooltip = false;
+
+ public void setTooltip()
+ {
+ this.hastooltip = true;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public ControlItemDisplay(IWidget parent, float x, float y)
+ {
+ this(parent, x, y, 16.0F);
+ }
+
+ public ControlItemDisplay(IWidget parent, float f, float y, ItemStack stack, boolean tooltip)
+ {
+ this(parent, f, y, 16.0F);
+ setItemStack(stack);
+ if (tooltip) {
+ setTooltip();
+ }
+ }
+
+ public ControlItemDisplay(IWidget parent, float x, float y, float size)
+ {
+ super(parent, x, y, size, size);
+ }
+
+ public void onRenderBackground()
+ {
+ IPoint relativeToWindow = getAbsolutePosition().sub(getSuperParent().getPosition());
+ if ((relativeToWindow.x() > Window.get(this).getSize().x() + 100.0F) || (relativeToWindow.y() > Window.get(this).getSize().y() + 100.0F)) {
+ return;
+ }
+ if (this.itemStack != null) {
+ if (getSize().x() != 16.0F)
+ {
+ GL11.glPushMatrix();
+ float scale = getSize().x() / 16.0F;
+ GL11.glScalef(scale, scale, 1.0F);
+ BinnieCore.proxy.getMinecraftInstance();float phase = (float)Minecraft.getSystemTime() / 20.0F;
+ CraftGUI.Render.item(IPoint.ZERO, this.itemStack, this.rotating);
+ GL11.glPopMatrix();
+ }
+ else
+ {
+ CraftGUI.Render.item(IPoint.ZERO, this.itemStack, this.rotating);
+ }
+ }
+ }
+
+ public void setItemStack(ItemStack itemStack)
+ {
+ this.itemStack = itemStack;
+ }
+
+ public ItemStack getItemStack()
+ {
+ return this.itemStack;
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if ((this.hastooltip) && (this.itemStack != null)) {
+ tooltip.add(this.itemStack.getTooltip(((Window)getSuperParent()).getPlayer(), false));
+ }
+ super.getTooltip(tooltip);
+ }
+
+ private boolean rotating = false;
+
+ public void setRotating()
+ {
+ this.rotating = true;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java b/src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java
new file mode 100644
index 0000000000..d69c61136d
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java
@@ -0,0 +1,223 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.BinnieCore;
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.MachineSide;
+import binnie.core.machines.inventory.TankSlot;
+import binnie.core.machines.inventory.Validator;
+import binnie.core.machines.power.ITankMachine;
+import binnie.core.machines.power.TankInfo;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+import binnie.craftgui.minecraft.MinecraftTooltip;
+import binnie.craftgui.minecraft.MinecraftTooltip.Type;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.opengl.GL11;
+
+public class ControlLiquidTank
+ extends Control
+ implements ITooltip
+{
+ public static List<Integer> tankError = new ArrayList();
+ private int tankID = 0;
+ private boolean horizontal = false;
+
+ public ControlLiquidTank(IWidget parent, int x, int y)
+ {
+ this(parent, x, y, false);
+ }
+
+ public ControlLiquidTank(IWidget parent, int x, int y, boolean horizontal)
+ {
+ super(parent, x, y, horizontal ? 60.0F : 18.0F, horizontal ? 18.0F : 60.0F);
+ this.horizontal = horizontal;
+ addAttribute(Attribute.MouseOver);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (event.getButton() == 0)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("id", (byte)ControlLiquidTank.this.tankID);
+ Window.get(ControlLiquidTank.this.getWidget()).sendClientAction("tank-click", nbt);
+ }
+ }
+ });
+ }
+
+ public void setTankID(int tank)
+ {
+ this.tankID = tank;
+ }
+
+ public TankInfo getTank()
+ {
+ return Window.get(this).getContainer().getTankInfo(this.tankID);
+ }
+
+ public boolean isTankValid()
+ {
+ return !getTank().isEmpty();
+ }
+
+ public int getTankCapacity()
+ {
+ return (int)getTank().getCapacity();
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTank : CraftGUITexture.LiquidTank, IPoint.ZERO);
+ if ((isMouseOver()) && (Window.get(this).getGui().isHelpMode()))
+ {
+ int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
+ CraftGUI.Render.gradientRect(getArea().inset(1), c, c);
+ }
+ else if (tankError.contains(Integer.valueOf(this.tankID)))
+ {
+ int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
+ CraftGUI.Render.gradientRect(getArea().inset(1), c, c);
+ }
+ else if (getSuperParent().getMousedOverWidget() == this)
+ {
+ if (Window.get(this).getGui().getDraggedItem() != null) {
+ CraftGUI.Render.gradientRect(getArea().inset(1), -1426089575, -1426089575);
+ } else {
+ CraftGUI.Render.gradientRect(getArea().inset(1), -2130706433, -2130706433);
+ }
+ }
+ if (isTankValid())
+ {
+ Object content = null;
+
+ float height = this.horizontal ? 16.0F : 58.0F;
+
+ int squaled = (int)(height * (getTank().getAmount() / getTank().getCapacity()));
+
+
+
+ int yPos = (int)height + 1;
+
+ Fluid fluid = getTank().liquid.getFluid();
+
+ int hex = fluid.getColor(getTank().liquid);
+
+ int r = (hex & 0xFF0000) >> 16;
+ int g = (hex & 0xFF00) >> 8;
+ int b = hex & 0xFF;
+
+ GL11.glColor4f(r / 255.0F, g / 255.0F, b / 255.0F, 1.0F);
+
+ GL11.glEnable(3042);
+
+ GL11.glBlendFunc(770, 771);
+
+ IPoint pos = getAbsolutePosition();
+ IPoint offset = new IPoint(0.0F, height - squaled);
+ IArea limited = getArea().inset(1);
+ if (this.horizontal) {
+ limited.setSize(new IPoint(limited.w() - 1.0F, limited.h()));
+ }
+ CraftGUI.Render.limitArea(new IArea(limited.pos().add(pos).add(offset), limited.size().sub(offset)));
+
+
+ GL11.glEnable(3089);
+
+ BinnieCore.proxy.bindTexture(TextureMap.locationItemsTexture);
+ for (int y = 0; y < height; y += 16) {
+ for (int x = 0; x < (this.horizontal ? 58 : 16); x += 16)
+ {
+ IIcon icon = fluid.getIcon();
+
+ CraftGUI.Render.iconBlock(new IPoint(1 + x, 1 + y), icon);
+ }
+ }
+ GL11.glDisable(3089);
+ GL11.glDisable(3042);
+ }
+ }
+
+ public void onRenderForeground()
+ {
+ CraftGUI.Render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTankOverlay : CraftGUITexture.LiquidTankOverlay, IPoint.ZERO);
+ if ((isMouseOver()) && (Window.get(this).getGui().isHelpMode()))
+ {
+ IArea area = getArea();
+ CraftGUI.Render.colour(MinecraftTooltip.getOutline(Tooltip.Type.Help));
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ if (tankError.contains(Integer.valueOf(this.tankID)))
+ {
+ IArea area = getArea();
+ CraftGUI.Render.colour(MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error));
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ if (getTankSlot() != null)
+ {
+ TankSlot slot = getTankSlot();
+ tooltip.add(slot.getName());
+ tooltip.add("Capacity: " + getTankCapacity() + " mB");
+ tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
+ tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
+ if (slot.isReadOnly()) {
+ tooltip.add("Output Only Tank");
+ }
+ tooltip.add("Accepts: " + (slot.getValidator() == null ? "Any Item" : slot.getValidator().getTooltip()));
+
+ return;
+ }
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if (isTankValid())
+ {
+ int percentage = (int)(100.0D * getTank().getAmount() / getTankCapacity());
+
+ tooltip.add(getTank().getName());
+
+ tooltip.add(percentage + "% full");
+ tooltip.add((int)getTank().getAmount() + " mB");
+
+
+
+ return;
+ }
+ tooltip.add("Empty");
+ }
+
+ private TankSlot getTankSlot()
+ {
+ ITankMachine tank = (ITankMachine)Machine.getInterface(ITankMachine.class, Window.get(this).getInventory());
+
+ return tank != null ? tank.getTankSlot(this.tankID) : null;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java b/src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java
new file mode 100644
index 0000000000..f2a64e3e38
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java
@@ -0,0 +1,14 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.resource.Texture;
+
+public class ControlMachineProgress
+ extends ControlProgress
+{
+ public ControlMachineProgress(IWidget parent, int x, int y, Texture base, Texture progress, Position dir)
+ {
+ super(parent, x, y, base, progress, dir);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java b/src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java
new file mode 100644
index 0000000000..f15d102789
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java
@@ -0,0 +1,108 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.minecraft.InventoryType;
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class ControlPlayerInventory
+ extends Control
+{
+ private List<ControlSlot> slots = new ArrayList();
+
+ public ControlPlayerInventory(IWidget parent, boolean wide)
+ {
+ super(parent, (int)(parent.getSize().x() / 2.0F) - (wide ? 110 : 81), (int)parent.getSize().y() - (wide ? 54 : 76) - 12, wide ? 'Ü' : '¢', wide ? 54 : 76);
+ for (int row = 0; row < 3; row++) {
+ for (int column = 0; column < 9; column++)
+ {
+ ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18);
+ this.slots.add(slot);
+ }
+ }
+ if (wide) {
+ for (int i1 = 0; i1 < 9; i1++)
+ {
+ ControlSlot slot = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18);
+ this.slots.add(slot);
+ }
+ } else {
+ for (int i1 = 0; i1 < 9; i1++)
+ {
+ ControlSlot slot = new ControlSlot(this, i1 * 18, 58.0F);
+ this.slots.add(slot);
+ }
+ }
+ create();
+ }
+
+ public ControlPlayerInventory(IWidget parent)
+ {
+ this(parent, false);
+ }
+
+ public ControlPlayerInventory(IWidget parent, int x, int y)
+ {
+ super(parent, x, y, 54.0F, 220.0F);
+ for (int row = 0; row < 6; row++) {
+ for (int column = 0; column < 6; column++)
+ {
+ ControlSlot slot = new ControlSlot(this, column * 18, row * 18);
+ this.slots.add(slot);
+ }
+ }
+ create();
+ }
+
+ public void create()
+ {
+ for (int row = 0; row < 3; row++) {
+ for (int column = 0; column < 9; column++)
+ {
+ ControlSlot slot = (ControlSlot)this.slots.get(column + row * 9);
+ slot.assign(InventoryType.Player, 9 + column + row * 9);
+ }
+ }
+ for (int i1 = 0; i1 < 9; i1++)
+ {
+ ControlSlot slot = (ControlSlot)this.slots.get(27 + i1);
+ slot.assign(InventoryType.Player, i1);
+ }
+ }
+
+ public void addItem(ItemStack item)
+ {
+ if (item == null) {
+ return;
+ }
+ for (ControlSlot slot : this.slots) {
+ if (!slot.slot.getHasStack())
+ {
+ slot.slot.putStack(item);
+ return;
+ }
+ }
+ }
+
+ public void addInventory(IInventory inventory)
+ {
+ for (int i = 0; i < inventory.getSizeInventory(); i++) {
+ addItem(inventory.getStackInSlot(i));
+ }
+ }
+
+ public ControlSlot getSlot(int i)
+ {
+ if ((i < 0) || (i >= this.slots.size())) {
+ return null;
+ }
+ return (ControlSlot)this.slots.get(i);
+ }
+
+ public void onUpdateClient() {}
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java b/src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java
new file mode 100644
index 0000000000..b0f522b180
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java
@@ -0,0 +1,39 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.power.PowerSystem;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlPowerSystem
+ extends Control
+ implements ITooltip
+{
+ private PowerSystem system;
+
+ public ControlPowerSystem(IWidget parent, float x, float y, PowerSystem system)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ this.system = system;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.PowerButton, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.setType(Tooltip.Type.Power);
+ tooltip.add("Power Supply");
+ tooltip.add("Powered by " + this.system.getUnitName());
+ tooltip.setMaxWidth(200);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlProgress.java b/src/Java/binnie/craftgui/minecraft/control/ControlProgress.java
new file mode 100644
index 0000000000..6508c84107
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlProgress.java
@@ -0,0 +1,30 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.Texture;
+
+public class ControlProgress
+ extends ControlProgressBase
+{
+ private Texture progressBlank;
+ private Texture progressBar;
+ private Position direction;
+
+ public ControlProgress(IWidget parent, int x, int y, Texture progressBlank, Texture progressBar, Position dir)
+ {
+ super(parent, x, y, progressBlank == null ? 0.0F : progressBlank.w(), progressBlank == null ? 0.0F : progressBlank.h());
+ this.progressBlank = progressBlank;
+ this.progressBar = progressBar;
+ this.progress = 0.0F;
+ this.direction = dir;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(this.progressBlank, getArea());
+ CraftGUI.Render.texturePercentage(this.progressBar, getArea(), this.direction, this.progress);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java b/src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java
new file mode 100644
index 0000000000..f7e2ef4f39
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java
@@ -0,0 +1,100 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.power.IProcess;
+import binnie.core.machines.power.ProcessInfo;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.Window;
+
+public class ControlProgressBase
+ extends Control
+{
+ protected float progress;
+
+ public ControlProgressBase(IWidget parent, float x, float y, float w, float h)
+ {
+ super(parent, x, y, w, h);
+ this.progress = 0.0F;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void setProgress(float progress)
+ {
+ this.progress = progress;
+ if (this.progress < 0.0F) {
+ this.progress = 0.0F;
+ } else if (this.progress > 1.0F) {
+ this.progress = 1.0F;
+ }
+ }
+
+ protected ProcessInfo getProcess()
+ {
+ return Window.get(this).getContainer().getProcessInfo();
+ }
+
+ public void onUpdateClient()
+ {
+ ProcessInfo process = getProcess();
+ if (process != null) {
+ setProgress(process.getCurrentProgress() / 100.0F);
+ }
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ ProcessInfo process = getProcess();
+
+ IProcess machineProcess = (IProcess)Machine.getMachine(Window.get(this).getInventory()).getInterface(IProcess.class);
+ if (process != null)
+ {
+ tooltip.add("Progress");
+ if (this.progress == 0.0F) {
+ tooltip.add("Not in Progress");
+ } else if (process.getProcessTime() > 0) {
+ tooltip.add(machineProcess.getTooltip() + " (" + (int)process.getCurrentProgress() + "%)");
+ } else {
+ tooltip.add("In Progress");
+ }
+ if (process.getProcessTime() > 0)
+ {
+ tooltip.add("Time Left: " + convertTime((int)((1.0F - this.progress) * process.getProcessTime())));
+
+ tooltip.add("Total Time: " + convertTime(process.getProcessTime()));
+ tooltip.add("Energy Cost: " + process.getProcessEnergy() * 10 + " RF");
+ }
+ else
+ {
+ tooltip.add("Energy Cost: " + process.getEnergyPerTick() * 10.0F + " RF / tick");
+ }
+ }
+ }
+
+ public static String convertTime(int time)
+ {
+ int seconds = (int)(time / 20.0F);
+ int minutes = 0;
+ while (seconds >= 60)
+ {
+ minutes++;
+ seconds -= 60;
+ }
+ String ts = "";
+ if (minutes > 0) {
+ ts = ts + minutes + " minute" + (minutes == 1 ? "" : "s");
+ }
+ if (seconds > 0)
+ {
+ if (ts.length() > 0) {
+ ts = ts + " ";
+ }
+ ts = ts + seconds + " second" + (seconds == 1 ? "" : "s");
+ }
+ return ts;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlide.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlide.java
new file mode 100644
index 0000000000..44cfe0fd37
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlide.java
@@ -0,0 +1,113 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import org.lwjgl.opengl.GL11;
+
+public class ControlSlide
+ extends Control
+{
+ private IArea expanded;
+ private IArea shrunk;
+ private boolean slideActive = true;
+ private Position anchor;
+ private String label = null;
+
+ public ControlSlide(IWidget parent, float x, float y, float w, float h, Position anchor2)
+ {
+ super(parent, x, y, w, h);
+ addAttribute(Attribute.MouseOver);
+ addAttribute(Attribute.BlockTooltip);
+ this.expanded = new IArea(getPosition(), getSize());
+ this.anchor = anchor2.opposite();
+ float border = this.anchor.x() != 0 ? this.expanded.w() - 6.0F : this.expanded.h() - 6.0F;
+ this.shrunk = this.expanded.inset(new IBorder(this.anchor, border));
+
+
+ this.slideActive = false;
+ }
+
+ public void onRenderBackground()
+ {
+ super.onRenderBackground();
+ if (this.label != null)
+ {
+ float lw = CraftGUI.Render.textWidth(this.label) + 16;
+ float lh = CraftGUI.Render.textHeight() + 16;
+ boolean hor = this.anchor.x() != 0;
+ IArea ar = isSlideActive() ? this.expanded : this.shrunk;
+ IArea tabArea = new IArea(hor ? -lh / 2.0F : -lw / 2.0F, hor ? -lw / 2.0F : -lh / 2.0F, hor ? lh : lw, hor ? lw : lh);
+ IPoint shift = new IPoint(ar.w() * (1 - this.anchor.x()) / 2.0F, ar.h() * (1 - this.anchor.y()) / 2.0F);
+
+
+
+
+ tabArea = tabArea.shift(shift.x() - (-3.0F + lh / 2.0F) * this.anchor.x(), shift.y() - (-3.0F + lh / 2.0F) * this.anchor.y());
+ Texture texture = CraftGUI.Render.getTexture(isSlideActive() ? CraftGUITexture.Tab : CraftGUITexture.TabDisabled).crop(this.anchor.opposite(), 8.0F);
+ CraftGUI.Render.texture(texture, tabArea);
+ texture = CraftGUI.Render.getTexture(CraftGUITexture.TabOutline).crop(this.anchor.opposite(), 8.0F);
+ CraftGUI.Render.texture(texture, tabArea.inset(2));
+ IArea labelArea = new IArea(-lw / 2.0F, 0.0F, lw, lh);
+ GL11.glPushMatrix();
+ GL11.glTranslatef(shift.x() + this.anchor.x() * 2.0F, shift.y() + this.anchor.y() * 2.0F, 0.0F);
+ if (this.anchor.x() != 0) {
+ GL11.glRotatef(90.0F, 0.0F, 0.0F, this.anchor.x());
+ }
+ if (this.anchor.y() > 0) {
+ GL11.glTranslatef(0.0F, -lh, 0.0F);
+ }
+ CraftGUI.Render.text(labelArea, TextJustification.MiddleCenter, this.label, 16777215);
+ GL11.glPopMatrix();
+ }
+ CraftGUI.Render.texture(CraftGUITexture.Window, getArea());
+ Object slideTexture = this.anchor == Position.Left ? CraftGUITexture.SlideLeft : this.anchor == Position.Top ? CraftGUITexture.SlideUp : this.anchor == Position.Bottom ? CraftGUITexture.SlideDown : CraftGUITexture.SlideRight;
+
+ CraftGUI.Render.texture(slideTexture, new IPoint((this.anchor.x() + 1.0F) * w() / 2.0F - 8.0F, (this.anchor.y() + 1.0F) * h() / 2.0F - 8.0F));
+ }
+
+ public boolean isSlideActive()
+ {
+ return this.slideActive;
+ }
+
+ public void onUpdateClient()
+ {
+ boolean mouseOver = isMouseOverWidget(getRelativeMousePosition());
+ if (mouseOver != this.slideActive) {
+ setSlide(mouseOver);
+ }
+ }
+
+ public boolean isMouseOverWidget(IPoint relativeMouse)
+ {
+ return getArea().outset(isSlideActive() ? 16 : 8).outset(new IBorder(this.anchor.opposite(), 16.0F)).contains(relativeMouse);
+ }
+
+ public boolean isChildVisible(IWidget child)
+ {
+ return this.slideActive;
+ }
+
+ public void setSlide(boolean b)
+ {
+ this.slideActive = b;
+ IArea area = isSlideActive() ? this.expanded : this.shrunk;
+ setSize(area.size());
+ setPosition(area.pos());
+ }
+
+ public void setLabel(String l)
+ {
+ this.label = l;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlot.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlot.java
new file mode 100644
index 0000000000..c3de12acaa
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlot.java
@@ -0,0 +1,221 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.inventory.InventorySlot;
+import binnie.core.machines.inventory.MachineSide;
+import binnie.core.machines.inventory.SlotValidator;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.CustomSlot;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+import binnie.craftgui.minecraft.InventoryType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.WindowInventory;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.multiplayer.PlayerControllerMP;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+
+public class ControlSlot
+ extends ControlSlotBase
+{
+ public static Map<EnumHighlighting, List<Integer>> highlighting = new HashMap();
+ public static boolean shiftClickActive = false;
+
+ static
+ {
+ for (EnumHighlighting h : EnumHighlighting.values()) {
+ highlighting.put(h, new ArrayList());
+ }
+ }
+
+ public Slot slot = null;
+
+ public ControlSlot(IWidget parent, float x, float y)
+ {
+ super(parent, x, y);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (ControlSlot.this.slot != null)
+ {
+ Window.get(ControlSlot.this.getWidget()).getGui();((Window)ControlSlot.this.getSuperParent()).getGui().getMinecraft().playerController.windowClick(((Window)ControlSlot.this.getSuperParent()).getContainer().windowId, ControlSlot.this.slot.slotNumber, event.getButton(), GuiCraftGUI.isShiftKeyDown() ? 1 : 0, ((Window)ControlSlot.this.getSuperParent()).getGui().getMinecraft().thePlayer);
+ }
+ }
+ });
+ }
+
+ public ControlSlot(IWidget parent, int x, int y, Slot slot)
+ {
+ super(parent, x, y);
+ this.slot = slot;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.Slot, IPoint.ZERO);
+ if (this.slot == null) {
+ return;
+ }
+ InventorySlot islot = getInventorySlot();
+ if ((islot != null) && (islot.getValidator() != null))
+ {
+ IIcon icon = islot.getValidator().getIcon(!islot.getInputSides().isEmpty());
+ if (icon != null) {
+ CraftGUI.Render.iconItem(new IPoint(1.0F, 1.0F), icon);
+ }
+ }
+ boolean highlighted = false;
+ for (Map.Entry<EnumHighlighting, List<Integer>> highlight : highlighting.entrySet()) {
+ if ((highlight.getKey() != EnumHighlighting.ShiftClick) || (shiftClickActive)) {
+ if ((!highlighted) && (((List)highlight.getValue()).contains(Integer.valueOf(this.slot.slotNumber))))
+ {
+ highlighted = true;
+
+ int c = -1442840576 + Math.min(((EnumHighlighting)highlight.getKey()).getColour(), 16777215);
+ CraftGUI.Render.gradientRect(new IArea(1.0F, 1.0F, 16.0F, 16.0F), c, c);
+ }
+ }
+ }
+ if ((!highlighted) && (getSuperParent().getMousedOverWidget() == this)) {
+ if ((Window.get(this).getGui().getDraggedItem() != null) && (!this.slot.isItemValid(Window.get(this).getGui().getDraggedItem()))) {
+ CraftGUI.Render.gradientRect(new IArea(1.0F, 1.0F, 16.0F, 16.0F), -1426089575, -1426089575);
+ } else {
+ CraftGUI.Render.gradientRect(new IArea(1.0F, 1.0F, 16.0F, 16.0F), -2130706433, -2130706433);
+ }
+ }
+ }
+
+ public void onRenderOverlay()
+ {
+ if (this.slot == null) {
+ return;
+ }
+ boolean highlighted = false;
+ for (Map.Entry<EnumHighlighting, List<Integer>> highlight : highlighting.entrySet()) {
+ if ((highlight.getKey() != EnumHighlighting.ShiftClick) || (shiftClickActive)) {
+ if ((!highlighted) && (((List)highlight.getValue()).contains(Integer.valueOf(this.slot.slotNumber))))
+ {
+ highlighted = true;
+ int c = ((EnumHighlighting)highlight.getKey()).getColour();
+ IArea area = getArea();
+ if (((getParent() instanceof ControlSlotArray)) || ((getParent() instanceof ControlPlayerInventory)))
+ {
+ area = getParent().getArea();
+ area.setPosition(IPoint.ZERO.sub(getPosition()));
+ }
+ CraftGUI.Render.colour(c);
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ }
+ }
+ }
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ if (this.slot == null) {
+ return;
+ }
+ if ((isMouseOver()) && (GuiScreen.isShiftKeyDown()))
+ {
+ Window.get(this).getContainer().setMouseOverSlot(this.slot);
+ shiftClickActive = true;
+ }
+ if (Window.get(this).getGui().isHelpMode()) {
+ if (isMouseOver()) {
+ for (ControlSlot slot2 : getControlSlots()) {
+ if (slot2.slot != null) {
+ ((List)highlighting.get(EnumHighlighting.Help)).add(Integer.valueOf(slot2.slot.slotNumber));
+ }
+ }
+ }
+ }
+ }
+
+ private List<ControlSlot> getControlSlots()
+ {
+ List<ControlSlot> slots = new ArrayList();
+ if (((getParent() instanceof ControlSlotArray)) || ((getParent() instanceof ControlPlayerInventory))) {
+ for (IWidget child : getParent().getWidgets()) {
+ slots.add((ControlSlot)child);
+ }
+ } else {
+ slots.add(this);
+ }
+ return slots;
+ }
+
+ public ItemStack getItemStack()
+ {
+ if (this.slot != null) {
+ return this.slot.getStack();
+ }
+ return null;
+ }
+
+ public ControlSlot assign(int index)
+ {
+ return assign(InventoryType.Machine, index);
+ }
+
+ public ControlSlot assign(InventoryType inventory, int index)
+ {
+ if (this.slot != null) {
+ return this;
+ }
+ this.slot = ((Window)getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
+ return this;
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ if (this.slot == null) {
+ return;
+ }
+ InventorySlot slot = getInventorySlot();
+ if (getInventorySlot() != null)
+ {
+ tooltip.add(slot.getName());
+ tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
+ tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
+ if (slot.isReadOnly()) {
+ tooltip.add("Pickup Only Slot");
+ }
+ tooltip.add("Accepts: " + (slot.getValidator() == null ? "Any Item" : slot.getValidator().getTooltip()));
+ }
+ else if ((this.slot.inventory instanceof WindowInventory))
+ {
+ SlotValidator s = ((WindowInventory)this.slot.inventory).getValidator(this.slot.getSlotIndex());
+ tooltip.add("Accepts: " + (s == null ? "Any Item" : s.getTooltip()));
+ }
+ else if ((this.slot.inventory instanceof InventoryPlayer))
+ {
+ tooltip.add("Player Inventory");
+ }
+ }
+
+ public InventorySlot getInventorySlot()
+ {
+ return (this.slot instanceof CustomSlot) ? ((CustomSlot)this.slot).getInventorySlot() : null;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java
new file mode 100644
index 0000000000..772b9a5f85
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java
@@ -0,0 +1,76 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.InventoryType;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class ControlSlotArray
+ extends Control
+ implements Iterable<ControlSlot>
+{
+ private int rows;
+ private int columns;
+ private List<ControlSlot> slots = new ArrayList();
+
+ public ControlSlotArray(IWidget parent, int x, int y, int columns, int rows)
+ {
+ super(parent, x, y, columns * 18, rows * 18);
+ this.rows = rows;
+ this.columns = columns;
+ for (int row = 0; row < rows; row++) {
+ for (int column = 0; column < columns; column++) {
+ this.slots.add(createSlot(column * 18, row * 18));
+ }
+ }
+ }
+
+ public ControlSlot createSlot(int x, int y)
+ {
+ return new ControlSlot(this, x, y);
+ }
+
+ public void setItemStacks(ItemStack[] array)
+ {
+ int i = 0;
+ for (ItemStack item : array)
+ {
+ if (i >= this.slots.size()) {
+ return;
+ }
+ ((ControlSlot)this.slots.get(i)).slot.putStack(item);
+ i++;
+ }
+ }
+
+ public ControlSlot getControlSlot(int i)
+ {
+ if ((i < 0) || (i >= this.slots.size())) {
+ return null;
+ }
+ return (ControlSlot)this.slots.get(i);
+ }
+
+ public ControlSlotArray create(int[] index)
+ {
+ return create(InventoryType.Machine, index);
+ }
+
+ public ControlSlotArray create(InventoryType type, int[] index)
+ {
+ int i = 0;
+ for (ControlSlot slot : this.slots) {
+ slot.assign(type, index[(i++)]);
+ }
+ return this;
+ }
+
+ public Iterator<ControlSlot> iterator()
+ {
+ return this.slots.iterator();
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java
new file mode 100644
index 0000000000..db7b9fa973
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java
@@ -0,0 +1,77 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventWidget.ChangeSize;
+import binnie.craftgui.events.EventWidget.ChangeSize.Handler;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import net.minecraft.item.ItemStack;
+
+public abstract class ControlSlotBase
+ extends Control
+ implements ITooltip
+{
+ private ControlItemDisplay itemDisplay;
+
+ public ControlSlotBase(IWidget parent, float x, float y)
+ {
+ this(parent, x, y, 18);
+ }
+
+ public ControlSlotBase(IWidget parent, float x, float y, int size)
+ {
+ super(parent, x, y, size, size);
+ addAttribute(Attribute.MouseOver);
+ this.itemDisplay = new ControlItemDisplay(this, 1.0F, 1.0F, size - 2);
+
+ addSelfEventHandler(new EventWidget.ChangeSize.Handler()
+ {
+ public void onEvent(EventWidget.ChangeSize event)
+ {
+ if (ControlSlotBase.this.itemDisplay != null) {
+ ControlSlotBase.this.itemDisplay.setSize(ControlSlotBase.this.getSize().sub(new IPoint(2.0F, 2.0F)));
+ }
+ }
+ });
+ }
+
+ protected void setRotating()
+ {
+ this.itemDisplay.setRotating();
+ }
+
+ public void onRenderBackground()
+ {
+ int size = (int)getSize().x();
+ CraftGUI.Render.texture(CraftGUITexture.Slot, getArea());
+ if (getSuperParent().getMousedOverWidget() == this) {
+ CraftGUI.Render.gradientRect(new IArea(new IPoint(1.0F, 1.0F), getArea().size().sub(new IPoint(2.0F, 2.0F))), -2130706433, -2130706433);
+ }
+ }
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ this.itemDisplay.setItemStack(getItemStack());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ ItemStack item = getItemStack();
+ if (item == null) {
+ return;
+ }
+ tooltip.add(item.getTooltip(((Window)getSuperParent()).getPlayer(), false));
+ }
+
+ public abstract ItemStack getItemStack();
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java
new file mode 100644
index 0000000000..eb14237a4d
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java
@@ -0,0 +1,43 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.IChargedSlots;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlSlotCharge
+ extends Control
+{
+ private int slot;
+
+ float getCharge()
+ {
+ IChargedSlots slots = (IChargedSlots)Machine.getInterface(IChargedSlots.class, Window.get(this).getInventory());
+ return slots == null ? 0.0F : slots.getCharge(this.slot);
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.PanelBlack, getArea());
+
+ CraftGUI.Render.texturePercentage(CraftGUI.Render.getTexture(CraftGUITexture.SlotCharge), getArea().inset(1), Position.Bottom, getCharge());
+ }
+
+ public ControlSlotCharge(IWidget parent, int x, int y, int slot)
+ {
+ super(parent, x, y, 4.0F, 18.0F);
+ this.slot = slot;
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ tooltip.add("Charge Remaining: " + (int)(getCharge() * 100.0F) + "%");
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java b/src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java
new file mode 100644
index 0000000000..8337dc23fc
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java
@@ -0,0 +1,47 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.genetics.IItemStackRepresentitive;
+import binnie.craftgui.controls.tab.ControlTab;
+import binnie.craftgui.controls.tab.ControlTabBar;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import net.minecraft.item.ItemStack;
+
+public class ControlTabIcon<T>
+ extends ControlTab<T>
+{
+ private ControlItemDisplay item;
+
+ public ControlTabIcon(ControlTabBar<T> parent, float x, float y, float w, float h, T value)
+ {
+ super(parent, x, y, w, h, value);
+ this.item = new ControlItemDisplay(this, -8.0F + w / 2.0F, -8.0F + h / 2.0F);
+ this.item.hastooltip = false;
+ }
+
+ public ItemStack getItemStack()
+ {
+ if ((this.value instanceof IItemStackRepresentitive)) {
+ return ((IItemStackRepresentitive)this.value).getItemStackRepresentitive();
+ }
+ return null;
+ }
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ this.item.setItemStack(getItemStack());
+ float x = ((ControlTabBar)getParent()).getDirection().x();
+ this.item.setOffset(new IPoint((isCurrentSelection()) || (isMouseOver()) ? 0.0F : -4.0F * x, 0.0F));
+ }
+
+ public boolean hasOutline()
+ {
+ return false;
+ }
+
+ public int getOutlineColour()
+ {
+ return 16777215;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlUser.java b/src/Java/binnie/craftgui/minecraft/control/ControlUser.java
new file mode 100644
index 0000000000..41c5a3c0bd
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlUser.java
@@ -0,0 +1,41 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlUser
+ extends Control
+ implements ITooltip
+{
+ private String username = "";
+ String team = "";
+
+ public ControlUser(IWidget parent, float x, float y, String username)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ this.username = username;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.UserButton, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.setType(Tooltip.Type.User);
+ tooltip.add("Owner");
+ if (this.username != "") {
+ tooltip.add(this.username);
+ }
+ tooltip.setMaxWidth(200);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java b/src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java
new file mode 100644
index 0000000000..7eb1f2d988
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java
@@ -0,0 +1,28 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.minecraft.MinecraftTooltip;
+import binnie.craftgui.minecraft.MinecraftTooltip.Type;
+
+public enum EnumHighlighting
+{
+ Error, Warning, Help, ShiftClick;
+
+ private EnumHighlighting() {}
+
+ int getColour()
+ {
+ switch (1.$SwitchMap$binnie$craftgui$minecraft$control$EnumHighlighting[ordinal()])
+ {
+ case 1:
+ return MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
+ case 2:
+ return MinecraftTooltip.getOutline(Tooltip.Type.Help);
+ case 3:
+ return 16776960;
+ case 4:
+ return MinecraftTooltip.getOutline(MinecraftTooltip.Type.Warning);
+ }
+ return 0;
+ }
+}