class_name QuickSlotsSlot extends Panel @export var amount_label: Label @export var slot_texture: TextureRect var slot_index: int = 0 func _ready() -> void: InventoryManager.inventory_slot_updated.connect(_on_inventory_slot_updated) func init(_slot_index: int) -> void: slot_index = _slot_index refresh() func clear() -> void: slot_texture.texture = null amount_label.text = "" slot_texture.tooltip_text = "" func refresh() -> void: if InventoryManager.inventory.size() < 1 or slot_index >= InventoryManager.inventory.size(): return clear() elif InventoryManager.inventory[slot_index] == null: return clear() elif InventoryManager.creative_mode: amount_label.text = "∞" return slot_texture.texture = load(InventoryManager.inventory[slot_index].item_texture) slot_texture.tooltip_text = InventoryManager.inventory[slot_index].name + "\n" + InventoryManager.inventory[slot_index].description amount_label.text = "x" + str(InventoryManager.inventory[slot_index].amount) func _on_inventory_slot_updated(_slot_index: int) -> void: if _slot_index != slot_index: return refresh()