Added debug inventory menu

This commit is contained in:
2025-05-19 17:41:39 -05:00
parent 3b9986b4ee
commit 057ed10851
26 changed files with 309 additions and 24 deletions

View File

@@ -0,0 +1,46 @@
class_name FullInventoryMenu extends Panel
@export var itemLine:PackedScene = null;
@export var itemList:Control = null;
var inventory:Inventory = null;
func _ready() -> void:
hide()
_updateItemList()
func _exit_tree() -> void:
pass
func open(inventory:Inventory = null) -> void:
if self.inventory != null:
self.inventory.inventoryUpdated.disconnect(_updateItemList)
if inventory == null:
inventory = ITEM.PLAYER_INVENTORY;
self.inventory = inventory;
self.inventory.inventoryUpdated.connect(_updateItemList)
_updateItemList()
self.show()
func close() -> void:
self.hide()
func isOpen() -> bool:
return self.visible
func _updateItemList() -> void:
if inventory == null:
return
# Clear item list
while itemList.get_child_count() > 0:
var child = itemList.get_child(0)
itemList.remove_child(child)
child.queue_free()
for stack in inventory.contents:
var node = itemLine.instantiate()
node.setStack(stack)
itemList.add_child(node)

View File

@@ -0,0 +1 @@
uid://cla3ph1j2ligp

View File

@@ -0,0 +1,5 @@
class_name ItemLine extends HBoxContainer
func setStack(stack:ItemStack) -> void:
$ItemName.text = Item.getName(stack.type, 1)
$ItemQuantity.text = str(stack.quantity)

View File

@@ -0,0 +1 @@
uid://dgblia2ukssbe