Added menu selection sound
This commit is contained in:
@@ -87,15 +87,19 @@ func _input(event: InputEvent) -> void:
|
||||
if not visible: return
|
||||
|
||||
if event.is_action_pressed("ui_left") and selected_sector.sector_to_left:
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_previous)
|
||||
_set_selected_sector(selected_sector.sector_to_left)
|
||||
|
||||
if event.is_action_pressed("ui_right") and selected_sector.sector_to_right:
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_next)
|
||||
_set_selected_sector(selected_sector.sector_to_right)
|
||||
|
||||
if event.is_action_pressed("ui_up") and selected_sector.sector_above:
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_previous)
|
||||
_set_selected_sector(selected_sector.sector_above)
|
||||
|
||||
if event.is_action_pressed("ui_down") and selected_sector.sector_below:
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_next)
|
||||
_set_selected_sector(selected_sector.sector_below)
|
||||
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
|
||||
@@ -23,6 +23,33 @@ func _ready() -> void:
|
||||
_setup_neighbors()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_up") and not fullscreen_button.has_focus():
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_previous)
|
||||
if event.is_action_pressed("ui_down") and not back_button.has_focus():
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_next)
|
||||
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, window_factor_buttons.get_child_count() - offset_end):
|
||||
var child := window_factor_buttons.get_child(i)
|
||||
if child is Button and child.has_focus():
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _connect_window_factor_buttons() -> void:
|
||||
for child in window_factor_buttons.get_children():
|
||||
if child is Button:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ func _ready() -> void:
|
||||
_update_continue_button()
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -11,6 +11,8 @@ const DEFAULT_SEED_LENGTH := 16
|
||||
|
||||
var _seed_regex := RegEx.new()
|
||||
|
||||
var _old_custom_seed_length := -1
|
||||
|
||||
|
||||
@onready var random_edit : LineEdit = $%RandomEdit
|
||||
@onready var custom_edit : LineEdit = $%CustomEdit
|
||||
@@ -18,12 +20,49 @@ var _seed_regex := RegEx.new()
|
||||
@onready var use_random_button : Button = $%UseRandomButton
|
||||
@onready var use_custom_button : Button = $%UseCustomButton
|
||||
|
||||
@onready var back_button : Button = $%BackButton
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
var regex_pattern := "[%s]+" % SEED_CHARS
|
||||
_seed_regex.compile(regex_pattern)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_up") and _play_up_sound():
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_previous)
|
||||
if event.is_action_pressed("ui_down") and _play_down_sound():
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_next)
|
||||
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_up_sound() -> bool:
|
||||
match get_viewport().gui_get_focus_owner():
|
||||
use_custom_button, custom_edit, back_button: return true
|
||||
return false
|
||||
|
||||
|
||||
func _play_down_sound() -> bool:
|
||||
match get_viewport().gui_get_focus_owner():
|
||||
use_random_button, use_custom_button, custom_edit: return true
|
||||
return false
|
||||
|
||||
|
||||
func _play_left_sound() -> bool:
|
||||
match get_viewport().gui_get_focus_owner():
|
||||
use_random_button, use_custom_button, back_button: return true
|
||||
return false
|
||||
|
||||
|
||||
func _play_right_sound() -> bool:
|
||||
match get_viewport().gui_get_focus_owner():
|
||||
custom_edit: return true
|
||||
return false
|
||||
|
||||
|
||||
func _update_use_custom_button() -> void:
|
||||
var disabled := custom_edit.text.is_empty()
|
||||
use_custom_button.disabled = disabled
|
||||
@@ -62,6 +101,13 @@ func _on_seed_edit_text_changed(new_text: String) -> void:
|
||||
var caret_position := custom_edit.caret_column
|
||||
custom_edit.text = filtered_text
|
||||
custom_edit.caret_column = min(caret_position, filtered_text.length())
|
||||
|
||||
if _old_custom_seed_length < custom_edit.text.length():
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_next)
|
||||
elif _old_custom_seed_length > custom_edit.text.length():
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_previous)
|
||||
|
||||
_old_custom_seed_length = custom_edit.text.length()
|
||||
|
||||
_update_use_custom_button()
|
||||
|
||||
@@ -94,3 +140,7 @@ func _on_use_random_button_pressed() -> void:
|
||||
func _on_use_custom_button_pressed() -> void:
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_accept)
|
||||
_start_game(custom_edit.text)
|
||||
|
||||
|
||||
func _on_custom_edit_editing_toggled(_toggled_on: bool) -> void:
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_accept)
|
||||
|
||||
@@ -82,6 +82,7 @@ text = "Main menu"
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||
[connection signal="pressed" from="GridContainer/UseRandomButton" to="." method="_on_use_random_button_pressed"]
|
||||
[connection signal="editing_toggled" from="GridContainer/CustomEdit" to="." method="_on_custom_edit_editing_toggled"]
|
||||
[connection signal="text_changed" from="GridContainer/CustomEdit" to="." method="_on_seed_edit_text_changed"]
|
||||
[connection signal="text_submitted" from="GridContainer/CustomEdit" to="." method="_on_seed_edit_text_submitted"]
|
||||
[connection signal="pressed" from="GridContainer/UseCustomButton" to="." method="_on_use_custom_button_pressed"]
|
||||
|
||||
@@ -17,8 +17,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_main_menu_continue_game() -> void:
|
||||
|
||||
Reference in New Issue
Block a user