diff --git a/game/area_map/area_map.gd b/game/area_map/area_map.gd index 78a59a6..3a92d03 100644 --- a/game/area_map/area_map.gd +++ b/game/area_map/area_map.gd @@ -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"): diff --git a/game/menu/common/options.gd b/game/menu/common/options.gd index 68f72ce..6f7d840 100644 --- a/game/menu/common/options.gd +++ b/game/menu/common/options.gd @@ -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: diff --git a/game/menu/ingame/pause_menu.gd b/game/menu/ingame/pause_menu.gd index a7a287b..56cc708 100644 --- a/game/menu/ingame/pause_menu.gd +++ b/game/menu/ingame/pause_menu.gd @@ -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 diff --git a/game/menu/ingame/pause_screen.gd b/game/menu/ingame/pause_screen.gd index 87dc885..443db19 100644 --- a/game/menu/ingame/pause_screen.gd +++ b/game/menu/ingame/pause_screen.gd @@ -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: diff --git a/game/menu/ingame/weapon_selection_screen.gd b/game/menu/ingame/weapon_selection_screen.gd index 360bb82..8492d11 100644 --- a/game/menu/ingame/weapon_selection_screen.gd +++ b/game/menu/ingame/weapon_selection_screen.gd @@ -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 diff --git a/game/menu/main/main_menu.gd b/game/menu/main/main_menu.gd index 75ed96c..59761af 100644 --- a/game/menu/main/main_menu.gd +++ b/game/menu/main/main_menu.gd @@ -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 diff --git a/game/menu/main/seed_selection_menu.gd b/game/menu/main/seed_selection_menu.gd index d0e4b3c..2b95d5a 100644 --- a/game/menu/main/seed_selection_menu.gd +++ b/game/menu/main/seed_selection_menu.gd @@ -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) diff --git a/game/menu/main/seed_selection_menu.tscn b/game/menu/main/seed_selection_menu.tscn index 226ac78..cb9775b 100644 --- a/game/menu/main/seed_selection_menu.tscn +++ b/game/menu/main/seed_selection_menu.tscn @@ -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"] diff --git a/game/menu/main/title_screen.gd b/game/menu/main/title_screen.gd index 6eb63b7..e317ec7 100644 --- a/game/menu/main/title_screen.gd +++ b/game/menu/main/title_screen.gd @@ -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: diff --git a/styles/menu_theme.tres b/styles/menu_theme.tres index b901b14..aa6e6bc 100644 --- a/styles/menu_theme.tres +++ b/styles/menu_theme.tres @@ -351,7 +351,7 @@ HSlider/styles/slider = SubResource("StyleBoxTexture_r1n7q") 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/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/normal = SubResource("StyleBoxTexture_muh7f") LineEdit/styles/read_only = SubResource("StyleBoxTexture_rqpqp")