package com.lothrazar.powerinventory.inventory;

import com.lothrazar.powerinventory.Const;
import com.lothrazar.powerinventory.ModConfig;
import com.lothrazar.powerinventory.UtilTextureRender;
import com.lothrazar.powerinventory.inventory.client.GuiButtonOpenInventory;
import com.lothrazar.powerinventory.inventory.slot.*;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; 
import net.minecraft.util.ResourceLocation;

public class GuiCustomPlayerInventory extends GuiContainer
{
	ResourceLocation res = new ResourceLocation(Const.MODID, "inventory.png");
	private final InventoryCustomPlayer inventory;
	//private final EntityPlayer thePlayer;
	
	
	public GuiCustomPlayerInventory(EntityPlayer player, InventoryPlayer inventoryPlayer, InventoryCustomPlayer inventoryCustom)
	{
		//the player.inventory gets passed in here
		super(new ContainerCustomPlayer(player, inventoryPlayer, inventoryCustom));
		inventory = inventoryCustom;
		//thePlayer = player;
		
		this.xSize = 338;
		this.ySize = 221;
	}
	
	@Override
	public void initGui()
    { 
		super.initGui();
		 /*
		int button_id = 199;
		int width = 26;
		final int height = 20;

		
		btnEnder = new GuiButtonOpenInventory(button_id++, 
				this.guiLeft + SlotEnderChest.posX + 19, 
				this.guiTop + SlotEnderChest.posY - 1,
				12,height, "I",Const.INV_ENDER); 
		this.buttonList.add(btnEnder); 
		//btnEnder.enabled = false;// turn it on based on ender chest present or not
		//btnEnder.visible = btnEnder.enabled;
		
 */
    }
	
	public void drawScreen(int par1, int par2, float par3)
	{
		super.drawScreen(par1, par2, par3);
	
	}
	@Override
	protected void drawGuiContainerForegroundLayer(	int p_146976_2_, int p_146976_3_)
	{ 
		//drawing text and such on screen
		this.checkSlotsEmpty();
		
	}
	
	private void checkSlotsEmpty()
	{
		final int s = 16;

		if(inventory.getStackInSlot(Const.enderPearlSlot) == null)
		{  
			UtilTextureRender.drawTextureSimple(SlotEnderPearl.background,SlotEnderPearl.posX, SlotEnderPearl.posY,s,s);
		}

		if(inventory.getStackInSlot(Const.enderChestSlot) == null)
		{  
			UtilTextureRender.drawTextureSimple(SlotEnderChest.background,SlotEnderChest.posX, SlotEnderChest.posY,s,s);
		}
	}
	private ResourceLocation bkg = new ResourceLocation(Const.MODID,  "textures/gui/inventory.png");
	@Override
	protected void drawGuiContainerBackgroundLayer(float p_146976_1_,	int p_146976_2_, int p_146976_3_)
	{ 
		//GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
		//GL11.glScalef(1.0F, 1.0F, 1.0F);//so it does not change scale
		//this.mc.getTextureManager().bindTexture(new ResourceLocation(Const.MODID,  "textures/gui/inventory.png"));
		
		//UtilTextureRender.drawTexturedQuadFit(this.guiLeft, this.guiTop,this.xSize,this.ySize);//,0
		UtilTextureRender.drawTextureSimple(bkg, this.guiLeft, this.guiTop,this.xSize,this.ySize);
	 

        drawSlotAt(SlotEnderChest.posX, SlotEnderChest.posY);
    	drawSlotAt(SlotEnderPearl.posX, SlotEnderPearl.posY);
	}
	private void drawSlotAt(int x, int y)
	{
        UtilTextureRender.drawTextureSimple(Const.slot,this.guiLeft+ x -1, this.guiTop+ y -1,  Const.SQ, Const.SQ);
	}
}

@@ -520,16 +520,53 @@
 layer; %0A
+import net.minecraft.inventory.Slot;%0A
 import n
@@ -601,16 +601,16 @@
 cation;%0A
-
 %0Apublic 
@@ -739,16 +739,63 @@
 .png%22);%0A
+%09public static boolean SHOW_DEBUG_NUMS = true;%0A
 %09private
@@ -835,18 +835,58 @@
 ntory;%0A%09
-//
+private ContainerCustomPlayer container;%0A%09
 private 
@@ -1171,16 +1171,74 @@
 stom));%0A
+%09%09container = (ContainerCustomPlayer)this.inventorySlots;%0A
 %09%09invent
@@ -1262,18 +1262,16 @@
 stom;%0A%09%09
-//
 thePlaye
@@ -1914,16 +1914,370 @@
 par3);%0A%09
+%09%0A%09%09if(SHOW_DEBUG_NUMS)%7B %0A%09%09%09for(Slot s : this.container.inventorySlots)%0A%09%09%09%7B%0A%09%09%09%09//each slot has two different numbers. the slotNumber is UNIQUE, the index is not%0A%09%09%09%09this.drawString(this.fontRendererObj, %22%22 + s.getSlotIndex(), %0A%09%09%09%09%09%09this.guiLeft + s.xDisplayPosition,%0A%09%09%09%09%09%09this.guiTop + s.yDisplayPosition +  4, %0A%09%09%09%09%09%0916777120);//font color%0A%09%09%09%7D%0A%09%09%7D
 %0A%09%7D%0A%09@Ov
@@ -2406,16 +2406,22 @@
  screen%0A
+%09%09%0A%09%09%0A
 %09%09this.c
@@ -2438,19 +2438,16 @@
 mpty();%0A
-%09%09%0A
 %09%7D%0A%09%0A%09pr

add debug mode showing slot nums