|
|
@ -20,7 +20,7 @@ var _selected_item: int = 0 : |
|
|
|
func _init() -> void: |
|
|
|
InventoryManager.next_quick_slot.connect(select_next_item.bind()) |
|
|
|
InventoryManager.previous_quick_slot.connect(select_previous_item.bind()) |
|
|
|
InventoryManager.select_quick_slot.connect(select_item_index.bind()) |
|
|
|
InventoryManager.select_quick_slot.connect(select_quick_slot.bind()) |
|
|
|
|
|
|
|
func _ready() -> void: |
|
|
|
var current_slot: Panel = slots_container.get_child(_selected_item) |
|
|
@ -28,29 +28,29 @@ func _ready() -> void: |
|
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void: |
|
|
|
if event.is_action_pressed("quickslot1"): |
|
|
|
select_item_index(0) |
|
|
|
select_quick_slot(0) |
|
|
|
elif event.is_action_pressed("quickslot2"): |
|
|
|
select_item_index(1) |
|
|
|
select_quick_slot(1) |
|
|
|
elif event.is_action_pressed("quickslot3"): |
|
|
|
select_item_index(2) |
|
|
|
select_quick_slot(2) |
|
|
|
elif event.is_action_pressed("quickslot4"): |
|
|
|
select_item_index(3) |
|
|
|
select_quick_slot(3) |
|
|
|
elif event.is_action_pressed("quickslot5"): |
|
|
|
select_item_index(4) |
|
|
|
select_quick_slot(4) |
|
|
|
elif event.is_action_pressed("quickslot6"): |
|
|
|
select_item_index(5) |
|
|
|
select_quick_slot(5) |
|
|
|
elif event.is_action_pressed("quickslot7"): |
|
|
|
select_item_index(6) |
|
|
|
select_quick_slot(6) |
|
|
|
elif event.is_action_pressed("quickslot8"): |
|
|
|
select_item_index(7) |
|
|
|
select_quick_slot(7) |
|
|
|
elif event.is_action_pressed("quickslot9"): |
|
|
|
select_item_index(8) |
|
|
|
elif event.is_action_pressed("quickslot0"): |
|
|
|
select_item_index(9) |
|
|
|
select_quick_slot(8) |
|
|
|
elif event.is_action_pressed("quickslot10"): |
|
|
|
select_quick_slot(9) |
|
|
|
elif event.is_action_pressed("quickslot_next"): |
|
|
|
select_next_item() |
|
|
|
select_quick_slot((_selected_item + 1)) |
|
|
|
elif event.is_action_pressed("quickslot_previous"): |
|
|
|
select_previous_item() |
|
|
|
select_quick_slot((_selected_item - 1)) |
|
|
|
|
|
|
|
|
|
|
|
func get_quickslot_index() -> int: |
|
|
@ -59,22 +59,17 @@ func get_quickslot_index() -> int: |
|
|
|
func get_selected_item() -> String: |
|
|
|
return _items[_selected_item] |
|
|
|
|
|
|
|
func select_item_index(slot_index: int) -> void: |
|
|
|
if slot_index >= _items.size(): return |
|
|
|
|
|
|
|
func select_quick_slot(slot_index: int) -> void: |
|
|
|
_selected_item = slot_index |
|
|
|
update_highlighted_slot() |
|
|
|
InventoryManager.quick_slot_item_changed.emit(get_selected_item()) |
|
|
|
|
|
|
|
func select_previous_item() -> void: |
|
|
|
_selected_item -= 1 |
|
|
|
update_highlighted_slot() |
|
|
|
InventoryManager.quick_slot_item_changed.emit(get_selected_item()) |
|
|
|
select_quick_slot(_selected_item - 1) |
|
|
|
|
|
|
|
func select_next_item() -> void: |
|
|
|
_selected_item += 1 |
|
|
|
update_highlighted_slot() |
|
|
|
InventoryManager.quick_slot_item_changed.emit(get_selected_item()) |
|
|
|
select_quick_slot(_selected_item + 1) |
|
|
|
|
|
|
|
|
|
|
|
func update_highlighted_slot() -> void: |
|
|
|
var previous_slot: Panel = slots_container.get_child(_previous_selected_item) |
|
|
|