From 23f45d54650102072149bdfbac18fe6de5cbb2ed Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Sat, 22 Mar 2025 08:44:07 -0400 Subject: [PATCH] Quickslot starts from beginning/end when rolling over --- scenes/ui/quick_slots.gd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scenes/ui/quick_slots.gd b/scenes/ui/quick_slots.gd index 74d3a01..dcbe106 100644 --- a/scenes/ui/quick_slots.gd +++ b/scenes/ui/quick_slots.gd @@ -10,6 +10,10 @@ var _items: Array[String] = ["001", "005", "002", "003", "004", "006"] var _previous_selected_item: int = 0 var _selected_item: int = 0 : set(new_item_index): + if new_item_index < 0: + new_item_index = _items.size() - 1 + elif new_item_index >= _items.size(): + new_item_index = 0 _previous_selected_item = _selected_item _selected_item = new_item_index @@ -63,12 +67,12 @@ func select_item_index(slot_index: int) -> void: InventoryManager.quick_slot_item_changed.emit(get_selected_item()) func select_previous_item() -> void: - _selected_item = clampi(_selected_item - 1, 0, _items.size() - 1) + _selected_item -= 1 update_highlighted_slot() InventoryManager.quick_slot_item_changed.emit(get_selected_item()) func select_next_item() -> void: - _selected_item = clampi(_selected_item + 1, 0, _items.size() - 1) + _selected_item += 1 update_highlighted_slot() InventoryManager.quick_slot_item_changed.emit(get_selected_item())