Added debug inventory menu
This commit is contained in:
@@ -6,6 +6,8 @@ func _ready() -> void:
|
||||
$MainMenu.connect("pressed", _on_MainMenu_pressed);
|
||||
$OverworldOption/Overworld.connect("pressed", _on_Overworld_pressed);
|
||||
$Quests.connect("pressed", _on_Quests_pressed);
|
||||
$Inventory.connect("pressed", _on_Inventory_pressed);
|
||||
$Event.connect("pressed", _on_Event_pressed);
|
||||
$Cutscene.connect("pressed", _on_Custscene_pressed);
|
||||
$Cooking.connect("pressed", _on_Cooking_pressed);
|
||||
$Battle.connect("pressed", _on_Battle_pressed);
|
||||
@@ -58,6 +60,16 @@ func _on_Cooking_pressed():
|
||||
func _on_Battle_pressed():
|
||||
print("Battle pressed")
|
||||
|
||||
func _on_Event_pressed():
|
||||
print("Event pressed")
|
||||
|
||||
func _on_Inventory_pressed():
|
||||
close()
|
||||
if UI.INVENTORY_MENU.isOpen():
|
||||
UI.INVENTORY_MENU.close()
|
||||
else:
|
||||
UI.INVENTORY_MENU.open()
|
||||
|
||||
func open() -> void:
|
||||
show()
|
||||
|
||||
|
1
scripts/UI/FullInventoryMenu.gd.uid
Normal file
1
scripts/UI/FullInventoryMenu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bqe8ve2hn3coc
|
46
scripts/UI/Inventory/FullInventoryMenu.gd
Normal file
46
scripts/UI/Inventory/FullInventoryMenu.gd
Normal 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)
|
1
scripts/UI/Inventory/FullInventoryMenu.gd.uid
Normal file
1
scripts/UI/Inventory/FullInventoryMenu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cla3ph1j2ligp
|
5
scripts/UI/Inventory/ItemLine.gd
Normal file
5
scripts/UI/Inventory/ItemLine.gd
Normal 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)
|
1
scripts/UI/Inventory/ItemLine.gd.uid
Normal file
1
scripts/UI/Inventory/ItemLine.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dgblia2ukssbe
|
Reference in New Issue
Block a user