diff options
Diffstat (limited to 'editor')
83 files changed, 1370 insertions, 1383 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 3b87b3e65e..604758300d 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -338,14 +338,14 @@ void AnimationBezierTrackEdit::_notification(int p_what) { Ref<Texture2D> unlock = get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons")); float lock_hpos = remove_hpos - hsep - lock->get_width(); - Ref<Texture2D> visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")); - Ref<Texture2D> hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")); - float visibility_hpos = lock_hpos - hsep - visible->get_width(); + Ref<Texture2D> visibility_visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")); + Ref<Texture2D> visibility_hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")); + float visibility_hpos = lock_hpos - hsep - visibility_visible->get_width(); Ref<Texture2D> solo = get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons")); float solo_hpos = visibility_hpos - hsep - solo->get_width(); - float buttons_width = remove->get_width() + lock->get_width() + visible->get_width() + solo->get_width() + hsep * 3; + float buttons_width = remove->get_width() + lock->get_width() + visibility_visible->get_width() + solo->get_width() + hsep * 3; for (int i = 0; i < tracks.size(); ++i) { // RELATED TRACKS TITLES @@ -418,11 +418,11 @@ void AnimationBezierTrackEdit::_notification(int p_what) { draw_texture(unlock, lock_rect.position); } - Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visible->get_height() / 2.0, visible->get_width(), visible->get_height()); + Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visibility_visible->get_height() / 2.0, visibility_visible->get_width(), visibility_visible->get_height()); if (hidden_tracks.has(current_track)) { - draw_texture(hidden, visible_rect.position); + draw_texture(visibility_hidden, visible_rect.position); } else { - draw_texture(visible, visible_rect.position); + draw_texture(visibility_visible, visible_rect.position); } Rect2 solo_rect = Rect2(solo_hpos, icon_start_height - solo->get_height() / 2.0, solo->get_width(), solo->get_height()); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 9529460ab1..1d13972458 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2029,14 +2029,14 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(check, check_rect.position); ofs += check->get_width() + hsep; - Ref<Texture2D> type_icon = _get_key_type_icon(); - draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2)); - ofs += type_icon->get_width() + hsep; + Ref<Texture2D> key_type_icon = _get_key_type_icon(); + draw_texture(key_type_icon, Point2(ofs, int(get_size().height - key_type_icon->get_height()) / 2)); + ofs += key_type_icon->get_width() + hsep; - NodePath path = animation->track_get_path(track); + NodePath anim_path = animation->track_get_path(track); Node *node = nullptr; - if (root && root->has_node(path)) { - node = root->get_node(path); + if (root && root->has_node(anim_path)) { + node = root->get_node(anim_path); } String text; @@ -2053,7 +2053,7 @@ void AnimationTrackEdit::_notification(int p_what) { } else if (animation->track_get_type(track) == Animation::TYPE_ANIMATION) { text = TTR("Anim Clips:"); } else { - text += path.get_concatenated_subnames(); + text += anim_path.get_concatenated_subnames(); } text_color.a *= 0.7; } else if (node) { @@ -2062,14 +2062,14 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2)); icon_cache = icon; - text = String() + node->get_name() + ":" + path.get_concatenated_subnames(); + text = String() + node->get_name() + ":" + anim_path.get_concatenated_subnames(); ofs += hsep; ofs += icon->get_width(); } else { - icon_cache = type_icon; + icon_cache = key_type_icon; - text = path; + text = anim_path; } path_cache = text; @@ -2853,9 +2853,9 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (ape) { AnimationPlayer *ap = ape->get_player(); if (ap) { - NodePath path = animation->track_get_path(track); - Node *nd = ap->get_node(ap->get_root())->get_node(NodePath(path.get_concatenated_names())); - StringName prop = path.get_concatenated_subnames(); + NodePath npath = animation->track_get_path(track); + Node *nd = ap->get_node(ap->get_root())->get_node(NodePath(npath.get_concatenated_names())); + StringName prop = npath.get_concatenated_subnames(); PropertyInfo prop_info; ClassDB::get_property_info(nd->get_class(), prop, &prop_info); bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians") != -1; @@ -4463,24 +4463,24 @@ void AnimationTrackEditor::_update_tracks() { return; } - bool read_only = false; + bool file_read_only = false; if (!animation->get_path().is_resource_file()) { int srpos = animation->get_path().find("::"); if (srpos != -1) { String base = animation->get_path().substr(0, srpos); if (ResourceLoader::get_resource_type(base) == "PackedScene") { if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { - read_only = true; + file_read_only = true; } } else { if (FileAccess::exists(base + ".import")) { - read_only = true; + file_read_only = true; } } } } else { if (FileAccess::exists(animation->get_path() + ".import")) { - read_only = true; + file_read_only = true; } } @@ -4612,7 +4612,7 @@ void AnimationTrackEditor::_update_tracks() { track_edit->set_undo_redo(undo_redo); track_edit->set_timeline(timeline); track_edit->set_root(root); - track_edit->set_animation_and_track(animation, i, read_only); + track_edit->set_animation_and_track(animation, i, file_read_only); track_edit->set_play_position(timeline->get_play_position()); track_edit->set_editor(this); @@ -5072,10 +5072,8 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { return; } - Vector3 scale = base->get_scale(); - undo_redo->create_action(TTR("Add Scale Key")); - undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, scale); + undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, base->get_scale()); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs); undo_redo->commit_action(); @@ -5671,18 +5669,18 @@ void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) { if (animation.is_null()) { return; } - float step = animation->get_step(); - if (step == 0) { - step = 1; + float anim_step = animation->get_step(); + if (anim_step == 0) { + anim_step = 1; } if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(Key::SHIFT)) { // Use more precise snapping when holding Shift. // This is used when scrobbling the timeline using Alt + Mouse wheel. - step *= 0.25; + anim_step *= 0.25; } float pos = timeline->get_play_position(); - pos = Math::snapped(pos - step, step); + pos = Math::snapped(pos - anim_step, anim_step); if (pos < 0) { pos = 0; } @@ -5694,21 +5692,21 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeli if (animation.is_null()) { return; } - float step = animation->get_step(); - if (step == 0) { - step = 1; + float anim_step = animation->get_step(); + if (anim_step == 0) { + anim_step = 1; } if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(Key::SHIFT)) { // Use more precise snapping when holding Shift. // This is used when scrobbling the timeline using Alt + Mouse wheel. // Do not use precise snapping when using the menu action or keyboard shortcut, // as the default keyboard shortcut requires pressing Shift. - step *= 0.25; + anim_step *= 0.25; } float pos = timeline->get_play_position(); - pos = Math::snapped(pos + step, step); + pos = Math::snapped(pos + anim_step, anim_step); if (pos > animation->get_length()) { pos = animation->get_length(); } @@ -5801,9 +5799,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case EDIT_COPY_TRACKS_CONFIRM: { track_clipboard.clear(); - TreeItem *root = track_copy_select->get_root(); - if (root) { - TreeItem *it = root->get_first_child(); + TreeItem *tree_root = track_copy_select->get_root(); + if (tree_root) { + TreeItem *it = tree_root->get_first_child(); while (it) { Dictionary md = it->get_metadata(0); int idx = md["track_idx"]; @@ -6037,7 +6035,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { bool is_using_angle = animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_LINEAR_ANGLE || animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_CUBIC_ANGLE; // Make insert queue. - Vector<Pair<real_t, Variant>> insert_queue; + Vector<Pair<real_t, Variant>> insert_queue_new; for (int i = 0; i < len; i++) { // Check neighboring keys. if (keys[i] + 1 == keys[i + 1]) { @@ -6058,15 +6056,15 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Pair<real_t, Variant> keydata; keydata.first = from_t + delta_t; keydata.second = Tween::interpolate_variant(from_v, delta_v, delta_t, duration, transition_type, ease_type); - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } } // Do insertion. - for (int i = 0; i < insert_queue.size(); i++) { - undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, insert_queue[i].first, insert_queue[i].second); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, insert_queue[i].first); + for (int i = 0; i < insert_queue_new.size(); i++) { + undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, insert_queue_new[i].first, insert_queue_new[i].second); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, insert_queue_new[i].first); } ++E; @@ -6213,7 +6211,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { bool is_using_angle = it == Animation::INTERPOLATION_LINEAR_ANGLE || it == Animation::INTERPOLATION_CUBIC_ANGLE; // Make insert queue. - Vector<Pair<real_t, Variant>> insert_queue; + Vector<Pair<real_t, Variant>> insert_queue_new; switch (type) { case Animation::TYPE_POSITION_3D: { @@ -6223,7 +6221,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Vector3 v; animation->position_track_interpolate(i, delta_t, &v); keydata.second = v; - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; case Animation::TYPE_ROTATION_3D: { @@ -6233,7 +6231,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Quaternion v; animation->rotation_track_interpolate(i, delta_t, &v); keydata.second = v; - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; case Animation::TYPE_SCALE_3D: { @@ -6243,7 +6241,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Vector3 v; animation->scale_track_interpolate(i, delta_t, &v); keydata.second = v; - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; case Animation::TYPE_BLEND_SHAPE: { @@ -6253,7 +6251,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { float v; animation->blend_shape_track_interpolate(i, delta_t, &v); keydata.second = v; - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; case Animation::TYPE_VALUE: { @@ -6261,7 +6259,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Pair<real_t, Variant> keydata; keydata.first = delta_t; keydata.second = animation->value_track_interpolate(i, delta_t); - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; default: { @@ -6276,9 +6274,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { // Insert keys. undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", i, is_using_angle ? Animation::INTERPOLATION_LINEAR_ANGLE : Animation::INTERPOLATION_LINEAR); - for (int j = insert_queue.size() - 1; j >= 0; j--) { - undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue[j].first, insert_queue[j].second); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue[j].first); + for (int j = insert_queue_new.size() - 1; j >= 0; j--) { + undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue_new[j].first, insert_queue_new[j].second); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue_new[j].first); } // Undo methods. @@ -6925,19 +6923,19 @@ AnimationTrackEditor::AnimationTrackEditor() { track_copy_dialog->set_title(TTR("Select Tracks to Copy")); track_copy_dialog->set_ok_button_text(TTR("Copy")); - VBoxContainer *track_vbox = memnew(VBoxContainer); - track_copy_dialog->add_child(track_vbox); + VBoxContainer *track_copy_vbox = memnew(VBoxContainer); + track_copy_dialog->add_child(track_copy_vbox); Button *select_all_button = memnew(Button); select_all_button->set_text(TTR("Select All/None")); select_all_button->connect("pressed", callable_mp(this, &AnimationTrackEditor::_select_all_tracks_for_copy)); - track_vbox->add_child(select_all_button); + track_copy_vbox->add_child(select_all_button); track_copy_select = memnew(Tree); track_copy_select->set_h_size_flags(SIZE_EXPAND_FILL); track_copy_select->set_v_size_flags(SIZE_EXPAND_FILL); track_copy_select->set_hide_root(true); - track_vbox->add_child(track_copy_select); + track_copy_vbox->add_child(track_copy_select); track_copy_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed).bind(EDIT_COPY_TRACKS_CONFIRM)); } diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 6499cf8df2..971b671a0c 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -412,9 +412,9 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se sf->get_animation_list(&animations); int frame = get_animation()->track_get_key_value(get_track(), p_index); - String animation; + String animation_name; if (animations.size() == 1) { - animation = animations.front()->get(); + animation_name = animations.front()->get(); } else { // Go through other track to find if animation is set String animation_path = get_animation()->track_get_path(get_track()); @@ -422,10 +422,10 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track())); float track_time = get_animation()->track_get_key_time(get_track(), p_index); int animaiton_index = get_animation()->track_find_key(animation_track, track_time); - animation = get_animation()->track_get_key_value(animation_track, animaiton_index); + animation_name = get_animation()->track_get_key_value(animation_track, animaiton_index); } - Ref<Texture2D> texture = sf->get_frame(animation, frame); + Ref<Texture2D> texture = sf->get_frame(animation_name, frame); if (!texture.is_valid()) { return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec); } @@ -504,9 +504,9 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in sf->get_animation_list(&animations); int frame = get_animation()->track_get_key_value(get_track(), p_index); - String animation; + String animation_name; if (animations.size() == 1) { - animation = animations.front()->get(); + animation_name = animations.front()->get(); } else { // Go through other track to find if animation is set String animation_path = get_animation()->track_get_path(get_track()); @@ -514,10 +514,10 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track())); float track_time = get_animation()->track_get_key_time(get_track(), p_index); int animaiton_index = get_animation()->track_find_key(animation_track, track_time); - animation = get_animation()->track_get_key_value(animation_track, animaiton_index); + animation_name = get_animation()->track_get_key_value(animation_track, animaiton_index); } - texture = sf->get_frame(animation, frame); + texture = sf->get_frame(animation_name, frame); if (!texture.is_valid()) { AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right); return; @@ -670,15 +670,15 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ Vector<Vector2> lines; Vector<Color> colorv; { - Ref<Animation> animation = ap->get_animation(anim); + Ref<Animation> ap_anim = ap->get_animation(anim); - for (int i = 0; i < animation->get_track_count(); i++) { - float h = (rect.size.height - 2) / animation->get_track_count(); + for (int i = 0; i < ap_anim->get_track_count(); i++) { + float h = (rect.size.height - 2) / ap_anim->get_track_count(); int y = 2 + h * i + h / 2; - for (int j = 0; j < animation->track_get_key_count(i); j++) { - float ofs = animation->track_get_key_time(i, j); + for (int j = 0; j < ap_anim->track_get_key_count(i); j++) { + float ofs = ap_anim->track_get_key_time(i, j); int x = p_x + ofs * p_pixels_sec + 2; if (x < from_x || x >= (to_x - 4)) { @@ -1244,15 +1244,15 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, Vector<Vector2> lines; Vector<Color> colorv; { - Ref<Animation> animation = ap->get_animation(anim); + Ref<Animation> ap_anim = ap->get_animation(anim); - for (int i = 0; i < animation->get_track_count(); i++) { - float h = (rect.size.height - 2) / animation->get_track_count(); + for (int i = 0; i < ap_anim->get_track_count(); i++) { + float h = (rect.size.height - 2) / ap_anim->get_track_count(); int y = 2 + h * i + h / 2; - for (int j = 0; j < animation->track_get_key_count(i); j++) { - float ofs = animation->track_get_key_time(i, j); + for (int j = 0; j < ap_anim->track_get_key_count(i); j++) { + float ofs = ap_anim->track_get_key_time(i, j); int x = p_x + ofs * p_pixels_sec + 2; if (x < from_x || x >= (to_x - 4)) { diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index fe9831d0ef..b73b49a434 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -184,7 +184,7 @@ void FindReplaceBar::_replace() { selection_end = Point2i(text_editor->get_selection_to_line(0), text_editor->get_selection_to_column(0)); } - String replace_text = get_replace_text(); + String repl_text = get_replace_text(); int search_text_len = get_search_text().length(); text_editor->begin_complex_operation(); @@ -201,13 +201,13 @@ void FindReplaceBar::_replace() { Point2i match_from(result_line, result_col); Point2i match_to(result_line, result_col + search_text_len); if (!(match_from < selection_begin || match_to > selection_end)) { - text_editor->insert_text_at_caret(replace_text, 0); + text_editor->insert_text_at_caret(repl_text, 0); if (match_to.x == selection_end.x) { // Adjust selection bounds if necessary - selection_end.y += replace_text.length() - search_text_len; + selection_end.y += repl_text.length() - search_text_len; } } } else { - text_editor->insert_text_at_caret(replace_text, 0); + text_editor->insert_text_at_caret(repl_text, 0); } } text_editor->end_complex_operation(); @@ -241,7 +241,7 @@ void FindReplaceBar::_replace_all() { text_editor->set_caret_line(0, false, true, 0, 0); text_editor->set_caret_column(0, true, 0); - String replace_text = get_replace_text(); + String repl_text = get_replace_text(); int search_text_len = get_search_text().length(); int rc = 0; @@ -264,7 +264,7 @@ void FindReplaceBar::_replace_all() { break; // Done. } - prev_match = Point2i(result_line, result_col + replace_text.length()); + prev_match = Point2i(result_line, result_col + repl_text.length()); text_editor->unfold_line(result_line); text_editor->select(result_line, result_col, result_line, match_to.y, 0); @@ -275,14 +275,14 @@ void FindReplaceBar::_replace_all() { } // Replace but adjust selection bounds. - text_editor->insert_text_at_caret(replace_text, 0); + text_editor->insert_text_at_caret(repl_text, 0); if (match_to.x == selection_end.x) { - selection_end.y += replace_text.length() - search_text_len; + selection_end.y += repl_text.length() - search_text_len; } } else { // Just replace. - text_editor->insert_text_at_caret(replace_text, 0); + text_editor->insert_text_at_caret(repl_text, 0); } rc++; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index ddeb8643b8..258ce434f6 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -184,8 +184,8 @@ void ConnectDialog::_add_bind() { Variant::Type type = (Variant::Type)type_list->get_item_id(type_list->get_selected()); Variant value; - Callable::CallError error; - Variant::construct(type, value, nullptr, 0, error); + Callable::CallError err; + Variant::construct(type, value, nullptr, 0, err); cdbinds->params.push_back(value); cdbinds->notify_changed(); @@ -583,19 +583,19 @@ void ConnectionsDock::_make_or_edit_connection() { // Conditions to add function: must have a script and must not have the method already // (in the class, the script itself, or inherited). bool add_script_function = false; - Ref<Script> script = target->get_script(); - if (!target->get_script().is_null() && !ClassDB::has_method(target->get_class(), cd.method)) { + Ref<Script> scr = target->get_script(); + if (!scr.is_null() && !ClassDB::has_method(target->get_class(), cd.method)) { // There is a chance that the method is inherited from another script. bool found_inherited_function = false; - Ref<Script> inherited_script = script->get_base_script(); - while (!inherited_script.is_null()) { - int line = inherited_script->get_language()->find_function(cd.method, inherited_script->get_source_code()); + Ref<Script> inherited_scr = scr->get_base_script(); + while (!inherited_scr.is_null()) { + int line = inherited_scr->get_language()->find_function(cd.method, inherited_scr->get_source_code()); if (line != -1) { found_inherited_function = true; break; } - inherited_script = inherited_script->get_base_script(); + inherited_scr = inherited_scr->get_base_script(); } add_script_function = !found_inherited_function; @@ -816,13 +816,13 @@ void ConnectionsDock::_go_to_script(TreeItem &p_item) { return; } - Ref<Script> script = cd.target->get_script(); + Ref<Script> scr = cd.target->get_script(); - if (script.is_null()) { + if (scr.is_null()) { return; } - if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, cd.method)) { + if (scr.is_valid() && ScriptEditor::get_singleton()->script_goto_method(scr, cd.method)) { EditorNode::get_singleton()->editor_select(EditorNode::EDITOR_SCRIPT); } } @@ -1077,10 +1077,10 @@ void ConnectionsDock::update_tree() { } // List existing connections. - List<Object::Connection> connections; - selected_node->get_signal_connection_list(signal_name, &connections); + List<Object::Connection> existing_connections; + selected_node->get_signal_connection_list(signal_name, &existing_connections); - for (const Object::Connection &F : connections) { + for (const Object::Connection &F : existing_connections) { Connection connection = F; if (!(connection.flags & CONNECT_PERSIST)) { continue; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index a54d191a5b..ceca428306 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -213,18 +213,18 @@ void CreateDialog::_add_type(const String &p_type, const TypeCategory p_type_cat inherited_type = TypeCategory::CPP_TYPE; } else if (p_type_category == TypeCategory::PATH_TYPE) { ERR_FAIL_COND(!ResourceLoader::exists(p_type, "Script")); - Ref<Script> script = ResourceLoader::load(p_type, "Script"); - ERR_FAIL_COND(script.is_null()); + Ref<Script> scr = ResourceLoader::load(p_type, "Script"); + ERR_FAIL_COND(scr.is_null()); - Ref<Script> base = script->get_base_script(); + Ref<Script> base = scr->get_base_script(); if (base.is_null()) { String extends; - script->get_language()->get_global_class_name(script->get_path(), &extends); + scr->get_language()->get_global_class_name(scr->get_path(), &extends); inherits = extends; inherited_type = TypeCategory::CPP_TYPE; } else { - inherits = script->get_language()->get_global_class_name(base->get_path()); + inherits = scr->get_language()->get_global_class_name(base->get_path()); if (inherits.is_empty()) { inherits = base->get_path(); inherited_type = TypeCategory::PATH_TYPE; @@ -232,18 +232,18 @@ void CreateDialog::_add_type(const String &p_type, const TypeCategory p_type_cat } } else { if (ScriptServer::is_global_class(p_type)) { - Ref<Script> script = EditorNode::get_editor_data().script_class_load_script(p_type); - ERR_FAIL_COND(script.is_null()); + Ref<Script> scr = EditorNode::get_editor_data().script_class_load_script(p_type); + ERR_FAIL_COND(scr.is_null()); - Ref<Script> base = script->get_base_script(); + Ref<Script> base = scr->get_base_script(); if (base.is_null()) { String extends; - script->get_language()->get_global_class_name(script->get_path(), &extends); + scr->get_language()->get_global_class_name(scr->get_path(), &extends); inherits = extends; inherited_type = TypeCategory::CPP_TYPE; } else { - inherits = script->get_language()->get_global_class_name(base->get_path()); + inherits = scr->get_language()->get_global_class_name(base->get_path()); if (inherits.is_empty()) { inherits = base->get_path(); inherited_type = TypeCategory::PATH_TYPE; diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp index 4c445eb766..809c0c2cff 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp @@ -921,11 +921,11 @@ void DebugAdapterProtocol::on_debug_stack_frame_vars(const int &p_size) { ERR_FAIL_COND(!stackframe_list.has(frame)); List<int> scope_ids = stackframe_list.find(frame)->value; for (List<int>::Element *E = scope_ids.front(); E; E = E->next()) { - int variable_id = E->get(); - if (variable_list.has(variable_id)) { - variable_list.find(variable_id)->value.clear(); + int var_id = E->get(); + if (variable_list.has(var_id)) { + variable_list.find(var_id)->value.clear(); } else { - variable_list.insert(variable_id, Array()); + variable_list.insert(var_id, Array()); } } } @@ -941,7 +941,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) { List<int> scope_ids = stackframe_list.find(frame)->value; ERR_FAIL_COND(scope_ids.size() != 3); ERR_FAIL_INDEX(stack_var.type, 3); - int variable_id = scope_ids[stack_var.type]; + int var_id = scope_ids[stack_var.type]; DAP::Variable variable; @@ -950,7 +950,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) { variable.type = Variant::get_type_name(stack_var.value.get_type()); variable.variablesReference = parse_variant(stack_var.value); - variable_list.find(variable_id)->value.push_back(variable.to_json()); + variable_list.find(var_id)->value.push_back(variable.to_json()); _remaining_vars--; } diff --git a/editor/debugger/debug_adapter/debug_adapter_server.cpp b/editor/debugger/debug_adapter/debug_adapter_server.cpp index 41e6b1f308..37da64beae 100644 --- a/editor/debugger/debug_adapter/debug_adapter_server.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_server.cpp @@ -64,10 +64,10 @@ void DebugAdapterServer::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { protocol._request_timeout = EditorSettings::get_singleton()->get("network/debug_adapter/request_timeout"); protocol._sync_breakpoints = EditorSettings::get_singleton()->get("network/debug_adapter/sync_breakpoints"); - int remote_port = (int)_EDITOR_GET("network/debug_adapter/remote_port"); - if (remote_port != this->remote_port) { - this->stop(); - this->start(); + int port = (int)_EDITOR_GET("network/debug_adapter/remote_port"); + if (port != remote_port) { + stop(); + start(); } } break; } diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 7ea6cedd2b..371aaf8617 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -166,11 +166,11 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { if (pinfo.hint_string == "Script") { if (debug_obj->get_script() != var) { debug_obj->set_script(Ref<RefCounted>()); - Ref<Script> script(var); - if (!script.is_null()) { - ScriptInstance *script_instance = script->placeholder_instance_create(debug_obj); - if (script_instance) { - debug_obj->set_script_and_instance(var, script_instance); + Ref<Script> scr(var); + if (!scr.is_null()) { + ScriptInstance *scr_instance = scr->placeholder_instance_create(debug_obj); + if (scr_instance) { + debug_obj->set_script_and_instance(var, scr_instance); } } } diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 9fd7fa578f..06b73cf296 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -477,13 +477,10 @@ void EditorDebuggerNode::_menu_option(int p_id) { } void EditorDebuggerNode::_update_debug_options() { - bool keep_debugger_open = EditorSettings::get_singleton()->get_project_metadata("debug_options", "keep_debugger_open", false); - bool debug_with_external_editor = EditorSettings::get_singleton()->get_project_metadata("debug_options", "debug_with_external_editor", false); - - if (keep_debugger_open) { + if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "keep_debugger_open", false).operator bool()) { _menu_option(DEBUG_KEEP_DEBUGGER_OPEN); } - if (debug_with_external_editor) { + if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "debug_with_external_editor", false).operator bool()) { _menu_option(DEBUG_WITH_EXTERNAL_EDITOR); } } diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 10b50a81e4..e2fd462f3a 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -349,12 +349,12 @@ void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_name void EditorPerformanceProfiler::add_profile_frame(const Vector<float> &p_values) { for (KeyValue<StringName, Monitor> &E : monitors) { - float data = 0.0f; + float value = 0.0f; if (E.value.frame_index >= 0 && E.value.frame_index < p_values.size()) { - data = p_values[E.value.frame_index]; + value = p_values[E.value.frame_index]; } - E.value.history.push_front(data); - E.value.update_value(data); + E.value.history.push_front(value); + E.value.update_value(value); } marker_frame++; monitor_draw->queue_redraw(); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 622ad00502..f1fc1019b9 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -747,8 +747,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da if (element) { Callable &c = element->value; ERR_FAIL_COND_MSG(c.is_null(), "Invalid callable registered: " + cap); - Variant cmd = p_msg.substr(colon_index + 1), data = p_data; - const Variant *args[2] = { &cmd, &data }; + Variant cmd = p_msg.substr(colon_index + 1), cmd_data = p_data; + const Variant *args[2] = { &cmd, &cmd_data }; Variant retval; Callable::CallError err; c.callp(args, 2, retval, err); @@ -895,9 +895,9 @@ void ScriptEditorDebugger::_clear_execution() { } void ScriptEditorDebugger::_set_breakpoint(const String &p_file, const int &p_line, const bool &p_enabled) { - Ref<Script> script = ResourceLoader::load(p_file); - emit_signal(SNAME("set_breakpoint"), script, p_line - 1, p_enabled); - script.unref(); + Ref<Script> scr = ResourceLoader::load(p_file); + emit_signal(SNAME("set_breakpoint"), scr, p_line - 1, p_enabled); + scr.unref(); } void ScriptEditorDebugger::_clear_breakpoints() { @@ -979,15 +979,15 @@ void ScriptEditorDebugger::stop() { } void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) { - Array data; - data.push_back(p_enable); + Array msg_data; + msg_data.push_back(p_enable); switch (p_type) { case PROFILER_NETWORK: - _put_msg("profiler:multiplayer", data); - _put_msg("profiler:rpc", data); + _put_msg("profiler:multiplayer", msg_data); + _put_msg("profiler:rpc", msg_data); break; case PROFILER_VISUAL: - _put_msg("profiler:visual", data); + _put_msg("profiler:visual", msg_data); break; case PROFILER_SCRIPTS_SERVERS: if (p_enable) { @@ -997,9 +997,9 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) { Array opts; int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions"); opts.push_back(CLAMP(max_funcs, 16, 512)); - data.push_back(opts); + msg_data.push_back(opts); } - _put_msg("profiler:servers", data); + _put_msg("profiler:servers", msg_data); break; default: ERR_FAIL_MSG("Invalid profiler type"); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index b0ea289bbe..9064329d1f 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -792,14 +792,14 @@ void OrphanResourcesDialog::show() { popup_centered_ratio(0.4); } -void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &paths) { +void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &r_paths) { while (p_item) { if (p_item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) { - paths.push_back(p_item->get_metadata(0)); + r_paths.push_back(p_item->get_metadata(0)); } if (p_item->get_first_child()) { - _find_to_delete(p_item->get_first_child(), paths); + _find_to_delete(p_item->get_first_child(), r_paths); } p_item = p_item->get_next(); diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h index 6e39015ec3..7a523457ef 100644 --- a/editor/dependency_editor.h +++ b/editor/dependency_editor.h @@ -165,7 +165,7 @@ class OrphanResourcesDialog : public ConfirmationDialog { bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent); List<String> paths; - void _find_to_delete(TreeItem *p_item, List<String> &paths); + void _find_to_delete(TreeItem *p_item, List<String> &r_paths); void _delete_confirm(); void _button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index aaa5956c17..77697f4de1 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -183,16 +183,16 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { int pp = path.rfind("/"); - TreeItem *parent; + TreeItem *parent_item; if (pp == -1) { - parent = root; + parent_item = root; } else { String ppath = path.substr(0, pp); ERR_CONTINUE(!dir_map.has(ppath)); - parent = dir_map[ppath]; + parent_item = dir_map[ppath]; } - TreeItem *ti = tree->create_item(parent); + TreeItem *ti = tree->create_item(parent_item); ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); ti->set_checked(0, true); ti->set_editable(0, true); @@ -284,17 +284,17 @@ void EditorAssetInstaller::ok_pressed() { Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES); da->make_dir(dirpath); } else { - Vector<uint8_t> data; - data.resize(info.uncompressed_size); + Vector<uint8_t> uncomp_data; + uncomp_data.resize(info.uncompressed_size); //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptrw(), data.size()); + unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size()); unzCloseCurrentFile(pkg); Ref<FileAccess> f = FileAccess::open(path, FileAccess::WRITE); if (f.is_valid()) { - f->store_buffer(data.ptr(), data.size()); + f->store_buffer(uncomp_data.ptr(), uncomp_data.size()); } else { failed_files.push_back(path); } diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 09dce869c9..83deff1469 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -919,10 +919,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { effect_options = memnew(PopupMenu); effect_options->connect("index_pressed", callable_mp(this, &EditorAudioBus::_effect_add)); add_child(effect_options); - List<StringName> effects; - ClassDB::get_inheriters_from_class("AudioEffect", &effects); - effects.sort_custom<StringName::AlphCompare>(); - for (const StringName &E : effects) { + List<StringName> effect_list; + ClassDB::get_inheriters_from_class("AudioEffect", &effect_list); + effect_list.sort_custom<StringName::AlphCompare>(); + for (const StringName &E : effect_list) { if (!ClassDB::can_instantiate(E) || ClassDB::is_virtual(E)) { continue; } diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 544b6c7141..98f21bda7a 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -222,15 +222,15 @@ void EditorAutoloadSettings::_autoload_edited() { name = "autoload/" + name; int order = ProjectSettings::get_singleton()->get_order(selected_autoload); - String path = ProjectSettings::get_singleton()->get(selected_autoload); + String scr_path = ProjectSettings::get_singleton()->get(selected_autoload); undo_redo->create_action(TTR("Rename Autoload")); - undo_redo->add_do_property(ProjectSettings::get_singleton(), name, path); + undo_redo->add_do_property(ProjectSettings::get_singleton(), name, scr_path); undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", name, order); undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", selected_autoload); - undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, path); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, scr_path); undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", selected_autoload, order); undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name); @@ -250,20 +250,20 @@ void EditorAutoloadSettings::_autoload_edited() { String base = "autoload/" + ti->get_text(0); int order = ProjectSettings::get_singleton()->get_order(base); - String path = ProjectSettings::get_singleton()->get(base); + String scr_path = ProjectSettings::get_singleton()->get(base); - if (path.begins_with("*")) { - path = path.substr(1, path.length()); + if (scr_path.begins_with("*")) { + scr_path = scr_path.substr(1, scr_path.length()); } // Singleton autoloads are represented with a leading "*" in their path. if (checked) { - path = "*" + path; + scr_path = "*" + scr_path; } undo_redo->create_action(TTR("Toggle Autoload Globals")); - undo_redo->add_do_property(ProjectSettings::get_singleton(), base, path); + undo_redo->add_do_property(ProjectSettings::get_singleton(), base, scr_path); undo_redo->add_undo_property(ProjectSettings::get_singleton(), base, ProjectSettings::get_singleton()->get(base)); undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", base, order); @@ -404,11 +404,11 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + "."); Node *n = nullptr; Ref<PackedScene> scn = res; - Ref<Script> script = res; + Ref<Script> scr = res; if (scn.is_valid()) { n = scn->instantiate(); - } else if (script.is_valid()) { - StringName ibt = script->get_instance_base_type(); + } else if (scr.is_valid()) { + StringName ibt = scr->get_instance_base_type(); bool valid_type = ClassDB::is_parent_class(ibt, "Node"); ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit from Node: " + p_path + "."); @@ -417,7 +417,7 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { ERR_FAIL_COND_V_MSG(!obj, nullptr, "Cannot instance script for Autoload, expected 'Node' inheritance, got: " + String(ibt) + "."); n = Object::cast_to<Node>(obj); - n->set_script(script); + n->set_script(scr); } ERR_FAIL_COND_V_MSG(!n, nullptr, "Path in Autoload not a node or script: " + p_path + "."); @@ -453,21 +453,21 @@ void EditorAutoloadSettings::update_autoload() { } String name = pi.name.get_slice("/", 1); - String path = ProjectSettings::get_singleton()->get(pi.name); + String scr_path = ProjectSettings::get_singleton()->get(pi.name); if (name.is_empty()) { continue; } AutoloadInfo info; - info.is_singleton = path.begins_with("*"); + info.is_singleton = scr_path.begins_with("*"); if (info.is_singleton) { - path = path.substr(1, path.length()); + scr_path = scr_path.substr(1, scr_path.length()); } info.name = name; - info.path = path; + info.path = scr_path; info.order = ProjectSettings::get_singleton()->get_order(pi.name); bool need_to_add = true; @@ -499,7 +499,7 @@ void EditorAutoloadSettings::update_autoload() { item->set_text(0, name); item->set_editable(0, true); - item->set_text(1, path); + item->set_text(1, scr_path); item->set_selectable(1, true); item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK); @@ -745,13 +745,12 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_ return false; } - const String &path = p_path; - if (!FileAccess::exists(path)) { + if (!FileAccess::exists(p_path)) { EditorNode::get_singleton()->show_warning(TTR("Can't add Autoload:") + "\n" + vformat(TTR("%s is an invalid path. File does not exist."), path)); return false; } - if (!path.begins_with("res://")) { + if (!p_path.begins_with("res://")) { EditorNode::get_singleton()->show_warning(TTR("Can't add Autoload:") + "\n" + vformat(TTR("%s is an invalid path. Not in resource path (res://)."), path)); return false; } @@ -762,7 +761,7 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_ undo_redo->create_action(TTR("Add Autoload")); // Singleton autoloads are represented with a leading "*" in their path. - undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + path); + undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + p_path); if (ProjectSettings::get_singleton()->has_setting(name)) { undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name)); @@ -829,21 +828,21 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } String name = pi.name.get_slice("/", 1); - String path = ProjectSettings::get_singleton()->get(pi.name); + String scr_path = ProjectSettings::get_singleton()->get(pi.name); if (name.is_empty()) { continue; } AutoloadInfo info; - info.is_singleton = path.begins_with("*"); + info.is_singleton = scr_path.begins_with("*"); if (info.is_singleton) { - path = path.substr(1, path.length()); + scr_path = scr_path.substr(1, scr_path.length()); } info.name = name; - info.path = path; + info.path = scr_path; info.order = ProjectSettings::get_singleton()->get_order(pi.name); if (info.is_singleton) { diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 9fa08a0adb..ab252a7ff1 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1023,10 +1023,10 @@ void EditorFileDialog::set_current_path(const String &p_path) { if (pos == -1) { set_current_file(p_path); } else { - String dir = p_path.substr(0, pos); - String file = p_path.substr(pos + 1, p_path.length()); - set_current_dir(dir); - set_current_file(file); + String path_dir = p_path.substr(0, pos); + String path_file = p_path.substr(pos + 1, p_path.length()); + set_current_dir(path_dir); + set_current_file(path_file); } } @@ -1614,26 +1614,26 @@ void EditorFileDialog::set_default_display_mode(DisplayMode p_mode) { } void EditorFileDialog::_save_to_recent() { - String dir = get_current_dir(); - Vector<String> recent = EditorSettings::get_singleton()->get_recent_dirs(); + String cur_dir = get_current_dir(); + Vector<String> recent_new = EditorSettings::get_singleton()->get_recent_dirs(); const int max = 20; int count = 0; - bool res = dir.begins_with("res://"); + bool res = cur_dir.begins_with("res://"); - for (int i = 0; i < recent.size(); i++) { - bool cres = recent[i].begins_with("res://"); - if (recent[i] == dir || (res == cres && count > max)) { - recent.remove_at(i); + for (int i = 0; i < recent_new.size(); i++) { + bool cres = recent_new[i].begins_with("res://"); + if (recent_new[i] == cur_dir || (res == cres && count > max)) { + recent_new.remove_at(i); i--; } else { count++; } } - recent.insert(0, dir); + recent_new.insert(0, cur_dir); - EditorSettings::get_singleton()->set_recent_dirs(recent); + EditorSettings::get_singleton()->set_recent_dirs(recent_new); } void EditorFileDialog::set_disable_overwrite_warning(bool p_disable) { diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 9153640115..6f34c677db 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -919,11 +919,11 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptLanguage *lang = ScriptServer::get_language(i); if (lang->supports_documentation() && fi->type == lang->get_type()) { - Ref<Script> script = ResourceLoader::load(path); - if (script == nullptr) { + Ref<Script> scr = ResourceLoader::load(path); + if (scr == nullptr) { continue; } - Vector<DocData::ClassDoc> docs = script->get_documentation(); + Vector<DocData::ClassDoc> docs = scr->get_documentation(); for (int j = 0; j < docs.size(); j++) { EditorHelp::get_doc_data()->add_doc(docs[j]); } @@ -1902,8 +1902,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String List<String> import_variants; List<String> gen_files; - Variant metadata; - Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &metadata); + Variant meta; + Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files, &meta); if (err != OK) { ERR_PRINT("Error importing '" + p_file + "'."); @@ -1955,8 +1955,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const HashMap<String f->store_line("valid=false"); } - if (metadata != Variant()) { - f->store_line("metadata=" + metadata.get_construct_string()); + if (meta != Variant()) { + f->store_line("metadata=" + meta.get_construct_string()); } f->store_line(""); @@ -2108,11 +2108,11 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { reimport_files.sort(); - bool use_threads = GLOBAL_GET("editor/import/use_multiple_threads"); + bool use_multiple_threads = GLOBAL_GET("editor/import/use_multiple_threads"); int from = 0; for (int i = 0; i < reimport_files.size(); i++) { - if (use_threads && reimport_files[i].threaded) { + if (use_multiple_threads && reimport_files[i].threaded) { if (i + 1 == reimport_files.size() || reimport_files[i + 1].importer != reimport_files[from].importer) { if (from - i == 0) { //single file, do not use threads @@ -2124,16 +2124,16 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { importer->import_threaded_begin(); - ImportThreadData data; - data.max_index = from; - data.reimport_from = from; - data.reimport_files = reimport_files.ptr(); + ImportThreadData tdata; + tdata.max_index = from; + tdata.reimport_from = from; + tdata.reimport_files = reimport_files.ptr(); - WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &EditorFileSystem::_reimport_thread, &data, i - from + 1, -1, false, vformat(TTR("Import resources of type: %s"), reimport_files[from].importer)); + WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &EditorFileSystem::_reimport_thread, &tdata, i - from + 1, -1, false, vformat(TTR("Import resources of type: %s"), reimport_files[from].importer)); int current_index = from - 1; do { - if (current_index < data.max_index) { - current_index = data.max_index; + if (current_index < tdata.max_index) { + current_index = tdata.max_index; pr.step(reimport_files[current_index].path.get_file(), current_index); } OS::get_singleton()->delay_usec(1); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 745dcdd04c..5192680787 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -184,9 +184,9 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) { void EditorHelp::_class_desc_resized(bool p_force_update_theme) { // Add extra horizontal margins for better readability. // The margins increase as the width of the editor help container increases. - Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); int font_size = get_theme_font_size(SNAME("doc_source_size"), SNAME("EditorFonts")); - real_t char_width = doc_code_font->get_char_size('x', font_size).width; + real_t char_width = font->get_char_size('x', font_size).width; const int new_display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5; if (display_margin != new_display_margin || p_force_update_theme) { display_margin = new_display_margin; @@ -412,13 +412,13 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods, bool &r_method_descrpitons) { - Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); class_desc->pop(); // title font size class_desc->pop(); // title font class_desc->pop(); // title color class_desc->add_newline(); - class_desc->push_font(doc_code_font); + class_desc->push_font(font); class_desc->push_indent(1); class_desc->push_table(2); class_desc->set_table_column_expand(1, true); @@ -479,9 +479,8 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods, } void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, const String &p_method_type) { - Ref<Font> doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts")); - Ref<Font> doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); - Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + Ref<Font> font = get_theme_font(SNAME("doc"), SNAME("EditorFonts")); + Ref<Font> code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); String link_color_text = title_color.to_html(false); class_desc->pop(); // title font size class_desc->pop(); // title font @@ -501,7 +500,7 @@ void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, } for (int i = 0; i < methods_filtered.size(); i++) { - class_desc->push_font(doc_code_font); + class_desc->push_font(code_font); _add_method(methods_filtered[i], false); class_desc->pop(); @@ -509,7 +508,7 @@ void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, class_desc->add_newline(); class_desc->push_color(text_color); - class_desc->push_font(doc_font); + class_desc->push_font(font); class_desc->push_indent(1); if (methods_filtered[i].errors_returned.size()) { class_desc->append_text(TTR("Error codes returned:")); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 73688fc2b7..286dcf4b8e 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -450,7 +450,7 @@ bool EditorHelpSearch::Runner::_phase_member_items() { return false; } - TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item; + TreeItem *parent_item = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item; bool constructor_created = false; for (int i = 0; i < match.methods.size(); i++) { String text = match.methods[i]->name; @@ -464,23 +464,23 @@ bool EditorHelpSearch::Runner::_phase_member_items() { continue; } } - _create_method_item(parent, match.doc, text, match.methods[i]); + _create_method_item(parent_item, match.doc, text, match.methods[i]); } for (int i = 0; i < match.signals.size(); i++) { - _create_signal_item(parent, match.doc, match.signals[i]); + _create_signal_item(parent_item, match.doc, match.signals[i]); } for (int i = 0; i < match.constants.size(); i++) { - _create_constant_item(parent, match.doc, match.constants[i]); + _create_constant_item(parent_item, match.doc, match.constants[i]); } for (int i = 0; i < match.properties.size(); i++) { - _create_property_item(parent, match.doc, match.properties[i]); + _create_property_item(parent_item, match.doc, match.properties[i]); } for (int i = 0; i < match.theme_properties.size(); i++) { - _create_theme_property_item(parent, match.doc, match.theme_properties[i]); + _create_theme_property_item(parent_item, match.doc, match.theme_properties[i]); } for (int i = 0; i < match.annotations.size(); i++) { // Hide the redundant leading @ symbol. - _create_annotation_item(parent, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]); + _create_annotation_item(parent_item, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]); } ++iterator_match; @@ -567,19 +567,19 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_ } // Ensure parent nodes are created first. - TreeItem *parent = root_item; + TreeItem *parent_item = root_item; if (!p_match.doc->inherits.is_empty()) { if (class_items.has(p_match.doc->inherits)) { - parent = class_items[p_match.doc->inherits]; + parent_item = class_items[p_match.doc->inherits]; } else { ClassMatch &base_match = matches[p_match.doc->inherits]; if (base_match.doc) { - parent = _create_class_hierarchy(base_match); + parent_item = _create_class_hierarchy(base_match); } } } - TreeItem *class_item = _create_class_item(parent, p_match.doc, !p_match.name); + TreeItem *class_item = _create_class_item(parent_item, p_match.doc, !p_match.name); class_items[p_match.doc->name] = class_item; return class_item; } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 65c65a517f..3856423fc4 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -783,9 +783,9 @@ Variant EditorProperty::get_drag_data(const Point2 &p_point) { dp["property"] = property; dp["value"] = object->get(property); - Label *label = memnew(Label); - label->set_text(property); - set_drag_preview(label); + Label *drag_label = memnew(Label); + drag_label->set_text(property); + set_drag_preview(drag_label); return dp; } @@ -1061,7 +1061,7 @@ void EditorInspectorPlugin::add_property_editor_for_multiple_properties(const St } bool EditorInspectorPlugin::can_handle(Object *p_object) { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_can_handle, p_object, success)) { return success; } @@ -1081,7 +1081,7 @@ void EditorInspectorPlugin::parse_group(Object *p_object, const String &p_group) } bool EditorInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) { - bool ret; + bool ret = false; if (GDVIRTUAL_CALL(_parse_property, p_object, p_type, p_path, p_hint, p_hint_text, p_usage, p_wide, ret)) { return ret; } @@ -1575,9 +1575,9 @@ int EditorInspectorArray::_get_array_count() { return _extract_properties_as_array(object_property_list).size(); } else if (mode == MODE_USE_COUNT_PROPERTY) { bool valid; - int count = object->get(count_property, &valid); + int count_val = object->get(count_property, &valid); ERR_FAIL_COND_V_MSG(!valid, 0, vformat("%s is not a valid property to be used as array count.", count_property)); - return count; + return count_val; } return 0; } @@ -2768,13 +2768,13 @@ void EditorInspector::update_tree() { // Set the category icon. if (!EditorNode::get_editor_data().is_type_recognized(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) { // If we have a category inside a script, search for the first script with a valid icon. - Ref<Script> script = ResourceLoader::load(p.hint_string, "Script"); + Ref<Script> scr = ResourceLoader::load(p.hint_string, "Script"); StringName base_type; StringName name; - if (script.is_valid()) { - base_type = script->get_instance_base_type(); - name = EditorNode::get_editor_data().script_class_get_name(script->get_path()); - Vector<DocData::ClassDoc> docs = script->get_documentation(); + if (scr.is_valid()) { + base_type = scr->get_instance_base_type(); + name = EditorNode::get_editor_data().script_class_get_name(scr->get_path()); + Vector<DocData::ClassDoc> docs = scr->get_documentation(); if (!docs.is_empty()) { doc_name = docs[0].name; } @@ -2782,20 +2782,20 @@ void EditorInspector::update_tree() { label = name; } } - while (script.is_valid()) { - name = EditorNode::get_editor_data().script_class_get_name(script->get_path()); + while (scr.is_valid()) { + name = EditorNode::get_editor_data().script_class_get_name(scr->get_path()); String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name); if (name != StringName() && !icon_path.is_empty()) { category->icon = ResourceLoader::load(icon_path, "Texture"); break; } - const EditorData::CustomType *ctype = EditorNode::get_editor_data().get_custom_type_by_path(script->get_path()); + const EditorData::CustomType *ctype = EditorNode::get_editor_data().get_custom_type_by_path(scr->get_path()); if (ctype) { category->icon = ctype->icon; break; } - script = script->get_base_script(); + scr = scr->get_base_script(); } if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) { category->icon = get_theme_icon(base_type, SNAME("EditorIcons")); diff --git a/editor/editor_locale_dialog.cpp b/editor/editor_locale_dialog.cpp index 87da67fb05..953358b23e 100644 --- a/editor/editor_locale_dialog.cpp +++ b/editor/editor_locale_dialog.cpp @@ -149,7 +149,7 @@ void EditorLocaleDialog::_filter_lang_option_changed() { void EditorLocaleDialog::_filter_script_option_changed() { TreeItem *t = script_list->get_edited(); - String script = t->get_metadata(0); + String scr_code = t->get_metadata(0); bool checked = t->is_checked(0); Variant prev; @@ -160,11 +160,11 @@ void EditorLocaleDialog::_filter_script_option_changed() { prev = f_script_all; } - int l_idx = f_script_all.find(script); + int l_idx = f_script_all.find(scr_code); if (checked) { if (l_idx == -1) { - f_script_all.append(script); + f_script_all.append(scr_code); } } else { if (l_idx != -1) { @@ -298,7 +298,7 @@ void EditorLocaleDialog::_update_tree() { Vector<String> scripts = TranslationServer::get_singleton()->get_all_scripts(); for (const String &E : scripts) { if (is_edit_mode || (filter == SHOW_ALL_LOCALES) || f_script_all.has(E) || f_script_all.is_empty()) { - const String &script = TranslationServer::get_singleton()->get_script_name(E); + const String &scr_code = TranslationServer::get_singleton()->get_script_name(E); TreeItem *t = script_list->create_item(s_root); if (is_edit_mode) { t->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); @@ -307,7 +307,7 @@ void EditorLocaleDialog::_update_tree() { } else if (script_code->get_text() == E) { t->select(0); } - t->set_text(0, vformat("%s [%s]", script, E)); + t->set_text(0, vformat("%s [%s]", scr_code, E)); t->set_metadata(0, E); } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 34c0c35b12..f83ff598c5 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -892,8 +892,8 @@ void EditorNode::_update_update_spinner() { } void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_name) { - Ref<Script> script = Object::cast_to<Script>(p_script); - if (script.is_null()) { + Ref<Script> scr = Object::cast_to<Script>(p_script); + if (scr.is_null()) { return; } if (p_activate_name.length()) { @@ -901,7 +901,7 @@ void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_nam } project_settings_editor->update_plugins(); project_settings_editor->hide(); - push_item(script.operator->()); + push_item(scr.operator->()); } void EditorNode::_remove_plugin_from_enabled(const String &p_name) { @@ -1665,10 +1665,8 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { cache_base = temp_path.path_join("resthumb-" + cache_base); // Does not have it, try to load a cached thumbnail. - String file = cache_base + ".png"; - post_process_preview(img); - img->save_png(file); + img->save_png(cache_base + ".png"); } } @@ -2038,8 +2036,8 @@ void EditorNode::_dialog_action(String p_file) { ERR_FAIL_COND(saving_resource.is_null()); save_resource_in_path(saving_resource, p_file); saving_resource = Ref<Resource>(); - ObjectID current = editor_history.get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; + ObjectID current_id = editor_history.get_current(); + Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; ERR_FAIL_COND(!current_obj); current_obj->notify_property_list_changed(); } break; @@ -2240,8 +2238,8 @@ static bool overrides_external_editor(Object *p_object) { } void EditorNode::_edit_current(bool p_skip_foreign) { - ObjectID current = editor_history.get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; + ObjectID current_id = editor_history.get_current(); + Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; Ref<Resource> res = Object::cast_to<Resource>(current_obj); if (p_skip_foreign && res.is_valid()) { @@ -2691,9 +2689,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { save_confirmation->set_text(TTR("Save modified resources before closing?")); } } else { - Node *scene_root = editor_data.get_edited_scene_root(tab_closing_idx); - if (scene_root) { - String scene_filename = scene_root->get_scene_file_path(); + Node *ed_scene_root = editor_data.get_edited_scene_root(tab_closing_idx); + if (ed_scene_root) { + String scene_filename = ed_scene_root->get_scene_file_path(); if (p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) { save_confirmation->set_ok_button_text(TTR("Save & Reload")); save_confirmation->set_text(vformat(TTR("Save changes to '%s' before reloading?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene")); @@ -3511,39 +3509,39 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, } String script_path = cf->get_value("plugin", "script"); - Ref<Script> script; // We need to save it for creating "ep" below. + Ref<Script> scr; // We need to save it for creating "ep" below. // Only try to load the script if it has a name. Else, the plugin has no init script. if (script_path.length() > 0) { script_path = addon_path.get_base_dir().path_join(script_path); - script = ResourceLoader::load(script_path); + scr = ResourceLoader::load(script_path); - if (script.is_null()) { + if (scr.is_null()) { show_warning(vformat(TTR("Unable to load addon script from path: '%s'."), script_path)); return; } // Errors in the script cause the base_type to be an empty StringName. - if (script->get_instance_base_type() == StringName()) { + if (scr->get_instance_base_type() == StringName()) { show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, addon_path)); _remove_plugin_from_enabled(addon_path); return; } // Plugin init scripts must inherit from EditorPlugin and be tools. - if (String(script->get_instance_base_type()) != "EditorPlugin") { + if (String(scr->get_instance_base_type()) != "EditorPlugin") { show_warning(vformat(TTR("Unable to load addon script from path: '%s' Base type is not EditorPlugin."), script_path)); return; } - if (!script->is_tool()) { + if (!scr->is_tool()) { show_warning(vformat(TTR("Unable to load addon script from path: '%s' Script is not in tool mode."), script_path)); return; } } EditorPlugin *ep = memnew(EditorPlugin); - ep->set_script(script); + ep->set_script(scr); addon_name_to_plugin[addon_path] = ep; add_editor_plugin(ep, p_config_changed); @@ -3641,17 +3639,17 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { changing_scene = false; - int current = -1; + int current_tab = -1; for (int i = 0; i < editor_table.size(); i++) { if (editor_plugin_screen == editor_table[i]) { - current = i; + current_tab = i; break; } } if (p_state.has("editor_index")) { int index = p_state["editor_index"]; - if (current < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there. + if (current_tab < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there. if (index < 2 || !get_edited_scene()) { editor_select(index); } @@ -3659,7 +3657,7 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { } if (get_edited_scene()) { - if (current < 2) { + if (current_tab < 2) { // Use heuristic instead. int n2d = 0, n3d = 0; _find_node_types(get_edited_scene(), n2d, n3d); @@ -3939,9 +3937,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b void EditorNode::open_request(const String &p_path) { if (!opening_prev) { - List<String>::Element *prev_scene = previous_scenes.find(p_path); - if (prev_scene != nullptr) { - prev_scene->erase(); + List<String>::Element *prev_scene_item = previous_scenes.find(p_path); + if (prev_scene_item != nullptr) { + prev_scene_item->erase(); } } @@ -4192,9 +4190,9 @@ void EditorNode::stop_child_process(OS::ProcessID p_pid) { Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) const { ERR_FAIL_COND_V(!p_object, nullptr); - Ref<Script> script = p_object->get_script(); + Ref<Script> scr = p_object->get_script(); - if (script.is_valid()) { + if (scr.is_valid()) { // Uncommenting would break things! Consider adding a parameter if you need it. // StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path()); // if (name != StringName()) { @@ -4202,18 +4200,18 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons // } // TODO: Should probably be deprecated in 4.x - StringName base = script->get_instance_base_type(); + StringName base = scr->get_instance_base_type(); if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) { const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base]; - Ref<Script> base_script = script; - while (base_script.is_valid()) { + Ref<Script> base_scr = scr; + while (base_scr.is_valid()) { for (int i = 0; i < types.size(); ++i) { - if (types[i].script == base_script) { + if (types[i].script == base_scr) { return types[i].script; } } - base_script = base_script->get_base_script(); + base_scr = base_scr->get_base_script(); } } } @@ -4224,30 +4222,30 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons StringName EditorNode::get_object_custom_type_name(const Object *p_object) const { ERR_FAIL_COND_V(!p_object, StringName()); - Ref<Script> script = p_object->get_script(); - if (script.is_null() && Object::cast_to<Script>(p_object)) { - script = p_object; + Ref<Script> scr = p_object->get_script(); + if (scr.is_null() && Object::cast_to<Script>(p_object)) { + scr = p_object; } - if (script.is_valid()) { - Ref<Script> base_script = script; - while (base_script.is_valid()) { - StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path()); + if (scr.is_valid()) { + Ref<Script> base_scr = scr; + while (base_scr.is_valid()) { + StringName name = EditorNode::get_editor_data().script_class_get_name(base_scr->get_path()); if (name != StringName()) { return name; } // TODO: Should probably be deprecated in 4.x. - StringName base = base_script->get_instance_base_type(); + StringName base = base_scr->get_instance_base_type(); if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) { const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base]; for (int i = 0; i < types.size(); ++i) { - if (types[i].script == base_script) { + if (types[i].script == base_scr) { return types[i].name; } } } - base_script = base_script->get_base_script(); + base_scr = base_scr->get_base_script(); } } @@ -4291,40 +4289,40 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) { ERR_FAIL_COND_V(!p_object || !gui_base, nullptr); - Ref<Script> script = p_object->get_script(); - if (script.is_null() && p_object->is_class("Script")) { - script = p_object; + Ref<Script> scr = p_object->get_script(); + if (scr.is_null() && p_object->is_class("Script")) { + scr = p_object; } - if (script.is_valid() && !script_icon_cache.has(script)) { - Ref<Script> base_script = script; - while (base_script.is_valid()) { - StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path()); + if (scr.is_valid() && !script_icon_cache.has(scr)) { + Ref<Script> base_scr = scr; + while (base_scr.is_valid()) { + StringName name = EditorNode::get_editor_data().script_class_get_name(base_scr->get_path()); String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name); Ref<ImageTexture> icon = _load_custom_class_icon(icon_path); if (icon.is_valid()) { - script_icon_cache[script] = icon; + script_icon_cache[scr] = icon; return icon; } // TODO: should probably be deprecated in 4.x - StringName base = base_script->get_instance_base_type(); + StringName base = base_scr->get_instance_base_type(); if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) { const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base]; for (int i = 0; i < types.size(); ++i) { - if (types[i].script == base_script && types[i].icon.is_valid()) { - script_icon_cache[script] = types[i].icon; + if (types[i].script == base_scr && types[i].icon.is_valid()) { + script_icon_cache[scr] = types[i].icon; return types[i].icon; } } } - base_script = base_script->get_base_script(); + base_scr = base_scr->get_base_script(); } // If no icon found, cache it as null. - script_icon_cache[script] = Ref<Texture>(); - } else if (script.is_valid() && script_icon_cache.has(script) && script_icon_cache[script].is_valid()) { - return script_icon_cache[script]; + script_icon_cache[scr] = Ref<Texture>(); + } else if (scr.is_valid() && script_icon_cache.has(scr) && script_icon_cache[scr].is_valid()) { + return script_icon_cache[scr]; } // TODO: Should probably be deprecated in 4.x. @@ -4348,7 +4346,7 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p if (ScriptServer::is_global_class(p_class)) { String class_name = p_class; - Ref<Script> script = EditorNode::get_editor_data().script_class_load_script(class_name); + Ref<Script> scr = EditorNode::get_editor_data().script_class_load_script(class_name); while (true) { String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(class_name); @@ -4359,18 +4357,18 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p // Find next global class along the inheritance chain. do { - Ref<Script> base_script = script->get_base_script(); - if (base_script.is_null()) { + Ref<Script> base_scr = scr->get_base_script(); + if (base_scr.is_null()) { // We've reached a native class, use its icon. String base_type; - script->get_language()->get_global_class_name(script->get_path(), &base_type); + scr->get_language()->get_global_class_name(scr->get_path(), &base_type); if (gui_base->has_theme_icon(base_type, "EditorIcons")) { return gui_base->get_theme_icon(base_type, "EditorIcons"); } return gui_base->get_theme_icon(p_fallback, "EditorIcons"); } - script = base_script; - class_name = EditorNode::get_editor_data().script_class_get_name(script->get_path()); + scr = base_scr; + class_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path()); } while (class_name.is_empty()); } } @@ -4675,12 +4673,12 @@ void EditorNode::_dock_move_left() { if (dock_popup_selected_idx < 0 || dock_popup_selected_idx >= DOCK_SLOT_MAX) { return; } - Control *current = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab()); - Control *prev = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1); - if (!current || !prev) { + Control *current_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab()); + Control *prev_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1); + if (!current_ctl || !prev_ctl) { return; } - dock_slot[dock_popup_selected_idx]->move_child(current, prev->get_index()); + dock_slot[dock_popup_selected_idx]->move_child(current_ctl, prev_ctl->get_index()); dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1); dock_select->queue_redraw(); _edit_current(); @@ -4688,12 +4686,12 @@ void EditorNode::_dock_move_left() { } void EditorNode::_dock_move_right() { - Control *current = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab()); - Control *next = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1); - if (!current || !next) { + Control *current_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab()); + Control *next_ctl = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1); + if (!current_ctl || !next_ctl) { return; } - dock_slot[dock_popup_selected_idx]->move_child(next, current->get_index()); + dock_slot[dock_popup_selected_idx]->move_child(next_ctl, current_ctl->get_index()); dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1); dock_select->queue_redraw(); _edit_current(); @@ -5283,9 +5281,9 @@ void EditorNode::_layout_menu_option(int p_id) { } void EditorNode::_scene_tab_script_edited(int p_tab) { - Ref<Script> script = editor_data.get_scene_root_script(p_tab); - if (script.is_valid()) { - InspectorDock::get_singleton()->edit_resource(script); + Ref<Script> scr = editor_data.get_scene_root_script(p_tab); + if (scr.is_valid()) { + InspectorDock::get_singleton()->edit_resource(scr); } } diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index d1f41dad84..a8fd9d0eb0 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -59,7 +59,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { continue; } - Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); + Ref<Texture2D> obj_icon = EditorNode::get_singleton()->get_object_icon(obj); String proper_name = ""; Vector<String> name_parts = E.name.split("/"); @@ -72,7 +72,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { } int index = sub_objects_menu->get_item_count(); - sub_objects_menu->add_icon_item(icon, proper_name, objects.size()); + sub_objects_menu->add_icon_item(obj_icon, proper_name, objects.size()); sub_objects_menu->set_item_indent(index, p_depth); objects.push_back(obj->get_instance_id()); @@ -122,15 +122,15 @@ void EditorPath::update_path() { continue; } - Ref<Texture2D> icon; + Ref<Texture2D> obj_icon; if (Object::cast_to<MultiNodeEdit>(obj)) { - icon = EditorNode::get_singleton()->get_class_icon(Object::cast_to<MultiNodeEdit>(obj)->get_edited_class_name()); + obj_icon = EditorNode::get_singleton()->get_class_icon(Object::cast_to<MultiNodeEdit>(obj)->get_edited_class_name()); } else { - icon = EditorNode::get_singleton()->get_object_icon(obj); + obj_icon = EditorNode::get_singleton()->get_object_icon(obj); } - if (icon.is_valid()) { - current_object_icon->set_texture(icon); + if (obj_icon.is_valid()) { + current_object_icon->set_texture(obj_icon); } if (i == history->get_path_size() - 1) { diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index ddd4ea4adb..4fdf669121 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -570,7 +570,7 @@ void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) { } bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_forward_canvas_gui_input, p_event, success)) { return success; } @@ -605,7 +605,7 @@ int EditorPlugin::update_overlays() const { } EditorPlugin::AfterGUIInput EditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { - int success; + int success = EditorPlugin::AFTER_GUI_INPUT_PASS; if (GDVIRTUAL_CALL(_forward_3d_gui_input, p_camera, p_event, success)) { return static_cast<EditorPlugin::AfterGUIInput>(success); @@ -662,7 +662,7 @@ void EditorPlugin::edit(Object *p_object) { } bool EditorPlugin::handles(Object *p_object) const { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_handles, p_object, success)) { return success; } diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index bd19df41fe..dd647c944d 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -98,14 +98,14 @@ void EditorPluginSettings::update_plugins() { String author = cf->get_value("plugin", "author"); String version = cf->get_value("plugin", "version"); String description = cf->get_value("plugin", "description"); - String script = cf->get_value("plugin", "script"); + String scr = cf->get_value("plugin", "script"); TreeItem *item = plugin_list->create_item(root); item->set_text(0, name); - item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + script + "\n" + TTR("Description:") + " " + description); + item->set_tooltip_text(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + scr + "\n" + TTR("Description:") + " " + description); item->set_metadata(0, path); item->set_text(1, version); - item->set_metadata(1, script); + item->set_metadata(1, scr); item->set_text(2, author); item->set_metadata(2, description); item->set_cell_mode(3, TreeItem::CELL_MODE_CHECK); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 66a3076733..0ea1bb72df 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -51,9 +51,9 @@ void EditorPropertyNil::update_property() { } EditorPropertyNil::EditorPropertyNil() { - Label *label = memnew(Label); - label->set_text("<null>"); - add_child(label); + Label *prop_label = memnew(Label); + prop_label->set_text("<null>"); + add_child(prop_label); } ///////////////////// TEXT ///////////////////////// @@ -3644,8 +3644,8 @@ bool EditorPropertyNodePath::can_drop_data_fw(const Point2 &p_point, const Varia void EditorPropertyNodePath::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { ERR_FAIL_COND(!is_drop_valid(p_data)); - Dictionary data = p_data; - Array nodes = data["nodes"]; + Dictionary data_dict = p_data; + Array nodes = data_dict["nodes"]; Node *node = get_tree()->get_edited_scene_root()->get_node(nodes[0]); if (node) { @@ -3973,19 +3973,19 @@ void EditorPropertyResource::_update_preferred_shader() { if (parent_property) { EditorShaderPicker *shader_picker = Object::cast_to<EditorShaderPicker>(resource_picker); - Object *object = parent_property->get_edited_object(); - const StringName &property = parent_property->get_edited_property(); + Object *ed_object = parent_property->get_edited_object(); + const StringName &ed_property = parent_property->get_edited_property(); // Set preferred shader based on edited parent type. - if ((Object::cast_to<GPUParticles2D>(object) || Object::cast_to<GPUParticles3D>(object)) && property == SNAME("process_material")) { + if ((Object::cast_to<GPUParticles2D>(ed_object) || Object::cast_to<GPUParticles3D>(ed_object)) && ed_property == SNAME("process_material")) { shader_picker->set_preferred_mode(Shader::MODE_PARTICLES); - } else if (Object::cast_to<FogVolume>(object)) { + } else if (Object::cast_to<FogVolume>(ed_object)) { shader_picker->set_preferred_mode(Shader::MODE_FOG); - } else if (Object::cast_to<CanvasItem>(object)) { + } else if (Object::cast_to<CanvasItem>(ed_object)) { shader_picker->set_preferred_mode(Shader::MODE_CANVAS_ITEM); - } else if (Object::cast_to<Node3D>(object) || Object::cast_to<Mesh>(object)) { + } else if (Object::cast_to<Node3D>(ed_object) || Object::cast_to<Mesh>(ed_object)) { shader_picker->set_preferred_mode(Shader::MODE_SPATIAL); - } else if (Object::cast_to<Sky>(object)) { + } else if (Object::cast_to<Sky>(ed_object)) { shader_picker->set_preferred_mode(Shader::MODE_SKY); } } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 728a3b0f80..d98ad117d7 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -260,9 +260,9 @@ void EditorPropertyArray::update_property() { HBoxContainer *hbox = memnew(HBoxContainer); vbox->add_child(hbox); - Label *label = memnew(Label(TTR("Size:"))); - label->set_h_size_flags(SIZE_EXPAND_FILL); - hbox->add_child(label); + Label *size_label = memnew(Label(TTR("Size:"))); + size_label->set_h_size_flags(SIZE_EXPAND_FILL); + hbox->add_child(size_label); size_slider = memnew(EditorSpinSlider); size_slider->set_step(1); @@ -367,17 +367,17 @@ void EditorPropertyArray::update_property() { bool is_untyped_array = array.get_type() == Variant::ARRAY && subtype == Variant::NIL; if (is_untyped_array) { - Button *edit = memnew(Button); - edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - hbox->add_child(edit); - edit->set_disabled(is_read_only()); - edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit, i + offset)); + Button *edit_btn = memnew(Button); + edit_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + hbox->add_child(edit_btn); + edit_btn->set_disabled(is_read_only()); + edit_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit_btn, i + offset)); } else { - Button *remove = memnew(Button); - remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - remove->set_disabled(is_read_only()); - remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(i + offset)); - hbox->add_child(remove); + Button *remove_btn = memnew(Button); + remove_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + remove_btn->set_disabled(is_read_only()); + remove_btn->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(i + offset)); + hbox->add_child(remove_btn); } prop->update_property(); @@ -1155,11 +1155,11 @@ void EditorPropertyDictionary::update_property() { } hbox->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); - Button *edit = memnew(Button); - edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); - edit->set_disabled(is_read_only()); - hbox->add_child(edit); - edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit, change_index)); + Button *edit_btn = memnew(Button); + edit_btn->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + edit_btn->set_disabled(is_read_only()); + hbox->add_child(edit_btn); + edit_btn->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit_btn, change_index)); prop->update_property(); @@ -1396,10 +1396,10 @@ void EditorPropertyLocalizableString::update_property() { property_vbox->add_child(hbox); hbox->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); - Button *edit = memnew(Button); - edit->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); - hbox->add_child(edit); - edit->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit, remove_index)); + Button *edit_btn = memnew(Button); + edit_btn->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + hbox->add_child(edit_btn); + edit_btn->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item).bind(edit_btn, remove_index)); prop->update_property(); } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index f89aef4cc3..01816b7205 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -96,9 +96,9 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const } if (preview_rect) { - Ref<Script> script = edited_resource; - if (script.is_valid()) { - assign_button->set_text(script->get_path().get_file()); + Ref<Script> scr = edited_resource; + if (scr.is_valid()) { + assign_button->set_text(scr->get_path().get_file()); return; } @@ -981,8 +981,8 @@ void EditorScriptPicker::set_create_options(Object *p_menu_node) { menu_node->add_icon_item(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); if (script_owner) { - Ref<Script> script = script_owner->get_script(); - if (script.is_valid()) { + Ref<Script> scr = script_owner->get_script(); + if (scr.is_valid()) { menu_node->add_icon_item(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); } } @@ -1040,12 +1040,12 @@ void EditorShaderPicker::set_create_options(Object *p_menu_node) { } bool EditorShaderPicker::handle_menu_selected(int p_which) { - Ref<ShaderMaterial> material = Ref<ShaderMaterial>(get_edited_material()); + Ref<ShaderMaterial> ed_material = Ref<ShaderMaterial>(get_edited_material()); switch (p_which) { case OBJ_MENU_NEW_SHADER: { - if (material.is_valid()) { - SceneTreeDock::get_singleton()->open_shader_dialog(material, preferred_mode); + if (ed_material.is_valid()) { + SceneTreeDock::get_singleton()->open_shader_dialog(ed_material, preferred_mode); return true; } } break; diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 706b77c142..33de63e63d 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -41,7 +41,7 @@ #include "editor/editor_settings.h" bool EditorResourcePreviewGenerator::handles(const String &p_type) const { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_handles, p_type, success)) { return success; } @@ -70,7 +70,7 @@ Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String & } bool EditorResourcePreviewGenerator::generate_small_preview_automatically() const { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_generate_small_preview_automatically, success)) { return success; } @@ -79,7 +79,7 @@ bool EditorResourcePreviewGenerator::generate_small_preview_automatically() cons } bool EditorResourcePreviewGenerator::can_generate_small_preview() const { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_can_generate_small_preview, success)) { return success; } diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index e078bea037..94f4fec89a 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -226,9 +226,9 @@ void SectionedInspector::update_category_list() { TreeItem *root = sections->create_item(); section_map[""] = root; - String filter; + String filter_text; if (search_box) { - filter = search_box->get_text(); + filter_text = search_box->get_text(); } const EditorPropertyNameProcessor::Style name_style = EditorPropertyNameProcessor::get_settings_style(); @@ -245,7 +245,7 @@ void SectionedInspector::update_category_list() { continue; } - if (!filter.is_empty() && !_property_path_matches(pi.name, filter, name_style)) { + if (!filter_text.is_empty() && !_property_path_matches(pi.name, filter_text, name_style)) { continue; } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 74445e6caa..0c01fcb869 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -76,14 +76,14 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value) Array arr = p_value; for (int i = 0; i < arr.size(); i++) { Dictionary dict = arr[i]; - String name = dict["name"]; + String shortcut_name = dict["name"]; Array shortcut_events = dict["shortcuts"]; Ref<Shortcut> sc; sc.instantiate(); sc->set_events(shortcut_events); - add_shortcut(name, sc); + add_shortcut(shortcut_name, sc); } return false; @@ -92,16 +92,16 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value) for (int i = 0; i < actions_arr.size(); i++) { Dictionary action_dict = actions_arr[i]; - String name = action_dict["name"]; + String action_name = action_dict["name"]; Array events = action_dict["events"]; InputMap *im = InputMap::get_singleton(); - im->action_erase_events(name); + im->action_erase_events(action_name); - builtin_action_overrides[name].clear(); + builtin_action_overrides[action_name].clear(); for (int ev_idx = 0; ev_idx < events.size(); ev_idx++) { - im->action_add_event(name, events[ev_idx]); - builtin_action_overrides[name].push_back(events[ev_idx]); + im->action_add_event(action_name, events[ev_idx]); + builtin_action_overrides[action_name].push_back(events[ev_idx]); } } return false; @@ -735,8 +735,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) { Vector<String> list = p_extra_config->get_value("init_projects", "list"); for (int i = 0; i < list.size(); i++) { - String name = list[i].replace("/", "::"); - set("projects/" + name, list[i]); + String proj_name = list[i].replace("/", "::"); + set("projects/" + proj_name, list[i]); } } diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index 6a5242f0c6..6b2cc99df9 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -78,19 +78,19 @@ void EditorToaster::_notification(int p_what) { // Change alpha over time. bool needs_update = false; for (const KeyValue<Control *, Toast> &element : toasts) { - Color modulate = element.key->get_modulate(); + Color modulate_fade = element.key->get_modulate(); // Change alpha over time. - if (element.value.popped && modulate.a < 1.0) { - modulate.a += delta * 3; - element.key->set_modulate(modulate); - } else if (!element.value.popped && modulate.a > 0.0) { - modulate.a -= delta * 2; - element.key->set_modulate(modulate); + if (element.value.popped && modulate_fade.a < 1.0) { + modulate_fade.a += delta * 3; + element.key->set_modulate(modulate_fade); + } else if (!element.value.popped && modulate_fade.a > 0.0) { + modulate_fade.a -= delta * 2; + element.key->set_modulate(modulate_fade); } // Hide element if it is not visible anymore. - if (modulate.a <= 0) { + if (modulate_fade.a <= 0) { if (element.key->is_visible()) { element.key->hide(); needs_update = true; @@ -317,7 +317,7 @@ void EditorToaster::_set_notifications_enabled(bool p_enabled) { void EditorToaster::_repop_old() { // Repop olds, up to max_temporary_count bool needs_update = false; - int visible = 0; + int visible_count = 0; for (int i = vbox_container->get_child_count() - 1; i >= 0; i--) { Control *control = Object::cast_to<Control>(vbox_container->get_child(i)); if (!control->is_visible()) { @@ -326,8 +326,8 @@ void EditorToaster::_repop_old() { toasts[control].popped = true; needs_update = true; } - visible++; - if (visible >= max_temporary_count) { + visible_count++; + if (visible_count >= max_temporary_count) { break; } } diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp index ceb5b63293..9ebf4d795a 100644 --- a/editor/export/export_template_manager.cpp +++ b/editor/export/export_template_manager.cpp @@ -265,9 +265,9 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code, mirrors_available = false; - Dictionary data = json.get_data(); - if (data.has("mirrors")) { - Array mirrors = data["mirrors"]; + Dictionary mirror_data = json.get_data(); + if (mirror_data.has("mirrors")) { + Array mirrors = mirror_data["mirrors"]; for (int i = 0; i < mirrors.size(); i++) { Dictionary m = mirrors[i]; @@ -401,17 +401,17 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ String file = String::utf8(fname); if (file.ends_with("version.txt")) { - Vector<uint8_t> data; - data.resize(info.uncompressed_size); + Vector<uint8_t> uncomp_data; + uncomp_data.resize(info.uncompressed_size); // Read. unzOpenCurrentFile(pkg); - ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); + ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size()); ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file)); unzCloseCurrentFile(pkg); String data_str; - data_str.parse_utf8((const char *)data.ptr(), data.size()); + data_str.parse_utf8((const char *)uncomp_data.ptr(), uncomp_data.size()); data_str = data_str.strip_edges(); // Version number should be of the form major.minor[.patch].status[.module_config] @@ -473,12 +473,12 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ continue; } - Vector<uint8_t> data; - data.resize(info.uncompressed_size); + Vector<uint8_t> uncomp_data; + uncomp_data.resize(info.uncompressed_size); // Read unzOpenCurrentFile(pkg); - ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); + ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size()); ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file)); unzCloseCurrentFile(pkg); @@ -512,7 +512,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ ERR_CONTINUE_MSG(true, "Can't open file from path '" + String(to_write) + "'."); } - f->store_buffer(data.ptr(), data.size()); + f->store_buffer(uncomp_data.ptr(), uncomp_data.size()); f.unref(); // close file. #ifndef WINDOWS_ENABLED FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF); @@ -714,12 +714,12 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ String base_dir = path.get_base_dir(); if (!path.ends_with("/")) { - Vector<uint8_t> data; - data.resize(info.uncompressed_size); + Vector<uint8_t> uncomp_data; + uncomp_data.resize(info.uncompressed_size); // Read. unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptrw(), data.size()); + unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size()); unzCloseCurrentFile(pkg); if (!dirs_tested.has(base_dir)) { @@ -730,7 +730,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ String to_write = String("res://android/build").path_join(path); Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE); if (f.is_valid()) { - f->store_buffer(data.ptr(), data.size()); + f->store_buffer(uncomp_data.ptr(), uncomp_data.size()); f.unref(); // close file. #ifndef WINDOWS_ENABLED FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF); diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index 43aac5e981..05a17c9951 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -94,7 +94,7 @@ void ProjectExportDialog::_add_preset(int p_platform) { Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset(); ERR_FAIL_COND(!preset.is_valid()); - String name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name(); + String preset_name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name(); bool make_runnable = true; int attempt = 1; while (true) { @@ -105,7 +105,7 @@ void ProjectExportDialog::_add_preset(int p_platform) { if (p->get_platform() == preset->get_platform() && p->is_runnable()) { make_runnable = false; } - if (p->get_name() == name) { + if (p->get_name() == preset_name) { valid = false; break; } @@ -116,10 +116,10 @@ void ProjectExportDialog::_add_preset(int p_platform) { } attempt++; - name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt); + preset_name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt); } - preset->set_name(name); + preset->set_name(preset_name); if (make_runnable) { preset->set_runnable(make_runnable); } @@ -154,12 +154,12 @@ void ProjectExportDialog::_update_presets() { current_idx = i; } - String name = preset->get_name(); + String preset_name = preset->get_name(); if (preset->is_runnable()) { - name += " (" + TTR("Runnable") + ")"; + preset_name += " (" + TTR("Runnable") + ")"; } preset->update_files_to_export(); - presets->add_item(name, preset->get_platform()->get_logo()); + presets->add_item(preset_name, preset->get_platform()->get_logo()); } if (current_idx != -1) { @@ -552,7 +552,7 @@ void ProjectExportDialog::_duplicate_preset() { Ref<EditorExportPreset> preset = current->get_platform()->create_preset(); ERR_FAIL_COND(!preset.is_valid()); - String name = current->get_name() + " (copy)"; + String preset_name = current->get_name() + " (copy)"; bool make_runnable = true; while (true) { bool valid = true; @@ -562,7 +562,7 @@ void ProjectExportDialog::_duplicate_preset() { if (p->get_platform() == preset->get_platform() && p->is_runnable()) { make_runnable = false; } - if (p->get_name() == name) { + if (p->get_name() == preset_name) { valid = false; break; } @@ -572,10 +572,10 @@ void ProjectExportDialog::_duplicate_preset() { break; } - name += " (copy)"; + preset_name += " (copy)"; } - preset->set_name(name); + preset->set_name(preset_name); if (make_runnable) { preset->set_runnable(make_runnable); } @@ -945,8 +945,8 @@ void ProjectExportDialog::_export_all_dialog_action(const String &p_str) { } void ProjectExportDialog::_export_all(bool p_debug) { - String mode = p_debug ? TTR("Debug") : TTR("Release"); - EditorProgress ep("exportall", TTR("Exporting All") + " " + mode, EditorExport::get_singleton()->get_export_preset_count(), true); + String export_target = p_debug ? TTR("Debug") : TTR("Release"); + EditorProgress ep("exportall", TTR("Exporting All") + " " + export_target, EditorExport::get_singleton()->get_export_preset_count(), true); bool show_dialog = false; result_dialog_log->clear(); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 424eab2f02..673ad1cb21 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -218,11 +218,11 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo TreeItem *root = tree->create_item(); // Handles the favorites. - TreeItem *favorites = tree->create_item(root); - favorites->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); - favorites->set_text(0, TTR("Favorites:")); - favorites->set_metadata(0, "Favorites"); - favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); + TreeItem *favorites_item = tree->create_item(root); + favorites_item->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); + favorites_item->set_text(0, TTR("Favorites:")); + favorites_item->set_metadata(0, "Favorites"); + favorites_item->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorites(); @@ -272,7 +272,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo } if (searched_string.length() == 0 || text.to_lower().find(searched_string) >= 0) { - TreeItem *ti = tree->create_item(favorites); + TreeItem *ti = tree->create_item(favorites_item); ti->set_text(0, text); ti->set_icon(0, icon); ti->set_icon_modulate(0, color); @@ -784,9 +784,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { List<FileInfo> file_list; if (path == "Favorites") { // Display the favorites. - Vector<String> favorites = EditorSettings::get_singleton()->get_favorites(); - for (int i = 0; i < favorites.size(); i++) { - String favorite = favorites[i]; + Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites(); + for (const String &favorite : favorites_list) { String text; Ref<Texture2D> icon; if (favorite == "res://") { @@ -1056,15 +1055,15 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit void FileSystemDock::_tree_activate_file() { TreeItem *selected = tree->get_selected(); if (selected) { - String path = selected->get_metadata(0); + String file_path = selected->get_metadata(0); TreeItem *parent = selected->get_parent(); bool is_favorite = parent != nullptr && parent->get_metadata(0) == "Favorites"; - if ((!is_favorite && path.ends_with("/")) || path == "Favorites") { + if ((!is_favorite && file_path.ends_with("/")) || file_path == "Favorites") { bool collapsed = selected->is_collapsed(); selected->set_collapsed(!collapsed); } else { - _select_file(path, is_favorite && !path.ends_with("/")); + _select_file(file_path, is_favorite && !file_path.ends_with("/")); } } } @@ -1169,29 +1168,29 @@ void FileSystemDock::_push_to_history() { button_hist_next->set_disabled(history_pos == history.size() - 1); } -void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const { - if (efsd == nullptr) { +void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *p_efsd, Vector<String> &r_files, Vector<String> &r_folders) const { + if (p_efsd == nullptr) { return; } - for (int i = 0; i < efsd->get_subdir_count(); i++) { - folders.push_back(efsd->get_subdir(i)->get_path()); - _get_all_items_in_dir(efsd->get_subdir(i), files, folders); + for (int i = 0; i < p_efsd->get_subdir_count(); i++) { + r_folders.push_back(p_efsd->get_subdir(i)->get_path()); + _get_all_items_in_dir(p_efsd->get_subdir(i), r_files, r_folders); } - for (int i = 0; i < efsd->get_file_count(); i++) { - files.push_back(efsd->get_file_path(i)); + for (int i = 0; i < p_efsd->get_file_count(); i++) { + r_files.push_back(p_efsd->get_file_path(i)); } } -void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const { - for (int i = 0; i < efsd->get_subdir_count(); i++) { - _find_remaps(efsd->get_subdir(i), renames, to_remaps); +void FileSystemDock::_find_remaps(EditorFileSystemDirectory *p_efsd, const HashMap<String, String> &r_renames, Vector<String> &r_to_remaps) const { + for (int i = 0; i < p_efsd->get_subdir_count(); i++) { + _find_remaps(p_efsd->get_subdir(i), r_renames, r_to_remaps); } - for (int i = 0; i < efsd->get_file_count(); i++) { - Vector<String> deps = efsd->get_file_deps(i); + for (int i = 0; i < p_efsd->get_file_count(); i++) { + Vector<String> deps = p_efsd->get_file_deps(i); for (int j = 0; j < deps.size(); j++) { - if (renames.has(deps[j])) { - to_remaps.push_back(efsd->get_file_path(i)); + if (r_renames.has(deps[j])) { + r_to_remaps.push_back(p_efsd->get_file_path(i)); break; } } @@ -1345,25 +1344,25 @@ void FileSystemDock::_update_resource_paths_after_move(const HashMap<String, Str } for (int i = 0; i < EditorNode::get_editor_data().get_edited_scene_count(); i++) { - String path; + String file_path; if (i == EditorNode::get_editor_data().get_edited_scene()) { if (!get_tree()->get_edited_scene_root()) { continue; } - path = get_tree()->get_edited_scene_root()->get_scene_file_path(); + file_path = get_tree()->get_edited_scene_root()->get_scene_file_path(); } else { - path = EditorNode::get_editor_data().get_scene_path(i); + file_path = EditorNode::get_editor_data().get_scene_path(i); } - if (p_renames.has(path)) { - path = p_renames[path]; + if (p_renames.has(file_path)) { + file_path = p_renames[file_path]; } if (i == EditorNode::get_editor_data().get_edited_scene()) { - get_tree()->get_edited_scene_root()->set_scene_file_path(path); + get_tree()->get_edited_scene_root()->set_scene_file_path(file_path); } else { - EditorNode::get_editor_data().set_scene_path(i, path); + EditorNode::get_editor_data().set_scene_path(i, file_path); } } } @@ -1421,11 +1420,10 @@ void FileSystemDock::_update_project_settings_after_move(const HashMap<String, S } void FileSystemDock::_update_favorites_list_after_move(const HashMap<String, String> &p_files_renames, const HashMap<String, String> &p_folders_renames) const { - Vector<String> favorites = EditorSettings::get_singleton()->get_favorites(); + Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites(); Vector<String> new_favorites; - for (int i = 0; i < favorites.size(); i++) { - String old_path = favorites[i]; + for (const String &old_path : favorites_list) { if (p_folders_renames.has(old_path)) { new_favorites.push_back(p_folders_renames[old_path]); } else if (p_files_renames.has(old_path)) { @@ -1836,23 +1834,23 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected case FILE_ADD_FAVORITE: { // Add the files from favorites. - Vector<String> favorites = EditorSettings::get_singleton()->get_favorites(); + Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites(); for (int i = 0; i < p_selected.size(); i++) { - if (!favorites.has(p_selected[i])) { - favorites.push_back(p_selected[i]); + if (!favorites_list.has(p_selected[i])) { + favorites_list.push_back(p_selected[i]); } } - EditorSettings::get_singleton()->set_favorites(favorites); + EditorSettings::get_singleton()->set_favorites(favorites_list); _update_tree(_compute_uncollapsed_paths()); } break; case FILE_REMOVE_FAVORITE: { // Remove the files from favorites. - Vector<String> favorites = EditorSettings::get_singleton()->get_favorites(); + Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites(); for (int i = 0; i < p_selected.size(); i++) { - favorites.erase(p_selected[i]); + favorites_list.erase(p_selected[i]); } - EditorSettings::get_singleton()->set_favorites(favorites); + EditorSettings::get_singleton()->set_favorites(favorites_list); _update_tree(_compute_uncollapsed_paths()); if (path == "Favorites") { _update_file_list(true); @@ -2274,7 +2272,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, int drop_section = tree->get_drop_section_at_position(p_point); int drop_position; - Vector<String> files = drag_data["files"]; + Vector<String> drag_files = drag_data["files"]; TreeItem *favorites_item = tree->get_root()->get_first_child(); TreeItem *resources_item = favorites_item->get_next(); @@ -2295,8 +2293,8 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, // Remove dragged favorites. Vector<int> to_remove; int offset = 0; - for (int i = 0; i < files.size(); i++) { - int to_remove_pos = dirs.find(files[i]); + for (int i = 0; i < drag_files.size(); i++) { + int to_remove_pos = dirs.find(drag_files[i]); to_remove.push_back(to_remove_pos); if (to_remove_pos < drop_position) { offset++; @@ -2309,8 +2307,8 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, } // Re-add them at the right position. - for (int i = 0; i < files.size(); i++) { - dirs.insert(drop_position, files[i]); + for (int i = 0; i < drag_files.size(); i++) { + dirs.insert(drop_position, drag_files[i]); drop_position++; } @@ -2379,13 +2377,13 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, } else if (favorite) { // Add the files from favorites. Vector<String> fnames = drag_data["files"]; - Vector<String> favorites = EditorSettings::get_singleton()->get_favorites(); + Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites(); for (int i = 0; i < fnames.size(); i++) { - if (!favorites.has(fnames[i])) { - favorites.push_back(fnames[i]); + if (!favorites_list.has(fnames[i])) { + favorites_list.push_back(fnames[i]); } } - EditorSettings::get_singleton()->set_favorites(favorites); + EditorSettings::get_singleton()->set_favorites(favorites_list); _update_tree(_compute_uncollapsed_paths()); } } @@ -2463,7 +2461,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str Vector<String> filenames; Vector<String> foldernames; - Vector<String> favorites = EditorSettings::get_singleton()->get_favorites(); + Vector<String> favorites_list = EditorSettings::get_singleton()->get_favorites(); bool all_files = true; bool all_files_scenes = true; @@ -2484,8 +2482,8 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str // Check if in favorites. bool found = false; - for (int j = 0; j < favorites.size(); j++) { - if (favorites[j] == fpath) { + for (int j = 0; j < favorites_list.size(); j++) { + if (favorites_list[j] == fpath) { found = true; break; } @@ -2852,10 +2850,10 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { } } -void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &files) const { +void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &r_files) const { if (!p_path.ends_with("/")) { if (FileAccess::exists(p_path + ".import")) { - files.push_back(p_path); + r_files.push_back(p_path); } return; } @@ -2866,7 +2864,7 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &f while (!n.is_empty()) { if (n != "." && n != ".." && !n.ends_with(".import")) { String npath = p_path + n + (da->current_is_dir() ? "/" : ""); - _get_imported_files(npath, files); + _get_imported_files(npath, r_files); } n = da->get_next(); } diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index c38b3f8a47..f39ca9e74d 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -213,11 +213,11 @@ private: void _file_multi_selected(int p_index, bool p_selected); void _tree_multi_selected(Object *p_item, int p_column, bool p_selected); - void _get_imported_files(const String &p_path, Vector<String> &files) const; + void _get_imported_files(const String &p_path, Vector<String> &r_files) const; void _update_import_dock(); - void _get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const; - void _find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const; + void _get_all_items_in_dir(EditorFileSystemDirectory *p_efsd, Vector<String> &r_files, Vector<String> &r_folders) const; + void _find_remaps(EditorFileSystemDirectory *p_efsd, const HashMap<String, String> &r_renames, Vector<String> &r_to_remaps) const; void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, HashMap<String, String> &p_file_renames, HashMap<String, String> &p_folder_renames); void _try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const; void _update_dependencies_after_move(const HashMap<String, String> &p_renames) const; diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 16c5003fdc..a0f4ade182 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -968,8 +968,8 @@ void FindInFilesPanel::update_replace_buttons() { _replace_all_button->set_disabled(disabled); } -void FindInFilesPanel::set_progress_visible(bool visible) { - _progress_bar->set_self_modulate(Color(1, 1, 1, visible ? 1 : 0)); +void FindInFilesPanel::set_progress_visible(bool p_visible) { + _progress_bar->set_self_modulate(Color(1, 1, 1, p_visible ? 1 : 0)); } void FindInFilesPanel::_bind_methods() { diff --git a/editor/find_in_files.h b/editor/find_in_files.h index c57a084779..46ba3842af 100644 --- a/editor/find_in_files.h +++ b/editor/find_in_files.h @@ -198,7 +198,7 @@ private: void draw_result_text(Object *item_obj, Rect2 rect); - void set_progress_visible(bool visible); + void set_progress_visible(bool p_visible); void clear(); FindInFiles *_finder = nullptr; diff --git a/editor/import/audio_stream_import_settings.cpp b/editor/import/audio_stream_import_settings.cpp index e3da82a5cb..d94b517003 100644 --- a/editor/import/audio_stream_import_settings.cpp +++ b/editor/import/audio_stream_import_settings.cpp @@ -76,7 +76,7 @@ void AudioStreamImportSettings::_notification(int p_what) { void AudioStreamImportSettings::_draw_preview() { Rect2 rect = _preview->get_rect(); - Size2 size = rect.size; + Size2 rect_size = rect.size; Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream); float preview_offset = zoom_bar->get_value(); @@ -85,7 +85,7 @@ void AudioStreamImportSettings::_draw_preview() { Ref<Font> beat_font = get_theme_font(SNAME("main"), SNAME("EditorFonts")); int main_size = get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts")); Vector<Vector2> lines; - lines.resize(size.width * 2); + lines.resize(rect_size.width * 2); Color color_active = get_theme_color(SNAME("contrast_color_2"), SNAME("Editor")); Color color_inactive = color_active; color_inactive.a *= 0.5; @@ -107,9 +107,9 @@ void AudioStreamImportSettings::_draw_preview() { } } - for (int i = 0; i < size.width; i++) { - float ofs = preview_offset + i * preview_len / size.width; - float ofs_n = preview_offset + (i + 1) * preview_len / size.width; + for (int i = 0; i < rect_size.width; i++) { + float ofs = preview_offset + i * preview_len / rect_size.width; + float ofs_n = preview_offset + (i + 1) * preview_len / rect_size.width; float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5; float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5; @@ -139,8 +139,8 @@ void AudioStreamImportSettings::_draw_preview() { int bar_beats = stream->get_bar_beats(); int last_text_end_x = 0; - for (int i = 0; i < size.width; i++) { - float ofs = preview_offset + i * preview_len / size.width; + for (int i = 0; i < rect_size.width; i++) { + float ofs = preview_offset + i * preview_len / rect_size.width; int beat = int(ofs / beat_size); if (beat != prev_beat) { String text = itos(beat); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index 1e0f45419f..5585c8edd2 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -949,11 +949,11 @@ void DynamicFontImportSettings::_re_import() { void DynamicFontImportSettings::open_settings(const String &p_path) { // Load base font data. - Vector<uint8_t> data = FileAccess::get_file_as_array(p_path); + Vector<uint8_t> font_data = FileAccess::get_file_as_array(p_path); // Load font for preview. font_preview.instantiate(); - font_preview->set_data(data); + font_preview->set_data(font_data); String font_name = vformat("%s (%s)", font_preview->get_font_name(), font_preview->get_font_style_name()); String sample; @@ -976,7 +976,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { // Load second copy of font with MSDF disabled for the glyph table and metadata extraction. font_main.instantiate(); - font_main->set_data(data); + font_main->set_data(font_data); font_main->set_multichannel_signed_distance_field(false); text_edit->add_theme_font_override("font", font_main); @@ -1036,7 +1036,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { double embolden = preload_config.has("variation_embolden") ? preload_config["variation_embolden"].operator double() : 0; int face_index = preload_config.has("variation_face_index") ? preload_config["variation_face_index"].operator int() : 0; Transform2D transform = preload_config.has("variation_transform") ? preload_config["variation_transform"].operator Transform2D() : Transform2D(); - Vector2i size = preload_config.has("size") ? preload_config["size"].operator Vector2i() : Vector2i(16, 0); + Vector2i font_size = preload_config.has("size") ? preload_config["size"].operator Vector2i() : Vector2i(16, 0); String cfg_name = preload_config.has("name") ? preload_config["name"].operator String() : vformat("Configuration %d", i); TreeItem *vars_item = vars_list->create_item(vars_list_root); @@ -1061,8 +1061,8 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { import_variation_data_custom->options = options_variations; vars_item->set_metadata(0, import_variation_data_custom); - import_variation_data_custom->set("size", size.x); - import_variation_data_custom->set("outline_size", size.y); + import_variation_data_custom->set("size", font_size.x); + import_variation_data_custom->set("outline_size", font_size.y); import_variation_data_custom->set("variation_opentype", variation); import_variation_data_custom->set("variation_embolden", embolden); import_variation_data_custom->set("variation_face_index", face_index); diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp index 5211f003c1..5d684fc5db 100644 --- a/editor/import/editor_import_plugin.cpp +++ b/editor/import/editor_import_plugin.cpp @@ -154,7 +154,7 @@ bool EditorImportPlugin::get_option_visibility(const String &p_path, const Strin d[E->key] = E->value; ++E; } - bool visible; + bool visible = false; if (GDVIRTUAL_CALL(_get_option_visibility, p_path, p_option, d, visible)) { return visible; } @@ -172,7 +172,7 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa ++E; } - int err; + int err = 0; if (GDVIRTUAL_CALL(_import, p_source_file, p_save_path, options, platform_variants, gen_files, err)) { Error ret_err = Error(err); diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index ed83535421..9dafa47c1c 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -396,12 +396,12 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const texture_import->used_channels = used_channels; _check_compress_ctex(p_source_file, texture_import); if (r_metadata) { - Dictionary metadata; - metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED; + Dictionary meta; + meta["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED; if (formats_imported.size()) { - metadata["imported_formats"] = formats_imported; + meta["imported_formats"] = formats_imported; } - *r_metadata = metadata; + *r_metadata = meta; } return OK; @@ -432,20 +432,20 @@ String ResourceImporterLayeredTexture::get_import_settings_string() const { bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_path) const { //will become invalid if formats are missing to import - Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path); + Dictionary meta = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path); - if (!metadata.has("vram_texture")) { + if (!meta.has("vram_texture")) { return false; } - bool vram = metadata["vram_texture"]; + bool vram = meta["vram_texture"]; if (!vram) { return true; //do not care about non vram } Vector<String> formats_imported; - if (metadata.has("imported_formats")) { - formats_imported = metadata["imported_formats"]; + if (meta.has("imported_formats")) { + formats_imported = meta["imported_formats"]; } int index = 0; diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index c06756ff0b..73f1c0b39b 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -669,23 +669,23 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } if (r_metadata) { - Dictionary metadata; - metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED; + Dictionary meta; + meta["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED; if (formats_imported.size()) { - metadata["imported_formats"] = formats_imported; + meta["imported_formats"] = formats_imported; } if (editor_image.is_valid()) { - metadata["has_editor_variant"] = true; + meta["has_editor_variant"] = true; if (use_editor_scale) { - metadata["editor_scale"] = EDSCALE; + meta["editor_scale"] = EDSCALE; } if (convert_editor_colors) { - metadata["editor_dark_theme"] = EditorSettings::get_singleton()->is_dark_theme(); + meta["editor_dark_theme"] = EditorSettings::get_singleton()->is_dark_theme(); } } - *r_metadata = metadata; + *r_metadata = meta; } return OK; } @@ -715,29 +715,29 @@ String ResourceImporterTexture::get_import_settings_string() const { bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) const { //will become invalid if formats are missing to import - Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path); + Dictionary meta = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path); - if (metadata.has("has_editor_variant")) { - if (metadata.has("editor_scale") && (float)metadata["editor_scale"] != EDSCALE) { + if (meta.has("has_editor_variant")) { + if (meta.has("editor_scale") && (float)meta["editor_scale"] != EDSCALE) { return false; } - if (metadata.has("editor_dark_theme") && (bool)metadata["editor_dark_theme"] != EditorSettings::get_singleton()->is_dark_theme()) { + if (meta.has("editor_dark_theme") && (bool)meta["editor_dark_theme"] != EditorSettings::get_singleton()->is_dark_theme()) { return false; } } - if (!metadata.has("vram_texture")) { + if (!meta.has("vram_texture")) { return false; } - bool vram = metadata["vram_texture"]; + bool vram = meta["vram_texture"]; if (!vram) { return true; // Do not care about non-VRAM. } Vector<String> formats_imported; - if (metadata.has("imported_formats")) { - formats_imported = metadata["imported_formats"]; + if (meta.has("imported_formats")) { + formats_imported = meta["imported_formats"]; } int index = 0; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 74fdbdebd7..d8b75db30f 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -255,8 +255,8 @@ void InspectorDock::_resource_file_selected(String p_file) { } void InspectorDock::_save_resource(bool save_as) { - ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; + ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); + Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -270,8 +270,8 @@ void InspectorDock::_save_resource(bool save_as) { } void InspectorDock::_unref_resource() { - ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; + ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); + Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -281,8 +281,8 @@ void InspectorDock::_unref_resource() { } void InspectorDock::_copy_resource() { - ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; + ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); + Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -610,8 +610,8 @@ void InspectorDock::apply_script_properties(Object *p_object) { } for (const Pair<StringName, Variant> &E : stored_properties) { - Variant current; - if (si->get(E.first, current) && current.get_type() == E.second.get_type()) { + Variant current_prop; + if (si->get(E.first, current_prop) && current_prop.get_type() == E.second.get_type()) { si->set(E.first, E.second); } } diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 71ff77e9bc..a7ebf21cd2 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -80,11 +80,11 @@ void PluginConfigDialog::_on_confirmed() { if (!templates.is_empty()) { template_content = templates[0].content; } - Ref<Script> script = ScriptServer::get_language(lang_idx)->make_template(template_content, class_name, "EditorPlugin"); - script->set_path(script_path, true); - ResourceSaver::save(script); + Ref<Script> scr = ScriptServer::get_language(lang_idx)->make_template(template_content, class_name, "EditorPlugin"); + scr->set_path(script_path, true); + ResourceSaver::save(scr); - emit_signal(SNAME("plugin_ready"), script.ptr(), active_edit->is_pressed() ? _to_absolute_plugin_path(_get_subfolder()) : ""); + emit_signal(SNAME("plugin_ready"), scr.ptr(), active_edit->is_pressed() ? _to_absolute_plugin_path(_get_subfolder()) : ""); } else { EditorNode::get_singleton()->get_project_settings()->update_plugins(); } diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index c928b95642..cb07d8cf01 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -561,8 +561,8 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset); const Vector2 point = xform.xform(p); - const Color modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1); - p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, modulate); + const Color overlay_modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1); + p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, overlay_modulate); if (vertex == hover_point) { Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index f75dcdf2d6..765d85c1ac 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -406,11 +406,11 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) { making_triangle.clear(); if (p_tool == 2) { - Vector<Vector2> points; + Vector<Vector2> bl_points; for (int i = 0; i < blend_space->get_blend_point_count(); i++) { - points.push_back(blend_space->get_blend_point_position(i)); + bl_points.push_back(blend_space->get_blend_point_position(i)); } - Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(points); + Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(bl_points); for (int i = 0; i < tr.size(); i++) { blend_space->add_triangle(tr[i].points[0], tr[i].points[1], tr[i].points[2]); } @@ -494,8 +494,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { //triangles first for (int i = 0; i < blend_space->get_triangle_count(); i++) { - Vector<Vector2> points; - points.resize(3); + Vector<Vector2> bl_points; + bl_points.resize(3); for (int j = 0; j < 3; j++) { int point_idx = blend_space->get_triangle_point(i, j); @@ -509,11 +509,11 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point *= s; point.y = s.height - point.y; - points.write[j] = point; + bl_points.write[j] = point; } for (int j = 0; j < 3; j++) { - blend_space_draw->draw_line(points[j], points[(j + 1) % 3], linecolor, Math::round(EDSCALE), true); + blend_space_draw->draw_line(bl_points[j], bl_points[(j + 1) % 3], linecolor, Math::round(EDSCALE), true); } Color color; @@ -530,7 +530,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { color, color }; - blend_space_draw->draw_primitive(points, colors, Vector<Vector2>()); + blend_space_draw->draw_primitive(bl_points, colors, Vector<Vector2>()); } points.clear(); @@ -560,19 +560,19 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { } if (making_triangle.size()) { - Vector<Vector2> points; + Vector<Vector2> bl_points; for (int i = 0; i < making_triangle.size(); i++) { Vector2 point = blend_space->get_blend_point_position(making_triangle[i]); point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point *= s; point.y = s.height - point.y; - points.push_back(point); + bl_points.push_back(point); } - for (int i = 0; i < points.size() - 1; i++) { - blend_space_draw->draw_line(points[i], points[i + 1], linecolor, Math::round(2 * EDSCALE), true); + for (int i = 0; i < bl_points.size() - 1; i++) { + blend_space_draw->draw_line(bl_points[i], bl_points[i + 1], linecolor, Math::round(2 * EDSCALE), true); } - blend_space_draw->draw_line(points[points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, Math::round(2 * EDSCALE), true); + blend_space_draw->draw_line(bl_points[bl_points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, Math::round(2 * EDSCALE), true); } ///draw cursor position diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index ca7b2d0015..067730a87a 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -262,10 +262,10 @@ void AnimationNodeBlendTreeEditor::update_graph() { node->add_theme_color_override("resizer_color", c); } - List<AnimationNodeBlendTree::NodeConnection> connections; - blend_tree->get_node_connections(&connections); + List<AnimationNodeBlendTree::NodeConnection> node_connections; + blend_tree->get_node_connections(&node_connections); - for (const AnimationNodeBlendTree::NodeConnection &E : connections) { + for (const AnimationNodeBlendTree::NodeConnection &E : node_connections) { StringName from = E.output_node; StringName to = E.input_node; int to_idx = E.input_index; @@ -293,9 +293,9 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { if (p_idx == MENU_LOAD_FILE) { open_file->clear_filters(); - List<String> filters; - ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters); - for (const String &E : filters) { + List<String> ext_filters; + ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &ext_filters); + for (const String &E : ext_filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); @@ -611,10 +611,10 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano HashSet<String> paths; HashMap<String, RBSet<String>> types; { - List<StringName> animations; - player->get_animation_list(&animations); + List<StringName> animation_list; + player->get_animation_list(&animation_list); - for (const StringName &E : animations) { + for (const StringName &E : animation_list) { Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { String track_path = anim->track_get_path(i); @@ -970,10 +970,10 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima //recreate connections graph->clear_connections(); - List<AnimationNodeBlendTree::NodeConnection> connections; - blend_tree->get_node_connections(&connections); + List<AnimationNodeBlendTree::NodeConnection> node_connections; + blend_tree->get_node_connections(&node_connections); - for (const AnimationNodeBlendTree::NodeConnection &E : connections) { + for (const AnimationNodeBlendTree::NodeConnection &E : node_connections) { StringName from = E.output_node; StringName to = E.input_node; int to_idx = E.input_index; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index e8caac565c..dc84c08506 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -826,13 +826,13 @@ void AnimationPlayerEditor::_update_player() { } // Check if the global library is foreign since we want to disable options for adding/remove/renaming animations if it is. - Ref<AnimationLibrary> library = player->get_animation_library(K); + Ref<AnimationLibrary> anim_library = player->get_animation_library(K); if (K == "") { - foreign_global_anim_lib = EditorNode::get_singleton()->is_resource_read_only(library); + foreign_global_anim_lib = EditorNode::get_singleton()->is_resource_read_only(anim_library); } List<StringName> animlist; - library->get_animation_list(&animlist); + anim_library->get_animation_list(&animlist); for (const StringName &E : animlist) { String path = K; @@ -913,19 +913,19 @@ void AnimationPlayerEditor::_update_player() { void AnimationPlayerEditor::_update_animation_list_icons() { for (int i = 0; i < animation->get_item_count(); i++) { - String name = animation->get_item_text(i); + String anim_name = animation->get_item_text(i); if (animation->is_item_disabled(i) || animation->is_item_separator(i)) { continue; } Ref<Texture2D> icon; - if (name == player->get_autoplay()) { - if (name == SceneStringNames::get_singleton()->RESET) { + if (anim_name == player->get_autoplay()) { + if (anim_name == SceneStringNames::get_singleton()->RESET) { icon = autoplay_reset_icon; } else { icon = autoplay_icon; } - } else if (name == SceneStringNames::get_singleton()->RESET) { + } else if (anim_name == SceneStringNames::get_singleton()->RESET) { icon = reset_icon; } @@ -1356,8 +1356,8 @@ void AnimationPlayerEditor::_free_onion_layers() { void AnimationPlayerEditor::_prepare_onion_layers_1() { // This would be called per viewport and we want to act once only. - int64_t frame = get_tree()->get_frame(); - if (frame == onion.last_frame) { + int64_t cur_frame = get_tree()->get_frame(); + if (cur_frame == onion.last_frame) { return; } @@ -1366,7 +1366,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() { return; } - onion.last_frame = frame; + onion.last_frame = cur_frame; // Refresh viewports with no onion layers overlaid. onion.can_overlay = false; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 3c9486cdaa..2d1f4088a0 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -243,19 +243,19 @@ void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_a } void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) { - Preview preview; - preview.id = p_id; - preview.video_link = p_url; - preview.is_video = p_video; - preview.button = memnew(Button); - preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"))); - preview.button->set_toggle_mode(true); - preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id)); - preview_hb->add_child(preview.button); + Preview new_preview; + new_preview.id = p_id; + new_preview.video_link = p_url; + new_preview.is_video = p_video; + new_preview.button = memnew(Button); + new_preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"))); + new_preview.button->set_toggle_mode(true); + new_preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id)); + preview_hb->add_child(new_preview.button); if (!p_video) { - preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")); + new_preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")); } - preview_images.push_back(preview); + preview_images.push_back(new_preview); if (preview_images.size() == 1 && !p_video) { _preview_click(p_id); } diff --git a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp index d670197c53..e21a50a434 100644 --- a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp +++ b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp @@ -44,8 +44,8 @@ void AudioStreamRandomizerEditorPlugin::make_visible(bool p_visible) { } void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(undo_redo.is_null()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(undo_redo_man.is_null()); AudioStreamRandomizer *randomizer = Object::cast_to<AudioStreamRandomizer>(p_edited); if (!randomizer) { @@ -76,12 +76,12 @@ void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_und end = MIN(MAX(p_from_index, p_to_pos) + 1, end); } -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); // Save layers' properties. if (p_from_index < 0) { - undo_redo->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos); + undo_redo_man->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_undo_method(randomizer, "add_stream", p_from_index); + undo_redo_man->add_undo_method(randomizer, "add_stream", p_from_index); } List<PropertyInfo> properties; @@ -107,11 +107,11 @@ void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_und #undef ADD_UNDO if (p_from_index < 0) { - undo_redo->add_do_method(randomizer, "add_stream", p_to_pos); + undo_redo_man->add_do_method(randomizer, "add_stream", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(randomizer, "remove_stream", p_from_index); + undo_redo_man->add_do_method(randomizer, "remove_stream", p_from_index); } else { - undo_redo->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos); + undo_redo_man->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos); } } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 84b8b4aed8..6e108a9a72 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -304,7 +304,7 @@ void CanvasItemEditor::_snap_other_nodes( Point2 &r_current_snap, SnapTarget (&r_current_snap_target)[2], const SnapTarget p_snap_target, List<const CanvasItem *> p_exceptions, const Node *p_current) { - const CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_current); + const CanvasItem *ci = Object::cast_to<CanvasItem>(p_current); // Check if the element is in the exception bool exception = false; @@ -315,12 +315,12 @@ void CanvasItemEditor::_snap_other_nodes( } }; - if (canvas_item && !exception) { - Transform2D ci_transform = canvas_item->get_global_transform_with_canvas(); + if (ci && !exception) { + Transform2D ci_transform = ci->get_global_transform_with_canvas(); if (fmod(ci_transform.get_rotation() - p_transform_to_snap.get_rotation(), (real_t)360.0) == 0.0) { - if (canvas_item->_edit_use_rect()) { - Point2 begin = ci_transform.xform(canvas_item->_edit_get_rect().get_position()); - Point2 end = ci_transform.xform(canvas_item->_edit_get_rect().get_position() + canvas_item->_edit_get_rect().get_size()); + if (ci->_edit_use_rect()) { + Point2 begin = ci_transform.xform(ci->_edit_get_rect().get_position()); + Point2 end = ci_transform.xform(ci->_edit_get_rect().get_position() + ci->_edit_get_rect().get_size()); _snap_if_closer_point(p_value, r_current_snap, r_current_snap_target, begin, p_snap_target, ci_transform.get_rotation()); _snap_if_closer_point(p_value, r_current_snap, r_current_snap_target, end, p_snap_target, ci_transform.get_rotation()); @@ -528,14 +528,14 @@ Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_li ERR_FAIL_COND_V(p_list.is_empty(), Rect2()); // Handles the first element - CanvasItem *canvas_item = p_list.front()->get(); - Rect2 rect = Rect2(canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_rect().get_center()), Size2()); + CanvasItem *ci = p_list.front()->get(); + Rect2 rect = Rect2(ci->get_global_transform_with_canvas().xform(ci->_edit_get_rect().get_center()), Size2()); // Expand with the other ones - for (CanvasItem *canvas_item2 : p_list) { - Transform2D xform = canvas_item2->get_global_transform_with_canvas(); + for (CanvasItem *ci2 : p_list) { + Transform2D xform = ci2->get_global_transform_with_canvas(); - Rect2 current_rect = canvas_item2->_edit_get_rect(); + Rect2 current_rect = ci2->_edit_get_rect(); rect.expand_to(xform.xform(current_rect.position)); rect.expand_to(xform.xform(current_rect.position + Vector2(current_rect.size.x, 0))); rect.expand_to(xform.xform(current_rect.position + current_rect.size)); @@ -553,24 +553,24 @@ void CanvasItemEditor::_expand_encompassing_rect_using_children(Rect2 &r_rect, c return; } - const CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); + const CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); for (int i = p_node->get_child_count() - 1; i >= 0; i--) { - if (canvas_item && !canvas_item->is_set_as_top_level()) { - _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); + if (ci && !ci->is_set_as_top_level()) { + _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, p_parent_xform * ci->get_transform(), p_canvas_xform); } else { - const CanvasLayer *canvas_layer = Object::cast_to<CanvasLayer>(p_node); - _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, Transform2D(), canvas_layer ? canvas_layer->get_transform() : p_canvas_xform); + const CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); + _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, Transform2D(), cl ? cl->get_transform() : p_canvas_xform); } } - if (canvas_item && canvas_item->is_visible_in_tree() && (include_locked_nodes || !_is_node_locked(canvas_item))) { + if (ci && ci->is_visible_in_tree() && (include_locked_nodes || !_is_node_locked(ci))) { Transform2D xform = p_canvas_xform; - if (!canvas_item->is_set_as_top_level()) { + if (!ci->is_set_as_top_level()) { xform *= p_parent_xform; } - xform *= canvas_item->get_transform(); - Rect2 rect = canvas_item->_edit_get_rect(); + xform *= ci->get_transform(); + Rect2 rect = ci->_edit_get_rect(); if (r_first) { r_rect = Rect2(xform.xform(rect.get_center()), Size2()); r_first = false; @@ -599,14 +599,14 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no } const real_t grab_distance = EDITOR_GET("editors/polygon_editor/point_grab_radius"); - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); for (int i = p_node->get_child_count() - 1; i >= 0; i--) { - if (canvas_item) { - if (!canvas_item->is_set_as_top_level()) { - _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); + if (ci) { + if (!ci->is_set_as_top_level()) { + _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_parent_xform * ci->get_transform(), p_canvas_xform); } else { - _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, canvas_item->get_transform(), p_canvas_xform); + _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, ci->get_transform(), p_canvas_xform); } } else { CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); @@ -614,18 +614,18 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no } } - if (canvas_item && canvas_item->is_visible_in_tree()) { + if (ci && ci->is_visible_in_tree()) { Transform2D xform = p_canvas_xform; - if (!canvas_item->is_set_as_top_level()) { + if (!ci->is_set_as_top_level()) { xform *= p_parent_xform; } - xform = (xform * canvas_item->get_transform()).affine_inverse(); + xform = (xform * ci->get_transform()).affine_inverse(); const real_t local_grab_distance = xform.basis_xform(Vector2(grab_distance, 0)).length() / zoom; - if (canvas_item->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) { - Node2D *node = Object::cast_to<Node2D>(canvas_item); + if (ci->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) { + Node2D *node = Object::cast_to<Node2D>(ci); _SelectResult res; - res.item = canvas_item; + res.item = ci; res.z_index = node ? node->get_z_index() : 0; res.has_z = node; r_items.push_back(res); @@ -647,13 +647,13 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel node = scene->get_deepest_editable_node(node); } - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(node); + CanvasItem *ci = Object::cast_to<CanvasItem>(node); if (!p_allow_locked) { // Replace the node by the group if grouped while (node && node != scene->get_parent()) { - CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node); - if (canvas_item_tmp && node->has_meta("_edit_group_")) { - canvas_item = canvas_item_tmp; + CanvasItem *ci_tmp = Object::cast_to<CanvasItem>(node); + if (ci_tmp && node->has_meta("_edit_group_")) { + ci = ci_tmp; } node = node->get_parent(); } @@ -662,18 +662,18 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel // Check if the canvas item is already in the list (for groups or scenes) bool duplicate = false; for (int j = 0; j < i; j++) { - if (r_items[j].item == canvas_item) { + if (r_items[j].item == ci) { duplicate = true; break; } } //Remove the item if invalid - if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || (!p_allow_locked && _is_node_locked(canvas_item))) { + if (!ci || duplicate || (ci != scene && ci->get_owner() != scene && !scene->is_editable_instance(ci->get_owner())) || (!p_allow_locked && _is_node_locked(ci))) { r_items.remove_at(i); i--; } else { - r_items.write[i].item = canvas_item; + r_items.write[i].item = ci; } } } @@ -686,7 +686,7 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n return; } - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); Node *scene = EditorNode::get_singleton()->get_edited_scene(); bool editable = p_node == scene || p_node->get_owner() == scene || p_node == scene->get_deepest_editable_node(p_node); @@ -695,37 +695,37 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n if (!lock_children || !editable) { for (int i = p_node->get_child_count() - 1; i >= 0; i--) { - if (canvas_item) { - if (!canvas_item->is_set_as_top_level()) { - _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); + if (ci) { + if (!ci->is_set_as_top_level()) { + _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, p_parent_xform * ci->get_transform(), p_canvas_xform); } else { - _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, canvas_item->get_transform(), p_canvas_xform); + _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, ci->get_transform(), p_canvas_xform); } } else { - CanvasLayer *canvas_layer = Object::cast_to<CanvasLayer>(p_node); - _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, Transform2D(), canvas_layer ? canvas_layer->get_transform() : p_canvas_xform); + CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); + _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, Transform2D(), cl ? cl->get_transform() : p_canvas_xform); } } } - if (canvas_item && canvas_item->is_visible_in_tree() && !locked && editable) { + if (ci && ci->is_visible_in_tree() && !locked && editable) { Transform2D xform = p_canvas_xform; - if (!canvas_item->is_set_as_top_level()) { + if (!ci->is_set_as_top_level()) { xform *= p_parent_xform; } - xform *= canvas_item->get_transform(); + xform *= ci->get_transform(); - if (canvas_item->_edit_use_rect()) { - Rect2 rect = canvas_item->_edit_get_rect(); + if (ci->_edit_use_rect()) { + Rect2 rect = ci->_edit_get_rect(); if (p_rect.has_point(xform.xform(rect.position)) && p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, 0))) && p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, rect.size.y))) && p_rect.has_point(xform.xform(rect.position + Vector2(0, rect.size.y)))) { - r_items->push_back(canvas_item); + r_items->push_back(ci); } } else { if (p_rect.has_point(xform.xform(Point2()))) { - r_items->push_back(canvas_item); + r_items->push_back(ci); } } } @@ -765,11 +765,11 @@ bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_po List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retrieve_locked, bool remove_canvas_item_if_parent_in_selection) { List<CanvasItem *> selection; for (const KeyValue<Node *, Object *> &E : editor_selection->get_selection()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(canvas_item))) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (ci && ci->is_visible_in_tree() && ci->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(ci))) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); if (se) { - selection.push_back(canvas_item); + selection.push_back(ci); } } } @@ -819,18 +819,18 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items original_transform = Transform2D(); bool transform_stored = false; - for (CanvasItem *canvas_item : p_canvas_items) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + for (CanvasItem *ci : p_canvas_items) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); if (se) { if (!transform_stored) { - original_transform = canvas_item->get_global_transform(); + original_transform = ci->get_global_transform(); transform_stored = true; } - se->undo_state = canvas_item->_edit_get_state(); - se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - if (canvas_item->_edit_use_rect()) { - se->pre_drag_rect = canvas_item->_edit_get_rect(); + se->undo_state = ci->_edit_get_state(); + se->pre_drag_xform = ci->get_global_transform_with_canvas(); + if (ci->_edit_use_rect()) { + se->pre_drag_rect = ci->_edit_get_rect(); } else { se->pre_drag_rect = Rect2(); } @@ -839,20 +839,20 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items } void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_items, bool restore_bones) { - for (CanvasItem *canvas_item : drag_selection) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); - canvas_item->_edit_set_state(se->undo_state); + for (CanvasItem *ci : drag_selection) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); + ci->_edit_set_state(se->undo_state); } } void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) { List<CanvasItem *> modified_canvas_items; - for (CanvasItem *canvas_item : p_canvas_items) { - Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item)->undo_state; - Dictionary new_state = canvas_item->_edit_get_state(); + for (CanvasItem *ci : p_canvas_items) { + Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci)->undo_state; + Dictionary new_state = ci->_edit_get_state(); if (old_state.hash() != new_state.hash()) { - modified_canvas_items.push_back(canvas_item); + modified_canvas_items.push_back(ci); } } @@ -861,16 +861,16 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite } undo_redo->create_action(action_name); - for (CanvasItem *canvas_item : modified_canvas_items) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + for (CanvasItem *ci : modified_canvas_items) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); if (se) { - undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); + undo_redo->add_do_method(ci, "_edit_set_state", ci->_edit_get_state()); + undo_redo->add_undo_method(ci, "_edit_set_state", se->undo_state); if (commit_bones) { for (const Dictionary &F : se->pre_drag_bones_undo_state) { - canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent()); - undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", F); + ci = Object::cast_to<CanvasItem>(ci->get_parent()); + undo_redo->add_do_method(ci, "_edit_set_state", ci->_edit_get_state()); + undo_redo->add_undo_method(ci, "_edit_set_state", F); } } } @@ -1318,9 +1318,9 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { // Filters the selection with nodes that allow setting the pivot drag_selection = List<CanvasItem *>(); - for (CanvasItem *canvas_item : selection) { - if (canvas_item->_edit_use_pivot()) { - drag_selection.push_back(canvas_item); + for (CanvasItem *ci : selection) { + if (ci->_edit_use_pivot()) { + drag_selection.push_back(ci); } } @@ -1334,8 +1334,8 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, nullptr, drag_selection); } - for (CanvasItem *canvas_item : drag_selection) { - canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); + for (CanvasItem *ci : drag_selection) { + ci->_edit_set_pivot(ci->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } drag_type = DRAG_PIVOT; @@ -1355,8 +1355,8 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_to, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL); } - for (CanvasItem *canvas_item : drag_selection) { - canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); + for (CanvasItem *ci : drag_selection) { + ci->_edit_set_pivot(ci->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } return true; } @@ -1408,11 +1408,11 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { if (drag_selection.size() > 0) { drag_type = DRAG_ROTATE; drag_from = transform.affine_inverse().xform(b->get_position()); - CanvasItem *canvas_item = drag_selection[0]; - if (canvas_item->_edit_use_pivot()) { - drag_rotation_center = canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_pivot()); + CanvasItem *ci = drag_selection[0]; + if (ci->_edit_use_pivot()) { + drag_rotation_center = ci->get_global_transform_with_canvas().xform(ci->_edit_get_pivot()); } else { - drag_rotation_center = canvas_item->get_global_transform_with_canvas().get_origin(); + drag_rotation_center = ci->get_global_transform_with_canvas().get_origin(); } _save_canvas_item_state(drag_selection); return true; @@ -1425,11 +1425,11 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { // Rotate the node if (m.is_valid()) { _restore_canvas_item_state(drag_selection); - for (CanvasItem *canvas_item : drag_selection) { + for (CanvasItem *ci : drag_selection) { drag_to = transform.affine_inverse().xform(m->get_position()); //Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements - bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0); - canvas_item->_edit_set_rotation(snap_angle(canvas_item->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), canvas_item->_edit_get_rotation())); + bool opposite = (ci->get_global_transform().get_scale().sign().dot(ci->get_transform().get_scale().sign()) == 0); + ci->_edit_set_rotation(snap_angle(ci->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), ci->_edit_get_rotation())); viewport->queue_redraw(); } return true; @@ -1477,9 +1477,9 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && b->is_double_click() && tool == TOOL_SELECT) { List<CanvasItem *> selection = _get_edited_canvas_items(); if (selection.size() == 1) { - CanvasItem *canvas_item = selection[0]; - if (!canvas_item->get_scene_file_path().is_empty() && canvas_item != EditorNode::get_singleton()->get_edited_scene()) { - EditorNode::get_singleton()->open_request(canvas_item->get_scene_file_path()); + CanvasItem *ci = selection[0]; + if (!ci->get_scene_file_path().is_empty() && ci != EditorNode::get_singleton()->get_edited_scene()) { + EditorNode::get_singleton()->open_request(ci->get_scene_file_path()); return true; } } @@ -1641,10 +1641,10 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && tool == TOOL_SELECT) { List<CanvasItem *> selection = _get_edited_canvas_items(); if (selection.size() == 1) { - CanvasItem *canvas_item = selection[0]; - if (canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) { - Rect2 rect = canvas_item->_edit_get_rect(); - Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); + CanvasItem *ci = selection[0]; + if (ci->_edit_use_rect() && _is_node_movable(ci)) { + Rect2 rect = ci->_edit_get_rect(); + Transform2D xform = transform * ci->get_global_transform_with_canvas(); const Vector2 endpoints[4] = { xform.xform(rect.position), @@ -1689,7 +1689,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { drag_type = resize_drag; drag_from = transform.affine_inverse().xform(b->get_position()); drag_selection = List<CanvasItem *>(); - drag_selection.push_back(canvas_item); + drag_selection.push_back(ci); _save_canvas_item_state(drag_selection); return true; } @@ -1702,36 +1702,36 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { drag_type == DRAG_TOP_LEFT || drag_type == DRAG_TOP_RIGHT || drag_type == DRAG_BOTTOM_LEFT || drag_type == DRAG_BOTTOM_RIGHT) { // Resize the node if (m.is_valid()) { - CanvasItem *canvas_item = drag_selection[0]; - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + CanvasItem *ci = drag_selection[0]; + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); //Reset state - canvas_item->_edit_set_state(se->undo_state); + ci->_edit_set_state(se->undo_state); bool uniform = m->is_shift_pressed(); bool symmetric = m->is_alt_pressed(); - Rect2 local_rect = canvas_item->_edit_get_rect(); + Rect2 local_rect = ci->_edit_get_rect(); real_t aspect = local_rect.get_size().y / local_rect.get_size().x; Point2 current_begin = local_rect.get_position(); Point2 current_end = local_rect.get_position() + local_rect.get_size(); - Point2 max_begin = (symmetric) ? (current_begin + current_end - canvas_item->_edit_get_minimum_size()) / 2.0 : current_end - canvas_item->_edit_get_minimum_size(); - Point2 min_end = (symmetric) ? (current_begin + current_end + canvas_item->_edit_get_minimum_size()) / 2.0 : current_begin + canvas_item->_edit_get_minimum_size(); + Point2 max_begin = (symmetric) ? (current_begin + current_end - ci->_edit_get_minimum_size()) / 2.0 : current_end - ci->_edit_get_minimum_size(); + Point2 min_end = (symmetric) ? (current_begin + current_end + ci->_edit_get_minimum_size()) / 2.0 : current_begin + ci->_edit_get_minimum_size(); Point2 center = (current_begin + current_end) / 2.0; drag_to = transform.affine_inverse().xform(m->get_position()); - Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse(); + Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse(); Point2 drag_to_snapped_begin; Point2 drag_to_snapped_end; // last call decides which snapping lines are drawn if (drag_type == DRAG_LEFT || drag_type == DRAG_TOP || drag_type == DRAG_TOP_LEFT) { - drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item); - drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item); + drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci); + drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci); } else { - drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item); - drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item); + drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci); + drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci); } Point2 drag_begin = xform.xform(drag_to_snapped_begin); @@ -1787,7 +1787,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { current_begin.y = 2.0 * center.y - current_end.y; } } - canvas_item->_edit_set_rect(Rect2(current_begin, current_end - current_begin)); + ci->_edit_set_rect(Rect2(current_begin, current_end - current_begin)); return true; } @@ -1850,11 +1850,11 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && ((b->is_alt_pressed() && b->is_ctrl_pressed()) || tool == TOOL_SCALE)) { List<CanvasItem *> selection = _get_edited_canvas_items(); if (selection.size() == 1) { - CanvasItem *canvas_item = selection[0]; + CanvasItem *ci = selection[0]; - if (_is_node_movable(canvas_item)) { - Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + if (_is_node_movable(ci)) { + Transform2D xform = transform * ci->get_global_transform_with_canvas(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; drag_type = DRAG_SCALE_BOTH; @@ -1873,7 +1873,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { drag_from = transform.affine_inverse().xform(b->get_position()); drag_selection = List<CanvasItem *>(); - drag_selection.push_back(canvas_item); + drag_selection.push_back(ci); _save_canvas_item_state(drag_selection); return true; } @@ -1885,12 +1885,12 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { // Resize the node if (m.is_valid()) { _restore_canvas_item_state(drag_selection); - CanvasItem *canvas_item = drag_selection[0]; + CanvasItem *ci = drag_selection[0]; drag_to = transform.affine_inverse().xform(m->get_position()); - Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse(); - Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D parent_xform = ci->get_global_transform_with_canvas() * ci->get_transform().affine_inverse(); + Transform2D unscaled_transform = (transform * parent_xform * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform; bool uniform = m->is_shift_pressed(); @@ -1900,7 +1900,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { Point2 drag_to_local = simple_xform.xform(drag_to); Point2 offset = drag_to_local - drag_from_local; - Size2 scale = canvas_item->_edit_get_scale(); + Size2 scale = ci->_edit_get_scale(); Size2 original_scale = scale; real_t ratio = scale.y / scale.x; if (drag_type == DRAG_SCALE_BOTH) { @@ -1938,7 +1938,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { } } - canvas_item->_edit_set_scale(scale); + ci->_edit_set_scale(scale); return true; } @@ -1999,9 +1999,9 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (selection.size() > 0) { drag_type = DRAG_MOVE; - CanvasItem *canvas_item = selection[0]; - Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse(); - Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized(); + CanvasItem *ci = selection[0]; + Transform2D parent_xform = ci->get_global_transform_with_canvas() * ci->get_transform().affine_inverse(); + Transform2D unscaled_transform = (transform * parent_xform * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; if (show_transformation_gizmos) { @@ -2058,10 +2058,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (CanvasItem *canvas_item : drag_selection) { - Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); + for (CanvasItem *ci : drag_selection) { + Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse() * ci->get_transform(); - canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); + ci->_edit_set_position(ci->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); index++; } return true; @@ -2181,10 +2181,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (CanvasItem *canvas_item : drag_selection) { - Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); + for (CanvasItem *ci : drag_selection) { + Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse() * ci->get_transform(); - canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); + ci->_edit_set_position(ci->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); index++; } } @@ -2263,8 +2263,8 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { Node *node = item; while (node && node != scene->get_parent()) { - CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node); - if (canvas_item_tmp && node->has_meta("_edit_group_")) { + CanvasItem *ci_tmp = Object::cast_to<CanvasItem>(node); + if (ci_tmp && node->has_meta("_edit_group_")) { locked = 2; } node = node->get_parent(); @@ -2325,16 +2325,16 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { } // Find the item to select - CanvasItem *canvas_item = nullptr; + CanvasItem *ci = nullptr; Vector<_SelectResult> selection = Vector<_SelectResult>(); // Retrieve the canvas items _get_canvas_items_at_pos(click, selection); if (!selection.is_empty()) { - canvas_item = selection[0].item; + ci = selection[0].item; } - if (!canvas_item) { + if (!ci) { // Start a box selection if (!b->is_shift_pressed()) { // Clear the selection if not additive @@ -2348,7 +2348,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { box_selecting_to = drag_from; return true; } else { - bool still_selected = _select_click_on_item(canvas_item, click, b->is_shift_pressed()); + bool still_selected = _select_click_on_item(ci, click, b->is_shift_pressed()); // Start dragging if (still_selected) { // Drag the node(s) if requested @@ -2488,16 +2488,16 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { // Compute the nodes names and icon position Vector<_HoverResult> hovering_results_tmp; for (int i = 0; i < hovering_results_items.size(); i++) { - CanvasItem *canvas_item = hovering_results_items[i].item; + CanvasItem *ci = hovering_results_items[i].item; - if (canvas_item->_edit_use_rect()) { + if (ci->_edit_use_rect()) { continue; } _HoverResult hover_result; - hover_result.position = canvas_item->get_global_transform_with_canvas().get_origin(); - hover_result.icon = EditorNode::get_singleton()->get_object_icon(canvas_item); - hover_result.name = canvas_item->get_name(); + hover_result.position = ci->get_global_transform_with_canvas().get_origin(); + hover_result.icon = EditorNode::get_singleton()->get_object_icon(ci); + hover_result.name = ci->get_name(); hovering_results_tmp.push_back(hover_result); } @@ -3312,16 +3312,16 @@ void CanvasItemEditor::_draw_selection() { Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); Ref<Texture2D> previous_position_icon = get_theme_icon(SNAME("EditorPositionPrevious"), SNAME("EditorIcons")); - RID ci = viewport->get_canvas_item(); + RID vp_ci = viewport->get_canvas_item(); List<CanvasItem *> selection = _get_edited_canvas_items(true, false); bool single = selection.size() == 1; for (CanvasItem *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); - bool item_locked = canvas_item->has_meta("_edit_lock_"); + bool item_locked = ci->has_meta("_edit_lock_"); // Draw the previous position if we are dragging the node if (show_helpers && @@ -3331,7 +3331,7 @@ void CanvasItemEditor::_draw_selection() { const Transform2D pre_drag_xform = transform * se->pre_drag_xform; const Color pre_drag_color = Color(0.4, 0.6, 1, 0.7); - if (canvas_item->_edit_use_rect()) { + if (ci->_edit_use_rect()) { Vector2 pre_drag_endpoints[4] = { pre_drag_xform.xform(se->pre_drag_rect.position), pre_drag_xform.xform(se->pre_drag_rect.position + Vector2(se->pre_drag_rect.size.x, 0)), @@ -3347,11 +3347,11 @@ void CanvasItemEditor::_draw_selection() { } } - Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); + Transform2D xform = transform * ci->get_global_transform_with_canvas(); // Draw the selected items position / surrounding boxes - if (canvas_item->_edit_use_rect()) { - Rect2 rect = canvas_item->_edit_get_rect(); + if (ci->_edit_use_rect()) { + Rect2 rect = ci->_edit_get_rect(); const Vector2 endpoints[4] = { xform.xform(rect.position), xform.xform(rect.position + Vector2(rect.size.x, 0)), @@ -3369,7 +3369,7 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE)); } } else { - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); viewport->draw_texture(position_icon, -(position_icon->get_size() / 2)); @@ -3378,9 +3378,9 @@ void CanvasItemEditor::_draw_selection() { if (single && !item_locked && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks // Draw the pivot - if (canvas_item->_edit_use_pivot()) { + if (ci->_edit_use_pivot()) { // Draw the node's pivot - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); @@ -3389,15 +3389,15 @@ void CanvasItemEditor::_draw_selection() { } // Draw control-related helpers - Control *control = Object::cast_to<Control>(canvas_item); + Control *control = Object::cast_to<Control>(ci); if (control && _is_node_movable(control)) { _draw_control_anchors(control); _draw_control_helpers(control); } // Draw the resize handles - if (tool == TOOL_SELECT && canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) { - Rect2 rect = canvas_item->_edit_get_rect(); + if (tool == TOOL_SELECT && ci->_edit_use_rect() && _is_node_movable(ci)) { + Rect2 rect = ci->_edit_get_rect(); const Vector2 endpoints[4] = { xform.xform(rect.position), xform.xform(rect.position + Vector2(rect.size.x, 0)), @@ -3411,12 +3411,12 @@ void CanvasItemEditor::_draw_selection() { Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized(); ofs *= Math_SQRT2 * (select_handle->get_size().width / 2); - select_handle->draw(ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor()); + select_handle->draw(vp_ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor()); ofs = (endpoints[i] + endpoints[next]) / 2; ofs += (endpoints[next] - endpoints[i]).orthogonal().normalized() * (select_handle->get_size().width / 2); - select_handle->draw(ci, (ofs - (select_handle->get_size() / 2)).floor()); + select_handle->draw(vp_ci, (ofs - (select_handle->get_size() / 2)).floor()); } } @@ -3424,8 +3424,8 @@ void CanvasItemEditor::_draw_selection() { bool is_ctrl = Input::get_singleton()->is_key_pressed(Key::CTRL); bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT); if (tool == TOOL_MOVE && show_transformation_gizmos) { - if (_is_node_movable(canvas_item)) { - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + if (_is_node_movable(ci)) { + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE); @@ -3454,8 +3454,8 @@ void CanvasItemEditor::_draw_selection() { // Draw the rescale handles if (show_transformation_gizmos && ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y)) { - if (_is_node_movable(canvas_item)) { - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + if (_is_node_movable(ci)) { + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); @@ -3589,16 +3589,16 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans 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_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); + if (ci && !ci->is_visible_in_tree()) { return; } Transform2D parent_xform = p_parent_xform; Transform2D canvas_xform = p_canvas_xform; - if (canvas_item && !canvas_item->is_set_as_top_level()) { - parent_xform = parent_xform * canvas_item->get_transform(); + if (ci && !ci->is_set_as_top_level()) { + parent_xform = parent_xform * ci->get_transform(); } else { CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); parent_xform = Transform2D(); @@ -3609,12 +3609,12 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans _draw_invisible_nodes_positions(p_node->get_child(i), parent_xform, canvas_xform); } - if (canvas_item && !canvas_item->_edit_use_rect() && (!editor_selection->is_selected(canvas_item) || _is_node_locked(canvas_item))) { + if (ci && !ci->_edit_use_rect() && (!editor_selection->is_selected(ci) || _is_node_locked(ci))) { Transform2D xform = transform * canvas_xform * parent_xform; // Draw the node's position Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPositionUnselected"), SNAME("EditorIcons")); - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); viewport->draw_texture(position_icon, -position_icon->get_size() / 2, Color(1.0, 1.0, 1.0, 0.5)); @@ -3720,16 +3720,16 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p 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_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); + if (ci && !ci->is_visible_in_tree()) { return; } Transform2D parent_xform = p_parent_xform; Transform2D canvas_xform = p_canvas_xform; - if (canvas_item && !canvas_item->is_set_as_top_level()) { - parent_xform = parent_xform * canvas_item->get_transform(); + if (ci && !ci->is_set_as_top_level()) { + parent_xform = parent_xform * ci->get_transform(); } else { CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); parent_xform = Transform2D(); @@ -3740,19 +3740,19 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p _draw_locks_and_groups(p_node->get_child(i), parent_xform, canvas_xform); } - RID viewport_canvas_item = viewport->get_canvas_item(); - if (canvas_item) { + RID viewport_ci = viewport->get_canvas_item(); + if (ci) { real_t offset = 0; Ref<Texture2D> lock = get_theme_icon(SNAME("LockViewport"), SNAME("EditorIcons")); if (p_node->has_meta("_edit_lock_") && show_edit_locks) { - lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); + lock->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); offset += lock->get_size().x; } Ref<Texture2D> group = get_theme_icon(SNAME("GroupViewport"), SNAME("EditorIcons")); - if (canvas_item->has_meta("_edit_group_") && show_edit_locks) { - group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); + if (ci->has_meta("_edit_group_") && show_edit_locks) { + group->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); //offset += group->get_size().x; } } @@ -3885,16 +3885,16 @@ void CanvasItemEditor::_notification(int p_what) { // Update the viewport if the canvas_item changes List<CanvasItem *> selection = _get_edited_canvas_items(true); - for (CanvasItem *canvas_item : selection) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + for (CanvasItem *ci : selection) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); Rect2 rect; - if (canvas_item->_edit_use_rect()) { - rect = canvas_item->_edit_get_rect(); + if (ci->_edit_use_rect()) { + rect = ci->_edit_get_rect(); } else { rect = Rect2(); } - Transform2D xform = canvas_item->get_transform(); + Transform2D xform = ci->get_transform(); if (rect != se->prev_rect || xform != se->prev_xform) { viewport->queue_redraw(); @@ -3902,7 +3902,7 @@ void CanvasItemEditor::_notification(int p_what) { se->prev_xform = xform; } - Control *control = Object::cast_to<Control>(canvas_item); + Control *control = Object::cast_to<Control>(ci); if (control) { real_t anchors[4]; Vector2 pivot; @@ -3923,7 +3923,7 @@ void CanvasItemEditor::_notification(int p_what) { } } - if (canvas_item->_edit_use_pivot()) { + if (ci->_edit_use_pivot()) { nb_having_pivot++; } } @@ -4184,17 +4184,17 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, AnimationTrackEditor *te = AnimationPlayerEditor::get_singleton()->get_track_editor(); te->make_insert_queue(); for (const KeyValue<Node *, Object *> &E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (!canvas_item || !canvas_item->is_visible_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (!ci || !ci->is_visible_in_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->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 (Object::cast_to<Node2D>(ci)) { + Node2D *n2d = Object::cast_to<Node2D>(ci); if (key_pos && p_location) { te->insert_node_value_key(n2d, "position", n2d->get_position(), p_on_existing); @@ -4241,8 +4241,8 @@ 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); + } else if (Object::cast_to<Control>(ci)) { + Control *ctrl = Object::cast_to<Control>(ci); if (key_pos) { te->insert_node_value_key(ctrl, "position", ctrl->get_position(), p_on_existing); @@ -4390,16 +4390,16 @@ void CanvasItemEditor::_popup_callback(int p_op) { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - if (!canvas_item || !canvas_item->is_inside_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + if (!ci || !ci->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->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_"); + undo_redo->add_do_method(ci, "set_meta", "_edit_lock_", true); + undo_redo->add_undo_method(ci, "remove_meta", "_edit_lock_"); undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed"); } @@ -4412,16 +4412,16 @@ void CanvasItemEditor::_popup_callback(int p_op) { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - if (!canvas_item || !canvas_item->is_inside_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + if (!ci || !ci->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->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); + undo_redo->add_do_method(ci, "remove_meta", "_edit_lock_"); + undo_redo->add_undo_method(ci, "set_meta", "_edit_lock_", true); undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed"); } @@ -4434,16 +4434,16 @@ void CanvasItemEditor::_popup_callback(int p_op) { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - if (!canvas_item || !canvas_item->is_inside_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + if (!ci || !ci->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->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_"); + undo_redo->add_do_method(ci, "set_meta", "_edit_group_", true); + undo_redo->add_undo_method(ci, "remove_meta", "_edit_group_"); undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed"); } @@ -4456,16 +4456,16 @@ void CanvasItemEditor::_popup_callback(int p_op) { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - if (!canvas_item || !canvas_item->is_inside_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + if (!ci || !ci->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->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); + undo_redo->add_do_method(ci, "remove_meta", "_edit_group_"); + undo_redo->add_undo_method(ci, "set_meta", "_edit_group_", true); undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed"); } @@ -4496,17 +4496,17 @@ void CanvasItemEditor::_popup_callback(int p_op) { const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (!canvas_item || !canvas_item->is_visible_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (!ci || !ci->is_visible_in_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->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 (Object::cast_to<Node2D>(ci)) { + Node2D *n2d = Object::cast_to<Node2D>(ci); PoseClipboard pc; pc.pos = n2d->get_position(); pc.rot = n2d->get_rotation(); @@ -4542,17 +4542,17 @@ void CanvasItemEditor::_popup_callback(int p_op) { HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (!canvas_item || !canvas_item->is_visible_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (!ci || !ci->is_visible_in_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->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 (Object::cast_to<Node2D>(ci)) { + Node2D *n2d = Object::cast_to<Node2D>(ci); if (key_pos) { n2d->set_position(Vector2()); @@ -4563,8 +4563,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { 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); + } else if (Object::cast_to<Control>(ci)) { + Control *ctrl = Object::cast_to<Control>(ci); if (key_pos) { ctrl->set_position(Point2()); @@ -4658,28 +4658,28 @@ void CanvasItemEditor::_focus_selection(int p_op) { const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (!canvas_item) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (!ci) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } // counting invisible items, for now - //if (!canvas_item->is_visible_in_tree()) continue; + //if (!ci->is_visible_in_tree()) continue; ++count; Rect2 item_rect; - if (canvas_item->_edit_use_rect()) { - item_rect = canvas_item->_edit_get_rect(); + if (ci->_edit_use_rect()) { + item_rect = ci->_edit_get_rect(); } else { item_rect = Rect2(); } - Vector2 pos = canvas_item->get_global_transform().get_origin(); - Vector2 scale = canvas_item->get_global_transform().get_scale(); - real_t angle = canvas_item->get_global_transform().get_rotation(); + Vector2 pos = ci->get_global_transform().get_origin(); + Vector2 scale = ci->get_global_transform().get_scale(); + real_t angle = ci->get_global_transform().get_rotation(); Transform2D t(angle, Vector2(0.f, 0.f)); item_rect = t.xform(item_rect); diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index e56fd5dfe3..a0e6771768 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -110,8 +110,8 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { int vpc = 0; { - Vector<uint8_t> data = img->get_data(); - const uint8_t *r = data.ptr(); + Vector<uint8_t> img_data = img->get_data(); + const uint8_t *r = img_data.ptr(); for (int i = 0; i < s.width; i++) { for (int j = 0; j < s.height; j++) { diff --git a/editor/plugins/editor_resource_conversion_plugin.cpp b/editor/plugins/editor_resource_conversion_plugin.cpp index 91394dbac7..2db860fd07 100644 --- a/editor/plugins/editor_resource_conversion_plugin.cpp +++ b/editor/plugins/editor_resource_conversion_plugin.cpp @@ -46,7 +46,7 @@ String EditorResourceConversionPlugin::converts_to() const { } bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) const { - bool ret; + bool ret = false; if (GDVIRTUAL_CALL(_handles, p_resource, ret)) { return ret; } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index e2d19c34e6..1b2afe2151 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -207,8 +207,8 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { int vpc = 0; { - Vector<uint8_t> data = img->get_data(); - const uint8_t *r = data.ptr(); + Vector<uint8_t> img_data = img->get_data(); + const uint8_t *r = img_data.ptr(); for (int i = 0; i < s.width; i++) { for (int j = 0; j < s.height; j++) { diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index d91cbb6571..db3a46d1f1 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -255,8 +255,8 @@ void GPUParticles3DEditor::_menu_option(int p_option) { } } break; case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: { - Ref<ParticleProcessMaterial> material = node->get_process_material(); - if (material.is_null()) { + Ref<ParticleProcessMaterial> mat = node->get_process_material(); + if (mat.is_null()) { EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticleProcessMaterial' is required.")); return; } @@ -366,13 +366,13 @@ void GPUParticles3DEditor::_generate_emission_points() { Ref<Image> image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img)); Ref<ImageTexture> tex = ImageTexture::create_from_image(image); - Ref<ParticleProcessMaterial> material = node->get_process_material(); - ERR_FAIL_COND(material.is_null()); + Ref<ParticleProcessMaterial> mat = node->get_process_material(); + ERR_FAIL_COND(mat.is_null()); if (normals.size() > 0) { - material->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_DIRECTED_POINTS); - material->set_emission_point_count(point_count); - material->set_emission_point_texture(tex); + mat->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_DIRECTED_POINTS); + mat->set_emission_point_count(point_count); + mat->set_emission_point_texture(tex); Vector<uint8_t> point_img2; point_img2.resize(w * h * 3 * sizeof(float)); @@ -390,11 +390,11 @@ void GPUParticles3DEditor::_generate_emission_points() { } Ref<Image> image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2)); - material->set_emission_normal_texture(ImageTexture::create_from_image(image2)); + mat->set_emission_normal_texture(ImageTexture::create_from_image(image2)); } else { - material->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_POINTS); - material->set_emission_point_count(point_count); - material->set_emission_point_texture(tex); + mat->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_POINTS); + mat->set_emission_point_count(point_count); + mat->set_emission_point_texture(tex); } } diff --git a/editor/plugins/gradient_editor.cpp b/editor/plugins/gradient_editor.cpp index c13b162db6..822f303d93 100644 --- a/editor/plugins/gradient_editor.cpp +++ b/editor/plugins/gradient_editor.cpp @@ -90,8 +90,8 @@ void GradientEditor::_gradient_changed() { } editing = true; - Vector<Gradient::Point> points = gradient->get_points(); - set_points(points); + Vector<Gradient::Point> grad_points = gradient->get_points(); + set_points(grad_points); set_interpolation_mode(gradient->get_interpolation_mode()); queue_redraw(); editing = false; diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 31053f90b8..d73761d770 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -51,9 +51,9 @@ void Line2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const { } void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) { - Node2D *node = _get_node(); - undo_redo->add_do_method(node, "set_points", p_polygon); - undo_redo->add_undo_method(node, "set_points", p_previous); + Node2D *_node = _get_node(); + undo_redo->add_do_method(_node, "set_points", p_polygon); + undo_redo->add_undo_method(_node, "set_points", p_previous); } Line2DEditor::Line2DEditor() {} diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 4a262d2940..7194cd9d27 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -1119,7 +1119,7 @@ void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { - bool ret; + bool ret = false; if (GDVIRTUAL_CALL(_is_handle_highlighted, Ref<EditorNode3DGizmo>(p_gizmo), p_id, p_secondary, ret)) { return ret; } @@ -1151,7 +1151,7 @@ void EditorNode3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, in } int EditorNode3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const { - int ret; + int ret = -1; if (GDVIRTUAL_CALL(_subgizmos_intersect_ray, Ref<EditorNode3DGizmo>(p_gizmo), p_camera, p_point, ret)) { return ret; } @@ -4167,9 +4167,9 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); - List<uint32_t> owners; - co->get_shape_owners(&owners); - for (uint32_t &owner_id : owners) { + List<uint32_t> owner_ids; + co->get_shape_owners(&owner_ids); + for (uint32_t &owner_id : owner_ids) { Transform3D xform = co->shape_owner_get_transform(owner_id); Object *owner = co->shape_owner_get_owner(owner_id); // Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo. diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 2f49b3a62d..4430877b8a 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2429,11 +2429,11 @@ void Node3DEditorViewport::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - bool visible = is_visible_in_tree(); + bool vp_visible = is_visible_in_tree(); - set_process(visible); + set_process(vp_visible); - if (visible) { + if (vp_visible) { orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL)); _update_name(); _update_camera(0); @@ -3880,8 +3880,8 @@ bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Poin Vector3 xform_ray = ai.basis.xform(world_ray).normalized(); Vector3 xform_pos = ai.xform(world_pos); - for (int surface = 0; surface < surface_count; surface++) { - Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface); + for (int surface_idx = 0; surface_idx < surface_count; surface_idx++) { + Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface_idx); Vector3 rpos, rnorm; if (surface_mesh->intersect_ray(xform_pos, xform_ray, rpos, rnorm)) { @@ -3894,7 +3894,7 @@ bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Poin } if (dist < closest_dist) { - closest_surface = surface; + closest_surface = surface_idx; closest_dist = dist; } } @@ -4020,16 +4020,16 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po Node3D *node3d = Object::cast_to<Node3D>(instantiated_scene); if (node3d) { - Transform3D global_transform; + Transform3D gl_transform; Node3D *parent_node3d = Object::cast_to<Node3D>(parent); if (parent_node3d) { - global_transform = parent_node3d->get_global_gizmo_transform(); + gl_transform = parent_node3d->get_global_gizmo_transform(); } - global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point)); - global_transform.basis *= node3d->get_transform().basis; + gl_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point)); + gl_transform.basis *= node3d->get_transform().basis; - editor_data->get_undo_redo()->add_do_method(instantiated_scene, "set_global_transform", global_transform); + editor_data->get_undo_redo()->add_do_method(instantiated_scene, "set_global_transform", gl_transform); } return true; @@ -4163,8 +4163,8 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant } if (can_instantiate) { - Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point)); - preview_node->set_global_transform(global_transform); + Transform3D gl_transform = Transform3D(Basis(), _get_instance_position(p_point)); + preview_node->set_global_transform(gl_transform); return true; } diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 0203f2933f..d7953bf4e0 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -264,33 +264,33 @@ void Path3DGizmo::redraw() { if (Path3DEditorPlugin::singleton->get_edited_path() == path) { v3p.clear(); - Vector<Vector3> handles; - Vector<Vector3> sec_handles; + Vector<Vector3> handle_points; + Vector<Vector3> sec_handle_points; for (int i = 0; i < c->get_point_count(); i++) { Vector3 p = c->get_point_position(i); - handles.push_back(p); + handle_points.push_back(p); // push Out points first so they get selected if the In and Out points are on top of each other. if (i < c->get_point_count() - 1) { v3p.push_back(p); v3p.push_back(p + c->get_point_out(i)); - sec_handles.push_back(p + c->get_point_out(i)); + sec_handle_points.push_back(p + c->get_point_out(i)); } if (i > 0) { v3p.push_back(p); v3p.push_back(p + c->get_point_in(i)); - sec_handles.push_back(p + c->get_point_in(i)); + sec_handle_points.push_back(p + c->get_point_in(i)); } } if (v3p.size() > 1) { add_lines(v3p, path_thin_material); } - if (handles.size()) { - add_handles(handles, handles_material); + if (handle_points.size()) { + add_handles(handle_points, handles_material); } - if (sec_handles.size()) { - add_handles(sec_handles, sec_handles_material, Vector<int>(), false, true); + if (sec_handle_points.size()) { + add_handles(sec_handle_points, sec_handles_material, Vector<int>(), false, true); } } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 67813a3635..876ef3bae9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -128,12 +128,12 @@ void EditorStandardSyntaxHighlighter::_update_cache() { } } - const Ref<Script> script = _get_edited_resource(); - if (script.is_valid()) { + const Ref<Script> scr = _get_edited_resource(); + if (scr.is_valid()) { /* Core types. */ const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color"); List<String> core_types; - script->get_language()->get_core_type_words(&core_types); + scr->get_language()->get_core_type_words(&core_types); for (const String &E : core_types) { highlighter->add_keyword_color(E, basetype_color); } @@ -142,9 +142,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color"); const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color"); List<String> keywords; - script->get_language()->get_reserved_words(&keywords); + scr->get_language()->get_reserved_words(&keywords); for (const String &E : keywords) { - if (script->get_language()->is_control_flow_keyword(E)) { + if (scr->get_language()->is_control_flow_keyword(E)) { highlighter->add_keyword_color(E, control_flow_keyword_color); } else { highlighter->add_keyword_color(E, keyword_color); @@ -153,19 +153,19 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Member types. */ const Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color"); - StringName instance_base = script->get_instance_base_type(); + StringName instance_base = scr->get_instance_base_type(); if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); for (const PropertyInfo &E : plist) { - String name = E.name; + String prop_name = E.name; if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; } - if (name.contains("/")) { + if (prop_name.contains("/")) { continue; } - highlighter->add_member_keyword_color(name, member_variable_color); + highlighter->add_member_keyword_color(prop_name, member_variable_color); } List<String> clist; @@ -178,7 +178,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Comments */ const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color"); List<String> comments; - script->get_language()->get_comment_delimiters(&comments); + scr->get_language()->get_comment_delimiters(&comments); for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); @@ -188,7 +188,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Strings */ const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color"); List<String> strings; - script->get_language()->get_string_delimiters(&strings); + scr->get_language()->get_string_delimiters(&strings); for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); @@ -431,8 +431,8 @@ void ScriptEditor::_goto_script_line2(int p_line) { } void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) { - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + Ref<Script> scr = Object::cast_to<Script>(*p_script); + if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { if (edit(p_script, p_line, 0)) { EditorNode::get_singleton()->push_item(p_script.ptr()); @@ -447,15 +447,15 @@ void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) { } void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) { - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + Ref<Script> scr = Object::cast_to<Script>(*p_script); + if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (!se) { continue; } - if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + if ((scr != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == scr->get_path()) { se->set_executing_line(p_line); } } @@ -463,15 +463,15 @@ void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) { } void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) { - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + Ref<Script> scr = Object::cast_to<Script>(*p_script); + if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (!se) { continue; } - if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + if ((scr != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == scr->get_path()) { se->clear_executing_line(); } } @@ -479,19 +479,19 @@ void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) { } void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_enabled) { - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + Ref<Script> scr = Object::cast_to<Script>(*p_script); + if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { // Update if open. for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); - if (se && se->get_edited_resource()->get_path() == script->get_path()) { + if (se && se->get_edited_resource()->get_path() == scr->get_path()) { se->set_breakpoint(p_line, p_enabled); return; } } // Handle closed. - Dictionary state = script_editor_cache->get_value(script->get_path(), "state"); + Dictionary state = script_editor_cache->get_value(scr->get_path(), "state"); Array breakpoints; if (state.has("breakpoints")) { breakpoints = state["breakpoints"]; @@ -505,8 +505,8 @@ void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_ breakpoints.push_back(p_line); } state["breakpoints"] = breakpoints; - script_editor_cache->set_value(script->get_path(), "state", state); - EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_line + 1, false); + script_editor_cache->set_value(scr->get_path(), "state", state); + EditorDebuggerNode::get_singleton()->set_breakpoint(scr->get_path(), p_line + 1, false); } } @@ -627,9 +627,9 @@ void ScriptEditor::_go_to_tab(int p_idx) { Object::cast_to<ScriptEditorBase>(c)->ensure_focus(); } - Ref<Script> script = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource(); - if (script != nullptr) { - notify_script_changed(script); + Ref<Script> scr = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource(); + if (scr != nullptr) { + notify_script_changed(scr); } Object::cast_to<ScriptEditorBase>(c)->validate(); @@ -705,9 +705,9 @@ void ScriptEditor::_open_recent_script(int p_idx) { ResourceLoader::get_recognized_extensions_for_type("Script", &extensions); if (extensions.find(path.get_extension())) { - Ref<Script> script = ResourceLoader::load(path); - if (script.is_valid()) { - edit(script, true); + Ref<Script> scr = ResourceLoader::load(path); + if (scr.is_valid()) { + edit(scr, true); return; } } @@ -729,9 +729,9 @@ void ScriptEditor::_open_recent_script(int p_idx) { } else { EditorNode::get_singleton()->load_resource(res_path); } - Ref<Script> script = ResourceLoader::load(path); - if (script.is_valid()) { - edit(script, true); + Ref<Script> scr = ResourceLoader::load(path); + if (scr.is_valid()) { + edit(scr, true); return; } } else if (!path.is_resource_file()) { @@ -774,9 +774,9 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { previous_scripts.push_back(file->get_path()); } - Ref<Script> script = file; - if (script.is_valid()) { - notify_script_close(script); + Ref<Script> scr = file; + if (scr.is_valid()) { + notify_script_close(scr); } } } @@ -851,8 +851,8 @@ void ScriptEditor::_close_docs_tab() { void ScriptEditor::_copy_script_path() { ScriptEditorBase *se = _get_current_editor(); if (se) { - Ref<Resource> script = se->get_edited_resource(); - DisplayServer::get_singleton()->clipboard_set(script->get_path()); + Ref<Resource> scr = se->get_edited_resource(); + DisplayServer::get_singleton()->clipboard_set(scr->get_path()); } } @@ -908,9 +908,9 @@ void ScriptEditor::_resave_scripts(const String &p_str) { continue; } - Ref<Resource> script = se->get_edited_resource(); + Ref<Resource> scr = se->get_edited_resource(); - if (script->is_built_in()) { + if (scr->is_built_in()) { continue; //internal script, who cares } @@ -928,13 +928,13 @@ void ScriptEditor::_resave_scripts(const String &p_str) { } } - Ref<TextFile> text_file = script; + Ref<TextFile> text_file = scr; if (text_file != nullptr) { se->apply_code(); _save_text_file(text_file, text_file->get_path()); break; } else { - EditorNode::get_singleton()->save_resource(script); + EditorNode::get_singleton()->save_resource(scr); } se->tag_saved_version(); } @@ -949,9 +949,9 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) { continue; } - Ref<Resource> script = se->get_edited_resource(); + Ref<Resource> scr = se->get_edited_resource(); - if (script == p_res) { + if (scr == p_res) { se->tag_saved_version(); } } @@ -1106,8 +1106,8 @@ Ref<Script> ScriptEditor::_get_current_script() { ScriptEditorBase *current = _get_current_editor(); if (current) { - Ref<Script> script = current->get_edited_resource(); - return script != nullptr ? script : nullptr; + Ref<Script> scr = current->get_edited_resource(); + return scr != nullptr ? scr : nullptr; } else { return nullptr; } @@ -1284,7 +1284,7 @@ void ScriptEditor::_menu_option(int p_option) { Ref<Resource> resource = current->get_edited_resource(); Ref<TextFile> text_file = resource; - Ref<Script> script = resource; + Ref<Script> scr = resource; if (text_file != nullptr) { file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); @@ -1301,15 +1301,15 @@ void ScriptEditor::_menu_option(int p_option) { break; } - if (script.is_valid()) { - clear_docs_from_script(script); + if (scr.is_valid()) { + clear_docs_from_script(scr); } EditorNode::get_singleton()->push_item(resource.ptr()); EditorNode::get_singleton()->save_resource_as(resource); - if (script.is_valid()) { - update_docs_from_script(script); + if (scr.is_valid()) { + update_docs_from_script(scr); } } break; @@ -1367,18 +1367,18 @@ void ScriptEditor::_menu_option(int p_option) { _copy_script_path(); } break; case SHOW_IN_FILE_SYSTEM: { - const Ref<Resource> script = current->get_edited_resource(); - String path = script->get_path(); + const Ref<Resource> scr = current->get_edited_resource(); + String path = scr->get_path(); if (!path.is_empty()) { - if (script->is_built_in()) { + if (scr->is_built_in()) { path = path.get_slice("::", 0); // Show the scene instead. } FileSystemDock *file_system_dock = FileSystemDock::get_singleton(); file_system_dock->navigate_to_path(path); // Ensure that the FileSystem dock is visible. - TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); - tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock)); + TabContainer *dock_tab_container = (TabContainer *)file_system_dock->get_parent_control(); + dock_tab_container->set_current_tab(dock_tab_container->get_tab_idx_from_control(file_system_dock)); } } break; case CLOSE_DOCS: { @@ -1635,12 +1635,12 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (se) { - Ref<Script> script = se->get_edited_resource(); - if (script == nullptr || !script.is_valid()) { + Ref<Script> scr = se->get_edited_resource(); + if (scr == nullptr || !scr.is_valid()) { continue; } - if (script->is_built_in() && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed + if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed _close_tab(i, false); i--; } @@ -1668,12 +1668,12 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { continue; } - Ref<Script> script = se->get_edited_resource(); - if (script == nullptr) { + Ref<Script> scr = se->get_edited_resource(); + if (scr == nullptr) { continue; } - String base = script->get_path(); + String base = scr->get_path(); loaded_scripts.insert(base); if (base.begins_with("local://") || base.is_empty()) { continue; @@ -2184,20 +2184,20 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, return false; } - Ref<Script> script = p_resource; + Ref<Script> scr = p_resource; // Don't open dominant script if using an external editor. bool use_external_editor = EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") || - (script.is_valid() && script->get_language()->overrides_external_editor()); - use_external_editor = use_external_editor && !(script.is_valid() && script->is_built_in()); // Ignore external editor for built-in scripts. + (scr.is_valid() && scr->get_language()->overrides_external_editor()); + use_external_editor = use_external_editor && !(scr.is_valid() && scr->is_built_in()); // Ignore external editor for built-in scripts. const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/behavior/files/open_dominant_script_on_scene_change"); const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene(); - if (script.is_valid() && script->get_language()->overrides_external_editor()) { + if (scr.is_valid() && scr->get_language()->overrides_external_editor()) { if (should_open) { - Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col); + Error err = scr->get_language()->open_in_external_editor(scr, p_line >= 0 ? p_line : 0, p_col); if (err != OK) { ERR_PRINT("Couldn't open script in the overridden external text editor"); } @@ -2271,7 +2271,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, continue; } - if ((script != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { + if ((scr != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { if (should_open) { se->enable_editor(); @@ -2316,9 +2316,9 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, } se->add_syntax_highlighter(highlighter); - if (script != nullptr && !highlighter_set) { + if (scr != nullptr && !highlighter_set) { PackedStringArray languages = highlighter->_get_supported_languages(); - if (languages.has(script->get_language()->get_name())) { + if (languages.has(scr->get_language()->get_name())) { se->set_syntax_highlighter(highlighter); highlighter_set = true; } @@ -2399,7 +2399,7 @@ void ScriptEditor::save_current_script() { Ref<Resource> resource = current->get_edited_resource(); Ref<TextFile> text_file = resource; - Ref<Script> script = resource; + Ref<Script> scr = resource; if (text_file != nullptr) { current->apply_code(); @@ -2407,8 +2407,8 @@ void ScriptEditor::save_current_script() { return; } - if (script.is_valid()) { - clear_docs_from_script(script); + if (scr.is_valid()) { + clear_docs_from_script(scr); } if (resource->is_built_in()) { @@ -2423,8 +2423,8 @@ void ScriptEditor::save_current_script() { EditorNode::get_singleton()->save_resource(resource); } - if (script.is_valid()) { - update_docs_from_script(script); + if (scr.is_valid()) { + update_docs_from_script(scr); } } @@ -2462,21 +2462,21 @@ void ScriptEditor::save_all_scripts() { if (!edited_res->is_built_in()) { Ref<TextFile> text_file = edited_res; - Ref<Script> script = edited_res; + Ref<Script> scr = edited_res; if (text_file != nullptr) { _save_text_file(text_file, text_file->get_path()); continue; } - if (script.is_valid()) { - clear_docs_from_script(script); + if (scr.is_valid()) { + clear_docs_from_script(scr); } EditorNode::get_singleton()->save_resource(edited_res); //external script, save it - if (script.is_valid()) { - update_docs_from_script(script); + if (scr.is_valid()) { + update_docs_from_script(scr); } } else { // For built-in scripts, save their scenes instead. @@ -2526,13 +2526,13 @@ void ScriptEditor::reload_scripts(bool p_refresh_only) { continue; } - Ref<Script> script = edited_res; - if (script != nullptr) { - Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); - ERR_CONTINUE(!rel_script.is_valid()); - script->set_source_code(rel_script->get_source_code()); - script->set_last_modified_time(rel_script->get_last_modified_time()); - script->reload(true); + Ref<Script> scr = edited_res; + if (scr != nullptr) { + Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); + ERR_CONTINUE(!rel_scr.is_valid()); + scr->set_source_code(rel_scr->get_source_code()); + scr->set_last_modified_time(rel_scr->get_last_modified_time()); + scr->reload(true); } Ref<TextFile> text_file = edited_res; @@ -2605,17 +2605,17 @@ void ScriptEditor::_editor_stop() { void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args) { ERR_FAIL_COND(!p_obj); - Ref<Script> script = p_obj->get_script(); - ERR_FAIL_COND(!script.is_valid()); + Ref<Script> scr = p_obj->get_script(); + ERR_FAIL_COND(!scr.is_valid()); - EditorNode::get_singleton()->push_item(script.ptr()); + EditorNode::get_singleton()->push_item(scr.ptr()); for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (!se) { continue; } - if (se->get_edited_resource() != script) { + if (se->get_edited_resource() != scr) { continue; } @@ -2626,7 +2626,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const script_list->select(script_list->find_metadata(i)); // Save the current script so the changes can be picked up by an external editor. - if (!script.ptr()->is_built_in()) { // But only if it's not built-in script. + if (!scr.ptr()->is_built_in()) { // But only if it's not built-in script. save_current_script(); } @@ -3376,9 +3376,9 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { seb->set_edit_state(history[history_pos].state); seb->ensure_focus(); - Ref<Script> script = seb->get_edited_resource(); - if (script != nullptr) { - notify_script_changed(script); + Ref<Script> scr = seb->get_edited_resource(); + if (scr != nullptr) { + notify_script_changed(scr); } } @@ -3414,9 +3414,9 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const { continue; } - Ref<Script> script = se->get_edited_resource(); - if (script != nullptr) { - out_scripts.push_back(script); + Ref<Script> scr = se->get_edited_resource(); + if (scr != nullptr) { + out_scripts.push_back(scr); } } @@ -3467,9 +3467,9 @@ void ScriptEditor::_help_search(String p_text) { } void ScriptEditor::_open_script_request(const String &p_path) { - Ref<Script> script = ResourceLoader::load(p_path); - if (script.is_valid()) { - script_editor->edit(script, false); + Ref<Script> scr = ResourceLoader::load(p_path); + if (scr.is_valid()) { + script_editor->edit(scr, false); return; } @@ -3534,9 +3534,9 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb EditorNode::get_singleton()->load_scene(fpath); return; } else { - Ref<Script> script = res; - if (script.is_valid()) { - edit(script); + Ref<Script> scr = res; + if (scr.is_valid()) { + edit(scr); ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor()); if (ste) { @@ -3806,12 +3806,12 @@ ScriptEditor::ScriptEditor() { script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option)); menu_hb->add_child(script_search_menu); - MenuButton *debug_menu = memnew(MenuButton); - menu_hb->add_child(debug_menu); - debug_menu->hide(); // Handled by EditorDebuggerNode below. + MenuButton *debug_menu_btn = memnew(MenuButton); + menu_hb->add_child(debug_menu_btn); + debug_menu_btn->hide(); // Handled by EditorDebuggerNode below. EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); - debugger->set_script_debug_button(debug_menu); + debugger->set_script_debug_button(debug_menu_btn); debugger->connect("goto_script_line", callable_mp(this, &ScriptEditor::_goto_script_line)); debugger->connect("set_execution", callable_mp(this, &ScriptEditor::_set_execution)); debugger->connect("clear_execution", callable_mp(this, &ScriptEditor::_clear_execution)); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 9910a97f88..58a0160010 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -703,25 +703,25 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo } for (const Ref<Script> &E : scripts) { - Ref<Script> script = E; + Ref<Script> scr = E; - if (p_for_script.is_valid() && p_for_script != script) { + if (p_for_script.is_valid() && p_for_script != scr) { continue; } - if (script->is_built_in()) { + if (scr->is_built_in()) { continue; //internal script, who cares, though weird } - uint64_t last_date = script->get_last_modified_time(); - uint64_t date = FileAccess::get_modified_time(script->get_path()); + uint64_t last_date = scr->get_last_modified_time(); + uint64_t date = FileAccess::get_modified_time(scr->get_path()); if (last_date != date) { - Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); - ERR_CONTINUE(!rel_script.is_valid()); - script->set_source_code(rel_script->get_source_code()); - script->set_last_modified_time(rel_script->get_last_modified_time()); - script->update_exports(); + Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); + ERR_CONTINUE(!rel_scr.is_valid()); + scr->set_source_code(rel_scr->get_source_code()); + scr->set_last_modified_time(rel_scr->get_last_modified_time()); + scr->update_exports(); _trigger_live_script_reload(); } @@ -982,10 +982,10 @@ void ScriptTextEditor::_update_connected_methods() { Vector<Node *> nodes = _find_all_node_for_script(base, base, script); HashSet<StringName> methods_found; for (int i = 0; i < nodes.size(); i++) { - List<Connection> connections; - nodes[i]->get_signals_connected_to_this(&connections); + List<Connection> signal_connections; + nodes[i]->get_signals_connected_to_this(&signal_connections); - for (const Connection &connection : connections) { + for (const Connection &connection : signal_connections) { if (!(connection.flags & CONNECT_PERSIST)) { continue; } diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 99f0ff638e..83245366f9 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -587,25 +587,25 @@ void Skeleton3DEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data void Skeleton3DEditor::move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx) { Node *node = get_node_or_null(p_skeleton_path); - Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node); - ERR_FAIL_NULL(skeleton); + Skeleton3D *skeleton_node = Object::cast_to<Skeleton3D>(node); + ERR_FAIL_NULL(skeleton_node); Ref<EditorUndoRedoManager> &ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Set Bone Parentage")); // If the target is a child of ourselves, we move only *us* and not our children. - if (skeleton->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) { - const BoneId parent_idx = skeleton->get_bone_parent(p_selected_boneidx); - const int bone_count = skeleton->get_bone_count(); + if (skeleton_node->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) { + const BoneId parent_idx = skeleton_node->get_bone_parent(p_selected_boneidx); + const int bone_count = skeleton_node->get_bone_count(); for (BoneId i = 0; i < bone_count; ++i) { - if (skeleton->get_bone_parent(i) == p_selected_boneidx) { - ur->add_undo_method(skeleton, "set_bone_parent", i, skeleton->get_bone_parent(i)); - ur->add_do_method(skeleton, "set_bone_parent", i, parent_idx); - skeleton->set_bone_parent(i, parent_idx); + if (skeleton_node->get_bone_parent(i) == p_selected_boneidx) { + ur->add_undo_method(skeleton_node, "set_bone_parent", i, skeleton_node->get_bone_parent(i)); + ur->add_do_method(skeleton_node, "set_bone_parent", i, parent_idx); + skeleton_node->set_bone_parent(i, parent_idx); } } } - ur->add_undo_method(skeleton, "set_bone_parent", p_selected_boneidx, skeleton->get_bone_parent(p_selected_boneidx)); - ur->add_do_method(skeleton, "set_bone_parent", p_selected_boneidx, p_target_boneidx); - skeleton->set_bone_parent(p_selected_boneidx, p_target_boneidx); + ur->add_undo_method(skeleton_node, "set_bone_parent", p_selected_boneidx, skeleton_node->get_bone_parent(p_selected_boneidx)); + ur->add_do_method(skeleton_node, "set_bone_parent", p_selected_boneidx, p_target_boneidx); + skeleton_node->set_bone_parent(p_selected_boneidx, p_target_boneidx); update_joint_tree(); ur->commit_action(); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index d0a1ddafa1..cfece173d6 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -1095,8 +1095,8 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & } for (int i = 0; i < files.size(); i++) { - String file = files[i]; - String ftype = EditorFileSystem::get_singleton()->get_file_type(file); + String f = files[i]; + String ftype = EditorFileSystem::get_singleton()->get_file_type(f); if (!ClassDB::is_parent_class(ftype, "Texture2D")) { return false; diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp index 9dea990bd8..48086bf235 100644 --- a/editor/plugins/text_shader_editor.cpp +++ b/editor/plugins/text_shader_editor.cpp @@ -202,12 +202,12 @@ void ShaderTextEditor::set_warnings_panel(RichTextLabel *p_warnings_panel) { } void ShaderTextEditor::_load_theme_settings() { - CodeEdit *text_editor = get_text_editor(); + CodeEdit *te = get_text_editor(); Color updated_marked_line_color = EDITOR_GET("text_editor/theme/highlighting/mark_color"); if (updated_marked_line_color != marked_line_color) { - for (int i = 0; i < text_editor->get_line_count(); i++) { - if (text_editor->get_line_background_color(i) == marked_line_color) { - text_editor->set_line_background_color(i, updated_marked_line_color); + for (int i = 0; i < te->get_line_count(); i++) { + if (te->get_line_background_color(i) == marked_line_color) { + te->set_line_background_color(i, updated_marked_line_color); } } marked_line_color = updated_marked_line_color; @@ -257,14 +257,14 @@ void ShaderTextEditor::_load_theme_settings() { const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i)); for (int j = 0; j < modes.size(); j++) { - const ShaderLanguage::ModeInfo &info = modes[j]; + const ShaderLanguage::ModeInfo &mode_info = modes[j]; - if (!info.options.is_empty()) { - for (int k = 0; k < info.options.size(); k++) { - built_ins.push_back(String(info.name) + "_" + String(info.options[k])); + if (!mode_info.options.is_empty()) { + for (int k = 0; k < mode_info.options.size(); k++) { + built_ins.push_back(String(mode_info.name) + "_" + String(mode_info.options[k])); } } else { - built_ins.push_back(String(info.name)); + built_ins.push_back(String(mode_info.name)); } } } @@ -278,14 +278,14 @@ void ShaderTextEditor::_load_theme_settings() { const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())); for (int i = 0; i < modes.size(); i++) { - const ShaderLanguage::ModeInfo &info = modes[i]; + const ShaderLanguage::ModeInfo &mode_info = modes[i]; - if (!info.options.is_empty()) { - for (int j = 0; j < info.options.size(); j++) { - built_ins.push_back(String(info.name) + "_" + String(info.options[j])); + if (!mode_info.options.is_empty()) { + for (int j = 0; j < mode_info.options.size(); j++) { + built_ins.push_back(String(mode_info.name) + "_" + String(mode_info.options[j])); } } else { - built_ins.push_back(String(info.name)); + built_ins.push_back(String(mode_info.name)); } } } @@ -303,12 +303,12 @@ void ShaderTextEditor::_load_theme_settings() { syntax_highlighter->add_color_region("//", "", comment_color, true); syntax_highlighter->set_disabled_branch_color(comment_color); - text_editor->clear_comment_delimiters(); - text_editor->add_comment_delimiter("/*", "*/", false); - text_editor->add_comment_delimiter("//", "", true); + te->clear_comment_delimiters(); + te->add_comment_delimiter("/*", "*/", false); + te->add_comment_delimiter("//", "", true); - if (!text_editor->has_auto_brace_completion_open_key("/*")) { - text_editor->add_auto_brace_completion_pair("/*", "*/"); + if (!te->has_auto_brace_completion_open_key("/*")) { + te->add_auto_brace_completion_pair("/*", "*/"); } // Colorize preprocessor include strings. @@ -399,22 +399,22 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa ShaderLanguage sl; String calltip; - ShaderLanguage::ShaderCompileInfo info; - info.global_shader_uniform_type_func = _get_global_shader_uniform_type; + ShaderLanguage::ShaderCompileInfo comp_info; + comp_info.global_shader_uniform_type_func = _get_global_shader_uniform_type; if (shader.is_null()) { - info.is_include = true; + comp_info.is_include = true; - sl.complete(code, info, r_options, calltip); + sl.complete(code, comp_info, r_options, calltip); get_text_editor()->set_code_hint(calltip); return; } _check_shader_mode(); - info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())); - info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())); - info.shader_types = ShaderTypes::get_singleton()->get_types(); + comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())); + comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())); + comp_info.shader_types = ShaderTypes::get_singleton()->get_types(); - sl.complete(code, info, r_options, calltip); + sl.complete(code, comp_info, r_options, calltip); get_text_editor()->set_code_hint(calltip); } @@ -464,22 +464,22 @@ void ShaderTextEditor::_validate_script() { //preprocessor error ERR_FAIL_COND(err_positions.size() == 0); - String error_text = error_pp; - int error_line = err_positions.front()->get().line; + String err_text = error_pp; + int err_line = err_positions.front()->get().line; if (err_positions.size() == 1) { // Error in main file - error_text = "error(" + itos(error_line) + "): " + error_text; + err_text = "error(" + itos(err_line) + "): " + err_text; } else { - error_text = "error(" + itos(error_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + error_text; + err_text = "error(" + itos(err_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + err_text; set_error_count(err_positions.size() - 1); } - set_error(error_text); - set_error_pos(error_line - 1, 0); + set_error(err_text); + set_error_pos(err_line - 1, 0); for (int i = 0; i < get_text_editor()->get_line_count(); i++) { get_text_editor()->set_line_background_color(i, Color(0, 0, 0, 0)); } - get_text_editor()->set_line_background_color(error_line - 1, marked_line_color); + get_text_editor()->set_line_background_color(err_line - 1, marked_line_color); set_warning_count(0); @@ -507,39 +507,39 @@ void ShaderTextEditor::_validate_script() { } sl.set_warning_flags(flags); - ShaderLanguage::ShaderCompileInfo info; - info.global_shader_uniform_type_func = _get_global_shader_uniform_type; + ShaderLanguage::ShaderCompileInfo comp_info; + comp_info.global_shader_uniform_type_func = _get_global_shader_uniform_type; if (shader.is_null()) { - info.is_include = true; + comp_info.is_include = true; } else { Shader::Mode mode = shader->get_mode(); - info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode)); - info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode)); - info.shader_types = ShaderTypes::get_singleton()->get_types(); + comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode)); + comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode)); + comp_info.shader_types = ShaderTypes::get_singleton()->get_types(); } code = code_pp; //compiler error - last_compile_result = sl.compile(code, info); + last_compile_result = sl.compile(code, comp_info); if (last_compile_result != OK) { - String error_text; - int error_line; + String err_text; + int err_line; Vector<ShaderLanguage::FilePosition> include_positions = sl.get_include_positions(); if (include_positions.size() > 1) { //error is in an include - error_line = include_positions[0].line; - error_text = "error(" + itos(error_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text(); + err_line = include_positions[0].line; + err_text = "error(" + itos(err_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text(); set_error_count(include_positions.size() - 1); } else { - error_line = sl.get_error_line(); - error_text = "error(" + itos(error_line) + "): " + sl.get_error_text(); + err_line = sl.get_error_line(); + err_text = "error(" + itos(err_line) + "): " + sl.get_error_text(); set_error_count(0); } - set_error(error_text); - set_error_pos(error_line - 1, 0); - get_text_editor()->set_line_background_color(error_line - 1, marked_line_color); + set_error(err_text); + set_error_pos(err_line - 1, 0); + get_text_editor()->set_line_background_color(err_line - 1, marked_line_color); } else { set_error(""); } diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index d0f8e1f32d..73ca8b6176 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -212,8 +212,8 @@ void GenericTilePolygonEditor::_base_control_draw() { for (int i = 0; i < (int)polygons.size(); i++) { const Vector<Vector2> &polygon = polygons[i]; for (int j = 0; j < polygon.size(); j++) { - const Color modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1); - base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, modulate); + const Color poly_modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1); + base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, poly_modulate); } } } @@ -2662,27 +2662,27 @@ TileDataTerrainsEditor::~TileDataTerrainsEditor() { } Variant TileDataNavigationEditor::_get_painted_value() { - Ref<NavigationPolygon> navigation_polygon; - navigation_polygon.instantiate(); + Ref<NavigationPolygon> nav_polygon; + nav_polygon.instantiate(); for (int i = 0; i < polygon_editor->get_polygon_count(); i++) { Vector<Vector2> polygon = polygon_editor->get_polygon(i); - navigation_polygon->add_outline(polygon); + nav_polygon->add_outline(polygon); } - navigation_polygon->make_polygons_from_outlines(); - return navigation_polygon; + nav_polygon->make_polygons_from_outlines(); + return nav_polygon; } void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile); ERR_FAIL_COND(!tile_data); - Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer); + Ref<NavigationPolygon> nav_polygon = tile_data->get_navigation_polygon(navigation_layer); polygon_editor->clear_polygons(); - if (navigation_polygon.is_valid()) { - for (int i = 0; i < navigation_polygon->get_outline_count(); i++) { - polygon_editor->add_polygon(navigation_polygon->get_outline(i)); + if (nav_polygon.is_valid()) { + for (int i = 0; i < nav_polygon->get_outline_count(); i++) { + polygon_editor->add_polygon(nav_polygon->get_outline(i)); } } polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); @@ -2691,8 +2691,8 @@ void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile); ERR_FAIL_COND(!tile_data); - Ref<NavigationPolygon> navigation_polygon = p_value; - tile_data->set_navigation_polygon(navigation_layer, navigation_polygon); + Ref<NavigationPolygon> nav_polygon = p_value; + tile_data->set_navigation_polygon(navigation_layer, nav_polygon); polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } @@ -2740,9 +2740,9 @@ void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfo // Draw all shapes. RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform); - Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer); - if (navigation_polygon.is_valid()) { - Vector<Vector2> verts = navigation_polygon->get_vertices(); + Ref<NavigationPolygon> nav_polygon = tile_data->get_navigation_polygon(navigation_layer); + if (nav_polygon.is_valid()) { + Vector<Vector2> verts = nav_polygon->get_vertices(); if (verts.size() < 3) { return; } @@ -2759,9 +2759,9 @@ void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfo } RandomPCG rand; - for (int i = 0; i < navigation_polygon->get_polygon_count(); i++) { + for (int i = 0; i < nav_polygon->get_polygon_count(); i++) { // An array of vertices for this polygon. - Vector<int> polygon = navigation_polygon->get_polygon(i); + Vector<int> polygon = nav_polygon->get_polygon(i); Vector<Vector2> vertices; vertices.resize(polygon.size()); for (int j = 0; j < polygon.size(); j++) { diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index acfa8b3d00..7cc29dbfad 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -3190,10 +3190,10 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { TreeItem *selected_tree_item = terrains_tree->get_selected(); if (selected_tree_item && selected_tree_item->get_metadata(0)) { Dictionary metadata_dict = selected_tree_item->get_metadata(0); - int selected_terrain_set = metadata_dict["terrain_set"]; - int selected_terrain_id = metadata_dict["terrain_id"]; - ERR_FAIL_INDEX(selected_terrain_set, tile_set->get_terrain_sets_count()); - ERR_FAIL_INDEX(selected_terrain_id, tile_set->get_terrains_count(selected_terrain_set)); + int sel_terrain_set = metadata_dict["terrain_set"]; + int sel_terrain_id = metadata_dict["terrain_id"]; + ERR_FAIL_INDEX(sel_terrain_set, tile_set->get_terrain_sets_count()); + ERR_FAIL_INDEX(sel_terrain_id, tile_set->get_terrains_count(sel_terrain_set)); // Add the two first generic modes int item_index = terrains_tile_list->add_icon_item(main_vbox_container->get_theme_icon(SNAME("TerrainConnect"), SNAME("EditorIcons"))); @@ -3211,13 +3211,13 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { // Sort the items in a map by the number of corresponding terrains. RBMap<int, RBSet<TileSet::TerrainsPattern>> sorted; - for (const TileSet::TerrainsPattern &E : per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id]) { + for (const TileSet::TerrainsPattern &E : per_terrain_terrains_patterns[sel_terrain_set][sel_terrain_id]) { // Count the number of matching sides/terrains. int count = 0; for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); - if (tile_set->is_valid_terrain_peering_bit(selected_terrain_set, bit) && E.get_terrain_peering_bit(bit) == selected_terrain_id) { + if (tile_set->is_valid_terrain_peering_bit(sel_terrain_set, bit) && E.get_terrain_peering_bit(bit) == sel_terrain_id) { count++; } } @@ -3234,7 +3234,7 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { bool transpose = false; double max_probability = -1.0; - for (const TileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(selected_terrain_set, terrains_pattern)) { + for (const TileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(sel_terrain_set, terrains_pattern)) { Ref<TileSetSource> source = tile_set->get_source(cell.source_id); Ref<TileSetAtlasSource> atlas_source = source; @@ -3689,8 +3689,8 @@ void TileMapEditor::_update_layers_selection() { } void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(undo_redo.is_null()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(undo_redo_man.is_null()); TileMap *tile_map = Object::cast_to<TileMap>(p_edited); if (!tile_map) { @@ -3721,12 +3721,12 @@ void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_ end = MIN(MAX(p_from_index, p_to_pos) + 1, end); } -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); // Save layers' properties. if (p_from_index < 0) { - undo_redo->add_undo_method(tile_map, "remove_layer", p_to_pos < 0 ? tile_map->get_layers_count() : p_to_pos); + undo_redo_man->add_undo_method(tile_map, "remove_layer", p_to_pos < 0 ? tile_map->get_layers_count() : p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_undo_method(tile_map, "add_layer", p_from_index); + undo_redo_man->add_undo_method(tile_map, "add_layer", p_from_index); } List<PropertyInfo> properties; @@ -3752,11 +3752,11 @@ void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_ #undef ADD_UNDO if (p_from_index < 0) { - undo_redo->add_do_method(tile_map, "add_layer", p_to_pos); + undo_redo_man->add_do_method(tile_map, "add_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_map, "remove_layer", p_from_index); + undo_redo_man->add_do_method(tile_map, "remove_layer", p_from_index); } else { - undo_redo->add_do_method(tile_map, "move_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(tile_map, "move_layer", p_from_index, p_to_pos); } } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 4299ae8d3e..1857606f00 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -561,9 +561,9 @@ void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() { void TileSetAtlasSourceEditor::_update_atlas_source_inspector() { // Update visibility. - bool visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button; - atlas_source_inspector_label->set_visible(visible); - atlas_source_inspector->set_visible(visible); + bool inspector_visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button; + atlas_source_inspector_label->set_visible(inspector_visible); + atlas_source_inspector->set_visible(inspector_visible); } void TileSetAtlasSourceEditor::_update_tile_inspector() { @@ -2067,14 +2067,14 @@ void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) } void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(!undo_redo.is_valid()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(!undo_redo_man.is_valid()); -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); AtlasTileProxyObject *tile_data_proxy = Object::cast_to<AtlasTileProxyObject>(p_edited); if (tile_data_proxy) { - UndoRedo *internal_undo_redo = undo_redo->get_history_for_object(tile_data_proxy).undo_redo; + UndoRedo *internal_undo_redo = undo_redo_man->get_history_for_object(tile_data_proxy).undo_redo; internal_undo_redo->start_force_keep_in_merge_ends(); Vector<String> components = String(p_property).split("/", true, 2); @@ -2107,7 +2107,7 @@ void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo TileSetAtlasSource *atlas_source = atlas_source_proxy->get_edited(); ERR_FAIL_COND(!atlas_source); - UndoRedo *internal_undo_redo = undo_redo->get_history_for_object(atlas_source).undo_redo; + UndoRedo *internal_undo_redo = undo_redo_man->get_history_for_object(atlas_source).undo_redo; internal_undo_redo->start_force_keep_in_merge_ends(); PackedVector2Array arr; diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 7394288fcd..3b057b7631 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -407,11 +407,11 @@ void TileSetEditor::_tab_changed(int p_tab_changed) { } void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(undo_redo.is_null()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(undo_redo_man.is_null()); - TileSet *tile_set = Object::cast_to<TileSet>(p_edited); - if (!tile_set) { + TileSet *ed_tile_set = Object::cast_to<TileSet>(p_edited); + if (!ed_tile_set) { return; } @@ -421,18 +421,18 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ int begin = 0; int end; if (p_array_prefix == "occlusion_layer_") { - end = tile_set->get_occlusion_layers_count(); + end = ed_tile_set->get_occlusion_layers_count(); } else if (p_array_prefix == "physics_layer_") { - end = tile_set->get_physics_layers_count(); + end = ed_tile_set->get_physics_layers_count(); } else if (p_array_prefix == "terrain_set_") { - end = tile_set->get_terrain_sets_count(); + end = ed_tile_set->get_terrain_sets_count(); } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") { int terrain_set = components[0].trim_prefix("terrain_set_").to_int(); - end = tile_set->get_terrains_count(terrain_set); + end = ed_tile_set->get_terrains_count(terrain_set); } else if (p_array_prefix == "navigation_layer_") { - end = tile_set->get_navigation_layers_count(); + end = ed_tile_set->get_navigation_layers_count(); } else if (p_array_prefix == "custom_data_layer_") { - end = tile_set->get_custom_data_layers_count(); + end = ed_tile_set->get_custom_data_layers_count(); } else { ERR_FAIL_MSG("Invalid array prefix for TileSet."); } @@ -452,10 +452,10 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ end = MIN(MAX(p_from_index, p_to_pos) + 1, end); } -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); // Save layers' properties. List<PropertyInfo> properties; - tile_set->get_property_list(&properties); + ed_tile_set->get_property_list(&properties); for (PropertyInfo pi : properties) { if (pi.name.begins_with(p_array_prefix)) { String str = pi.name.trim_prefix(p_array_prefix); @@ -469,17 +469,17 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ if (to_char_index > 0) { int array_index = str.left(to_char_index).to_int(); if (array_index >= begin && array_index < end) { - ADD_UNDO(tile_set, pi.name); + ADD_UNDO(ed_tile_set, pi.name); } } } } // Save properties for TileSetAtlasSources tile data - for (int i = 0; i < tile_set->get_source_count(); i++) { - int source_id = tile_set->get_source_id(i); + for (int i = 0; i < ed_tile_set->get_source_count(); i++) { + int source_id = ed_tile_set->get_source_id(i); - Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id); + Ref<TileSetAtlasSource> tas = ed_tile_set->get_source(source_id); if (tas.is_valid()) { for (int j = 0; j < tas->get_tiles_count(); j++) { Vector2i tile_id = tas->get_tile_id(j); @@ -537,68 +537,68 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ // Add do method. if (p_array_prefix == "occlusion_layer_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_occlusion_layer", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_occlusion_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_occlusion_layer", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_occlusion_layer", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_occlusion_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_occlusion_layer", p_from_index, p_to_pos); } } else if (p_array_prefix == "physics_layer_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_physics_layer", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_physics_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_physics_layer", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_physics_layer", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_physics_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_physics_layer", p_from_index, p_to_pos); } } else if (p_array_prefix == "terrain_set_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_terrain_set", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_terrain_set", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_terrain_set", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_terrain_set", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_terrain_set", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_terrain_set", p_from_index, p_to_pos); } } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") { int terrain_set = components[0].trim_prefix("terrain_set_").to_int(); if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_terrain", terrain_set, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_terrain", terrain_set, p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_terrain", terrain_set, p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_terrain", terrain_set, p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_terrain", terrain_set, p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_terrain", terrain_set, p_from_index, p_to_pos); } } else if (p_array_prefix == "navigation_layer_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_navigation_layer", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_navigation_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_navigation_layer", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_navigation_layer", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_navigation_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_navigation_layer", p_from_index, p_to_pos); } } else if (p_array_prefix == "custom_data_layer_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_custom_data_layer", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_custom_data_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_custom_data_layer", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_custom_data_layer", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_custom_data_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_custom_data_layer", p_from_index, p_to_pos); } } } void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(undo_redo.is_null()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(undo_redo_man.is_null()); -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); - TileSet *tile_set = Object::cast_to<TileSet>(p_edited); - if (tile_set) { +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); + TileSet *ed_tile_set = Object::cast_to<TileSet>(p_edited); + if (ed_tile_set) { Vector<String> components = p_property.split("/", true, 3); - for (int i = 0; i < tile_set->get_source_count(); i++) { - int source_id = tile_set->get_source_id(i); + for (int i = 0; i < ed_tile_set->get_source_count(); i++) { + int source_id = ed_tile_set->get_source_id(i); - Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id); + Ref<TileSetAtlasSource> tas = ed_tile_set->get_source(source_id); if (tas.is_valid()) { for (int j = 0; j < tas->get_tiles_count(); j++) { Vector2i tile_id = tas->get_tile_id(j); diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index 17115519e2..68bc4389a2 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -264,8 +264,8 @@ void TilesEditorPlugin::set_sorting_option(int p_option) { source_sort = p_option; } -List<int> TilesEditorPlugin::get_sorted_sources(const Ref<TileSet> tile_set) const { - SourceNameComparator::tile_set = tile_set; +List<int> TilesEditorPlugin::get_sorted_sources(const Ref<TileSet> p_tile_set) const { + SourceNameComparator::tile_set = p_tile_set; List<int> source_ids; for (int i = 0; i < tile_set->get_source_count(); i++) { diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 40993ea168..d87513bfe1 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -86,7 +86,7 @@ void VisualShaderNodePlugin::set_editor(VisualShaderEditor *p_editor) { } Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) { - Object *ret; + Object *ret = nullptr; if (GDVIRTUAL_CALL(_create_editor, p_parent_resource, p_node, ret)) { return Object::cast_to<Control>(ret); } @@ -1235,11 +1235,11 @@ void VisualShaderEditor::_update_nodes() { Ref<Resource> res = ResourceLoader::load(script_path); ERR_FAIL_COND(res.is_null()); ERR_FAIL_COND(!res->is_class("Script")); - Ref<Script> script = Ref<Script>(res); + Ref<Script> scr = Ref<Script>(res); Ref<VisualShaderNodeCustom> ref; ref.instantiate(); - ref->set_script(script); + ref->set_script(scr); if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) { continue; } @@ -1278,7 +1278,7 @@ void VisualShaderEditor::_update_nodes() { Dictionary dict; dict["name"] = name; - dict["script"] = script; + dict["script"] = scr; dict["description"] = description; dict["return_icon_type"] = return_icon_type; @@ -1705,9 +1705,9 @@ void VisualShaderEditor::_update_graph() { } } - List<VisualShader::Connection> connections; - visual_shader->get_node_connections(type, &connections); - graph_plugin->set_connections(connections); + List<VisualShader::Connection> node_connections; + visual_shader->get_node_connections(type, &node_connections); + graph_plugin->set_connections(node_connections); Vector<int> nodes = visual_shader->get_node_list(type); @@ -1724,7 +1724,7 @@ void VisualShaderEditor::_update_graph() { graph_plugin->make_dirty(false); - for (const VisualShader::Connection &E : connections) { + for (const VisualShader::Connection &E : node_connections) { int from = E.from_node; int from_idx = E.from_port; int to = E.to_node; @@ -1899,45 +1899,45 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { - int from_node = E.from_node; - int from_port = E.from_port; - int to_node = E.to_node; - int to_port = E.to_port; + int cn_from_node = E.from_node; + int cn_from_port = E.from_port; + int cn_to_node = E.to_node; + int cn_to_port = E.to_port; - if (from_node == p_node) { + if (cn_from_node == p_node) { if (p_expand) { - if (from_port > p_port) { // reconnect ports after expanded ports - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); + if (cn_from_port > p_port) { // reconnect ports after expanded ports + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port + type_size, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port + type_size, to_node, to_port); + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port + type_size, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port + type_size, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port); } } else { - if (from_port > p_port + type_size) { // reconnect ports after expanded ports - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); + if (cn_from_port > p_port + type_size) { // reconnect ports after expanded ports + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_port - type_size, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port - type_size, to_node, to_port); + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port - type_size, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port - type_size, to_node, to_port); - } else if (from_port > p_port) { // disconnect component ports - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port); + } else if (cn_from_port > p_port) { // disconnect component ports + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); } } } @@ -1973,30 +1973,30 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { - int from_node = E.from_node; - int from_port = E.from_port; - int to_node = E.to_node; - int to_port = E.to_port; - - if (to_node == p_node) { - if (to_port == p_port) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - } else if (to_port > p_port) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port - 1); - undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port - 1); - - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port - 1); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port - 1); + int cn_from_node = E.from_node; + int cn_from_port = E.from_port; + int cn_to_node = E.to_node; + int cn_to_port = E.to_port; + + if (cn_to_node == p_node) { + if (cn_to_port == p_port) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + } else if (cn_to_port > p_port) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1); + + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1); } } } @@ -2022,30 +2022,30 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { - int from_node = E.from_node; - int from_port = E.from_port; - int to_node = E.to_node; - int to_port = E.to_port; - - if (from_node == p_node) { - if (from_port == p_port) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - } else if (from_port > p_port) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port - 1, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port - 1, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port - 1, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port - 1, to_node, to_port); + int cn_from_node = E.from_node; + int cn_from_port = E.from_port; + int cn_to_node = E.to_node; + int cn_to_port = E.to_port; + + if (cn_from_node == p_node) { + if (cn_from_port == p_port) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + } else if (cn_from_port > p_port) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port); } } } @@ -2932,16 +2932,16 @@ void VisualShaderEditor::_add_varying(const String &p_name, VisualShader::Varyin void VisualShaderEditor::_remove_varying(const String &p_name) { undo_redo->create_action(vformat(TTR("Remove Varying from Visual Shader: %s"), p_name)); - VisualShader::VaryingMode mode = visual_shader->get_varying_mode(p_name); + VisualShader::VaryingMode var_mode = visual_shader->get_varying_mode(p_name); undo_redo->add_do_method(visual_shader.ptr(), "remove_varying", p_name); - undo_redo->add_undo_method(visual_shader.ptr(), "add_varying", p_name, mode, visual_shader->get_varying_type(p_name)); + undo_redo->add_undo_method(visual_shader.ptr(), "add_varying", p_name, var_mode, visual_shader->get_varying_type(p_name)); undo_redo->add_do_method(this, "_update_varyings"); undo_redo->add_undo_method(this, "_update_varyings"); for (int i = 0; i <= VisualShader::TYPE_LIGHT; i++) { - if (mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT && i == 0) { + if (var_mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT && i == 0) { continue; } @@ -2967,10 +2967,10 @@ void VisualShaderEditor::_remove_varying(const String &p_name) { } } - List<VisualShader::Connection> connections; - visual_shader->get_node_connections(type, &connections); + List<VisualShader::Connection> node_connections; + visual_shader->get_node_connections(type, &node_connections); - for (VisualShader::Connection &E : connections) { + for (VisualShader::Connection &E : node_connections) { Ref<VisualShaderNodeVaryingGetter> var_getter = Object::cast_to<VisualShaderNodeVaryingGetter>(visual_shader->get_node(type, E.from_node).ptr()); if (var_getter.is_valid() && E.from_port > 0) { undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); @@ -3847,10 +3847,10 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<CopyItem> &r_items, Li } } - List<VisualShader::Connection> connections; - visual_shader->get_node_connections(type, &connections); + List<VisualShader::Connection> node_connections; + visual_shader->get_node_connections(type, &node_connections); - for (const VisualShader::Connection &E : connections) { + for (const VisualShader::Connection &E : node_connections) { if (nodes.has(E.from_node) && nodes.has(E.to_node)) { r_connections.push_back(E); } @@ -3961,15 +3961,15 @@ void VisualShaderEditor::_duplicate_nodes() { int type = get_current_shader_type(); List<CopyItem> items; - List<VisualShader::Connection> connections; + List<VisualShader::Connection> node_connections; - _dup_copy_nodes(type, items, connections); + _dup_copy_nodes(type, items, node_connections); if (items.is_empty()) { return; } - _dup_paste_nodes(type, items, connections, Vector2(10, 10) * EDSCALE, true); + _dup_paste_nodes(type, items, node_connections, Vector2(10, 10) * EDSCALE, true); } void VisualShaderEditor::_copy_nodes(bool p_cut) { @@ -4064,11 +4064,11 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, bool type_changed = next_input_type != prev_input_type; - Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Visual Shader Input Type Changed")); + Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo(); + undo_redo_man->create_action(TTR("Visual Shader Input Type Changed")); - undo_redo->add_do_method(p_input.ptr(), "set_input_name", p_name); - undo_redo->add_undo_method(p_input.ptr(), "set_input_name", prev_name); + undo_redo_man->add_do_method(p_input.ptr(), "set_input_name", p_name); + undo_redo_man->add_undo_method(p_input.ptr(), "set_input_name", prev_name); if (type_changed) { for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) { @@ -4098,30 +4098,30 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { - int from_node = E.from_node; - int from_port = E.from_port; - int to_node = E.to_node; - int to_port = E.to_port; - - if (from_node == id) { - bool is_incompatible_types = !visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, to_node)->get_input_port_type(to_port)); - - if (is_incompatible_types || from_port > type_size) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); + int cn_from_node = E.from_node; + int cn_from_port = E.from_port; + int cn_to_node = E.to_node; + int cn_to_port = E.to_port; + + if (cn_from_node == id) { + bool is_incompatible_types = !visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, cn_to_node)->get_input_port_type(cn_to_port)); + + if (is_incompatible_types || cn_from_port > type_size) { + undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); } } } - undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); - undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); } } } - undo_redo->commit_action(); + undo_redo_man->commit_action(); } void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name) { @@ -4133,11 +4133,11 @@ void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParamete bool type_changed = p_parameter_ref->get_parameter_type_by_name(p_name) != p_parameter_ref->get_parameter_type_by_name(prev_name); - Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("ParameterRef Name Changed")); + Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo(); + undo_redo_man->create_action(TTR("ParameterRef Name Changed")); - undo_redo->add_do_method(p_parameter_ref.ptr(), "set_parameter_name", p_name); - undo_redo->add_undo_method(p_parameter_ref.ptr(), "set_parameter_name", prev_name); + undo_redo_man->add_do_method(p_parameter_ref.ptr(), "set_parameter_name", p_name); + undo_redo_man->add_undo_method(p_parameter_ref.ptr(), "set_parameter_name", prev_name); // update output port for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) { @@ -4152,20 +4152,20 @@ void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParamete if (visual_shader->is_port_types_compatible(p_parameter_ref->get_parameter_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } - undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); - undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); break; } } - undo_redo->commit_action(); + undo_redo_man->commit_action(); } void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name) { @@ -4177,11 +4177,11 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var bool is_getter = Ref<VisualShaderNodeVaryingGetter>(p_varying.ptr()).is_valid(); - Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Varying Name Changed")); + Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo(); + undo_redo_man->create_action(TTR("Varying Name Changed")); - undo_redo->add_do_method(p_varying.ptr(), "set_varying_name", p_name); - undo_redo->add_undo_method(p_varying.ptr(), "set_varying_name", prev_name); + undo_redo_man->add_do_method(p_varying.ptr(), "set_varying_name", p_name); + undo_redo_man->add_undo_method(p_varying.ptr(), "set_varying_name", prev_name); VisualShader::VaryingType vtype = p_varying->get_varying_type_by_name(p_name); VisualShader::VaryingType prev_vtype = p_varying->get_varying_type_by_name(prev_name); @@ -4189,8 +4189,8 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var bool type_changed = vtype != prev_vtype; if (type_changed) { - undo_redo->add_do_method(p_varying.ptr(), "set_varying_type", vtype); - undo_redo->add_undo_method(p_varying.ptr(), "set_varying_type", prev_vtype); + undo_redo_man->add_do_method(p_varying.ptr(), "set_varying_type", vtype); + undo_redo_man->add_undo_method(p_varying.ptr(), "set_varying_type", prev_vtype); } // update ports @@ -4209,32 +4209,32 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var if (visual_shader->is_port_types_compatible(p_varying->get_varying_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } else { if (E.to_node == id) { if (visual_shader->is_port_types_compatible(p_varying->get_varying_type_by_name(p_name), visual_shader->get_node(type, E.from_node)->get_output_port_type(E.from_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } } - undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); - undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); break; } } - undo_redo->commit_action(); + undo_redo_man->commit_action(); } void VisualShaderEditor::_float_constant_selected(int p_which) { @@ -4515,8 +4515,8 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da for (int i = 0; i < arr.size(); i++) { String type = ResourceLoader::get_resource_type(arr[i]); if (type == "GDScript") { - Ref<Script> script = ResourceLoader::load(arr[i]); - if (script->get_instance_base_type() == "VisualShaderNodeCustom") { + Ref<Script> scr = ResourceLoader::load(arr[i]); + if (scr->get_instance_base_type() == "VisualShaderNodeCustom") { saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE); saved_node_pos_dirty = true; @@ -6229,9 +6229,9 @@ void VisualShaderNodePortPreview::_shader_changed() { } } - Ref<ShaderMaterial> material; - material.instantiate(); - material->set_shader(preview_shader); + Ref<ShaderMaterial> mat; + mat.instantiate(); + mat->set_shader(preview_shader); //find if a material is also being edited and copy parameters to this one @@ -6252,12 +6252,12 @@ void VisualShaderNodePortPreview::_shader_changed() { List<PropertyInfo> params; src_mat->get_shader()->get_shader_uniform_list(¶ms); for (const PropertyInfo &E : params) { - material->set(E.name, src_mat->get(E.name)); + mat->set(E.name, src_mat->get(E.name)); } } } - set_material(material); + set_material(mat); } void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port) { diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 673da8872d..05015528c6 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -563,19 +563,19 @@ private: Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da->make_dir(dir.path_join(rel_path)); } else { - Vector<uint8_t> data; - data.resize(info.uncompressed_size); + Vector<uint8_t> uncomp_data; + uncomp_data.resize(info.uncompressed_size); String rel_path = path.substr(zip_root.length()); //read unzOpenCurrentFile(pkg); - ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); + ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size()); ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", rel_path)); unzCloseCurrentFile(pkg); Ref<FileAccess> f = FileAccess::open(dir.path_join(rel_path), FileAccess::WRITE); if (f.is_valid()) { - f->store_buffer(data.ptr(), data.size()); + f->store_buffer(uncomp_data.ptr(), uncomp_data.size()); } else { failed_files.push_back(rel_path); } @@ -1490,7 +1490,7 @@ void ProjectList::sort_projects() { for (int i = 0; i < _projects.size(); ++i) { Item &item = _projects.write[i]; - bool visible = true; + bool item_visible = true; if (!_search_term.is_empty()) { String search_path; if (_search_term.contains("/")) { @@ -1502,10 +1502,10 @@ void ProjectList::sort_projects() { } // When searching, display projects whose name or path contain the search term - visible = item.project_name.findn(_search_term) != -1 || search_path.findn(_search_term) != -1; + item_visible = item.project_name.findn(_search_term) != -1 || search_path.findn(_search_term) != -1; } - item.control->set_visible(visible); + item.control->set_visible(item_visible); } for (int i = 0; i < _projects.size(); ++i) { diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 81f37eaeec..0f91760a84 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -357,12 +357,12 @@ void ProjectSettingsEditor::_action_edited(const String &p_name, const Dictionar } else { // Events changed - int event_count = ((Array)p_action["events"]).size(); + int act_event_count = ((Array)p_action["events"]).size(); int old_event_count = ((Array)old_val["events"]).size(); - if (event_count == old_event_count) { + if (act_event_count == old_event_count) { undo_redo->create_action(TTR("Edit Input Action Event")); - } else if (event_count > old_event_count) { + } else if (act_event_count > old_event_count) { undo_redo->create_action(TTR("Add Input Action Event")); } else { undo_redo->create_action(TTR("Remove Input Action Event")); diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 300a3d0f05..f918570c66 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -652,9 +652,9 @@ void RenameDialog::_features_toggled(bool pressed) { } // Adjust to minimum size in y - Size2i size = get_size(); - size.y = 0; - set_size(size); + Size2i new_size = get_size(); + new_size.y = 0; + set_size(new_size); } #endif // MODULE_REGEX_ENABLED diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp index 4563dbb0f7..5b54a5a229 100644 --- a/editor/scene_create_dialog.cpp +++ b/editor/scene_create_dialog.cpp @@ -170,9 +170,9 @@ Node *SceneCreateDialog::create_scene_root() { root = memnew(Node3D); break; case ROOT_USER_INTERFACE: { - Control *gui = memnew(Control); - gui->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); - root = gui; + Control *gui_ctl = memnew(Control); + gui_ctl->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); + root = gui_ctl; } break; case ROOT_OTHER: root = Object::cast_to<Node>(select_node_dialog->instance_selected()); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 967334f183..acaa4ec3c9 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -330,9 +330,9 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de Ref<SceneState> ss = p->get_scene_inherited_state(); if (ss.is_valid()) { String path = ss->get_path(); - Ref<PackedScene> data = ResourceLoader::load(path); - if (data.is_valid()) { - p = data->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); + Ref<PackedScene> pack_data = ResourceLoader::load(path); + if (pack_data.is_valid()) { + p = pack_data->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); if (!p) { continue; } @@ -1147,9 +1147,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { String name = selected_favorite_root.get_slicec(' ', 0); if (ScriptServer::is_global_class(name)) { new_node = Object::cast_to<Node>(ClassDB::instantiate(ScriptServer::get_global_class_native_base(name))); - Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(name), "Script"); - if (new_node && script.is_valid()) { - new_node->set_script(script); + Ref<Script> scr = ResourceLoader::load(ScriptServer::get_global_class_path(name), "Script"); + if (new_node && scr.is_valid()) { + new_node->set_script(scr); new_node->set_name(name); } } else { diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 2fef3ba8d7..da727a127a 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -215,8 +215,8 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { if (connect_to_script_mode) { Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - Ref<Script> script = p_node->get_script(); - if (!script.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != script) { + Ref<Script> scr = p_node->get_script(); + if (!scr.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != scr) { //has script item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT); } else { @@ -224,7 +224,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); item->set_selectable(0, false); - if (!script.is_null()) { // make sure to mark the script if a custom type + if (!scr.is_null()) { // make sure to mark the script if a custom type item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT); item->set_button_disabled(0, item->get_button_count(0) - 1, true); } @@ -268,8 +268,8 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { if (can_rename) { //should be can edit.. - String warning = p_node->get_configuration_warnings_as_string(); - if (!warning.is_empty()) { + String conf_warning = p_node->get_configuration_warnings_as_string(); + if (!conf_warning.is_empty()) { const int num_warnings = p_node->get_configuration_warnings().size(); String warning_icon; if (num_warnings == 1) { @@ -284,15 +284,15 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { const String bullet_point = String::utf8("• "); int next_newline = 0; while (next_newline != -1) { - next_newline = warning.find("\n", next_newline + 2); - if (warning.substr(next_newline + 1, bullet_point.length()) != bullet_point) { - warning = warning.insert(next_newline + 1, " "); + next_newline = conf_warning.find("\n", next_newline + 2); + if (conf_warning.substr(next_newline + 1, bullet_point.length()) != bullet_point) { + conf_warning = conf_warning.insert(next_newline + 1, " "); } } String newline = (num_warnings == 1 ? "\n" : "\n\n"); - item->add_button(0, get_theme_icon(warning_icon, SNAME("EditorIcons")), BUTTON_WARNING, false, TTR("Node configuration warning:") + newline + warning); + item->add_button(0, get_theme_icon(warning_icon, SNAME("EditorIcons")), BUTTON_WARNING, false, TTR("Node configuration warning:") + newline + conf_warning); } if (p_node->is_unique_name_in_owner()) { @@ -385,20 +385,20 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { p_node->connect("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed).bind(p_node)); } - Ref<Script> script = p_node->get_script(); - if (!script.is_null()) { + Ref<Script> scr = p_node->get_script(); + if (!scr.is_null()) { String additional_notes; Color button_color = Color(1, 1, 1); // Can't set tooltip after adding button, need to do it before. - if (script->is_tool()) { + if (scr->is_tool()) { additional_notes += "\n" + TTR("This script is currently running in the editor."); button_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } - if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == script) { + if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == scr) { additional_notes += "\n" + TTR("This script is a custom type."); button_color.a = 0.5; } - item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path() + additional_notes); + item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + scr->get_path() + additional_notes); item->set_button_color(0, item->get_button_count(0) - 1, button_color); } @@ -511,16 +511,16 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { int idx = item->get_button_by_id(0, BUTTON_VISIBILITY); ERR_FAIL_COND(idx == -1); - bool visible = false; + bool node_visible = false; if (p_node->is_class("CanvasItem") || p_node->is_class("CanvasLayer") || p_node->is_class("Window")) { - visible = p_node->call("is_visible"); + node_visible = p_node->call("is_visible"); CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw(); } else if (p_node->is_class("Node3D")) { - visible = p_node->call("is_visible"); + node_visible = p_node->call("is_visible"); } - if (visible) { + if (node_visible) { item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); } else { item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); @@ -1138,7 +1138,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from return Variant(); //dragging from button } - Vector<Node *> selected; + Vector<Node *> selected_nodes; Vector<Ref<Texture2D>> icons; TreeItem *next = tree->get_next_selected(nullptr); while (next) { @@ -1148,14 +1148,14 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from if (n) { // Only allow selection if not part of an instantiated scene. if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_scene_file_path().is_empty()) { - selected.push_back(n); + selected_nodes.push_back(n); icons.push_back(next->get_icon(0)); } } next = tree->get_next_selected(next); } - if (selected.is_empty()) { + if (selected_nodes.is_empty()) { return Variant(); } @@ -1164,20 +1164,20 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from int list_max = 10; float opacity_step = 1.0f / list_max; float opacity_item = 1.0f; - for (int i = 0; i < selected.size(); i++) { + for (int i = 0; i < selected_nodes.size(); i++) { if (i < list_max) { HBoxContainer *hb = memnew(HBoxContainer); TextureRect *tf = memnew(TextureRect); tf->set_texture(icons[i]); tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); hb->add_child(tf); - Label *label = memnew(Label(selected[i]->get_name())); + Label *label = memnew(Label(selected_nodes[i]->get_name())); hb->add_child(label); vb->add_child(hb); hb->set_modulate(Color(1, 1, 1, opacity_item)); opacity_item -= opacity_step; } - NodePath p = selected[i]->get_path(); + NodePath p = selected_nodes[i]->get_path(); objs.push_back(p); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index f57dfe4827..cc09c3a432 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -828,9 +828,9 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_get_current_template() const return ScriptLanguage::ScriptTemplate(); } -Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(const ScriptLanguage *language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const { +Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(const ScriptLanguage *p_language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const { Vector<ScriptLanguage::ScriptTemplate> user_templates; - String extension = language->get_extension(); + String extension = p_language->get_extension(); String dir_path = p_dir.path_join(p_object); @@ -840,7 +840,7 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c String file = d->get_next(); while (file != String()) { if (file.get_extension() == extension) { - user_templates.append(_parse_template(language, dir_path, file, p_origin, p_object)); + user_templates.append(_parse_template(p_language, dir_path, file, p_origin, p_object)); } file = d->get_next(); } @@ -849,7 +849,7 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c return user_templates; } -ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptLanguage *language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const { +ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptLanguage *p_language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const { ScriptLanguage::ScriptTemplate script_template = ScriptLanguage::ScriptTemplate(); script_template.origin = p_origin; script_template.inherit = p_inherits; @@ -857,7 +857,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL // Get meta delimiter String meta_delimiter = String(); List<String> comment_delimiters; - language->get_comment_delimiters(&comment_delimiters); + p_language->get_comment_delimiters(&comment_delimiters); for (const String &script_delimiter : comment_delimiters) { if (!script_delimiter.contains(" ")) { meta_delimiter = script_delimiter; diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index c7d8cfc38a..fb1a49a1ca 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -119,8 +119,8 @@ class ScriptCreateDialog : public ConfirmationDialog { void _update_template_menu(); void _update_dialog(); ScriptLanguage::ScriptTemplate _get_current_template() const; - Vector<ScriptLanguage::ScriptTemplate> _get_user_templates(const ScriptLanguage *language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const; - ScriptLanguage::ScriptTemplate _parse_template(const ScriptLanguage *language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const; + Vector<ScriptLanguage::ScriptTemplate> _get_user_templates(const ScriptLanguage *p_language, const StringName &p_object, const String &p_dir, const ScriptLanguage::TemplateLocation &p_origin) const; + ScriptLanguage::ScriptTemplate _parse_template(const ScriptLanguage *p_language, const String &p_path, const String &p_filename, const ScriptLanguage::TemplateLocation &p_origin, const String &p_inherits) const; String _get_script_origin_label(const ScriptLanguage::TemplateLocation &p_origin) const; protected: diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index ae533b5b75..cdbe88b99e 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -96,20 +96,20 @@ void ShaderCreateDialog::_update_language_info() { type_data.clear(); for (int i = 0; i < SHADER_TYPE_MAX; i++) { - ShaderTypeData data; + ShaderTypeData shader_type_data; if (i == int(SHADER_TYPE_TEXT)) { - data.use_templates = true; - data.extensions.push_back("gdshader"); - data.default_extension = "gdshader"; + shader_type_data.use_templates = true; + shader_type_data.extensions.push_back("gdshader"); + shader_type_data.default_extension = "gdshader"; } else if (i == int(SHADER_TYPE_INC)) { - data.extensions.push_back("gdshaderinc"); - data.default_extension = "gdshaderinc"; + shader_type_data.extensions.push_back("gdshaderinc"); + shader_type_data.default_extension = "gdshaderinc"; } else { - data.default_extension = "tres"; + shader_type_data.default_extension = "tres"; } - data.extensions.push_back("res"); - data.extensions.push_back("tres"); - type_data.push_back(data); + shader_type_data.extensions.push_back("res"); + shader_type_data.extensions.push_back("tres"); + type_data.push_back(shader_type_data); } } @@ -261,9 +261,9 @@ void ShaderCreateDialog::_load_exist() { void ShaderCreateDialog::_type_changed(int p_language) { current_type = p_language; - ShaderTypeData data = type_data[p_language]; + ShaderTypeData shader_type_data = type_data[p_language]; - String selected_ext = "." + data.default_extension; + String selected_ext = "." + shader_type_data.default_extension; String path = file_path->get_text(); String extension = ""; @@ -284,10 +284,10 @@ void ShaderCreateDialog::_type_changed(int p_language) { type_menu->set_item_disabled(int(SHADER_TYPE_INC), load_enabled); mode_menu->set_disabled(p_language == SHADER_TYPE_INC); - template_menu->set_disabled(!data.use_templates); + template_menu->set_disabled(!shader_type_data.use_templates); template_menu->clear(); - if (data.use_templates) { + if (shader_type_data.use_templates) { int last_template = EditorSettings::get_singleton()->get_project_metadata("shader_setup", "last_selected_template", 0); template_menu->add_item(TTR("Default")); @@ -437,8 +437,6 @@ String ShaderCreateDialog::_validate_path(const String &p_path) { } } - ShaderTypeData data = type_data[type_menu->get_selected()]; - bool found = false; bool match = false; |