extends Node

class_name InventoryMenu


@onready var inventory : Inventory
@onready var item_list : VBoxContainer =  $CanvasLayer/PanelContainer/VBoxContainer/MarginContainer/ScrollContainer/VBoxContainer
var item_scene : PackedScene = preload("res://Scenes/Menu/InventoryUiItem.tscn")

func _ready() -> void:
	$CanvasLayer.hide()
	pass


func toggle_inventory() -> bool:
	var canvas = $CanvasLayer
	if canvas.visible == true:
		$CanvasLayer.hide()
		return false
	else:
		update_inventory()
		$CanvasLayer.show()
		return true

func update_inventory():
	for i in inventory.items:
		var new_item = item_scene.instantiate()
		# new_item.set_values(i.item.name, i.item.value, i.item.weight)
		item_list.add_child(new_item)
		new_item.set_values(i.item.name, 10, 10)
		print(i.item.name)
		print(i)
	pass
