package projectzombie.menu;

import gl_engine.matrix.Matrix4;
import gl_engine.vec.Vec2d;
import projectzombie.Main;
import projectzombie.init.Items;
import projectzombie.init.Models;
import projectzombie.init.Recipes;
import projectzombie.inventory.Crafting;
import projectzombie.inventory.Inventory;
import projectzombie.inventory.recipe.Recipe;
import projectzombie.menu.gui.GUIContainerSlider;
import projectzombie.menu.gui.GUIItemSlot;
import projectzombie.menu.gui.GUIItemSlotGetter;
import projectzombie.menu.gui.GUIRecipeCard;
import projectzombie.util.ItemStack;

public class MenuInventoryBasic extends MenuInventory
{
	private GUIContainerSlider slider;
	private Inventory inventory;

	public MenuInventoryBasic(Menu parent, Crafting tool) {
		super(parent);
		
		Recipe[] recipies = Recipes.getCraftableRecipies(tool);
		inventory = Main.player.getInventory();
		
		slider = new GUIContainerSlider(new Vec2d(
				Models.UI_INVENTORY.getWidth() * 21 / 256.0,
				-Models.UI_INVENTORY.getHeight() * 127 / 256.0), new Vec2d(
				Models.UI_INVENTORY.getWidth() * 234 / 256.0,
				Models.UI_INVENTORY.getHeight() * 254 / 256.0),
				recipies.length * Models.UI_LABEL_RECIPE.getHeight() *
				36 / 34.0 - Models.UI_INVENTORY.getHeight());
		
		for(int i=0;i<recipies.length;i++)
		{
			Recipe recipe = recipies[i];
			
			GUIRecipeCard slot = new GUIRecipeCard(inventory, slider, recipe, tool, new Vec2d(0,
					Models.UI_SELECTION_BOX_CRAFTING.getHeight() / 2 -
					(i + 1) * Models.UI_LABEL_RECIPE.getHeight() * 36 / 34.0));
			
			
			slider.add(slot);
		}
		
		gui.add(slider);
	}
	
	@Override
	public void render()
	{
		Matrix4 matrix = Matrix4.translate(0, -Models.UI_INVENTORY.getHeight() / 2, 0);
		
		// Render the inventory gui
		Models.UI_SELECTION_BOX_CRAFTING.setModel(matrix);
		Models.UI_SELECTION_BOX_CRAFTING.render();
		
		super.render();
	}
}
