@@ -56,13 +56,15 @@ func set_raw_input(raw_input):
56
56
_color_input .color = raw_input
57
57
_update_panel_bg_color (raw_input )
58
58
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 ( "." )
62
62
TYPE_BOOL :
63
63
_bool_input_option .select (raw_input )
64
+ TYPE_NIL :
65
+ _line_edit .text = raw_input .trim_suffix ("__nil__" )
64
66
_ :
65
- _line_edit .text = raw_input
67
+ _line_edit .text = "" if raw_input == null else str ( raw_input )
66
68
67
69
68
70
func get_raw_input ():
@@ -76,9 +78,15 @@ func get_raw_input():
76
78
TYPE_COLOR :
77
79
return _color_input .color
78
80
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 ))
80
82
TYPE_BOOL :
81
83
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__"
82
90
_ :
83
91
return _line_edit .text
84
92
@@ -125,13 +133,21 @@ func get_string() -> String:
125
133
126
134
match variant_type :
127
135
TYPE_STRING :
136
+ # HACK: don't include quotes around NIL strings
137
+ if input .ends_with ("__nil__" ):
138
+ return input .trim_suffix ("__nil__" )
128
139
return "'%s '" % input .replace ("\\ " , "\\\\ " ).replace ("'" , "\\ '" )
129
140
TYPE_VECTOR2 :
130
- return "Vector2( %s ) " % input
141
+ return "Vector2%s " % str ( input )
131
142
TYPE_COLOR :
132
143
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 ]
133
148
_ :
134
149
return "%s " % input
150
+ return ""
135
151
136
152
137
153
func _validate_and_submit_edit_text (line_edit : Node , type : Variant .Type ):
0 commit comments