Added menu selection sound
This commit is contained in:
@@ -15,6 +15,29 @@ const WEAPON_SELECTOR = preload("res://game/menu/ingame/weapon_selector.tscn")
|
||||
@onready var weapon_selectors : Control = $%WeaponSelectors
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_left") and _play_left_sound():
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_previous)
|
||||
if event.is_action_pressed("ui_right") and _play_right_sound():
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_next)
|
||||
|
||||
|
||||
func _play_left_sound() -> bool:
|
||||
return _play_side_sound(1, 0)
|
||||
|
||||
|
||||
func _play_right_sound() -> bool:
|
||||
return _play_side_sound(0, 1)
|
||||
|
||||
|
||||
func _play_side_sound(offset_begin: int, offset_end: int) -> bool:
|
||||
for i in range(offset_begin, weapon_selectors.get_child_count() - offset_end):
|
||||
var child := weapon_selectors.get_child(i)
|
||||
if child is WeaponSelector and child.button.has_focus():
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _set_world_data(data: WorldData) -> void:
|
||||
world_data = data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user