@@ -56,13 +56,15 @@ func set_raw_input(raw_input):
5656 _color_input .color = raw_input
5757 _update_panel_bg_color (raw_input )
5858 TYPE_VECTOR2 :
59- var split = raw_input . split ( "," )
60- _x_line_edit .text = split [ 0 ]
61- _y_line_edit .text = split [ 1 ]
59+ # Rounding because floats are doubles by default but Vector2s have single components
60+ _x_line_edit .text = ( " %.4f " % raw_input . x ). rstrip ( "0" ). rstrip ( "." )
61+ _y_line_edit .text = ( " %.4f " % raw_input . y ). rstrip ( "0" ). rstrip ( "." )
6262 TYPE_BOOL :
6363 _bool_input_option .select (raw_input )
64+ TYPE_NIL :
65+ _line_edit .text = raw_input .trim_suffix ("__nil__" )
6466 _ :
65- _line_edit .text = raw_input
67+ _line_edit .text = "" if raw_input == null else str ( raw_input )
6668
6769
6870func get_raw_input ():
@@ -76,9 +78,15 @@ func get_raw_input():
7678 TYPE_COLOR :
7779 return _color_input .color
7880 TYPE_VECTOR2 :
79- return _x_line_edit .text + "," + _y_line_edit .text
81+ return Vector2 ( float ( _x_line_edit .text ), float ( _y_line_edit .text ))
8082 TYPE_BOOL :
8183 return bool (_bool_input_option .selected )
84+ TYPE_INT :
85+ return null if _line_edit .text == "" else int (_line_edit .text )
86+ TYPE_FLOAT :
87+ return null if _line_edit .text == "" else float (_line_edit .text )
88+ TYPE_NIL :
89+ return _line_edit .text + "__nil__"
8290 _ :
8391 return _line_edit .text
8492
@@ -125,13 +133,21 @@ func get_string() -> String:
125133
126134 match variant_type :
127135 TYPE_STRING :
136+ # HACK: don't include quotes around NIL strings
137+ if input .ends_with ("__nil__" ):
138+ return input .trim_suffix ("__nil__" )
128139 return "'%s '" % input .replace ("\\ " , "\\\\ " ).replace ("'" , "\\ '" )
129140 TYPE_VECTOR2 :
130- return "Vector2( %s ) " % input
141+ return "Vector2%s " % str ( input )
131142 TYPE_COLOR :
132143 return "Color%s " % str (input )
144+ TYPE_OBJECT :
145+ if input is OptionData :
146+ var option_data := input as OptionData
147+ return option_data .items [option_data .selected ]
133148 _ :
134149 return "%s " % input
150+ return ""
135151
136152
137153func _validate_and_submit_edit_text (line_edit : Node , type : Variant .Type ):
0 commit comments