Skip to content

Commit f1d4a70

Browse files
Independent choices (#2057)
Moves choices logic into the choice event (the first choice of a question will handle it) instead of the text event. Also updates the visual editor logic, lines and warning for choices to reflect that they can now exist wherever they want.
1 parent 5bca685 commit f1d4a70

File tree

11 files changed

+209
-129
lines changed

11 files changed

+209
-129
lines changed

addons/dialogic/Editor/Events/BranchEnd.gd

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,42 @@
22
extends Control
33
## A scene shown at the end of events that contain other events
44

5-
var resource : DialogicEndBranchEvent
5+
var resource: DialogicEndBranchEvent
66

77
# References
8-
var parent_node : Control = null
9-
var end_control :Control = null
8+
var parent_node: Control = null
9+
var end_control: Control = null
1010

1111
# Indent
1212
var indent_size := 22
1313
var current_indent_level := 1
1414

15+
var selected := false
16+
1517
func _ready() -> void:
1618
$Icon.icon = get_theme_icon("GuiSpinboxUpdown", "EditorIcons")
17-
$Spacer.custom_minimum_size.x = 100*DialogicUtil.get_editor_scale()
19+
$Spacer.custom_minimum_size.x = 90*DialogicUtil.get_editor_scale()
1820
visual_deselect()
1921
parent_node_changed()
2022

2123

2224
## Called by the visual timeline editor
2325
func visual_select() -> void:
2426
modulate = get_theme_color("highlighted_font_color", "Editor")
27+
selected = true
2528

2629

2730
## Called by the visual timeline editor
2831
func visual_deselect() -> void:
2932
if !parent_node:return
33+
selected = false
3034
modulate = parent_node.resource.event_color.lerp(get_theme_color("font_color", "Editor"), 0.3)
3135

3236

37+
func is_selected() -> bool:
38+
return selected
39+
40+
3341
## Called by the visual timeline editor
3442
func highlight() -> void:
3543
if !parent_node:return

addons/dialogic/Editor/Events/BranchEnd.tscn

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@
22

33
[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/BranchEnd.gd" id="1"]
44

5-
[sub_resource type="Image" id="Image_8tlok"]
5+
[sub_resource type="Image" id="Image_8jrl8"]
66
data = {
7-
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 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, 93, 93, 131, 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, 93, 93, 131, 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, 93, 93, 131, 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, 252, 255, 93, 93, 252, 255, 93, 93, 252, 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, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 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, 93, 93, 55, 255, 97, 97, 58, 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, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 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, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 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, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 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),
7+
"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),
88
"format": "RGBA8",
99
"height": 16,
1010
"mipmaps": false,
1111
"width": 16
1212
}
1313

14-
[sub_resource type="ImageTexture" id="ImageTexture_vm1jl"]
15-
image = SubResource("Image_8tlok")
14+
[sub_resource type="ImageTexture" id="ImageTexture_44ap0"]
15+
image = SubResource("Image_8jrl8")
1616

1717
[node name="EndBranch" type="HBoxContainer"]
18-
custom_minimum_size = Vector2(0, 40)
1918
anchors_preset = 10
2019
anchor_right = 1.0
21-
offset_bottom = 40.0
20+
offset_bottom = 24.0
2221
grow_horizontal = 2
2322
mouse_filter = 0
2423
script = ExtResource("1")
@@ -28,7 +27,7 @@ layout_mode = 2
2827
size_flags_vertical = 0
2928

3029
[node name="Spacer" type="Control" parent="."]
31-
custom_minimum_size = Vector2(75, 0)
30+
custom_minimum_size = Vector2(90, 0)
3231
layout_mode = 2
3332
size_flags_vertical = 0
3433

@@ -40,7 +39,7 @@ size_flags_vertical = 4
4039
tooltip_text = "Click and drag"
4140
focus_mode = 0
4241
mouse_filter = 1
43-
icon = SubResource("ImageTexture_vm1jl")
42+
icon = SubResource("ImageTexture_44ap0")
4443
flat = true
4544

4645
[node name="HiddenEventsLabel" type="Label" parent="."]
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[gd_resource type="StyleBoxFlat" format=3 uid="uid://obyrr26pqk2p"]
22

33
[resource]
4-
content_margin_left = 7.0
5-
content_margin_top = 0.0
6-
content_margin_right = 0.0
7-
content_margin_bottom = 0.0
4+
content_margin_left = 3.0
5+
content_margin_top = 1.0
6+
content_margin_right = 4.0
7+
content_margin_bottom = 1.0
88
bg_color = Color(0.776471, 0.776471, 0.776471, 0.207843)
9-
border_width_left = 3
109
border_color = Color(1, 1, 1, 1)
11-
corner_radius_top_left = 1
10+
corner_radius_top_left = 5
1211
corner_radius_top_right = 5
1312
corner_radius_bottom_right = 5
14-
corner_radius_bottom_left = 1
15-
expand_margin_top = 3.0
16-
expand_margin_bottom = 3.0
13+
corner_radius_bottom_left = 5
14+
expand_margin_left = 1.0
15+
expand_margin_top = 1.0
16+
expand_margin_bottom = 2.0
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[gd_resource type="StyleBoxEmpty" format=3 uid="uid://cl75ikyq2is7c"]
22

33
[resource]
4-
content_margin_left = 7.0
4+
content_margin_left = 3.0
5+
content_margin_top = 1.0
6+
content_margin_right = 4.0
7+
content_margin_bottom = 1.0

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

Lines changed: 87 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func _ready() -> void:
2626
%TimelineArea.get_theme_color("background_color", "CodeEdit")
2727

2828

29-
################### EVENT DRAGGING #############################################
29+
#region EVENT DRAGGING
3030
################################################################################
3131

3232
func start_dragging(type:DragTypes, data:Variant) -> void:
@@ -67,74 +67,127 @@ func finish_dragging():
6767
drag_canceled.emit()
6868
queue_redraw()
6969

70+
#endregion
7071

7172

72-
##################### LINE DRAWING #############################################
73+
#region LINE DRAWING
7374
################################################################################
7475

7576
func _draw() -> void:
7677
var _scale := DialogicUtil.get_editor_scale()
7778
var line_width := 5 * _scale
7879
var horizontal_line_length := 100*_scale
79-
var color_multiplier := Color(1,1,1,0.5)
80+
var color_multiplier := Color(1,1,1,0.25)
8081
var selected_color_multiplier := Color(1,1,1,1)
82+
83+
84+
## Draw Event Lines
8185
for idx in range($Timeline.get_child_count()):
82-
var event : Control = $Timeline.get_child(idx)
86+
var block : Control = $Timeline.get_child(idx)
8387

84-
if not "resource" in event:
88+
if not "resource" in block:
8589
continue
8690

87-
if not event.visible:
91+
if not block.visible:
8892
continue
8993

90-
if event.resource is DialogicEndBranchEvent:
94+
if block.resource is DialogicEndBranchEvent:
9195
continue
9296

93-
if not (event.has_any_enabled_body_content or event.resource.can_contain_events):
97+
if not (block.has_any_enabled_body_content or block.resource.can_contain_events):
9498
continue
9599

96-
var icon_panel_height := 32*_scale
97-
var rect_position :Vector2= event.get_node('%IconPanel').global_position+Vector2(0,1)*event.get_node('%IconPanel').size+Vector2(0,-4)
98-
var color :Color= event.resource.event_color
99-
if event.is_selected():
100+
var icon_panel_height: int = block.get_node('%IconPanel').size.y
101+
var rect_position: Vector2 = block.get_node('%IconPanel').global_position+Vector2(0,1)*block.get_node('%IconPanel').size+Vector2(0,-4)
102+
var color: Color = block.resource.event_color
103+
104+
if block.is_selected() or block.end_node and block.end_node.is_selected():
100105
color *= selected_color_multiplier
101106
else:
102107
color *= color_multiplier
103108

104-
if idx < $Timeline.get_child_count()-1 and event.current_indent_level < $Timeline.get_child(idx+1).current_indent_level:
105-
var end_node :Node= event.end_node
106-
var sub_idx := idx
109+
if block.expanded and not block.resource.can_contain_events:
110+
draw_rect(Rect2(rect_position-global_position+Vector2(line_width, 0), Vector2(line_width, block.size.y-block.get_node('%IconPanel').size.y)), color)
107111

108-
if !end_node: # this doesn't have an end node (e.g. text event with choices in it)
112+
## If the indentation has not changed, nothing else happens
113+
if idx >= $Timeline.get_child_count()-1 or block.current_indent_level >= $Timeline.get_child(idx+1).current_indent_level:
114+
continue
115+
116+
## Draw connection between opening and end branch events
117+
if block.resource.can_contain_events:
118+
var end_node: Node = block.end_node
119+
120+
if end_node != null:
121+
var v_length: float = end_node.global_position.y+end_node.size.y/2-rect_position.y
122+
#var rect_size := Vector2(line_width, )
123+
var offset := Vector2(line_width, 0)
124+
125+
# Draw vertical line
126+
draw_rect(Rect2(rect_position-global_position+offset, Vector2(line_width, v_length)), color)
127+
# Draw horizonal line (on END BRANCH event)
128+
draw_rect(Rect2(
129+
rect_position.x+line_width-global_position.x+offset.x,
130+
rect_position.y+v_length-line_width-global_position.y,
131+
horizontal_line_length-offset.x,
132+
line_width),
133+
color)
134+
135+
if block.resource.wants_to_group:
136+
var group_color: Color = block.resource.event_color*color_multiplier
137+
var group_starter := true
138+
if idx != 0:
139+
var block_above := $Timeline.get_child(idx-1)
140+
if block_above.resource.event_name == block.resource.event_name:
141+
group_starter = false
142+
if block_above.resource is DialogicEndBranchEvent and block_above.parent_node.resource.event_name == block.resource.event_name:
143+
group_starter = false
144+
145+
## Draw small horizontal line on any event in group
146+
draw_rect(Rect2(
147+
rect_position.x-global_position.x-line_width,
148+
rect_position.y-global_position.y-icon_panel_height/2,
149+
line_width,
150+
line_width),
151+
group_color)
152+
153+
if group_starter:
154+
## Find the last event in the group (or that events END BRANCH)
155+
var sub_idx := idx
156+
var group_end_idx := idx
109157
while sub_idx < $Timeline.get_child_count()-1:
110158
sub_idx += 1
111-
if $Timeline.get_child(sub_idx).current_indent_level == event.current_indent_level:
112-
end_node = $Timeline.get_child(sub_idx-1)
159+
if $Timeline.get_child(sub_idx).current_indent_level == block.current_indent_level-1:
160+
group_end_idx = sub_idx-1
113161
break
114-
var rect_size := Vector2()
115-
if end_node != null:
116-
rect_size = Vector2(line_width, end_node.global_position.y+end_node.size.y-rect_position.y)
117-
if end_node.resource is DialogicEndBranchEvent and event.resource.can_contain_events:
118-
rect_size = Vector2(line_width, end_node.global_position.y+end_node.size.y/2-rect_position.y)
119-
else:
120-
rect_size = Vector2(line_width, $Timeline.get_child(-1).global_position.y+$Timeline.get_child(-1).size.y-rect_position.y)
121162

122-
draw_rect(Rect2(rect_position-global_position, rect_size), color)
123-
draw_rect(Rect2(Vector2(event.get_node('%IconPanel').global_position.x+line_width, rect_position.y+rect_size.y-line_width)-global_position, Vector2(horizontal_line_length, line_width)), color)
163+
var end_node := $Timeline.get_child(group_end_idx)
164+
165+
var offset := Vector2(-2*line_width, -icon_panel_height/2)
166+
var v_length: float = end_node.global_position.y - rect_position.y + icon_panel_height
167+
168+
## Draw vertical line
169+
draw_rect(Rect2(
170+
rect_position.x - global_position.x + offset.x,
171+
rect_position.y - global_position.y + offset.y,
172+
line_width,
173+
v_length),
174+
group_color)
124175

125-
elif event.expanded:
126-
draw_rect(Rect2(rect_position-global_position, Vector2(line_width, event.size.y-event.get_node('%IconPanel').size.y+10*_scale)), color.darkened(0.5))
127176

177+
## Draw line that indicates the dragging position
128178
if dragging and get_global_rect().has_point(get_global_mouse_position()):
129-
var height :int = 0
179+
var height: int = 0
130180
if drag_to_position == %Timeline.get_child_count():
131181
height = %Timeline.get_child(-1).global_position.y+%Timeline.get_child(-1).size.y-global_position.y-(line_width/2.0)
132182
else:
133183
height = %Timeline.get_child(drag_to_position).global_position.y-global_position.y-(line_width/2.0)
134184

135-
draw_line(Vector2(0, height), Vector2(size.x*0.9, height), get_theme_color("accent_color", "Editor"), line_width*0.2)
185+
draw_line(Vector2(0, height), Vector2(size.x*0.9, height), get_theme_color("accent_color", "Editor"), line_width*.3)
136186

137-
##################### SPACE BELOW ##############################################
187+
#endregion
188+
189+
190+
#region SPACE BELOW
138191
################################################################################
139192

140193
func add_extra_scroll_area_to_timeline(fake_arg:Variant=null) -> void:
@@ -143,3 +196,5 @@ func add_extra_scroll_area_to_timeline(fake_arg:Variant=null) -> void:
143196
%Timeline.size.y = 0
144197
if %Timeline.size.y + 200 > %TimelineArea.size.y:
145198
%Timeline.custom_minimum_size = Vector2(0, %Timeline.size.y + 200)
199+
200+
#endregion

0 commit comments

Comments
 (0)