feat: adds option to sync talking animation finishing with either audio or text; if with text, now finishes when text is done rendering.

This commit is contained in:
Duncan Brown
2022-12-02 20:01:34 -05:00
committed by Julian Murgia
parent f64b59621d
commit 13a600598f
6 changed files with 70 additions and 7 deletions

View File

@@ -112,3 +112,9 @@ func interrupt():
_dialog_player.remove_child(_type_player)
emit_signal("say_finished")
# To be called if voice audio has finished.
func voice_audio_finished():
if _type_player != null:
_type_player.voice_audio_finished()

View File

@@ -13,11 +13,15 @@ const TEXT_TIME_PER_LETTER_MS_FAST = "%s/text_time_per_fast_letter_ms" % SETTING
const READING_SPEED_IN_WPM = "%s/reading_speed_in_wpm" % SETTINGS_ROOT
const CLEAR_TEXT_BY_CLICK_ONLY = "%s/clear_text_by_click_only" % SETTINGS_ROOT
const LEFT_CLICK_ACTION = "%s/left_click_action" % SETTINGS_ROOT
const STOP_TALKING_ANIMATION_ON = "%s/stop_talking_animation_on" % SETTINGS_ROOT
const LEFT_CLICK_ACTION_SPEED_UP = "Speed up"
const LEFT_CLICK_ACTION_INSTANT_FINISH = "Instant finish"
const LEFT_CLICK_ACTION_NOTHING = "None"
const STOP_TALKING_ANIMATION_ON_END_OF_TEXT = "End of text"
const STOP_TALKING_ANIMATION_ON_END_OF_AUDIO = "End of audio"
const READING_SPEED_IN_WPM_DEFAULT_VALUE = 200
const TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE = 100
const TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE = 25
@@ -29,6 +33,11 @@ var leftClickActions: Array = [
LEFT_CLICK_ACTION_NOTHING
]
var stopTalkingAnimationOnOptions: Array = [
STOP_TALKING_ANIMATION_ON_END_OF_TEXT,
STOP_TALKING_ANIMATION_ON_END_OF_AUDIO
]
# Override function to return the plugin name.
func get_plugin_name():
@@ -65,6 +74,10 @@ func disable_plugin():
ESCProjectSettingsManager.remove_setting(
LEFT_CLICK_ACTION
)
ESCProjectSettingsManager.remove_setting(
STOP_TALKING_ANIMATION_ON
)
EscoriaPlugin.deregister_dialog_manager(MANAGER_CLASS)
@@ -127,7 +140,7 @@ func enable_plugin():
ESCProjectSettingsManager.register_setting(
LEFT_CLICK_ACTION,
"Speed up",
LEFT_CLICK_ACTION_SPEED_UP,
{
"type": TYPE_STRING,
"hint": PROPERTY_HINT_ENUM,
@@ -135,6 +148,18 @@ func enable_plugin():
}
)
var stopTalkingAnimationOnOptionsString: String = ",".join(stopTalkingAnimationOnOptions)
ESCProjectSettingsManager.register_setting(
STOP_TALKING_ANIMATION_ON,
STOP_TALKING_ANIMATION_ON_END_OF_AUDIO,
{
"type": TYPE_STRING,
"hint": PROPERTY_HINT_ENUM,
"hint_string": stopTalkingAnimationOnOptionsString
}
)
else:
get_editor_interface().set_plugin_enabled(
get_plugin_name(),

View File

@@ -174,9 +174,20 @@ func finish():
tween.start()
# To be called if voice audio has finished.
func voice_audio_finished():
if avatar_node and avatar_node.texture:
avatar_node.texture.current_frame = 0
avatar_node.texture.pause = true
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key):
if avatar_node.texture is AnimatedTexture:
avatar_node.texture.current_frame = 0
avatar_node.texture.pause = true
text_node.visible_characters = -1
var time_to_disappear: float = _calculate_time_to_disappear()
@@ -196,10 +207,6 @@ func _get_number_of_words() -> int:
# Ending the dialog
func _on_dialog_finished():
if avatar_node.texture is AnimatedTexture:
avatar_node.texture.current_frame = 0
avatar_node.texture.pause = true
# Only trigger to clear the text if we aren't limiting the clearing trigger to a click.
if not ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
emit_signal("say_finished")
@@ -218,3 +225,5 @@ func _on_resumed():
if not tween.is_active():
is_paused = false
tween.resume_all()

View File

@@ -198,9 +198,15 @@ func finish():
tween.start()
# To be called if voice audio has finished.
func voice_audio_finished():
_stop_character_talking()
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key):
_stop_character_talking()
text_node.visible_characters = -1
var time_to_disappear: float = _calculate_time_to_disappear()
@@ -220,8 +226,6 @@ func _get_number_of_words() -> int:
# Ending the dialog
func _on_dialog_finished():
_stop_character_talking()
# Only trigger to clear the text if we aren't limiting the clearing trigger to a click.
if not ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
emit_signal("say_finished")