TinyAdventure/ui/item_slot.gd

18 lines
411 B
GDScript
Raw Normal View History

2024-07-09 22:33:38 +02:00
class_name ItemSlot
extends PanelContainer
@onready var texture_rect:TextureRect = %TextureRect
@onready var count_label = %CountLabel
2024-07-09 22:33:38 +02:00
func display(item:Item, count:int):
if item != null:
texture_rect.texture = item.icon
update_quantity_text(count)
func update_quantity_text(stack_size) -> void:
if stack_size <= 1:
count_label.hide()
else:
count_label.text = str(stack_size)
count_label.show()