Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Signal text_started that aligns with the text appearing #2523

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Snowdrama
Copy link

The await on line 124 can take some time depending on if the textbox fades in or has an animation when opening, and because of that the about_to_show_text signal has a delay before the text begins to render.

Delay from before the await to after the await measured by Time.get_ticks_msec()
image

dialogic.Text.about_to_show_text.emit({'text':final_text, 'character':character, 'portrait':portrait, 'append': is_append})

print("About to await dialogic.Text.update_textbox %s" % Time.get_ticks_msec())
await dialogic.Text.update_textbox(final_text, false)
print("Done Awaiting dialogic.Text.update_textbox %s" % Time.get_ticks_msec())

If you use about_to_show_text to enable an animation, as an example for lip flaps, the delay makes it look awkward because mouth begins moving before the text begins rendering. This PR adds a signal after the await so that it's closer to when the text starts rendering.

Here's an example where I swap between a normal mouth to an AnimatedSprite2D for the character to talk:

extends Node2D

#this goes on the group in a custom layered character scene that has the mouth

@export var normal_sprite : Sprite2D
@export var talking_sprite : AnimatedSprite2D

func _ready():
	Dialogic.Text.about_to_show_text.connect(start_talking)
	# The text_started signal is a drop in replacement that feels much better for things
	# That need to respond to the text being drawn
	# Dialogic.Text.text_started.connect(start_talking)
	Dialogic.Text.text_finished.connect(stop_talking)
	
func start_talking(info:Dictionary):
	normal_sprite.visible = false
	talking_sprite.visible = true
	
func stop_talking(info:Dictionary):
	normal_sprite.visible = true
	talking_sprite.visible = false

I saw while I was researching there was similar methods to this that may have been in previous versions like started_revealing_text but those seem to have been removed or something.

@Jowan-Spooner
Copy link
Member

I like this, though we really need to improve the documentation on all those signals, cause now the names alone are a bit confusing.

@Snowdrama
Copy link
Author

I like this, though we really need to improve the documentation on all those signals, cause now the names alone are a bit confusing.

I definitely can understand, the about_to_show_text signal is a bit confusing for sure because if the text window isn't open that await means it's like "preparing to show text" while revealing the textbox. The second time it's called though the text box is already open so it more correctly corresponds to the text appearing, definitely unintuitive.

I can definitely look at updating the signal documentation with descriptions to help clarify the difference in the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants