mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-04-22 21:05:33 +00:00
🩹 rename roll to cycle
This commit is contained in:
parent
cd96f3fd0f
commit
a1cc4dbfbd
1 changed files with 12 additions and 8 deletions
|
|
@ -35,9 +35,9 @@ func _unhandled_input(event : InputEvent) -> void:
|
|||
if event is InputEventMouseButton:
|
||||
# @NOTE: there could be a control setting for direction
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
|
||||
roll(1)
|
||||
cycle(1)
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
|
||||
roll(-1)
|
||||
cycle(-1)
|
||||
|
||||
## This method overrides [method Node.add_child] method to make sure not to exceed the inventory capacity
|
||||
func _add_child(node: Node, force_readable_name: bool = false, internal: InternalMode = InternalMode.INTERNAL_MODE_DISABLED) -> void:
|
||||
|
|
@ -46,14 +46,18 @@ func _add_child(node: Node, force_readable_name: bool = false, internal: Interna
|
|||
else:
|
||||
push_warning("inventory is full")
|
||||
|
||||
## The number of places by which the [selected] cursor is shifted in the
|
||||
## inventory. This method affects which item is selected.
|
||||
func roll(shift : int = 1) -> void:
|
||||
var sidx : int = selected.get_index()
|
||||
## This method cycles through the items in the inventory. If an item is already
|
||||
## [member selected], it hides the current item, shifts by the specified number
|
||||
## of items, and shows the new selected item. If no item is selected, it selects
|
||||
## the first item. If the inventory is empty, it displays a warning message.
|
||||
func cycle(shift : int = 1) -> void:
|
||||
var cc : int = get_child_count()
|
||||
if selected:
|
||||
selected.hide()
|
||||
selected = get_child(wrapi(sidx + shift, 0, cc))
|
||||
selected = get_child(wrapi(selected.get_index() + shift, 0, cc))
|
||||
selected.show()
|
||||
elif cc > 0:
|
||||
selected = get_child(0)
|
||||
selected.show()
|
||||
else:
|
||||
push_warning("inventory cursor cannot be rolled as no node is selected")
|
||||
push_warning("inventory is empty")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue