khanat-client/scenes/interfaces/inventory_window/inventory_box.gd

28 lines
820 B
GDScript3
Raw Normal View History

2020-04-01 19:02:49 +00:00
extends VBoxContainer
signal inventory_item_hovered( item )
signal inventory_item_gui_input( item, event, node )
2021-01-21 21:03:44 +00:00
2020-04-01 19:02:49 +00:00
func _on_inventory_item_hovered( item ):
2021-01-21 21:03:44 +00:00
emit_signal( "inventory_item_hovered", item )
2020-04-01 19:02:49 +00:00
func _on_inventory_item_gui_input( item, event, node ):
2021-01-21 21:03:44 +00:00
emit_signal( "inventory_item_gui_input", item, event, node )
2020-04-01 19:02:49 +00:00
func clean_inventory():
2021-01-21 21:03:44 +00:00
for child in $scroll_item_box/items_box.get_children():
$scroll_item_box/items_box.remove_child( child )
child.queue_free()
2020-04-01 19:02:49 +00:00
func set_inventory( p_inventory ):
2021-01-21 21:03:44 +00:00
self.clean_inventory()
if p_inventory:
for item in p_inventory.items:
print( item )
var new_item_box = preload( "res://scenes/interfaces/inventory_window/item_box.tscn").instance()
new_item_box.item = item
new_item_box.update()
$scroll_item_box/items_box.add_child( new_item_box )