Skip to content

Commit

Permalink
Fixes for TypingSounds (#1848)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Jowan-Spooner authored Oct 31, 2023
1 parent 7cfbd1b commit 948a861
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions addons/dialogic/Modules/Text/event_text.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions addons/dialogic/Modules/Text/node_type_sound.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions addons/dialogic/Other/DialogicUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit 948a861

Please sign in to comment.