From 948a861970b45a3dec76f3a3860134d4f5a18df1 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner <42868150+Jowan-Spooner@users.noreply.github.com> Date: Tue, 31 Oct 2023 11:35:46 +0100 Subject: [PATCH] Fixes for TypingSounds (#1848) * Make sure typing sound resets on text without character - fixes #1842 * Fix #1834 The load_typing_sounds method will now always list imported audio files only and correctly load them when exported. --- addons/dialogic/Modules/Text/event_text.gd | 1 + addons/dialogic/Modules/Text/node_type_sound.gd | 8 +++++--- addons/dialogic/Other/DialogicUtil.gd | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/dialogic/Modules/Text/event_text.gd b/addons/dialogic/Modules/Text/event_text.gd index b04764edf..15a6a8cfd 100644 --- a/addons/dialogic/Modules/Text/event_text.gd +++ b/addons/dialogic/Modules/Text/event_text.gd @@ -82,6 +82,7 @@ func _execute() -> void: else: dialogic.Portraits.change_speaker(null) dialogic.Text.update_name_label(null) + dialogic.Text.update_typing_sound_mood() if not dialogic.Text.input_handler.dialogic_action.is_connected(_on_dialogic_input_action): dialogic.Text.input_handler.dialogic_action.connect(_on_dialogic_input_action) diff --git a/addons/dialogic/Modules/Text/node_type_sound.gd b/addons/dialogic/Modules/Text/node_type_sound.gd index db807bd7d..685245a8c 100644 --- a/addons/dialogic/Modules/Text/node_type_sound.gd +++ b/addons/dialogic/Modules/Text/node_type_sound.gd @@ -111,9 +111,11 @@ static func load_sounds_from_path(path:String) -> Array[AudioStream]: if path.get_extension().to_lower() in ['mp3', 'wav', 'ogg'] and load(path) is AudioStream: return [load(path)] var _sounds :Array[AudioStream]= [] - for file in DialogicUtil.listdir(path, true, false, true): - if file.get_extension().to_lower() in ['mp3', 'wav', 'ogg'] and load(file) is AudioStream: - _sounds.append(load(file)) + for file:String in DialogicUtil.listdir(path, true, false, true, true): + if !file.ends_with('.import'): + continue + if file.trim_suffix('.import').get_extension().to_lower() in ['mp3', 'wav', 'ogg'] and ResourceLoader.load(file.trim_suffix('.import')) is AudioStream: + _sounds.append(ResourceLoader.load(file.trim_suffix('.import'))) return _sounds diff --git a/addons/dialogic/Other/DialogicUtil.gd b/addons/dialogic/Other/DialogicUtil.gd index 58f7f946b..c86eb25dc 100644 --- a/addons/dialogic/Other/DialogicUtil.gd +++ b/addons/dialogic/Other/DialogicUtil.gd @@ -26,7 +26,7 @@ static func get_dialogic_plugin() -> Node: ################################################################################ ## FILE SYSTEM ################################################################################ -static func listdir(path: String, files_only: bool = true, throw_error:bool = true, full_file_path:bool = false) -> Array: +static func listdir(path: String, files_only: bool = true, throw_error:bool = true, full_file_path:bool = false, include_imports := false) -> Array: var files: Array = [] if path.is_empty(): path = "res://" if DirAccess.dir_exists_absolute(path): @@ -36,7 +36,7 @@ static func listdir(path: String, files_only: bool = true, throw_error:bool = tr while file_name != "": if not file_name.begins_with("."): if files_only: - if not dir.current_is_dir() and not file_name.ends_with('.import'): + if not dir.current_is_dir() and (not file_name.ends_with('.import') or include_imports): if full_file_path: files.append(path.path_join(file_name)) else: