@@ -70,6 +70,10 @@ var paused := false:
7070
7171 dialogic_resumed .emit ()
7272
73+ ## A timeline that will be played when dialog ends.
74+ ## By default this timeline only contains a clear event.
75+ var dialog_ending_timeline : DialogicTimeline
76+
7377## Emitted when [member paused] changes to `true`.
7478signal dialogic_paused
7579## Emitted when [member paused] changes to `false`.
@@ -158,6 +162,9 @@ func _ready() -> void:
158162
159163 clear ()
160164
165+ dialog_ending_timeline = DialogicTimeline .new ()
166+ dialog_ending_timeline .from_text ("[clear]" )
167+
161168
162169#region TIMELINE & EVENT HANDLING
163170## ##############################################################################
@@ -242,9 +249,22 @@ func preload_timeline(timeline_resource:Variant) -> Variant:
242249
243250
244251## Clears and stops the current timeline.
245- func end_timeline () -> void :
252+ ## If [param skip_ending] is `true`, the dialog_ending_timeline is not getting played
253+ func end_timeline (skip_ending := false ) -> void :
254+ if not skip_ending and dialog_ending_timeline and current_timeline != dialog_ending_timeline :
255+ start (dialog_ending_timeline )
256+ return
257+
246258 await clear (ClearFlags .TIMELINE_INFO_ONLY )
247- _on_timeline_ended ()
259+
260+ if Styles .has_active_layout_node () and Styles .get_layout_node ().is_inside_tree ():
261+ match ProjectSettings .get_setting ('dialogic/layout/end_behaviour' , 0 ):
262+ 0 :
263+ Styles .get_layout_node ().get_parent ().remove_child (Styles .get_layout_node ())
264+ Styles .get_layout_node ().queue_free ()
265+ 1 :
266+ Styles .get_layout_node ().hide ()
267+
248268 timeline_ended .emit ()
249269
250270
@@ -368,7 +388,7 @@ func load_full_state(state_info:Dictionary) -> void:
368388 if current_state_info .get ('current_timeline' , null ):
369389 start_timeline (current_state_info .current_timeline , current_state_info .get ('current_event_idx' , 0 ))
370390 else :
371- end_timeline .call_deferred ()
391+ end_timeline .call_deferred (true )
372392#endregion
373393
374394
@@ -413,16 +433,6 @@ func add_subsystem(subsystem_name:String, script_path:String) -> DialogicSubsyst
413433#region HELPERS
414434## ##############################################################################
415435
416- ## This handles the `Layout End Behaviour` setting that can be changed in the Dialogic settings.
417- func _on_timeline_ended () -> void :
418- if self .Styles .has_active_layout_node () and self .Styles .get_layout_node ().is_inside_tree ():
419- match ProjectSettings .get_setting ('dialogic/layout/end_behaviour' , 0 ):
420- 0 :
421- self .Styles .get_layout_node ().get_parent ().remove_child (self .Styles .get_layout_node ())
422- self .Styles .get_layout_node ().queue_free ()
423- 1 :
424- @warning_ignore ("unsafe_method_access" )
425- self .Styles .get_layout_node ().hide ()
426436
427437
428438func print_debug_moment () -> void :
0 commit comments