@@ -6,6 +6,7 @@ extends "res://addons/dialogic/Editor/Events/Parts/EventPart.gd"
66## node references
77onready var text_editor = $ TextEdit
88
9+ var timeline_area = null
910
1011# used to connect the signals
1112func _ready ():
@@ -20,6 +21,10 @@ func _ready():
2021 text_editor .set ('custom_colors/function_color' , get_color ("font_color" , "Editor" ))
2122 text_editor .set ('custom_colors/member_variable_color' , get_color ("font_color" , "Editor" ))
2223 text_editor .set ('custom_colors/symbol_color' , get_color ("font_color" , "Editor" ))
24+
25+ timeline_area = find_parent ('TimelineArea' )
26+ timeline_area .connect ('resized' , self , '_set_new_min_size' )
27+ _set_new_min_size ()
2328
2429
2530# called by the event block
@@ -82,21 +87,31 @@ func _set_new_min_size():
8287 # Getting new sizes
8388 var extra_vertical = 1.1
8489
85- if text_editor .get_line_count () > 1 :
86- extra_vertical = 1.22
87-
8890
8991
90- text_editor .rect_min_size .y = get_font ("normal_font" ).get_height () * ((text_editor .get_line_count () + 1 ) * extra_vertical )
9192
9293 # Getting the longest string and making that the width of the dialog bubble
94+ # also check how many lines wrap (and how often)
95+ var count_wrapped_lines = 0
9396 var longest_string = ''
9497 for l in text_editor .text .split ('\n ' ):
9598 if l .length () > longest_string .length ():
9699 longest_string = l
100+ if get_font ("normal_font" ).get_string_size (l ).x > get_max_x_size ():
101+ count_wrapped_lines += get_font ("normal_font" ).get_string_size (l ).x / (get_max_x_size ())
102+
103+ # set the height
104+ if text_editor .get_line_count () > 1 :
105+ extra_vertical = 1.22
106+ text_editor .rect_min_size .y = get_font ("normal_font" ).get_height () * ((text_editor .get_line_count () + 1 + count_wrapped_lines ) * extra_vertical )
97107
108+ # set the width
98109 text_editor .rect_min_size .x = get_font ("normal_font" ).get_string_size (longest_string ).x + 50
110+ if text_editor .rect_min_size .x > get_max_x_size ():
111+ text_editor .rect_min_size .x = get_max_x_size ()
99112
113+ func get_max_x_size ():
114+ return timeline_area .rect_size .x - (text_editor .rect_global_position .x - timeline_area .rect_global_position .x ) - 50
100115
101116func _on_TextEditor_focus_entered () -> void :
102117 if (Input .is_mouse_button_pressed (BUTTON_LEFT )):
0 commit comments