feat: allows for the skipping of dialogue after the text is fully visible; still need to look at integrating with user options
This commit is contained in:
committed by
Julian Murgia
parent
886f402395
commit
bd2f28214b
@@ -41,6 +41,7 @@ func has_chooser_type(type: String) -> bool:
|
||||
# - type: Type of dialog box to use
|
||||
func say(dialog_player: Node, global_id: String, text: String, type: String):
|
||||
_dialog_player = dialog_player
|
||||
|
||||
if type == "floating":
|
||||
_type_player = preload(\
|
||||
"res://addons/escoria-dialog-simple/types/floating.tscn"\
|
||||
@@ -51,6 +52,7 @@ func say(dialog_player: Node, global_id: String, text: String, type: String):
|
||||
).instance()
|
||||
|
||||
_type_player.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
||||
_type_player.connect("say_visible", self, "_on_say_visible", [], CONNECT_ONESHOT)
|
||||
|
||||
_dialog_player.add_child(_type_player)
|
||||
_type_player.say(global_id, text)
|
||||
@@ -66,6 +68,10 @@ func _on_say_finished():
|
||||
emit_signal("say_finished")
|
||||
|
||||
|
||||
func _on_say_visible():
|
||||
emit_signal("say_visible")
|
||||
|
||||
|
||||
# Present an option chooser to the player and sends the signal
|
||||
# `option_chosen` with the chosen dialog option
|
||||
#
|
||||
|
||||
@@ -5,6 +5,9 @@ extends Popup
|
||||
# Signal emitted when text has been said
|
||||
signal say_finished
|
||||
|
||||
# Signal emitted when text has just become fully visible
|
||||
signal say_visible
|
||||
|
||||
|
||||
# The text speed per character for normal display
|
||||
var _text_speed_per_character
|
||||
@@ -122,6 +125,7 @@ func _on_dialog_line_typed(object, key):
|
||||
text_node.visible_characters = -1
|
||||
$Timer.start(time_to_disappear)
|
||||
$Timer.connect("timeout", self, "_on_dialog_finished")
|
||||
emit_signal("say_visible")
|
||||
|
||||
|
||||
func _calculate_time_to_disappear() -> float:
|
||||
|
||||
@@ -5,6 +5,9 @@ extends RichTextLabel
|
||||
# Signal emitted when text has been said
|
||||
signal say_finished
|
||||
|
||||
# Signal emitted when text has just become fully visible
|
||||
signal say_visible
|
||||
|
||||
|
||||
# The text speed per character for normal display
|
||||
var _text_speed_per_character
|
||||
@@ -54,6 +57,8 @@ func _ready():
|
||||
bbcode_enabled = true
|
||||
$Tween.connect("tween_completed", self, "_on_dialog_line_typed")
|
||||
|
||||
connect("tree_exiting", self, "_on_tree_exiting")
|
||||
|
||||
escoria.connect("paused", self, "_on_paused")
|
||||
escoria.connect("resumed", self, "_on_resumed")
|
||||
|
||||
@@ -145,6 +150,7 @@ func _on_dialog_line_typed(object, key):
|
||||
text_node.visible_characters = -1
|
||||
$Timer.start(time_to_disappear)
|
||||
$Timer.connect("timeout", self, "_on_dialog_finished")
|
||||
emit_signal("say_visible")
|
||||
|
||||
|
||||
func _calculate_time_to_disappear() -> float:
|
||||
@@ -157,9 +163,7 @@ func _get_number_of_words() -> int:
|
||||
|
||||
# Ending the dialog
|
||||
func _on_dialog_finished():
|
||||
# Make the speaking item animation stop talking, if it is still alive
|
||||
if is_instance_valid(_current_character) and _current_character != null:
|
||||
_current_character.stop_talking()
|
||||
_stop_character_talking()
|
||||
emit_signal("say_finished")
|
||||
|
||||
|
||||
@@ -175,3 +179,14 @@ func _on_resumed():
|
||||
if not tween.is_active():
|
||||
is_paused = false
|
||||
tween.resume_all()
|
||||
|
||||
|
||||
# Handler to deal with this node being removed
|
||||
func _on_tree_exiting() -> void:
|
||||
_stop_character_talking()
|
||||
|
||||
|
||||
func _stop_character_talking():
|
||||
# Make the speaking item animation stop talking, if it is still alive
|
||||
if is_instance_valid(_current_character) and _current_character != null:
|
||||
_current_character.stop_talking()
|
||||
|
||||
Reference in New Issue
Block a user