You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
@@ -472,8 +472,9 @@ float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
|
||||
void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
|
||||
Ref<InputEventKey> k = p_ev;
|
||||
|
||||
if (!is_visible_in_tree())
|
||||
if (!is_visible_in_tree()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) {
|
||||
viewport->update();
|
||||
@@ -487,8 +488,9 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
|
||||
} else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
|
||||
// Divide the grid size
|
||||
Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
|
||||
if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0)
|
||||
if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) {
|
||||
grid_step_multiplier--;
|
||||
}
|
||||
viewport->update();
|
||||
}
|
||||
}
|
||||
@@ -496,17 +498,19 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
|
||||
|
||||
Object *CanvasItemEditor::_get_editor_data(Object *p_what) {
|
||||
CanvasItem *ci = Object::cast_to<CanvasItem>(p_what);
|
||||
if (!ci)
|
||||
if (!ci) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return memnew(CanvasItemEditorSelectedItem);
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_keying_changed() {
|
||||
if (AnimationPlayerEditor::singleton->get_track_editor()->is_visible_in_tree())
|
||||
if (AnimationPlayerEditor::singleton->get_track_editor()->is_visible_in_tree()) {
|
||||
animation_hb->show();
|
||||
else
|
||||
} else {
|
||||
animation_hb->hide();
|
||||
}
|
||||
}
|
||||
|
||||
Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_list) {
|
||||
@@ -532,10 +536,12 @@ Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_li
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_expand_encompassing_rect_using_children(Rect2 &r_rect, const Node *p_node, bool &r_first, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, bool include_locked_nodes) {
|
||||
if (!p_node)
|
||||
if (!p_node) {
|
||||
return;
|
||||
if (Object::cast_to<Viewport>(p_node))
|
||||
}
|
||||
if (Object::cast_to<Viewport>(p_node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
|
||||
|
||||
@@ -571,10 +577,12 @@ Rect2 CanvasItemEditor::_get_encompassing_rect(const Node *p_node) {
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) {
|
||||
if (!p_node)
|
||||
if (!p_node) {
|
||||
return;
|
||||
if (Object::cast_to<Viewport>(p_node))
|
||||
}
|
||||
if (Object::cast_to<Viewport>(p_node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const real_t grab_distance = EDITOR_GET("editors/poly_editor/point_grab_radius");
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
|
||||
@@ -659,8 +667,9 @@ void CanvasItemEditor::_get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResu
|
||||
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from));
|
||||
|
||||
Vector<Vector2> bone_shape;
|
||||
if (!_get_bone_shape(&bone_shape, nullptr, E))
|
||||
if (!_get_bone_shape(&bone_shape, nullptr, E)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if the point is inside the Polygon2D
|
||||
if (Geometry::is_point_in_polygon(screen_pos, bone_shape)) {
|
||||
@@ -672,8 +681,9 @@ void CanvasItemEditor::_get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResu
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (duplicate)
|
||||
if (duplicate) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Else, add it
|
||||
_SelectResult res;
|
||||
@@ -692,21 +702,25 @@ bool CanvasItemEditor::_get_bone_shape(Vector<Vector2> *shape, Vector<Vector2> *
|
||||
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(bone->key().from));
|
||||
Node2D *to_node = Object::cast_to<Node2D>(ObjectDB::get_instance(bone->key().to));
|
||||
|
||||
if (!from_node)
|
||||
if (!from_node) {
|
||||
return false;
|
||||
if (!from_node->is_inside_tree())
|
||||
}
|
||||
if (!from_node->is_inside_tree()) {
|
||||
return false; //may have been removed
|
||||
}
|
||||
|
||||
if (!to_node && bone->get().length == 0)
|
||||
if (!to_node && bone->get().length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2 from = transform.xform(from_node->get_global_position());
|
||||
Vector2 to;
|
||||
|
||||
if (to_node)
|
||||
if (to_node) {
|
||||
to = transform.xform(to_node->get_global_position());
|
||||
else
|
||||
} else {
|
||||
to = transform.xform(from_node->get_global_transform().xform(Vector2(bone->get().length, 0)));
|
||||
}
|
||||
|
||||
Vector2 rel = to - from;
|
||||
Vector2 relt = rel.tangent().normalized() * bone_width;
|
||||
@@ -734,10 +748,12 @@ bool CanvasItemEditor::_get_bone_shape(Vector<Vector2> *shape, Vector<Vector2> *
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_node, List<CanvasItem *> *r_items, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) {
|
||||
if (!p_node)
|
||||
if (!p_node) {
|
||||
return;
|
||||
if (Object::cast_to<Viewport>(p_node))
|
||||
}
|
||||
if (Object::cast_to<Viewport>(p_node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
|
||||
Node *scene = editor->get_edited_scene();
|
||||
@@ -852,10 +868,12 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_save_canvas_item_ik_chain(const CanvasItem *p_canvas_item, List<float> *p_bones_length, List<Dictionary> *p_bones_state) {
|
||||
if (p_bones_length)
|
||||
if (p_bones_length) {
|
||||
*p_bones_length = List<float>();
|
||||
if (p_bones_state)
|
||||
}
|
||||
if (p_bones_state) {
|
||||
*p_bones_state = List<Dictionary>();
|
||||
}
|
||||
|
||||
const Node2D *bone = Object::cast_to<Node2D>(p_canvas_item);
|
||||
if (bone && bone->has_meta("_edit_bone_")) {
|
||||
@@ -881,10 +899,12 @@ void CanvasItemEditor::_save_canvas_item_ik_chain(const CanvasItem *p_canvas_ite
|
||||
for (List<const Node2D *>::Element *bone_E = bone_ik_list.front(); bone_E; bone_E = bone_E->next()) {
|
||||
bone_xform = bone_xform * bone->get_transform().affine_inverse();
|
||||
const Node2D *parent_bone = bone_E->get();
|
||||
if (p_bones_length)
|
||||
if (p_bones_length) {
|
||||
p_bones_length->push_back(parent_bone->get_global_transform().get_origin().distance_to(bone->get_global_position()));
|
||||
if (p_bones_state)
|
||||
}
|
||||
if (p_bones_state) {
|
||||
p_bones_state->push_back(parent_bone->_edit_get_state());
|
||||
}
|
||||
bone = parent_bone;
|
||||
}
|
||||
}
|
||||
@@ -956,13 +976,15 @@ void CanvasItemEditor::_snap_changed() {
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_selection_result_pressed(int p_result) {
|
||||
if (selection_results.size() <= p_result)
|
||||
if (selection_results.size() <= p_result) {
|
||||
return;
|
||||
}
|
||||
|
||||
CanvasItem *item = selection_results[p_result].item;
|
||||
|
||||
if (item)
|
||||
if (item) {
|
||||
_select_click_on_item(item, Point2(), selection_menu_additive_selection);
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_selection_menu_hide() {
|
||||
@@ -1262,8 +1284,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
|
||||
}
|
||||
}
|
||||
|
||||
if (is_pan_key)
|
||||
if (is_pan_key) {
|
||||
pan_pressed = k->is_pressed();
|
||||
}
|
||||
}
|
||||
|
||||
Ref<InputEventMouseMotion> m = p_event;
|
||||
@@ -1350,10 +1373,11 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
|
||||
drag_to = transform.affine_inverse().xform(m->get_position());
|
||||
_restore_canvas_item_state(drag_selection);
|
||||
Vector2 new_pos;
|
||||
if (drag_selection.size() == 1)
|
||||
if (drag_selection.size() == 1) {
|
||||
new_pos = snap_point(drag_to, SNAP_NODE_SIDES | SNAP_NODE_CENTER | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, drag_selection[0]);
|
||||
else
|
||||
} else {
|
||||
new_pos = snap_point(drag_to, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL);
|
||||
}
|
||||
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = E->get();
|
||||
canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos));
|
||||
@@ -1462,8 +1486,9 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
|
||||
|
||||
// Remove not movable nodes
|
||||
for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
if (!_is_node_movable(E->get(), true))
|
||||
if (!_is_node_movable(E->get(), true)) {
|
||||
selection.erase(E);
|
||||
}
|
||||
}
|
||||
|
||||
drag_selection = selection;
|
||||
@@ -1611,28 +1636,36 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
|
||||
|
||||
switch (drag_type) {
|
||||
case DRAG_ANCHOR_TOP_LEFT:
|
||||
if (!use_single_axis || !use_y)
|
||||
if (!use_single_axis || !use_y) {
|
||||
control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false);
|
||||
if (!use_single_axis || use_y)
|
||||
}
|
||||
if (!use_single_axis || use_y) {
|
||||
control->set_anchor(MARGIN_TOP, new_anchor.y, false, false);
|
||||
}
|
||||
break;
|
||||
case DRAG_ANCHOR_TOP_RIGHT:
|
||||
if (!use_single_axis || !use_y)
|
||||
if (!use_single_axis || !use_y) {
|
||||
control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false);
|
||||
if (!use_single_axis || use_y)
|
||||
}
|
||||
if (!use_single_axis || use_y) {
|
||||
control->set_anchor(MARGIN_TOP, new_anchor.y, false, false);
|
||||
}
|
||||
break;
|
||||
case DRAG_ANCHOR_BOTTOM_RIGHT:
|
||||
if (!use_single_axis || !use_y)
|
||||
if (!use_single_axis || !use_y) {
|
||||
control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false);
|
||||
if (!use_single_axis || use_y)
|
||||
}
|
||||
if (!use_single_axis || use_y) {
|
||||
control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false);
|
||||
}
|
||||
break;
|
||||
case DRAG_ANCHOR_BOTTOM_LEFT:
|
||||
if (!use_single_axis || !use_y)
|
||||
if (!use_single_axis || !use_y) {
|
||||
control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false);
|
||||
if (!use_single_axis || use_y)
|
||||
}
|
||||
if (!use_single_axis || use_y) {
|
||||
control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false);
|
||||
}
|
||||
break;
|
||||
case DRAG_ANCHOR_ALL:
|
||||
if (!use_single_axis || !use_y) {
|
||||
@@ -1710,13 +1743,15 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
|
||||
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
|
||||
ofs *= (select_handle->get_size().width / 2);
|
||||
ofs += endpoints[i];
|
||||
if (ofs.distance_to(b->get_position()) < radius)
|
||||
if (ofs.distance_to(b->get_position()) < radius) {
|
||||
resize_drag = dragger[i * 2];
|
||||
}
|
||||
|
||||
ofs = (endpoints[i] + endpoints[next]) / 2;
|
||||
ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
|
||||
if (ofs.distance_to(b->get_position()) < radius)
|
||||
if (ofs.distance_to(b->get_position()) < radius) {
|
||||
resize_drag = dragger[i * 2 + 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (resize_drag != DRAG_NONE) {
|
||||
@@ -2141,20 +2176,23 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
||||
bool move_local_base_rotated = k->get_control() || k->get_metakey();
|
||||
|
||||
Vector2 dir;
|
||||
if (k->get_keycode() == KEY_UP)
|
||||
if (k->get_keycode() == KEY_UP) {
|
||||
dir += Vector2(0, -1);
|
||||
else if (k->get_keycode() == KEY_DOWN)
|
||||
} else if (k->get_keycode() == KEY_DOWN) {
|
||||
dir += Vector2(0, 1);
|
||||
else if (k->get_keycode() == KEY_LEFT)
|
||||
} else if (k->get_keycode() == KEY_LEFT) {
|
||||
dir += Vector2(-1, 0);
|
||||
else if (k->get_keycode() == KEY_RIGHT)
|
||||
} else if (k->get_keycode() == KEY_RIGHT) {
|
||||
dir += Vector2(1, 0);
|
||||
if (k->get_shift())
|
||||
}
|
||||
if (k->get_shift()) {
|
||||
dir *= grid_step * Math::pow(2.0, grid_step_multiplier);
|
||||
}
|
||||
|
||||
drag_to += dir;
|
||||
if (k->get_shift())
|
||||
if (k->get_shift()) {
|
||||
drag_to = drag_to.snapped(grid_step * Math::pow(2.0, grid_step_multiplier));
|
||||
}
|
||||
|
||||
Point2 previous_pos;
|
||||
if (drag_selection.size() == 1) {
|
||||
@@ -2293,8 +2331,9 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
||||
Point2 click = transform.affine_inverse().xform(b->get_position());
|
||||
|
||||
Node *scene = editor->get_edited_scene();
|
||||
if (!scene)
|
||||
if (!scene) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Find the item to select
|
||||
CanvasItem *canvas_item = nullptr;
|
||||
@@ -2362,10 +2401,12 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
||||
|
||||
Point2 bsfrom = drag_from;
|
||||
Point2 bsto = box_selecting_to;
|
||||
if (bsfrom.x > bsto.x)
|
||||
if (bsfrom.x > bsto.x) {
|
||||
SWAP(bsfrom.x, bsto.x);
|
||||
if (bsfrom.y > bsto.y)
|
||||
}
|
||||
if (bsfrom.y > bsto.y) {
|
||||
SWAP(bsfrom.y, bsto.y);
|
||||
}
|
||||
|
||||
_find_canvas_items_in_rect(Rect2(bsfrom, bsto - bsfrom), scene, &selitems);
|
||||
for (List<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) {
|
||||
@@ -2402,15 +2443,17 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
|
||||
bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
|
||||
if (tool != TOOL_RULER)
|
||||
if (tool != TOOL_RULER) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Ref<InputEventMouseButton> b = p_event;
|
||||
Ref<InputEventMouseMotion> m = p_event;
|
||||
|
||||
Point2 previous_origin = ruler_tool_origin;
|
||||
if (!ruler_tool_active)
|
||||
if (!ruler_tool_active) {
|
||||
ruler_tool_origin = snap_point(viewport->get_local_mouse_position() / zoom + view_offset);
|
||||
}
|
||||
|
||||
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT) {
|
||||
if (b->is_pressed()) {
|
||||
@@ -2446,8 +2489,9 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) {
|
||||
for (int i = 0; i < hovering_results_items.size(); i++) {
|
||||
CanvasItem *canvas_item = hovering_results_items[i].item;
|
||||
|
||||
if (canvas_item->_edit_use_rect())
|
||||
if (canvas_item->_edit_use_rect()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
_HoverResult hover_result;
|
||||
hover_result.position = canvas_item->get_global_transform_with_canvas().get_origin();
|
||||
@@ -2516,8 +2560,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
|
||||
|
||||
accepted = (_gui_input_zoom_or_pan(p_event, accepted) || accepted);
|
||||
|
||||
if (accepted)
|
||||
if (accepted) {
|
||||
accept_event();
|
||||
}
|
||||
|
||||
// Handles the mouse hovering
|
||||
_gui_input_hover(p_event);
|
||||
@@ -2569,10 +2614,11 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_hovering_h_guide)
|
||||
if (is_hovering_h_guide) {
|
||||
c = CURSOR_VSIZE;
|
||||
else if (is_hovering_v_guide)
|
||||
} else if (is_hovering_v_guide) {
|
||||
c = CURSOR_HSIZE;
|
||||
}
|
||||
|
||||
viewport->set_default_cursor_shape(c);
|
||||
|
||||
@@ -2633,8 +2679,9 @@ void CanvasItemEditor::_draw_guides() {
|
||||
if (EditorNode::get_singleton()->get_edited_scene() && EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_vertical_guides_")) {
|
||||
Array vguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_vertical_guides_");
|
||||
for (int i = 0; i < vguides.size(); i++) {
|
||||
if (drag_type == DRAG_V_GUIDE && i == dragged_guide_index)
|
||||
if (drag_type == DRAG_V_GUIDE && i == dragged_guide_index) {
|
||||
continue;
|
||||
}
|
||||
float x = xform.xform(Point2(vguides[i], 0)).x;
|
||||
viewport->draw_line(Point2(x, 0), Point2(x, viewport->get_size().y), guide_color, Math::round(EDSCALE));
|
||||
}
|
||||
@@ -2643,8 +2690,9 @@ void CanvasItemEditor::_draw_guides() {
|
||||
if (EditorNode::get_singleton()->get_edited_scene() && EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_horizontal_guides_")) {
|
||||
Array hguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_horizontal_guides_");
|
||||
for (int i = 0; i < hguides.size(); i++) {
|
||||
if (drag_type == DRAG_H_GUIDE && i == dragged_guide_index)
|
||||
if (drag_type == DRAG_H_GUIDE && i == dragged_guide_index) {
|
||||
continue;
|
||||
}
|
||||
float y = xform.xform(Point2(0, hguides[i])).y;
|
||||
viewport->draw_line(Point2(0, y), Point2(viewport->get_size().x, y), guide_color, Math::round(EDSCALE));
|
||||
}
|
||||
@@ -2844,8 +2892,9 @@ void CanvasItemEditor::_draw_grid() {
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_draw_ruler_tool() {
|
||||
if (tool != TOOL_RULER)
|
||||
if (tool != TOOL_RULER) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ruler_tool_active) {
|
||||
Color ruler_primary_color = get_theme_color("accent_color", "Editor");
|
||||
@@ -3463,12 +3512,14 @@ void CanvasItemEditor::_draw_bones() {
|
||||
for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
|
||||
Vector<Vector2> bone_shape;
|
||||
Vector<Vector2> bone_shape_outline;
|
||||
if (!_get_bone_shape(&bone_shape, &bone_shape_outline, E))
|
||||
if (!_get_bone_shape(&bone_shape, &bone_shape_outline, E)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from));
|
||||
if (!from_node->is_visible_in_tree())
|
||||
if (!from_node->is_visible_in_tree()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector<Color> colors;
|
||||
if (from_node->has_meta("_edit_ik_")) {
|
||||
@@ -3511,11 +3562,13 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
|
||||
ERR_FAIL_COND(!p_node);
|
||||
|
||||
Node *scene = editor->get_edited_scene();
|
||||
if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner()))
|
||||
if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) {
|
||||
return;
|
||||
}
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
|
||||
if (canvas_item && !canvas_item->is_visible())
|
||||
if (canvas_item && !canvas_item->is_visible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D parent_xform = p_parent_xform;
|
||||
Transform2D canvas_xform = p_canvas_xform;
|
||||
@@ -3578,11 +3631,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
|
||||
ERR_FAIL_COND(!p_node);
|
||||
|
||||
Node *scene = editor->get_edited_scene();
|
||||
if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner()))
|
||||
if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) {
|
||||
return;
|
||||
}
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
|
||||
if (canvas_item && !canvas_item->is_visible())
|
||||
if (canvas_item && !canvas_item->is_visible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Transform2D parent_xform = p_parent_xform;
|
||||
Transform2D canvas_xform = p_canvas_xform;
|
||||
@@ -3743,10 +3798,12 @@ void CanvasItemEditor::_draw_viewport() {
|
||||
}
|
||||
|
||||
_draw_bones();
|
||||
if (show_rulers)
|
||||
if (show_rulers) {
|
||||
_draw_rulers();
|
||||
if (show_guides)
|
||||
}
|
||||
if (show_guides) {
|
||||
_draw_guides();
|
||||
}
|
||||
_draw_smart_snapping();
|
||||
_draw_focus();
|
||||
_draw_hover();
|
||||
@@ -3993,10 +4050,12 @@ void CanvasItemEditor::_selection_changed() {
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
Control *control = Object::cast_to<Control>(E->get());
|
||||
if (!control)
|
||||
if (!control) {
|
||||
continue;
|
||||
if (Object::cast_to<Container>(control->get_parent()))
|
||||
}
|
||||
if (Object::cast_to<Container>(control->get_parent())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nbValidControls++;
|
||||
if (control->has_meta("_edit_use_anchors_") && control->get_meta("_edit_use_anchors_")) {
|
||||
@@ -4024,8 +4083,9 @@ void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_queue_update_bone_list() {
|
||||
if (bone_list_dirty)
|
||||
if (bone_list_dirty) {
|
||||
return;
|
||||
}
|
||||
|
||||
call_deferred("_update_bone_list");
|
||||
bone_list_dirty = true;
|
||||
@@ -4180,8 +4240,9 @@ void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const floa
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_update_scroll(float) {
|
||||
if (updating_scroll)
|
||||
if (updating_scroll) {
|
||||
return;
|
||||
}
|
||||
|
||||
view_offset.x = h_scroll->get_value();
|
||||
view_offset.y = v_scroll->get_value();
|
||||
@@ -4273,8 +4334,9 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) {
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_zoom_on_position(float p_zoom, Point2 p_position) {
|
||||
if (p_zoom < MIN_ZOOM || p_zoom > MAX_ZOOM)
|
||||
if (p_zoom < MIN_ZOOM || p_zoom > MAX_ZOOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
float prev_zoom = zoom;
|
||||
zoom = p_zoom;
|
||||
@@ -4360,21 +4422,26 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation,
|
||||
|
||||
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
|
||||
if (!canvas_item || !canvas_item->is_visible_in_tree())
|
||||
if (!canvas_item || !canvas_item->is_visible_in_tree()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Object::cast_to<Node2D>(canvas_item)) {
|
||||
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
|
||||
|
||||
if (key_pos && p_location)
|
||||
if (key_pos && p_location) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), p_on_existing);
|
||||
if (key_rot && p_rotation)
|
||||
}
|
||||
if (key_rot && p_rotation) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "rotation_degrees", Math::rad2deg(n2d->get_rotation()), p_on_existing);
|
||||
if (key_scale && p_scale)
|
||||
}
|
||||
if (key_scale && p_scale) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "scale", n2d->get_scale(), p_on_existing);
|
||||
}
|
||||
|
||||
if (n2d->has_meta("_edit_bone_") && n2d->get_parent_item()) {
|
||||
//look for an IK chain
|
||||
@@ -4390,19 +4457,23 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!n->get_parent_item())
|
||||
if (!n->get_parent_item()) {
|
||||
break;
|
||||
}
|
||||
n = Object::cast_to<Node2D>(n->get_parent_item());
|
||||
}
|
||||
|
||||
if (has_chain && ik_chain.size()) {
|
||||
for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) {
|
||||
if (key_pos)
|
||||
if (key_pos) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), p_on_existing);
|
||||
if (key_rot)
|
||||
}
|
||||
if (key_rot) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "rotation_degrees", Math::rad2deg(F->get()->get_rotation()), p_on_existing);
|
||||
if (key_scale)
|
||||
}
|
||||
if (key_scale) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), p_on_existing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4410,12 +4481,15 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation,
|
||||
} else if (Object::cast_to<Control>(canvas_item)) {
|
||||
Control *ctrl = Object::cast_to<Control>(canvas_item);
|
||||
|
||||
if (key_pos)
|
||||
if (key_pos) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), p_on_existing);
|
||||
if (key_rot)
|
||||
}
|
||||
if (key_rot) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_degrees(), p_on_existing);
|
||||
if (key_scale)
|
||||
}
|
||||
if (key_scale) {
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_size", ctrl->get_size(), p_on_existing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4424,8 +4498,9 @@ void CanvasItemEditor::_button_toggle_anchor_mode(bool p_status) {
|
||||
List<CanvasItem *> selection = _get_edited_canvas_items(false, false);
|
||||
for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
Control *control = Object::cast_to<Control>(E->get());
|
||||
if (!control || Object::cast_to<Container>(control->get_parent()))
|
||||
if (!control || Object::cast_to<Container>(control->get_parent())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
control->set_meta("_edit_use_anchors_", p_status);
|
||||
}
|
||||
@@ -4564,10 +4639,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
|
||||
if (!canvas_item || !canvas_item->is_inside_tree())
|
||||
if (!canvas_item || !canvas_item->is_inside_tree()) {
|
||||
continue;
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
}
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(canvas_item, "set_meta", "_edit_lock_", true);
|
||||
undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_lock_");
|
||||
@@ -4584,10 +4661,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
|
||||
if (!canvas_item || !canvas_item->is_inside_tree())
|
||||
if (!canvas_item || !canvas_item->is_inside_tree()) {
|
||||
continue;
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
}
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_lock_");
|
||||
undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_lock_", true);
|
||||
@@ -4604,10 +4683,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
|
||||
if (!canvas_item || !canvas_item->is_inside_tree())
|
||||
if (!canvas_item || !canvas_item->is_inside_tree()) {
|
||||
continue;
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
}
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(canvas_item, "set_meta", "_edit_group_", true);
|
||||
undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_group_");
|
||||
@@ -4624,10 +4705,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
|
||||
if (!canvas_item || !canvas_item->is_inside_tree())
|
||||
if (!canvas_item || !canvas_item->is_inside_tree()) {
|
||||
continue;
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
}
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_group_");
|
||||
undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_group_", true);
|
||||
@@ -4762,11 +4845,13 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
|
||||
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
|
||||
if (!canvas_item || !canvas_item->is_visible_in_tree())
|
||||
if (!canvas_item || !canvas_item->is_visible_in_tree()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Object::cast_to<Node2D>(canvas_item)) {
|
||||
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
|
||||
@@ -4781,14 +4866,16 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
|
||||
} break;
|
||||
case ANIM_PASTE_POSE: {
|
||||
if (!pose_clipboard.size())
|
||||
if (!pose_clipboard.size()) {
|
||||
break;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("Paste Pose"));
|
||||
for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) {
|
||||
Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id));
|
||||
if (!n2d)
|
||||
if (!n2d) {
|
||||
continue;
|
||||
}
|
||||
undo_redo->add_do_method(n2d, "set_position", E->get().pos);
|
||||
undo_redo->add_do_method(n2d, "set_rotation", E->get().rot);
|
||||
undo_redo->add_do_method(n2d, "set_scale", E->get().scale);
|
||||
@@ -4804,26 +4891,32 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
|
||||
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
|
||||
if (!canvas_item || !canvas_item->is_visible_in_tree())
|
||||
if (!canvas_item || !canvas_item->is_visible_in_tree()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Object::cast_to<Node2D>(canvas_item)) {
|
||||
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
|
||||
|
||||
if (key_pos)
|
||||
if (key_pos) {
|
||||
n2d->set_position(Vector2());
|
||||
if (key_rot)
|
||||
}
|
||||
if (key_rot) {
|
||||
n2d->set_rotation(0);
|
||||
if (key_scale)
|
||||
}
|
||||
if (key_scale) {
|
||||
n2d->set_scale(Vector2(1, 1));
|
||||
}
|
||||
} else if (Object::cast_to<Control>(canvas_item)) {
|
||||
Control *ctrl = Object::cast_to<Control>(canvas_item);
|
||||
|
||||
if (key_pos)
|
||||
if (key_pos) {
|
||||
ctrl->set_position(Point2());
|
||||
}
|
||||
/*
|
||||
if (key_scale)
|
||||
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size());
|
||||
@@ -4872,14 +4965,18 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
undo_redo->create_action(TTR("Create Custom Bone(s) from Node(s)"));
|
||||
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
Node2D *n2d = Object::cast_to<Node2D>(E->key());
|
||||
if (!n2d)
|
||||
if (!n2d) {
|
||||
continue;
|
||||
if (!n2d->is_visible_in_tree())
|
||||
}
|
||||
if (!n2d->is_visible_in_tree()) {
|
||||
continue;
|
||||
if (!n2d->get_parent_item())
|
||||
}
|
||||
if (!n2d->get_parent_item()) {
|
||||
continue;
|
||||
if (n2d->has_meta("_edit_bone_") && n2d->get_meta("_edit_bone_"))
|
||||
}
|
||||
if (n2d->has_meta("_edit_bone_") && n2d->get_meta("_edit_bone_")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(n2d, "set_meta", "_edit_bone_", true);
|
||||
undo_redo->add_undo_method(n2d, "remove_meta", "_edit_bone_");
|
||||
@@ -4897,12 +4994,15 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
undo_redo->create_action(TTR("Clear Bones"));
|
||||
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
Node2D *n2d = Object::cast_to<Node2D>(E->key());
|
||||
if (!n2d)
|
||||
if (!n2d) {
|
||||
continue;
|
||||
if (!n2d->is_visible_in_tree())
|
||||
}
|
||||
if (!n2d->is_visible_in_tree()) {
|
||||
continue;
|
||||
if (!n2d->has_meta("_edit_bone_"))
|
||||
}
|
||||
if (!n2d->has_meta("_edit_bone_")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(n2d, "remove_meta", "_edit_bone_");
|
||||
undo_redo->add_undo_method(n2d, "set_meta", "_edit_bone_", n2d->get_meta("_edit_bone_"));
|
||||
@@ -4920,12 +5020,15 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
undo_redo->create_action(TTR("Make IK Chain"));
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
|
||||
if (!canvas_item || !canvas_item->is_visible_in_tree())
|
||||
if (!canvas_item || !canvas_item->is_visible_in_tree()) {
|
||||
continue;
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
}
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
if (canvas_item->has_meta("_edit_ik_") && canvas_item->get_meta("_edit_ik_"))
|
||||
}
|
||||
if (canvas_item->has_meta("_edit_ik_") && canvas_item->get_meta("_edit_ik_")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(canvas_item, "set_meta", "_edit_ik_", true);
|
||||
undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_ik_");
|
||||
@@ -4941,12 +5044,15 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
undo_redo->create_action(TTR("Clear IK Chain"));
|
||||
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *n2d = Object::cast_to<CanvasItem>(E->key());
|
||||
if (!n2d)
|
||||
if (!n2d) {
|
||||
continue;
|
||||
if (!n2d->is_visible_in_tree())
|
||||
}
|
||||
if (!n2d->is_visible_in_tree()) {
|
||||
continue;
|
||||
if (!n2d->has_meta("_edit_ik_"))
|
||||
}
|
||||
if (!n2d->has_meta("_edit_ik_")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(n2d, "remove_meta", "_edit_ik_");
|
||||
undo_redo->add_undo_method(n2d, "set_meta", "_edit_ik_", n2d->get_meta("_edit_ik_"));
|
||||
@@ -4967,10 +5073,12 @@ void CanvasItemEditor::_focus_selection(int p_op) {
|
||||
Map<Node *, Object *> &selection = editor_selection->get_selection();
|
||||
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
|
||||
if (!canvas_item)
|
||||
if (!canvas_item) {
|
||||
continue;
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
|
||||
}
|
||||
if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// counting invisible items, for now
|
||||
//if (!canvas_item->is_visible_in_tree()) continue;
|
||||
@@ -4996,8 +5104,9 @@ void CanvasItemEditor::_focus_selection(int p_op) {
|
||||
rect = rect.merge(canvas_item_rect);
|
||||
}
|
||||
};
|
||||
if (count == 0)
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_op == VIEW_CENTER_TO_SELECTION) {
|
||||
center = rect.position + rect.size / 2;
|
||||
@@ -5794,8 +5903,9 @@ void CanvasItemEditorViewport::_on_select_type(Object *selected) {
|
||||
}
|
||||
|
||||
void CanvasItemEditorViewport::_on_change_type_confirmed() {
|
||||
if (!button_group->get_pressed_button())
|
||||
if (!button_group->get_pressed_button()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox *check = Object::cast_to<CheckBox>(button_group->get_pressed_button());
|
||||
default_type = check->get_text();
|
||||
@@ -5835,8 +5945,9 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
|
||||
}
|
||||
}
|
||||
|
||||
if (add_preview)
|
||||
if (add_preview) {
|
||||
editor->get_scene_root()->add_child(preview_node);
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItemEditorViewport::_remove_preview() {
|
||||
@@ -6010,20 +6121,21 @@ void CanvasItemEditorViewport::_perform_drop_data() {
|
||||
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
|
||||
if (texture != nullptr && texture.is_valid()) {
|
||||
Node *child;
|
||||
if (default_type == "Light2D")
|
||||
if (default_type == "Light2D") {
|
||||
child = memnew(Light2D);
|
||||
else if (default_type == "GPUParticles2D")
|
||||
} else if (default_type == "GPUParticles2D") {
|
||||
child = memnew(GPUParticles2D);
|
||||
else if (default_type == "Polygon2D")
|
||||
} else if (default_type == "Polygon2D") {
|
||||
child = memnew(Polygon2D);
|
||||
else if (default_type == "TouchScreenButton")
|
||||
} else if (default_type == "TouchScreenButton") {
|
||||
child = memnew(TouchScreenButton);
|
||||
else if (default_type == "TextureRect")
|
||||
} else if (default_type == "TextureRect") {
|
||||
child = memnew(TextureRect);
|
||||
else if (default_type == "NinePatchRect")
|
||||
} else if (default_type == "NinePatchRect") {
|
||||
child = memnew(NinePatchRect);
|
||||
else
|
||||
} else {
|
||||
child = memnew(Sprite2D); // default
|
||||
}
|
||||
|
||||
_create_nodes(target_node, child, path, drop_pos);
|
||||
}
|
||||
@@ -6127,8 +6239,9 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
|
||||
if (d.has("type") && String(d["type"]) == "files") {
|
||||
selected_files = d["files"];
|
||||
}
|
||||
if (selected_files.size() == 0)
|
||||
if (selected_files.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
|
||||
if (list.size() == 0) {
|
||||
|
||||
Reference in New Issue
Block a user