aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/craftgui/minecraft
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
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')
-rw-r--r--src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java549
-rw-r--r--src/Java/binnie/craftgui/minecraft/CustomSlot.java54
-rw-r--r--src/Java/binnie/craftgui/minecraft/Dialog.java53
-rw-r--r--src/Java/binnie/craftgui/minecraft/EnumColor.java32
-rw-r--r--src/Java/binnie/craftgui/minecraft/GUIIcon.java30
-rw-r--r--src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java605
-rw-r--r--src/Java/binnie/craftgui/minecraft/IMachineInformation.java6
-rw-r--r--src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java9
-rw-r--r--src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java8
-rw-r--r--src/Java/binnie/craftgui/minecraft/InventoryType.java8
-rw-r--r--src/Java/binnie/craftgui/minecraft/ListMap.java149
-rw-r--r--src/Java/binnie/craftgui/minecraft/MinecraftGUI.java14
-rw-r--r--src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java63
-rw-r--r--src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java18
-rw-r--r--src/Java/binnie/craftgui/minecraft/Window.java338
-rw-r--r--src/Java/binnie/craftgui/minecraft/WindowInventory.java144
-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
-rw-r--r--src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java10
-rw-r--r--src/Java/binnie/craftgui/minecraft/render/RenderCommand.java16
39 files changed, 3767 insertions, 0 deletions
diff --git a/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java b/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java
new file mode 100644
index 0000000000..9b6a2809d9
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java
@@ -0,0 +1,549 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.BinnieCore;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.network.INetwork.RecieveGuiNBT;
+import binnie.core.machines.network.INetwork.SendGuiNBT;
+import binnie.core.machines.power.ErrorState;
+import binnie.core.machines.power.IErrorStateSource;
+import binnie.core.machines.power.IPoweredMachine;
+import binnie.core.machines.power.IProcess;
+import binnie.core.machines.power.ITankMachine;
+import binnie.core.machines.power.PowerInfo;
+import binnie.core.machines.power.ProcessInfo;
+import binnie.core.machines.power.TankInfo;
+import binnie.core.machines.transfer.TransferRequest;
+import binnie.core.machines.transfer.TransferRequest.TransferSlot;
+import binnie.core.network.packet.MessageContainerUpdate;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.EnumHighlighting;
+import com.mojang.authlib.GameProfile;
+import cpw.mods.fml.relauncher.Side;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class ContainerCraftGUI
+ extends Container
+{
+ private Window window;
+
+ public ContainerCraftGUI(Window window)
+ {
+ this.window = window;
+ IMachine machine = Machine.getMachine(window.getInventory());
+ if (getSide() == Side.SERVER)
+ {
+ this.inventoryItemStacks = new ListMap();
+ this.inventorySlots = new ListMap();
+ if (machine != null)
+ {
+ GameProfile user = machine.getOwner();
+ if (user != null)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setString("username", user.getName());
+ sendNBTToClient("username", nbt);
+ }
+ }
+ }
+ }
+
+ protected Slot addSlotToContainer(Slot slot)
+ {
+ return super.addSlotToContainer(slot);
+ }
+
+ private Side getSide()
+ {
+ return this.window.isServer() ? Side.SERVER : Side.CLIENT;
+ }
+
+ public Slot getSlot(int par1)
+ {
+ if ((par1 < 0) || (par1 >= this.inventorySlots.size())) {
+ return null;
+ }
+ return (Slot)this.inventorySlots.get(par1);
+ }
+
+ public void putStackInSlot(int par1, ItemStack par2ItemStack)
+ {
+ if (getSlot(par1) != null) {
+ getSlot(par1).putStack(par2ItemStack);
+ }
+ }
+
+ public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack)
+ {
+ for (int i = 0; i < par1ArrayOfItemStack.length; i++) {
+ if (getSlot(i) != null) {
+ getSlot(i).putStack(par1ArrayOfItemStack[i]);
+ }
+ }
+ }
+
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+ super.onContainerClosed(par1EntityPlayer);
+
+ WindowInventory inventory = this.window.getWindowInventory();
+ for (int i = 0; i < inventory.getSizeInventory(); i++) {
+ if (inventory.dispenseOnClose(i))
+ {
+ ItemStack stack = inventory.getStackInSlot(i);
+ if (stack != null)
+ {
+ stack = new TransferRequest(stack, par1EntityPlayer.inventory).transfer(true);
+ if (stack != null) {
+ par1EntityPlayer.dropPlayerItemWithRandomChoice(stack, false);
+ }
+ }
+ }
+ }
+ }
+
+ public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player)
+ {
+ Slot slot = getSlot(slotNum);
+ if (((slot instanceof CustomSlot)) && (((CustomSlot)slot).handleClick()))
+ {
+ ((CustomSlot)slot).onSlotClick(this, mouseButton, modifier, player);
+ return player.inventory.getItemStack();
+ }
+ ItemStack stack = super.slotClick(slotNum, mouseButton, modifier, player);
+ return stack;
+ }
+
+ public void sendNBTToClient(String key, NBTTagCompound nbt)
+ {
+ this.syncedNBT.put(key, nbt);
+ }
+
+ public boolean canInteractWith(EntityPlayer var1)
+ {
+ return true;
+ }
+
+ public final ItemStack transferStackInSlot(EntityPlayer player, int slotID)
+ {
+ return shiftClick(player, slotID);
+ }
+
+ private ItemStack shiftClick(EntityPlayer player, int slotnumber)
+ {
+ TransferRequest request = getShiftClickRequest(player, slotnumber);
+ if (request == null) {
+ return null;
+ }
+ ItemStack itemstack = request.transfer(true);
+ Slot shiftClickedSlot = (Slot)this.inventorySlots.get(slotnumber);
+
+ shiftClickedSlot.putStack(itemstack);
+ shiftClickedSlot.onSlotChanged();
+
+ return null;
+ }
+
+ private TransferRequest getShiftClickRequest(EntityPlayer player, int slotnumber)
+ {
+ if (slotnumber < 0) {
+ return null;
+ }
+ Slot shiftClickedSlot = (Slot)this.inventorySlots.get(slotnumber);
+
+ ItemStack itemstack = null;
+ if (shiftClickedSlot.getHasStack()) {
+ itemstack = shiftClickedSlot.getStack().copy();
+ }
+ IInventory playerInventory = player.inventory;
+ IInventory containerInventory = this.window.getInventory();
+ IInventory windowInventory = this.window.getWindowInventory();
+
+ IInventory fromPlayer = containerInventory == null ? windowInventory : containerInventory;
+
+ int[] target = new int[36];
+ for (int i = 0; i < 36; i++) {
+ target[i] = i;
+ }
+ TransferRequest request;
+ TransferRequest request;
+ if (shiftClickedSlot.inventory == playerInventory) {
+ request = new TransferRequest(itemstack, fromPlayer).setOrigin(shiftClickedSlot.inventory);
+ } else {
+ request = new TransferRequest(itemstack, playerInventory).setOrigin(shiftClickedSlot.inventory).setTargetSlots(target);
+ }
+ if ((this.window instanceof IWindowAffectsShiftClick)) {
+ ((IWindowAffectsShiftClick)this.window).alterRequest(request);
+ }
+ return request;
+ }
+
+ public final ItemStack tankClick(EntityPlayer player, int slotID)
+ {
+ if (player.inventory.getItemStack() == null) {
+ return null;
+ }
+ ItemStack heldItem = player.inventory.getItemStack().copy();
+
+ heldItem = new TransferRequest(heldItem, this.window.getInventory()).setOrigin(player.inventory).setTargetSlots(new int[0]).setTargetTanks(new int[] { slotID }).transfer(true);
+
+
+ player.inventory.setItemStack(heldItem);
+ if ((player instanceof EntityPlayerMP)) {
+ ((EntityPlayerMP)player).updateHeldItem();
+ }
+ return heldItem;
+ }
+
+ public boolean handleNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ if (side == Side.SERVER)
+ {
+ if (name.equals("tank-click")) {
+ tankClick(player, action.getByte("id"));
+ }
+ if (name.equals("slot-reg"))
+ {
+ int type = action.getByte("t");
+ int index = action.getShort("i");
+ int slotNumber = action.getShort("n");
+ getOrCreateSlot(InventoryType.values()[(type % 4)], index, slotNumber);
+ }
+ }
+ if (name.contains("tank-update")) {
+ onTankUpdate(action);
+ } else if (name.equals("power-update")) {
+ onPowerUpdate(action);
+ } else if (name.equals("process-update")) {
+ onProcessUpdate(action);
+ } else if (name.equals("error-update")) {
+ onErrorUpdate(action);
+ } else if (name.equals("mouse-over-slot")) {
+ onMouseOverSlot(player, action);
+ } else if (name.equals("shift-click-info")) {
+ onRecieveShiftClickHighlights(player, action);
+ }
+ return false;
+ }
+
+ private Map<String, NBTTagCompound> syncedNBT = new HashMap();
+ private Map<String, NBTTagCompound> sentNBT = new HashMap();
+
+ public void detectAndSendChanges()
+ {
+ super.detectAndSendChanges();
+
+
+
+
+ ITankMachine tanks = (ITankMachine)Machine.getInterface(ITankMachine.class, this.window.getInventory());
+ IPoweredMachine powered = (IPoweredMachine)Machine.getInterface(IPoweredMachine.class, this.window.getInventory());
+ IErrorStateSource error = (IErrorStateSource)Machine.getInterface(IErrorStateSource.class, this.window.getInventory());
+ IProcess process = (IProcess)Machine.getInterface(IProcess.class, this.window.getInventory());
+ if ((tanks != null) && (this.window.isServer())) {
+ for (int i = 0; i < tanks.getTankInfos().length; i++)
+ {
+ TankInfo tank = tanks.getTankInfos()[i];
+ if (!getTankInfo(i).equals(tank))
+ {
+ this.syncedNBT.put("tank-update-" + i, createTankNBT(i, tank));
+
+ this.syncedTanks.put(Integer.valueOf(i), tank);
+ }
+ }
+ }
+ if ((powered != null) && (this.window.isServer())) {
+ this.syncedNBT.put("power-update", createPowerNBT(powered.getPowerInfo()));
+ }
+ if ((process != null) && (this.window.isServer())) {
+ this.syncedNBT.put("process-update", createProcessNBT(process.getInfo()));
+ }
+ if ((error != null) && (this.window.isServer())) {
+ this.syncedNBT.put("error-update", createErrorNBT(error));
+ }
+ INetwork.SendGuiNBT machineSync = (INetwork.SendGuiNBT)Machine.getInterface(INetwork.SendGuiNBT.class, this.window.getInventory());
+ if (machineSync != null) {
+ machineSync.sendGuiNBT(this.syncedNBT);
+ }
+ Map<String, NBTTagCompound> sentThisTime = new HashMap();
+ for (Map.Entry<String, NBTTagCompound> nbt : this.syncedNBT.entrySet())
+ {
+ ((NBTTagCompound)nbt.getValue()).setString("type", (String)nbt.getKey());
+
+
+
+
+
+
+ boolean shouldSend = true;
+ NBTTagCompound lastSent = (NBTTagCompound)this.sentNBT.get(nbt.getKey());
+ if (lastSent != null) {
+ shouldSend = !lastSent.equals(nbt.getValue());
+ }
+ if (shouldSend)
+ {
+ for (int j = 0; j < this.crafters.size(); j++) {
+ if ((this.crafters.get(j) instanceof EntityPlayerMP))
+ {
+ EntityPlayerMP player = (EntityPlayerMP)this.crafters.get(j);
+ BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate((NBTTagCompound)nbt.getValue()), player);
+ }
+ }
+ sentThisTime.put(nbt.getKey(), nbt.getValue());
+ }
+ }
+ this.sentNBT.putAll(sentThisTime);
+
+ this.syncedNBT.clear();
+ }
+
+ private NBTTagCompound createErrorNBT(IErrorStateSource error)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ ErrorState state = null;
+ if (error.canWork() != null)
+ {
+ nbt.setByte("type", (byte)0);
+ state = error.canWork();
+ }
+ else if (error.canProgress() != null)
+ {
+ nbt.setByte("type", (byte)1);
+ state = error.canProgress();
+ }
+ if (state != null) {
+ state.writeToNBT(nbt);
+ }
+ return nbt;
+ }
+
+ public NBTTagCompound createPowerNBT(PowerInfo powerInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ powerInfo.writeToNBT(nbt);
+ return nbt;
+ }
+
+ public NBTTagCompound createProcessNBT(ProcessInfo powerInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ powerInfo.writeToNBT(nbt);
+ return nbt;
+ }
+
+ public NBTTagCompound createTankNBT(int tank, TankInfo tankInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ tankInfo.writeToNBT(nbt);
+ nbt.setByte("tank", (byte)tank);
+ return nbt;
+ }
+
+ private Map<Integer, TankInfo> syncedTanks = new HashMap();
+ private PowerInfo syncedPower = new PowerInfo();
+ private ProcessInfo syncedProcess = new ProcessInfo();
+ private int errorType = 0;
+ private ErrorState error = null;
+
+ public void onTankUpdate(NBTTagCompound nbt)
+ {
+ int tankID = nbt.getByte("tank");
+ TankInfo tank = new TankInfo();
+ tank.readFromNBT(nbt);
+ this.syncedTanks.put(Integer.valueOf(tankID), tank);
+ }
+
+ public void onProcessUpdate(NBTTagCompound nbt)
+ {
+ this.syncedProcess = new ProcessInfo();
+ this.syncedProcess.readFromNBT(nbt);
+ }
+
+ public void onPowerUpdate(NBTTagCompound nbt)
+ {
+ this.syncedPower = new PowerInfo();
+ this.syncedPower.readFromNBT(nbt);
+ }
+
+ public PowerInfo getPowerInfo()
+ {
+ return this.syncedPower;
+ }
+
+ public ProcessInfo getProcessInfo()
+ {
+ return this.syncedProcess;
+ }
+
+ public TankInfo getTankInfo(int tank)
+ {
+ return this.syncedTanks.containsKey(Integer.valueOf(tank)) ? (TankInfo)this.syncedTanks.get(Integer.valueOf(tank)) : new TankInfo();
+ }
+
+ public void onErrorUpdate(NBTTagCompound nbt)
+ {
+ this.errorType = nbt.getByte("type");
+ if (nbt.hasKey("name"))
+ {
+ this.error = new ErrorState("", "");
+ this.error.readFromNBT(nbt);
+ }
+ else
+ {
+ this.error = null;
+ }
+ }
+
+ public ErrorState getErrorState()
+ {
+ return this.error;
+ }
+
+ public int getErrorType()
+ {
+ return this.errorType;
+ }
+
+ public CustomSlot[] getCustomSlots()
+ {
+ List<CustomSlot> slots = new ArrayList();
+ for (Object object : this.inventorySlots) {
+ if ((object instanceof CustomSlot)) {
+ slots.add((CustomSlot)object);
+ }
+ }
+ return (CustomSlot[])slots.toArray(new CustomSlot[0]);
+ }
+
+ private int mousedOverSlotNumber = -1;
+
+ public void setMouseOverSlot(Slot slot)
+ {
+ if (slot.slotNumber != this.mousedOverSlotNumber)
+ {
+ this.mousedOverSlotNumber = slot.slotNumber;
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).clear();
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setShort("slot", (short)slot.slotNumber);
+ this.window.sendClientAction("mouse-over-slot", nbt);
+ }
+ }
+
+ private void onMouseOverSlot(EntityPlayer player, NBTTagCompound data)
+ {
+ int slotnumber = data.getShort("slot");
+ TransferRequest request = getShiftClickRequest(player, slotnumber);
+ if (request == null) {
+ return;
+ }
+ request.transfer(false);
+ NBTTagCompound nbt = new NBTTagCompound();
+
+ List<Integer> slots = new ArrayList();
+ for (TransferRequest.TransferSlot tslot : request.getInsertedSlots())
+ {
+ Slot slot = getSlot(tslot.inventory, tslot.id);
+ if (slot != null) {
+ slots.add(Integer.valueOf(slot.slotNumber));
+ }
+ }
+ int[] array = new int[slots.size()];
+ for (int i = 0; i < slots.size(); i++) {
+ array[i] = ((Integer)slots.get(i)).intValue();
+ }
+ nbt.setIntArray("slots", array);
+ nbt.setShort("origin", (short)slotnumber);
+
+ this.syncedNBT.put("shift-click-info", nbt);
+ }
+
+ private void onRecieveShiftClickHighlights(EntityPlayer player, NBTTagCompound data)
+ {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).clear();
+ for (int slotnumber : data.getIntArray("slots")) {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).add(Integer.valueOf(slotnumber));
+ }
+ }
+
+ private CustomSlot getSlot(IInventory inventory, int id)
+ {
+ for (Object o : this.inventorySlots)
+ {
+ CustomSlot slot = (CustomSlot)o;
+ if ((slot.inventory == inventory) && (slot.getSlotIndex() == id)) {
+ return slot;
+ }
+ }
+ return null;
+ }
+
+ public void recieveNBT(Side side, EntityPlayer player, NBTTagCompound action)
+ {
+ String name = action.getString("type");
+ if (handleNBT(side, player, name, action)) {
+ return;
+ }
+ this.window.recieveGuiNBT(getSide(), player, name, action);
+ INetwork.RecieveGuiNBT machine = (INetwork.RecieveGuiNBT)Machine.getInterface(INetwork.RecieveGuiNBT.class, this.window.getInventory());
+ if (machine != null) {
+ machine.recieveGuiNBT(getSide(), player, name, action);
+ }
+ }
+
+ public Slot getOrCreateSlot(InventoryType type, int index)
+ {
+ IInventory inventory = getInventory(type);
+ Slot slot = getSlot(inventory, index);
+ if (slot == null)
+ {
+ slot = new CustomSlot(inventory, index);
+ addSlotToContainer(slot);
+ }
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("t", (byte)type.ordinal());
+ nbt.setShort("i", (short)index);
+ nbt.setShort("n", (short)slot.slotNumber);
+ this.window.sendClientAction("slot-reg", nbt);
+ return slot;
+ }
+
+ protected IInventory getInventory(InventoryType type)
+ {
+ if (type == InventoryType.Machine) {
+ return this.window.getInventory();
+ }
+ if (type == InventoryType.Player) {
+ return this.window.getPlayer().inventory;
+ }
+ if (type == InventoryType.Window) {
+ return this.window.getWindowInventory();
+ }
+ return null;
+ }
+
+ private Slot getOrCreateSlot(InventoryType type, int index, int slotNumber)
+ {
+ IInventory inventory = getInventory(type);
+ if (this.inventorySlots.get(slotNumber) != null) {
+ return null;
+ }
+ Slot slot = new CustomSlot(inventory, index);
+ slot.slotNumber = slotNumber;
+ this.inventorySlots.add(slotNumber, slot);
+ this.inventoryItemStacks.add(slotNumber, (Object)null);
+ return slot;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/CustomSlot.java b/src/Java/binnie/craftgui/minecraft/CustomSlot.java
new file mode 100644
index 0000000000..ae45ffb3fd
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/CustomSlot.java
@@ -0,0 +1,54 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.IInventorySlots;
+import binnie.core.machines.inventory.InventorySlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class CustomSlot
+ extends Slot
+{
+ public boolean isItemValid(ItemStack par1ItemStack)
+ {
+ return this.inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
+ }
+
+ public CustomSlot(IInventory inventory, int index)
+ {
+ super(inventory, index, 0, 0);
+ }
+
+ public InventorySlot getInventorySlot()
+ {
+ IInventorySlots slots = (IInventorySlots)Machine.getInterface(IInventorySlots.class, this.inventory);
+ if (slots != null) {
+ return slots.getSlot(getSlotIndex());
+ }
+ return null;
+ }
+
+ public boolean handleClick()
+ {
+ InventorySlot slot = getInventorySlot();
+ return (slot != null) && (slot.isRecipe());
+ }
+
+ public void onSlotClick(ContainerCraftGUI container, int mouseButton, int modifier, EntityPlayer player)
+ {
+ ItemStack stack = player.inventory.getItemStack();
+ if ((stack == null) || (mouseButton == 2))
+ {
+ putStack(null);
+ }
+ else
+ {
+ stack = stack.copy();
+ stack.stackSize = 1;
+ putStack(stack);
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/Dialog.java b/src/Java/binnie/craftgui/minecraft/Dialog.java
new file mode 100644
index 0000000000..efd67dec25
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/Dialog.java
@@ -0,0 +1,53 @@
+package binnie.craftgui.minecraft;
+
+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.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public abstract class Dialog
+ extends Control
+{
+ public Dialog(IWidget parent, float w, float h)
+ {
+ super(parent, (parent.w() - w) / 2.0F, (parent.h() - h) / 2.0F, w, h);
+ addAttribute(Attribute.MouseOver);
+ addAttribute(Attribute.AlwaysOnTop);
+ addAttribute(Attribute.BlockTooltip);
+ initialise();
+ addEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (!Dialog.this.getArea().contains(Dialog.this.getRelativeMousePosition()))
+ {
+ Dialog.this.onClose();
+ Dialog.this.getParent().deleteChild(Dialog.this);
+ }
+ }
+ }.setOrigin(EventHandler.Origin.Any, this));
+ }
+
+ public abstract void initialise();
+
+ public abstract void onClose();
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.gradientRect(getArea().outset(400), -1442840576, -1442840576);
+ CraftGUI.Render.texture(CraftGUITexture.Window, getArea());
+ CraftGUI.Render.texture(CraftGUITexture.TabOutline, getArea().inset(4));
+ }
+
+ public boolean isMouseOverWidget(IPoint relativeMouse)
+ {
+ return true;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/EnumColor.java b/src/Java/binnie/craftgui/minecraft/EnumColor.java
new file mode 100644
index 0000000000..e778cf31c8
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/EnumColor.java
@@ -0,0 +1,32 @@
+package binnie.craftgui.minecraft;
+
+public enum EnumColor
+{
+ Black("Black", 0, '0'), DarkBlue("Dark Blue", 170, '1'), DarkGreen("Dark Green", 43520, '2'), DarkAqua("Dark Aqua", 43690, '3'), DarkRed("Dark Red", 11141120, '4'), Purple("Purple", 11141290, '5'), Gold("Gold", 16755200, '6'), Grey("Grey", 11184810, '7'), DarkGrey("Dark Grey", 5592405, '8'), Blue("Blue", 5592575, '9'), Green("Green", 5635925, 'a'), Aqua("Aqua", 5636095, 'b'), Red("Red", 16733525, 'c'), Pink("Pink", 16733695, 'd'), Yellow("Yellow", 16777045, 'e'), White("White", 16777215, 'f');
+
+ int colour;
+ String name;
+ char code;
+
+ private EnumColor(String name, int colour, char code)
+ {
+ this.name = name;
+ this.colour = colour;
+ this.code = code;
+ }
+
+ public int getColour()
+ {
+ return this.colour;
+ }
+
+ public String getCode()
+ {
+ return "§" + this.code;
+ }
+
+ public String toString()
+ {
+ return this.name;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/GUIIcon.java b/src/Java/binnie/craftgui/minecraft/GUIIcon.java
new file mode 100644
index 0000000000..96338b2551
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/GUIIcon.java
@@ -0,0 +1,30 @@
+package binnie.craftgui.minecraft;
+
+import binnie.Binnie;
+import binnie.core.BinnieCore;
+import binnie.core.resource.BinnieIcon;
+import binnie.core.resource.ManagerResource;
+import net.minecraft.util.IIcon;
+
+public enum GUIIcon
+{
+ ArrowUp("arrow-up"), ArrowDown("arrow-down"), ArrowLeft("arrow-left"), ArrowRight("arrow-right"), ArrowUpLeft("arrow-upleft"), ArrowUpRight("arrow-upright"), ArrowRightUp("arrow-rightup"), ArrowRightDown("arrow-rightdown"), ArrowDownRight("arrow-downright"), ArrowDownLeft("arrow-downleft"), ArrowLeftDown("arrow-leftdown"), ArrowLeftUp("arrow-leftup");
+
+ String path;
+ BinnieIcon icon;
+
+ private GUIIcon(String path)
+ {
+ this.path = path;
+ }
+
+ public void register()
+ {
+ this.icon = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/" + this.path);
+ }
+
+ public IIcon getIcon()
+ {
+ return this.icon.getIcon();
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java b/src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java
new file mode 100644
index 0000000000..bfd4a5f876
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java
@@ -0,0 +1,605 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.BinnieCore;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventKey.Down;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Up;
+import binnie.craftgui.events.EventMouse.Wheel;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityClientPlayerMP;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.client.settings.GameSettings;
+import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.JsonToNBT;
+import net.minecraft.nbt.NBTException;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+@SideOnly(Side.CLIENT)
+public class GuiCraftGUI
+ extends GuiContainer
+{
+ IPoint mousePos = new IPoint(0.0F, 0.0F);
+ private Window window;
+ private ItemStack draggedItem;
+
+ public void updateScreen()
+ {
+ this.window.updateClient();
+ }
+
+ public Minecraft getMinecraft()
+ {
+ return this.mc;
+ }
+
+ public GuiCraftGUI(Window window)
+ {
+ super(window.getContainer());
+ this.window = window;
+ resize(window.getSize());
+ }
+
+ protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {}
+
+ public void initGui()
+ {
+ super.initGui();
+ this.mc.thePlayer.openContainer = this.inventorySlots;
+ this.guiLeft = ((this.width - this.xSize) / 2);
+ this.guiTop = ((this.height - this.ySize) / 2);
+ this.window.setSize(new IPoint(this.xSize, this.ySize));
+ this.window.setPosition(new IPoint(this.guiLeft, this.guiTop));
+ this.window.initGui();
+ }
+
+ public ItemStack getDraggedItem()
+ {
+ return this.draggedItem;
+ }
+
+ public void drawScreen(int mouseX, int mouseY, float par3)
+ {
+ this.window.setMousePosition(mouseX - (int)this.window.getPosition().x(), mouseY - (int)this.window.getPosition().y());
+
+
+ drawDefaultBackground();
+
+
+ GL11.glDisable(32826);
+ RenderHelper.disableStandardItemLighting();
+ GL11.glDisable(2896);
+ GL11.glDisable(2929);
+
+ this.zLevel = 10.0F;
+ itemRender.zLevel = this.zLevel;
+
+ this.window.render();
+
+
+ RenderHelper.enableGUIStandardItemLighting();
+ GL11.glPushMatrix();
+ GL11.glEnable(32826);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
+
+
+
+
+
+ InventoryPlayer playerInventory = this.mc.thePlayer.inventory;
+ this.draggedItem = playerInventory.getItemStack();
+ if (this.draggedItem != null)
+ {
+ renderItem(new IPoint(mouseX - 8, mouseY - 8), this.draggedItem, 200, false);
+ renderItem(new IPoint(mouseX - 8, mouseY - 8), this.draggedItem, 200, false);
+ }
+ GL11.glDisable(32826);
+ GL11.glPopMatrix();
+
+
+
+
+
+ GL11.glDisable(2896);
+ GL11.glDisable(2929);
+
+
+ MinecraftTooltip tooltip = new MinecraftTooltip();
+ if (isHelpMode())
+ {
+ tooltip.setType(Tooltip.Type.Help);
+ this.window.getHelpTooltip(tooltip);
+ }
+ else
+ {
+ tooltip.setType(Tooltip.Type.Standard);
+ this.window.getTooltip(tooltip);
+ }
+ if (tooltip.exists()) {
+ renderTooltip(new IPoint(mouseX, mouseY), tooltip);
+ }
+ this.zLevel = 0.0F;
+
+ GL11.glEnable(2896);
+ GL11.glEnable(2929);
+ }
+
+ public void renderTooltip(IPoint mousePosition, MinecraftTooltip tooltip)
+ {
+ int mouseX = (int)mousePosition.x();
+ int mouseY = (int)mousePosition.y();
+ FontRenderer font = getFontRenderer();
+ GL11.glDisable(32826);
+ RenderHelper.disableStandardItemLighting();
+ GL11.glDisable(2896);
+ GL11.glDisable(2929);
+ int k = 0;
+
+ List<String> strings = new ArrayList();
+ for (String string : tooltip.getList()) {
+ if (string != null) {
+ if (!string.contains("~~~")) {
+ strings.addAll(font.listFormattedStringToWidth(string, tooltip.maxWidth));
+ } else {
+ strings.add(string);
+ }
+ }
+ }
+ Iterator iterator = strings.iterator();
+ while (iterator.hasNext())
+ {
+ String s = (String)iterator.next();
+ int l = font.getStringWidth(s);
+ if (s.contains("~~~")) {
+ l = 12 + font.getStringWidth(s.replaceAll("~~~(.*?)~~~", ""));
+ }
+ if (l > k) {
+ k = l;
+ }
+ }
+ int i1 = mouseX + 12;
+ int j1 = mouseY - 12;
+ int k1 = 8;
+ if (strings.size() > 1) {
+ k1 += 2 + (strings.size() - 1) * 10;
+ }
+ if (i1 + k > this.width) {
+ i1 -= 28 + k;
+ }
+ if (j1 + k1 + 6 > this.height) {
+ j1 = this.height - k1 - 6;
+ }
+ this.zLevel = 300.0F;
+ itemRender.zLevel = 300.0F;
+ int l1 = -267386864;
+ int i2 = 1342177280 + MinecraftTooltip.getOutline(tooltip.getType());
+ int j2 = i2;
+ drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1);
+ drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1);
+ drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1);
+ drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1);
+ drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1);
+
+ drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2);
+ drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2);
+ drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
+ drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);
+ for (int k2 = 0; k2 < strings.size(); k2++)
+ {
+ String s1 = (String)strings.get(k2);
+ if (k2 == 0) {
+ s1 = MinecraftTooltip.getTitle(tooltip.getType()) + s1;
+ } else {
+ s1 = MinecraftTooltip.getBody(tooltip.getType()) + s1;
+ }
+ if (s1.contains("~~~"))
+ {
+ String split = s1.split("~~~")[1];
+ try
+ {
+ NBTTagCompound nbt = (NBTTagCompound)JsonToNBT.func_150315_a(split);
+ ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
+ GL11.glPushMatrix();
+ GL11.glTranslatef(i1, j1 - 1.5F, 0.0F);
+ GL11.glScalef(0.6F, 0.6F, 1.0F);
+ renderItem(new IPoint(0.0F, 0.0F), stack, false);
+ GL11.glPopMatrix();
+ }
+ catch (NBTException e)
+ {
+ e.printStackTrace();
+ }
+ s1 = " " + s1.replaceAll("~~~(.*?)~~~", "");
+ }
+ font.drawStringWithShadow(s1, i1, j1, -1);
+ if (k2 == 0) {
+ j1 += 2;
+ }
+ j1 += 10;
+ }
+ this.zLevel = 0.0F;
+ itemRender.zLevel = 0.0F;
+ GL11.glEnable(2896);
+ GL11.glEnable(2929);
+ RenderHelper.enableStandardItemLighting();
+ GL11.glEnable(32826);
+ }
+
+ protected void mouseClicked(int x, int y, int button)
+ {
+ IWidget origin = this.window;
+ if (this.window.getMousedOverWidget() != null) {
+ origin = this.window.getMousedOverWidget();
+ }
+ this.window.callEvent(new EventMouse.Down(origin, x, y, button));
+ }
+
+ public boolean isShiftDown()
+ {
+ return Keyboard.isKeyDown(this.mc.gameSettings.keyBindSneak.getKeyCode());
+ }
+
+ protected void keyTyped(char c, int key)
+ {
+ if ((key == 1) || ((key == this.mc.gameSettings.keyBindInventory.getKeyCode()) && (this.window.getFocusedWidget() == null))) {
+ this.mc.thePlayer.closeScreen();
+ }
+ IWidget origin = this.window.getFocusedWidget() == null ? this.window : this.window.getFocusedWidget();
+
+ this.window.callEvent(new EventKey.Down(origin, c, key));
+ }
+
+ protected void mouseMovedOrUp(int x, int y, int button)
+ {
+ IWidget origin = this.window.getMousedOverWidget() == null ? this.window : this.window.getMousedOverWidget();
+ float dy;
+ if (button == -1)
+ {
+ float dx = Mouse.getEventDX() * this.width / this.mc.displayWidth;
+ dy = -(Mouse.getEventDY() * this.height / this.mc.displayHeight);
+ }
+ else
+ {
+ this.window.callEvent(new EventMouse.Up(origin, x, y, button));
+ }
+ }
+
+ public void handleMouseInput()
+ {
+ super.handleMouseInput();
+ int dWheel = Mouse.getDWheel();
+ IWidget origin = this.window.getFocusedWidget() == null ? this.window : this.window.getFocusedWidget();
+ if (dWheel != 0) {
+ this.window.callEvent(new EventMouse.Wheel(this.window, dWheel));
+ }
+ }
+
+ public void onGuiClosed()
+ {
+ this.window.onClose();
+ }
+
+ public void renderTexturedRect(float x, float y, float u, float v, float w, float h)
+ {
+ drawTexturedModalRect((int)x, (int)y, (int)u, (int)v, (int)w, (int)h);
+ }
+
+ public void renderTexture(IPoint position, IArea textureArea)
+ {
+ drawTexturedModalRect((int)position.x(), (int)position.y(), (int)textureArea.pos().x(), (int)textureArea.pos().y(), (int)textureArea.size().x(), (int)textureArea.size().y());
+ }
+
+ private void renderTexturedRect(IArea area, IPoint uv)
+ {
+ renderTexturedRect(area.pos().x(), area.pos().y(), uv.x(), uv.y(), area.size().x(), area.size().y());
+ }
+
+ public void renderTexturePadded(IArea area, IArea texture, IBorder padding)
+ {
+ int borderLeft = (int)padding.l();
+ int borderRight = (int)padding.r();
+ int borderTop = (int)padding.t();
+ int borderBottom = (int)padding.b();
+
+ int posX = (int)area.pos().x();
+ int posY = (int)area.pos().y();
+ int width = (int)area.size().x();
+ int height = (int)area.size().y();
+
+ int textWidth = (int)texture.w();
+ int textHeight = (int)texture.h();
+
+ int u = (int)texture.x();
+ int v = (int)texture.y();
+ if (borderTop + borderBottom > height)
+ {
+ borderTop = height / 2;
+ borderBottom = height / 2;
+ }
+ if (borderLeft + borderRight > width)
+ {
+ borderLeft = width / 2;
+ borderRight = width / 2;
+ }
+ IPoint origin = area.pos();
+
+ drawTexturedModalRect(posX, posY, u, v, borderLeft, borderTop);
+
+
+ drawTexturedModalRect(posX + width - borderRight, posY, u + textWidth - borderRight, v, borderRight, borderTop);
+
+
+ drawTexturedModalRect(posX, posY + height - borderBottom, u, v + textHeight - borderBottom, borderLeft, borderBottom);
+
+
+ drawTexturedModalRect(posX + width - borderRight, posY + height - borderBottom, u + textWidth - borderRight, v + textHeight - borderBottom, borderRight, borderBottom);
+
+
+
+ int currentXPos = borderLeft;
+ while (currentXPos < width - borderRight)
+ {
+ int distanceXRemaining = width - borderRight - currentXPos;
+
+
+ int texturingWidth = textWidth - borderLeft - borderRight;
+ if (texturingWidth > distanceXRemaining) {
+ texturingWidth = distanceXRemaining;
+ }
+ if (texturingWidth <= 0) {
+ break;
+ }
+ drawTexturedModalRect(posX + currentXPos, posY, u + borderLeft, v, texturingWidth, borderTop);
+
+ drawTexturedModalRect(posX + currentXPos, posY + height - borderBottom, u + borderLeft, v + textHeight - borderBottom, texturingWidth, borderBottom);
+
+
+ int currentYPos = borderTop;
+ while (currentYPos < height - borderBottom)
+ {
+ int distanceYRemaining = height - borderBottom - currentYPos;
+
+
+ int texturingHeight = textHeight - borderTop - borderBottom;
+ if (texturingHeight > distanceYRemaining) {
+ texturingHeight = distanceYRemaining;
+ }
+ if (texturingHeight <= 0) {
+ break;
+ }
+ drawTexturedModalRect(posX + currentXPos, posY + currentYPos, u + borderLeft, v + borderTop, texturingWidth, texturingHeight);
+
+ currentYPos += texturingHeight;
+ }
+ currentXPos += texturingWidth;
+ }
+ int currentYPos = borderTop;
+ while (currentYPos < height - borderBottom)
+ {
+ int distanceYRemaining = height - borderBottom - currentYPos;
+
+
+ int texturingHeight = textHeight - borderTop - borderBottom;
+ if (texturingHeight > distanceYRemaining) {
+ texturingHeight = distanceYRemaining;
+ }
+ if (texturingHeight <= 0) {
+ break;
+ }
+ drawTexturedModalRect(posX, posY + currentYPos, u, v + borderTop, borderLeft, texturingHeight);
+
+ drawTexturedModalRect(posX + width - borderRight, posY + currentYPos, u + textWidth - borderRight, v + borderTop, borderRight, texturingHeight);
+ currentYPos += texturingHeight;
+ }
+ }
+
+ public void drawGradientArea(float p_73733_1_, float p_73733_2_, float p_73733_3_, float p_73733_4_, int p_73733_5_, int p_73733_6_)
+ {
+ float f = (p_73733_5_ >> 24 & 0xFF) / 255.0F;
+ float f1 = (p_73733_5_ >> 16 & 0xFF) / 255.0F;
+ float f2 = (p_73733_5_ >> 8 & 0xFF) / 255.0F;
+ float f3 = (p_73733_5_ & 0xFF) / 255.0F;
+ float f4 = (p_73733_6_ >> 24 & 0xFF) / 255.0F;
+ float f5 = (p_73733_6_ >> 16 & 0xFF) / 255.0F;
+ float f6 = (p_73733_6_ >> 8 & 0xFF) / 255.0F;
+ float f7 = (p_73733_6_ & 0xFF) / 255.0F;
+ GL11.glDisable(3553);
+ GL11.glEnable(3042);
+ GL11.glDisable(3008);
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+ GL11.glShadeModel(7425);
+ Tessellator tessellator = Tessellator.instance;
+ tessellator.startDrawingQuads();
+ tessellator.setColorRGBA_F(f1, f2, f3, f);
+ tessellator.addVertex(p_73733_3_, p_73733_2_, this.zLevel);
+ tessellator.addVertex(p_73733_1_, p_73733_2_, this.zLevel);
+ tessellator.setColorRGBA_F(f5, f6, f7, f4);
+ tessellator.addVertex(p_73733_1_, p_73733_4_, this.zLevel);
+ tessellator.addVertex(p_73733_3_, p_73733_4_, this.zLevel);
+ tessellator.draw();
+ GL11.glShadeModel(7424);
+ GL11.glDisable(3042);
+ GL11.glEnable(3008);
+ GL11.glEnable(3553);
+ }
+
+ public void renderItem(IPoint pos, ItemStack item, boolean rotating)
+ {
+ renderItem(pos, item, (int)this.zLevel + 3, rotating);
+ }
+
+ private void renderItem(IPoint pos, ItemStack item, int zLevel, boolean rotating)
+ {
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
+
+ GL11.glPushMatrix();
+
+ RenderHelper.enableGUIStandardItemLighting();
+ GL11.glEnable(32826);
+ GL11.glEnable(2929);
+
+
+
+
+
+
+
+ FontRenderer font = item.getItem().getFontRenderer(item);
+ if (font == null) {
+ font = getFontRenderer();
+ }
+ if (item != null)
+ {
+ BinnieCore.proxy.getMinecraftInstance();float phase = (float)Minecraft.getSystemTime() / 20.0F;
+
+ GL11.glPushMatrix();
+ if (rotating)
+ {
+ GL11.glTranslatef(8.0F, 8.0F, 0.0F);
+ GL11.glRotatef(phase, 0.0F, -0.866F, 0.5F);
+ GL11.glTranslatef(-8.0F, -8.0F, -67.099998F);
+ }
+ itemRender.renderItemAndEffectIntoGUI(font, this.mc.renderEngine, item, (int)pos.x(), (int)pos.y());
+ GL11.glPopMatrix();
+ itemRender.renderItemOverlayIntoGUI(font, this.mc.renderEngine, item, (int)pos.x(), (int)pos.y(), null);
+ }
+ GL11.glClear(256);
+ GL11.glEnable(3042);
+
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+
+
+ RenderHelper.disableStandardItemLighting();
+
+ CraftGUI.Render.colour(-1);
+
+ GL11.glEnable(32826);
+ GL11.glPopMatrix();
+ }
+
+ public void renderIcon(IPoint pos, IIcon icon, ResourceLocation map)
+ {
+ if (icon == null) {
+ return;
+ }
+ GL11.glPushMatrix();
+ GL11.glEnable(32826);
+
+
+ BinnieCore.proxy.bindTexture(map);
+
+
+ itemRender.zLevel = this.zLevel;
+
+ itemRender.renderIcon((int)pos.x(), (int)pos.y(), icon, 16, 16);
+
+
+
+ GL11.glEnable(32826);
+ GL11.glPopMatrix();
+ }
+
+ public boolean isHelpMode()
+ {
+ return Keyboard.isKeyDown(15);
+ }
+
+ public FontRenderer getFontRenderer()
+ {
+ return this.fontRendererObj;
+ }
+
+ public void resize(IPoint size)
+ {
+ this.xSize = ((int)size.x());
+ this.ySize = ((int)size.y());
+ this.guiLeft = ((this.width - this.xSize) / 2);
+ this.guiTop = ((this.height - this.ySize) / 2);
+ this.window.setPosition(new IPoint(this.guiLeft, this.guiTop));
+ }
+
+ public void limitArea(IArea area)
+ {
+ float x = area.pos().x();
+ float y = area.pos().y();
+ float w = area.size().x();
+ float h = area.size().y();
+
+ y = this.height - (y + h);
+ float k = this.xSize;
+ float scaleX = this.width / this.mc.displayWidth;
+ float scaleY = this.height / this.mc.displayHeight;
+
+ x += 0.0F;
+ y += 0.0F;
+ w += 0.0F;
+ h += 0.0F;
+
+
+
+ GL11.glScissor((int)(x / scaleX), (int)(y / scaleY), (int)(w / scaleX), (int)(h / scaleY));
+ }
+
+ public int getZLevel()
+ {
+ return (int)this.zLevel;
+ }
+
+ public void drawRect(float p_73734_0_, float p_73734_1_, float p_73734_2_, float p_73734_3_, int p_73734_4_)
+ {
+ if (p_73734_0_ < p_73734_2_)
+ {
+ float j1 = p_73734_0_;
+ p_73734_0_ = p_73734_2_;
+ p_73734_2_ = j1;
+ }
+ if (p_73734_1_ < p_73734_3_)
+ {
+ float j1 = p_73734_1_;
+ p_73734_1_ = p_73734_3_;
+ p_73734_3_ = j1;
+ }
+ float f3 = (p_73734_4_ >> 24 & 0xFF) / 255.0F;
+ float f = (p_73734_4_ >> 16 & 0xFF) / 255.0F;
+ float f1 = (p_73734_4_ >> 8 & 0xFF) / 255.0F;
+ float f2 = (p_73734_4_ & 0xFF) / 255.0F;
+ Tessellator tessellator = Tessellator.instance;
+ GL11.glEnable(3042);
+ GL11.glDisable(3553);
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+ GL11.glColor4f(f, f1, f2, f3);
+ tessellator.startDrawingQuads();
+ tessellator.addVertex(p_73734_0_, p_73734_3_, 0.0D);
+ tessellator.addVertex(p_73734_2_, p_73734_3_, 0.0D);
+ tessellator.addVertex(p_73734_2_, p_73734_1_, 0.0D);
+ tessellator.addVertex(p_73734_0_, p_73734_1_, 0.0D);
+ tessellator.draw();
+ GL11.glEnable(3553);
+ GL11.glDisable(3042);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/IMachineInformation.java b/src/Java/binnie/craftgui/minecraft/IMachineInformation.java
new file mode 100644
index 0000000000..cd709bbf8a
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/IMachineInformation.java
@@ -0,0 +1,6 @@
+package binnie.craftgui.minecraft;
+
+public abstract interface IMachineInformation
+{
+ public abstract String getInformation();
+}
diff --git a/src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java b/src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java
new file mode 100644
index 0000000000..5bdec6e4ae
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java
@@ -0,0 +1,9 @@
+package binnie.craftgui.minecraft;
+
+import binnie.craftgui.core.ITooltip;
+
+public abstract interface IMinecraftTooltip
+ extends ITooltip
+{
+ public abstract void getTooltip(MinecraftTooltip paramMinecraftTooltip);
+}
diff --git a/src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java b/src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java
new file mode 100644
index 0000000000..ced88aa028
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java
@@ -0,0 +1,8 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.machines.transfer.TransferRequest;
+
+public abstract interface IWindowAffectsShiftClick
+{
+ public abstract void alterRequest(TransferRequest paramTransferRequest);
+}
diff --git a/src/Java/binnie/craftgui/minecraft/InventoryType.java b/src/Java/binnie/craftgui/minecraft/InventoryType.java
new file mode 100644
index 0000000000..f10a065a99
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/InventoryType.java
@@ -0,0 +1,8 @@
+package binnie.craftgui.minecraft;
+
+public enum InventoryType
+{
+ Player, Machine, Window, Custom;
+
+ private InventoryType() {}
+}
diff --git a/src/Java/binnie/craftgui/minecraft/ListMap.java b/src/Java/binnie/craftgui/minecraft/ListMap.java
new file mode 100644
index 0000000000..7c0fbf37dd
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/ListMap.java
@@ -0,0 +1,149 @@
+package binnie.craftgui.minecraft;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map.Entry;
+import java.util.Set;
+
+class ListMap<T>
+ implements List<T>
+{
+ private LinkedHashMap<Integer, T> map = new LinkedHashMap();
+
+ public int size()
+ {
+ int i = -1;
+ for (Iterator i$ = this.map.keySet().iterator(); i$.hasNext();)
+ {
+ int k = ((Integer)i$.next()).intValue();
+ if (k > i) {
+ i = k;
+ }
+ }
+ return i + 1;
+ }
+
+ public boolean isEmpty()
+ {
+ return this.map.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ return this.map.containsValue(o);
+ }
+
+ public Iterator<T> iterator()
+ {
+ return this.map.values().iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return this.map.values().toArray();
+ }
+
+ public <P> P[] toArray(P[] a)
+ {
+ return this.map.values().toArray(a);
+ }
+
+ public boolean add(T e)
+ {
+ if (get(size()) == null)
+ {
+ add(size(), e);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean remove(Object o)
+ {
+ return false;
+ }
+
+ public boolean containsAll(Collection<?> c)
+ {
+ return this.map.values().containsAll(c);
+ }
+
+ public boolean addAll(Collection<? extends T> c)
+ {
+ return false;
+ }
+
+ public boolean addAll(int index, Collection<? extends T> c)
+ {
+ return false;
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public void clear()
+ {
+ this.map.clear();
+ }
+
+ public T get(int index)
+ {
+ return this.map.get(Integer.valueOf(index));
+ }
+
+ public T set(int index, T element)
+ {
+ this.map.put(Integer.valueOf(index), element);
+ return element;
+ }
+
+ public void add(int index, T element)
+ {
+ this.map.put(Integer.valueOf(index), element);
+ }
+
+ public T remove(int index)
+ {
+ return null;
+ }
+
+ public int indexOf(Object o)
+ {
+ for (Map.Entry<Integer, T> entry : this.map.entrySet()) {
+ if (entry.getValue() == o) {
+ return ((Integer)entry.getKey()).intValue();
+ }
+ }
+ return 0;
+ }
+
+ public int lastIndexOf(Object o)
+ {
+ return indexOf(o);
+ }
+
+ public ListIterator<T> listIterator()
+ {
+ return null;
+ }
+
+ public ListIterator<T> listIterator(int index)
+ {
+ return null;
+ }
+
+ public List<T> subList(int fromIndex, int toIndex)
+ {
+ return null;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/MinecraftGUI.java b/src/Java/binnie/craftgui/minecraft/MinecraftGUI.java
new file mode 100644
index 0000000000..a87b4deeb8
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/MinecraftGUI.java
@@ -0,0 +1,14 @@
+package binnie.craftgui.minecraft;
+
+import binnie.craftgui.window.Panel.IPanelType;
+
+public class MinecraftGUI
+{
+ public static enum PanelType
+ implements Panel.IPanelType
+ {
+ Black, Gray, Tinted, Coloured, Outline, TabOutline;
+
+ private PanelType() {}
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java b/src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java
new file mode 100644
index 0000000000..4b48e33e6d
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java
@@ -0,0 +1,63 @@
+package binnie.craftgui.minecraft;
+
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.ITooltipType;
+import net.minecraft.util.EnumChatFormatting;
+
+public class MinecraftTooltip
+ extends Tooltip
+{
+ public static enum Type
+ implements Tooltip.ITooltipType
+ {
+ Error, Warning;
+
+ private Type() {}
+ }
+
+ public static int getOutline(Tooltip.ITooltipType type)
+ {
+ return TypeColour.valueOf(type.toString()).getOutline();
+ }
+
+ public static String getTitle(Tooltip.ITooltipType type)
+ {
+ return TypeColour.valueOf(type.toString()).getTitle();
+ }
+
+ public static String getBody(Tooltip.ITooltipType type)
+ {
+ return TypeColour.valueOf(type.toString()).getBody();
+ }
+
+ private static enum TypeColour
+ {
+ Standard(5243135, EnumChatFormatting.WHITE, EnumChatFormatting.GRAY), Help(5046016, EnumChatFormatting.GREEN, EnumChatFormatting.DARK_GREEN), Information(49151, EnumChatFormatting.AQUA, EnumChatFormatting.DARK_AQUA), Error(16724224, EnumChatFormatting.RED, EnumChatFormatting.DARK_RED), Warning(16752384, EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD), User(9839667, EnumChatFormatting.RED, EnumChatFormatting.DARK_RED), Power(9006592, EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD);
+
+ int outline;
+ String mainText;
+ String bodyText;
+
+ private TypeColour(int outline, EnumChatFormatting mainText, EnumChatFormatting bodyText)
+ {
+ this.outline = outline;
+ this.mainText = mainText.toString();
+ this.bodyText = bodyText.toString();
+ }
+
+ public int getOutline()
+ {
+ return this.outline;
+ }
+
+ public String getTitle()
+ {
+ return this.mainText;
+ }
+
+ public String getBody()
+ {
+ return this.bodyText;
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java b/src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java
new file mode 100644
index 0000000000..d2655dc2fc
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java
@@ -0,0 +1,18 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.IInitializable;
+
+public class ModuleCraftGUI
+ implements IInitializable
+{
+ public void preInit() {}
+
+ public void init() {}
+
+ public void postInit()
+ {
+ for (GUIIcon icon : ) {
+ icon.register();
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/Window.java b/src/Java/binnie/craftgui/minecraft/Window.java
new file mode 100644
index 0000000000..e09cf1e376
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/Window.java
@@ -0,0 +1,338 @@
+package binnie.craftgui.minecraft;
+
+import binnie.Binnie;
+import binnie.core.AbstractMod;
+import binnie.core.BinnieCore;
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.IInventoryMachine;
+import binnie.core.machines.network.INetwork.RecieveGuiNBT;
+import binnie.core.machines.power.PowerSystem;
+import binnie.core.network.packet.MessageCraftGUI;
+import binnie.core.proxy.BinnieProxy;
+import binnie.core.resource.BinnieResource;
+import binnie.core.resource.ManagerResource;
+import binnie.core.resource.ResourceType;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITooltipHelp;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.TopLevelWidget;
+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.control.ControlHelp;
+import binnie.craftgui.minecraft.control.ControlInfo;
+import binnie.craftgui.minecraft.control.ControlPowerSystem;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlUser;
+import binnie.craftgui.minecraft.control.EnumHighlighting;
+import binnie.craftgui.resource.StyleSheetManager;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import com.mojang.authlib.GameProfile;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.List;
+import java.util.Map;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+
+public abstract class Window
+ extends TopLevelWidget
+ implements INetwork.RecieveGuiNBT
+{
+ private GuiCraftGUI gui;
+ private ContainerCraftGUI container;
+ private WindowInventory windowInventory;
+ private ControlText title;
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ Deque<IWidget> queue = calculateMousedOverWidgets();
+ while (!queue.isEmpty())
+ {
+ IWidget widget = (IWidget)queue.removeFirst();
+ if ((widget.isEnabled()) && (widget.isVisible()) && (widget.calculateIsMouseOver()))
+ {
+ if ((widget instanceof ITooltip))
+ {
+ ((ITooltip)widget).getTooltip(tooltip);
+ if (tooltip.exists()) {
+ return;
+ }
+ }
+ if (widget.hasAttribute(Attribute.BlockTooltip)) {
+ return;
+ }
+ }
+ }
+ }
+
+ public void getHelpTooltip(MinecraftTooltip tooltip)
+ {
+ Deque<IWidget> queue = calculateMousedOverWidgets();
+ while (!queue.isEmpty())
+ {
+ IWidget widget = (IWidget)queue.removeFirst();
+ if ((widget.isEnabled()) && (widget.isVisible()) && (widget.calculateIsMouseOver()))
+ {
+ if ((widget instanceof ITooltipHelp))
+ {
+ ((ITooltipHelp)widget).getHelpTooltip(tooltip);
+ if (tooltip.exists()) {
+ return;
+ }
+ }
+ if (widget.hasAttribute(Attribute.BlockTooltip)) {
+ return;
+ }
+ }
+ }
+ }
+
+ protected abstract AbstractMod getMod();
+
+ protected abstract String getName();
+
+ public BinnieResource getBackgroundTextureFile(int i)
+ {
+ return Binnie.Resource.getPNG(getMod(), ResourceType.GUI, getName() + (i == 1 ? "" : Integer.valueOf(i)));
+ }
+
+ public boolean showHelpButton()
+ {
+ return Machine.getInterface(IInventoryMachine.class, getInventory()) != null;
+ }
+
+ public String showInfoButton()
+ {
+ if (Machine.getInterface(IMachineInformation.class, getInventory()) != null) {
+ return ((IMachineInformation)Machine.getInterface(IMachineInformation.class, getInventory())).getInformation();
+ }
+ return null;
+ }
+
+ public Window(float width, float height, EntityPlayer player, IInventory inventory, Side side)
+ {
+ this.side = side;
+ setInventories(player, inventory);
+ this.container = new ContainerCraftGUI(this);
+ this.windowInventory = new WindowInventory(this);
+ if (side == Side.SERVER) {
+ return;
+ }
+ setSize(new IPoint(width, height));
+ this.gui = new GuiCraftGUI(this);
+ for (EnumHighlighting h : EnumHighlighting.values()) {
+ ControlSlot.highlighting.put(h, new ArrayList());
+ }
+ CraftGUI.Render = new Renderer(this.gui);
+ CraftGUI.Render.stylesheet(StyleSheetManager.getDefault());
+
+ this.titleButtonLeft = -14.0F;
+ if (showHelpButton()) {
+ new ControlHelp(this, this.titleButtonLeft += 22.0F, 8.0F);
+ }
+ if (showInfoButton() != null) {
+ new ControlInfo(this, this.titleButtonLeft += 22.0F, 8.0F, showInfoButton());
+ }
+ Window wind = this;
+
+ addSelfEventHandler(new EventWidget.ChangeSize.Handler()
+ {
+ public void onEvent(EventWidget.ChangeSize event)
+ {
+ if ((Window.this.isClient()) && (Window.this.getGui() != null))
+ {
+ Window.this.getGui().resize(Window.this.getSize());
+ if (Window.this.title != null) {
+ Window.this.title.setSize(new IPoint(Window.this.w(), Window.this.title.h()));
+ }
+ }
+ }
+ });
+ }
+
+ protected float titleButtonLeft = 8.0F;
+ protected float titleButtonRight = 8.0F;
+
+ public void setTitle(String title)
+ {
+ this.title = new ControlTextCentered(this, 12.0F, title);
+ this.title.setColour(4210752);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public final GuiCraftGUI getGui()
+ {
+ return this.gui;
+ }
+
+ public final ContainerCraftGUI getContainer()
+ {
+ return this.container;
+ }
+
+ public final WindowInventory getWindowInventory()
+ {
+ return this.windowInventory;
+ }
+
+ private StandardTexture bgText1 = null;
+ private StandardTexture bgText2 = null;
+ private boolean hasBeenInitialised = false;
+ private EntityPlayer player;
+ private IInventory entityInventory;
+
+ public final void initGui()
+ {
+ if (this.hasBeenInitialised) {
+ return;
+ }
+ this.bgText1 = new StandardTexture(0, 0, 256, 256, getBackgroundTextureFile(1));
+ if (getSize().x() > 256.0F) {
+ this.bgText2 = new StandardTexture(0, 0, 256, 256, getBackgroundTextureFile(2));
+ }
+ if (!BinnieCore.proxy.checkTexture(this.bgText1.getTexture()))
+ {
+ this.bgText1 = null;
+ this.bgText2 = null;
+ }
+ initialiseClient();
+ this.hasBeenInitialised = true;
+ }
+
+ public abstract void initialiseClient();
+
+ public void initialiseServer() {}
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.colour(16777215);
+ if (getBackground1() != null) {
+ CraftGUI.Render.texture(getBackground1(), IPoint.ZERO);
+ }
+ if (getBackground2() != null) {
+ CraftGUI.Render.texture(getBackground2(), new IPoint(256.0F, 0.0F));
+ }
+ CraftGUI.Render.colour(getColour());
+ CraftGUI.Render.texture(CraftGUITexture.Window, getArea());
+ }
+
+ public void onUpdateClient()
+ {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Help)).clear();
+
+ ControlSlot.shiftClickActive = false;
+ }
+
+ public EntityPlayer getPlayer()
+ {
+ return this.player;
+ }
+
+ public GameProfile getUsername()
+ {
+ return getPlayer().getGameProfile();
+ }
+
+ public ItemStack getHeldItemStack()
+ {
+ if (this.player != null) {
+ return this.player.inventory.getItemStack();
+ }
+ return null;
+ }
+
+ public IInventory getInventory()
+ {
+ return this.entityInventory;
+ }
+
+ public void setInventories(EntityPlayer player2, IInventory inventory)
+ {
+ this.player = player2;
+ this.entityInventory = inventory;
+ }
+
+ public void onClose() {}
+
+ public void setHeldItemStack(ItemStack stack)
+ {
+ if (this.player != null) {
+ this.player.inventory.setItemStack(stack);
+ }
+ }
+
+ private Side side = Side.CLIENT;
+
+ public boolean isServer()
+ {
+ return !isClient();
+ }
+
+ public boolean isClient()
+ {
+ return this.side == Side.CLIENT;
+ }
+
+ public World getWorld()
+ {
+ if (getPlayer() != null) {
+ return getPlayer().worldObj;
+ }
+ return BinnieCore.proxy.getWorld();
+ }
+
+ public void onInventoryUpdate() {}
+
+ public void sendClientAction(String name, NBTTagCompound action)
+ {
+ action.setString("type", name);
+ MessageCraftGUI packet = new MessageCraftGUI(action);
+ BinnieCore.proxy.sendToServer(packet);
+ }
+
+ public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ if ((side == Side.CLIENT) && (name.equals("username")))
+ {
+ new ControlUser(this, w() - (this.titleButtonRight += 16.0F), 8.0F, action.getString("username"));
+ this.titleButtonRight += 6.0F;
+ }
+ if ((side == Side.CLIENT) && (name.equals("power-system")))
+ {
+ new ControlPowerSystem(this, w() - (this.titleButtonRight += 16.0F), 8.0F, PowerSystem.get(action.getByte("system")));
+ this.titleButtonRight += 6.0F;
+ }
+ }
+
+ public void onWindowInventoryChanged() {}
+
+ public Texture getBackground1()
+ {
+ return this.bgText1;
+ }
+
+ public Texture getBackground2()
+ {
+ return this.bgText2;
+ }
+
+ public static <T extends Window> T get(IWidget widget)
+ {
+ return (Window)widget.getSuperParent();
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/WindowInventory.java b/src/Java/binnie/craftgui/minecraft/WindowInventory.java
new file mode 100644
index 0000000000..9c38bf1a9b
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/WindowInventory.java
@@ -0,0 +1,144 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.machines.inventory.SlotValidator;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+
+public class WindowInventory
+ implements IInventory
+{
+ private Window window;
+
+ public WindowInventory(Window window)
+ {
+ this.window = window;
+ }
+
+ private Map<Integer, ItemStack> inventory = new HashMap();
+ private Map<Integer, SlotValidator> validators = new HashMap();
+ private List<Integer> disabledAutoDispenses = new ArrayList();
+
+ public int getSizeInventory()
+ {
+ if (this.inventory.size() == 0) {
+ return 0;
+ }
+ int max = 0;
+ for (Iterator i$ = this.inventory.keySet().iterator(); i$.hasNext();)
+ {
+ int i = ((Integer)i$.next()).intValue();
+ if (i > max) {
+ max = i;
+ }
+ }
+ return max + 1;
+ }
+
+ public ItemStack getStackInSlot(int var1)
+ {
+ if (this.inventory.containsKey(Integer.valueOf(var1))) {
+ return (ItemStack)this.inventory.get(Integer.valueOf(var1));
+ }
+ return null;
+ }
+
+ public ItemStack decrStackSize(int index, int amount)
+ {
+ if (this.inventory.containsKey(Integer.valueOf(index)))
+ {
+ ItemStack item = (ItemStack)this.inventory.get(Integer.valueOf(index));
+ ItemStack output = item.copy();
+ int available = item.stackSize;
+ if (amount > available) {
+ amount = available;
+ }
+ item.stackSize -= amount;
+ output.stackSize = amount;
+ if (item.stackSize == 0) {
+ setInventorySlotContents(index, null);
+ }
+ return output;
+ }
+ return null;
+ }
+
+ public ItemStack getStackInSlotOnClosing(int var1)
+ {
+ return null;
+ }
+
+ public void setInventorySlotContents(int var1, ItemStack var2)
+ {
+ this.inventory.put(Integer.valueOf(var1), var2);
+ markDirty();
+ }
+
+ public String getInventoryName()
+ {
+ return "window.inventory";
+ }
+
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ public void markDirty()
+ {
+ this.window.onWindowInventoryChanged();
+ }
+
+ public boolean isUseableByPlayer(EntityPlayer var1)
+ {
+ return true;
+ }
+
+ public void openInventory() {}
+
+ public void closeInventory() {}
+
+ public boolean hasCustomInventoryName()
+ {
+ return false;
+ }
+
+ public boolean isItemValidForSlot(int i, ItemStack itemstack)
+ {
+ if (this.validators.containsKey(Integer.valueOf(i))) {
+ return ((SlotValidator)this.validators.get(Integer.valueOf(i))).isValid(itemstack);
+ }
+ return true;
+ }
+
+ public void createSlot(int slot)
+ {
+ this.inventory.put(Integer.valueOf(slot), null);
+ }
+
+ public void setValidator(int slot, SlotValidator validator)
+ {
+ this.validators.put(Integer.valueOf(slot), validator);
+ }
+
+ public void disableAutoDispense(int i)
+ {
+ this.disabledAutoDispenses.add(Integer.valueOf(i));
+ }
+
+ public boolean dispenseOnClose(int i)
+ {
+ return !this.disabledAutoDispenses.contains(Integer.valueOf(i));
+ }
+
+ public SlotValidator getValidator(int i)
+ {
+ return (SlotValidator)this.validators.get(Integer.valueOf(i));
+ }
+}
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;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java b/src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java
new file mode 100644
index 0000000000..51addcd1db
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java
@@ -0,0 +1,10 @@
+package binnie.craftgui.minecraft.render;
+
+import binnie.core.resource.IBinnieTexture;
+import binnie.craftgui.core.geometry.IArea;
+
+public class MinecraftTexture
+{
+ IArea textureArea = new IArea(0.0F, 0.0F, 0.0F, 0.0F);
+ IBinnieTexture texture;
+}
diff --git a/src/Java/binnie/craftgui/minecraft/render/RenderCommand.java b/src/Java/binnie/craftgui/minecraft/render/RenderCommand.java
new file mode 100644
index 0000000000..2cfa60f08a
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/render/RenderCommand.java
@@ -0,0 +1,16 @@
+package binnie.craftgui.minecraft.render;
+
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+
+public abstract class RenderCommand
+{
+ IWidget widget;
+
+ public RenderCommand(IWidget widget)
+ {
+ this.widget = widget;
+ }
+
+ public abstract void render(GuiCraftGUI paramGuiCraftGUI);
+}