@@ -69,3 +69,127 @@ func _on_gui_input(event):
6969 if (_last_event_button_drop_attempt != '' ):
7070 drop_data (Vector2 .ZERO , { "source" : "EventButton" , "event_id" : _last_event_button_drop_attempt } )
7171 _is_drag_receiving = false
72+
73+ func _draw ():
74+ var timeline_children = $ TimeLine .get_children ()
75+ var timeline_lenght = timeline_children .size ()
76+ var line_color = Color ("#4D4D4D" )
77+ var test_color = Color (1 ,0 ,0 ,0.5 )
78+ var _scale = DialogicUtil .get_editor_scale (self )
79+ var line_width = 3 * _scale
80+ var pos_x = (32 * _scale )
81+ var pos_y = 51 * _scale
82+
83+ # Adjusting the pos_x. Not sure why it is not consistent between render scales
84+ if _scale == 1.5 :
85+ pos_x -= 3
86+ if _scale == 1.75 :
87+ pos_x -= 4
88+ if _scale == 2 :
89+ pos_x -= 6
90+
91+ for event in $ TimeLine .get_children ():
92+ if not 'event_data' in event :
93+ continue
94+
95+ # If the event is the last one, don't draw anything aftwards
96+ if timeline_children [timeline_lenght - 1 ] == event :
97+ return
98+
99+ # Drawing long lines on questions and conditions
100+ if event .event_name == 'Question' or event .event_name == 'Condition' :
101+ var keep_going = true
102+ var end_reference
103+ for e in timeline_children :
104+ if keep_going :
105+ if e .get_index () > event .get_index ():
106+ if e .current_indent_level == event .current_indent_level :
107+ if e .event_name == 'End Branch' :
108+ end_reference = e
109+ keep_going = false
110+ if e .event_name == 'Question' or event .event_name == 'Condition' :
111+ keep_going = false
112+ if keep_going == false :
113+ if end_reference :
114+ # This line_size thing should be fixed, not sure why it is different when
115+ # the indent level is 0 and when it is bigger.
116+ var line_size = 0
117+ if event .current_indent_level > 0 :
118+ line_size = (event .indent_size * event .current_indent_level ) + (4 * _scale )
119+ # end the line_size thingy
120+
121+ # Drawing the line from the Question/Condition node to the End Branch one.
122+ draw_rect (Rect2 (
123+ Vector2 (pos_x + line_size , pos_y - scroll_vertical )+ event .rect_position ,
124+ Vector2 (line_width , (end_reference .rect_global_position .y - event .rect_global_position .y ) - (43 * _scale ))
125+ ),
126+ line_color , true )
127+
128+ # Drawing other lines and archs
129+ var next_event = timeline_children [event .get_index () + 1 ]
130+ if event .current_indent_level > 0 :
131+ # Line at current indent
132+ var line_size = (event .indent_size * event .current_indent_level ) + (4 * _scale )
133+ if next_event .event_name != 'End Branch' and event .event_name != 'Choice' :
134+ if event .event_name != 'Question' and next_event .event_name == 'Choice' :
135+ # Skip drawing lines before going to the next choice
136+ pass
137+ else :
138+ draw_rect (Rect2 (
139+ Vector2 (pos_x + line_size , pos_y - scroll_vertical )+ event .rect_position ,
140+ Vector2 (line_width , event .rect_size .y - (40 * _scale ))
141+ ),
142+ line_color ,
143+ true )
144+ else :
145+ # Root (level 0) Vertical Line
146+ draw_rect (Rect2 (
147+ Vector2 (pos_x , pos_y - scroll_vertical )+ event .rect_position ,
148+ Vector2 (line_width , event .rect_size .y - (40 * _scale ))
149+ ),
150+ line_color ,
151+ true )
152+
153+ # Drawing arc
154+ if event .event_name == 'Choice' :
155+ # Connecting with the question
156+ var arc_start_x = (event .indent_size * (event .current_indent_level )) + (16.2 * _scale )
157+ var arc_start_y = 5
158+ var arc_point_count = 12 * _scale
159+ var arc_radius = 24 * _scale
160+ var start_angle = 90
161+ var end_angle = 185
162+
163+ if event .current_indent_level == 1 :
164+ arc_start_x = (event .indent_size * (event .current_indent_level )) + (7.5 * _scale )
165+
166+ draw_arc (
167+ Vector2 (arc_start_x , arc_start_y - scroll_vertical )+ event .rect_position ,
168+ arc_radius ,
169+ deg2rad (start_angle ),
170+ deg2rad (end_angle ),
171+ arc_point_count , # point count
172+ line_color ,
173+ line_width - (1 * _scale ),
174+ true
175+ )
176+
177+ # Don't draw arc if next event is another choice event
178+ if next_event .event_name == "Choice" or next_event .event_name == "End Branch" :
179+ return
180+
181+ # Connecting with the next event
182+
183+ arc_start_x = (event .indent_size * (event .current_indent_level + 1 )) + (16 * _scale )
184+ arc_start_y = (pos_y + (8 * _scale ))
185+
186+ draw_arc (
187+ Vector2 (arc_start_x , arc_start_y - scroll_vertical )+ event .rect_position ,
188+ arc_radius ,
189+ deg2rad (start_angle ),
190+ deg2rad (end_angle ),
191+ arc_point_count ,
192+ line_color ,
193+ line_width - (1 * _scale ),
194+ true
195+ )
0 commit comments