Added menu selection sound
This commit is contained in:
@@ -87,15 +87,19 @@ func _input(event: InputEvent) -> void:
|
|||||||
if not visible: return
|
if not visible: return
|
||||||
|
|
||||||
if event.is_action_pressed("ui_left") and selected_sector.sector_to_left:
|
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)
|
_set_selected_sector(selected_sector.sector_to_left)
|
||||||
|
|
||||||
if event.is_action_pressed("ui_right") and selected_sector.sector_to_right:
|
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)
|
_set_selected_sector(selected_sector.sector_to_right)
|
||||||
|
|
||||||
if event.is_action_pressed("ui_up") and selected_sector.sector_above:
|
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)
|
_set_selected_sector(selected_sector.sector_above)
|
||||||
|
|
||||||
if event.is_action_pressed("ui_down") and selected_sector.sector_below:
|
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)
|
_set_selected_sector(selected_sector.sector_below)
|
||||||
|
|
||||||
if event.is_action_pressed("ui_accept"):
|
if event.is_action_pressed("ui_accept"):
|
||||||
|
|||||||
@@ -23,6 +23,33 @@ func _ready() -> void:
|
|||||||
_setup_neighbors()
|
_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:
|
func _connect_window_factor_buttons() -> void:
|
||||||
for child in window_factor_buttons.get_children():
|
for child in window_factor_buttons.get_children():
|
||||||
if child is Button:
|
if child is Button:
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ func _ready() -> void:
|
|||||||
_setup_neighbors()
|
_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:
|
func _on_visibility_changed() -> void:
|
||||||
if not is_node_ready(): return
|
if not is_node_ready(): return
|
||||||
if not visible: return
|
if not visible: return
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ func _show_menu(menu: Control) -> void:
|
|||||||
|
|
||||||
for m in menus:
|
for m in menus:
|
||||||
m.hide()
|
m.hide()
|
||||||
|
m.set_process_input(false)
|
||||||
|
|
||||||
menu.show()
|
menu.show()
|
||||||
|
menu.set_process_input(true)
|
||||||
|
|
||||||
|
|
||||||
func _on_pause_menu_continue_game() -> void:
|
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
|
@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:
|
func _set_world_data(data: WorldData) -> void:
|
||||||
world_data = data
|
world_data = data
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ func _ready() -> void:
|
|||||||
_update_continue_button()
|
_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:
|
func _on_visibility_changed() -> void:
|
||||||
if not is_node_ready(): return
|
if not is_node_ready(): return
|
||||||
if not visible: return
|
if not visible: return
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ const DEFAULT_SEED_LENGTH := 16
|
|||||||
|
|
||||||
var _seed_regex := RegEx.new()
|
var _seed_regex := RegEx.new()
|
||||||
|
|
||||||
|
var _old_custom_seed_length := -1
|
||||||
|
|
||||||
|
|
||||||
@onready var random_edit : LineEdit = $%RandomEdit
|
@onready var random_edit : LineEdit = $%RandomEdit
|
||||||
@onready var custom_edit : LineEdit = $%CustomEdit
|
@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_random_button : Button = $%UseRandomButton
|
||||||
@onready var use_custom_button : Button = $%UseCustomButton
|
@onready var use_custom_button : Button = $%UseCustomButton
|
||||||
|
|
||||||
|
@onready var back_button : Button = $%BackButton
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
var regex_pattern := "[%s]+" % SEED_CHARS
|
var regex_pattern := "[%s]+" % SEED_CHARS
|
||||||
_seed_regex.compile(regex_pattern)
|
_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:
|
func _update_use_custom_button() -> void:
|
||||||
var disabled := custom_edit.text.is_empty()
|
var disabled := custom_edit.text.is_empty()
|
||||||
use_custom_button.disabled = disabled
|
use_custom_button.disabled = disabled
|
||||||
@@ -63,6 +102,13 @@ func _on_seed_edit_text_changed(new_text: String) -> void:
|
|||||||
custom_edit.text = filtered_text
|
custom_edit.text = filtered_text
|
||||||
custom_edit.caret_column = min(caret_position, filtered_text.length())
|
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()
|
_update_use_custom_button()
|
||||||
|
|
||||||
|
|
||||||
@@ -94,3 +140,7 @@ func _on_use_random_button_pressed() -> void:
|
|||||||
func _on_use_custom_button_pressed() -> void:
|
func _on_use_custom_button_pressed() -> void:
|
||||||
SoundManager.play_ui_stream(SoundManager.ui_stream_accept)
|
SoundManager.play_ui_stream(SoundManager.ui_stream_accept)
|
||||||
_start_game(custom_edit.text)
|
_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="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||||
[connection signal="pressed" from="GridContainer/UseRandomButton" to="." method="_on_use_random_button_pressed"]
|
[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_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="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"]
|
[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:
|
for m in menus:
|
||||||
m.hide()
|
m.hide()
|
||||||
|
m.set_process_input(false)
|
||||||
|
|
||||||
menu.show()
|
menu.show()
|
||||||
|
menu.set_process_input(true)
|
||||||
|
|
||||||
|
|
||||||
func _on_main_menu_continue_game() -> void:
|
func _on_main_menu_continue_game() -> void:
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ HSlider/styles/slider = SubResource("StyleBoxTexture_r1n7q")
|
|||||||
Label/colors/font_color = Color(0.95686275, 0.95686275, 0.95686275, 1)
|
Label/colors/font_color = Color(0.95686275, 0.95686275, 0.95686275, 1)
|
||||||
LineEdit/colors/caret_color = Color(0.2, 0.23529412, 0.34117648, 1)
|
LineEdit/colors/caret_color = Color(0.2, 0.23529412, 0.34117648, 1)
|
||||||
LineEdit/colors/font_color = Color(0.14509805, 0.44313726, 0.4745098, 1)
|
LineEdit/colors/font_color = Color(0.14509805, 0.44313726, 0.4745098, 1)
|
||||||
LineEdit/colors/font_placeholder_color = Color(0.2, 0.23529412, 0.34117648, 1)
|
LineEdit/colors/font_placeholder_color = Color(0.5803922, 0.6901961, 0.7607843, 1)
|
||||||
LineEdit/styles/focus = SubResource("StyleBoxTexture_6ro36")
|
LineEdit/styles/focus = SubResource("StyleBoxTexture_6ro36")
|
||||||
LineEdit/styles/normal = SubResource("StyleBoxTexture_muh7f")
|
LineEdit/styles/normal = SubResource("StyleBoxTexture_muh7f")
|
||||||
LineEdit/styles/read_only = SubResource("StyleBoxTexture_rqpqp")
|
LineEdit/styles/read_only = SubResource("StyleBoxTexture_rqpqp")
|
||||||
|
|||||||
Reference in New Issue
Block a user