godot_scene_code_converter icon indicating copy to clipboard operation
godot_scene_code_converter copied to clipboard

Use node name for variable name + format floats as floats

Open AaronRecord opened this issue 4 years ago • 2 comments

Previous:

set_rect_rotation(0.1);
set_rect_scale(Vector2(1.642, 1));
set_rect_clip_content(true);
set_h_size_flags(Control::SIZE_EXPAND_FILL);
set_v_size_flags(9);
set_size_flags_stretch_ratio(3);
set_modulate(Color(0.219608, 1, 0, 1));
set_material(nullptr /* TODO resource here */);

// MyControl
Control *control = memnew(Control);
control->set_margin(MARGIN_RIGHT, 40 * EDSCALE);
control->set_margin(MARGIN_BOTTOM, 40 * EDSCALE);
control->set_pause_mode(1);
add_child(control);

Now:

set_rect_rotation(0.1f);
set_rect_scale(Vector2(1.642f, 1.0f));
set_rect_clip_content(true);
set_h_size_flags(Control::SIZE_EXPAND_FILL);
set_v_size_flags(9);
set_size_flags_stretch_ratio(3.0f);
set_modulate(Color(0.219608f, 1.0f, 0.0f, 1.0f));
set_material(/* TODO: reference here */);

Control *my_control = memnew(Control);
my_control->set_margin(MARGIN_RIGHT, 40.0f * EDSCALE);
my_control->set_margin(MARGIN_BOTTOM, 40.0f * EDSCALE);
my_control->set_pause_mode(1);
add_child(my_control);

TestScene.zip

AaronRecord avatar Jun 11 '21 04:06 AaronRecord

I realized that multiple nodes can share the same name as long as they have different parents, so I made it so that when there's duplicates it adds a number to the end of the variable name (my_node, my_node1, my_node2, etc.), and it prints a warning recommending giving each node a unique name.

AaronRecord avatar Jun 12 '21 01:06 AaronRecord

Just realized a bug, will fix later

AaronRecord avatar Nov 25 '21 23:11 AaronRecord