Skip to content

Commit 5d96384

Browse files
Feature: Play from here (#2535)
* Implement play from here Adds a play from here option to the right click menu both in the visual editor and the text editor. The action can also be triggered with Ctrl+F6 or Ctrl+Shift+B on macOS. Those shortcuts have been added to the shortcut cheat sheet. The text editor thing required a new method on the timeline resource that I'm not super pleased with, but it works. It works by keeping an index of all the lines and the event index they end at. I hope this doesn't have a big impact on timeline processing, but I don't think it should. * Fix text event doc link --------- Co-authored-by: Pasquale J Crea <pasquale@firedfromlife.com>
1 parent 64b1cf0 commit 5d96384

File tree

11 files changed

+120
-68
lines changed

11 files changed

+120
-68
lines changed

addons/dialogic/Core/DialogicGameHandler.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ func _ready() -> void:
165165
## Method to start a timeline AND ensure that a layout scene is present.
166166
## For argument info, checkout [method start_timeline].
167167
## -> returns the layout node
168-
func start(timeline:Variant, label:Variant="") -> Node:
168+
func start(timeline:Variant, label_or_idx:Variant="") -> Node:
169169
# If we don't have a style subsystem, default to just start_timeline()
170170
if not has_subsystem('Styles'):
171171
printerr("[Dialogic] You called Dialogic.start() but the Styles subsystem is missing!")
172172
clear(ClearFlags.KEEP_VARIABLES)
173-
start_timeline(timeline, label)
173+
start_timeline(timeline, label_or_idx)
174174
return null
175175

176176
# Otherwise make sure there is a style active.
@@ -183,9 +183,9 @@ func start(timeline:Variant, label:Variant="") -> Node:
183183

184184
if not scene.is_node_ready():
185185
scene.ready.connect(clear.bind(ClearFlags.KEEP_VARIABLES))
186-
scene.ready.connect(start_timeline.bind(timeline, label))
186+
scene.ready.connect(start_timeline.bind(timeline, label_or_idx))
187187
else:
188-
start_timeline(timeline, label)
188+
start_timeline(timeline, label_or_idx)
189189

190190
return scene
191191

addons/dialogic/Editor/Events/EventBlock/event_right_click_menu.gd

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ var current_event: Node = null
55

66
func _ready() -> void:
77
clear()
8-
add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), "Duplicate")
8+
add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), "Duplicate", 0)
99
add_separator()
10-
add_icon_item(get_theme_icon("Help", "EditorIcons"), "Documentation")
11-
add_icon_item(get_theme_icon("CodeHighlighter", "EditorIcons"), "Open Code")
10+
add_icon_item(get_theme_icon("PlayStart", "EditorIcons"), "Play from here", 1)
1211
add_separator()
13-
add_icon_item(get_theme_icon("ArrowUp", "EditorIcons"), "Move up")
14-
add_icon_item(get_theme_icon("ArrowDown", "EditorIcons"), "Move down")
12+
add_icon_item(get_theme_icon("Help", "EditorIcons"), "Documentation", 2)
13+
add_icon_item(get_theme_icon("CodeHighlighter", "EditorIcons"), "Open Code", 3)
1514
add_separator()
16-
add_icon_item(get_theme_icon("Remove", "EditorIcons"), "Delete")
15+
add_icon_item(get_theme_icon("ArrowUp", "EditorIcons"), "Move up", 4)
16+
add_icon_item(get_theme_icon("ArrowDown", "EditorIcons"), "Move down", 5)
17+
add_separator()
18+
add_icon_item(get_theme_icon("Remove", "EditorIcons"), "Delete", 6)
1719

1820
var menu_background := StyleBoxFlat.new()
1921
menu_background.bg_color = get_parent().get_theme_color("base_color", "Editor")

addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ func _ready() -> void:
1414
syntax_highlighter = code_completion_helper.syntax_highlighter
1515
timeline_editor.editors_manager.sidebar.content_item_activated.connect(_on_content_item_clicked)
1616

17+
get_menu().add_icon_item(get_theme_icon("PlayStart", "EditorIcons"), "Play from here", 42)
18+
get_menu().id_pressed.connect(_on_context_menu_id_pressed)
19+
1720

1821
func _on_text_editor_text_changed() -> void:
1922
timeline_editor.current_resource_state = DialogicEditor.ResourceStates.UNSAVED
@@ -73,6 +76,15 @@ func text_timeline_to_array(text:String) -> Array:
7376
## HELPFUL EDITOR FUNCTIONALITY
7477
################################################################################
7578

79+
func _on_context_menu_id_pressed(id:int) -> void:
80+
if id == 42:
81+
play_from_here()
82+
83+
84+
func play_from_here() -> void:
85+
timeline_editor.play_timeline(timeline_editor.current_resource.get_index_from_text_line(text, get_caret_line()))
86+
87+
7688
func _gui_input(event):
7789
if not event is InputEventKey: return
7890
if not event.is_pressed(): return
@@ -90,6 +102,11 @@ func _gui_input(event):
90102

91103
"Ctrl+Shift+D", "Ctrl+D":
92104
duplicate_lines()
105+
106+
"Ctrl+F6" when OS.get_name() != "macOS": # Play from here
107+
play_from_here()
108+
"Ctrl+Shift+B" when OS.get_name() == "macOS": # Play from here
109+
play_from_here()
93110
_:
94111
return
95112
get_viewport().set_input_as_handled()

addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -938,25 +938,30 @@ func indent_events() -> void:
938938
#region SPECIAL BLOCK OPERATIONS
939939
################################################################################
940940

941-
func _on_event_popup_menu_index_pressed(index:int) -> void:
941+
func _on_event_popup_menu_id_pressed(id:int) -> void:
942942
var item: Control = %EventPopupMenu.current_event
943-
if index == 0:
943+
if id == 0:
944944
if not item in selected_items:
945945
selected_items = [item]
946946
duplicate_selected()
947-
elif index == 2:
947+
948+
elif id == 1:
949+
play_from_here(%EventPopupMenu.current_event.get_index())
950+
951+
elif id == 2:
948952
if not item.resource.help_page_path.is_empty():
949953
OS.shell_open(item.resource.help_page_path)
950-
elif index == 3:
954+
955+
elif id == 3:
951956
find_parent('EditorView').plugin_reference.get_editor_interface().set_main_screen_editor('Script')
952957
find_parent('EditorView').plugin_reference.get_editor_interface().edit_script(item.resource.get_script(), 1, 1)
953-
elif index == 5 or index == 6:
954-
if index == 5:
958+
elif id == 4 or id == 5:
959+
if id == 4:
955960
offset_blocks_by_index(selected_items, -1)
956961
else:
957962
offset_blocks_by_index(selected_items, +1)
958963

959-
elif index == 8:
964+
elif id == 6:
960965
var events_indexed : Dictionary
961966
if item in selected_items:
962967
events_indexed = get_events_indexed(selected_items)
@@ -969,6 +974,12 @@ func _on_event_popup_menu_index_pressed(index:int) -> void:
969974
indent_events()
970975

971976

977+
func play_from_here(index:=-1) -> void:
978+
if index == -1:
979+
if not selected_items.is_empty():
980+
index = selected_items[0].get_index()
981+
timeline_editor.play_timeline(index)
982+
972983
func _on_right_sidebar_resized() -> void:
973984
var _scale := DialogicUtil.get_editor_scale()
974985

@@ -1078,6 +1089,11 @@ func _input(event:InputEvent) -> void:
10781089
_add_event_button_pressed(DialogicLabelEvent.new(), true)
10791090
get_viewport().set_input_as_handled()
10801091

1092+
"Ctrl+F6" when OS.get_name() != "macOS": # Play from here
1093+
play_from_here()
1094+
"Ctrl+Shift+B" when OS.get_name() == "macOS": # Play from here
1095+
play_from_here()
1096+
10811097
## Some shortcuts should be disabled when writing text.
10821098
var focus_owner: Control = get_viewport().gui_get_focus_owner()
10831099
if focus_owner is TextEdit or focus_owner is LineEdit or (focus_owner is Button and focus_owner.get_parent_control().name == "Spin"):

addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.tscn

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
[ext_resource type="Script" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd" id="1_8smxc"]
44
[ext_resource type="Theme" uid="uid://cqst728xxipcw" path="res://addons/dialogic/Editor/Theme/MainTheme.tres" id="2_x0fhp"]
5-
[ext_resource type="Script" uid="uid://bigjdicunph7y" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/TimelineArea.gd" id="3_sap1x"]
5+
[ext_resource type="Script" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/TimelineArea.gd" id="3_sap1x"]
66
[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/EventBlock/event_right_click_menu.gd" id="4_ugiq6"]
77

88
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_phyjj"]
99
content_margin_top = 10.0
1010

11-
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qtla0"]
11+
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_6gqu8"]
1212
bg_color = Color(0, 0, 0, 1)
1313

14-
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3omuv"]
14+
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jujwh"]
1515
content_margin_left = 4.0
1616
content_margin_top = 4.0
1717
content_margin_right = 4.0
@@ -24,7 +24,7 @@ border_width_right = 2
2424
border_width_bottom = 2
2525
corner_detail = 1
2626

27-
[sub_resource type="Image" id="Image_6gdod"]
27+
[sub_resource type="Image" id="Image_h7ek6"]
2828
data = {
2929
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
3030
"format": "RGBA8",
@@ -33,8 +33,8 @@ data = {
3333
"width": 16
3434
}
3535

36-
[sub_resource type="ImageTexture" id="ImageTexture_brv5s"]
37-
image = SubResource("Image_6gdod")
36+
[sub_resource type="ImageTexture" id="ImageTexture_xe7d2"]
37+
image = SubResource("Image_h7ek6")
3838

3939
[node name="TimelineVisualEditor" type="MarginContainer"]
4040
anchors_preset = 15
@@ -70,31 +70,31 @@ size_flags_vertical = 3
7070
[node name="EventPopupMenu" type="PopupMenu" parent="View/TimelineArea"]
7171
unique_name_in_owner = true
7272
size = Vector2i(165, 124)
73-
theme_override_styles/panel = SubResource("StyleBoxFlat_qtla0")
74-
theme_override_styles/hover = SubResource("StyleBoxFlat_3omuv")
73+
theme_override_styles/panel = SubResource("StyleBoxFlat_6gqu8")
74+
theme_override_styles/hover = SubResource("StyleBoxFlat_jujwh")
7575
item_count = 9
7676
item_0/text = "Duplicate"
77-
item_0/icon = SubResource("ImageTexture_brv5s")
77+
item_0/icon = SubResource("ImageTexture_xe7d2")
7878
item_1/id = -1
7979
item_1/separator = true
8080
item_2/text = "Documentation"
81-
item_2/icon = SubResource("ImageTexture_brv5s")
81+
item_2/icon = SubResource("ImageTexture_xe7d2")
8282
item_2/id = 2
8383
item_3/text = "Open Code"
84-
item_3/icon = SubResource("ImageTexture_brv5s")
84+
item_3/icon = SubResource("ImageTexture_xe7d2")
8585
item_3/id = 3
8686
item_4/id = -1
8787
item_4/separator = true
8888
item_5/text = "Move up"
89-
item_5/icon = SubResource("ImageTexture_brv5s")
89+
item_5/icon = SubResource("ImageTexture_xe7d2")
9090
item_5/id = 5
9191
item_6/text = "Move down"
92-
item_6/icon = SubResource("ImageTexture_brv5s")
92+
item_6/icon = SubResource("ImageTexture_xe7d2")
9393
item_6/id = 6
9494
item_7/id = -1
9595
item_7/separator = true
9696
item_8/text = "Delete"
97-
item_8/icon = SubResource("ImageTexture_brv5s")
97+
item_8/icon = SubResource("ImageTexture_xe7d2")
9898
item_8/id = 8
9999
script = ExtResource("4_ugiq6")
100100

@@ -112,5 +112,5 @@ size_flags_vertical = 3
112112
size_flags_stretch_ratio = 0.2
113113

114114
[connection signal="drag_completed" from="View/TimelineArea" to="." method="_on_timeline_area_drag_completed"]
115-
[connection signal="index_pressed" from="View/TimelineArea/EventPopupMenu" to="." method="_on_event_popup_menu_index_pressed"]
115+
[connection signal="id_pressed" from="View/TimelineArea/EventPopupMenu" to="." method="_on_event_popup_menu_id_pressed"]
116116
[connection signal="resized" from="View/RightSidebar" to="." method="_on_right_sidebar_resized"]

addons/dialogic/Editor/TimelineEditor/shortcut_popup.gd

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ var shortcuts := [
1717
{"shortcut":"Alt/Opt+Down", "text":"Move selected events/lines down"},
1818
{},
1919
{"shortcut":"Ctrl+F", "text":"Search"},
20+
{},
21+
{"shortcut":"Ctrl+F5", "text":"Play timeline", "platform":"-macOS"},
22+
{"shortcut":"Ctrl+B", "text":"Play timeline", "platform":"macOS"},
23+
{"shortcut":"Ctrl+F6", "text":"Play timeline from here", "platform":"-macOS"},
24+
{"shortcut":"Ctrl+Shift+B", "text":"Play timeline from here", "platform":"macOS"},
2025

2126
{},
2227
{"shortcut":"Ctrl+C", "text":"Copy"},
@@ -42,20 +47,26 @@ func _ready() -> void:
4247
%CloseShortcutPanel.icon = get_theme_icon("Close", "EditorIcons")
4348
get_theme_stylebox("panel").bg_color = get_theme_color("dark_color_3", "Editor")
4449

50+
4551
func reload_shortcuts() -> void:
4652
for i in %ShortcutList.get_children():
4753
i.queue_free()
4854

49-
5055
var is_text_editor: bool = %TextEditor.visible
5156
for i in shortcuts:
5257
if i.is_empty():
5358
%ShortcutList.add_child(HSeparator.new())
5459
%ShortcutList.add_child(HSeparator.new())
5560
continue
61+
5662
if "editor" in i and not get_node("%"+i.editor).visible:
5763
continue
5864

65+
if "platform" in i:
66+
var platform := OS.get_name()
67+
if not (platform == i.platform.trim_prefix("-") != i.platform.begins_with("-")):
68+
continue
69+
5970
var hbox := HBoxContainer.new()
6071
hbox.add_theme_constant_override("separation", 0)
6172
for key_text in i.shortcut.split("+"):
@@ -64,17 +75,17 @@ func reload_shortcuts() -> void:
6475
plus_l.text = "+"
6576
hbox.add_child(plus_l)
6677

67-
68-
6978
var key := Button.new()
7079
if key_text == "Up":
7180
key.icon = get_theme_icon("ArrowUp", "EditorIcons")
7281
elif key_text == "Down":
7382
key.icon = get_theme_icon("ArrowDown", "EditorIcons")
7483
else:
84+
key_text = key_text.replace("Alt/Opt", "Opt" if OS.get_name() == "macOS" else "Alt")
7585
key.text = key_text
7686
key.disabled = true
7787
key.theme_type_variation = "ShortcutKeyLabel"
88+
key.add_theme_font_override("font", get_theme_font("source", "EditorFonts"))
7889
hbox.add_child(key)
7990

8091
%ShortcutList.add_child(hbox)
@@ -89,12 +100,13 @@ func open():
89100
if visible:
90101
close()
91102
return
92-
93103
reload_shortcuts()
94104

95105
show()
96-
size = get_parent().size - Vector2(200, 200)*DialogicUtil.get_editor_scale()
106+
await get_tree().process_frame
107+
size = get_parent().size - Vector2(100, 100)*DialogicUtil.get_editor_scale()
97108
size.x = %ShortcutList.get_minimum_size().x + 100
109+
size.y = min(size.y, %ShortcutList.get_minimum_size().y+100)
98110
global_position = get_parent().global_position+get_parent().size/2-size/2
99111

100112

addons/dialogic/Editor/TimelineEditor/test_timeline_scene.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ func _ready() -> void:
1515

1616
randomize()
1717
var current_timeline: String = DialogicUtil.get_editor_setting("current_timeline_path", "")
18+
var start_from_index: int = DialogicUtil.get_editor_setting("play_from_index", -1)
1819
if not current_timeline:
1920
get_tree().quit()
20-
DialogicUtil.autoload().start(current_timeline)
21+
DialogicUtil.autoload().start(current_timeline, start_from_index)
2122
DialogicUtil.autoload().timeline_ended.connect(get_tree().quit)
2223
DialogicUtil.autoload().signal_event.connect(receive_event_signal)
2324
DialogicUtil.autoload().text_signal.connect(receive_text_signal)
@@ -41,4 +42,3 @@ func _input(event:InputEvent) -> void:
4142

4243
auto_skip.disable_on_unread_text = false
4344
auto_skip.enabled = not is_auto_skip_enabled
44-

addons/dialogic/Editor/TimelineEditor/timeline_editor.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ func _input(event: InputEvent) -> void:
102102

103103

104104
## Method to play the current timeline. Connected to the button in the sidebar.
105-
func play_timeline() -> void:
105+
func play_timeline(index := -1) -> void:
106106
_save()
107107

108108
var dialogic_plugin := DialogicUtil.get_dialogic_plugin()
109109

110110
# Save the current opened timeline
111111
DialogicUtil.set_editor_setting('current_timeline_path', current_resource.resource_path)
112-
112+
DialogicUtil.set_editor_setting('play_from_index', index)
113113
DialogicUtil.get_dialogic_plugin().get_editor_interface().play_custom_scene("res://addons/dialogic/Editor/TimelineEditor/test_timeline_scene.tscn")
114114

115115

0 commit comments

Comments
 (0)