package net.aeronica.mods.mxtune.gui;

import java.io.IOException;

import org.lwjgl.opengl.GL11;

import net.aeronica.mods.mxtune.MXTuneMain;
import net.aeronica.mods.mxtune.inventory.ContainerInstrument;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import scala.Char;

public class GuiInstrumentInventory extends GuiContainer {
	public static final int GUI_ID = 1;

	private Minecraft mc;
	private FontRenderer fontRenderer = null;
	int theInvItemSlot;

	private static final ResourceLocation inventoryTexture = new ResourceLocation(
			MXTuneMain.prependModID("textures/gui/instrument_inventory.png"));

	/** The inventory to render on screen */
	// private final InventoryInstrument inventory;

	public GuiInstrumentInventory(ContainerInstrument containerInstrument) {
		super(containerInstrument);
		this.mc = Minecraft.getMinecraft();

		// The slot inventory.currentItem is 0 based
		this.theInvItemSlot = mc.player.inventory.currentItem;
		this.fontRenderer = mc.fontRenderer;

		xSize = 184;
		ySize = 166;
	}

	/**
	 * Draw the foreground layer for the GuiContainer (everything in front of
	 * the items)
	 */
	// NOTE: In Forge 804, getString() is named func_135053_a()
	// NOTE: In Forge 804, renderEngine is func_110434_K()
	// NOTE: In Forge 804, bindTexture() is func_110577_a()
	@Override
	protected void drawGuiContainerForegroundLayer(int par1, int par2) {
		if (mc.player.getHeldItemMainhand() == null)
			return;
		String s = mc.player.getHeldItemMainhand().getDisplayName();
		this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 12, 4210752);
		this.fontRenderer.drawString(I18n.format("container.inventory"), 12, this.ySize - 96 + 4, 4210752);
	}

	@Override
	protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
		GL11.glColor4f(1F, 1F, 1F, 1F);
		mc.renderEngine.bindTexture(inventoryTexture);
		drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
	}

	/*
	 * Don't allow the held inventory to be moved from it's slot.
	 * 
	 */
	@Override
	protected void keyTyped(char par1, int par2) throws IOException {
		if (Char.char2int(par1) == (this.theInvItemSlot + 49))
			return;
		super.keyTyped(par1, par2);
	}
}

@@ -549,31 +549,8 @@
 1;%0A%0A
-%09private Minecraft mc;%0A
 %09pri
@@ -765,100 +765,8 @@
 );%0A%0A
-%09/** The inventory to render on screen */%0A%09// private final InventoryInstrument inventory;%0A%0A
 %09pub
@@ -1086,281 +1086,777 @@
 %09%7D%0A%0A
-%09/**%0A%09
+    /**%0A    
  * Draw
+s
  the 
-foreground layer for the GuiContainer (everything in front of%0A%09 * the items)%0A%09 */%0A%09// NOTE: In Forge 804, getString() is named func_135053_a()%0A%09// NOTE: In Forge 804, renderEngine is func_110434_K()%0A%09// NOTE: In Forge 804, bindTexture() is func_110577_a()
+screen and all the components in it including tool tips%0A     */%0A%09@Override%0A    public void drawScreen(int mouseX, int mouseY, float partialTicks)%0A    %7B%0A        this.drawDefaultBackground();%0A        super.drawScreen(mouseX, mouseY, partialTicks);%0A        this.renderHoveredToolTip(mouseX, mouseY);%0A    %7D%0A%0A%09/**%0A%09 * Draw the tool tips of items in this inventory%0A%09 */%0A%09@Override%0A    protected void renderHoveredToolTip(int mouseX, int mouseY)%0A    %7B%0A        if (this.getSlotUnderMouse() != null && this.getSlotUnderMouse().getHasStack())%0A        %7B%0A            this.renderToolTip(this.getSlotUnderMouse().getStack(), mouseX, mouseY);%0A        %7D%0A    %7D%0A%0A%09/**%0A%09 * Draw the foreground layer for the GuiContainer (everything in front of%0A%09 * the items)%0A%09 */
 %0A%09@O
@@ -2530,23 +2530,24 @@
  held in
-ventory
+strument
  to be m
@@ -2618,30 +2618,38 @@
 ed(char 
-p
+typedCh
 ar
-1
 , int 
-par2
+keyCode
 ) throws
@@ -2683,20 +2683,25 @@
 har2int(
-p
+typedCh
 ar
-1
 ) == (th
@@ -2757,18 +2757,26 @@
 ped(
-p
+typedCh
 ar
-1
 , 
-par2
+keyCode
 );%0A%09

Handle drawing tool tips for the items in the instrument inventory.