Fix: makes dialog players pausable by removing yields (#472)
This commit is contained in:
@@ -49,9 +49,18 @@ func say(dialog_player: Node, global_id: String, text: String, type: String):
|
||||
_type_player = preload(\
|
||||
"res://addons/escoria-dialog-simple/types/avatar.tscn"\
|
||||
).instance()
|
||||
|
||||
_type_player.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
||||
|
||||
_dialog_player.add_child(_type_player)
|
||||
_type_player.say(global_id, text)
|
||||
yield(_type_player, "say_finished")
|
||||
# yield(_type_player, "say_finished")
|
||||
# if _dialog_player.get_children().has(_type_player):
|
||||
# _dialog_player.remove_child(_type_player)
|
||||
# emit_signal("say_finished")
|
||||
|
||||
|
||||
func _on_say_finished():
|
||||
if _dialog_player.get_children().has(_type_player):
|
||||
_dialog_player.remove_child(_type_player)
|
||||
emit_signal("say_finished")
|
||||
@@ -86,3 +95,10 @@ func interrupt():
|
||||
if _dialog_player.get_children().has(_type_player):
|
||||
_dialog_player.remove_child(_type_player)
|
||||
emit_signal("say_finished")
|
||||
|
||||
|
||||
# Getter for the type player
|
||||
#
|
||||
# *Returns* the type player
|
||||
func get_type_player() -> Node:
|
||||
return _type_player
|
||||
|
||||
@@ -29,10 +29,13 @@ onready var text_node = $Panel/MarginContainer/HSplitContainer/text
|
||||
# The tween node for text animations
|
||||
onready var tween = $Panel/MarginContainer/HSplitContainer/text/Tween
|
||||
|
||||
# Whether the dialog manager is paused
|
||||
onready var is_paused: bool = true
|
||||
|
||||
|
||||
|
||||
# Build up the UI
|
||||
func _ready():
|
||||
pause_mode = PAUSE_MODE_STOP
|
||||
_text_speed_per_character = ProjectSettings.get_setting(
|
||||
"escoria/dialog_simple/text_speed_per_character"
|
||||
)
|
||||
@@ -48,6 +51,9 @@ func _ready():
|
||||
self,
|
||||
"_on_dialog_line_typed"
|
||||
)
|
||||
|
||||
escoria.connect("paused", self, "_on_paused")
|
||||
escoria.connect("resumed", self, "_on_resumed")
|
||||
|
||||
|
||||
# Switch the current character
|
||||
@@ -108,3 +114,16 @@ func _on_dialog_finished():
|
||||
emit_signal("say_finished")
|
||||
queue_free()
|
||||
|
||||
|
||||
# Handler managing pause notification from Escoria
|
||||
func _on_paused():
|
||||
if tween.is_active():
|
||||
is_paused = true
|
||||
tween.stop_all()
|
||||
|
||||
|
||||
# Handler managing resume notification from Escoria
|
||||
func _on_resumed():
|
||||
if not tween.is_active():
|
||||
is_paused = false
|
||||
tween.resume_all()
|
||||
|
||||
@@ -29,10 +29,12 @@ onready var tween: Tween = $Tween
|
||||
# The node showing the text
|
||||
onready var text_node: RichTextLabel = self
|
||||
|
||||
# Whether the dialog manager is paused
|
||||
onready var is_paused: bool = true
|
||||
|
||||
|
||||
# Enable bbcode and catch the signal when a tween completed
|
||||
func _ready():
|
||||
pause_mode = PAUSE_MODE_STOP
|
||||
_text_speed_per_character = ProjectSettings.get_setting(
|
||||
"escoria/dialog_simple/text_speed_per_character"
|
||||
)
|
||||
@@ -44,7 +46,10 @@ func _ready():
|
||||
)
|
||||
bbcode_enabled = true
|
||||
$Tween.connect("tween_completed", self, "_on_dialog_line_typed")
|
||||
|
||||
|
||||
escoria.connect("paused", self, "_on_paused")
|
||||
escoria.connect("resumed", self, "_on_resumed")
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if _current_character.is_inside_tree() and \
|
||||
@@ -140,3 +145,17 @@ func _on_dialog_finished():
|
||||
if is_instance_valid(_current_character) and _current_character != null:
|
||||
_current_character.stop_talking()
|
||||
emit_signal("say_finished")
|
||||
|
||||
|
||||
# Handler managing pause notification from Escoria
|
||||
func _on_paused():
|
||||
if tween.is_active():
|
||||
is_paused = true
|
||||
tween.stop_all()
|
||||
|
||||
|
||||
# Handler managing resume notification from Escoria
|
||||
func _on_resumed():
|
||||
if not tween.is_active():
|
||||
is_paused = false
|
||||
tween.resume_all()
|
||||
|
||||
@@ -13,7 +13,6 @@ script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
text_speed_per_character = 0.0
|
||||
|
||||
[node name="Tween" type="Tween" parent="."]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user