using Godot;

public partial class Item : Control
{
	[Export]
	public TipoItem Tipo;

	public override void _Ready()
	{
		switch (Tipo)
		{
			case TipoItem.NoItem:
				GetNode<TextureButton>("Click").TextureNormal = null;
				break;
            case TipoItem.Filtro:
                GetNode<TextureButton>("Click").TextureNormal = ResourceLoader.Load<Texture2D>("res://Res/PNGs/Mascara.webp");
                break;
            case TipoItem.LlaveCajaF:
                GetNode<TextureButton>("Click").TextureNormal = ResourceLoader.Load<Texture2D>("res://Res/PNGs/Asset_p1_llave.png");
                break;
            case TipoItem.Destornillador:
                GetNode<TextureButton>("Click").TextureNormal = ResourceLoader.Load<Texture2D>("res://Res/PNGs/Asset_p2_destornillador.png");
                break;
            case TipoItem.Tarjeta:
                GetNode<TextureButton>("Click").TextureNormal = ResourceLoader.Load<Texture2D>("res://Res/PNGs/Blanco.png");
                break;
        }
	}

	public void _on_item_pressed()
	{
		if (Game.sala.itemSelected!=null && !Game.sala.itemSelected.Equals(this))
		{
            Game.sala.itemSelected.Modulate = new Color(1, 1, 1, 1f);
            Game.sala.itemSelected = this;
            Modulate = new Color(1, 1, 0, 1f);
        }
		else if (Game.sala.itemSelected != null && Game.sala.itemSelected.Equals(this))
		{
			Game.sala.itemSelected.Modulate = new Color(1, 1, 1, 1f);
			Game.sala.itemSelected = null;
		}
        else if (Game.sala.itemSelected == null)
        {
            Game.sala.itemSelected = this;
            Modulate = new Color(1, 1, 0, 1f);
        }
		if (Game.sala.itemSelected!= null && Game.sala.itemSelected.Tipo==TipoItem.Filtro)
        {
            Game.sala.GetNode<Label>("Control/3/Nota2/ClaveP").Visible = true;
        }
        else
        {
            Game.sala.GetNode<Label>("Control/3/Nota2/ClaveP").Visible = false;
        }
    }
}

public enum TipoItem
{
	NoItem,
	Filtro=1,
	LlaveCajaF=3,
	Destornillador=5,
	Tarjeta=10
}
