Skip to content

Commit

Permalink
Add Sorting to Drop Down Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
XavianOgletree committed Sep 28, 2020
1 parent 9114f95 commit cd77a50
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func _on_save_audio_button_pressed() -> void:
if result is GDScriptFunctionState:
yield(result, "completed")

set_progress(i, len(lines))
set_progress(i + 1, len(lines))

set_progress(len(lines), len(lines))
show_message("All files saved!")
Expand Down
2 changes: 2 additions & 0 deletions scripts/apis/GoogleTextToSpeechApi.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extends "res://scripts/apis/TextToSpeechApi.gd"
const SortingUtils = preload("res://scripts/utils/SortingUtils.gd")

func get_voices(
http: HTTPRequest,
Expand All @@ -25,6 +26,7 @@ func get_voices(
if voice.languageCodes[0] == "en-US":
voices.append({name = "%s %s" % [voice.name, voice.ssmlGender], metadata = voice})

voices.sort_custom(SortingUtils, "sort_decending_by_name")
return voices

else:
Expand Down
7 changes: 7 additions & 0 deletions scripts/utils/SortingUtils.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends Reference

static func sort_assending_by_name(a, b):
return a.name > b.name

static func sort_decending_by_name(a,b):
return a.name < b.name

0 comments on commit cd77a50

Please sign in to comment.