Added menu selection sound

This commit is contained in:
2025-12-26 11:47:09 +03:00
parent a7aeacd547
commit 099cda6368
10 changed files with 124 additions and 1 deletions
+7
View File
@@ -15,6 +15,13 @@ func _ready() -> void:
_setup_neighbors()
func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_up"):
SoundManager.play_ui_stream(SoundManager.ui_stream_previous)
if event.is_action_pressed("ui_down"):
SoundManager.play_ui_stream(SoundManager.ui_stream_next)
func _on_visibility_changed() -> void:
if not is_node_ready(): return
if not visible: return
+2
View File
@@ -24,8 +24,10 @@ func _show_menu(menu: Control) -> void:
for m in menus:
m.hide()
m.set_process_input(false)
menu.show()
menu.set_process_input(true)
func _on_pause_menu_continue_game() -> void:
@@ -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