package com.zenoton.TunnelLWJGL.java.Inventory.Tools;

import com.zenoton.TunnelLWJGL.java.helpers.InputMouse;
import com.zenoton.TunnelLWJGL.java.helpers.Resources;
import com.zenoton.TunnelLWJGL.java.helpers.Texture;
import org.lwjgl.opengl.GL11;

import static org.lwjgl.opengl.GL11.*;

/**
 * Created by CAMPBELL MILLAR on 15/09/2015. READ ATTACHED LICENCE (GNU LESSER PUBLIC LICENCE).
 */
public abstract class Tools {
    public int inventorySlot;
    public String tool;
    public Texture toolImage = null;
    public static int selectedSlot=0;
    public Tools(int inventorySlot){
        this.inventorySlot = inventorySlot;
        init();
    }
    public abstract void init();
    public void render(){
        glPushMatrix();
        GL11.glScalef(1,1,0);
        glTranslatef(0,0,0);
        Resources.getImage("slot").draw(32*inventorySlot+600,10);
        glPopMatrix();
        if (inventorySlot == selectedSlot){
            Resources.getImage("slector").draw(32*inventorySlot+600,10);
        }
        if (toolImage != null){
            toolImage.draw((32*inventorySlot+600)+8,18);
        }
        glPopMatrix();
    }
    public void clicked(int x,int y){
        if(x>32*inventorySlot+600 && x<32*inventorySlot+600+32 && y>10 && y<10+32 && InputMouse.leftButton()){
            selectedSlot = inventorySlot;
        }
    }
    public abstract void update();
}
