@@ -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
@@ -108,32 +116,6 @@ func get_snapped_block() -> Block:
108116 return snap_point .get_snapped_block ()
109117
110118
111- func get_string () -> String :
112- var snapped_block : ParameterBlock = get_snapped_block () as ParameterBlock
113- if snapped_block :
114- var generated_string = snapped_block .get_parameter_string ()
115- if Types .can_cast (snapped_block .variant_type , variant_type ):
116- return Types .cast (generated_string , snapped_block .variant_type , variant_type )
117- else :
118- push_warning ("No cast from %s to %s ; using '%s ' verbatim" % [snapped_block , variant_type , generated_string ])
119- return generated_string
120-
121- var input = get_raw_input ()
122-
123- if option :
124- return _option_input .get_item_text (_option_input .selected ).to_snake_case ()
125-
126- match variant_type :
127- TYPE_STRING :
128- return "'%s '" % input .replace ("\\ " , "\\\\ " ).replace ("'" , "\\ '" )
129- TYPE_VECTOR2 :
130- return "Vector2(%s )" % input
131- TYPE_COLOR :
132- return "Color%s " % str (input )
133- _ :
134- return "%s " % input
135-
136-
137119func _validate_and_submit_edit_text (line_edit : Node , type : Variant .Type ):
138120 if _last_submitted_text [line_edit ] == line_edit .text :
139121 return
@@ -147,6 +129,7 @@ func _validate_and_submit_edit_text(line_edit: Node, type: Variant.Type):
147129 line_edit .text = _last_submitted_text [line_edit ]
148130 return
149131 _last_submitted_text [line_edit ] = line_edit .text
132+
150133 modified .emit ()
151134
152135
0 commit comments