diff options
Diffstat (limited to 'editor')
103 files changed, 2067 insertions, 1831 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 9af8b907c4..0183d08733 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -648,7 +648,7 @@ void AnimationBezierTrackEdit::set_animation_and_track(const Ref<Animation> &p_a animation = p_animation; read_only = p_read_only; selected_track = p_track; - update(); + queue_redraw(); } Size2 AnimationBezierTrackEdit::get_minimum_size() const { @@ -691,11 +691,11 @@ void AnimationBezierTrackEdit::_play_position_draw() { void AnimationBezierTrackEdit::set_play_position(real_t p_pos) { play_position_pos = p_pos; - play_position->update(); + play_position->queue_redraw(); } void AnimationBezierTrackEdit::update_play_position() { - play_position->update(); + play_position->queue_redraw(); } void AnimationBezierTrackEdit::set_root(Node *p_root) { @@ -734,12 +734,12 @@ void AnimationBezierTrackEdit::set_filtered(bool p_filtered) { } } } - update(); + queue_redraw(); } void AnimationBezierTrackEdit::_zoom_changed() { - update(); - play_position->update(); + queue_redraw(); + play_position->queue_redraw(); } void AnimationBezierTrackEdit::_update_locked_tracks_after(int p_track) { @@ -787,7 +787,7 @@ String AnimationBezierTrackEdit::get_tooltip(const Point2 &p_pos) const { void AnimationBezierTrackEdit::_clear_selection() { selection.clear(); emit_signal(SNAME("clear_selection")); - update(); + queue_redraw(); } void AnimationBezierTrackEdit::_change_selected_keys_handle_mode(Animation::HandleMode p_mode, bool p_auto) { @@ -819,7 +819,7 @@ void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int selection.insert(IntPair(p_track, idx)); emit_signal(SNAME("select_key"), idx, true, p_track); - update(); + queue_redraw(); } void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { @@ -909,7 +909,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { v_scroll = (maximum_value + minimum_value) / 2.0; v_zoom = (maximum_value - minimum_value) / ((get_size().height - timeline->get_size().height) * 0.9); - update(); + queue_redraw(); accept_event(); return; } else if (ED_GET_SHORTCUT("animation_bezier_editor/select_all_keys")->matches_event(p_event)) { @@ -917,13 +917,13 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { selection.insert(IntPair(edit_points[i].track, edit_points[i].key)); } - update(); + queue_redraw(); accept_event(); return; } else if (ED_GET_SHORTCUT("animation_bezier_editor/deselect_all_keys")->matches_event(p_event)) { selection.clear(); - update(); + queue_redraw(); accept_event(); return; } @@ -1024,7 +1024,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } } } - update(); + queue_redraw(); return; } else if (I.key == VISIBILITY_ICON) { if (hidden_tracks.has(track)) { @@ -1054,7 +1054,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { solo_track = -1; } - update(); + queue_redraw(); return; } else if (I.key == SOLO_ICON) { if (solo_track == track) { @@ -1076,7 +1076,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { set_animation_and_track(animation, track, read_only); solo_track = track; } - update(); + queue_redraw(); return; } return; @@ -1098,7 +1098,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } else { selection.insert(pair); } - update(); + queue_redraw(); select_single_attempt = IntPair(-1, -1); } else if (selection.has(pair)) { moving_selection_attempt = true; @@ -1110,7 +1110,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_handle_right = animation->bezier_track_get_key_out_handle(pair.first, pair.second); moving_selection_offset = Vector2(); select_single_attempt = pair; - update(); + queue_redraw(); } else { moving_selection_attempt = true; moving_selection = true; @@ -1135,7 +1135,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_handle_track = edit_points[i].track; moving_handle_left = animation->bezier_track_get_key_in_handle(edit_points[i].track, edit_points[i].key); moving_handle_right = animation->bezier_track_get_key_out_handle(edit_points[i].track, edit_points[i].key); - update(); + queue_redraw(); return; } @@ -1145,7 +1145,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_handle_track = edit_points[i].track; moving_handle_left = animation->bezier_track_get_key_in_handle(edit_points[i].track, edit_points[i].key); moving_handle_right = animation->bezier_track_get_key_out_handle(edit_points[i].track, edit_points[i].key); - update(); + queue_redraw(); return; } } @@ -1186,7 +1186,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_selection_from_track = selected_track; moving_selection_offset = Vector2(); select_single_attempt = IntPair(-1, -1); - update(); + queue_redraw(); return; } @@ -1258,7 +1258,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { box_selecting_attempt = false; box_selecting = false; - update(); + queue_redraw(); } if (moving_selection_attempt && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { @@ -1376,7 +1376,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } moving_selection_attempt = false; - update(); + queue_redraw(); } } @@ -1397,7 +1397,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { additional_moving_handle_lefts.clear(); additional_moving_handle_rights.clear(); - update(); + queue_redraw(); } if (box_selecting_attempt && mm.is_valid()) { @@ -1412,7 +1412,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { //avoid cursor from going too above, so it does not lose focus with viewport warp_mouse(Vector2(get_local_mouse_position().x, 0)); } - update(); + queue_redraw(); } if ((moving_handle == 1 || moving_handle == -1) && mm.is_valid()) { @@ -1461,7 +1461,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { moving_handle_left = -moving_handle_right; } } - update(); + queue_redraw(); } if ((moving_handle == -1 || moving_handle == 1) && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { @@ -1478,7 +1478,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } undo_redo->commit_action(); moving_handle = 0; - update(); + queue_redraw(); } } } @@ -1491,7 +1491,7 @@ void AnimationBezierTrackEdit::_pan_callback(Vector2 p_scroll_vec) { v_scroll += p_scroll_vec.y * v_zoom; v_scroll = CLAMP(v_scroll, -100000, 100000); timeline->set_value(timeline->get_value() - p_scroll_vec.x / timeline->get_zoom_scale()); - update(); + queue_redraw(); } void AnimationBezierTrackEdit::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt) { @@ -1511,7 +1511,7 @@ void AnimationBezierTrackEdit::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_or } } v_scroll = v_scroll + (p_origin.y - get_size().y / 2.0) * (v_zoom - v_zoom_orig); - update(); + queue_redraw(); } void AnimationBezierTrackEdit::_menu_selected(int p_index) { @@ -1541,7 +1541,7 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) { undo_redo->add_do_method(animation.ptr(), "track_insert_key", selected_track, time, new_point); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", selected_track, time); undo_redo->commit_action(); - update(); + queue_redraw(); } } break; case MENU_KEY_DUPLICATE: { @@ -1624,7 +1624,7 @@ void AnimationBezierTrackEdit::duplicate_selection() { selection.insert(IntPair(track, existing_idx)); } - update(); + queue_redraw(); } void AnimationBezierTrackEdit::delete_selection() { diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index aaaf3e6f04..4991b2cfaf 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1399,8 +1399,8 @@ public: }; void AnimationTimelineEdit::_zoom_changed(double) { - update(); - play_position->update(); + queue_redraw(); + play_position->queue_redraw(); emit_signal(SNAME("zoom_changed")); } @@ -1430,7 +1430,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { undo_redo->add_undo_method(animation.ptr(), "set_length", animation->get_length()); undo_redo->commit_action(); editing = false; - update(); + queue_redraw(); emit_signal(SNAME("length_changed"), p_new_len); } @@ -1703,7 +1703,7 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation, boo add_track->hide(); play_position->hide(); } - update(); + queue_redraw(); update_values(); } @@ -1731,7 +1731,7 @@ void AnimationTimelineEdit::set_track_edit(AnimationTrackEdit *p_track_edit) { void AnimationTimelineEdit::set_play_position(float p_pos) { play_position_pos = p_pos; - play_position->update(); + play_position->queue_redraw(); } float AnimationTimelineEdit::get_play_position() const { @@ -1739,7 +1739,7 @@ float AnimationTimelineEdit::get_play_position() const { } void AnimationTimelineEdit::update_play_position() { - play_position->update(); + play_position->queue_redraw(); } void AnimationTimelineEdit::update_values() { @@ -1853,9 +1853,9 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) { if (dragging_hsize) { int ofs = mm->get_position().x - dragging_hsize_from; name_limit = dragging_hsize_at + ofs; - update(); + queue_redraw(); emit_signal(SNAME("name_limit_changed")); - play_position->update(); + play_position->queue_redraw(); } if (dragging_timeline) { int x = mm->get_position().x - get_name_limit(); @@ -1898,7 +1898,7 @@ void AnimationTimelineEdit::_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origi void AnimationTimelineEdit::set_use_fps(bool p_use_fps) { use_fps = p_use_fps; update_values(); - update(); + queue_redraw(); } bool AnimationTimelineEdit::is_using_fps() const { @@ -2292,13 +2292,13 @@ void AnimationTrackEdit::_notification(int p_what) { case NOTIFICATION_MOUSE_ENTER: hovered = true; - update(); + queue_redraw(); break; case NOTIFICATION_MOUSE_EXIT: hovered = false; // When the mouse cursor exits the track, we're no longer hovering any keyframe. hovering_key_idx = -1; - update(); + queue_redraw(); [[fallthrough]]; case NOTIFICATION_DRAG_END: { cancel_drop(); @@ -2491,7 +2491,7 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati read_only = p_read_only; track = p_track; - update(); + queue_redraw(); ERR_FAIL_INDEX(track, animation->get_track_count()); @@ -2553,11 +2553,11 @@ void AnimationTrackEdit::_play_position_draw() { void AnimationTrackEdit::set_play_position(float p_pos) { play_position_pos = p_pos; - play_position->update(); + play_position->queue_redraw(); } void AnimationTrackEdit::update_play_position() { - play_position->update(); + play_position->queue_redraw(); } void AnimationTrackEdit::set_root(Node *p_root) { @@ -2565,8 +2565,8 @@ void AnimationTrackEdit::set_root(Node *p_root) { } void AnimationTrackEdit::_zoom_changed() { - update(); - play_position->update(); + queue_redraw(); + play_position->queue_redraw(); } void AnimationTrackEdit::_path_submitted(const String &p_text) { @@ -2811,7 +2811,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track)); undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track)); undo_redo->commit_action(); - update(); + queue_redraw(); accept_event(); } @@ -3090,7 +3090,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (hovering_key_idx != previous_hovering_key_idx) { // Required to draw keyframe hover feedback on the correct keyframe. - update(); + queue_redraw(); } } } @@ -3156,7 +3156,7 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d dropping_at = 1; } - const_cast<AnimationTrackEdit *>(this)->update(); + const_cast<AnimationTrackEdit *>(this)->queue_redraw(); const_cast<AnimationTrackEdit *>(this)->emit_signal(SNAME("drop_attempted"), track); return true; @@ -3202,7 +3202,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", track, update_mode); undo_redo->add_undo_method(animation.ptr(), "value_track_set_update_mode", track, animation->value_track_get_update_mode(track)); undo_redo->commit_action(); - update(); + queue_redraw(); } break; case MENU_INTERPOLATION_NEAREST: @@ -3215,7 +3215,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", track, interp_mode); undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_type", track, animation->track_get_interpolation_type(track)); undo_redo->commit_action(); - update(); + queue_redraw(); } break; case MENU_LOOP_WRAP: case MENU_LOOP_CLAMP: { @@ -3224,7 +3224,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, loop_wrap); undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, animation->track_get_interpolation_loop_wrap(track)); undo_redo->commit_action(); - update(); + queue_redraw(); } break; case MENU_KEY_INSERT: { @@ -3247,13 +3247,13 @@ void AnimationTrackEdit::_menu_selected(int p_index) { void AnimationTrackEdit::cancel_drop() { if (dropping_at != 0) { dropping_at = 0; - update(); + queue_redraw(); } } void AnimationTrackEdit::set_in_group(bool p_enable) { in_group = p_enable; - update(); + queue_redraw(); } void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselection) { @@ -3399,7 +3399,7 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co icon = p_type; node_name = p_name; node = p_node; - update(); + queue_redraw(); update_minimum_size(); } @@ -3419,11 +3419,11 @@ void AnimationTrackEditGroup::set_timeline(AnimationTimelineEdit *p_timeline) { void AnimationTrackEditGroup::set_root(Node *p_root) { root = p_root; - update(); + queue_redraw(); } void AnimationTrackEditGroup::_zoom_changed() { - update(); + queue_redraw(); } void AnimationTrackEditGroup::_bind_methods() { @@ -4645,18 +4645,18 @@ void AnimationTrackEditor::_update_tracks() { void AnimationTrackEditor::_redraw_tracks() { for (int i = 0; i < track_edits.size(); i++) { - track_edits[i]->update(); + track_edits[i]->queue_redraw(); } } void AnimationTrackEditor::_redraw_groups() { for (int i = 0; i < groups.size(); i++) { - groups[i]->update(); + groups[i]->queue_redraw(); } } void AnimationTrackEditor::_sync_animation_change() { - bezier_edit->update(); + bezier_edit->queue_redraw(); } void AnimationTrackEditor::_animation_changed() { @@ -4669,12 +4669,12 @@ void AnimationTrackEditor::_animation_changed() { } if (key_edit && key_edit->setting) { - // If editing a key, just update the edited track, makes refresh less costly. + // If editing a key, just redraw the edited track, makes refresh less costly. if (key_edit->track < track_edits.size()) { if (animation->track_get_type(key_edit->track) == Animation::TYPE_BEZIER) { - bezier_edit->update(); + bezier_edit->queue_redraw(); } else { - track_edits[key_edit->track]->update(); + track_edits[key_edit->track]->queue_redraw(); } } return; @@ -4713,7 +4713,7 @@ void AnimationTrackEditor::_update_step_spinbox() { } void AnimationTrackEditor::_animation_update() { - timeline->update(); + timeline->queue_redraw(); timeline->update_values(); bool same = true; @@ -4742,7 +4742,7 @@ void AnimationTrackEditor::_animation_update() { _update_tracks(); } - bezier_edit->update(); + bezier_edit->queue_redraw(); _update_step_spinbox(); emit_signal(SNAME("animation_step_changed"), animation->get_step()); @@ -5000,7 +5000,7 @@ void AnimationTrackEditor::_timeline_value_changed(double) { } _redraw_groups(); - bezier_edit->update(); + bezier_edit->queue_redraw(); bezier_edit->update_play_position(); } diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index ab64aaa24d..6499cf8df2 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -197,7 +197,7 @@ void AnimationTrackEditAudio::_preview_changed(ObjectID p_which) { Ref<AudioStream> stream = object->call("get_stream"); if (stream.is_valid() && stream->get_instance_id() == p_which) { - update(); + queue_redraw(); } } @@ -799,7 +799,7 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) { for (int i = 0; i < get_animation()->track_get_key_count(get_track()); i++) { Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), i); if (stream.is_valid() && stream->get_instance_id() == p_which) { - update(); + queue_redraw(); return; } } @@ -1026,7 +1026,7 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant get_undo_redo()->add_undo_method(get_animation().ptr(), "track_remove_key_at_time", get_track(), ofs); get_undo_redo()->commit_action(); - update(); + queue_redraw(); return; } } @@ -1086,7 +1086,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { if (len_resizing && mm.is_valid()) { len_resizing_rel += mm->get_relative().x; len_resizing_start = mm->is_shift_pressed(); - update(); + queue_redraw(); accept_event(); return; } @@ -1097,7 +1097,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { len_resizing_start = mb->is_shift_pressed(); len_resizing_from_px = mb->get_position().x; len_resizing_rel = 0; - update(); + queue_redraw(); accept_event(); return; } @@ -1120,7 +1120,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { } len_resizing_index = -1; - update(); + queue_redraw(); accept_event(); return; } diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 2b1584b20c..2d5e70e1ff 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1092,7 +1092,7 @@ void CodeTextEditor::trim_trailing_whitespace() { if (trimed_whitespace) { text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } } @@ -1110,7 +1110,7 @@ void CodeTextEditor::insert_final_newline() { text_editor->set_line(final_line, line); text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } } @@ -1154,7 +1154,7 @@ void CodeTextEditor::convert_indent_to_spaces() { if (changed_indentation) { text_editor->set_caret_column(cursor_column); text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } } @@ -1203,7 +1203,7 @@ void CodeTextEditor::convert_indent_to_tabs() { if (changed_indentation) { text_editor->set_caret_column(cursor_column); text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } } @@ -1295,7 +1295,7 @@ void CodeTextEditor::move_lines_up() { text_editor->set_caret_line(next_id); } text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } void CodeTextEditor::move_lines_down() { @@ -1341,7 +1341,7 @@ void CodeTextEditor::move_lines_down() { text_editor->set_caret_line(next_id); } text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } void CodeTextEditor::_delete_line(int p_line) { @@ -1418,7 +1418,7 @@ void CodeTextEditor::duplicate_selection() { } text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } void CodeTextEditor::toggle_inline_comment(const String &delimiter) { @@ -1495,7 +1495,7 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) { text_editor->set_caret_column(col); } text_editor->end_complex_operation(); - text_editor->update(); + text_editor->queue_redraw(); } void CodeTextEditor::goto_line(int p_line) { diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 587c16c229..dce9ca2b93 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -753,22 +753,12 @@ void ConnectionsDock::_open_connection_dialog(TreeItem &p_item) { } Dictionary subst; - - String s = node_name.capitalize().replace(" ", ""); - subst["NodeName"] = s; - if (!s.is_empty()) { - s[0] = s.to_lower()[0]; - } - subst["nodeName"] = s; - subst["node_name"] = node_name.capitalize().replace(" ", "_").to_lower(); - - s = signal_name.capitalize().replace(" ", ""); - subst["SignalName"] = s; - if (!s.is_empty()) { - s[0] = s.to_lower()[0]; - } - subst["signalName"] = s; - subst["signal_name"] = signal_name.capitalize().replace(" ", "_").to_lower(); + subst["NodeName"] = node_name.to_pascal_case(); + subst["nodeName"] = node_name.to_camel_case(); + subst["node_name"] = node_name.to_snake_case(); + subst["SignalName"] = signal_name.to_pascal_case(); + subst["signalName"] = signal_name.to_camel_case(); + subst["signal_name"] = signal_name.to_snake_case(); String dst_method = String(EDITOR_GET("interface/editors/default_signal_callback_name")).format(subst); @@ -1070,7 +1060,7 @@ void ConnectionsDock::update_tree() { } // "::" separators used in make_custom_tooltip for formatting. - signal_item->set_tooltip(0, String(signal_name) + "::" + signaldesc + "::" + descr); + signal_item->set_tooltip_text(0, String(signal_name) + "::" + signaldesc + "::" + descr); } // List existing connections. diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 03e636d43a..8ccfda1145 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -313,7 +313,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String } const String &description = DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description); - r_item->set_tooltip(0, description); + r_item->set_tooltip_text(0, description); if (p_type_category == TypeCategory::OTHER_TYPE && !script_type) { Ref<Texture2D> icon = EditorNode::get_editor_data().get_custom_types()[custom_type_parents[p_type]][custom_type_indices[p_type]].icon; @@ -383,7 +383,7 @@ void CreateDialog::_confirmed() { } { - Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().path_join("create_recent." + base_type), FileAccess::WRITE); if (f.is_valid()) { f->store_line(selected_item); @@ -660,7 +660,7 @@ void CreateDialog::_save_and_update_favorite_list() { TreeItem *root = favorites->create_item(); { - Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites." + base_type), FileAccess::WRITE); if (f.is_valid()) { for (int i = 0; i < favorite_list.size(); i++) { String l = favorite_list[i]; @@ -686,7 +686,7 @@ void CreateDialog::_save_and_update_favorite_list() { void CreateDialog::_load_favorites_and_history() { String dir = EditorPaths::get_singleton()->get_project_settings_dir(); - Ref<FileAccess> f = FileAccess::open(dir.plus_file("create_recent." + base_type), FileAccess::READ); + Ref<FileAccess> f = FileAccess::open(dir.path_join("create_recent." + base_type), FileAccess::READ); if (f.is_valid()) { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); @@ -698,7 +698,7 @@ void CreateDialog::_load_favorites_and_history() { } } - f = FileAccess::open(dir.plus_file("favorites." + base_type), FileAccess::READ); + f = FileAccess::open(dir.path_join("favorites." + base_type), FileAccess::READ); if (f.is_valid()) { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index dbd2c61d44..76efcd7190 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -155,7 +155,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int const SceneDebuggerTree::RemoteNode &node = p_tree->nodes[i]; TreeItem *item = create_item(parent); item->set_text(0, node.name); - item->set_tooltip(0, TTR("Type:") + " " + node.type_name); + item->set_tooltip_text(0, TTR("Type:") + " " + node.type_name); Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(node.type_name, ""); if (icon.is_valid()) { item->set_icon(0, icon); diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 55d025f675..10b50a81e4 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -61,7 +61,7 @@ void EditorPerformanceProfiler::Monitor::update_value(float p_value) { } break; } item->set_text(1, label); - item->set_tooltip(1, tooltip); + item->set_tooltip_text(1, tooltip); if (p_value > max) { max = p_value; @@ -73,7 +73,7 @@ void EditorPerformanceProfiler::Monitor::reset() { max = 0.0f; if (item) { item->set_text(1, ""); - item->set_tooltip(1, ""); + item->set_tooltip_text(1, ""); } } @@ -92,7 +92,7 @@ String EditorPerformanceProfiler::_create_label(float p_value, Performance::Moni } void EditorPerformanceProfiler::_monitor_select() { - monitor_draw->update(); + monitor_draw->queue_redraw(); } void EditorPerformanceProfiler::_monitor_draw() { @@ -283,12 +283,12 @@ void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) { float spacing = float(point_sep) / float(columns); marker_frame = (rect.size.x - point.x) / spacing; } - monitor_draw->update(); + monitor_draw->queue_redraw(); return; } } marker_key = ""; - monitor_draw->update(); + monitor_draw->queue_redraw(); } } @@ -308,7 +308,7 @@ void EditorPerformanceProfiler::reset() { _build_monitor_tree(); marker_key = ""; marker_frame = 0; - monitor_draw->update(); + monitor_draw->queue_redraw(); } void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_names) { @@ -357,7 +357,7 @@ void EditorPerformanceProfiler::add_profile_frame(const Vector<float> &p_values) E.value.update_value(data); } marker_frame++; - monitor_draw->update(); + monitor_draw->queue_redraw(); } List<float> *EditorPerformanceProfiler::get_monitor_data(const StringName &p_name) { diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index b49cab9df7..cf48366bd3 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -318,7 +318,7 @@ void EditorProfiler::_update_plot() { graph_texture->update(img); graph->set_texture(graph_texture); - graph->update(); + graph->queue_redraw(); } void EditorProfiler::_update_frame() { @@ -356,7 +356,7 @@ void EditorProfiler::_update_frame() { item->set_metadata(1, it.script); item->set_metadata(2, it.line); item->set_text_alignment(2, HORIZONTAL_ALIGNMENT_RIGHT); - item->set_tooltip(0, it.name + "\n" + it.script + ":" + itos(it.line)); + item->set_tooltip_text(0, it.name + "\n" + it.script + ":" + itos(it.line)); float time = dtime == DISPLAY_SELF_TIME ? it.self : it.total; @@ -421,7 +421,7 @@ void EditorProfiler::_graph_tex_draw() { void EditorProfiler::_graph_tex_mouse_exit() { hover_metric = -1; - graph->update(); + graph->queue_redraw(); } void EditorProfiler::_cursor_metric_changed(double) { @@ -429,7 +429,7 @@ void EditorProfiler::_cursor_metric_changed(double) { return; } - graph->update(); + graph->queue_redraw(); _update_frame(); } @@ -480,13 +480,13 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } } - graph->update(); + graph->queue_redraw(); } } void EditorProfiler::disable_seeking() { seeking = false; - graph->update(); + graph->queue_redraw(); } void EditorProfiler::_combo_changed(int) { diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 6f3dd1793c..8e7135f1c5 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -312,7 +312,7 @@ void EditorVisualProfiler::_update_plot() { graph_texture->update(img); graph->set_texture(graph_texture); - graph->update(); + graph->queue_redraw(); } void EditorVisualProfiler::_update_frame(bool p_focus_selected) { @@ -489,7 +489,7 @@ void EditorVisualProfiler::_graph_tex_draw() { void EditorVisualProfiler::_graph_tex_mouse_exit() { hover_metric = -1; - graph->update(); + graph->queue_redraw(); } void EditorVisualProfiler::_cursor_metric_changed(double) { @@ -497,7 +497,7 @@ void EditorVisualProfiler::_cursor_metric_changed(double) { return; } - graph->update(); + graph->queue_redraw(); _update_frame(); } @@ -613,7 +613,7 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } } - graph->update(); + graph->queue_redraw(); } } @@ -637,7 +637,7 @@ int EditorVisualProfiler::_get_cursor_index() const { void EditorVisualProfiler::disable_seeking() { seeking = false; - graph->update(); + graph->queue_redraw(); } void EditorVisualProfiler::_combo_changed(int) { diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index fab211f18c..5baa9970af 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -580,8 +580,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da stack_trace->set_text(1, frame_txt); } - error->set_tooltip(0, tooltip); - error->set_tooltip(1, tooltip); + error->set_tooltip_text(0, tooltip); + error->set_tooltip_text(1, tooltip); if (warning_count == 0 && error_count == 0) { expand_all_button->set_disabled(false); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 489a55ede0..ec9a744e57 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -1071,7 +1071,7 @@ Error DocTools::load_classes(const String &p_dir) { while (!path.is_empty()) { if (!da->current_is_dir() && path.ends_with("xml")) { Ref<XMLParser> parser = memnew(XMLParser); - Error err2 = parser->open(p_dir.plus_file(path)); + Error err2 = parser->open(p_dir.path_join(path)); if (err2) { return err2; } @@ -1380,7 +1380,7 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String, } Error err; - String save_file = save_path.plus_file(c.name + ".xml"); + String save_file = save_path.path_join(c.name + ".xml"); Ref<FileAccess> f = FileAccess::open(save_file, FileAccess::WRITE, &err); ERR_CONTINUE_MSG(err != OK, "Can't write doc file: " + save_file + "."); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 8dc8a0ab6b..aaa5956c17 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -215,11 +215,11 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { if (FileAccess::exists(res_path)) { num_file_conflicts += 1; ti->set_custom_color(0, tree->get_theme_color(SNAME("error_color"), SNAME("Editor"))); - ti->set_tooltip(0, vformat(TTR("%s (already exists)"), res_path)); + ti->set_tooltip_text(0, vformat(TTR("%s (already exists)"), res_path)); ti->set_checked(0, false); ti->propagate_check(0); } else { - ti->set_tooltip(0, res_path); + ti->set_tooltip_text(0, res_path); } ti->set_metadata(0, res_path); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index a95cc4981a..b1253ed7cb 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -182,7 +182,7 @@ void EditorAudioBus::_notification(int p_what) { case NOTIFICATION_DRAG_END: { if (hovering_drop) { hovering_drop = false; - update(); + queue_redraw(); } } break; } @@ -967,7 +967,7 @@ void EditorAudioBusDrop::_notification(int p_what) { case NOTIFICATION_MOUSE_ENTER: { if (!hovering_drop) { hovering_drop = true; - update(); + queue_redraw(); } } break; @@ -975,7 +975,7 @@ void EditorAudioBusDrop::_notification(int p_what) { case NOTIFICATION_DRAG_END: { if (hovering_drop) { hovering_drop = false; - update(); + queue_redraw(); } } break; } diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 120ac5b984..544b6c7141 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -164,7 +164,7 @@ void EditorAutoloadSettings::_autoload_add() { if (!fpath.ends_with("/")) { fpath = fpath.get_base_dir(); } - dialog->config("Node", fpath.plus_file(vformat("%s.gd", autoload_add_name->get_text().camelcase_to_underscore())), false, false); + dialog->config("Node", fpath.path_join(vformat("%s.gd", autoload_add_name->get_text().to_snake_case())), false, false); dialog->popup_centered(); } else { if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) { @@ -371,7 +371,7 @@ void EditorAutoloadSettings::_autoload_open(const String &fpath) { void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { // Convert the file name to PascalCase, which is the convention for classes in GDScript. - const String class_name = p_path.get_file().get_basename().capitalize().replace(" ", ""); + const String class_name = p_path.get_file().get_basename().to_pascal_case(); // If the name collides with a built-in class, prefix the name to make it possible to add without having to edit the name. // The prefix is subjective, but it provides better UX than leaving the Add button disabled :) @@ -580,7 +580,7 @@ void EditorAutoloadSettings::_script_created(Ref<Script> p_script) { FileSystemDock::get_singleton()->get_script_create_dialog()->hide(); path = p_script->get_path().get_base_dir(); autoload_add_path->set_text(p_script->get_path()); - autoload_add_name->set_text(p_script->get_path().get_file().get_basename().capitalize().replace(" ", "")); + autoload_add_name->set_text(p_script->get_path().get_file().get_basename().to_pascal_case()); _autoload_add(); } diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 4071722185..3bb050ce77 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -172,7 +172,7 @@ void EditorDirDialog::_make_dir_confirm() { mkdirerr->popup_centered(Size2(250, 80) * EDSCALE); } else { opened_paths.insert(dir); - //reload(dir.plus_file(makedirname->get_text())); + //reload(dir.path_join(makedirname->get_text())); EditorFileSystem::get_singleton()->scan_changes(); //we created a dir, so rescan changes } makedirname->set_text(""); // reset label diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index f0bf9fd5b3..708173ea26 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -315,7 +315,7 @@ void EditorFeatureProfileManager::_notification(int p_what) { current_profile = EDITOR_GET("_default_feature_profile"); if (!current_profile.is_empty()) { current.instantiate(); - Error err = current->load_from_file(EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(current_profile + ".profile")); + Error err = current->load_from_file(EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(current_profile + ".profile")); if (err != OK) { ERR_PRINT("Error loading default feature profile: " + current_profile); current_profile = String(); @@ -346,7 +346,7 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr if (p_select_profile.is_empty()) { //default, keep if (profile_list->get_selected() >= 0) { selected_profile = profile_list->get_item_metadata(profile_list->get_selected()); - if (!FileAccess::exists(EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(selected_profile + ".profile"))) { + if (!FileAccess::exists(EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(selected_profile + ".profile"))) { selected_profile = String(); //does not exist } } @@ -475,7 +475,7 @@ void EditorFeatureProfileManager::_create_new_profile() { EditorNode::get_singleton()->show_warning(TTR("Profile must be a valid filename and must not contain '.'")); return; } - String file = EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(name + ".profile"); + String file = EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(name + ".profile"); if (FileAccess::exists(file)) { EditorNode::get_singleton()->show_warning(TTR("Profile with this name already exists.")); return; @@ -630,7 +630,7 @@ void EditorFeatureProfileManager::_class_list_item_selected() { property->set_selectable(0, true); property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); property->set_text(0, text); - property->set_tooltip(0, tooltip); + property->set_tooltip_text(0, tooltip); property->set_metadata(0, name); String icon_type = Variant::get_type_name(E.type); property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); @@ -754,8 +754,8 @@ void EditorFeatureProfileManager::_update_selected_profile() { } else { //reload edited, if different from current edited.instantiate(); - Error err = edited->load_from_file(EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile")); - ERR_FAIL_COND_MSG(err != OK, "Error when loading editor feature profile from file '" + EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(profile + ".profile") + "'."); + Error err = edited->load_from_file(EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(profile + ".profile")); + ERR_FAIL_COND_MSG(err != OK, "Error when loading editor feature profile from file '" + EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(profile + ".profile") + "'."); } updating_features = true; @@ -810,7 +810,7 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths return; } - String dst_file = EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(basefile); + String dst_file = EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(basefile); if (FileAccess::exists(dst_file)) { EditorNode::get_singleton()->show_warning(vformat(TTR("Profile '%s' already exists. Remove it first before importing, import aborted."), basefile.get_basename())); @@ -825,7 +825,7 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths Error err = profile->load_from_file(p_paths[i]); ERR_CONTINUE(err != OK); String basefile = p_paths[i].get_file(); - String dst_file = EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(basefile); + String dst_file = EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(basefile); profile->save_to_file(dst_file); } @@ -849,7 +849,7 @@ void EditorFeatureProfileManager::_save_and_update() { ERR_FAIL_COND(edited_path.is_empty()); ERR_FAIL_COND(edited.is_null()); - edited->save_to_file(EditorPaths::get_singleton()->get_feature_profiles_dir().plus_file(edited_path + ".profile")); + edited->save_to_file(EditorPaths::get_singleton()->get_feature_profiles_dir().path_join(edited_path + ".profile")); if (edited == current) { update_timer->start(); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 5d249b0fab..e24aa995c8 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -251,7 +251,7 @@ void EditorFileDialog::_file_submitted(const String &p_file) { } void EditorFileDialog::_save_confirm_pressed() { - String f = dir_access->get_current_dir().plus_file(file->get_text()); + String f = dir_access->get_current_dir().path_join(file->get_text()); _save_to_recent(); hide(); emit_signal(SNAME("file_selected"), f); @@ -284,7 +284,7 @@ void EditorFileDialog::_post_popup() { } if (is_visible() && !get_current_file().is_empty()) { - _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } if (is_visible()) { @@ -381,7 +381,7 @@ void EditorFileDialog::_action_pressed() { Vector<String> files; for (int i = 0; i < item_list->get_item_count(); i++) { if (item_list->is_selected(i)) { - files.push_back(fbase.plus_file(item_list->get_item_text(i))); + files.push_back(fbase.path_join(item_list->get_item_text(i))); } } @@ -395,7 +395,7 @@ void EditorFileDialog::_action_pressed() { } String file_text = file->get_text(); - String f = file_text.is_absolute_path() ? file_text : dir_access->get_current_dir().plus_file(file_text); + String f = file_text.is_absolute_path() ? file_text : dir_access->get_current_dir().path_join(file_text); if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) { _save_to_recent(); @@ -410,7 +410,7 @@ void EditorFileDialog::_action_pressed() { if (item_list->is_selected(i)) { Dictionary d = item_list->get_item_metadata(i); if (d["dir"]) { - path = path.plus_file(d["name"]); + path = path.path_join(d["name"]); break; } @@ -461,7 +461,7 @@ void EditorFileDialog::_action_pressed() { if (!valid && filterSliceCount > 0) { String str = (flt.get_slice(",", 0).strip_edges()); f += str.substr(1, str.length() - 1); - _request_single_thumbnail(get_current_dir().plus_file(f.get_file())); + _request_single_thumbnail(get_current_dir().path_join(f.get_file())); file->set_text(f.get_file()); valid = true; } @@ -505,7 +505,7 @@ void EditorFileDialog::_item_selected(int p_item) { if (!d["dir"]) { file->set_text(d["name"]); - _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } else if (mode == FILE_MODE_OPEN_DIR) { set_ok_button_text(TTR("Select This Folder")); } @@ -523,7 +523,7 @@ void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { if (!d["dir"] && p_selected) { file->set_text(d["name"]); - _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } get_ok_button()->set_disabled(_is_open_should_be_disabled()); @@ -830,7 +830,7 @@ void EditorFileDialog::update_file_list() { Dictionary d; d["name"] = dir_name; - d["path"] = cdir.plus_file(dir_name); + d["path"] = cdir.path_join(dir_name); d["dir"] = true; item_list->set_item_metadata(-1, d); @@ -879,7 +879,7 @@ void EditorFileDialog::update_file_list() { item_list->add_item(files.front()->get()); if (get_icon_func) { - Ref<Texture2D> icon = get_icon_func(cdir.plus_file(files.front()->get())); + Ref<Texture2D> icon = get_icon_func(cdir.path_join(files.front()->get())); if (display_mode == DISPLAY_THUMBNAILS) { item_list->set_item_icon(-1, file_thumbnail); item_list->set_item_tag_icon(-1, icon); @@ -891,7 +891,7 @@ void EditorFileDialog::update_file_list() { Dictionary d; d["name"] = files.front()->get(); d["dir"] = false; - String fullpath = cdir.plus_file(files.front()->get()); + String fullpath = cdir.path_join(files.front()->get()); d["path"] = fullpath; item_list->set_item_metadata(-1, d); @@ -995,7 +995,7 @@ String EditorFileDialog::get_current_file() const { } String EditorFileDialog::get_current_path() const { - return dir_access->get_current_dir().plus_file(file->get_text()); + return dir_access->get_current_dir().path_join(file->get_text()); } void EditorFileDialog::set_current_dir(const String &p_dir) { @@ -1014,7 +1014,7 @@ void EditorFileDialog::set_current_file(const String &p_file) { _focus_file_text(); if (is_visible()) { - _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index bda2e283ef..177bc6d2b2 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -99,7 +99,7 @@ String EditorFileSystemDirectory::get_path() const { String p; const EditorFileSystemDirectory *d = this; while (d->parent) { - p = d->name.plus_file(p); + p = d->name.path_join(p); d = d->parent; } @@ -110,7 +110,7 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const { String file = get_file(p_idx); const EditorFileSystemDirectory *d = this; while (d->parent) { - file = d->name.plus_file(file); + file = d->name.path_join(file); d = d->parent; } @@ -219,7 +219,7 @@ void EditorFileSystem::_scan_filesystem() { String project = ProjectSettings::get_singleton()->get_resource_path(); - String fscache = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME); + String fscache = EditorPaths::get_singleton()->get_project_settings_dir().path_join(CACHE_FILE_NAME); { Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::READ); @@ -261,7 +261,7 @@ void EditorFileSystem::_scan_filesystem() { String file; file = name; - name = cpath.plus_file(name); + name = cpath.path_join(name); FileCache fc; fc.type = split[1]; @@ -289,7 +289,7 @@ void EditorFileSystem::_scan_filesystem() { } } - String update_cache = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4"); + String update_cache = EditorPaths::get_singleton()->get_project_settings_dir().path_join("filesystem_update4"); if (FileAccess::exists(update_cache)) { { @@ -332,7 +332,7 @@ void EditorFileSystem::_scan_filesystem() { void EditorFileSystem::_save_filesystem_cache() { group_file_cache.clear(); - String fscache = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME); + String fscache = EditorPaths::get_singleton()->get_project_settings_dir().path_join(CACHE_FILE_NAME); Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::WRITE); ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + fscache + "'. Check user write permissions."); @@ -758,7 +758,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc continue; } - if (_should_skip_directory(cd.plus_file(f))) { + if (_should_skip_directory(cd.path_join(f))) { continue; } @@ -822,7 +822,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo); fi->file = E->get(); - String path = cd.plus_file(fi->file); + String path = cd.path_join(fi->file); FileCache *fc = file_cache.getptr(path); uint64_t mt = FileAccess::get_modified_time(path); @@ -982,7 +982,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const int idx = p_dir->find_dir_index(f); if (idx == -1) { - if (_should_skip_directory(cd.plus_file(f))) { + if (_should_skip_directory(cd.path_join(f))) { continue; } @@ -991,7 +991,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const efd->parent = p_dir; efd->name = f; Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_RESOURCES); - d->change_dir(cd.plus_file(f)); + d->change_dir(cd.path_join(f)); _scan_new_dir(efd, d, p_progress.get_sub(1, 1)); ItemAction ia; @@ -1017,7 +1017,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo); fi->file = f; - String path = cd.plus_file(fi->file); + String path = cd.path_join(fi->file); fi->modified_time = FileAccess::get_modified_time(path); fi->import_modified_time = 0; fi->type = ResourceLoader::get_resource_type(path); @@ -1066,7 +1066,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const continue; } - String path = cd.plus_file(p_dir->files[i]->file); + String path = cd.path_join(p_dir->files[i]->file); if (import_extensions.has(p_dir->files[i]->file.get_extension().to_lower())) { //check here if file must be imported or not @@ -1452,7 +1452,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p void EditorFileSystem::_save_late_updated_files() { //files that already existed, and were modified, need re-scanning for dependencies upon project restart. This is done via saving this special file - String fscache = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4"); + String fscache = EditorPaths::get_singleton()->get_project_settings_dir().path_join("filesystem_update4"); Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::WRITE); ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + fscache + "'. Check user write permissions."); for (const String &E : late_update_files) { @@ -2198,12 +2198,12 @@ bool EditorFileSystem::_should_skip_directory(const String &p_path) { return true; } - if (FileAccess::exists(p_path.plus_file("project.godot"))) { + if (FileAccess::exists(p_path.path_join("project.godot"))) { // skip if another project inside this return true; } - if (FileAccess::exists(p_path.plus_file(".gdignore"))) { + if (FileAccess::exists(p_path.path_join(".gdignore"))) { // skip if a `.gdignore` file is inside this return true; } diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index c1d6e505db..d455e0248e 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -56,7 +56,7 @@ void EditorFolding::save_resource_folding(const Ref<Resource> &p_resource, const config->set_value("folding", "sections_unfolded", unfolds); String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); config->save(file); } @@ -74,7 +74,7 @@ void EditorFolding::load_resource_folding(Ref<Resource> p_resource, const String config.instantiate(); String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); if (config->load(file) != OK) { return; @@ -150,7 +150,7 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path config->set_value("folding", "nodes_folded", nodes_folded); String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); config->save(file); } @@ -160,7 +160,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) { String path = EditorPaths::get_singleton()->get_project_settings_dir(); String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); if (config->load(file) != OK) { return; @@ -214,7 +214,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) { bool EditorFolding::has_folding_data(const String &p_path) { String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; - file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(file); + file = EditorPaths::get_singleton()->get_project_settings_dir().path_join(file); return FileAccess::exists(file); } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index fe03166a01..97f5363bb8 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1929,7 +1929,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } String image = bbcode.substr(brk_end + 1, end - brk_end - 1); - Ref<Texture2D> texture = ResourceLoader::load(base_path.plus_file(image), "Texture2D"); + Ref<Texture2D> texture = ResourceLoader::load(base_path.path_join(image), "Texture2D"); if (texture.is_valid()) { p_rt->add_image(texture); } @@ -1946,7 +1946,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } else if (tag.begins_with("font=")) { String fnt = tag.substr(5, tag.length()); - Ref<Font> font = ResourceLoader::load(base_path.plus_file(fnt), "Font"); + Ref<Font> font = ResourceLoader::load(base_path.path_join(fnt), "Font"); if (font.is_valid()) { p_rt->push_font(font); } else { diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index b4678d8363..2e35f21e47 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -562,8 +562,8 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const item->set_icon(0, icon); item->set_text(0, p_doc->name); item->set_text(1, TTR("Class")); - item->set_tooltip(0, tooltip); - item->set_tooltip(1, tooltip); + item->set_tooltip_text(0, tooltip); + item->set_tooltip_text(1, tooltip); item->set_metadata(0, "class_name:" + p_doc->name); if (p_gray) { item->set_custom_color(0, disabled_color); @@ -639,8 +639,8 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons item->set_icon(0, icon); item->set_text(0, text); item->set_text(1, TTRGET(p_type)); - item->set_tooltip(0, p_tooltip); - item->set_tooltip(1, p_tooltip); + item->set_tooltip_text(0, p_tooltip); + item->set_tooltip_text(1, p_tooltip); item->set_metadata(0, "class_" + p_metatype + ":" + p_class_name + ":" + p_name); _match_item(item, p_name); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 8716196658..6aa0bd3f99 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -231,7 +231,7 @@ void EditorProperty::_notification(int p_what) { bottom_child_rect = bottom_rect; } - update(); //need to redraw text + queue_redraw(); //need to redraw text } break; case NOTIFICATION_DRAW: { @@ -398,7 +398,7 @@ void EditorProperty::_notification(int p_what) { void EditorProperty::set_label(const String &p_label) { label = p_label; - update(); + queue_redraw(); } String EditorProperty::get_label() const { @@ -478,7 +478,7 @@ void EditorProperty::update_revert_and_pin_status() { } can_revert = new_can_revert; pinned = new_pinned; - update(); + queue_redraw(); } } @@ -499,7 +499,7 @@ bool EditorProperty::use_keying_next() const { void EditorProperty::set_checkable(bool p_checkable) { checkable = p_checkable; - update(); + queue_redraw(); queue_sort(); } @@ -509,7 +509,7 @@ bool EditorProperty::is_checkable() const { void EditorProperty::set_checked(bool p_checked) { checked = p_checked; - update(); + queue_redraw(); } bool EditorProperty::is_checked() const { @@ -518,18 +518,18 @@ bool EditorProperty::is_checked() const { void EditorProperty::set_draw_warning(bool p_draw_warning) { draw_warning = p_draw_warning; - update(); + queue_redraw(); } void EditorProperty::set_keying(bool p_keying) { keying = p_keying; - update(); + queue_redraw(); queue_sort(); } void EditorProperty::set_deletable(bool p_deletable) { deletable = p_deletable; - update(); + queue_redraw(); queue_sort(); } @@ -552,7 +552,7 @@ void EditorProperty::_focusable_focused(int p_index) { bool already_selected = selected; selected = true; selected_focusable = p_index; - update(); + queue_redraw(); if (!already_selected && selected) { emit_signal(SNAME("selected"), property, selected_focusable); } @@ -571,7 +571,7 @@ void EditorProperty::select(int p_focusable) { focusables[p_focusable]->grab_focus(); } else { selected = true; - update(); + queue_redraw(); } if (!already_selected && selected) { @@ -582,7 +582,7 @@ void EditorProperty::select(int p_focusable) { void EditorProperty::deselect() { selected = false; selected_focusable = -1; - update(); + queue_redraw(); } bool EditorProperty::is_selected() const { @@ -608,25 +608,25 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { bool new_keying_hover = keying_rect.has_point(mpos) && !button_left; if (new_keying_hover != keying_hover) { keying_hover = new_keying_hover; - update(); + queue_redraw(); } bool new_delete_hover = delete_rect.has_point(mpos) && !button_left; if (new_delete_hover != delete_hover) { delete_hover = new_delete_hover; - update(); + queue_redraw(); } bool new_revert_hover = revert_rect.has_point(mpos) && !button_left; if (new_revert_hover != revert_hover) { revert_hover = new_revert_hover; - update(); + queue_redraw(); } bool new_check_hover = check_rect.has_point(mpos) && !button_left; if (new_check_hover != check_hover) { check_hover = new_check_hover; - update(); + queue_redraw(); } } @@ -641,7 +641,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { if (!selected && selectable) { selected = true; emit_signal(SNAME("selected"), property, -1); - update(); + queue_redraw(); } if (keying_rect.has_point(mpos)) { @@ -681,7 +681,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { if (check_rect.has_point(mpos)) { checked = !checked; - update(); + queue_redraw(); emit_signal(SNAME("property_checked"), property, checked); } } else if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) { @@ -912,7 +912,7 @@ void EditorProperty::menu_option(int p_option) { } break; case MENU_PIN_VALUE: { emit_signal(SNAME("property_pinned"), property, !pinned); - update(); + queue_redraw(); } break; case MENU_OPEN_DOCUMENTATION: { ScriptEditor::get_singleton()->goto_help(doc_path); @@ -961,7 +961,7 @@ void EditorProperty::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keying"), "set_keying", "is_keying"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deletable"), "set_deletable", "is_deletable"); - ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); + ADD_SIGNAL(MethodInfo("property_changed", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), PropertyInfo(Variant::STRING_NAME, "field"), PropertyInfo(Variant::BOOL, "changing"))); ADD_SIGNAL(MethodInfo("multiple_properties_changed", PropertyInfo(Variant::PACKED_STRING_ARRAY, "properties"), PropertyInfo(Variant::ARRAY, "value"))); ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING_NAME, "property"))); ADD_SIGNAL(MethodInfo("property_deleted", PropertyInfo(Variant::STRING_NAME, "property"))); @@ -1372,26 +1372,26 @@ void EditorInspectorSection::_notification(int p_what) { } dropping = children_can_drop; - update(); + queue_redraw(); } break; case NOTIFICATION_DRAG_END: { dropping = false; - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_ENTER: { if (dropping) { dropping_unfold_timer->start(); } - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { if (dropping) { dropping_unfold_timer->stop(); } - update(); + queue_redraw(); } break; } } @@ -1477,7 +1477,7 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) { fold(); } } else if (mb.is_valid() && !mb->is_pressed()) { - update(); + queue_redraw(); } } @@ -1494,7 +1494,7 @@ void EditorInspectorSection::unfold() { object->editor_set_section_unfold(section, true); vbox->show(); - update(); + queue_redraw(); } void EditorInspectorSection::fold() { @@ -1508,7 +1508,7 @@ void EditorInspectorSection::fold() { object->editor_set_section_unfold(section, false); vbox->hide(); - update(); + queue_redraw(); } bool EditorInspectorSection::has_revertable_properties() const { @@ -1523,7 +1523,7 @@ void EditorInspectorSection::property_can_revert_changed(const String &p_path, b revertable_properties.erase(p_path); } if (has_revertable_properties() != had_revertable_properties) { - update(); + queue_redraw(); } } @@ -2052,8 +2052,8 @@ void EditorInspectorArray::_setup() { ae.panel->set_drag_forwarding(this); ae.panel->set_meta("index", begin_array_index + i); ae.panel->set_tooltip_text(vformat(TTR("Element %d: %s%d*"), i, array_element_prefix, i)); - ae.panel->connect("focus_entered", callable_mp((CanvasItem *)ae.panel, &PanelContainer::update)); - ae.panel->connect("focus_exited", callable_mp((CanvasItem *)ae.panel, &PanelContainer::update)); + ae.panel->connect("focus_entered", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw)); + ae.panel->connect("focus_exited", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw)); ae.panel->connect("draw", callable_mp(this, &EditorInspectorArray::_panel_draw).bind(i)); ae.panel->connect("gui_input", callable_mp(this, &EditorInspectorArray::_panel_gui_input).bind(i)); ae.panel->add_theme_style_override(SNAME("panel"), i % 2 ? odd_style : even_style); @@ -2155,7 +2155,7 @@ bool EditorInspectorArray::can_drop_data_fw(const Point2 &p_point, const Variant return false; } // First, update drawing. - control_dropping->update(); + control_dropping->queue_redraw(); if (p_data.get_type() != Variant::DICTIONARY) { return false; @@ -2206,14 +2206,14 @@ void EditorInspectorArray::_notification(int p_what) { Dictionary dict = get_viewport()->gui_get_drag_data(); if (dict.has("type") && dict["type"] == "property_array_element" && String(dict["property_array_prefix"]) == array_element_prefix) { dropping = true; - control_dropping->update(); + control_dropping->queue_redraw(); } } break; case NOTIFICATION_DRAG_END: { if (dropping) { dropping = false; - control_dropping->update(); + control_dropping->queue_redraw(); } } break; } diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 86b0145240..a3d4296edb 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -131,7 +131,7 @@ void EditorLog::_save_state() { Ref<ConfigFile> config; config.instantiate(); // Load and amend existing config if it exists. - config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); const String section = "editor_log"; for (const KeyValue<MessageType, LogFilter *> &E : type_filter_map) { @@ -141,7 +141,7 @@ void EditorLog::_save_state() { config->set_value(section, "collapse", collapse); config->set_value(section, "show_search", search_box->is_visible()); - config->save(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); } void EditorLog::_load_state() { @@ -149,7 +149,7 @@ void EditorLog::_load_state() { Ref<ConfigFile> config; config.instantiate(); - config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); // Run the below code even if config->load returns an error, since we want the defaults to be set even if the file does not exist yet. const String section = "editor_log"; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 03422ef862..0f2e0c8fcb 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -544,6 +544,9 @@ void EditorNode::_update_from_settings() { Viewport::SDFScale sdf_scale = Viewport::SDFScale(int(GLOBAL_GET("rendering/2d/sdf/scale"))); scene_root->set_sdf_scale(sdf_scale); + Viewport::MSAA msaa = Viewport::MSAA(int(GLOBAL_GET("rendering/anti_aliasing/quality/msaa_2d"))); + scene_root->set_msaa_2d(msaa); + float mesh_lod_threshold = GLOBAL_GET("rendering/mesh_lod/lod_change/threshold_pixels"); scene_root->set_mesh_lod_threshold(mesh_lod_threshold); @@ -1098,7 +1101,7 @@ void EditorNode::_scan_external_changes() { } } - String project_settings_path = ProjectSettings::get_singleton()->get_resource_path().plus_file("project.godot"); + String project_settings_path = ProjectSettings::get_singleton()->get_resource_path().path_join("project.godot"); if (FileAccess::get_modified_time(project_settings_path) > ProjectSettings::get_singleton()->get_last_saved_time()) { TreeItem *ti = disk_changed_list->create_item(r); ti->set_text(0, "project.godot"); @@ -1316,7 +1319,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->set_current_file(p_resource->get_path().get_file()); } else { if (extensions.size()) { - String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore(); + String resource_name_snake_case = p_resource->get_class().to_snake_case(); file->set_current_file("new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower()); } else { file->set_current_file(String()); @@ -1333,7 +1336,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String } else if (preferred.size()) { String existing; if (extensions.size()) { - String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore(); + String resource_name_snake_case = p_resource->get_class().to_snake_case(); existing = "new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower(); } file->set_current_path(existing); @@ -1395,7 +1398,7 @@ void EditorNode::_get_scene_metadata(const String &p_file) { return; } - String path = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); + String path = EditorPaths::get_singleton()->get_project_settings_dir().path_join(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; cf.instantiate(); @@ -1427,7 +1430,7 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { return; } - String path = EditorPaths::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); + String path = EditorPaths::get_singleton()->get_project_settings_dir().path_join(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; cf.instantiate(); @@ -1623,7 +1626,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { // Save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5. String temp_path = EditorPaths::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_file).md5_text(); - cache_base = temp_path.plus_file("resthumb-" + cache_base); + cache_base = temp_path.path_join("resthumb-" + cache_base); // Does not have it, try to load a cached thumbnail. String file = cache_base + ".png"; @@ -2732,10 +2735,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { // Use casing of the root node. break; case SCENE_NAME_CASING_PASCAL_CASE: { - root_name = root_name.capitalize().replace(" ", ""); + root_name = root_name.to_pascal_case(); } break; case SCENE_NAME_CASING_SNAKE_CASE: - root_name = root_name.capitalize().replace(" ", "").replace("-", "_").camelcase_to_underscore(); + root_name = root_name.replace("-", "_").to_snake_case(); break; } file->set_current_path(root_name + "." + extensions.front()->get().to_lower()); @@ -2910,7 +2913,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { OS::get_singleton()->shell_open(String("file://") + OS::get_singleton()->get_user_data_dir()); } break; case FILE_EXPLORE_ANDROID_BUILD_TEMPLATES: { - OS::get_singleton()->shell_open("file://" + ProjectSettings::get_singleton()->get_resource_path().plus_file("android")); + OS::get_singleton()->shell_open("file://" + ProjectSettings::get_singleton()->get_resource_path().path_join("android")); } break; case FILE_QUIT: case RUN_PROJECT_MANAGER: @@ -3447,7 +3450,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, // 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().plus_file(script_path); + script_path = addon_path.get_base_dir().path_join(script_path); script = ResourceLoader::load(script_path); if (script.is_null()) { @@ -4565,7 +4568,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { } if (nrect != dock_select_rect_over_idx) { - dock_select->update(); + dock_select->queue_redraw(); dock_select_rect_over_idx = nrect; } @@ -4591,7 +4594,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { dock_popup_selected_idx = nrect; dock_slot[nrect]->set_current_tab(dock_slot[nrect]->get_tab_count() - 1); dock_slot[nrect]->show(); - dock_select->update(); + dock_select->queue_redraw(); _update_dock_containers(); @@ -4603,7 +4606,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { void EditorNode::_dock_popup_exit() { dock_select_rect_over_idx = -1; - dock_select->update(); + dock_select->queue_redraw(); } void EditorNode::_dock_pre_popup(int p_which) { @@ -4621,7 +4624,7 @@ void EditorNode::_dock_move_left() { } dock_slot[dock_popup_selected_idx]->move_child(current, prev->get_index()); dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1); - dock_select->update(); + dock_select->queue_redraw(); _edit_current(); _save_docks(); } @@ -4634,7 +4637,7 @@ void EditorNode::_dock_move_right() { } dock_slot[dock_popup_selected_idx]->move_child(next, current->get_index()); dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1); - dock_select->update(); + dock_select->queue_redraw(); _edit_current(); _save_docks(); } @@ -4732,13 +4735,13 @@ void EditorNode::_save_docks() { Ref<ConfigFile> config; config.instantiate(); // Load and amend existing config if it exists. - config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); _save_docks_to_config(config, "docks"); _save_open_scenes_to_config(config, "EditorNode"); editor_data.get_plugin_window_layout(config); - config->save(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + config->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); } void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) { @@ -4802,7 +4805,7 @@ void EditorNode::_dock_split_dragged(int ofs) { void EditorNode::_load_docks() { Ref<ConfigFile> config; config.instantiate(); - Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); if (err != OK) { // No config. if (overridden_default_layout >= 0) { @@ -5035,7 +5038,7 @@ bool EditorNode::has_scenes_in_session() { } Ref<ConfigFile> config; config.instantiate(); - Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + Error err = config->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("editor_layout.cfg")); if (err != OK) { return false; } @@ -5687,7 +5690,7 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str for (int i = 0; i < p_files.size(); i++) { String from = p_files[i]; - String to = to_path.plus_file(from.get_file()); + String to = to_path.path_join(from.get_file()); if (dir->dir_exists(from)) { Vector<String> sub_files; @@ -5702,7 +5705,7 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str continue; } - sub_files.push_back(from.plus_file(next_file)); + sub_files.push_back(from.path_join(next_file)); next_file = sub_dir->get_next(); } diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp index b6364e1ab7..54d4660cb6 100644 --- a/editor/editor_paths.cpp +++ b/editor/editor_paths.cpp @@ -67,19 +67,19 @@ String EditorPaths::get_self_contained_file() const { } String EditorPaths::get_export_templates_dir() const { - return get_data_dir().plus_file(export_templates_folder); + return get_data_dir().path_join(export_templates_folder); } String EditorPaths::get_project_settings_dir() const { - return get_project_data_dir().plus_file("editor"); + return get_project_data_dir().path_join("editor"); } String EditorPaths::get_text_editor_themes_dir() const { - return get_config_dir().plus_file(text_editor_themes_folder); + return get_config_dir().path_join(text_editor_themes_folder); } String EditorPaths::get_script_templates_dir() const { - return get_config_dir().plus_file(script_templates_folder); + return get_config_dir().path_join(script_templates_folder); } String EditorPaths::get_project_script_templates_dir() const { @@ -87,7 +87,7 @@ String EditorPaths::get_project_script_templates_dir() const { } String EditorPaths::get_feature_profiles_dir() const { - return get_config_dir().plus_file(feature_profiles_folder); + return get_config_dir().path_join(feature_profiles_folder); } void EditorPaths::create() { @@ -119,8 +119,8 @@ EditorPaths::EditorPaths() { String exe_path = OS::get_singleton()->get_executable_path().get_base_dir(); // On macOS, look outside .app bundle, since .app bundle is read-only. - if (OS::get_singleton()->has_feature("macos") && exe_path.ends_with("MacOS") && exe_path.plus_file("..").simplify_path().ends_with("Contents")) { - exe_path = exe_path.plus_file("../../..").simplify_path(); + if (OS::get_singleton()->has_feature("macos") && exe_path.ends_with("MacOS") && exe_path.path_join("..").simplify_path().ends_with("Contents")) { + exe_path = exe_path.path_join("../../..").simplify_path(); } { Ref<DirAccess> d = DirAccess::create_for_path(exe_path); @@ -141,24 +141,24 @@ EditorPaths::EditorPaths() { if (self_contained) { // editor is self contained, all in same folder data_path = exe_path; - data_dir = data_path.plus_file("editor_data"); + data_dir = data_path.path_join("editor_data"); config_path = exe_path; config_dir = data_dir; cache_path = exe_path; - cache_dir = data_dir.plus_file("cache"); + cache_dir = data_dir.path_join("cache"); } else { // Typically XDG_DATA_HOME or %APPDATA%. data_path = OS::get_singleton()->get_data_path(); - data_dir = data_path.plus_file(OS::get_singleton()->get_godot_dir_name()); + data_dir = data_path.path_join(OS::get_singleton()->get_godot_dir_name()); // Can be different from data_path e.g. on Linux or macOS. config_path = OS::get_singleton()->get_config_path(); - config_dir = config_path.plus_file(OS::get_singleton()->get_godot_dir_name()); + config_dir = config_path.path_join(OS::get_singleton()->get_godot_dir_name()); // Can be different from above paths, otherwise a subfolder of data_dir. cache_path = OS::get_singleton()->get_cache_path(); if (cache_path == data_path) { - cache_dir = data_dir.plus_file("cache"); + cache_dir = data_dir.path_join("cache"); } else { - cache_dir = cache_path.plus_file(OS::get_singleton()->get_godot_dir_name()); + cache_dir = cache_path.path_join(OS::get_singleton()->get_godot_dir_name()); } } @@ -232,7 +232,7 @@ EditorPaths::EditorPaths() { } // Check that the project data directory '.gdignore' file exists - String project_data_gdignore_file_path = project_data_dir.plus_file(".gdignore"); + String project_data_gdignore_file_path = project_data_dir.path_join(".gdignore"); if (!FileAccess::exists(project_data_gdignore_file_path)) { // Add an empty .gdignore file to avoid scan. Ref<FileAccess> f = FileAccess::open(project_data_gdignore_file_path, FileAccess::WRITE); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index b0bd500ef8..4fc6947636 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -599,7 +599,7 @@ int EditorPlugin::update_overlays() const { return count; } else { // This will update the normal viewport itself as well - CanvasItemEditor::get_singleton()->get_viewport_control()->update(); + CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw(); return 1; } } diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 5a010a66c1..a8df486381 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -102,7 +102,7 @@ void EditorPluginSettings::update_plugins() { TreeItem *item = plugin_list->create_item(root); item->set_text(0, name); - item->set_tooltip(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:") + " " + script + "\n" + TTR("Description:") + " " + description); item->set_metadata(0, path); item->set_text(1, version); item->set_metadata(1, script); @@ -178,8 +178,8 @@ Vector<String> EditorPluginSettings::_get_plugins(const String &p_dir) { continue; } - const String full_path = p_dir.plus_file(path); - const String plugin_config = full_path.plus_file("plugin.cfg"); + const String full_path = p_dir.path_join(path); + const String plugin_config = full_path.path_join("plugin.cfg"); if (FileAccess::exists(plugin_config)) { plugins.push_back(plugin_config); } else { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 0e69c0e2f4..b7910a152e 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -951,7 +951,7 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) { bool expand_was_hovered = expand_hovered; expand_hovered = expand_rect.has_point(mm->get_position()); if (expand_hovered != expand_was_hovered) { - update(); + queue_redraw(); } if (!expand_hovered) { @@ -959,7 +959,7 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) { if (flag_rects[i].has_point(mm->get_position())) { // Used to highlight the hovered flag in the layers grid. hovered_index = i; - update(); + queue_redraw(); return; } } @@ -968,7 +968,7 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) { // Remove highlight when no square is hovered. if (hovered_index != -1) { hovered_index = -1; - update(); + queue_redraw(); } return; @@ -986,11 +986,11 @@ void EditorPropertyLayersGrid::gui_input(const Ref<InputEvent> &p_ev) { } emit_signal(SNAME("flag_changed"), value); - update(); + queue_redraw(); } else if (expand_hovered) { expanded = !expanded; update_minimum_size(); - update(); + queue_redraw(); } } if (mb.is_valid() && mb->get_button_index() == MouseButton::RIGHT && mb->is_pressed()) { @@ -1131,11 +1131,11 @@ void EditorPropertyLayersGrid::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { if (expand_hovered) { expand_hovered = false; - update(); + queue_redraw(); } if (hovered_index != -1) { hovered_index = -1; - update(); + queue_redraw(); } } break; } @@ -1143,7 +1143,7 @@ void EditorPropertyLayersGrid::_notification(int p_what) { void EditorPropertyLayersGrid::set_flag(uint32_t p_flag) { value = p_flag; - update(); + queue_redraw(); } void EditorPropertyLayersGrid::_bind_methods() { @@ -1276,7 +1276,7 @@ void EditorPropertyLayers::_menu_pressed(int p_menu) { } else { grid->value |= (1 << p_menu); } - grid->update(); + grid->queue_redraw(); layers->set_item_checked(layers->get_item_index(p_menu), grid->value & (1 << p_menu)); _grid_changed(grid->value); } @@ -1523,13 +1523,13 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { // Ensure the easing doesn't appear as being dragged dragging = false; - easing_draw->update(); + easing_draw->queue_redraw(); } if (mb->get_button_index() == MouseButton::LEFT) { dragging = mb->is_pressed(); // Update to display the correct dragging color - easing_draw->update(); + easing_draw->queue_redraw(); } } @@ -1569,7 +1569,7 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { val = CLAMP(val, -1'000'000, 1'000'000); emit_changed(get_edited_property(), val); - easing_draw->update(); + easing_draw->queue_redraw(); } } @@ -1621,14 +1621,14 @@ void EditorPropertyEasing::_draw_easing() { } void EditorPropertyEasing::update_property() { - easing_draw->update(); + easing_draw->queue_redraw(); } void EditorPropertyEasing::_set_preset(int p_preset) { static const float preset_value[EASING_MAX] = { 0.0, 1.0, 2.0, 0.5, -2.0, -0.5 }; emit_changed(get_edited_property(), preset_value[p_preset]); - easing_draw->update(); + easing_draw->queue_redraw(); } void EditorPropertyEasing::_setup_spin() { @@ -1667,7 +1667,7 @@ void EditorPropertyEasing::_spin_focus_exited() { spin->hide(); // Ensure the easing doesn't appear as being dragged dragging = false; - easing_draw->update(); + easing_draw->queue_redraw(); } void EditorPropertyEasing::setup(bool p_positive_only, bool p_flip) { @@ -3952,7 +3952,7 @@ void EditorPropertyResource::_update_property_bg() { } updating_theme = false; - update(); + queue_redraw(); } void EditorPropertyResource::_update_preferred_shader() { diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index f6953e8866..ad84b30689 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -509,7 +509,7 @@ void EditorPropertyArray::_notification(int p_what) { if (is_visible_in_tree()) { if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { dropping = true; - edit->update(); + edit->queue_redraw(); } } } break; @@ -517,7 +517,7 @@ void EditorPropertyArray::_notification(int p_what) { case NOTIFICATION_DRAG_END: { if (dropping) { dropping = false; - edit->update(); + edit->queue_redraw(); } } break; } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index ce05026696..22e7b01418 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -775,14 +775,14 @@ void EditorResourcePicker::_notification(int p_what) { case NOTIFICATION_DRAG_BEGIN: { if (editable && _is_drop_valid(get_viewport()->gui_get_drag_data())) { dropping = true; - assign_button->update(); + assign_button->queue_redraw(); } } break; case NOTIFICATION_DRAG_END: { if (dropping) { dropping = false; - assign_button->update(); + assign_button->queue_redraw(); } } break; } @@ -1049,7 +1049,7 @@ void EditorAudioStreamPicker::_notification(int p_what) { Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(audio_stream); if (preview.is_valid()) { if (preview->get_version() != last_preview_version) { - stream_preview_rect->update(); + stream_preview_rect->queue_redraw(); last_preview_version = preview->get_version(); } } @@ -1083,10 +1083,10 @@ void EditorAudioStreamPicker::_notification(int p_what) { } } - stream_preview_rect->update(); + stream_preview_rect->queue_redraw(); } else { if (tagged_frame_offset_count != 0) { - stream_preview_rect->update(); + stream_preview_rect->queue_redraw(); } tagged_frame_offset_count = 0; } @@ -1107,7 +1107,7 @@ void EditorAudioStreamPicker::_update_resource() { set_assign_button_min_size(Size2(1, font->get_height(font_size) * 1.5)); } - stream_preview_rect->update(); + stream_preview_rect->queue_redraw(); } void EditorAudioStreamPicker::_preview_draw() { diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index c0ea2b743e..706b77c142 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -244,7 +244,7 @@ void EditorResourcePreview::_iterate() { } else { String temp_path = EditorPaths::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(item.path).md5_text(); - cache_base = temp_path.plus_file("resthumb-" + cache_base); + cache_base = temp_path.path_join("resthumb-" + cache_base); //does not have it, try to load a cached thumbnail diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 1faefb5af7..94ee741db5 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -283,7 +283,7 @@ void SectionedInspector::update_category_list() { const String tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(sectionarr[i], tooltip_style); ms->set_text(0, text); - ms->set_tooltip(0, tooltip); + ms->set_tooltip_text(0, tooltip); ms->set_metadata(0, metasection); ms->set_selectable(0, false); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index f5d3b4842d..edd44b0a3a 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -856,7 +856,7 @@ void EditorSettings::create() { // Validate editor config file. Ref<DirAccess> dir = DirAccess::open(EditorPaths::get_singleton()->get_config_dir()); String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres"; - config_file_path = EditorPaths::get_singleton()->get_config_dir().plus_file(config_file_name); + config_file_path = EditorPaths::get_singleton()->get_config_dir().path_join(config_file_name); if (!dir->file_exists(config_file_name)) { goto fail; } @@ -887,7 +887,7 @@ fail: if (extra_config->has_section("init_projects")) { Vector<String> list = extra_config->get_value("init_projects", "list"); for (int i = 0; i < list.size(); i++) { - list.write[i] = exe_path.plus_file(list[i]); + list.write[i] = exe_path.path_join(list[i]); } extra_config->set_value("init_projects", "list", list); } @@ -1106,7 +1106,7 @@ void EditorSettings::add_property_hint(const PropertyInfo &p_hint) { void EditorSettings::set_project_metadata(const String &p_section, const String &p_key, Variant p_data) { Ref<ConfigFile> cf = memnew(ConfigFile); - String path = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("project_metadata.cfg"); + String path = EditorPaths::get_singleton()->get_project_settings_dir().path_join("project_metadata.cfg"); Error err; err = cf->load(path); ERR_FAIL_COND_MSG(err != OK && err != ERR_FILE_NOT_FOUND, "Cannot load editor settings from file '" + path + "'."); @@ -1117,7 +1117,7 @@ void EditorSettings::set_project_metadata(const String &p_section, const String Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, Variant p_default) const { Ref<ConfigFile> cf = memnew(ConfigFile); - String path = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("project_metadata.cfg"); + String path = EditorPaths::get_singleton()->get_project_settings_dir().path_join("project_metadata.cfg"); Error err = cf->load(path); if (err != OK) { return p_default; @@ -1129,9 +1129,9 @@ void EditorSettings::set_favorites(const Vector<String> &p_favorites) { favorites = p_favorites; String favorites_file; if (Engine::get_singleton()->is_project_manager_hint()) { - favorites_file = EditorPaths::get_singleton()->get_config_dir().plus_file("favorite_dirs"); + favorites_file = EditorPaths::get_singleton()->get_config_dir().path_join("favorite_dirs"); } else { - favorites_file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("favorites"); + favorites_file = EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites"); } Ref<FileAccess> f = FileAccess::open(favorites_file, FileAccess::WRITE); if (f.is_valid()) { @@ -1149,9 +1149,9 @@ void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) { recent_dirs = p_recent_dirs; String recent_dirs_file; if (Engine::get_singleton()->is_project_manager_hint()) { - recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().plus_file("recent_dirs"); + recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().path_join("recent_dirs"); } else { - recent_dirs_file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("recent_dirs"); + recent_dirs_file = EditorPaths::get_singleton()->get_project_settings_dir().path_join("recent_dirs"); } Ref<FileAccess> f = FileAccess::open(recent_dirs_file, FileAccess::WRITE); if (f.is_valid()) { @@ -1169,11 +1169,11 @@ void EditorSettings::load_favorites_and_recent_dirs() { String favorites_file; String recent_dirs_file; if (Engine::get_singleton()->is_project_manager_hint()) { - favorites_file = EditorPaths::get_singleton()->get_config_dir().plus_file("favorite_dirs"); - recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().plus_file("recent_dirs"); + favorites_file = EditorPaths::get_singleton()->get_config_dir().path_join("favorite_dirs"); + recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().path_join("recent_dirs"); } else { - favorites_file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("favorites"); - recent_dirs_file = EditorPaths::get_singleton()->get_project_settings_dir().plus_file("recent_dirs"); + favorites_file = EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites"); + recent_dirs_file = EditorPaths::get_singleton()->get_project_settings_dir().path_join("recent_dirs"); } Ref<FileAccess> f = FileAccess::open(favorites_file, FileAccess::READ); if (f.is_valid()) { @@ -1236,7 +1236,7 @@ void EditorSettings::load_text_editor_theme() { return; // sorry for "Settings changed" console spam } - String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().plus_file(p_file + ".tet"); + String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(p_file + ".tet"); Ref<ConfigFile> cf = memnew(ConfigFile); Error err = cf->load(theme_path); @@ -1273,7 +1273,7 @@ bool EditorSettings::import_text_editor_theme(String p_file) { Ref<DirAccess> d = DirAccess::open(EditorPaths::get_singleton()->get_text_editor_themes_dir()); if (d.is_valid()) { - d->copy(p_file, EditorPaths::get_singleton()->get_text_editor_themes_dir().plus_file(p_file.get_file())); + d->copy(p_file, EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(p_file.get_file())); return true; } } @@ -1286,7 +1286,7 @@ bool EditorSettings::save_text_editor_theme() { if (_is_default_text_editor_theme(p_file.get_file().to_lower())) { return false; } - String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().plus_file(p_file + ".tet"); + String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(p_file + ".tet"); return _save_text_editor_theme(theme_path); } @@ -1339,7 +1339,7 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c } String EditorSettings::get_editor_layouts_config() const { - return EditorPaths::get_singleton()->get_config_dir().plus_file("editor_layouts.cfg"); + return EditorPaths::get_singleton()->get_config_dir().path_join("editor_layouts.cfg"); } float EditorSettings::get_auto_display_scale() const { diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 67c602ad2d..d190ab57c3 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -440,7 +440,7 @@ void EditorSettingsDialog::_update_shortcuts() { const String tooltip = EditorPropertyNameProcessor::get_singleton()->process_name(section_name, tooltip_style); section->set_text(0, item_name); - section->set_tooltip(0, tooltip); + section->set_tooltip_text(0, tooltip); section->set_selectable(0, false); section->set_selectable(1, false); section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index b9a3e9decf..73c365ce4a 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -82,7 +82,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) { if (grabbing_spinner) { Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); Input::get_singleton()->warp_mouse(grabbing_spinner_mouse_pos); - update(); + queue_redraw(); } else { _focus_entered(); } @@ -93,7 +93,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) { } } else if (mb->get_button_index() == MouseButton::WHEEL_UP || mb->get_button_index() == MouseButton::WHEEL_DOWN) { if (grabber->is_visible()) { - call_deferred(SNAME("update")); + call_deferred(SNAME("queue_redraw")); } } } @@ -137,7 +137,7 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) { bool new_hover = (mm->get_position().x > updown_offset); if (new_hover != hover_updown) { hover_updown = new_hover; - update(); + queue_redraw(); } } } @@ -190,7 +190,7 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(Math::is_zero_approx(scale_x)); float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range) / scale_x; set_as_ratio(grabbing_ratio + grabbing_ofs); - update(); + queue_redraw(); } } @@ -463,12 +463,12 @@ void EditorSpinSlider::_notification(int p_what) { case NOTIFICATION_MOUSE_ENTER: { mouse_over_spin = true; - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { mouse_over_spin = false; - update(); + queue_redraw(); } break; case NOTIFICATION_FOCUS_ENTER: { @@ -498,7 +498,7 @@ Size2 EditorSpinSlider::get_minimum_size() const { void EditorSpinSlider::set_hide_slider(bool p_hide) { hide_slider = p_hide; - update(); + queue_redraw(); } bool EditorSpinSlider::is_hiding_slider() const { @@ -507,7 +507,7 @@ bool EditorSpinSlider::is_hiding_slider() const { void EditorSpinSlider::set_label(const String &p_label) { label = p_label; - update(); + queue_redraw(); } String EditorSpinSlider::get_label() const { @@ -516,7 +516,7 @@ String EditorSpinSlider::get_label() const { void EditorSpinSlider::set_suffix(const String &p_suffix) { suffix = p_suffix; - update(); + queue_redraw(); } String EditorSpinSlider::get_suffix() const { @@ -583,17 +583,17 @@ void EditorSpinSlider::_value_focus_exited() { void EditorSpinSlider::_grabber_mouse_entered() { mouse_over_grabber = true; - update(); + queue_redraw(); } void EditorSpinSlider::_grabber_mouse_exited() { mouse_over_grabber = false; - update(); + queue_redraw(); } void EditorSpinSlider::set_read_only(bool p_enable) { read_only = p_enable; - update(); + queue_redraw(); } bool EditorSpinSlider::is_read_only() const { @@ -602,7 +602,7 @@ bool EditorSpinSlider::is_read_only() const { void EditorSpinSlider::set_flat(bool p_enable) { flat = p_enable; - update(); + queue_redraw(); } bool EditorSpinSlider::is_flat() const { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 5ff305fe16..088239c2d9 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -476,6 +476,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color font_color = mono_color.lerp(base_color, 0.25); const Color font_hover_color = mono_color.lerp(base_color, 0.125); const Color font_focus_color = mono_color.lerp(base_color, 0.125); + const Color font_hover_pressed_color = font_hover_color.lerp(accent_color, 0.74); const Color font_disabled_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.3); const Color font_readonly_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.65); const Color font_placeholder_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.6); @@ -751,6 +752,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "MenuButton", font_color); theme->set_color("font_hover_color", "MenuButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "MenuButton", font_hover_pressed_color); theme->set_color("font_focus_color", "MenuButton", font_focus_color); theme->set_stylebox("MenuHover", "EditorStyles", style_widget_hover); @@ -764,6 +766,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "Button", font_color); theme->set_color("font_hover_color", "Button", font_hover_color); + theme->set_color("font_hover_pressed_color", "Button", font_hover_pressed_color); theme->set_color("font_focus_color", "Button", font_focus_color); theme->set_color("font_pressed_color", "Button", accent_color); theme->set_color("font_disabled_color", "Button", font_disabled_color); @@ -816,6 +819,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "MenuBar", font_color); theme->set_color("font_hover_color", "MenuBar", font_hover_color); + theme->set_color("font_hover_pressed_color", "MenuBar", font_hover_pressed_color); theme->set_color("font_focus_color", "MenuBar", font_focus_color); theme->set_color("font_pressed_color", "MenuBar", accent_color); theme->set_color("font_disabled_color", "MenuBar", font_disabled_color); @@ -852,6 +856,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "OptionButton", font_color); theme->set_color("font_hover_color", "OptionButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "OptionButton", font_hover_pressed_color); theme->set_color("font_focus_color", "OptionButton", font_focus_color); theme->set_color("font_pressed_color", "OptionButton", accent_color); theme->set_color("font_disabled_color", "OptionButton", font_disabled_color); @@ -886,6 +891,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "CheckButton", font_color); theme->set_color("font_hover_color", "CheckButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "CheckButton", font_hover_pressed_color); theme->set_color("font_focus_color", "CheckButton", font_focus_color); theme->set_color("font_pressed_color", "CheckButton", accent_color); theme->set_color("font_disabled_color", "CheckButton", font_disabled_color); @@ -922,6 +928,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "CheckBox", font_color); theme->set_color("font_hover_color", "CheckBox", font_hover_color); + theme->set_color("font_hover_pressed_color", "CheckBox", font_hover_pressed_color); theme->set_color("font_focus_color", "CheckBox", font_focus_color); theme->set_color("font_pressed_color", "CheckBox", accent_color); theme->set_color("font_disabled_color", "CheckBox", font_disabled_color); @@ -1486,6 +1493,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("focus", "LinkButton", style_empty); theme->set_color("font_color", "LinkButton", font_color); theme->set_color("font_hover_color", "LinkButton", font_hover_color); + theme->set_color("font_hover_pressed_color", "LinkButton", font_hover_pressed_color); theme->set_color("font_focus_color", "LinkButton", font_focus_color); theme->set_color("font_pressed_color", "LinkButton", accent_color); theme->set_color("font_disabled_color", "LinkButton", font_disabled_color); @@ -1516,8 +1524,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { control_editor_popup_style->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE); control_editor_popup_style->set_border_width_all(0); - theme->set_stylebox("panel", "ControlEditorPopupButton", control_editor_popup_style); - theme->set_type_variation("ControlEditorPopupButton", "PopupPanel"); + theme->set_stylebox("panel", "ControlEditorPopupPanel", control_editor_popup_style); + theme->set_type_variation("ControlEditorPopupPanel", "PopupPanel"); // SpinBox theme->set_icon("updown", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdown"), SNAME("EditorIcons"))); diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index bb29b1c171..5b015fc95c 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -62,7 +62,7 @@ void EditorToaster::_notification(int p_what) { if (toasts[element.key].remaining_time < 0) { close(element.key); } - element.key->update(); + element.key->queue_redraw(); } } else { // Reset the timers when hovered. @@ -71,7 +71,7 @@ void EditorToaster::_notification(int p_what) { continue; } toasts[element.key].remaining_time = element.value.duration; - element.key->update(); + element.key->queue_redraw(); } } @@ -101,7 +101,7 @@ void EditorToaster::_notification(int p_what) { if (needs_update) { _update_vbox_position(); _update_disable_notifications_button(); - main_button->update(); + main_button->queue_redraw(); } } break; @@ -132,8 +132,8 @@ void EditorToaster::_notification(int p_what) { error_panel_style_progress->set_bg_color(get_theme_color(SNAME("base_color"), SNAME("Editor")).lightened(0.03)); error_panel_style_progress->set_border_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); - main_button->update(); - disable_notifications_button->update(); + main_button->queue_redraw(); + disable_notifications_button->queue_redraw(); } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -334,7 +334,7 @@ void EditorToaster::_repop_old() { if (needs_update) { _update_vbox_position(); _update_disable_notifications_button(); - main_button->update(); + main_button->queue_redraw(); } } @@ -389,7 +389,7 @@ Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_ _auto_hide_or_free_toasts(); _update_vbox_position(); _update_disable_notifications_button(); - main_button->update(); + main_button->queue_redraw(); return panel; } @@ -438,7 +438,7 @@ void EditorToaster::_popup_str(String p_message, Severity p_severity, String p_t _auto_hide_or_free_toasts(); _update_vbox_position(); _update_disable_notifications_button(); - main_button->update(); + main_button->queue_redraw(); } // Retrieve the label back then update the text. diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index cb188f9c3e..53cc8d5b22 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -168,14 +168,14 @@ void EditorVCSInterface::set_singleton(EditorVCSInterface *p_singleton) { void EditorVCSInterface::create_vcs_metadata_files(VCSMetadata p_vcs_metadata_type, String &p_dir) { if (p_vcs_metadata_type == VCSMetadata::GIT) { - Ref<FileAccess> f = FileAccess::open(p_dir.plus_file(".gitignore"), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(p_dir.path_join(".gitignore"), FileAccess::WRITE); if (f.is_null()) { ERR_FAIL_MSG(TTR("Couldn't create .gitignore in project path.")); } else { f->store_line("# Godot 4+ specific ignores"); f->store_line(".godot/"); } - f = FileAccess::open(p_dir.plus_file(".gitattributes"), FileAccess::WRITE); + f = FileAccess::open(p_dir.path_join(".gitattributes"), FileAccess::WRITE); if (f.is_null()) { ERR_FAIL_MSG(TTR("Couldn't create .gitattributes in project path.")); } else { diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 8283c24e61..e07b5e4cdb 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -295,7 +295,7 @@ Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const { String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { String current_version = VERSION_FULL_CONFIG; - String template_path = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(current_version).plus_file(template_file_name); + String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(current_version).path_join(template_file_name); if (FileAccess::exists(template_path)) { return template_path; @@ -848,7 +848,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } else { // Use default text server data. - String icu_data_file = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmp_icu_data"); + String icu_data_file = EditorPaths::get_singleton()->get_cache_dir().path_join("tmp_icu_data"); TS->save_support_data(icu_data_file); Vector<uint8_t> array = FileAccess::get_file_as_array(icu_data_file); err = p_func(p_udata, ts_data, array, idx, total, enc_in_filters, enc_ex_filters, key); @@ -861,7 +861,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } String config_file = "project.binary"; - String engine_cfb = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmp" + config_file); + String engine_cfb = EditorPaths::get_singleton()->get_cache_dir().path_join("tmp" + config_file); ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list); Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); DirAccess::remove_file_or_error(engine_cfb); @@ -885,7 +885,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da->make_dir_recursive(EditorPaths::get_singleton()->get_cache_dir()); - String tmppath = EditorPaths::get_singleton()->get_cache_dir().plus_file("packtmp"); + String tmppath = EditorPaths::get_singleton()->get_cache_dir().path_join("packtmp"); Ref<FileAccess> ftmp = FileAccess::open(tmppath, FileAccess::WRITE); if (ftmp.is_null()) { add_message(EXPORT_MESSAGE_ERROR, TTR("Save PCK"), vformat(TTR("Cannot create file \"%s\"."), tmppath)); diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp index 9fca4c908a..8538414523 100644 --- a/editor/export/editor_export_platform_pc.cpp +++ b/editor/export/editor_export_platform_pc.cpp @@ -185,9 +185,9 @@ Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset> String src_path = ProjectSettings::get_singleton()->globalize_path(so_files[i].path); String target_path; if (so_files[i].target.is_empty()) { - target_path = p_path.get_base_dir().plus_file(src_path.get_file()); + target_path = p_path.get_base_dir().path_join(src_path.get_file()); } else { - target_path = p_path.get_base_dir().plus_file(so_files[i].target).plus_file(src_path.get_file()); + target_path = p_path.get_base_dir().path_join(so_files[i].target).path_join(src_path.get_file()); } if (da->dir_exists(src_path)) { diff --git a/editor/export/editor_export_plugin.cpp b/editor/export/editor_export_plugin.cpp index cf3a9b0810..27a671a919 100644 --- a/editor/export/editor_export_plugin.cpp +++ b/editor/export/editor_export_plugin.cpp @@ -181,7 +181,7 @@ void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, con if (!convert) { return; } - String tmp_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpfile.res"); + String tmp_path = EditorPaths::get_singleton()->get_cache_dir().path_join("tmpfile.res"); Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path); if (err != OK) { DirAccess::remove_file_or_error(tmp_path); diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp index a0afcf4237..0ecbc9a8a3 100644 --- a/editor/export/export_template_manager.cpp +++ b/editor/export/export_template_manager.cpp @@ -91,7 +91,7 @@ void ExportTemplateManager::_update_template_status() { install_options_vb->show(); if (templates.has(current_version)) { - current_installed_path->set_text(templates_dir.plus_file(current_version)); + current_installed_path->set_text(templates_dir.path_join(current_version)); } } @@ -146,7 +146,7 @@ void ExportTemplateManager::_download_template(const String &p_url, bool p_skip_ download_progress_hb->show(); _set_current_progress_status(TTR("Starting the download...")); - download_templates->set_download_file(EditorPaths::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz")); + download_templates->set_download_file(EditorPaths::get_singleton()->get_cache_dir().path_join("tmp_templates.tpz")); download_templates->set_use_threads(true); const String proxy_host = EDITOR_GET("network/http_proxy/host"); @@ -440,7 +440,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ } Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - String template_path = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(version); + String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(version); Error err = d->make_dir_recursive(template_path); if (err != OK) { EditorNode::get_singleton()->show_warning(TTR("Error creating path for extracting templates:") + "\n" + template_path); @@ -486,12 +486,12 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ if (base_dir != contents_dir && base_dir.begins_with(contents_dir)) { base_dir = base_dir.substr(contents_dir.length(), file_path.length()).trim_prefix("/"); - file = base_dir.plus_file(file); + file = base_dir.path_join(file); Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_CONTINUE(da.is_null()); - String output_dir = template_path.plus_file(base_dir); + String output_dir = template_path.path_join(base_dir); if (!DirAccess::exists(output_dir)) { Error mkdir_err = da->make_dir_recursive(output_dir); @@ -503,7 +503,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ p->step(TTR("Importing:") + " " + file, fc); } - String to_write = template_path.plus_file(file); + String to_write = template_path.path_join(file); Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE); if (f.is_null()) { @@ -544,14 +544,14 @@ void ExportTemplateManager::_uninstall_template_confirmed() { Error err = da->change_dir(templates_dir); ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'."); err = da->change_dir(uninstall_version); - ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir.plus_file(uninstall_version) + "'."); + ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir.path_join(uninstall_version) + "'."); err = da->erase_contents_recursive(); - ERR_FAIL_COND_MSG(err != OK, "Could not remove all templates in '" + templates_dir.plus_file(uninstall_version) + "'."); + ERR_FAIL_COND_MSG(err != OK, "Could not remove all templates in '" + templates_dir.path_join(uninstall_version) + "'."); da->change_dir(".."); err = da->remove(uninstall_version); - ERR_FAIL_COND_MSG(err != OK, "Could not remove templates directory at '" + templates_dir.plus_file(uninstall_version) + "'."); + ERR_FAIL_COND_MSG(err != OK, "Could not remove templates directory at '" + templates_dir.path_join(uninstall_version) + "'."); _update_template_status(); } @@ -618,7 +618,7 @@ void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_co void ExportTemplateManager::_open_template_folder(const String &p_version) { const String &templates_dir = EditorPaths::get_singleton()->get_export_templates_dir(); - OS::get_singleton()->shell_open("file://" + templates_dir.plus_file(p_version)); + OS::get_singleton()->shell_open("file://" + templates_dir.path_join(p_version)); } void ExportTemplateManager::popup_manager() { @@ -641,13 +641,13 @@ void ExportTemplateManager::_hide_dialog() { } bool ExportTemplateManager::can_install_android_template() { - const String templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG); - return FileAccess::exists(templates_dir.plus_file("android_source.zip")); + const String templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().path_join(VERSION_FULL_CONFIG); + return FileAccess::exists(templates_dir.path_join("android_source.zip")); } Error ExportTemplateManager::install_android_template() { - const String &templates_path = EditorPaths::get_singleton()->get_export_templates_dir().plus_file(VERSION_FULL_CONFIG); - const String &source_zip = templates_path.plus_file("android_source.zip"); + const String &templates_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(VERSION_FULL_CONFIG); + const String &source_zip = templates_path.path_join("android_source.zip"); ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN); return install_android_template_from_file(source_zip); } @@ -723,11 +723,11 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ unzCloseCurrentFile(pkg); if (!dirs_tested.has(base_dir)) { - da->make_dir_recursive(String("android/build").plus_file(base_dir)); + da->make_dir_recursive(String("android/build").path_join(base_dir)); dirs_tested.insert(base_dir); } - String to_write = String("res://android/build").plus_file(path); + 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()); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index a42433caee..19788e70da 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -146,7 +146,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory file_item->set_text(0, fi.name); file_item->set_structured_text_bidi_override(0, TextServer::STRUCTURED_TEXT_FILE); file_item->set_icon(0, _get_tree_item_icon(!fi.import_broken, fi.type)); - String file_metadata = lpath.plus_file(fi.name); + String file_metadata = lpath.path_join(fi.name); file_item->set_metadata(0, file_metadata); if (!p_select_in_favorites && path == file_metadata) { file_item->select(0); @@ -276,7 +276,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo ti->set_text(0, text); ti->set_icon(0, icon); ti->set_icon_modulate(0, color); - ti->set_tooltip(0, fave); + ti->set_tooltip_text(0, fave); ti->set_selectable(0, true); ti->set_metadata(0, fave); if (p_select_in_favorites && fave == path) { @@ -867,7 +867,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { String dname = efd->get_subdir(i)->get_name(); files->add_item(dname, folder_icon, true); - files->set_item_metadata(-1, directory.plus_file(dname) + "/"); + files->set_item_metadata(-1, directory.path_join(dname) + "/"); files->set_item_icon_modulate(-1, folder_color); if (cselection.has(dname)) { @@ -880,7 +880,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { for (int i = 0; i < efd->get_file_count(); i++) { FileInfo fi; fi.name = efd->get_file(i); - fi.path = directory.plus_file(fi.name); + fi.path = directory.path_join(fi.name); fi.type = efd->get_file_type(i); fi.import_broken = !efd->get_file_import_is_valid(i); fi.modified_time = efd->get_file_modified_time(i); @@ -1545,7 +1545,7 @@ void FileSystemDock::_rename_operation_confirm() { } String old_path = to_rename.path.ends_with("/") ? to_rename.path.substr(0, to_rename.path.length() - 1) : to_rename.path; - String new_path = old_path.get_base_dir().plus_file(new_name); + String new_path = old_path.get_base_dir().path_join(new_name); if (old_path == new_path) { return; } @@ -1605,7 +1605,7 @@ void FileSystemDock::_duplicate_operation_confirm() { base_dir = base_dir.get_base_dir(); } - String new_path = base_dir.plus_file(new_name); + String new_path = base_dir.path_join(new_name); // Present a more user friendly warning for name conflict Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES); @@ -1630,7 +1630,7 @@ Vector<String> FileSystemDock::_check_existing() { String &p_to_path = to_move_path; for (int i = 0; i < to_move.size(); i++) { String ol_pth = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path; - String p_new_path = p_to_path.plus_file(ol_pth.get_file()); + String p_new_path = p_to_path.path_join(ol_pth.get_file()); FileOrFolder p_item = to_move[i]; String old_path = (p_item.is_file || p_item.path.ends_with("/")) ? p_item.path : (p_item.path + "/"); @@ -1662,7 +1662,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove // Check groups. for (int i = 0; i < to_move.size(); i++) { if (to_move[i].is_file && EditorFileSystem::get_singleton()->is_group_file(to_move[i].path)) { - EditorFileSystem::get_singleton()->move_group_file(to_move[i].path, p_to_path.plus_file(to_move[i].path.get_file())); + EditorFileSystem::get_singleton()->move_group_file(to_move[i].path, p_to_path.path_join(to_move[i].path.get_file())); } } @@ -1671,7 +1671,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove bool is_moved = false; for (int i = 0; i < to_move.size(); i++) { String old_path = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path; - String new_path = p_to_path.plus_file(old_path.get_file()); + String new_path = p_to_path.path_join(old_path.get_file()); if (old_path != new_path) { _try_move_item(to_move[i], new_path, file_renames, folder_renames); is_moved = true; @@ -2005,7 +2005,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected if (!fpath.ends_with("/")) { fpath = fpath.get_base_dir(); } - make_script_dialog->config("Node", fpath.plus_file("new_script.gd"), false, false); + make_script_dialog->config("Node", fpath.path_join("new_script.gd"), false, false); make_script_dialog->popup_centered(); } break; @@ -2047,15 +2047,15 @@ void FileSystemDock::_resource_created() { String type_name = new_resource_dialog->get_selected_type(); if (type_name == "Shader") { - make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 0); + make_shader_dialog->config(fpath.path_join("new_shader"), false, false, 0); make_shader_dialog->popup_centered(); return; } else if (type_name == "VisualShader") { - make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 1); + make_shader_dialog->config(fpath.path_join("new_shader"), false, false, 1); make_shader_dialog->popup_centered(); return; } else if (type_name == "ShaderInclude") { - make_shader_dialog->config(fpath.plus_file("new_shader_include"), false, false, 2); + make_shader_dialog->config(fpath.path_join("new_shader_include"), false, false, 2); make_shader_dialog->popup_centered(); return; } @@ -2370,11 +2370,11 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, String new_path_base; if (to_move[i].is_file) { - new_path = to_dir.plus_file(to_move[i].path.get_file()); + new_path = to_dir.path_join(to_move[i].path.get_file()); new_path_base = new_path.get_basename() + " (%d)." + new_path.get_extension(); } else { PackedStringArray path_split = to_move[i].path.split("/"); - new_path = to_dir.plus_file(path_split[path_split.size() - 2]); + new_path = to_dir.path_join(path_split[path_split.size() - 2]); new_path_base = new_path + " (%d)"; } diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 56387e87f5..16c5003fdc 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -168,7 +168,7 @@ void FindInFiles::_iterate() { String folder_name = folders_to_scan[folders_to_scan.size() - 1]; pop_back(folders_to_scan); - _current_dir = _current_dir.plus_file(folder_name); + _current_dir = _current_dir.path_join(folder_name); PackedStringArray sub_dirs; _scan_dir("res://" + _current_dir, sub_dirs); @@ -246,7 +246,7 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) { } else { String file_ext = file.get_extension(); if (_extension_filter.has(file_ext)) { - _files_to_scan.push_back(path.plus_file(file)); + _files_to_scan.push_back(path.path_join(file)); } } } diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 15add50fd4..dac86acae4 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -89,7 +89,7 @@ void GroupDialog::_load_nodes(Node *p_current) { if (keep) { node->set_text(0, item_name); node->set_metadata(0, path); - node->set_tooltip(0, path); + node->set_tooltip_text(0, path); Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node"); node->set_icon(0, icon); diff --git a/editor/import/audio_stream_import_settings.cpp b/editor/import/audio_stream_import_settings.cpp index cc7c5809d6..e3da82a5cb 100644 --- a/editor/import/audio_stream_import_settings.cpp +++ b/editor/import/audio_stream_import_settings.cpp @@ -57,13 +57,13 @@ void AudioStreamImportSettings::_notification(int p_what) { zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); - _indicator->update(); - _preview->update(); + _indicator->queue_redraw(); + _preview->queue_redraw(); } break; case NOTIFICATION_PROCESS: { _current = _player->get_playback_position(); - _indicator->update(); + _indicator->queue_redraw(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -167,7 +167,7 @@ void AudioStreamImportSettings::_draw_preview() { void AudioStreamImportSettings::_preview_changed(ObjectID p_which) { if (stream.is_valid() && stream->get_instance_id() == p_which) { - _preview->update(); + _preview->queue_redraw(); } } @@ -179,8 +179,8 @@ void AudioStreamImportSettings::_preview_zoom_in() { zoom_bar->set_page(page_size * 0.5); zoom_bar->set_value(zoom_bar->get_value() + page_size * 0.25); - _preview->update(); - _indicator->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_preview_zoom_out() { @@ -191,8 +191,8 @@ void AudioStreamImportSettings::_preview_zoom_out() { zoom_bar->set_page(MIN(zoom_bar->get_max(), page_size * 2.0)); zoom_bar->set_value(zoom_bar->get_value() - page_size * 0.5); - _preview->update(); - _indicator->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_preview_zoom_reset() { @@ -202,22 +202,22 @@ void AudioStreamImportSettings::_preview_zoom_reset() { zoom_bar->set_max(stream->get_length()); zoom_bar->set_page(zoom_bar->get_max()); zoom_bar->set_value(0); - _preview->update(); - _indicator->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_preview_zoom_offset_changed(double) { - _preview->update(); - _indicator->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_audio_changed() { if (!is_visible()) { return; } - _preview->update(); - _indicator->update(); - color_rect->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); + color_rect->queue_redraw(); } void AudioStreamImportSettings::_play() { @@ -238,7 +238,7 @@ void AudioStreamImportSettings::_stop() { _player->stop(); _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); _current = 0; - _indicator->update(); + _indicator->queue_redraw(); set_process(false); } @@ -246,7 +246,7 @@ void AudioStreamImportSettings::_on_finished() { _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); if (!_pausing) { _current = 0; - _indicator->update(); + _indicator->queue_redraw(); } else { _pausing = false; } @@ -310,7 +310,7 @@ void AudioStreamImportSettings::_draw_indicator() { void AudioStreamImportSettings::_on_indicator_mouse_exited() { _hovering_beat = -1; - _indicator->update(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::_on_input_indicator(Ref<InputEvent> p_event) { @@ -353,11 +353,11 @@ void AudioStreamImportSettings::_on_input_indicator(Ref<InputEvent> p_event) { int new_hovering_beat = _get_beat_at_pos(mm->get_position().x); if (new_hovering_beat != _hovering_beat) { _hovering_beat = new_hovering_beat; - _indicator->update(); + _indicator->queue_redraw(); } } else if (_hovering_beat != -1) { _hovering_beat = -1; - _indicator->update(); + _indicator->queue_redraw(); } } } @@ -391,7 +391,7 @@ void AudioStreamImportSettings::_seek_to(real_t p_x) { _current = zoom_bar->get_value() + p_x / _preview->get_rect().size.x * zoom_bar->get_page(); _current = CLAMP(_current, 0, stream->get_length()); _player->seek(_current); - _indicator->update(); + _indicator->queue_redraw(); } void AudioStreamImportSettings::edit(const String &p_path, const String &p_importer, const Ref<AudioStream> &p_stream) { @@ -410,9 +410,9 @@ void AudioStreamImportSettings::edit(const String &p_path, const String &p_impor if (!stream.is_null()) { stream->connect("changed", callable_mp(this, &AudioStreamImportSettings::_audio_changed)); - _preview->update(); - _indicator->update(); - color_rect->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); + color_rect->queue_redraw(); } else { hide(); } @@ -500,9 +500,9 @@ void AudioStreamImportSettings::_settings_changed() { updating_settings = false; - _preview->update(); - _indicator->update(); - color_rect->update(); + _preview->queue_redraw(); + _indicator->queue_redraw(); + color_rect->queue_redraw(); } void AudioStreamImportSettings::_reimport() { diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index 5b9ed2c1d2..5d8e453395 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -289,7 +289,7 @@ void Collada::_parse_image(XMLParser &parser) { String path = parser.get_attribute_value("source").strip_edges(); if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path - image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().plus_file(path.uri_decode())); + image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().path_join(path.uri_decode())); } } else { while (parser.read() == OK) { @@ -302,7 +302,7 @@ void Collada::_parse_image(XMLParser &parser) { if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path - path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().plus_file(path)); + path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().path_join(path)); } else if (path.find("file:///") == 0) { path = path.replace_first("file:///", ""); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index 0575f3cbf3..405d8d2169 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -474,7 +474,7 @@ void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_proper font_preview_label->add_theme_font_override("font", font_preview); font_preview_label->add_theme_font_size_override("font_size", 200 * EDSCALE); - font_preview_label->update(); + font_preview_label->queue_redraw(); } /*************************************************************************/ @@ -1096,7 +1096,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { } font_preview_label->add_theme_font_override("font", font_preview); font_preview_label->add_theme_font_size_override("font_size", 200 * EDSCALE); - font_preview_label->update(); + font_preview_label->queue_redraw(); _variations_validate(); diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index d1c4e1f8dd..fe70fd58b5 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -129,7 +129,7 @@ static Error _parse_material_library(const String &p_path, HashMap<String, Ref<S if (p.is_absolute_path()) { path = p; } else { - path = base_path.plus_file(p); + path = base_path.path_join(p); } Ref<Texture2D> texture = ResourceLoader::load(path); @@ -149,7 +149,7 @@ static Error _parse_material_library(const String &p_path, HashMap<String, Ref<S if (p.is_absolute_path()) { path = p; } else { - path = base_path.plus_file(p); + path = base_path.path_join(p); } Ref<Texture2D> texture = ResourceLoader::load(path); @@ -169,7 +169,7 @@ static Error _parse_material_library(const String &p_path, HashMap<String, Ref<S if (p.is_absolute_path()) { path = p; } else { - path = base_path.plus_file(p); + path = base_path.path_join(p); } Ref<Texture2D> texture = ResourceLoader::load(path); @@ -184,7 +184,7 @@ static Error _parse_material_library(const String &p_path, HashMap<String, Ref<S ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); String p = l.replace("map_bump", "").replace("\\", "/").strip_edges(); - String path = base_path.plus_file(p); + String path = base_path.path_join(p); Ref<Texture2D> texture = ResourceLoader::load(path); @@ -405,7 +405,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ HashMap<String, Ref<StandardMaterial3D>> lib; String lib_path = current_material_library; if (lib_path.is_relative_path()) { - lib_path = p_path.get_base_dir().plus_file(current_material_library); + lib_path = p_path.get_base_dir().path_join(current_material_library); } Error err = _parse_material_library(lib_path, lib, r_missing_deps); if (err == OK) { diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp index d3079141e0..55afd71c76 100644 --- a/editor/import/resource_importer_shader_file.cpp +++ b/editor/import/resource_importer_shader_file.cpp @@ -79,7 +79,7 @@ static String _include_function(const String &p_path, void *userpointer) { String include = p_path; if (include.is_relative_path()) { - include = base_path->plus_file(include); + include = base_path->path_join(include); } Ref<FileAccess> file_inc = FileAccess::open(include, FileAccess::READ, &err); diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 6c12464b5a..1ff771bcce 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -176,7 +176,7 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma item->set_meta("type", "Material"); item->set_meta("import_id", import_id); - item->set_tooltip(0, vformat(TTR("Import ID: %s"), import_id)); + item->set_tooltip_text(0, vformat(TTR("Import ID: %s"), import_id)); item->set_selectable(0, true); if (p_tree == scene_tree) { @@ -232,7 +232,7 @@ void SceneImportSettings::_fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, Tree item->set_meta("type", "Mesh"); item->set_meta("import_id", import_id); - item->set_tooltip(0, vformat(TTR("Import ID: %s"), import_id)); + item->set_tooltip_text(0, vformat(TTR("Import ID: %s"), import_id)); item->set_selectable(0, true); @@ -331,7 +331,7 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { item->set_meta("type", "Node"); item->set_meta("class", type); item->set_meta("import_id", import_id); - item->set_tooltip(0, vformat(TTR("Type: %s\nImport ID: %s"), type, import_id)); + item->set_tooltip_text(0, vformat(TTR("Type: %s\nImport ID: %s"), type, import_id)); item->set_selectable(0, true); @@ -979,7 +979,7 @@ void SceneImportSettings::_save_path_changed(const String &p_path) { if (FileAccess::exists(p_path)) { save_path_item->set_text(2, "Warning: File exists"); - save_path_item->set_tooltip(2, TTR("Existing file with the same name will be replaced.")); + save_path_item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced.")); save_path_item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { @@ -1024,12 +1024,12 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (md.has_import_id) { if (md.settings.has("use_external/enabled") && bool(md.settings["use_external/enabled"])) { item->set_text(2, "Already External"); - item->set_tooltip(2, TTR("This material already references an external file, no action will be taken.\nDisable the external property for it to be extracted again.")); + item->set_tooltip_text(2, TTR("This material already references an external file, no action will be taken.\nDisable the external property for it to be extracted again.")); } else { item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); - String path = p_path.plus_file(name); + String path = p_path.path_join(name); if (external_extension_type->get_selected() == 0) { path += ".tres"; } else { @@ -1039,7 +1039,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(1, path); if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); - item->set_tooltip(2, TTR("Existing file with the same name will be replaced.")); + item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced.")); item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { @@ -1052,7 +1052,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { } else { item->set_text(2, "No import ID"); - item->set_tooltip(2, TTR("Material has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); + item->set_tooltip_text(2, TTR("Material has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); } @@ -1077,12 +1077,12 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (md.has_import_id) { if (md.settings.has("save_to_file/enabled") && bool(md.settings["save_to_file/enabled"])) { item->set_text(2, "Already Saving"); - item->set_tooltip(2, TTR("This mesh already saves to an external resource, no action will be taken.")); + item->set_tooltip_text(2, TTR("This mesh already saves to an external resource, no action will be taken.")); } else { item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); - String path = p_path.plus_file(name); + String path = p_path.path_join(name); if (external_extension_type->get_selected() == 0) { path += ".tres"; } else { @@ -1092,7 +1092,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(1, path); if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); - item->set_tooltip(2, TTR("Existing file with the same name will be replaced on import.")); + item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced on import.")); item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { @@ -1105,7 +1105,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { } else { item->set_text(2, "No import ID"); - item->set_tooltip(2, TTR("Mesh has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); + item->set_tooltip_text(2, TTR("Mesh has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); } @@ -1129,12 +1129,12 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (ad.settings.has("save_to_file/enabled") && bool(ad.settings["save_to_file/enabled"])) { item->set_text(2, "Already Saving"); - item->set_tooltip(2, TTR("This animation already saves to an external resource, no action will be taken.")); + item->set_tooltip_text(2, TTR("This animation already saves to an external resource, no action will be taken.")); } else { item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); - String path = p_path.plus_file(name); + String path = p_path.path_join(name); if (external_extension_type->get_selected() == 0) { path += ".tres"; } else { @@ -1144,7 +1144,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(1, path); if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); - item->set_tooltip(2, TTR("Existing file with the same name will be replaced on import.")); + item->set_tooltip_text(2, TTR("Existing file with the same name will be replaced on import.")); item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 77a1700ebf..683481ecc1 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -193,7 +193,7 @@ void LocalizationEditor::_translation_res_option_popup(bool p_arrow_clicked) { TreeItem *ed = translation_remap_options->get_edited(); ERR_FAIL_COND(!ed); - locale_select->set_locale(ed->get_tooltip(1)); + locale_select->set_locale(ed->get_tooltip_text(1)); locale_select->popup_locale_dialog(); } @@ -202,7 +202,7 @@ void LocalizationEditor::_translation_res_option_selected(const String &p_locale ERR_FAIL_COND(!ed); ed->set_text(1, TranslationServer::get_singleton()->get_locale_name(p_locale)); - ed->set_tooltip(1, p_locale); + ed->set_tooltip_text(1, p_locale); LocalizationEditor::_translation_res_option_changed(); } @@ -226,7 +226,7 @@ void LocalizationEditor::_translation_res_option_changed() { String key = k->get_metadata(0); int idx = ed->get_metadata(0); String path = ed->get_metadata(1); - String locale = ed->get_tooltip(1); + String locale = ed->get_tooltip_text(1); ERR_FAIL_COND(!remaps.has(key)); PackedStringArray r = remaps[key]; @@ -486,7 +486,7 @@ void LocalizationEditor::update_translations() { TreeItem *t = translation_list->create_item(root); t->set_editable(0, false); t->set_text(0, translations[i].replace_first("res://", "")); - t->set_tooltip(0, translations[i]); + t->set_tooltip_text(0, translations[i]); t->set_metadata(0, i); t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); } @@ -520,14 +520,14 @@ void LocalizationEditor::update_translations() { TreeItem *t = translation_remap->create_item(root); t->set_editable(0, false); t->set_text(0, keys[i].replace_first("res://", "")); - t->set_tooltip(0, keys[i]); + t->set_tooltip_text(0, keys[i]); t->set_metadata(0, keys[i]); t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); // Display that it has been removed if this is the case. if (!FileAccess::exists(keys[i])) { t->set_text(0, t->get_text(0) + vformat(" (%s)", TTR("Removed"))); - t->set_tooltip(0, vformat(TTR("%s cannot be found."), t->get_tooltip(0))); + t->set_tooltip_text(0, vformat(TTR("%s cannot be found."), t->get_tooltip_text(0))); } if (keys[i] == remap_selected) { @@ -544,19 +544,19 @@ void LocalizationEditor::update_translations() { TreeItem *t2 = translation_remap_options->create_item(root2); t2->set_editable(0, false); t2->set_text(0, path.replace_first("res://", "")); - t2->set_tooltip(0, path); + t2->set_tooltip_text(0, path); t2->set_metadata(0, j); t2->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); t2->set_text(1, TranslationServer::get_singleton()->get_locale_name(locale)); t2->set_editable(1, true); t2->set_metadata(1, path); - t2->set_tooltip(1, locale); + t2->set_tooltip_text(1, locale); // Display that it has been removed if this is the case. if (!FileAccess::exists(path)) { t2->set_text(0, t2->get_text(0) + vformat(" (%s)", TTR("Removed"))); - t2->set_tooltip(0, vformat(TTR("%s cannot be found."), t2->get_tooltip(0))); + t2->set_tooltip_text(0, vformat(TTR("%s cannot be found."), t2->get_tooltip_text(0))); } } } @@ -573,7 +573,7 @@ void LocalizationEditor::update_translations() { TreeItem *t = translation_pot_list->create_item(root); t->set_editable(0, false); t->set_text(0, pot_translations[i].replace_first("res://", "")); - t->set_tooltip(0, pot_translations[i]); + t->set_tooltip_text(0, pot_translations[i]); t->set_metadata(0, i); t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); } diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 88aa6354e4..71ff77e9bc 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -62,7 +62,7 @@ void PluginConfigDialog::_on_confirmed() { if (script_name.get_extension().is_empty()) { script_name += "." + ext; } - String script_path = path.plus_file(script_name); + String script_path = path.path_join(script_name); Ref<ConfigFile> cf = memnew(ConfigFile); cf->set_value("plugin", "name", name_edit->get_text()); @@ -71,7 +71,7 @@ void PluginConfigDialog::_on_confirmed() { cf->set_value("plugin", "version", version_edit->get_text()); cf->set_value("plugin", "script", script_name); - cf->save(path.plus_file("plugin.cfg")); + cf->save(path.path_join("plugin.cfg")); if (!_edit_mode) { String class_name = script_name.get_basename(); diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 3b7829c37b..b79f4c90bf 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -120,7 +120,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - blend_space_draw->update(); // why not + blend_space_draw->queue_redraw(); // why not // try to see if a point can be selected selected_point = -1; @@ -167,7 +167,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven dragging_selected_attempt = false; dragging_selected = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -178,20 +178,20 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven blend_pos += blend_space->get_min_space(); AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && !blend_space_draw->has_focus()) { blend_space_draw->grab_focus(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mm.is_valid() && dragging_selected_attempt) { dragging_selected = true; drag_ofs = ((mm->get_position() - drag_from) / blend_space_draw->get_size()) * ((blend_space->get_max_space() - blend_space->get_min_space()) * Vector2(1, 0)); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); _update_edited_point_pos(); } @@ -202,7 +202,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -330,7 +330,7 @@ void AnimationNodeBlendSpace1DEditor::_update_space() { snap_value->set_value(blend_space->get_snap()); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); updating = false; } @@ -355,7 +355,7 @@ void AnimationNodeBlendSpace1DEditor::_config_changed(double) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_labels_changed(String) { @@ -374,7 +374,7 @@ void AnimationNodeBlendSpace1DEditor::_labels_changed(String) { } void AnimationNodeBlendSpace1DEditor::_snap_toggled() { - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_file_opened(const String &p_file) { @@ -425,7 +425,7 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_add_animation_type(int p_index) { @@ -443,7 +443,7 @@ void AnimationNodeBlendSpace1DEditor::_add_animation_type(int p_index) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_tool_switch(int p_tool) { @@ -456,7 +456,7 @@ void AnimationNodeBlendSpace1DEditor::_tool_switch(int p_tool) { } _update_tool_erase(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_update_edited_point_pos() { @@ -517,7 +517,7 @@ void AnimationNodeBlendSpace1DEditor::_erase_selected() { updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -537,7 +537,7 @@ void AnimationNodeBlendSpace1DEditor::_edit_point_pos(double) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace1DEditor::_open_editor() { diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index d904ccb5e0..1646a1cef4 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -52,7 +52,7 @@ bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref<AnimationNode> &p_node) } void AnimationNodeBlendSpace2DEditor::_blend_space_changed() { - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::edit(const Ref<AnimationNode> &p_node) { @@ -161,7 +161,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - blend_space_draw->update(); //update anyway + blend_space_draw->queue_redraw(); //update anyway //try to see if a point can be selected selected_point = -1; selected_triangle = -1; @@ -201,7 +201,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_triangle->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { - blend_space_draw->update(); //update anyway + blend_space_draw->queue_redraw(); //update anyway //try to see if a point can be selected selected_point = -1; @@ -260,7 +260,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } dragging_selected_attempt = false; dragging_selected = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mb.is_valid() && mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { @@ -271,14 +271,14 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && !blend_space_draw->has_focus()) { blend_space_draw->grab_focus(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mm.is_valid() && dragging_selected_attempt) { @@ -286,17 +286,17 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven if (!read_only) { drag_ofs = ((mm->get_position() - drag_from) / blend_space_draw->get_size()) * (blend_space->get_max_space() - blend_space->get_min_space()) * Vector2(1, -1); } - blend_space_draw->update(); + blend_space_draw->queue_redraw(); _update_edited_point_pos(); } if (mm.is_valid() && tool_triangle->is_pressed() && making_triangle.size()) { - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mm.is_valid() && !tool_triangle->is_pressed() && making_triangle.size()) { making_triangle.clear(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } if (mm.is_valid() && tool_blend->is_pressed() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { @@ -307,7 +307,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -359,7 +359,7 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_add_animation_type(int p_index) { @@ -377,7 +377,7 @@ void AnimationNodeBlendSpace2DEditor::_add_animation_type(int p_index) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_update_tool_erase() { @@ -424,7 +424,7 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) { tool_erase_sep->hide(); } _update_tool_erase(); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { @@ -614,7 +614,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { } void AnimationNodeBlendSpace2DEditor::_snap_toggled() { - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_update_space() { @@ -647,7 +647,7 @@ void AnimationNodeBlendSpace2DEditor::_update_space() { snap_x->set_value(blend_space->get_snap().x); snap_y->set_value(blend_space->get_snap().y); - blend_space_draw->update(); + blend_space_draw->queue_redraw(); updating = false; } @@ -674,7 +674,7 @@ void AnimationNodeBlendSpace2DEditor::_config_changed(double) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_labels_changed(String) { @@ -716,7 +716,7 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } else if (selected_triangle != -1) { updating = true; undo_redo->create_action(TTR("Remove BlendSpace2D Triangle")); @@ -728,7 +728,7 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } } @@ -767,7 +767,7 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) { undo_redo->commit_action(); updating = false; - blend_space_draw->update(); + blend_space_draw->queue_redraw(); } void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp index f9e5aa799a..50ba1a71c0 100644 --- a/editor/plugins/animation_library_editor.cpp +++ b/editor/plugins/animation_library_editor.cpp @@ -635,7 +635,7 @@ void AnimationLibraryEditor::update_tree() { String al_path = al->get_path(); if (!al_path.is_resource_file()) { libitem->set_text(1, TTR("[built-in]")); - libitem->set_tooltip(1, al_path); + libitem->set_tooltip_text(1, al_path); int srpos = al_path.find("::"); if (srpos != -1) { String base = al_path.substr(0, srpos); @@ -687,7 +687,7 @@ void AnimationLibraryEditor::update_tree() { String anim_path = anim->get_path(); if (!anim_path.is_resource_file()) { anitem->set_text(1, TTR("[built-in]")); - anitem->set_tooltip(1, anim_path); + anitem->set_tooltip_text(1, anim_path); int srpos = anim_path.find("::"); if (srpos != -1) { String base = anim_path.substr(0, srpos); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index be1e531cb8..cded53e054 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -128,7 +128,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv //travel playback->travel(node_rects[i].node_name); } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); return; } @@ -168,7 +168,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv Ref<AnimationNode> anode = state_machine->get_node(selected_node); EditorNode::get_singleton()->push_item(anode.ptr(), "", true); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); dragging_selected_attempt = true; dragging_selected = false; drag_from = mb->get_position(); @@ -228,7 +228,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); _update_mode(); } @@ -259,7 +259,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv dragging_selected_attempt = false; dragging_selected = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } // Connect nodes @@ -296,7 +296,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv _open_menu(mb->get_position()); } connecting_to_node = StringName(); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } // Start box selecting @@ -319,7 +319,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv // End box selecting if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && !mb->is_pressed() && box_selecting) { box_selecting = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); _update_mode(); } @@ -335,7 +335,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (mm.is_valid() && connecting && !read_only) { connecting_to = mm->get_position(); connecting_to_node = StringName(); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order if (node_rects[i].node_name != connecting_from && node_rects[i].node.has_point(connecting_to)) { //select node since nothing else was selected @@ -382,7 +382,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } // Move mouse while moving box select @@ -412,7 +412,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } if (mm.is_valid()) { @@ -442,7 +442,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (new_over_node != over_node || new_over_node_what != over_node_what) { over_node = new_over_node; over_node_what = new_over_node_what; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } // set tooltip for transition @@ -620,7 +620,7 @@ void AnimationNodeStateMachineEditor::_group_selected_nodes() { selected_nodes.clear(); selected_nodes.insert(group_name); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); accept_event(); _update_mode(); } @@ -721,7 +721,7 @@ void AnimationNodeStateMachineEditor::_ungroup_selected_nodes() { if (find) { selected_nodes = new_selected_nodes; selected_node = StringName(); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); accept_event(); _update_mode(); } @@ -909,7 +909,7 @@ bool AnimationNodeStateMachineEditor::_create_submenu(PopupMenu *p_menu, Ref<Ani void AnimationNodeStateMachineEditor::_stop_connecting() { connecting = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_delete_selected() { @@ -1028,7 +1028,7 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { undo_redo->commit_action(); updating = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { @@ -1056,7 +1056,7 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { undo_redo->commit_action(); updating = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_connect_to(int p_index) { @@ -1475,7 +1475,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { v_scroll->set_value(state_machine->get_graph_offset().y); updating = false; - state_machine_play_pos->update(); + state_machine_play_pos->queue_redraw(); } void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { @@ -1537,7 +1537,7 @@ void AnimationNodeStateMachineEditor::_update_graph() { updating = true; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); updating = false; } @@ -1609,34 +1609,34 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { } if (tidx == -1) { //missing transition, should redraw - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } if (transition_lines[i].disabled != state_machine->get_transition(tidx)->is_disabled()) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } if (transition_lines[i].auto_advance != state_machine->get_transition(tidx)->has_auto_advance()) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } if (transition_lines[i].advance_condition_name != state_machine->get_transition(tidx)->get_advance_condition_name()) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } if (transition_lines[i].mode != state_machine->get_transition(tidx)->get_switch_mode()) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } bool acstate = transition_lines[i].advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + String(transition_lines[i].advance_condition_name))); if (transition_lines[i].advance_condition_state != acstate) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); break; } } @@ -1671,14 +1671,14 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { } } - //update if travel state changed + //redraw if travel state changed if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) { - state_machine_draw->update(); + state_machine_draw->queue_redraw(); last_travel_path = tp; last_current_node = current_node; last_active = is_playing; last_blend_from_node = blend_from_node; - state_machine_play_pos->update(); + state_machine_play_pos->queue_redraw(); } { @@ -1703,7 +1703,7 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { if (last_play_pos != play_pos) { last_play_pos = play_pos; - state_machine_play_pos->update(); + state_machine_play_pos->queue_redraw(); } } break; @@ -1749,7 +1749,7 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { name_edit_popup->hide(); updating = false; - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_name_edited_focus_out() { @@ -1766,7 +1766,7 @@ void AnimationNodeStateMachineEditor::_scroll_changed(double) { } state_machine->set_graph_offset(Vector2(h_scroll->get_value(), v_scroll->get_value())); - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_erase_selected(const bool p_nested_action) { @@ -1857,7 +1857,7 @@ void AnimationNodeStateMachineEditor::_erase_selected(const bool p_nested_action selected_multi_transition = TransitionLine(); } - state_machine_draw->update(); + state_machine_draw->queue_redraw(); } void AnimationNodeStateMachineEditor::_update_mode() { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index bce4c9de8e..ed231c446b 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -59,10 +59,11 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) { Vector<String> path; if (tree && tree->has_meta("_tree_edit_path")) { path = tree->get_meta("_tree_edit_path"); - edit_path(path); } else { current_root = ObjectID(); } + + edit_path(path); } void AnimationTreeEditor::_path_button_pressed(int p_path) { @@ -129,6 +130,11 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) { } else { current_root = ObjectID(); edited_path = button_path; + + for (int i = 0; i < editors.size(); i++) { + editors[i]->edit(Ref<AnimationNode>()); + editors[i]->hide(); + } } _update_path(); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 025312c38c..41383edafe 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -487,7 +487,7 @@ void EditorAssetLibraryItemDownload::_make_request() { retry_button->hide(); download->cancel_request(); - download->set_download_file(EditorPaths::get_singleton()->get_cache_dir().plus_file("tmp_asset_" + itos(asset_id)) + ".zip"); + download->set_download_file(EditorPaths::get_singleton()->get_cache_dir().path_join("tmp_asset_" + itos(asset_id)) + ".zip"); Error err = download->request(host); if (err != OK) { @@ -730,7 +730,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB PackedByteArray image_data = p_data; if (use_cache) { - String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); + String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().path_join("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".data", FileAccess::READ); if (file.is_valid()) { @@ -804,7 +804,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) { for (int i = 0; i < headers.size(); i++) { if (headers[i].findn("ETag:") == 0) { // Save etag - String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); + String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().path_join("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); String new_etag = headers[i].substr(headers[i].find(":") + 1, headers[i].length()).strip_edges(); Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".etag", FileAccess::WRITE); if (file.is_valid()) { @@ -846,7 +846,7 @@ void EditorAssetLibrary::_update_image_queue() { List<int> to_delete; for (KeyValue<int, ImageQueue> &E : image_queue) { if (!E.value.active && current_images < max_images) { - String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + E.value.image_url.md5_text()); + String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().path_join("assetimage_" + E.value.image_url.md5_text()); Vector<String> headers; if (FileAccess::exists(cache_filename_base + ".etag") && FileAccess::exists(cache_filename_base + ".data")) { diff --git a/editor/plugins/bone_map_editor_plugin.cpp b/editor/plugins/bone_map_editor_plugin.cpp index c16dca00a3..988f9cc394 100644 --- a/editor/plugins/bone_map_editor_plugin.cpp +++ b/editor/plugins/bone_map_editor_plugin.cpp @@ -609,7 +609,7 @@ int BoneMapper::search_bone_by_name(Skeleton3D *p_skeleton, Vector<String> p_pic } BoneMapper::BoneSegregation BoneMapper::guess_bone_segregation(String p_bone_name) { - String fixed_bn = p_bone_name.camelcase_to_underscore().to_lower(); + String fixed_bn = p_bone_name.to_snake_case(); LocalVector<String> left_words; left_words.push_back("(?<![a-zA-Z])left"); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 37c79d4974..c4a32d6d4b 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -487,21 +487,21 @@ void CanvasItemEditor::shortcut_input(const Ref<InputEvent> &p_ev) { if (k.is_valid()) { if (k->get_keycode() == Key::CTRL || k->get_keycode() == Key::ALT || k->get_keycode() == Key::SHIFT) { - viewport->update(); + viewport->queue_redraw(); } if (k->is_pressed() && !k->is_ctrl_pressed() && !k->is_echo() && (grid_snap_active || _is_grid_visible())) { if (multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->matches_event(p_ev)) { // Multiply the grid size grid_step_multiplier = MIN(grid_step_multiplier + 1, 12); - viewport->update(); + viewport->queue_redraw(); } else if (divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->matches_event(p_ev)) { // Divide the grid size Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1); if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) { grid_step_multiplier--; } - viewport->update(); + viewport->queue_redraw(); } } } @@ -758,7 +758,7 @@ bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_po } } } - viewport->update(); + viewport->queue_redraw(); return still_selected; } @@ -875,15 +875,15 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite } } } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } void CanvasItemEditor::_snap_changed() { static_cast<SnapDialog *>(snap_dialog)->get_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step, snap_scale_step); grid_step_multiplier = 0; - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::_selection_result_pressed(int p_result) { @@ -983,7 +983,7 @@ void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) { case GRID_VISIBILITY_SHOW_WHEN_SNAPPING: case GRID_VISIBILITY_HIDE: grid_visibility = (GridVisibility)p_id; - viewport->update(); + viewport->queue_redraw(); view_menu->get_popup()->hide(); return; } @@ -1010,7 +1010,7 @@ void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) { break; } } - viewport->update(); + viewport->queue_redraw(); } bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_event) { @@ -1105,7 +1105,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve drag_to = xform.affine_inverse().xform(m->get_position()); dragged_guide_pos = xform.xform(snap_point(drag_to, SNAP_GRID | SNAP_PIXEL | SNAP_OTHER_NODES)); - viewport->update(); + viewport->queue_redraw(); return true; } @@ -1128,14 +1128,14 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->create_action(TTR("Move Vertical Guide")); undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } else { vguides.push_back(edited.x); undo_redo->create_action(TTR("Create Vertical Guide")); undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } else { @@ -1148,7 +1148,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides); } undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } @@ -1161,14 +1161,14 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->create_action(TTR("Move Horizontal Guide")); undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } else { hguides.push_back(edited.y); undo_redo->create_action(TTR("Create Horizontal Guide")); undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } else { @@ -1181,7 +1181,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); } undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } @@ -1197,7 +1197,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", prev_vguides); undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", prev_hguides); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } } @@ -1205,7 +1205,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1380,7 +1380,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection); _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1430,7 +1430,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { //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())); - viewport->update(); + viewport->queue_redraw(); } return true; } @@ -1463,7 +1463,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection); _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1625,7 +1625,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection); _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1824,7 +1824,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } @@ -1834,7 +1834,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -1963,7 +1963,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { } _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } @@ -1971,7 +1971,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection); _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -2096,7 +2096,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } @@ -2106,7 +2106,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -2214,7 +2214,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } _reset_drag(); } - viewport->update(); + viewport->queue_redraw(); return true; } @@ -2339,7 +2339,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (!b->is_shift_pressed()) { // Clear the selection if not additive editor_selection->clear(); - viewport->update(); + viewport->queue_redraw(); selected_from_canvas = true; }; @@ -2415,21 +2415,21 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { } _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } if (b.is_valid() && b->is_pressed() && b->get_button_index() == MouseButton::RIGHT) { // Cancel box selection _reset_drag(); - viewport->update(); + viewport->queue_redraw(); return true; } if (m.is_valid()) { // Update box selection box_selecting_to = transform.affine_inverse().xform(m->get_position()); - viewport->update(); + viewport->queue_redraw(); return true; } } @@ -2437,7 +2437,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (k.is_valid() && k->is_pressed() && k->get_keycode() == Key::ESCAPE && drag_type == DRAG_NONE && tool == TOOL_SELECT) { // Unselect everything editor_selection->clear(); - viewport->update(); + viewport->queue_redraw(); } return false; } @@ -2463,12 +2463,12 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) { ruler_tool_active = false; } - viewport->update(); + viewport->queue_redraw(); return true; } if (m.is_valid() && (ruler_tool_active || (grid_snap_active && previous_origin != ruler_tool_origin))) { - viewport->update(); + viewport->queue_redraw(); return true; } @@ -2480,7 +2480,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { if (m.is_valid()) { Point2 click = transform.affine_inverse().xform(m->get_position()); - // Checks if the hovered items changed, update the viewport if so + // Checks if the hovered items changed, redraw the viewport if so Vector<_SelectResult> hovering_results_items; _get_canvas_items_at_pos(click, hovering_results_items); hovering_results_items.sort(); @@ -2502,7 +2502,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { hovering_results_tmp.push_back(hover_result); } - // Check if changed, if so, update. + // Check if changed, if so, redraw. bool changed = false; if (hovering_results_tmp.size() == hovering_results.size()) { for (int i = 0; i < hovering_results_tmp.size(); i++) { @@ -2519,7 +2519,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { if (changed) { hovering_results = hovering_results_tmp; - viewport->update(); + viewport->queue_redraw(); } return true; @@ -3827,7 +3827,7 @@ void CanvasItemEditor::_draw_viewport() { void CanvasItemEditor::update_viewport() { _update_scrollbars(); - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::set_current_tool(Tool p_tool) { @@ -3895,7 +3895,7 @@ void CanvasItemEditor::_notification(int p_what) { Transform2D xform = canvas_item->get_transform(); if (rect != se->prev_rect || xform != se->prev_xform) { - viewport->update(); + viewport->queue_redraw(); se->prev_rect = rect; se->prev_xform = xform; } @@ -3917,7 +3917,7 @@ void CanvasItemEditor::_notification(int p_what) { se->prev_anchors[SIDE_RIGHT] = anchors[SIDE_RIGHT]; se->prev_anchors[SIDE_TOP] = anchors[SIDE_TOP]; se->prev_anchors[SIDE_BOTTOM] = anchors[SIDE_BOTTOM]; - viewport->update(); + viewport->queue_redraw(); } } @@ -3933,7 +3933,7 @@ void CanvasItemEditor::_notification(int p_what) { for (KeyValue<BoneKey, BoneList> &E : bone_list) { Object *b = ObjectDB::get_instance(E.key.from); if (!b) { - viewport->update(); + viewport->queue_redraw(); break; } @@ -3946,13 +3946,13 @@ void CanvasItemEditor::_notification(int p_what) { if (global_xform != E.value.xform) { E.value.xform = global_xform; - viewport->update(); + viewport->queue_redraw(); } Bone2D *bone = Object::cast_to<Bone2D>(b); if (bone && bone->get_length() != E.value.length) { E.value.length = bone->get_length(); - viewport->update(); + viewport->queue_redraw(); } } } break; @@ -4106,7 +4106,7 @@ void CanvasItemEditor::_update_scroll(real_t) { view_offset.x = h_scroll->get_value(); view_offset.y = v_scroll->get_value(); - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::_zoom_on_position(real_t p_zoom, Point2 p_position) { @@ -4148,12 +4148,12 @@ void CanvasItemEditor::_shortcut_zoom_set(real_t p_zoom) { void CanvasItemEditor::_button_toggle_smart_snap(bool p_status) { smart_snap_active = p_status; - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::_button_toggle_grid_snap(bool p_status) { grid_snap_active = p_status; - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::_button_override_camera(bool p_pressed) { @@ -4174,7 +4174,7 @@ void CanvasItemEditor::_button_tool_select(int p_index) { tool = (Tool)p_index; - viewport->update(); + viewport->queue_redraw(); _update_cursor(); } @@ -4276,25 +4276,25 @@ void CanvasItemEditor::_popup_callback(int p_op) { show_origin = !show_origin; int idx = view_menu->get_popup()->get_item_index(SHOW_ORIGIN); view_menu->get_popup()->set_item_checked(idx, show_origin); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_VIEWPORT: { show_viewport = !show_viewport; int idx = view_menu->get_popup()->get_item_index(SHOW_VIEWPORT); view_menu->get_popup()->set_item_checked(idx, show_viewport); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_EDIT_LOCKS: { show_edit_locks = !show_edit_locks; int idx = view_menu->get_popup()->get_item_index(SHOW_EDIT_LOCKS); view_menu->get_popup()->set_item_checked(idx, show_edit_locks); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_TRANSFORMATION_GIZMOS: { show_transformation_gizmos = !show_transformation_gizmos; int idx = view_menu->get_popup()->get_item_index(SHOW_TRANSFORMATION_GIZMOS); view_menu->get_popup()->set_item_checked(idx, show_transformation_gizmos); - viewport->update(); + viewport->queue_redraw(); } break; case SNAP_USE_NODE_PARENT: { snap_node_parent = !snap_node_parent; @@ -4340,7 +4340,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { snap_relative = !snap_relative; int idx = snap_config_menu->get_popup()->get_item_index(SNAP_RELATIVE); snap_config_menu->get_popup()->set_item_checked(idx, snap_relative); - viewport->update(); + viewport->queue_redraw(); } break; case SNAP_USE_PIXEL: { snap_pixel = !snap_pixel; @@ -4370,20 +4370,20 @@ void CanvasItemEditor::_popup_callback(int p_op) { show_helpers = !show_helpers; int idx = view_menu->get_popup()->get_item_index(SHOW_HELPERS); view_menu->get_popup()->set_item_checked(idx, show_helpers); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_RULERS: { show_rulers = !show_rulers; int idx = view_menu->get_popup()->get_item_index(SHOW_RULERS); view_menu->get_popup()->set_item_checked(idx, show_rulers); _update_scrollbars(); - viewport->update(); + viewport->queue_redraw(); } break; case SHOW_GUIDES: { show_guides = !show_guides; int idx = view_menu->get_popup()->get_item_index(SHOW_GUIDES); view_menu->get_popup()->set_item_checked(idx, show_guides); - viewport->update(); + viewport->queue_redraw(); } break; case LOCK_SELECTED: { undo_redo->create_action(TTR("Lock Selected")); @@ -4403,8 +4403,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed"); } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } break; case UNLOCK_SELECTED: { @@ -4425,8 +4425,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed"); } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } break; case GROUP_SELECTED: { @@ -4447,8 +4447,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed"); } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } break; case UNGROUP_SELECTED: { @@ -4469,8 +4469,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed"); } - undo_redo->add_do_method(viewport, "update"); - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_do_method(viewport, "queue_redraw"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } break; @@ -4590,7 +4590,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_do_method(root, "remove_meta", "_edit_vertical_guides_"); undo_redo->add_undo_method(root, "set_meta", "_edit_vertical_guides_", vguides); } - undo_redo->add_undo_method(viewport, "update"); + undo_redo->add_undo_method(viewport, "queue_redraw"); undo_redo->commit_action(); } @@ -4704,7 +4704,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { real_t scale_y = viewport->get_size().y / rect.size.y; zoom = scale_x < scale_y ? scale_x : scale_y; zoom *= 0.90; - viewport->update(); + viewport->queue_redraw(); zoom_widget->set_zoom(zoom); call_deferred(SNAME("_popup_callback"), VIEW_CENTER_TO_SELECTION); } @@ -4930,7 +4930,7 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) { if (update_scrollbars) { _update_scrollbars(); } - viewport->update(); + viewport->queue_redraw(); } void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { @@ -4980,7 +4980,7 @@ CanvasItemEditor::CanvasItemEditor() { undo_redo = EditorNode::get_singleton()->get_undo_redo(); editor_selection = EditorNode::get_singleton()->get_editor_selection(); editor_selection->add_editor_plugin(this); - editor_selection->connect("selection_changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); + editor_selection->connect("selection_changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); editor_selection->connect("selection_changed", callable_mp(this, &CanvasItemEditor::_selection_changed)); SceneTreeDock::get_singleton()->connect("node_created", callable_mp(this, &CanvasItemEditor::_node_created)); diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index 69f32a3a98..bb6092755e 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -523,7 +523,7 @@ ControlEditorPopupButton::ControlEditorPopupButton() { set_focus_mode(FOCUS_NONE); popup_panel = memnew(PopupPanel); - popup_panel->set_theme_type_variation("ControlEditorPopupButton"); + popup_panel->set_theme_type_variation("ControlEditorPopupPanel"); add_child(popup_panel); popup_panel->connect("about_to_popup", callable_mp(this, &ControlEditorPopupButton::_popup_visibility_changed).bind(true)); popup_panel->connect("popup_hide", callable_mp(this, &ControlEditorPopupButton::_popup_visibility_changed).bind(false)); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 013a9f10a4..9a31263f9a 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -87,7 +87,7 @@ void CurveEditor::set_curve(Ref<Curve> curve) { _hover_point = -1; _selected_tangent = TANGENT_NONE; - update(); + queue_redraw(); // Note: if you edit a curve, then set another, and try to undo, // it will normally apply on the previous curve, but you won't see it @@ -311,7 +311,7 @@ void CurveEditor::on_preset_item_selected(int preset_id) { } void CurveEditor::_curve_changed() { - update(); + queue_redraw(); // Point count can change in case of undo if (_selected_point >= _curve_ref->get_point_count()) { set_selected_point(-1); @@ -512,14 +512,14 @@ void CurveEditor::toggle_linear(TangentIndex tangent) { void CurveEditor::set_selected_point(int index) { if (index != _selected_point) { _selected_point = index; - update(); + queue_redraw(); } } void CurveEditor::set_hover_point_index(int index) { if (index != _hover_point) { _hover_point = index; - update(); + queue_redraw(); } } diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 0196214ceb..f4a718119e 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -255,7 +255,7 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const Ref<Resource> &p_f Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { String temp_path = EditorPaths::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text(); - cache_base = temp_path.plus_file("resthumb-" + cache_base); + cache_base = temp_path.path_join("resthumb-" + cache_base); //does not have it, try to load a cached thumbnail diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp index 935b0a5501..2df951518e 100644 --- a/editor/plugins/font_config_plugin.cpp +++ b/editor/plugins/font_config_plugin.cpp @@ -942,7 +942,7 @@ Size2 FontPreview::get_minimum_size() const { void FontPreview::set_data(const Ref<Font> &p_f) { prev_font = p_f; - update(); + queue_redraw(); } FontPreview::FontPreview() { diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index f368d5bea1..890090c899 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -50,7 +50,7 @@ void GradientEditor::_gradient_changed() { Vector<Gradient::Point> points = gradient->get_points(); set_points(points); set_interpolation_mode(gradient->get_interpolation_mode()); - update(); + queue_redraw(); editing = false; } @@ -83,7 +83,7 @@ void GradientEditor::reverse_gradient() { gradient->reverse(); set_points(gradient->get_points()); emit_signal(SNAME("ramp_changed")); - update(); + queue_redraw(); } GradientEditor::GradientEditor() { diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.cpp b/editor/plugins/gradient_texture_2d_editor_plugin.cpp index 5aaf450d3f..dc01a52bb3 100644 --- a/editor/plugins/gradient_texture_2d_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_2d_editor_plugin.cpp @@ -89,17 +89,17 @@ void GradientTexture2DEditorRect::gui_input(const Ref<InputEvent> &p_event) { void GradientTexture2DEditorRect::set_texture(Ref<GradientTexture2D> &p_texture) { texture = p_texture; - texture->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); + texture->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::queue_redraw)); } void GradientTexture2DEditorRect::set_snap_enabled(bool p_snap_enabled) { snap_enabled = p_snap_enabled; - update(); + queue_redraw(); } void GradientTexture2DEditorRect::set_snap_size(float p_snap_size) { snap_size = p_snap_size; - update(); + queue_redraw(); } void GradientTexture2DEditorRect::_notification(int p_what) { diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 74a6e90a6d..709f19016c 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -153,7 +153,7 @@ MaterialEditor::MaterialEditor() { vc->add_child(viewport); viewport->set_disable_input(true); viewport->set_transparent_background(true); - viewport->set_msaa(Viewport::MSAA_4X); + viewport->set_msaa_3d(Viewport::MSAA_4X); camera = memnew(Camera3D); camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 3))); diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 980d2974a0..90d50d30d9 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -112,7 +112,7 @@ MeshEditor::MeshEditor() { viewport->set_world_3d(world_3d); //use own world add_child(viewport); viewport->set_disable_input(true); - viewport->set_msaa(Viewport::MSAA_4X); + viewport->set_msaa_3d(Viewport::MSAA_4X); set_stretch(true); camera = memnew(Camera3D); camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 1.1))); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index f165b83999..b771faeb33 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -99,7 +99,7 @@ void ViewportRotationControl::_notification(int p_what) { axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor"))); - update(); + queue_redraw(); if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { connect("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited)); @@ -247,13 +247,13 @@ void ViewportRotationControl::_update_focus() { } if (focused_axis != original_focus) { - update(); + queue_redraw(); } } void ViewportRotationControl::_on_mouse_exited() { focused_axis = -2; - update(); + queue_redraw(); } void ViewportRotationControl::set_viewport(Node3DEditorViewport *p_viewport) { @@ -350,7 +350,7 @@ void Node3DEditorViewport::_update_camera(real_t p_interp_delta) { } update_transform_gizmo_view(); - rotation_control->update(); + rotation_control->queue_redraw(); spatial_editor->update_grid(); } } @@ -1614,7 +1614,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } - surface->update(); + surface->queue_redraw(); } else { if (_edit.gizmo.is_valid()) { _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false); @@ -1632,7 +1632,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (cursor.region_select) { _select_region(); cursor.region_select = false; - surface->update(); + surface->queue_redraw(); } } @@ -1657,7 +1657,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { _edit.mode = TRANSFORM_NONE; set_message(""); } - surface->update(); + surface->queue_redraw(); } } break; @@ -1741,7 +1741,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (cursor.region_select) { cursor.region_end = m->get_position(); - surface->update(); + surface->queue_redraw(); return; } @@ -2244,12 +2244,12 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) { void Node3DEditorViewport::scale_fov(real_t p_fov_offset) { cursor.fov_scale = CLAMP(cursor.fov_scale + p_fov_offset, 0.1, 2.5); - surface->update(); + surface->queue_redraw(); } void Node3DEditorViewport::reset_fov() { cursor.fov_scale = 1.0; - surface->update(); + surface->queue_redraw(); } void Node3DEditorViewport::scale_cursor_distance(real_t scale) { @@ -2268,7 +2268,7 @@ void Node3DEditorViewport::scale_cursor_distance(real_t scale) { } zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S; - surface->update(); + surface->queue_redraw(); } void Node3DEditorViewport::scale_freelook_speed(real_t scale) { @@ -2281,7 +2281,7 @@ void Node3DEditorViewport::scale_freelook_speed(real_t scale) { } zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S; - surface->update(); + surface->queue_redraw(); } Point2i Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const { @@ -2393,8 +2393,8 @@ void Node3DEditorViewport::_project_settings_changed() { // Update MSAA, screen-space AA and debanding if changed - const int msaa_mode = ProjectSettings::get_singleton()->get("rendering/anti_aliasing/quality/msaa"); - viewport->set_msaa(Viewport::MSAA(msaa_mode)); + const int msaa_mode = ProjectSettings::get_singleton()->get("rendering/anti_aliasing/quality/msaa_3d"); + viewport->set_msaa_3d(Viewport::MSAA(msaa_mode)); const int ssaa_mode = GLOBAL_GET("rendering/anti_aliasing/quality/screen_space_aa"); viewport->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode)); const bool use_taa = GLOBAL_GET("rendering/anti_aliasing/quality/use_taa"); @@ -2454,7 +2454,7 @@ void Node3DEditorViewport::_notification(int p_what) { if (zoom_indicator_delay > 0) { zoom_indicator_delay -= delta; if (zoom_indicator_delay <= 0) { - surface->update(); + surface->queue_redraw(); zoom_limit_label->hide(); } } @@ -2472,7 +2472,7 @@ void Node3DEditorViewport::_notification(int p_what) { previewing = cam; previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera()); - surface->update(); + surface->queue_redraw(); } } @@ -2538,13 +2538,13 @@ void Node3DEditorViewport::_notification(int p_what) { if (message_time > 0) { if (message != last_message) { - surface->update(); + surface->queue_redraw(); last_message = message; } message_time -= get_physics_process_delta_time(); if (message_time < 0) { - surface->update(); + surface->queue_redraw(); } } @@ -3356,13 +3356,13 @@ void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { if (!preview) { preview_camera->hide(); } - surface->update(); + surface->queue_redraw(); } else { previewing = preview; previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace - surface->update(); + surface->queue_redraw(); } } @@ -3384,7 +3384,7 @@ void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) { preview_camera->show(); } view_menu->show(); - surface->update(); + surface->queue_redraw(); } } @@ -3619,7 +3619,7 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) { previewing = Object::cast_to<Camera3D>(pv); previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace - surface->update(); + surface->queue_redraw(); preview_camera->set_pressed(true); preview_camera->show(); } @@ -4392,7 +4392,7 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { } spatial_editor->update_transform_gizmo(); - surface->update(); + surface->queue_redraw(); } break; @@ -4491,7 +4491,7 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { } spatial_editor->update_transform_gizmo(); - surface->update(); + surface->queue_redraw(); } break; @@ -4595,7 +4595,7 @@ void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) { } spatial_editor->update_transform_gizmo(); - surface->update(); + surface->queue_redraw(); } break; default: { @@ -4608,7 +4608,7 @@ void Node3DEditorViewport::finish_transform() { spatial_editor->update_transform_gizmo(); _edit.mode = TRANSFORM_NONE; _edit.instant = false; - surface->update(); + surface->queue_redraw(); } // Register a shortcut and also add it as an input action with the same events. @@ -5010,7 +5010,7 @@ void Node3DEditorViewportContainer::gui_input(const Ref<InputEvent> &p_event) { hovering_v = mm->get_position().y > (mid_h - v_sep / 2) && mm->get_position().y < (mid_h + v_sep / 2); if (was_hovering_h != hovering_h || was_hovering_v != hovering_v) { - update(); + queue_redraw(); } } @@ -5019,14 +5019,14 @@ void Node3DEditorViewportContainer::gui_input(const Ref<InputEvent> &p_event) { new_ratio = CLAMP(new_ratio, 40 / get_size().width, (get_size().width - 40) / get_size().width); ratio_h = new_ratio; queue_sort(); - update(); + queue_redraw(); } if (dragging_v) { real_t new_ratio = drag_begin_ratio.y + (mm->get_position().y - drag_begin_pos.y) / get_size().height; new_ratio = CLAMP(new_ratio, 40 / get_size().height, (get_size().height - 40) / get_size().height); ratio_v = new_ratio; queue_sort(); - update(); + queue_redraw(); } } } @@ -5036,7 +5036,7 @@ void Node3DEditorViewportContainer::_notification(int p_what) { case NOTIFICATION_MOUSE_ENTER: case NOTIFICATION_MOUSE_EXIT: { mouseover = (p_what == NOTIFICATION_MOUSE_ENTER); - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -7581,7 +7581,7 @@ void Node3DEditor::_preview_settings_changed() { Transform3D t; t.basis = Basis(Vector3(sun_rotation.x, sun_rotation.y, 0)); preview_sun->set_transform(t); - sun_direction->update(); + sun_direction->queue_redraw(); preview_sun->set_param(Light3D::PARAM_ENERGY, sun_energy->get_value()); preview_sun->set_param(Light3D::PARAM_SHADOW_MAX_DISTANCE, sun_max_distance->get_value()); preview_sun->set_color(sun_color->get_pick_color()); @@ -7615,7 +7615,7 @@ void Node3DEditor::_load_default_preview_settings() { sun_angle_altitude->set_value(-Math::rad_to_deg(sun_rotation.x)); sun_angle_azimuth->set_value(180.0 - Math::rad_to_deg(sun_rotation.y)); - sun_direction->update(); + sun_direction->queue_redraw(); environ_sky_color->set_pick_color(Color(0.385, 0.454, 0.55)); environ_ground_color->set_pick_color(Color(0.2, 0.169, 0.133)); environ_energy->set_value(1.0); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index e0298ebd5f..d38c5948cc 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -433,7 +433,7 @@ protected: static void _bind_methods(); public: - void update_surface() { surface->update(); } + void update_surface() { surface->queue_redraw(); } void update_transform_gizmo_view(); void set_can_preview(Camera3D *p_preview); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index b71cee8882..a652d1d12f 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -155,8 +155,8 @@ void Polygon2DEditor::_sync_bones() { undo_redo->add_undo_method(node, "_set_bones", prev_bones); undo_redo->add_do_method(this, "_update_bone_list"); undo_redo->add_undo_method(this, "_update_bone_list"); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -195,11 +195,11 @@ void Polygon2DEditor::_update_bone_list() { cb->connect("pressed", callable_mp(this, &Polygon2DEditor::_bone_paint_selected).bind(i)); } - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_bone_paint_selected(int p_index) { - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_uv_edit_mode_select(int p_mode) { @@ -269,7 +269,7 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) { } uv_edit->set_size(uv_edit->get_size()); // Necessary readjustment of the popup window. - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_uv_edit_popup_hide() { @@ -293,8 +293,8 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node, "set_uv", points); undo_redo->add_undo_method(node, "set_uv", uvs); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -314,8 +314,8 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node, "set_uv", points); undo_redo->add_undo_method(node, "set_uv", uvs); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } break; case UVEDIT_UV_TO_POLYGON: { @@ -328,8 +328,8 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->create_action(TTR("Create Polygon")); undo_redo->add_do_method(node, "set_polygon", uvs); undo_redo->add_undo_method(node, "set_polygon", points); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } break; case UVEDIT_UV_CLEAR: { @@ -340,8 +340,8 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->create_action(TTR("Create UV Map")); undo_redo->add_do_method(node, "set_uv", Vector<Vector2>()); undo_redo->add_undo_method(node, "set_uv", uvs); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } break; case UVEDIT_GRID_SETTINGS: { @@ -391,8 +391,8 @@ void Polygon2DEditor::_update_polygon_editing_state() { void Polygon2DEditor::_commit_action() { // Makes that undo/redoing actions made outside of the UV editor still affect its polygon. - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->add_do_method(CanvasItemEditor::get_singleton(), "update_viewport"); undo_redo->add_undo_method(CanvasItemEditor::get_singleton(), "update_viewport"); undo_redo->commit_action(); @@ -406,31 +406,31 @@ void Polygon2DEditor::_set_use_snap(bool p_use) { void Polygon2DEditor::_set_show_grid(bool p_show) { snap_show_grid = p_show; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "show_grid", p_show); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_set_snap_off_x(real_t p_val) { snap_offset.x = p_val; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "snap_offset", snap_offset); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_set_snap_off_y(real_t p_val) { snap_offset.y = p_val; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "snap_offset", snap_offset); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_set_snap_step_x(real_t p_val) { snap_step.x = p_val; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "snap_step", snap_step); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_set_snap_step_y(real_t p_val) { snap_step.y = p_val; EditorSettings::get_singleton()->set_project_metadata("polygon_2d_uv_editor", "snap_step", snap_step); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_uv_mode(int p_mode) { @@ -495,7 +495,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { node->set_uv(points_prev); node->set_internal_vertex_count(0); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } else { Vector2 tuv = mtx.affine_inverse().xform(snap_point(mb->get_position())); @@ -514,8 +514,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->add_undo_method(node, "_set_bones", uv_create_bones_prev); undo_redo->add_do_method(this, "_update_polygon_editing_state"); undo_redo->add_undo_method(this, "_update_polygon_editing_state"); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); uv_drag = false; uv_create = false; @@ -566,8 +566,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->add_undo_method(node, "set_internal_vertex_count", internal_vertices); undo_redo->add_do_method(this, "_update_polygon_editing_state"); undo_redo->add_undo_method(this, "_update_polygon_editing_state"); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -621,8 +621,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->add_undo_method(node, "set_internal_vertex_count", internal_vertices); undo_redo->add_do_method(this, "_update_polygon_editing_state"); undo_redo->add_undo_method(this, "_update_polygon_editing_state"); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -679,8 +679,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->create_action(TTR("Add Custom Polygon")); undo_redo->add_do_method(node, "set_polygons", polygons); undo_redo->add_undo_method(node, "set_polygons", node->get_polygons()); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -720,8 +720,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->create_action(TTR("Remove Custom Polygon")); undo_redo->add_do_method(node, "set_polygons", polygons); undo_redo->add_undo_method(node, "set_polygons", node->get_polygons()); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } } @@ -748,15 +748,15 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->create_action(TTR("Transform UV Map")); undo_redo->add_do_method(node, "set_uv", node->get_uv()); undo_redo->add_undo_method(node, "set_uv", points_prev); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } else if (uv_edit_mode[1]->is_pressed() && uv_move_current == UV_MODE_EDIT_POINT) { // Edit polygon. undo_redo->create_action(TTR("Transform Polygon")); undo_redo->add_do_method(node, "set_polygon", node->get_polygon()); undo_redo->add_undo_method(node, "set_polygon", points_prev); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); } @@ -767,8 +767,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->create_action(TTR("Paint Bone Weights")); undo_redo->add_do_method(node, "set_bone_weights", bone_painting_bone, node->get_bone_weights(bone_painting_bone)); undo_redo->add_undo_method(node, "set_bone_weights", bone_painting_bone, prev_weights); - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->add_do_method(uv_edit_draw, "queue_redraw"); + undo_redo->add_undo_method(uv_edit_draw, "queue_redraw"); undo_redo->commit_action(); bone_painting = false; } @@ -780,7 +780,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { node->set_bone_weights(bone_painting_bone, prev_weights); } - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } } @@ -906,14 +906,14 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { node->set_bone_weights(bone_painting_bone, painted_weights); } - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); CanvasItemEditor::get_singleton()->update_viewport(); } else if (polygon_create.size()) { uv_create_to = mtx.affine_inverse().xform(mm->get_position()); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } else if (uv_mode == UV_MODE_PAINT_WEIGHT || uv_mode == UV_MODE_CLEAR_WEIGHT) { bone_paint_pos = mm->get_position(); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } } @@ -954,7 +954,7 @@ void Polygon2DEditor::_uv_scroll_changed(real_t) { uv_draw_ofs.x = uv_hscroll->get_value(); uv_draw_ofs.y = uv_vscroll->get_value(); uv_draw_zoom = uv_zoom->get_value(); - uv_edit_draw->update(); + uv_edit_draw->queue_redraw(); } void Polygon2DEditor::_uv_draw() { diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 80566419b1..21647d1b69 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -196,7 +196,7 @@ void ResourcePreloaderEditor::_update_library() { String type = r->get_class(); ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(type, "Object")); - ti->set_tooltip(0, TTR("Instance:") + " " + r->get_path() + "\n" + TTR("Type:") + " " + type); + ti->set_tooltip_text(0, TTR("Instance:") + " " + r->get_path() + "\n" + TTR("Type:") + " " + type); ti->set_text(1, r->get_path()); ti->set_editable(1, false); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 98be34cb86..aa1d630372 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1540,7 +1540,7 @@ void ScriptEditor::_show_save_theme_as_dialog() { file_dialog_option = THEME_SAVE_AS; file_dialog->clear_filters(); file_dialog->add_filter("*.tet"); - file_dialog->set_current_path(EditorPaths::get_singleton()->get_text_editor_themes_dir().plus_file(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))); + file_dialog->set_current_path(EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))); file_dialog->popup_file_dialog(); file_dialog->set_title(TTR("Save Theme As...")); } @@ -2038,7 +2038,7 @@ void ScriptEditor::_update_script_names() { } break; case DISPLAY_DIR_AND_NAME: { if (!path.get_base_dir().get_file().is_empty()) { - sd.name = path.get_base_dir().get_file().plus_file(name); + sd.name = path.get_base_dir().get_file().path_join(name); } else { sd.name = name; } @@ -2064,7 +2064,7 @@ void ScriptEditor::_update_script_names() { name = name.get_file(); } break; case DISPLAY_DIR_AND_NAME: { - name = name.get_base_dir().get_file().plus_file(name.get_file()); + name = name.get_base_dir().get_file().path_join(name.get_file()); } break; default: break; @@ -3267,7 +3267,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { p_layout->set_value("ScriptEditor", "list_split_offset", list_split->get_split_offset()); // Save the cache. - script_editor_cache->save(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("script_editor_cache.cfg")); + script_editor_cache->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("script_editor_cache.cfg")); } void ScriptEditor::_help_class_open(const String &p_class) { @@ -3648,7 +3648,7 @@ ScriptEditor::ScriptEditor() { current_theme = ""; script_editor_cache.instantiate(); - script_editor_cache->load(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("script_editor_cache.cfg")); + script_editor_cache->load(EditorPaths::get_singleton()->get_project_settings_dir().path_join("script_editor_cache.cfg")); completion_cache = memnew(EditorScriptCodeCompletionCache); restoring_layout = false; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 5e7db17edf..fff956a05e 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -942,7 +942,7 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) { String ScriptTextEditor::_get_absolute_path(const String &rel_path) { String base_path = script->get_path().get_base_dir(); - String path = base_path.plus_file(rel_path); + String path = base_path.path_join(rel_path); return path.replace("///", "//").simplify_path(); } @@ -1124,15 +1124,15 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case EDIT_TOGGLE_FOLD_LINE: { tx->toggle_foldable_line(tx->get_caret_line()); - tx->update(); + tx->queue_redraw(); } break; case EDIT_FOLD_ALL_LINES: { tx->fold_all_lines(); - tx->update(); + tx->queue_redraw(); } break; case EDIT_UNFOLD_ALL_LINES: { tx->unfold_all_lines(); - tx->update(); + tx->queue_redraw(); } break; case EDIT_TOGGLE_COMMENT: { _edit_option_toggle_inline_comment(); @@ -1590,7 +1590,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data } } - String variable_name = String(node->get_name()).camelcase_to_underscore(true).validate_identifier(); + String variable_name = String(node->get_name()).to_snake_case().validate_identifier(); if (use_type) { text_to_drop += vformat("@onready var %s: %s = %s%s\n", variable_name, node->get_class_name(), is_unique ? "%" : "$", path); } else { @@ -1760,7 +1760,7 @@ void ScriptTextEditor::_color_changed(const Color &p_color) { code_editor->get_text_editor()->begin_complex_operation(); code_editor->get_text_editor()->set_line(color_position.x, line_with_replaced_args); code_editor->get_text_editor()->end_complex_operation(); - code_editor->get_text_editor()->update(); + code_editor->get_text_editor()->queue_redraw(); } void ScriptTextEditor::_prepare_edit_menu() { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 53bc6fbdf4..6674d15268 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -1398,12 +1398,12 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) { switch (p_index) { case FILE_NEW: { String base_path = FileSystemDock::get_singleton()->get_current_path().get_base_dir(); - shader_create_dialog->config(base_path.plus_file("new_shader"), false, false, 0); + shader_create_dialog->config(base_path.path_join("new_shader"), false, false, 0); shader_create_dialog->popup_centered(); } break; case FILE_NEW_INCLUDE: { String base_path = FileSystemDock::get_singleton()->get_current_path().get_base_dir(); - shader_create_dialog->config(base_path.plus_file("new_shader"), false, false, 2); + shader_create_dialog->config(base_path.path_join("new_shader"), false, false, 2); shader_create_dialog->popup_centered(); } break; case FILE_OPEN: { diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index f21adabffb..026d957407 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -182,27 +182,27 @@ void BoneTransformEditor::_update_properties() { if (split[2] == "enabled") { enabled_checkbox->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); enabled_checkbox->update_property(); - enabled_checkbox->update(); + enabled_checkbox->queue_redraw(); } if (split[2] == "position") { position_property->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); position_property->update_property(); - position_property->update(); + position_property->queue_redraw(); } if (split[2] == "rotation") { rotation_property->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); rotation_property->update_property(); - rotation_property->update(); + rotation_property->queue_redraw(); } if (split[2] == "scale") { scale_property->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); scale_property->update_property(); - scale_property->update(); + scale_property->queue_redraw(); } if (split[2] == "rest") { rest_matrix->set_read_only(E.usage & PROPERTY_USAGE_READ_ONLY); rest_matrix->update_property(); - rest_matrix->update(); + rest_matrix->queue_redraw(); } } } @@ -690,8 +690,6 @@ void Skeleton3DEditor::update_editors() { void Skeleton3DEditor::create_editors() { set_h_size_flags(SIZE_EXPAND_FILL); - add_theme_constant_override("separation", 0); - set_focus_mode(FOCUS_ALL); Node3DEditor *ne = Node3DEditor::get_singleton(); @@ -823,20 +821,11 @@ void Skeleton3DEditor::create_editors() { void Skeleton3DEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { - edit_mode_button->set_icon(get_theme_icon(SNAME("ToolBoneSelect"), SNAME("EditorIcons"))); - key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); - key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); - key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); - key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); - key_insert_all_button->set_icon(get_theme_icon(SNAME("NewKey"), SNAME("EditorIcons"))); - get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Object::CONNECT_ONESHOT); - break; - } case NOTIFICATION_ENTER_TREE: { create_editors(); update_joint_tree(); update_editors(); + joint_tree->connect("item_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_selection_changed)); joint_tree->connect("item_mouse_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_rmb_select)); #ifdef TOOLS_ENABLED @@ -845,8 +834,23 @@ void Skeleton3DEditor::_notification(int p_what) { skeleton->connect("bone_enabled_changed", callable_mp(this, &Skeleton3DEditor::_bone_enabled_changed)); skeleton->connect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible)); #endif - break; - } + + get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Object::CONNECT_ONESHOT); + } break; + case NOTIFICATION_READY: { + // Will trigger NOTIFICATION_THEME_CHANGED, but won't cause any loops if called here. + add_theme_constant_override("separation", 0); + } break; + case NOTIFICATION_THEME_CHANGED: { + edit_mode_button->set_icon(get_theme_icon(SNAME("ToolBoneSelect"), SNAME("EditorIcons"))); + key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); + key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); + key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); + key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); + key_insert_all_button->set_icon(get_theme_icon(SNAME("NewKey"), SNAME("EditorIcons"))); + + update_joint_tree(); + } break; } } diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index e45c907e86..615fd5dba9 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -128,7 +128,7 @@ void Sprite2DEditor::_menu_option(int p_option) { _update_mesh_data(); debug_uv_dialog->popup_centered(); - debug_uv->update(); + debug_uv->queue_redraw(); } break; case MENU_OPTION_CONVERT_TO_POLYGON_2D: { @@ -137,7 +137,7 @@ void Sprite2DEditor::_menu_option(int p_option) { _update_mesh_data(); debug_uv_dialog->popup_centered(); - debug_uv->update(); + debug_uv->queue_redraw(); } break; case MENU_OPTION_CREATE_COLLISION_POLY_2D: { debug_uv_dialog->set_ok_button_text(TTR("Create CollisionPolygon2D")); @@ -145,7 +145,7 @@ void Sprite2DEditor::_menu_option(int p_option) { _update_mesh_data(); debug_uv_dialog->popup_centered(); - debug_uv->update(); + debug_uv->queue_redraw(); } break; case MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D: { @@ -154,7 +154,7 @@ void Sprite2DEditor::_menu_option(int p_option) { _update_mesh_data(); debug_uv_dialog->popup_centered(); - debug_uv->update(); + debug_uv->queue_redraw(); } break; } @@ -302,7 +302,7 @@ void Sprite2DEditor::_update_mesh_data() { } } - debug_uv->update(); + debug_uv->queue_redraw(); } void Sprite2DEditor::_create_node() { diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 87f0fc4ad0..9508835442 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -182,7 +182,7 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { if (last_frame_selected != idx || idx != -1) { last_frame_selected = idx; - split_sheet_preview->update(); + split_sheet_preview->queue_redraw(); } } @@ -208,7 +208,7 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { } last_frame_selected = idx; - split_sheet_preview->update(); + split_sheet_preview->queue_redraw(); } } } @@ -307,7 +307,7 @@ void SpriteFramesEditor::_sheet_select_clear_all_frames() { frames_selected.clear(); } - split_sheet_preview->update(); + split_sheet_preview->queue_redraw(); } void SpriteFramesEditor::_sheet_spin_changed(double p_value, int p_dominant_param) { @@ -363,7 +363,7 @@ void SpriteFramesEditor::_sheet_spin_changed(double p_value, int p_dominant_para frames_selected.clear(); last_frame_selected = -1; - split_sheet_preview->update(); + split_sheet_preview->queue_redraw(); } void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) { diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index d4baff34e2..fffcce6d9a 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -36,7 +36,7 @@ bool StyleBoxPreview::grid_preview_enabled = true; void StyleBoxPreview::_grid_preview_toggled(bool p_active) { grid_preview_enabled = p_active; - preview->update(); + preview->queue_redraw(); } bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) { @@ -66,7 +66,7 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) { } void StyleBoxPreview::_sb_changed() { - preview->update(); + preview->queue_redraw(); } void StyleBoxPreview::_notification(int p_what) { diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.cpp b/editor/plugins/sub_viewport_preview_editor_plugin.cpp index c8bb0cd56f..074a9708b7 100644 --- a/editor/plugins/sub_viewport_preview_editor_plugin.cpp +++ b/editor/plugins/sub_viewport_preview_editor_plugin.cpp @@ -39,7 +39,7 @@ void EditorInspectorPluginSubViewportPreview::parse_begin(Object *p_object) { TexturePreview *sub_viewport_preview = memnew(TexturePreview(sub_viewport->get_texture(), false)); // Otherwise `sub_viewport_preview`'s `texture_display` doesn't update properly when `sub_viewport`'s size changes. - sub_viewport->connect("size_changed", callable_mp((CanvasItem *)sub_viewport_preview->get_texture_display(), &CanvasItem::update)); + sub_viewport->connect("size_changed", callable_mp((CanvasItem *)sub_viewport_preview->get_texture_display(), &CanvasItem::queue_redraw)); add_custom_control(sub_viewport_preview); } diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 0900415b04..76332b2d10 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -339,15 +339,15 @@ void TextEditor::_edit_option(int p_op) { } break; case EDIT_TOGGLE_FOLD_LINE: { tx->toggle_foldable_line(tx->get_caret_line()); - tx->update(); + tx->queue_redraw(); } break; case EDIT_FOLD_ALL_LINES: { tx->fold_all_lines(); - tx->update(); + tx->queue_redraw(); } break; case EDIT_UNFOLD_ALL_LINES: { tx->unfold_all_lines(); - tx->update(); + tx->queue_redraw(); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { trim_trailing_whitespace(); diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 64cafa17f3..c2517b4b79 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -53,7 +53,7 @@ void Texture3DEditor::_texture_changed() { if (!is_visible()) { return; } - update(); + queue_redraw(); } void Texture3DEditor::_update_material() { @@ -124,7 +124,7 @@ void Texture3DEditor::edit(Ref<Texture3D> p_texture) { } texture->connect("changed", callable_mp(this, &Texture3DEditor::_texture_changed)); - update(); + queue_redraw(); texture_rect->set_material(material); setting = true; layer->set_max(texture->get_depth() - 1); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 2c6f70463d..1118f18605 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -64,7 +64,7 @@ void TextureLayeredEditor::_texture_changed() { if (!is_visible()) { return; } - update(); + queue_redraw(); } void TextureLayeredEditor::_update_material() { @@ -190,7 +190,7 @@ void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) { } texture->connect("changed", callable_mp(this, &TextureLayeredEditor::_texture_changed)); - update(); + queue_redraw(); texture_rect->set_material(materials[texture->get_layered_type()]); setting = true; if (texture->get_layered_type() == TextureLayered::LAYERED_TYPE_2D_ARRAY) { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 50a7dc7f96..f0e3619060 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -381,8 +381,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } undo_redo->add_do_method(this, "_update_rect"); undo_redo->add_undo_method(this, "_update_rect"); - undo_redo->add_do_method(edit_draw, "update"); - undo_redo->add_undo_method(edit_draw, "update"); + undo_redo->add_do_method(edit_draw, "queue_redraw"); + undo_redo->add_undo_method(edit_draw, "queue_redraw"); undo_redo->commit_action(); break; } @@ -455,8 +455,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } undo_redo->add_do_method(this, "_update_rect"); undo_redo->add_undo_method(this, "_update_rect"); - undo_redo->add_do_method(edit_draw, "update"); - undo_redo->add_undo_method(edit_draw, "update"); + undo_redo->add_do_method(edit_draw, "queue_redraw"); + undo_redo->add_undo_method(edit_draw, "queue_redraw"); undo_redo->commit_action(); drag = false; creating = false; @@ -477,7 +477,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } else { apply_rect(rect_prev); rect = rect_prev; - edit_draw->update(); + edit_draw->queue_redraw(); drag_index = -1; } } @@ -546,7 +546,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { rect = Rect2(drag_from, Size2()); rect.expand_to(new_pos); apply_rect(rect); - edit_draw->update(); + edit_draw->queue_redraw(); return; } @@ -601,7 +601,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } break; } } - edit_draw->update(); + edit_draw->queue_redraw(); } } @@ -642,7 +642,7 @@ void TextureRegionEditor::_scroll_changed(float) { draw_ofs.x = hscroll->get_value(); draw_ofs.y = vscroll->get_value(); - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_mode(int p_mode) { @@ -658,37 +658,37 @@ void TextureRegionEditor::_set_snap_mode(int p_mode) { _update_autoslice(); } - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_off_x(float p_val) { snap_offset.x = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_off_y(float p_val) { snap_offset.y = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_step_x(float p_val) { snap_step.x = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_step_y(float p_val) { snap_step.y = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_sep_x(float p_val) { snap_separation.x = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_set_snap_sep_y(float p_val) { snap_separation.y = p_val; - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_zoom_on_position(float p_zoom, Point2 p_position) { @@ -702,7 +702,7 @@ void TextureRegionEditor::_zoom_on_position(float p_zoom, Point2 p_position) { ofs = ofs / prev_zoom - ofs / draw_zoom; draw_ofs = (draw_ofs + ofs).round(); - edit_draw->update(); + edit_draw->queue_redraw(); } void TextureRegionEditor::_zoom_in() { @@ -933,7 +933,7 @@ void TextureRegionEditor::edit(Object *p_obj) { obj_styleBox = Ref<StyleBoxTexture>(nullptr); atlas_tex = Ref<AtlasTexture>(nullptr); } - edit_draw->update(); + edit_draw->queue_redraw(); popup_centered_ratio(0.5); request_center = true; } @@ -963,7 +963,7 @@ void TextureRegionEditor::_edit_region() { _zoom_reset(); hscroll->hide(); vscroll->hide(); - edit_draw->update(); + edit_draw->queue_redraw(); return; } @@ -979,7 +979,7 @@ void TextureRegionEditor::_edit_region() { } _update_rect(); - edit_draw->update(); + edit_draw->queue_redraw(); } Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const { diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index ea8da1e86d..8cc96201e7 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -56,7 +56,7 @@ void ThemeEditorPreview::add_preview_overlay(Control *p_overlay) { void ThemeEditorPreview::_propagate_redraw(Control *p_at) { p_at->notification(NOTIFICATION_THEME_CHANGED); p_at->update_minimum_size(); - p_at->update(); + p_at->queue_redraw(); for (int i = 0; i < p_at->get_child_count(); i++) { Control *a = Object::cast_to<Control>(p_at->get_child(i)); if (a) { @@ -174,7 +174,7 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even if (mm.is_valid()) { Vector2 mp = preview_content->get_local_mouse_position(); hovered_control = _find_hovered_control(preview_content, mp); - picker_overlay->update(); + picker_overlay->queue_redraw(); } // Forward input to the scroll container underneath to allow scrolling. @@ -183,7 +183,7 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even void ThemeEditorPreview::_reset_picker_overlay() { hovered_control = nullptr; - picker_overlay->update(); + picker_overlay->queue_redraw(); } void ThemeEditorPreview::_notification(int p_what) { diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index 8d2b150d6d..5f0576a675 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -404,12 +404,12 @@ void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_ _update_zoom_and_panning(); // Update. - base_tiles_draw->update(); - base_tiles_texture_grid->update(); - base_tiles_shape_grid->update(); - alternatives_draw->update(); - background_left->update(); - background_right->update(); + base_tiles_draw->queue_redraw(); + base_tiles_texture_grid->queue_redraw(); + base_tiles_shape_grid->queue_redraw(); + alternatives_draw->queue_redraw(); + background_left->queue_redraw(); + background_right->queue_redraw(); } float TileAtlasView::get_zoom() const { @@ -493,13 +493,13 @@ Rect2i TileAtlasView::get_alternative_tile_rect(const Vector2i p_coords, int p_a return alternative_tiles_rect_cache[p_coords][p_alternative_tile]; } -void TileAtlasView::update() { - base_tiles_draw->update(); - base_tiles_texture_grid->update(); - base_tiles_shape_grid->update(); - alternatives_draw->update(); - background_left->update(); - background_right->update(); +void TileAtlasView::queue_redraw() { + base_tiles_draw->queue_redraw(); + base_tiles_texture_grid->queue_redraw(); + base_tiles_shape_grid->queue_redraw(); + alternatives_draw->queue_redraw(); + background_left->queue_redraw(); + background_right->queue_redraw(); } void TileAtlasView::_notification(int p_what) { diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h index 1c0b622bb1..c710eac107 100644 --- a/editor/plugins/tiles/tile_atlas_view.h +++ b/editor/plugins/tiles/tile_atlas_view.h @@ -154,8 +154,8 @@ public: p_control->set_mouse_filter(Control::MOUSE_FILTER_PASS); }; - // Update everything. - void update(); + // Redraw everything. + void queue_redraw(); TileAtlasView(); }; diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 73e07e6647..1bfbd342c2 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -240,12 +240,12 @@ void GenericTilePolygonEditor::_base_control_draw() { void GenericTilePolygonEditor::_center_view() { panning = Vector2(); - base_control->update(); + base_control->queue_redraw(); button_center_view->set_disabled(true); } void GenericTilePolygonEditor::_zoom_changed() { - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { @@ -266,26 +266,26 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { polygon.write[i] = polygon[i] * tile_set->get_tile_size(); } undo_redo->add_do_method(this, "add_polygon", polygon); - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_do_method(this, "emit_signal", "polygons_changed"); undo_redo->add_undo_method(this, "clear_polygons"); for (unsigned int i = 0; i < polygons.size(); i++) { undo_redo->add_undo_method(this, "add_polygon", polygons[i]); } - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "emit_signal", "polygons_changed"); undo_redo->commit_action(true); } break; case CLEAR_TILE: { undo_redo->create_action(TTR("Clear Polygons")); undo_redo->add_do_method(this, "clear_polygons"); - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_do_method(this, "emit_signal", "polygons_changed"); undo_redo->add_undo_method(this, "clear_polygons"); for (unsigned int i = 0; i < polygons.size(); i++) { undo_redo->add_undo_method(this, "add_polygon", polygons[i]); } - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "emit_signal", "polygons_changed"); undo_redo->commit_action(true); } break; @@ -318,12 +318,12 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) { } undo_redo->add_do_method(this, "set_polygon", i, new_polygon); } - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_do_method(this, "emit_signal", "polygons_changed"); for (unsigned int i = 0; i < polygons.size(); i++) { undo_redo->add_undo_method(this, "set_polygon", polygons[i]); } - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "emit_signal", "polygons_changed"); undo_redo->commit_action(true); } break; @@ -491,9 +491,9 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(this, "clear_polygons"); } undo_redo->add_do_method(this, "add_polygon", in_creation_polygon); - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "remove_polygon", added); - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->commit_action(false); emit_signal(SNAME("polygons_changed")); } else { @@ -539,8 +539,8 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(this, "set_polygon", closest_polygon, polygons[closest_polygon]); undo_redo->add_undo_method(this, "set_polygon", closest_polygon, old_polygon); } - undo_redo->add_do_method(base_control, "update"); - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->commit_action(false); emit_signal(SNAME("polygons_changed")); } @@ -549,9 +549,9 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) if (drag_type == DRAG_TYPE_DRAG_POINT) { undo_redo->create_action(TTR("Edit Polygons")); undo_redo->add_do_method(this, "set_polygon", drag_polygon_index, polygons[drag_polygon_index]); - undo_redo->add_do_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); undo_redo->add_undo_method(this, "set_polygon", drag_polygon_index, drag_old_polygon); - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->commit_action(false); emit_signal(SNAME("polygons_changed")); } else if (drag_type == DRAG_TYPE_CREATE_POINT) { @@ -586,8 +586,8 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(this, "set_polygon", closest_polygon, polygons[closest_polygon]); undo_redo->add_undo_method(this, "set_polygon", closest_polygon, old_polygon); } - undo_redo->add_do_method(base_control, "update"); - undo_redo->add_undo_method(base_control, "update"); + undo_redo->add_do_method(base_control, "queue_redraw"); + undo_redo->add_undo_method(base_control, "queue_redraw"); undo_redo->commit_action(false); emit_signal(SNAME("polygons_changed")); } else { @@ -611,7 +611,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) } } - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::set_use_undo_redo(bool p_use_undo_redo) { @@ -659,7 +659,7 @@ void GenericTilePolygonEditor::set_background(Ref<Texture2D> p_texture, Rect2 p_ background_v_flip = p_flip_v; background_transpose = p_transpose; background_modulate = p_modulate; - base_control->update(); + base_control->queue_redraw(); } int GenericTilePolygonEditor::get_polygon_count() { @@ -672,13 +672,13 @@ int GenericTilePolygonEditor::add_polygon(Vector<Point2> p_polygon, int p_index) if (p_index < 0) { polygons.push_back(p_polygon); - base_control->update(); + base_control->queue_redraw(); button_edit->set_pressed(true); return polygons.size() - 1; } else { polygons.insert(p_index, p_polygon); button_edit->set_pressed(true); - base_control->update(); + base_control->queue_redraw(); return p_index; } } @@ -690,12 +690,12 @@ void GenericTilePolygonEditor::remove_polygon(int p_index) { if (polygons.size() == 0) { button_create->set_pressed(true); } - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::clear_polygons() { polygons.clear(); - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector<Point2> p_polygon) { @@ -703,7 +703,7 @@ void GenericTilePolygonEditor::set_polygon(int p_polygon_index, Vector<Point2> p ERR_FAIL_COND(p_polygon.size() < 3); polygons[p_polygon_index] = p_polygon; button_edit->set_pressed(true); - base_control->update(); + base_control->queue_redraw(); } Vector<Point2> GenericTilePolygonEditor::get_polygon(int p_polygon_index) { @@ -713,7 +713,7 @@ Vector<Point2> GenericTilePolygonEditor::get_polygon(int p_polygon_index) { void GenericTilePolygonEditor::set_polygons_color(Color p_color) { polygon_color = p_color; - base_control->update(); + base_control->queue_redraw(); } void GenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon_mode) { diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 556788f50c..ec406ef9ba 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -351,7 +351,7 @@ void TileMapEditorTilesPlugin::_update_atlas_view() { tile_atlas_view->set_atlas_source(*tile_map->get_tileset(), atlas_source, source_id); TilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view); - tile_atlas_control->update(); + tile_atlas_control->queue_redraw(); } void TileMapEditorTilesPlugin::_update_scenes_collection_view() { @@ -1651,8 +1651,8 @@ void TileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern( } } _update_source_display(); - tile_atlas_control->update(); - alternative_tiles_control->update(); + tile_atlas_control->queue_redraw(); + alternative_tiles_control->queue_redraw(); } void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { @@ -1736,7 +1736,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() { hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; - tile_atlas_control->update(); + tile_atlas_control->queue_redraw(); } void TileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) { @@ -1780,8 +1780,8 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEven Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - tile_atlas_control->update(); - alternative_tiles_control->update(); + tile_atlas_control->queue_redraw(); + alternative_tiles_control->queue_redraw(); } Ref<InputEventMouseButton> mb = p_event; @@ -1841,7 +1841,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEven } tile_set_dragging_selection = false; } - tile_atlas_control->update(); + tile_atlas_control->queue_redraw(); } } @@ -1895,7 +1895,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() { hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; - alternative_tiles_control->update(); + alternative_tiles_control->queue_redraw(); } void TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event) { @@ -1938,8 +1938,8 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<In Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - tile_atlas_control->update(); - alternative_tiles_control->update(); + tile_atlas_control->queue_redraw(); + alternative_tiles_control->queue_redraw(); } Ref<InputEventMouseButton> mb = p_event; @@ -1959,8 +1959,8 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<In } _update_selection_pattern_from_tileset_tiles_selection(); } - tile_atlas_control->update(); - alternative_tiles_control->update(); + tile_atlas_control->queue_redraw(); + alternative_tiles_control->queue_redraw(); } } @@ -3618,7 +3618,7 @@ void TileMapEditor::_tab_changed(int p_tab_id) { } // Graphical update. - tabs_data[tabs_bar->get_current_tab()].panel->update(); + tabs_data[tabs_bar->get_current_tab()].panel->queue_redraw(); CanvasItemEditor::get_singleton()->update_viewport(); } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 46093469e3..2aea020902 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -624,8 +624,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataTextureOffsetEditor *tile_data_texture_offset_editor = memnew(TileDataTextureOffsetEditor); tile_data_texture_offset_editor->hide(); tile_data_texture_offset_editor->setup_property_editor(Variant::VECTOR2, "texture_offset"); - tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_texture_offset_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["texture_offset"] = tile_data_texture_offset_editor; } @@ -634,8 +634,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataDefaultEditor *tile_data_modulate_editor = memnew(TileDataDefaultEditor()); tile_data_modulate_editor->hide(); tile_data_modulate_editor->setup_property_editor(Variant::COLOR, "modulate", "", Color(1.0, 1.0, 1.0, 1.0)); - tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["modulate"] = tile_data_modulate_editor; } @@ -644,8 +644,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataDefaultEditor *tile_data_z_index_editor = memnew(TileDataDefaultEditor()); tile_data_z_index_editor->hide(); tile_data_z_index_editor->setup_property_editor(Variant::INT, "z_index"); - tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["z_index"] = tile_data_z_index_editor; } @@ -654,8 +654,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataYSortEditor *tile_data_y_sort_editor = memnew(TileDataYSortEditor); tile_data_y_sort_editor->hide(); tile_data_y_sort_editor->setup_property_editor(Variant::INT, "y_sort_origin"); - tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["y_sort_origin"] = tile_data_y_sort_editor; } @@ -665,8 +665,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataOcclusionShapeEditor *tile_data_occlusion_shape_editor = memnew(TileDataOcclusionShapeEditor()); tile_data_occlusion_shape_editor->hide(); tile_data_occlusion_shape_editor->set_occlusion_layer(i); - tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors[vformat("occlusion_layer_%d", i)] = tile_data_occlusion_shape_editor; } } @@ -680,8 +680,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { if (!tile_data_editors.has("terrain_set")) { TileDataTerrainsEditor *tile_data_terrains_editor = memnew(TileDataTerrainsEditor); tile_data_terrains_editor->hide(); - tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["terrain_set"] = tile_data_terrains_editor; } @@ -691,8 +691,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataDefaultEditor *tile_data_probability_editor = memnew(TileDataDefaultEditor()); tile_data_probability_editor->hide(); tile_data_probability_editor->setup_property_editor(Variant::FLOAT, "probability", "", 1.0); - tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors["probability"] = tile_data_probability_editor; } @@ -704,8 +704,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataCollisionEditor *tile_data_collision_editor = memnew(TileDataCollisionEditor()); tile_data_collision_editor->hide(); tile_data_collision_editor->set_physics_layer(i); - tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors[vformat("physics_layer_%d", i)] = tile_data_collision_editor; } } @@ -722,8 +722,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataNavigationEditor *tile_data_navigation_editor = memnew(TileDataNavigationEditor()); tile_data_navigation_editor->hide(); tile_data_navigation_editor->set_navigation_layer(i); - tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors[vformat("navigation_layer_%d", i)] = tile_data_navigation_editor; } } @@ -744,8 +744,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { TileDataDefaultEditor *tile_data_custom_data_editor = memnew(TileDataDefaultEditor()); tile_data_custom_data_editor->hide(); tile_data_custom_data_editor->setup_property_editor(tile_set->get_custom_data_layer_type(i), vformat("custom_data_%d", i), tile_set->get_custom_data_layer_name(i)); - tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update)); - tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update)); + tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw)); + tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw)); tile_data_editors[vformat("custom_data_%d", i)] = tile_data_custom_data_editor; } } @@ -872,10 +872,10 @@ void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed() { void TileSetAtlasSourceEditor::_tile_data_editors_tree_selected() { tile_data_editors_popup->call_deferred(SNAME("hide")); _update_current_tile_data_editor(); - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); } void TileSetAtlasSourceEditor::_update_atlas_view() { @@ -923,11 +923,11 @@ void TileSetAtlasSourceEditor::_update_atlas_view() { tile_atlas_view->set_padding(Side::SIDE_RIGHT, texture_region_base_size_min); // Redraw everything. - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); // Synchronize atlas view. TilesEditorPlugin::get_singleton()->synchronize_atlas_view(tile_atlas_view); @@ -961,14 +961,14 @@ void TileSetAtlasSourceEditor::_update_toolbar() { void TileSetAtlasSourceEditor::_tile_atlas_control_mouse_exited() { hovered_base_tile_coords = TileSetSource::INVALID_ATLAS_COORDS; - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); } void TileSetAtlasSourceEditor::_tile_atlas_view_transform_changed() { - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); } void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) { @@ -983,11 +983,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven // Update only what's needed. tile_set_changed_needs_update = false; - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } else { // Handle the event. @@ -1132,11 +1132,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven } // Redraw for the hovered tile. - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } @@ -1283,11 +1283,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven // Left click released. _end_dragging(); } - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } else if (mb->get_button_index() == MouseButton::RIGHT) { // Right click pressed. @@ -1298,11 +1298,11 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEven // Right click released. _end_dragging(); } - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } } @@ -1872,20 +1872,20 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<In if (current_tile_data_editor) { current_tile_data_editor->forward_painting_alternatives_gui_input(tile_atlas_view, tile_set_atlas_source, p_event); } - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); - tile_atlas_view->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); + tile_atlas_view->queue_redraw(); return; } Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); if (drag_type == DRAG_TYPE_MAY_POPUP_MENU) { if (Vector2(drag_start_mouse_pos).distance_to(alternative_tiles_control->get_local_mouse_position()) > 5.0 * EDSCALE) { @@ -1942,19 +1942,19 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<In drag_type = DRAG_TYPE_NONE; } } - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); } } void TileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() { hovered_alternative_tile_coords = Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE); - tile_atlas_control->update(); - tile_atlas_control_unscaled->update(); - alternative_tiles_control->update(); - alternative_tiles_control_unscaled->update(); + tile_atlas_control->queue_redraw(); + tile_atlas_control_unscaled->queue_redraw(); + alternative_tiles_control->queue_redraw(); + alternative_tiles_control_unscaled->queue_redraw(); } void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() { diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 83341b3016..2fb8bbe86b 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -6263,7 +6263,7 @@ void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, Visua type = p_type; port = p_port; node = p_node; - update(); + queue_redraw(); _shader_changed(); } diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index cdd088f0b1..83275a2a7b 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -41,9 +41,7 @@ const int ERROR_CODE = 77; #include "core/os/time.h" #include "core/templates/hash_map.h" #include "core/templates/list.h" - -const uint64_t CONVERSION_MAX_FILE_SIZE_MB = 4; -const uint64_t CONVERSION_MAX_FILE_SIZE = 1024 * 1024 * CONVERSION_MAX_FILE_SIZE_MB; +#include "core/templates/local_vector.h" static const char *enum_renames[][2] = { //// constants @@ -230,7 +228,6 @@ static const char *gdscript_function_renames[][2] = { { "add_stylebox_override", "add_theme_stylebox_override" }, // Control { "add_torque", "apply_torque" }, //RigidBody2D { "apply_changes", "_apply_changes" }, // EditorPlugin - { "bind_child_node_to_bone", "set_bone_children" }, // Skeleton3D { "body_add_force", "body_apply_force" }, // PhysicsServer2D { "body_add_torque", "body_apply_torque" }, // PhysicsServer2D { "bumpmap_to_normalmap", "bump_map_to_normal_map" }, // Image @@ -298,11 +295,11 @@ static const char *gdscript_function_renames[][2] = { { "get_d", "get_distance" }, // LineShape2D { "get_drag_data", "_get_drag_data" }, // Control { "get_drag_data_fw", "_get_drag_data_fw" }, // ScriptEditor - { "get_editor_description", "_get_editor_description" }, // Node { "get_editor_viewport", "get_viewport" }, // EditorPlugin { "get_enabled_focus_mode", "get_focus_mode" }, // BaseButton { "get_endian_swap", "is_big_endian" }, // File { "get_error_string", "get_error_message" }, // JSON + { "get_filename", "get_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places { "get_focus_neighbour", "get_focus_neighbor" }, // Control { "get_font_types", "get_font_type_list" }, // Theme { "get_frame_color", "get_color" }, // ColorRect @@ -398,7 +395,6 @@ static const char *gdscript_function_renames[][2] = { { "has_stylebox_override", "has_theme_stylebox_override" }, // Control { "http_escape", "uri_encode" }, // String { "http_unescape", "uri_decode" }, // String - { "import_animation_from_other_importer", "_import_animation" }, //EditorSceneFormatImporter { "import_scene_from_other_importer", "_import_scene" }, //EditorSceneFormatImporter { "instance_set_surface_material", "instance_set_surface_override_material" }, // RenderingServer { "intersect_polygons_2d", "intersect_polygons" }, // Geometry2D @@ -546,7 +542,6 @@ static const char *gdscript_function_renames[][2] = { { "targeting_property", "tween_property" }, // Tween { "track_remove_key_at_position", "track_remove_key_at_time" }, // Animation { "triangulate_delaunay_2d", "triangulate_delaunay" }, // Geometry2D - { "unbind_child_node_from_bone", "remove_bone_child" }, // Skeleton3D { "unselect", "deselect" }, // ItemList { "unselect_all", "deselect_all" }, // ItemList { "update_configuration_warning", "update_configuration_warnings" }, // Node @@ -555,6 +550,7 @@ static const char *gdscript_function_renames[][2] = { { "warp_mouse_position", "warp_mouse" }, // Input // Builtin types + // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed // { "empty", "is_empty" }, // Array - Used as custom rule // Be careful, this will be used everywhere { "clamped", "clamp" }, // Vector2 // Be careful, this will be used everywhere { "get_rotation_quat", "get_rotation_quaternion" }, // Basis @@ -568,6 +564,7 @@ static const char *gdscript_function_renames[][2] = { { "to_wchar", "to_utf32_buffer" }, // String // TODO - utf32 or utf16? // @GlobalScope + // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed { "bytes2var", "bytes_to_var" }, { "bytes2var_with_objects", "bytes_to_var_with_objects" }, { "db2linear", "db_to_linear" }, @@ -582,6 +579,7 @@ static const char *gdscript_function_renames[][2] = { { "var2bytes_with_objects", "var_to_bytes_with_objects" }, // @GDScript + // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed { "dict2inst", "dict_to_inst" }, { "inst2dict", "inst_to_dict" }, @@ -1057,6 +1055,14 @@ static const char *gdscript_properties_renames[][2] = { { "pause_mode", "process_mode" }, // Node { "physical_scancode", "physical_keycode" }, // InputEventKey { "popup_exclusive", "exclusive" }, // Window + { "rect_position", "position" }, // Control + { "rect_global_position", "global_position" }, // Control + { "rect_size", "size" }, // Control + { "rect_min_size", "minimum_size" }, // Control + { "rect_rotation", "rotation" }, // Control + { "rect_scale", "scale" }, // Control + { "rect_pivot_offset", "pivot_offset" }, // Control + { "rect_clip_content", "clip_contents" }, // Control { "refuse_new_network_connections", "refuse_new_connections" }, // MultiplayerAPI { "region_filter_clip", "region_filter_clip_enabled" }, // Sprite2D { "selectedframe", "selected_frame" }, // Theme @@ -1271,9 +1277,19 @@ static const char *builtin_types_renames[][2] = { static const char *shaders_renames[][2] = { { "ALPHA_SCISSOR", "ALPHA_SCISSOR_THRESHOLD" }, + { "CAMERA_MATRIX", "INV_VIEW_MATRIX" }, + { "INV_CAMERA_MATRIX", "VIEW_MATRIX" }, { "NORMALMAP", "NORMAL_MAP" }, { "NORMALMAP_DEPTH", "NORMAL_MAP_DEPTH" }, - { "TRANSMISSION", "SSS_TRANSMITTANCE_COLOR" }, + { "TRANSMISSION", "BACKLIGHT" }, + { "WORLD_MATRIX", "MODEL_MATRIX" }, + { "depth_draw_alpha_prepass", "depth_draw_opaque" }, + { "hint_albedo", "source_color" }, + { "hint_aniso", "hint_anisotropy" }, + { "hint_black", "hint_default_black" }, + { "hint_black_albedo", "hint_default_black" }, + { "hint_color", "source_color" }, + { "hint_white", "hint_default_white" }, { nullptr, nullptr }, }; @@ -1494,7 +1510,7 @@ static const char *class_renames[][2] = { }; // TODO - this colors needs to be validated(not all are valid) -static const char *colors_renames[][2] = { +static const char *color_renames[][2] = { { "aliceblue", "ALICE_BLUE" }, { "antiquewhite", "ANTIQUE_WHITE" }, { "aqua", "AQUA" }, @@ -1647,6 +1663,7 @@ static const char *colors_renames[][2] = { class ProjectConverter3To4::RegExContainer { public: + // Custom GDScript RegEx reg_is_empty = RegEx("\\bempty\\("); RegEx reg_super = RegEx("([\t ])\\.([a-zA-Z_])"); RegEx reg_json_to = RegEx("\\bto_json\\b"); @@ -1658,24 +1675,196 @@ public: RegEx reg_setget_set = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*[,]*[^a-z^A-Z^0-9^_]*$"); RegEx reg_setget_get = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+,[ \t]*([a-zA-Z0-9_]+)[ \t]*$"); RegEx reg_join = RegEx("([\\(\\)a-zA-Z0-9_]+)\\.join\\(([^\n^\\)]+)\\)"); - RegEx reg_mixed_tab_space = RegEx("([\t]+)([ ]+)"); RegEx reg_image_lock = RegEx("([a-zA-Z0-9_\\.]+)\\.lock\\(\\)"); RegEx reg_image_unlock = RegEx("([a-zA-Z0-9_\\.]+)\\.unlock\\(\\)"); RegEx reg_os_fullscreen = RegEx("OS.window_fullscreen[= ]+([^#^\n]+)"); RegEx reg_instantiate = RegEx("\\.instance\\(([^\\)]*)\\)"); + + // GDScript keywords + RegEx keyword_gdscript_tool = RegEx("^tool"); + RegEx keyword_gdscript_export_single = RegEx("^export"); + RegEx keyword_gdscript_export_mutli = RegEx("([\t]+)export\\b"); + RegEx keyword_gdscript_onready = RegEx("^onready"); + RegEx keyword_gdscript_remote = RegEx("^remote func"); + RegEx keyword_gdscript_remotesync = RegEx("^remotesync func"); + RegEx keyword_gdscript_sync = RegEx("^sync func"); + RegEx keyword_gdscript_slave = RegEx("^slave func"); + RegEx keyword_gdscript_puppet = RegEx("^puppet func"); + RegEx keyword_gdscript_puppetsync = RegEx("^puppetsync func"); + RegEx keyword_gdscript_master = RegEx("^master func"); + RegEx keyword_gdscript_mastersync = RegEx("^mastersync func"); + + // CSharp keywords + RegEx keyword_csharp_remote = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_remotesync = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_puppet = RegEx("\\[(Puppet|Slave)(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_puppetsync = RegEx("\\[PuppetSync(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_master = RegEx("\\[Master(Attribute)?(\\(\\))?\\]"); + RegEx keyword_csharp_mastersync = RegEx("\\[MasterSync(Attribute)?(\\(\\))?\\]"); + + // Colors + LocalVector<RegEx *> color_regexes; + LocalVector<String> color_renamed; + + // Classes + LocalVector<RegEx *> class_tscn_regexes; + LocalVector<RegEx *> class_gd_regexes; + LocalVector<RegEx *> class_shader_regexes; + + LocalVector<RegEx *> class_regexes; + + RegEx class_temp_tscn = RegEx("\\bTEMP_RENAMED_CLASS.tscn\\b"); + RegEx class_temp_gd = RegEx("\\bTEMP_RENAMED_CLASS.gd\\b"); + RegEx class_temp_shader = RegEx("\\bTEMP_RENAMED_CLASS.shader\\b"); + + LocalVector<String> class_temp_tscn_renames; + LocalVector<String> class_temp_gd_renames; + LocalVector<String> class_temp_shader_renames; + + // Common + LocalVector<RegEx *> enum_regexes; + LocalVector<RegEx *> gdscript_function_regexes; + LocalVector<RegEx *> project_settings_regexes; + LocalVector<RegEx *> gdscript_properties_regexes; + LocalVector<RegEx *> gdscript_signals_regexes; + LocalVector<RegEx *> shaders_regexes; + LocalVector<RegEx *> builtin_types_regexes; + LocalVector<RegEx *> csharp_function_regexes; + LocalVector<RegEx *> csharp_properties_regexes; + LocalVector<RegEx *> csharp_signal_regexes; + + RegExContainer() { + // Common + { + // Enum + for (unsigned int current_index = 0; enum_renames[current_index][0]; current_index++) { + enum_regexes.push_back(memnew(RegEx(String("\\b") + enum_renames[current_index][0] + "\\b"))); + } + // GDScript functions + for (unsigned int current_index = 0; gdscript_function_renames[current_index][0]; current_index++) { + gdscript_function_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_function_renames[current_index][0] + "\\b"))); + } + // Project Settings + for (unsigned int current_index = 0; project_settings_renames[current_index][0]; current_index++) { + project_settings_regexes.push_back(memnew(RegEx(String("\\b") + project_settings_renames[current_index][0] + "\\b"))); + } + // GDScript properties + for (unsigned int current_index = 0; gdscript_properties_renames[current_index][0]; current_index++) { + gdscript_properties_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_properties_renames[current_index][0] + "\\b"))); + } + // GDScript Signals + for (unsigned int current_index = 0; gdscript_signals_renames[current_index][0]; current_index++) { + gdscript_signals_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_signals_renames[current_index][0] + "\\b"))); + } + // Shaders + for (unsigned int current_index = 0; shaders_renames[current_index][0]; current_index++) { + shaders_regexes.push_back(memnew(RegEx(String("\\b") + shaders_renames[current_index][0] + "\\b"))); + } + // Builtin types + for (unsigned int current_index = 0; builtin_types_renames[current_index][0]; current_index++) { + builtin_types_regexes.push_back(memnew(RegEx(String("\\b") + builtin_types_renames[current_index][0] + "\\b"))); + } + // CSharp function renames + for (unsigned int current_index = 0; csharp_function_renames[current_index][0]; current_index++) { + csharp_function_regexes.push_back(memnew(RegEx(String("\\b") + csharp_function_renames[current_index][0] + "\\b"))); + } + // CSharp properties renames + for (unsigned int current_index = 0; csharp_properties_renames[current_index][0]; current_index++) { + csharp_properties_regexes.push_back(memnew(RegEx(String("\\b") + csharp_properties_renames[current_index][0] + "\\b"))); + } + // CSharp signals renames + for (unsigned int current_index = 0; csharp_signals_renames[current_index][0]; current_index++) { + csharp_signal_regexes.push_back(memnew(RegEx(String("\\b") + csharp_signals_renames[current_index][0] + "\\b"))); + } + } + + // Colors + { + for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) { + color_regexes.push_back(memnew(RegEx(String("\\bColor.") + color_renames[current_index][0] + "\\b"))); + color_renamed.push_back(String("Color.") + color_renames[current_index][1]); + } + } + // Classes + { + for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) { + class_tscn_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".tscn\\b"))); + class_gd_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".gd\\b"))); + class_shader_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".shader\\b"))); + + class_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + "\\b"))); + + class_temp_tscn_renames.push_back(String(class_renames[current_index][0]) + ".tscn"); + class_temp_gd_renames.push_back(String(class_renames[current_index][0]) + ".gd"); + class_temp_shader_renames.push_back(String(class_renames[current_index][0]) + ".shader"); + } + } + } + ~RegExContainer() { + for (unsigned int i = 0; i < color_regexes.size(); i++) { + memdelete(color_regexes[i]); + } + for (unsigned int i = 0; i < class_tscn_regexes.size(); i++) { + memdelete(class_tscn_regexes[i]); + memdelete(class_gd_regexes[i]); + memdelete(class_shader_regexes[i]); + memdelete(class_regexes[i]); + } + for (unsigned int i = 0; i < enum_regexes.size(); i++) { + memdelete(enum_regexes[i]); + } + for (unsigned int i = 0; i < gdscript_function_regexes.size(); i++) { + memdelete(gdscript_function_regexes[i]); + } + for (unsigned int i = 0; i < project_settings_regexes.size(); i++) { + memdelete(project_settings_regexes[i]); + } + for (unsigned int i = 0; i < gdscript_properties_regexes.size(); i++) { + memdelete(gdscript_properties_regexes[i]); + } + for (unsigned int i = 0; i < gdscript_signals_regexes.size(); i++) { + memdelete(gdscript_signals_regexes[i]); + } + for (unsigned int i = 0; i < shaders_regexes.size(); i++) { + memdelete(shaders_regexes[i]); + } + for (unsigned int i = 0; i < builtin_types_regexes.size(); i++) { + memdelete(builtin_types_regexes[i]); + } + for (unsigned int i = 0; i < csharp_function_regexes.size(); i++) { + memdelete(csharp_function_regexes[i]); + } + for (unsigned int i = 0; i < csharp_properties_regexes.size(); i++) { + memdelete(csharp_properties_regexes[i]); + } + for (unsigned int i = 0; i < csharp_signal_regexes.size(); i++) { + memdelete(csharp_signal_regexes[i]); + } + } }; +ProjectConverter3To4::ProjectConverter3To4(int maximum_file_size_kb, int maximum_line_length) { + this->maximum_file_size = maximum_file_size_kb * 1024; + this->maximum_line_length = maximum_line_length; +} + // Function responsible for converting project int ProjectConverter3To4::convert() { print_line("Starting conversion."); + uint64_t conversion_start_time = Time::get_singleton()->get_ticks_msec(); RegExContainer reg_container = RegExContainer(); + int cached_maximum_line_length = maximum_line_length; + maximum_line_length = 10000; // Use only for tests bigger value, to not break them + ERR_FAIL_COND_V_MSG(!test_array_names(), ERROR_CODE, "Cannot start converting due to problems with data in arrays."); ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), ERROR_CODE, "Cannot start converting due to problems with converting arrays."); + maximum_line_length = cached_maximum_line_length; + // Checking if folder contains valid Godot 3 project. - // Project cannot be converted 2 times + // Project should not be converted more than 1 times { String conventer_text = "; Project was converted by built-in tool to Godot 4.0"; @@ -1685,7 +1874,7 @@ int ProjectConverter3To4::convert() { String project_godot_content = FileAccess::get_file_as_string("project.godot", &err); ERR_FAIL_COND_V_MSG(err != OK, ERROR_CODE, "Failed to read content of \"project.godot\" file."); - ERR_FAIL_COND_V_MSG(project_godot_content.find(conventer_text) != -1, ERROR_CODE, "Project already was converted with this tool."); + ERR_FAIL_COND_V_MSG(project_godot_content.contains(conventer_text), ERROR_CODE, "Project already was converted with this tool."); Ref<FileAccess> file = FileAccess::open("project.godot", FileAccess::WRITE); ERR_FAIL_COND_V_MSG(file.is_null(), ERROR_CODE, "Failed to open project.godot file."); @@ -1700,11 +1889,19 @@ int ProjectConverter3To4::convert() { // Check file by file for (int i = 0; i < collected_files.size(); i++) { String file_name = collected_files[i]; - Error err = OK; - String file_content = FileAccess::get_file_as_string(file_name, &err); - ERR_CONTINUE_MSG(err != OK, "Failed to read content of \"" + file_name + "\"."); - uint64_t hash_before = file_content.hash64(); - uint64_t file_size = file_content.size(); + Vector<String> lines; + uint32_t ignored_lines = 0; + { + Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::READ); + ERR_CONTINUE_MSG(file.is_null(), "Failed to read content of \"" + file_name + "\"."); + while (!file->eof_reached()) { + String line = file->get_line(); + lines.append(line); + } + } + String file_content_before = collect_string_from_vector(lines); + uint64_t hash_before = file_content_before.hash(); + uint64_t file_size = file_content_before.size(); print_line("Trying to convert\t" + itos(i + 1) + "/" + itos(collected_files.size()) + " file - \"" + file_name.trim_prefix("res://") + "\" with size - " + itos(file_size / 1024) + " KB"); Vector<String> reason; @@ -1716,78 +1913,87 @@ int ProjectConverter3To4::convert() { file_name = file_name.replace(".shader", ".gdshader"); } - if (file_size < CONVERSION_MAX_FILE_SIZE) { + if (file_size < uint64_t(maximum_file_size)) { // TSCN must be the same work exactly same as .gd file because it may contains builtin script if (file_name.ends_with(".gd")) { - rename_classes(file_content); // Using only specialized function + rename_classes(lines, reg_container); // Using only specialized function - rename_common(enum_renames, file_content); - rename_enums(file_content); // Require to additional rename + rename_common(enum_renames, reg_container.enum_regexes, lines); + rename_colors(lines, reg_container); // Require to additional rename - rename_common(gdscript_function_renames, file_content); - rename_gdscript_functions(file_content, reg_container, false); // Require to additional rename + rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines); + rename_gdscript_functions(lines, reg_container, false); // Require to additional rename - rename_common(project_settings_renames, file_content); - rename_gdscript_keywords(file_content); - rename_common(gdscript_properties_renames, file_content); - rename_common(gdscript_signals_renames, file_content); - rename_common(shaders_renames, file_content); - rename_common(builtin_types_renames, file_content); + rename_common(project_settings_renames, reg_container.project_settings_regexes, lines); + rename_gdscript_keywords(lines, reg_container); + rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines); + rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines); + rename_common(shaders_renames, reg_container.shaders_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); - custom_rename(file_content, "\\.shader", ".gdshader"); + custom_rename(lines, "\\.shader", ".gdshader"); } else if (file_name.ends_with(".tscn")) { - rename_classes(file_content); // Using only specialized function + rename_classes(lines, reg_container); // Using only specialized function - rename_common(enum_renames, file_content); - rename_enums(file_content); // Require to additional rename + rename_common(enum_renames, reg_container.enum_regexes, lines); + rename_colors(lines, reg_container); // Require to additional rename - rename_common(gdscript_function_renames, file_content); - rename_gdscript_functions(file_content, reg_container, true); // Require to additional rename + rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines); + rename_gdscript_functions(lines, reg_container, true); // Require to additional rename - rename_common(project_settings_renames, file_content); - rename_gdscript_keywords(file_content); - rename_common(gdscript_properties_renames, file_content); - rename_common(gdscript_signals_renames, file_content); - rename_common(shaders_renames, file_content); - rename_common(builtin_types_renames, file_content); + rename_common(project_settings_renames, reg_container.project_settings_regexes, lines); + rename_gdscript_keywords(lines, reg_container); + rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines); + rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines); + rename_common(shaders_renames, reg_container.shaders_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); - custom_rename(file_content, "\\.shader", ".gdshader"); + custom_rename(lines, "\\.shader", ".gdshader"); } else if (file_name.ends_with(".cs")) { // TODO, C# should use different methods - rename_classes(file_content); // Using only specialized function - rename_common(csharp_function_renames, file_content); - rename_common(builtin_types_renames, file_content); - rename_common(csharp_properties_renames, file_content); - rename_common(csharp_signals_renames, file_content); - rename_csharp_functions(file_content); - rename_csharp_attributes(file_content); - custom_rename(file_content, "public class ", "public partial class "); + rename_classes(lines, reg_container); // Using only specialized function + rename_common(csharp_function_renames, reg_container.csharp_function_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); + rename_common(csharp_properties_renames, reg_container.csharp_properties_regexes, lines); + rename_common(csharp_signals_renames, reg_container.csharp_signal_regexes, lines); + rename_csharp_functions(lines, reg_container); + rename_csharp_attributes(lines, reg_container); + custom_rename(lines, "public class ", "public partial class "); } else if (file_name.ends_with(".gdshader") || file_name.ends_with(".shader")) { - rename_common(shaders_renames, file_content); + rename_common(shaders_renames, reg_container.shaders_regexes, lines); } else if (file_name.ends_with("tres")) { - rename_classes(file_content); // Using only specialized function + rename_classes(lines, reg_container); // Using only specialized function - rename_common(shaders_renames, file_content); - rename_common(builtin_types_renames, file_content); + rename_common(shaders_renames, reg_container.shaders_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); - custom_rename(file_content, "\\.shader", ".gdshader"); + custom_rename(lines, "\\.shader", ".gdshader"); } else if (file_name.ends_with("project.godot")) { - rename_common(project_settings_renames, file_content); - rename_common(builtin_types_renames, file_content); + rename_common(project_settings_renames, reg_container.project_settings_regexes, lines); + rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines); } else if (file_name.ends_with(".csproj")) { // TODO } else { ERR_PRINT(file_name + " is not supported!"); continue; } + + for (String &line : lines) { + if (uint64_t(line.length()) > maximum_line_length) { + ignored_lines += 1; + } + } } else { - reason.append(" ERROR: File has exceeded the maximum size allowed - " + itos(CONVERSION_MAX_FILE_SIZE_MB) + " MB"); + reason.append(" ERROR: File has exceeded the maximum size allowed - " + itos(maximum_file_size / 1024) + " KB"); is_ignored = true; } uint64_t end_time = Time::get_singleton()->get_ticks_msec(); - - if (!is_ignored) { - uint64_t hash_after = file_content.hash64(); + if (is_ignored) { + String end_message = " Checking file took " + itos(end_time - start_time) + " ms."; + print_line(end_message); + } else { + String file_content_after = collect_string_from_vector(lines); + uint64_t hash_after = file_content_after.hash64(); // Don't need to save file without any changes // Save if this is a shader, because it was renamed if (hash_before != hash_after || file_name.ends_with(".gdshader")) { @@ -1795,11 +2001,14 @@ int ProjectConverter3To4::convert() { Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::WRITE); ERR_CONTINUE_MSG(file.is_null(), "Failed to open \"" + file_name + "\" to save data to file."); - file->store_string(file_content); + file->store_string(file_content_after); reason.append(" File was changed, conversion took " + itos(end_time - start_time) + " ms."); } else { reason.append(" File was not changed, checking took " + itos(end_time - start_time) + " ms."); } + if (ignored_lines != 0) { + reason.append(" Ignored " + itos(ignored_lines) + " lines, because their length exceeds maximum allowed characters - " + itos(maximum_line_length)); + } } for (int k = 0; k < reason.size(); k++) { print_line(reason[k]); @@ -1807,20 +2016,28 @@ int ProjectConverter3To4::convert() { } print_line("Conversion ended - all files(" + itos(collected_files.size()) + "), converted files(" + itos(converted_files) + "), not converted files(" + itos(collected_files.size() - converted_files) + ")."); + uint64_t conversion_end_time = Time::get_singleton()->get_ticks_msec(); + print_line("Conversion of all files took " + itos(conversion_end_time - conversion_start_time) + " ms."); return 0; }; // Function responsible for validating project conversion. int ProjectConverter3To4::validate_conversion() { print_line("Starting checking if project conversion can be done."); + uint64_t conversion_start_time = Time::get_singleton()->get_ticks_msec(); RegExContainer reg_container = RegExContainer(); + int cached_maximum_line_length = maximum_line_length; + maximum_line_length = 10000; // Use only for tests bigger value, to not break them + ERR_FAIL_COND_V_MSG(!test_array_names(), ERROR_CODE, "Cannot start converting due to problems with data in arrays."); ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), ERROR_CODE, "Cannot start converting due to problems with converting arrays."); + maximum_line_length = cached_maximum_line_length; + // Checking if folder contains valid Godot 3 project. - // Project cannot be converted 2 times + // Project should not be converted more than 1 times { String conventer_text = "; Project was converted by built-in tool to Godot 4.0"; @@ -1830,7 +2047,7 @@ int ProjectConverter3To4::validate_conversion() { String project_godot_content = FileAccess::get_file_as_string("project.godot", &err); ERR_FAIL_COND_V_MSG(err != OK, ERROR_CODE, "Failed to read content of \"project.godot\" file."); - ERR_FAIL_COND_V_MSG(project_godot_content.find(conventer_text) != -1, ERROR_CODE, "Project already was converted with this tool."); + ERR_FAIL_COND_V_MSG(project_godot_content.contains(conventer_text), ERROR_CODE, "Project already was converted with this tool."); } Vector<String> collected_files = check_for_files(); @@ -1840,7 +2057,8 @@ int ProjectConverter3To4::validate_conversion() { // Check file by file for (int i = 0; i < collected_files.size(); i++) { String file_name = collected_files[i]; - Vector<String> file_content; + Vector<String> lines; + uint32_t ignored_lines = 0; uint64_t file_size = 0; { Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::READ); @@ -1848,7 +2066,7 @@ int ProjectConverter3To4::validate_conversion() { while (!file->eof_reached()) { String line = file->get_line(); file_size += line.size(); - file_content.append(line); + lines.append(line); } } print_line("Checking for conversion - " + itos(i + 1) + "/" + itos(collected_files.size()) + " file - \"" + file_name.trim_prefix("res://") + "\" with size - " + itos(file_size / 1024) + " KB"); @@ -1862,75 +2080,85 @@ int ProjectConverter3To4::validate_conversion() { reason.append("\tFile extension will be renamed from `shader` to `gdshader`."); } - if (file_size < CONVERSION_MAX_FILE_SIZE) { + if (file_size < uint64_t(maximum_file_size)) { if (file_name.ends_with(".gd")) { - changed_elements.append_array(check_for_rename_classes(file_content)); + changed_elements.append_array(check_for_rename_classes(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(enum_renames, file_content)); - changed_elements.append_array(check_for_rename_enums(file_content)); + changed_elements.append_array(check_for_rename_common(enum_renames, reg_container.enum_regexes, lines)); + changed_elements.append_array(check_for_rename_colors(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(gdscript_function_renames, file_content)); - changed_elements.append_array(check_for_rename_gdscript_functions(file_content, reg_container, false)); + changed_elements.append_array(check_for_rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines)); + changed_elements.append_array(check_for_rename_gdscript_functions(lines, reg_container, false)); - changed_elements.append_array(check_for_rename_common(project_settings_renames, file_content)); - changed_elements.append_array(check_for_rename_gdscript_keywords(file_content)); - changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, file_content)); - changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, file_content)); - changed_elements.append_array(check_for_rename_common(shaders_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); + changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines)); + changed_elements.append_array(check_for_rename_gdscript_keywords(lines, reg_container)); + changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines)); + changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines)); + changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); - changed_elements.append_array(check_for_custom_rename(file_content, "\\.shader", ".gdshader")); + changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader")); } else if (file_name.ends_with(".tscn")) { - changed_elements.append_array(check_for_rename_classes(file_content)); + changed_elements.append_array(check_for_rename_classes(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(enum_renames, file_content)); - changed_elements.append_array(check_for_rename_enums(file_content)); + changed_elements.append_array(check_for_rename_common(enum_renames, reg_container.enum_regexes, lines)); + changed_elements.append_array(check_for_rename_colors(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(gdscript_function_renames, file_content)); - changed_elements.append_array(check_for_rename_gdscript_functions(file_content, reg_container, true)); + changed_elements.append_array(check_for_rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines)); + changed_elements.append_array(check_for_rename_gdscript_functions(lines, reg_container, true)); - changed_elements.append_array(check_for_rename_common(project_settings_renames, file_content)); - changed_elements.append_array(check_for_rename_gdscript_keywords(file_content)); - changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, file_content)); - changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, file_content)); - changed_elements.append_array(check_for_rename_common(shaders_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); + changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines)); + changed_elements.append_array(check_for_rename_gdscript_keywords(lines, reg_container)); + changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines)); + changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines)); + changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); - changed_elements.append_array(check_for_custom_rename(file_content, "\\.shader", ".gdshader")); + changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader")); } else if (file_name.ends_with(".cs")) { - changed_elements.append_array(check_for_rename_common(class_renames, file_content)); - changed_elements.append_array(check_for_rename_common(csharp_function_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); - changed_elements.append_array(check_for_rename_common(csharp_properties_renames, file_content)); - changed_elements.append_array(check_for_rename_common(csharp_signals_renames, file_content)); - changed_elements.append_array(check_for_rename_csharp_functions(file_content)); - changed_elements.append_array(check_for_rename_csharp_attributes(file_content)); - changed_elements.append_array(check_for_custom_rename(file_content, "public class ", "public partial class ")); + changed_elements.append_array(check_for_rename_classes(lines, reg_container)); + changed_elements.append_array(check_for_rename_common(csharp_function_renames, reg_container.csharp_function_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); + changed_elements.append_array(check_for_rename_common(csharp_properties_renames, reg_container.csharp_properties_regexes, lines)); + changed_elements.append_array(check_for_rename_common(csharp_signals_renames, reg_container.csharp_signal_regexes, lines)); + changed_elements.append_array(check_for_rename_csharp_functions(lines, reg_container)); + changed_elements.append_array(check_for_rename_csharp_attributes(lines, reg_container)); + changed_elements.append_array(check_for_custom_rename(lines, "public class ", "public partial class ")); } else if (file_name.ends_with(".gdshader") || file_name.ends_with(".shader")) { - changed_elements.append_array(check_for_rename_common(shaders_renames, file_content)); + changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines)); } else if (file_name.ends_with("tres")) { - changed_elements.append_array(check_for_rename_classes(file_content)); + changed_elements.append_array(check_for_rename_classes(lines, reg_container)); - changed_elements.append_array(check_for_rename_common(shaders_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); + changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); - changed_elements.append_array(check_for_custom_rename(file_content, "\\.shader", ".gdshader")); + changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader")); } else if (file_name.ends_with("project.godot")) { - changed_elements.append_array(check_for_rename_common(project_settings_renames, file_content)); - changed_elements.append_array(check_for_rename_common(builtin_types_renames, file_content)); + changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines)); + changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines)); } else if (file_name.ends_with(".csproj")) { // TODO } else { ERR_PRINT(file_name + " is not supported!"); continue; } + + for (String &line : lines) { + if (uint64_t(line.length()) > maximum_line_length) { + ignored_lines += 1; + } + } } else { - reason.append("\tERROR: File has exceeded the maximum size allowed - " + itos(CONVERSION_MAX_FILE_SIZE_MB) + " MB"); + reason.append("\tERROR: File has exceeded the maximum size allowed - " + itos(maximum_file_size / 1024) + " KB"); is_ignored = true; } uint64_t end_time = Time::get_singleton()->get_ticks_msec(); - print_line(" Checking file took " + itos(end_time - start_time) + " ms."); + String end_message = " Checking file took " + itos(end_time - start_time) + " ms."; + if (ignored_lines != 0) { + end_message += " Ignored " + itos(ignored_lines) + " lines, because their length exceeds maximum allowed characters - " + itos(maximum_line_length); + } + print_line(end_message); for (int k = 0; k < reason.size(); k++) { print_line(reason[k]); @@ -1946,6 +2174,8 @@ int ProjectConverter3To4::validate_conversion() { } print_line("Checking for valid conversion ended - all files(" + itos(collected_files.size()) + "), files which would be converted(" + itos(converted_files) + "), files which would not be converted(" + itos(collected_files.size() - converted_files) + ")."); + uint64_t conversion_end_time = Time::get_singleton()->get_ticks_msec(); + print_line("Conversion of all files took " + itos(conversion_end_time - conversion_start_time) + " ms."); return 0; } @@ -1972,14 +2202,14 @@ Vector<String> ProjectConverter3To4::check_for_files() { continue; } if (dir.current_is_dir()) { - directories_to_check.append(current_dir.plus_file(file_name) + "/"); + directories_to_check.append(current_dir.path_join(file_name) + "/"); } else { bool proper_extension = false; if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj")) proper_extension = true; if (proper_extension) { - collected_files.append(current_dir.plus_file(file_name)); + collected_files.append(current_dir.path_join(file_name)); } } file_name = dir.get_next(); @@ -1991,218 +2221,230 @@ Vector<String> ProjectConverter3To4::check_for_files() { return collected_files; } -bool ProjectConverter3To4::test_conversion_single_additional(String name, String expected, void (ProjectConverter3To4::*func)(String &), String what) { - String got = name; - (this->*func)(got); - if (expected != got) { - ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got + "`"); +// Test expected results of gdscript +bool ProjectConverter3To4::test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin_script) { + Vector<String> got = name.split("\n"); + (this->*func)(got, reg_container, builtin_script); + String got_str = collect_string_from_vector(got); + if (expected != got_str) { + ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got_str + "`"); return false; } return true; } -bool ProjectConverter3To4::test_conversion_single_additional_builtin(String name, String expected, void (ProjectConverter3To4::*func)(String &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin_script) { - String got = name; - (this->*func)(got, reg_container, builtin_script); - if (expected != got) { - ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got + "`"); +bool ProjectConverter3To4::test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &), String what, const RegExContainer ®_container) { + Vector<String> got = name.split("\n"); + (this->*func)(got, reg_container); + String got_str = collect_string_from_vector(got); + if (expected != got_str) { + ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got_str + "`"); return false; } return true; } -bool ProjectConverter3To4::test_conversion_single_normal(String name, String expected, const char *array[][2], String what) { - String got = name; - rename_common(array, got); - if (expected != got) { - ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got + "`"); +bool ProjectConverter3To4::test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what) { + Vector<String> got = name.split("\n"); + rename_common(array, regex_cache, got); + String got_str = collect_string_from_vector(got); + if (expected != got_str) { + ERR_PRINT("Failed to convert " + what + " `" + name + "` to `" + expected + "`, got instead `" + got_str + "`"); return false; } return true; } // Validate if conversions are proper -bool ProjectConverter3To4::test_conversion(const RegExContainer ®_container) { +bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) { bool valid = true; - valid = valid & test_conversion_single_normal("Spatial", "Node3D", class_renames, "class"); + valid = valid & test_conversion_basic("TYPE_REAL", "TYPE_FLOAT", enum_renames, reg_container.enum_regexes, "enum"); - valid = valid & test_conversion_single_normal("TYPE_REAL", "TYPE_FLOAT", enum_renames, "enum"); + valid = valid & test_conversion_basic("can_instance", "can_instantiate", gdscript_function_renames, reg_container.gdscript_function_regexes, "gdscript function"); - valid = valid & test_conversion_single_normal("can_instance", "can_instantiate", gdscript_function_renames, "gdscript function"); + valid = valid & test_conversion_basic("CanInstance", "CanInstantiate", csharp_function_renames, reg_container.csharp_function_regexes, "csharp function"); - valid = valid & test_conversion_single_normal("CanInstance", "CanInstantiate", csharp_function_renames, "csharp function"); + valid = valid & test_conversion_basic("translation", "position", gdscript_properties_renames, reg_container.gdscript_properties_regexes, "gdscript property"); - valid = valid & test_conversion_single_normal("translation", "position", gdscript_properties_renames, "gdscript property"); + valid = valid & test_conversion_basic("Translation", "Position", csharp_properties_renames, reg_container.csharp_properties_regexes, "csharp property"); - valid = valid & test_conversion_single_normal("Translation", "Position", csharp_properties_renames, "csharp property"); + valid = valid & test_conversion_basic("NORMALMAP", "NORMAL_MAP", shaders_renames, reg_container.shaders_regexes, "shader"); - valid = valid & test_conversion_single_normal("NORMALMAP", "NORMAL_MAP", shaders_renames, "shader"); + valid = valid & test_conversion_basic("text_entered", "text_submitted", gdscript_signals_renames, reg_container.gdscript_signals_regexes, "gdscript signal"); - valid = valid & test_conversion_single_normal("text_entered", "text_submitted", gdscript_signals_renames, "gdscript signal"); + valid = valid & test_conversion_basic("TextEntered", "TextSubmitted", csharp_signals_renames, reg_container.csharp_signal_regexes, "csharp signal"); - valid = valid & test_conversion_single_normal("TextEntered", "TextSubmitted", csharp_signals_renames, "csharp signal"); + valid = valid & test_conversion_basic("audio/channel_disable_threshold_db", "audio/buses/channel_disable_threshold_db", project_settings_renames, reg_container.project_settings_regexes, "project setting"); - valid = valid & test_conversion_single_normal("audio/channel_disable_threshold_db", "audio/buses/channel_disable_threshold_db", project_settings_renames, "project setting"); - - valid = valid & test_conversion_single_normal("Transform", "Transform3D", builtin_types_renames, "builtin type"); + valid = valid & test_conversion_basic("Transform", "Transform3D", builtin_types_renames, reg_container.builtin_types_regexes, "builtin type"); // Custom Renames - valid = valid & test_conversion_single_additional("(Connect(A,B,C,D,E,F,G) != OK):", "(Connect(A,new Callable(B,C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp"); - valid = valid & test_conversion_single_additional("(Disconnect(A,B,C) != OK):", "(Disconnect(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp"); - valid = valid & test_conversion_single_additional("(IsConnected(A,B,C) != OK):", "(IsConnected(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename"); - - valid = valid & test_conversion_single_additional("[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[Sync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[Slave]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[Puppet]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[PuppetSync]", "[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[Master]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - valid = valid & test_conversion_single_additional("[MasterSync]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp"); - - valid = valid & test_conversion_single_additional_builtin("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\"display/window/size/fullscreen\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true); - valid = valid & test_conversion_single_additional_builtin("OS.get_window_safe_area()", "DisplayServer.get_display_safe_area()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("\tvar aa = roman(r.move_and_slide( a, b, c, d, e, f )) # Roman", "\tr.set_velocity(a)\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\tvar aa = roman(r.move_and_slide_with_snap( a, g, b, c, d, e, f )) # Roman", "\tr.set_velocity(a)\n\t# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `g`\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("list_dir_begin( a , b )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("list_dir_begin( a )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("list_dir_begin( )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("sort_custom( a , b )", "sort_custom(Callable(a,b))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("func c(var a, var b)", "func c(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("draw_line(1, 2, 3, 4, 5)", "draw_line(1,2,3,4)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("\timage.lock()", "\tfalse # image.lock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\timage.unlock()", "\tfalse # image.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\troman.image.unlock()", "\tfalse # roman.image.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\tmtx.lock()", "\tmtx.lock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\tmutex.unlock()", "\tmutex.unlock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional("\nonready", "\n@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("onready", "@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional(" onready", " onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\nexport", "\n@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\texport", "\t@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\texport_dialog", "\texport_dialog", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("export", "@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional(" export", " export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("tool", "@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n tool", "\n tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\ntool", "\n\n@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nremote func", "\n\n@rpc(any_peer) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nremotesync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nsync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nslave func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\npuppet func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\npuppetsync func", "\n\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nmaster func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - valid = valid & test_conversion_single_additional("\n\nmastersync func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); - - valid = valid & test_conversion_single_additional_builtin("var size : Vector2 = Vector2() setget set_function , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function\n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("var size : Vector2 = Vector2() setget set_function , ", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("var size : Vector2 = Vector2() setget set_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("var size : Vector2 = Vector2() setget , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function \n set(mod_value):\n mod_value # TODOConverter40 Non existent set function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("get_node(@", "get_node(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("yield(this, \"timeout\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("yield(this, \\\"timeout\\\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true); - - valid = valid & test_conversion_single_additional_builtin(" Transform.xform(Vector3(a,b,c)) ", " Transform * Vector3(a,b,c) ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin(" Transform.xform_inv(Vector3(a,b,c)) ", " Vector3(a,b,c) * Transform ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("export(float) var lifetime = 3.0", "export var lifetime: float = 3.0", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro'", "export var _font_name = 'AnonymousPro' # (String, 'AnonymousPro', 'CourierPrime')", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); // TODO, this is only a workaround - valid = valid & test_conversion_single_additional_builtin("export(PackedScene) var mob_scene", "export var mob_scene: PackedScene", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("var d = parse_json(roman(sfs))", "var test_json_conv = JSON.new()\ntest_json_conv.parse(roman(sfs))\nvar d = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("to_json( AA ) szon", "JSON.new().stringify( AA ) szon", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("s to_json", "s JSON.new().stringify", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("AF to_json2", "AF to_json2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("var rr = JSON.parse(a)", "var test_json_conv = JSON.new()\ntest_json_conv.parse(a)\nvar rr = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("empty()", "is_empty()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin(".empty", ".empty", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin(").roman(", ").roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\t.roman(", "\tsuper.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin(" .roman(", " super.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin(".1", ".1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin(" .1", " .1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("'.'", "'.'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("'.a'", "'.a'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\t._input(_event)", "\tsuper._input(_event)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C) != OK):", "(connect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C,D) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C,[D]) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C,[D,E]) != OK):", "(connect(A,Callable(B,C).bind(D,E)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C,[D,E],F) != OK):", "(connect(A,Callable(B,C).bind(D,E),F) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("(start(A,B) != OK):", "(start(Callable(A,B)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("func start(A,B):", "func start(A,B):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(start(A,B,C,D,E,F,G) != OK):", "(start(Callable(A,B).bind(C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("disconnect(A,B,C) != OK):", "disconnect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("is_connected(A,B,C) != OK):", "is_connected(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("is_connected(A,B,C))", "is_connected(A,Callable(B,C)))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("(tween_method(A,B,C,D,E).foo())", "(tween_method(Callable(A,B),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(tween_method(A,B,C,D,E,[F,G]).foo())", "(tween_method(Callable(A,B).bind(F,G),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(tween_callback(A,B).foo())", "(tween_callback(Callable(A,B)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("(tween_callback(A,B,[C,D]).foo())", "(tween_callback(Callable(A,B).bind(C,D)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("func _init(p_x:int)->void:", "func _init(p_x:int):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("assert(speed < 20, str(randi()%10))", "assert(speed < 20) #,str(randi()%10))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("assert(speed < 2)", "assert(speed < 2)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("assert(false, \"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", "assert(false) #,\"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("create_from_image(aa, bb)", "create_from_image(aa) #,bb", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("q_ImageTexture.create_from_image(variable1, variable2)", "q_ImageTexture.create_from_image(variable1) #,variable2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("set_cell_item(a, b, c, d ,e) # AA", "set_cell_item( Vector3(a,b,c) ,d,e) # AA", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("get_cell_item_orientation(a, b,c)", "get_cell_item_orientation(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("get_cell_item(a, b,c)", "get_cell_item(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("map_to_world(a, b,c)", "map_to_world(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin(" aa", " aa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\taa", "\taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("\t aa", "\taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin(" \taa", " \taa", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional_builtin("apply_force(position, impulse)", "apply_force(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_single_additional_builtin("apply_impulse(position, impulse)", "apply_impulse(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - - valid = valid & test_conversion_single_additional("AAA Color.white AF", "AAA Color.WHITE AF", &ProjectConverter3To4::rename_enums, "custom rename"); + valid = valid & test_conversion_with_regex("(Connect(A,B,C,D,E,F,G) != OK):", "(Connect(A,new Callable(B,C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("(Disconnect(A,B,C) != OK):", "(Disconnect(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("(IsConnected(A,B,C) != OK):", "(IsConnected(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename", reg_container); + + valid = valid & test_conversion_with_regex("[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[Sync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[Slave]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[Puppet]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[PuppetSync]", "[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[Master]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + valid = valid & test_conversion_with_regex("[MasterSync]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container); + + valid = valid & test_conversion_gdscript_builtin("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\"display/window/size/fullscreen\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true); + valid = valid & test_conversion_gdscript_builtin("OS.get_window_safe_area()", "DisplayServer.get_display_safe_area()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("\tvar aa = roman(r.move_and_slide( a, b, c, d, e, f )) # Roman", "\tr.set_velocity(a)\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\tvar aa = roman(r.move_and_slide_with_snap( a, g, b, c, d, e, f )) # Roman", "\tr.set_velocity(a)\n\t# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `g`\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("list_dir_begin( a , b )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("list_dir_begin( a )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("list_dir_begin( )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("sort_custom( a , b )", "sort_custom(Callable(a,b))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("func c(var a, var b)", "func c(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("draw_line(1, 2, 3, 4, 5)", "draw_line(1,2,3,4)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("\timage.lock()", "\tfalse # image.lock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\timage.unlock()", "\tfalse # image.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\troman.image.unlock()", "\tfalse # roman.image.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\tmtx.lock()", "\tmtx.lock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\tmutex.unlock()", "\tmutex.unlock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_with_regex("extends CSGBox", "extends CSGBox3D", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("CSGBox", "CSGBox3D", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial", "Node3D", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial.tscn", "Spatial.tscn", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial.gd", "Spatial.gd", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial.shader", "Spatial.shader", &ProjectConverter3To4::rename_classes, "classes", reg_container); + valid = valid & test_conversion_with_regex("Spatial.other", "Node3D.other", &ProjectConverter3To4::rename_classes, "classes", reg_container); + + valid = valid & test_conversion_with_regex("\nonready", "\n@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("onready", "@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex(" onready", " onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\nexport", "\n@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\texport", "\t@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\texport_dialog", "\texport_dialog", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("export", "@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex(" export", " export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("tool", "@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n tool", "\n tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\ntool", "\n\n@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nremote func", "\n\n@rpc(any_peer) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nremotesync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nsync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nslave func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\npuppet func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\npuppetsync func", "\n\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nmaster func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + valid = valid & test_conversion_with_regex("\n\nmastersync func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container); + + valid = valid & test_conversion_gdscript_builtin("var size : Vector2 = Vector2() setget set_function , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function\n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("var size : Vector2 = Vector2() setget set_function , ", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("var size : Vector2 = Vector2() setget set_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("var size : Vector2 = Vector2() setget , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function \n set(mod_value):\n mod_value # TODOConverter40 Non existent set function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("get_node(@", "get_node(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("yield(this, \"timeout\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("yield(this, \\\"timeout\\\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true); + + valid = valid & test_conversion_gdscript_builtin(" Transform.xform(Vector3(a,b,c)) ", " Transform * Vector3(a,b,c) ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(" Transform.xform_inv(Vector3(a,b,c)) ", " Vector3(a,b,c) * Transform ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("export(float) var lifetime = 3.0", "export var lifetime: float = 3.0", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro'", "export var _font_name = 'AnonymousPro' # (String, 'AnonymousPro', 'CourierPrime')", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); // TODO, this is only a workaround + valid = valid & test_conversion_gdscript_builtin("export(PackedScene) var mob_scene", "export var mob_scene: PackedScene", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("var d = parse_json(roman(sfs))", "var test_json_conv = JSON.new()\ntest_json_conv.parse(roman(sfs))\nvar d = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("to_json( AA ) szon", "JSON.new().stringify( AA ) szon", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("s to_json", "s JSON.new().stringify", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("AF to_json2", "AF to_json2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("var rr = JSON.parse(a)", "var test_json_conv = JSON.new()\ntest_json_conv.parse(a)\nvar rr = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("empty()", "is_empty()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(".empty", ".empty", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin(").roman(", ").roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\t.roman(", "\tsuper.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(" .roman(", " super.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(".1", ".1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin(" .1", " .1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("'.'", "'.'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("'.a'", "'.a'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("\t._input(_event)", "\tsuper._input(_event)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("(connect(A,B,C) != OK):", "(connect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(connect(A,B,C,D) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(connect(A,B,C,[D]) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(connect(A,B,C,[D,E]) != OK):", "(connect(A,Callable(B,C).bind(D,E)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(connect(A,B,C,[D,E],F) != OK):", "(connect(A,Callable(B,C).bind(D,E),F) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("(start(A,B) != OK):", "(start(Callable(A,B)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("func start(A,B):", "func start(A,B):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(start(A,B,C,D,E,F,G) != OK):", "(start(Callable(A,B).bind(C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("disconnect(A,B,C) != OK):", "disconnect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("is_connected(A,B,C) != OK):", "is_connected(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("is_connected(A,B,C))", "is_connected(A,Callable(B,C)))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E).foo())", "(tween_method(Callable(A,B),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E,[F,G]).foo())", "(tween_method(Callable(A,B).bind(F,G),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(tween_callback(A,B).foo())", "(tween_callback(Callable(A,B)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("(tween_callback(A,B,[C,D]).foo())", "(tween_callback(Callable(A,B).bind(C,D)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("func _init(", "func _init(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("func _init(p_x:int)->void:", "func _init(p_x:int):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("assert(speed < 20, str(randi()%10))", "assert(speed < 20) #,str(randi()%10))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("assert(speed < 2)", "assert(speed < 2)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("assert(false, \"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", "assert(false) #,\"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("create_from_image(aa, bb)", "create_from_image(aa) #,bb", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("q_ImageTexture.create_from_image(variable1, variable2)", "q_ImageTexture.create_from_image(variable1) #,variable2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("set_cell_item(a, b, c, d ,e) # AA", "set_cell_item( Vector3(a,b,c) ,d,e) # AA", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("get_cell_item_orientation(a, b,c)", "get_cell_item_orientation(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("get_cell_item(a, b,c)", "get_cell_item(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("map_to_world(a, b,c)", "map_to_world(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_gdscript_builtin("apply_force(position, impulse)", "apply_force(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("apply_impulse(position, impulse)", "apply_impulse(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("draw_rect(a,b,c,d,e).abc", "draw_rect(a,b,c,d).abc# e) TODOGODOT4 Antialiasing argument is missing", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("get_focus_owner()", "get_viewport().gui_get_focus_owner()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("button.pressed = 1", "button.button_pressed = 1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("button.pressed=1", "button.button_pressed=1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("button.pressed SF", "button.pressed SF", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + + valid = valid & test_conversion_with_regex("AAA Color.white AF", "AAA Color.WHITE AF", &ProjectConverter3To4::rename_colors, "custom rename", reg_container); // Custom rule conversion { String from = "instance"; String to = "instantiate"; String name = "AA.instance()"; - String got = "AA.instance()"; + Vector<String> got = String("AA.instance()").split("\n"); String expected = "AA.instantiate()"; custom_rename(got, from, to); - if (got != expected) { - ERR_PRINT("Failed to convert custom rename `" + name + "` to `" + expected + "`, got instead `" + got + "`"); + String got_str = collect_string_from_vector(got); + if (got_str != expected) { + ERR_PRINT("Failed to convert custom rename `" + name + "` to `" + expected + "`, got instead `" + got_str + "`"); } - valid = valid & (got == expected); + valid = valid & (got_str == expected); } // get_object_of_execution @@ -2317,8 +2559,7 @@ bool ProjectConverter3To4::test_array_names() { // Validate if all classes are valid { - int current_index = 0; - while (class_renames[current_index][0]) { + for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) { const String old_class = class_renames[current_index][0]; const String new_class = class_renames[current_index][1]; @@ -2333,84 +2574,65 @@ bool ProjectConverter3To4::test_array_names() { ERR_PRINT(String("Class `") + new_class + "` doesn't exists in Godot 4.0, so cannot be used in conversion."); valid = false; // This probably should be only a warning, but not 100% sure - this would need to be added to CI } - current_index++; - } - } - - // // TODO To be able to fully work, it needs https://github.com/godotengine/godot/pull/49053 - // // TODO this needs to be changed to hashset when available https://github.com/godotengine/godot-proposals/issues/867, to speedup searchng - // { - // OrderedHashMap<String, bool> all_functions; - - // List<StringName> classes_list; - // ClassDB::get_class_list(&classes_list); - // for (StringName &name_of_class : classes_list) { - // List<MethodInfo> method_list; - // ClassDB::get_method_list(name_of_class, &method_list, true); - // for (MethodInfo &function_data : method_list) { - // if (!all_functions.has(function_data.name)) { - // all_functions.insert(function_data.name, false); - // } - // } - // } - - // for (int type = Variant::Type::NIL + 1; type < Variant::Type::VARIANT_MAX; type++) { - // List<MethodInfo> method_list; - // Variant::get_method_list_by_type(&method_list, Variant::Type(type)); - // for (MethodInfo &function_data : method_list) { - // if (!all_functions.has(function_data.name)) { - // all_functions.insert(function_data.name, false); - // } - // } - // } - - // int current_element = 0; - // while (gdscript_function_renames[current_element][0] != nullptr) { - // if (!all_functions.has(gdscript_function_renames[current_element][1])) { - // ERR_PRINT(String("Missing gdscript function in pair (") + gdscript_function_renames[current_element][0] + " - ===> " + gdscript_function_renames[current_element][1] + " <===)"); - // valid = false; - // } - // // // DEBUG, disable below after tests - // // if (all_functions.has(gdscript_function_renames[current_element][0])) { - // // String used_in_classes = ""; - // // - // // for (StringName &name_of_class : classes_list) { - // // List<MethodInfo> method_list; - // // ClassDB::get_method_list(name_of_class, &method_list, true); - // // for (MethodInfo &function_data : method_list) { - // // if (function_data.name == gdscript_function_renames[current_element][0]) { - // // used_in_classes += String(name_of_class) + ", "; - // // } - // // } - // // } - // // for (int type = Variant::Type::NIL + 1; type < Variant::Type::VARIANT_MAX; type++) { - // // List<MethodInfo> method_list; - // // Variant::get_method_list_by_type(&method_list, Variant::Type(type)); - // // for (MethodInfo &function_data : method_list) { - // // if (function_data.name == gdscript_function_renames[current_element][0]) { - // // used_in_classes += Variant::get_type_name(Variant::Type(type)) + ", "; - // // } - // // } - // // } - // // used_in_classes = used_in_classes.trim_suffix(", "); - // // - // // WARN_PRINT(String("Godot contains function which will be renamed in pair ( ===> ") + gdscript_function_renames[current_element][0] + " <=== - " + gdscript_function_renames[current_element][1] + ") in class " + used_in_classes + " - check for possible invalid rule."); - // // } - // current_element++; - // } - // } + } + } + + { + HashSet<String> all_functions; + + // List of excluded functions from builtin types and global namespace, because currently it is not possible to get list of functions from them + // This will be available when https://github.com/godotengine/godot/pull/49053 or similar will be included into Godot + static const char *builtin_types_excluded_functions[] = { "dict_to_inst", "inst_to_dict", "bytes_to_var", "bytes_to_var_with_objects", "db_to_linear", "deg_to_rad", "linear_to_db", "rad_to_deg", "randf_range", "snapped", "str_to_var", "var_to_str", "var_to_bytes", "var_to_bytes_with_objects", "move_toward", "uri_encode", "uri_decode", "remove_at", "get_rotation_quaternion", "clamp", "grow_side", "is_absolute_path", "is_valid_int", "lerp", "to_ascii_buffer", "to_utf8_buffer", "to_utf32_buffer", "snapped", nullptr }; + for (int current_index = 0; builtin_types_excluded_functions[current_index]; current_index++) { + all_functions.insert(builtin_types_excluded_functions[current_index]); + } + + // for (int type = Variant::Type::NIL + 1; type < Variant::Type::VARIANT_MAX; type++) { + // List<MethodInfo> method_list; + // Variant::get_method_list_by_type(&method_list, Variant::Type(type)); + // for (MethodInfo &function_data : method_list) { + // if (!all_functions.has(function_data.name)) { + // all_functions.insert(function_data.name); + // } + // } + // } + + List<StringName> classes_list; + ClassDB::get_class_list(&classes_list); + for (StringName &name_of_class : classes_list) { + List<MethodInfo> method_list; + ClassDB::get_method_list(name_of_class, &method_list, true); + for (MethodInfo &function_data : method_list) { + if (!all_functions.has(function_data.name)) { + all_functions.insert(function_data.name); + } + } + } + + int current_element = 0; + while (gdscript_function_renames[current_element][0] != nullptr) { + if (!all_functions.has(gdscript_function_renames[current_element][1])) { + ERR_PRINT(String("Missing gdscript function in pair (") + gdscript_function_renames[current_element][0] + " - ===> " + gdscript_function_renames[current_element][1] + " <===)"); + valid = false; + } + current_element++; + } + } + if (!valid) { + ERR_PRINT("Found function which is used in converter, but cannot be found in Godot 4. Rename this element to new name or remove entire rule about it if is obsolete."); + } valid = valid & test_single_array(enum_renames); valid = valid & test_single_array(class_renames, true); valid = valid & test_single_array(gdscript_function_renames, true); valid = valid & test_single_array(csharp_function_renames, true); - valid = valid & test_single_array(gdscript_properties_renames); + valid = valid & test_single_array(gdscript_properties_renames, true); valid = valid & test_single_array(csharp_properties_renames); - valid = valid & test_single_array(shaders_renames); + valid = valid & test_single_array(shaders_renames, true); valid = valid & test_single_array(gdscript_signals_renames); valid = valid & test_single_array(project_settings_renames); valid = valid & test_single_array(builtin_types_renames); - valid = valid & test_single_array(colors_renames); + valid = valid & test_single_array(color_renames); return valid; } @@ -2419,10 +2641,9 @@ bool ProjectConverter3To4::test_array_names() { // Also checks if in name contains spaces at the end or beginning bool ProjectConverter3To4::test_single_array(const char *array[][2], bool ignore_second_check) { bool valid = true; - int current_index = 0; Vector<String> names = Vector<String>(); - while (array[current_index][0]) { + for (unsigned int current_index = 0; array[current_index][0]; current_index++) { if (String(array[current_index][0]).begins_with(" ") || String(array[current_index][0]).ends_with(" ")) { { ERR_PRINT(String("Entry \"") + array[current_index][0] + "\" ends or stars with space."); @@ -2448,7 +2669,6 @@ bool ProjectConverter3To4::test_single_array(const char *array[][2], bool ignore if (!ignore_second_check) { names.append(array[current_index][1]); } - current_index++; } return valid; }; @@ -2458,18 +2678,17 @@ bool ProjectConverter3To4::test_single_array(const char *array[][2], bool ignore Vector<String> ProjectConverter3To4::parse_arguments(const String &line) { Vector<String> parts; int string_size = line.length(); - int current_index = 0; int start_part = 0; // Index of beginning of start par int parts_counter = 0; char32_t previous_character = '\0'; bool is_inside_string = false; // if true, it ignore this 3 characters ( , ) inside string if (line.count("(") != line.count(")")) { - ERR_PRINT("Bug: substring should have equal number of open and close parenthess - `" + line + "`"); + ERR_PRINT("Converter internal bug: substring should have equal number of open and close parenthess in line - `" + line + "`"); return parts; } - while (current_index < string_size) { + for (int current_index = 0; current_index < string_size; current_index++) { char32_t character = line.get(current_index); switch (character) { case '(': { @@ -2514,7 +2733,6 @@ Vector<String> ProjectConverter3To4::parse_arguments(const String &line) { is_inside_string = !is_inside_string; } } - current_index++; previous_character = character; } @@ -2532,9 +2750,8 @@ Vector<String> ProjectConverter3To4::parse_arguments(const String &line) { // Finds latest parenthess owned by function // `function(abc(a,b),DD)):` finds this parenthess `function(abc(a,b),DD => ) <= ):` int ProjectConverter3To4::get_end_parenthess(const String &line) const { - int current_index = 0; int current_state = 0; - while (line.length() > current_index) { + for (int current_index = 0; line.length() > current_index; current_index++) { char32_t character = line.get(current_index); if (character == '(') { current_state++; @@ -2545,7 +2762,6 @@ int ProjectConverter3To4::get_end_parenthess(const String &line) const { return current_index; } } - current_index++; } return -1; } @@ -2647,229 +2863,217 @@ String ProjectConverter3To4::get_object_of_execution(const String &line) const { return line.substr(variable_start, (end - variable_start)); } -void ProjectConverter3To4::rename_enums(String &file_content) { - int current_index = 0; - - // Rename colors - if (file_content.find("Color.") != -1) { - while (colors_renames[current_index][0]) { - RegEx reg = RegEx(String("\\bColor.") + colors_renames[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); - file_content = reg.sub(file_content, String("Color.") + colors_renames[current_index][1], true); - current_index++; +void ProjectConverter3To4::rename_colors(Vector<String> &lines, const RegExContainer ®_container) { + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + if (line.contains("Color.")) { + for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) { + line = reg_container.color_regexes[current_index]->sub(line, reg_container.color_renamed[current_index], true); + } + } } } }; -Vector<String> ProjectConverter3To4::check_for_rename_enums(Vector<String> &file_content) { - int current_index = 0; - - Vector<String> found_things; +Vector<String> ProjectConverter3To4::check_for_rename_colors(Vector<String> &lines, const RegExContainer ®_container) { + Vector<String> found_renames; - // Rename colors - if (file_content.find("Color.") != -1) { - while (colors_renames[current_index][0]) { - RegEx reg = RegEx(String("\\bColor.") + colors_renames[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); - - int current_line = 1; - for (String &line : file_content) { - TypedArray<RegExMatch> reg_match = reg.search_all(line); - if (reg_match.size() > 0) { - found_things.append(line_formatter(current_line, colors_renames[current_index][0], colors_renames[current_index][1], line)); + int current_line = 1; + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + if (line.contains("Color.")) { + for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) { + TypedArray<RegExMatch> reg_match = reg_container.color_regexes[current_index]->search_all(line); + if (reg_match.size() > 0) { + found_renames.append(line_formatter(current_line, color_renames[current_index][0], color_renames[current_index][1], line)); + } } - current_line++; } - current_index++; } + current_line++; } - return found_things; + return found_renames; } -void ProjectConverter3To4::rename_classes(String &file_content) { - int current_index = 0; - - // TODO Maybe it is better way to not rename gd, tscn and other files which are named as classes - while (class_renames[current_index][0]) { - // Begin renaming workaround `Resource.gd` -> `RefCounter.gd` - RegEx reg_before = RegEx(String("\\b") + class_renames[current_index][0] + ".tscn\\b"); - CRASH_COND(!reg_before.is_valid()); - file_content = reg_before.sub(file_content, "TEMP_RENAMED_CLASS.tscn", true); - RegEx reg_before2 = RegEx(String("\\b") + class_renames[current_index][0] + ".gd\\b"); - CRASH_COND(!reg_before2.is_valid()); - file_content = reg_before2.sub(file_content, "TEMP_RENAMED_CLASS.gd", true); - RegEx reg_before3 = RegEx(String("\\b") + class_renames[current_index][0] + ".shader\\b"); - CRASH_COND(!reg_before3.is_valid()); - file_content = reg_before3.sub(file_content, "TEMP_RENAMED_CLASS.gd", true); - // End - - RegEx reg = RegEx(String("\\b") + class_renames[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); - file_content = reg.sub(file_content, class_renames[current_index][1], true); - - // Begin renaming workaround `Resource.gd` -> `RefCounter.gd` - RegEx reg_after = RegEx("\\bTEMP_RENAMED_CLASS.tscn\\b"); - CRASH_COND(!reg_after.is_valid()); - file_content = reg_after.sub(file_content, String(class_renames[current_index][0]) + ".tscn", true); - RegEx reg_after2 = RegEx("\\bTEMP_RENAMED_CLASS.gd\\b"); - CRASH_COND(!reg_after2.is_valid()); - file_content = reg_after2.sub(file_content, String(class_renames[current_index][0]) + ".gd", true); - RegEx reg_after3 = RegEx("\\bTEMP_RENAMED_CLASS.gd\\b"); - CRASH_COND(!reg_after3.is_valid()); - file_content = reg_after3.sub(file_content, String(class_renames[current_index][0]) + ".shader", true); - // End - - current_index++; - } - - // OS.get_ticks_msec -> Time.get_ticks_msec - RegEx reg_time1 = RegEx("OS.get_ticks_msec"); - CRASH_COND(!reg_time1.is_valid()); - file_content = reg_time1.sub(file_content, "Time.get_ticks_msec", true); - RegEx reg_time2 = RegEx("OS.get_ticks_usec"); - CRASH_COND(!reg_time2.is_valid()); - file_content = reg_time2.sub(file_content, "Time.get_ticks_usec", true); -}; - -Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &file_content) { - int current_index = 0; - - Vector<String> found_things; - - while (class_renames[current_index][0]) { - RegEx reg_before = RegEx(String("\\b") + class_renames[current_index][0] + ".tscn\\b"); - CRASH_COND(!reg_before.is_valid()); - RegEx reg_before2 = RegEx(String("\\b") + class_renames[current_index][0] + ".gd\\b"); - CRASH_COND(!reg_before2.is_valid()); - - RegEx reg = RegEx(String("\\b") + class_renames[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); +void ProjectConverter3To4::rename_classes(Vector<String> &lines, const RegExContainer ®_container) { + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) { + if (line.contains(class_renames[current_index][0])) { + bool found_ignored_items = false; + // Renaming Spatial.tscn to TEMP_RENAMED_CLASS.tscn + if (line.contains(String(class_renames[current_index][0]) + ".")) { + found_ignored_items = true; + line = reg_container.class_tscn_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.tscn", true); + line = reg_container.class_gd_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.gd", true); + line = reg_container.class_shader_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.shader", true); + } - int current_line = 1; - for (String &line : file_content) { - line = reg_before.sub(line, "TEMP_RENAMED_CLASS.tscn", true); - line = reg_before2.sub(line, "TEMP_RENAMED_CLASS.gd", true); + // Causal renaming Spatial -> Node3D + line = reg_container.class_regexes[current_index]->sub(line, class_renames[current_index][1], true); - TypedArray<RegExMatch> reg_match = reg.search_all(line); - if (reg_match.size() > 0) { - found_things.append(line_formatter(current_line, class_renames[current_index][0], class_renames[current_index][1], line)); + // Restore Spatial.tscn from TEMP_RENAMED_CLASS.tscn + if (found_ignored_items) { + line = reg_container.class_temp_tscn.sub(line, reg_container.class_temp_tscn_renames[current_index], true); + line = reg_container.class_temp_gd.sub(line, reg_container.class_temp_gd_renames[current_index], true); + line = reg_container.class_temp_shader.sub(line, reg_container.class_temp_shader_renames[current_index], true); + } + } } - current_line++; } - current_index++; } +}; + +Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &lines, const RegExContainer ®_container) { + Vector<String> found_renames; - // TODO OS -> TIME int current_line = 1; - RegEx reg_time1 = RegEx("OS.get_ticks_msec"); - CRASH_COND(!reg_time1.is_valid()); - RegEx reg_time2 = RegEx("OS.get_ticks_usec"); - CRASH_COND(!reg_time2.is_valid()); - for (String &line : file_content) { - String old = line; - line = reg_time1.sub(line, "Time.get_ticks_msec", true); - line = reg_time2.sub(line, "Time.get_ticks_usec", true); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) { + if (line.contains(class_renames[current_index][0])) { + String old_line = line; + bool found_ignored_items = false; + // Renaming Spatial.tscn to TEMP_RENAMED_CLASS.tscn + if (line.contains(String(class_renames[current_index][0]) + ".")) { + found_ignored_items = true; + line = reg_container.class_tscn_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.tscn", true); + line = reg_container.class_gd_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.gd", true); + line = reg_container.class_shader_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.shader", true); + } - if (old != line) { - found_things.append(simple_line_formatter(current_line, old, line)); + // Causal renaming Spatial -> Node3D + TypedArray<RegExMatch> reg_match = reg_container.class_regexes[current_index]->search_all(line); + if (reg_match.size() > 0) { + found_renames.append(line_formatter(current_line, class_renames[current_index][0], class_renames[current_index][1], old_line)); + } + + // Restore Spatial.tscn from TEMP_RENAMED_CLASS.tscn + if (found_ignored_items) { + line = reg_container.class_temp_tscn.sub(line, reg_container.class_temp_tscn_renames[current_index], true); + line = reg_container.class_temp_gd.sub(line, reg_container.class_temp_gd_renames[current_index], true); + line = reg_container.class_temp_shader.sub(line, reg_container.class_temp_shader_renames[current_index], true); + } + } + } } current_line++; } - return found_things; + return found_renames; } -void ProjectConverter3To4::rename_gdscript_functions(String &file_content, const RegExContainer ®_container, bool builtin) { - Vector<String> lines = file_content.split("\n"); - +void ProjectConverter3To4::rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin) { for (String &line : lines) { - process_gdscript_line(line, reg_container, builtin); - } - - // Collect vector to string - file_content = ""; - for (int i = 0; i < lines.size(); i++) { - file_content += lines[i]; - - if (i != lines.size() - 1) { - file_content += "\n"; + if (uint64_t(line.length()) <= maximum_line_length) { + process_gdscript_line(line, reg_container, builtin); } } }; -Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &file_content, const RegExContainer ®_container, bool builtin) { +Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin) { int current_line = 1; - Vector<String> found_things; + Vector<String> found_renames; - for (String &line : file_content) { - String old_line = line; - process_gdscript_line(line, reg_container, builtin); - if (old_line != line) { - found_things.append(simple_line_formatter(current_line, old_line, line)); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + String old_line = line; + process_gdscript_line(line, reg_container, builtin); + if (old_line != line) { + found_renames.append(simple_line_formatter(current_line, old_line, line)); + } } } - return found_things; + return found_renames; } + +// TODO, this function should run only on all .gd files and also on lines in tscn files which void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContainer ®_container, bool builtin) { - if (line.find("mtx") == -1 && line.find("mutex") == -1 && line.find("Mutex") == -1) { + // In this and other functions, reg.sub are used only after checking line with str.contains function which is sometimes few times faster with bigger line lengths + + if ((line.contains(".lock") || line.contains(".unlock")) && !line.contains("mtx") && !line.contains("mutex") && !line.contains("Mutex")) { line = reg_container.reg_image_lock.sub(line, "false # $1.lock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", true); line = reg_container.reg_image_unlock.sub(line, "false # $1.unlock() # TODOConverter40, image no longer require locking, `false` helps to not broke one line if/else, so can be freely removed", true); } - // Mixed use of spaces and tabs - tabs as first - TODO, this probably is problem problem, but not sure - line = reg_container.reg_mixed_tab_space.sub(line, "$1", true); - // PackedStringArray(req_godot).join('.') -> '.'.join(PackedStringArray(req_godot)) PoolStringArray - line = reg_container.reg_join.sub(line, "$2.join($1)", true); + if (line.contains(".join")) { + line = reg_container.reg_join.sub(line, "$2.join($1)", true); + } // -- empty() -> is_empty() Pool*Array - line = reg_container.reg_is_empty.sub(line, "is_empty(", true); + if (line.contains("empty")) { + line = reg_container.reg_is_empty.sub(line, "is_empty(", true); + } // -- \t.func() -> \tsuper.func() Object - line = reg_container.reg_super.sub(line, "$1super.$2", true); // TODO, not sure if possible, but for now this brake String text e.g. "Choosen .gitignore" -> "Choosen super.gitignore" + if (line.contains("(") && line.contains(".")) { + line = reg_container.reg_super.sub(line, "$1super.$2", true); // TODO, not sure if possible, but for now this broke String text e.g. "Choosen .gitignore" -> "Choosen super.gitignore" + } // -- JSON.parse(a) -> JSON.new().parse(a) etc. JSON - line = reg_container.reg_json_non_new.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); + if (line.contains("parse")) { + line = reg_container.reg_json_non_new.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); + } // -- to_json(a) -> JSON.new().stringify(a) Object - line = reg_container.reg_json_to.sub(line, "JSON.new().stringify", true); - + if (line.contains("to_json")) { + line = reg_container.reg_json_to.sub(line, "JSON.new().stringify", true); + } // -- parse_json(a) -> JSON.get_data() etc. Object - line = reg_container.reg_json_parse.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); + if (line.contains("parse_json")) { + line = reg_container.reg_json_parse.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true); + } // -- get_node(@ -> get_node( Node - line = line.replace("get_node(@", "get_node("); + if (line.contains("get_node")) { + line = line.replace("get_node(@", "get_node("); + } // export(float) var lifetime = 3.0 -> export var lifetime: float = 3.0 GDScript - line = reg_container.reg_export.sub(line, "export var $2: $1"); + if (line.contains("export")) { + line = reg_container.reg_export.sub(line, "export var $2: $1"); + } // export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro' -> export var _font_name = 'AnonymousPro' #(String, 'AnonymousPro', 'CourierPrime') GDScript - line = reg_container.reg_export_advanced.sub(line, "export var $2$3 # ($1)"); + if (line.contains("export")) { + line = reg_container.reg_export_advanced.sub(line, "export var $2$3 # ($1)"); + } // Setget Setget - line = reg_container.reg_setget_setget.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $4\n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); + if (line.contains("setget")) { + line = reg_container.reg_setget_setget.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $4\n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); + } // Setget set - line = reg_container.reg_setget_set.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Non existent get function \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); + if (line.contains("setget")) { + line = reg_container.reg_setget_set.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Non existent get function \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true); + } // Setget get - line = reg_container.reg_setget_get.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $3 \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Non existent set function", true); + if (line.contains("setget")) { + line = reg_container.reg_setget_get.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $3 \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Non existent set function", true); + } // OS.window_fullscreen = true -> ProjectSettings.set("display/window/size/fullscreen",true) - if (builtin) { - line = reg_container.reg_os_fullscreen.sub(line, "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", $1)", true); - } else { - line = reg_container.reg_os_fullscreen.sub(line, "ProjectSettings.set(\"display/window/size/fullscreen\", $1)", true); + if (line.contains("window_fullscreen")) { + if (builtin) { + line = reg_container.reg_os_fullscreen.sub(line, "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", $1)", true); + } else { + line = reg_container.reg_os_fullscreen.sub(line, "ProjectSettings.set(\"display/window/size/fullscreen\", $1)", true); + } } // Instantiate - line = reg_container.reg_instantiate.sub(line, ".instantiate($1)", true); + if (line.contains("instance")) { + line = reg_container.reg_instantiate.sub(line, ".instantiate($1)", true); + } // -- r.move_and_slide( a, b, c, d, e ) -> r.set_velocity(a) ... r.move_and_slide() KinematicBody - if (line.find("move_and_slide(") != -1) { + if (line.contains(("move_and_slide("))) { int start = line.find("move_and_slide("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2915,7 +3119,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- r.move_and_slide_with_snap( a, b, c, d, e ) -> r.set_velocity(a) ... r.move_and_slide() KinematicBody - if (line.find("move_and_slide_with_snap(") != -1) { + if (line.contains("move_and_slide_with_snap(")) { int start = line.find("move_and_slide_with_snap("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2966,7 +3170,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- sort_custom( a , b ) -> sort_custom(Callable( a , b )) Object - if (line.find("sort_custom(") != -1) { + if (line.contains("sort_custom(")) { int start = line.find("sort_custom("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2978,7 +3182,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- list_dir_begin( ) -> list_dir_begin() Object - if (line.find("list_dir_begin(") != -1) { + if (line.contains("list_dir_begin(")) { int start = line.find("list_dir_begin("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2987,7 +3191,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- draw_line(1,2,3,4,5) -> draw_line(1,2,3,4) CanvasItem - if (line.find("draw_line(") != -1) { + if (line.contains("draw_line(")) { int start = line.find("draw_line("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -2999,7 +3203,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- func c(var a, var b) -> func c(a, b) - if (line.find("func ") != -1 && line.find("var ") != -1) { + if (line.contains("func ") && line.contains("var ")) { int start = line.find("func "); start = line.substr(start).find("(") + start; int end = get_end_parenthess(line.substr(start)) + 1; @@ -3018,7 +3222,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- yield(this, \"timeout\") -> await this.timeout GDScript - if (line.find("yield(") != -1) { + if (line.contains("yield(")) { int start = line.find("yield("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3034,7 +3238,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- parse_json( AA ) -> TODO Object - if (line.find("parse_json(") != -1) { + if (line.contains("parse_json(")) { int start = line.find("parse_json("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3044,7 +3248,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- .xform(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform - if (line.find(".xform(") != -1) { + if (line.contains(".xform(")) { int start = line.find(".xform("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3056,12 +3260,12 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- .xform_inv(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform - if (line.find(".xform_inv(") != -1) { + if (line.contains(".xform_inv(")) { int start = line.find(".xform_inv("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { String object_exec = get_object_of_execution(line.substr(0, start)); - if (line.find(object_exec + ".xform") != -1) { + if (line.contains(object_exec + ".xform")) { int start2 = line.find(object_exec + ".xform"); Vector<String> parts = parse_arguments(line.substr(start, end)); if (parts.size() == 1) { @@ -3072,7 +3276,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- "(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) Object - if (line.find("connect(") != -1) { + if (line.contains("connect(")) { int start = line.find("connect("); // Protection from disconnect if (start == 0 || line.get(start - 1) != 's') { @@ -3088,7 +3292,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- disconnect(a,b,c) -> disconnect(a,Callable(b,c)) Object - if (line.find("disconnect(") != -1) { + if (line.contains("disconnect(")) { int start = line.find("disconnect("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3099,7 +3303,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- is_connected(a,b,c) -> is_connected(a,Callable(b,c)) Object - if (line.find("is_connected(") != -1) { + if (line.contains("is_connected(")) { int start = line.find("is_connected("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3111,7 +3315,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- "(tween_method(A,B,C,D,E) != OK):", "(tween_method(Callable(A,B),C,D,E) Object // -- "(tween_method(A,B,C,D,E,[F,G]) != OK):", "(tween_method(Callable(A,B).bind(F,G),C,D,E) Object - if (line.find("tween_method(") != -1) { + if (line.contains("tween_method(")) { int start = line.find("tween_method("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3124,7 +3328,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- "(tween_callback(A,B,[C,D]) != OK):", "(connect(Callable(A,B).bind(C,D)) Object - if (line.find("tween_callback(") != -1) { + if (line.contains("tween_callback(")) { int start = line.find("tween_callback("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3138,7 +3342,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } // -- start(a,b) -> start(Callable(a,b)) Thread // -- start(a,b,c,d) -> start(Callable(a,b).bind(c),d) Thread - if (line.find("start(") != -1) { + if (line.contains("start(")) { int start = line.find("start("); int end = get_end_parenthess(line.substr(start)) + 1; // Protection from 'func start' @@ -3154,16 +3358,18 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- func _init(p_x:int)->void: -> func _init(p_x:int): Object # https://github.com/godotengine/godot/issues/50589 - if (line.find(" _init(") != -1) { + if (line.contains(" _init(")) { int start = line.find(" _init("); - int end = line.rfind(":") + 1; - if (end > -1) { - Vector<String> parts = parse_arguments(line.substr(start, end)); - line = line.substr(0, start) + " _init(" + connect_arguments(parts, 0) + "):" + line.substr(end + start); + if (line.contains(":")) { + int end = line.rfind(":") + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + line = line.substr(0, start) + " _init(" + connect_arguments(parts, 0) + "):" + line.substr(end + start); + } } } // assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message - if (line.find("assert(") != -1) { + if (line.contains("assert(")) { int start = line.find("assert("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3174,7 +3380,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // create_from_image(aa, bb) -> create_from_image(aa) #, bb ImageTexture - if (line.find("create_from_image(") != -1) { + if (line.contains("create_from_image(")) { int start = line.find("create_from_image("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3185,7 +3391,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // set_cell_item(a, b, c, d ,e) -> set_cell_item(Vector3(a, b, c), d ,e) - if (line.find("set_cell_item(") != -1) { + if (line.contains("set_cell_item(")) { int start = line.find("set_cell_item("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3196,7 +3402,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // get_cell_item(a, b, c) -> get_cell_item(Vector3i(a, b, c)) - if (line.find("get_cell_item(") != -1) { + if (line.contains("get_cell_item(")) { int start = line.find("get_cell_item("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3207,7 +3413,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // get_cell_item_orientation(a, b, c) -> get_cell_item_orientation(Vector3i(a, b, c)) - if (line.find("get_cell_item_orientation(") != -1) { + if (line.contains("get_cell_item_orientation(")) { int start = line.find("get_cell_item_orientation("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3218,7 +3424,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // apply_impulse(A, B) -> apply_impulse(B, A) - if (line.find("apply_impulse(") != -1) { + if (line.contains("apply_impulse(")) { int start = line.find("apply_impulse("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3229,7 +3435,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // apply_force(A, B) -> apply_force(B, A) - if (line.find("apply_force(") != -1) { + if (line.contains("apply_force(")) { int start = line.find("apply_force("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3240,7 +3446,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // map_to_world(a, b, c) -> map_to_world(Vector3i(a, b, c)) - if (line.find("map_to_world(") != -1) { + if (line.contains("map_to_world(")) { int start = line.find("map_to_world("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3251,7 +3457,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // OS.get_window_safe_area() -> DisplayServer.get_display_safe_area() - if (line.find("OS.get_window_safe_area(") != -1) { + if (line.contains("OS.get_window_safe_area(")) { int start = line.find("OS.get_window_safe_area("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3261,14 +3467,59 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } } + // draw_rect(a,b,c,d,e) -> draw_rect(a,b,c,d)#e) TODOGODOT4 Antialiasing argument is missing + if (line.contains("draw_rect(")) { + int start = line.find("draw_rect("); + int end = get_end_parenthess(line.substr(start)) + 1; + if (end > -1) { + Vector<String> parts = parse_arguments(line.substr(start, end)); + if (parts.size() == 5) { + line = line.substr(0, start) + "draw_rect(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start) + "# " + parts[4] + ") TODOGODOT4 Antialiasing argument is missing"; + } + } + } + // get_focus_owner() -> get_viewport().gui_get_focus_owner() + if (line.contains("get_focus_owner()")) { + line = line.replace("get_focus_owner()", "get_viewport().gui_get_focus_owner()"); + } + + // button.pressed = 1 -> button.button_pressed = 1 + if (line.contains(".pressed")) { + int start = line.find(".pressed"); + bool foundNextEqual = false; + String line_to_check = line.substr(start + String(".pressed").length()); + for (int current_index = 0; line_to_check.length() > current_index; current_index++) { + char32_t chr = line_to_check.get(current_index); + if (chr == '\t' || chr == ' ') { + continue; + } else if (chr == '=') { + foundNextEqual = true; + } else { + break; + } + } + if (foundNextEqual) { + line = line.substr(0, start) + ".button_pressed" + line.substr(start + String(".pressed").length()); + } + } + + // OS -> Time functions + if (line.contains("OS.get_ticks_msec")) { + line = line.replace("OS.get_ticks_msec", "Time.get_ticks_msec"); + } + if (line.contains("OS.get_ticks_usec")) { + line = line.replace("OS.get_ticks_usec", "Time.get_ticks_usec"); + } + if (line.contains("OS.get_unix_time")) { + line = line.replace("OS.get_unix_time", "Time.get_unix_time_from_system"); + } } -void ProjectConverter3To4::process_csharp_line(String &line) { - // TODO maybe this can be changed to normal rule +void ProjectConverter3To4::process_csharp_line(String &line, const RegExContainer ®_container) { line = line.replace("OS.GetWindowSafeArea()", "DisplayServer.ScreenGetUsableRect()"); // -- Connect(,,,things) -> Connect(,Callable(,),things) Object - if (line.find("Connect(") != -1) { + if (line.contains("Connect(")) { int start = line.find("Connect("); // Protection from disconnect if (start == 0 || line.get(start - 1) != 's') { @@ -3282,7 +3533,7 @@ void ProjectConverter3To4::process_csharp_line(String &line) { } } // -- Disconnect(a,b,c) -> Disconnect(a,Callable(b,c)) Object - if (line.find("Disconnect(") != -1) { + if (line.contains("Disconnect(")) { int start = line.find("Disconnect("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3293,7 +3544,7 @@ void ProjectConverter3To4::process_csharp_line(String &line) { } } // -- IsConnected(a,b,c) -> IsConnected(a,Callable(b,c)) Object - if (line.find("IsConnected(") != -1) { + if (line.contains("IsConnected(")) { int start = line.find("IsConnected("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { @@ -3305,415 +3556,317 @@ void ProjectConverter3To4::process_csharp_line(String &line) { } } -void ProjectConverter3To4::rename_csharp_functions(String &file_content) { - Vector<String> lines = file_content.split("\n"); - +void ProjectConverter3To4::rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container) { for (String &line : lines) { - process_csharp_line(line); - } - - // Collect vector to string - file_content = ""; - for (int i = 0; i < lines.size(); i++) { - file_content += lines[i]; - - if (i != lines.size() - 1) { - file_content += "\n"; + if (uint64_t(line.length()) <= maximum_line_length) { + process_csharp_line(line, reg_container); } } }; -// This is almost 1:1 copy of function which rename gdscript functions -Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<String> &file_content) { +Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container) { int current_line = 1; - Vector<String> found_things; + Vector<String> found_renames; - for (String &line : file_content) { - String old_line = line; - process_csharp_line(line); - if (old_line != line) { - found_things.append(simple_line_formatter(current_line, old_line, line)); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + String old_line = line; + process_csharp_line(line, reg_container); + if (old_line != line) { + found_renames.append(simple_line_formatter(current_line, old_line, line)); + } } } - return found_things; + return found_renames; } -void ProjectConverter3To4::rename_csharp_attributes(String &file_content) { - // -- [Remote] -> [RPC(MultiplayerAPI.RPCMode.AnyPeer)] - { - RegEx reg_remote = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_remote.is_valid()); - file_content = reg_remote.sub(file_content, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true); - } - // -- [RemoteSync] -> [RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)] - { - RegEx reg_remotesync = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_remotesync.is_valid()); - file_content = reg_remotesync.sub(file_content, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true); - } - // -- [Puppet] -> [RPC] - { - RegEx reg_puppet = RegEx("\\[(Puppet|Slave)(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_puppet.is_valid()); - file_content = reg_puppet.sub(file_content, "[RPC]", true); - } - // -- [PuppetSync] -> [RPC(CallLocal = true)] - { - RegEx reg_puppetsync = RegEx("\\[PuppetSync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_puppetsync.is_valid()); - file_content = reg_puppetsync.sub(file_content, "[RPC(CallLocal = true)]", true); - } - String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n"; - // -- [Master] -> [RPC] - { - RegEx reg_remote = RegEx("\\[Master(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_remote.is_valid()); - file_content = reg_remote.sub(file_content, error_message + "[RPC]", true); - } - // -- [MasterSync] -> [RPC(CallLocal = true)] - { - RegEx reg_remote = RegEx("\\[MasterSync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!reg_remote.is_valid()); - file_content = reg_remote.sub(file_content, error_message + "[RPC(CallLocal = true)]", true); +void ProjectConverter3To4::rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container) { + static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n"; + + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + line = reg_container.keyword_csharp_remote.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true); + line = reg_container.keyword_csharp_remotesync.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true); + line = reg_container.keyword_csharp_puppet.sub(line, "[RPC]", true); + line = reg_container.keyword_csharp_puppetsync.sub(line, "[RPC(CallLocal = true)]", true); + line = reg_container.keyword_csharp_master.sub(line, error_message + "[RPC]", true); + line = reg_container.keyword_csharp_mastersync.sub(line, error_message + "[RPC(CallLocal = true)]", true); + } } } -Vector<String> ProjectConverter3To4::check_for_rename_csharp_attributes(Vector<String> &file_content) { +Vector<String> ProjectConverter3To4::check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container) { int current_line = 1; - Vector<String> found_things; + Vector<String> found_renames; - for (String &line : file_content) { - String old; - old = line; - { - RegEx regex = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[Puppet(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[Puppet]", "[RPC]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[(Puppet|Slave)Sync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC(CallLocal = true)]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[PuppetSync]", "[RPC(CallLocal = true)]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[Master(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[Master]", "[RPC]", line)); - } - old = line; - { - RegEx regex = RegEx("\\[MasterSync(Attribute)?(\\(\\))?\\]"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "[RPC(CallLocal = true)]", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "[MasterSync]", "[RPC(CallLocal = true)]", line)); - } + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + String old; + old = line; + line = reg_container.keyword_csharp_remote.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", line)); + } + old = line; + line = reg_container.keyword_csharp_remotesync.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", line)); + } + + old = line; + line = reg_container.keyword_csharp_puppet.sub(line, "[RPC]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[Puppet]", "[RPC]", line)); + } + + old = line; + line = reg_container.keyword_csharp_puppetsync.sub(line, "[RPC(CallLocal = true)]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[PuppetSync]", "[RPC(CallLocal = true)]", line)); + } + + old = line; + line = reg_container.keyword_csharp_master.sub(line, "[RPC]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[Master]", "[RPC]", line)); + } + + old = line; + line = reg_container.keyword_csharp_mastersync.sub(line, "[RPC(CallLocal = true)]", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "[MasterSync]", "[RPC(CallLocal = true)]", line)); + } + } current_line++; } - return found_things; + return found_renames; } -void ProjectConverter3To4::rename_gdscript_keywords(String &file_content) { - { - RegEx reg_first = RegEx("([\n]+)tool"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@tool", true); - RegEx reg_second = RegEx("^tool"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@tool", true); - } - { - RegEx reg_first = RegEx("([\n\t]+)export\\b"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@export", true); - RegEx reg_second = RegEx("^export"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@export", true); - } - { - RegEx reg_first = RegEx("([\n]+)onready"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@onready", true); - RegEx reg_second = RegEx("^onready"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@onready", true); - } - { - RegEx reg_first = RegEx("([\n]+)remote func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@rpc(any_peer) func", true); - RegEx reg_second = RegEx("^remote func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@rpc(any_peer) func", true); - } - { - RegEx reg_first = RegEx("([\n]+)remotesync func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@rpc(any_peer, call_local) func", true); - RegEx reg_second = RegEx("^remotesync func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@rpc(any_peer, call_local) func", true); - } - { - RegEx reg_first = RegEx("([\n]+)sync func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@rpc(any_peer, call_local) func", true); - RegEx reg_second = RegEx("^sync func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@rpc(any_peer, call_local) func", true); - } - { - RegEx reg_first = RegEx("([\n]+)slave func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@rpc func", true); - RegEx reg_second = RegEx("^slave func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@rpc func", true); - } - { - RegEx reg_first = RegEx("([\n]+)puppet func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@rpc func", true); - RegEx reg_second = RegEx("^puppet func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@rpc func", true); - } - { - RegEx reg_first = RegEx("([\n]+)puppetsync func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1@rpc(call_local) func", true); - RegEx reg_second = RegEx("^puppetsync func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, "@rpc(call_local) func", true); - } - String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n"; - { - RegEx reg_first = RegEx("([\n]+)master func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1" + error_message + "@rpc func", true); - RegEx reg_second = RegEx("^master func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, error_message + "@rpc func", true); - } - { - RegEx reg_first = RegEx("([\n]+)mastersync func"); - CRASH_COND(!reg_first.is_valid()); - file_content = reg_first.sub(file_content, "$1" + error_message + "@rpc(call_local) func", true); - RegEx reg_second = RegEx("^mastersync func"); - CRASH_COND(!reg_second.is_valid()); - file_content = reg_second.sub(file_content, error_message + "@rpc(call_local) func", true); +void ProjectConverter3To4::rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container) { + static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n"; + + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + if (line.contains("tool")) { + line = reg_container.keyword_gdscript_tool.sub(line, "@tool", true); + } + if (line.contains("export")) { + line = reg_container.keyword_gdscript_export_single.sub(line, "@export", true); + } + if (line.contains("export")) { + line = reg_container.keyword_gdscript_export_mutli.sub(line, "$1@export", true); + } + if (line.contains("onready")) { + line = reg_container.keyword_gdscript_onready.sub(line, "@onready", true); + } + if (line.contains("remote")) { + line = reg_container.keyword_gdscript_remote.sub(line, "@rpc(any_peer) func", true); + } + if (line.contains("remote")) { + line = reg_container.keyword_gdscript_remotesync.sub(line, "@rpc(any_peer, call_local) func", true); + } + if (line.contains("sync")) { + line = reg_container.keyword_gdscript_sync.sub(line, "@rpc(any_peer, call_local) func", true); + } + if (line.contains("slave")) { + line = reg_container.keyword_gdscript_slave.sub(line, "@rpc func", true); + } + if (line.contains("puppet")) { + line = reg_container.keyword_gdscript_puppet.sub(line, "@rpc func", true); + } + if (line.contains("puppet")) { + line = reg_container.keyword_gdscript_puppetsync.sub(line, "@rpc(call_local) func", true); + } + if (line.contains("master")) { + line = reg_container.keyword_gdscript_master.sub(line, error_message + "@rpc func", true); + } + if (line.contains("master")) { + line = reg_container.keyword_gdscript_mastersync.sub(line, error_message + "@rpc(call_local) func", true); + } + } } } -Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<String> &file_content) { - Vector<String> found_things; +Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container) { + Vector<String> found_renames; int current_line = 1; + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + String old; + + if (line.contains("tool")) { + old = line; + line = reg_container.keyword_gdscript_tool.sub(line, "@tool", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "tool", "@tool", line)); + } + } - for (String &line : file_content) { - String old; - old = line; - { - RegEx reg_first = RegEx("^tool"); - CRASH_COND(!reg_first.is_valid()); - line = reg_first.sub(line, "@tool", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "tool", "@tool", line)); - } - old = line; - { - RegEx reg_first = RegEx("([\t]+)export\\b"); - CRASH_COND(!reg_first.is_valid()); - line = reg_first.sub(line, "$1@export", true); - RegEx reg_second = RegEx("^export"); - CRASH_COND(!reg_second.is_valid()); - line = reg_second.sub(line, "@export", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "export", "@export", line)); - } - old = line; - { - RegEx reg_first = RegEx("^onready"); - CRASH_COND(!reg_first.is_valid()); - line = reg_first.sub(line, "@onready", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "onready", "@onready", line)); - } - old = line; - { - RegEx regex = RegEx("^remote func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc(any_peer) func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "remote func", "@rpc(any_peer) func", line)); - } - old = line; - { - RegEx regex = RegEx("^remotesync func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc(any_peer, call_local)) func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "remotesync func", "@rpc(any_peer, call_local)) func", line)); - } - old = line; - { - RegEx regex = RegEx("^sync func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc(any_peer, call_local)) func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "sync func", "@rpc(any_peer, call_local)) func", line)); - } - old = line; - { - RegEx regex = RegEx("^slave func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "slave func", "@rpc func", line)); - } - old = line; - { - RegEx regex = RegEx("^puppet func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "puppet func", "@rpc func", line)); - } - old = line; - { - RegEx regex = RegEx("^puppetsync func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc(call_local) func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "puppetsync func", "@rpc(call_local) func", line)); - } - old = line; - { - RegEx regex = RegEx("^master func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "master func", "@rpc func", line)); - } - old = line; - { - RegEx regex = RegEx("^mastersync func"); - CRASH_COND(!regex.is_valid()); - line = regex.sub(line, "@rpc(call_local) func", true); - } - if (old != line) { - found_things.append(line_formatter(current_line, "mastersync func", "@rpc(call_local) func", line)); - } - old = line; + if (line.contains("export")) { + old = line; + line = reg_container.keyword_gdscript_export_single.sub(line, "$1@export", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "export", "@export", line)); + } + } + if (line.contains("export")) { + old = line; + line = reg_container.keyword_gdscript_export_mutli.sub(line, "@export", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "export", "@export", line)); + } + } + + if (line.contains("onready")) { + old = line; + line = reg_container.keyword_gdscript_tool.sub(line, "@onready", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "onready", "@onready", line)); + } + } + + if (line.contains("remote")) { + old = line; + line = reg_container.keyword_gdscript_remote.sub(line, "@rpc(any_peer) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "remote func", "@rpc(any_peer) func", line)); + } + } + + if (line.contains("remote")) { + old = line; + line = reg_container.keyword_gdscript_remotesync.sub(line, "@rpc(any_peer, call_local)) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "remotesync func", "@rpc(any_peer, call_local)) func", line)); + } + } + + if (line.contains("sync")) { + old = line; + line = reg_container.keyword_gdscript_sync.sub(line, "@rpc(any_peer, call_local)) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "sync func", "@rpc(any_peer, call_local)) func", line)); + } + } + + if (line.contains("slave")) { + old = line; + line = reg_container.keyword_gdscript_slave.sub(line, "@rpc func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "slave func", "@rpc func", line)); + } + } + + if (line.contains("puppet")) { + old = line; + line = reg_container.keyword_gdscript_puppet.sub(line, "@rpc func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "puppet func", "@rpc func", line)); + } + } + + if (line.contains("puppet")) { + old = line; + line = reg_container.keyword_gdscript_puppetsync.sub(line, "@rpc(call_local) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "puppetsync func", "@rpc(call_local) func", line)); + } + } + + if (line.contains("master")) { + old = line; + line = reg_container.keyword_gdscript_master.sub(line, "@rpc func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "master func", "@rpc func", line)); + } + } + + if (line.contains("master")) { + old = line; + line = reg_container.keyword_gdscript_master.sub(line, "@rpc(call_local) func", true); + if (old != line) { + found_renames.append(line_formatter(current_line, "mastersync func", "@rpc(call_local) func", line)); + } + } + } current_line++; } - return found_things; + return found_renames; } -void ProjectConverter3To4::custom_rename(String &file_content, String from, String to) { +void ProjectConverter3To4::custom_rename(Vector<String> &lines, String from, String to) { RegEx reg = RegEx(String("\\b") + from + "\\b"); CRASH_COND(!reg.is_valid()); - file_content = reg.sub(file_content, to, true); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + line = reg.sub(line, to, true); + } + } }; -Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &file_content, String from, String to) { - Vector<String> found_things; +Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &lines, String from, String to) { + Vector<String> found_renames; RegEx reg = RegEx(String("\\b") + from + "\\b"); CRASH_COND(!reg.is_valid()); int current_line = 1; - for (String &line : file_content) { - TypedArray<RegExMatch> reg_match = reg.search_all(line); - if (reg_match.size() > 0) { - found_things.append(line_formatter(current_line, from.replace("\\.", "."), to, line)); // Without replacing it will print "\.shader" instead ".shader" + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + TypedArray<RegExMatch> reg_match = reg.search_all(line); + if (reg_match.size() > 0) { + found_renames.append(line_formatter(current_line, from.replace("\\.", "."), to, line)); // Without replacing it will print "\.shader" instead ".shader" + } } current_line++; } - return found_things; + return found_renames; } -void ProjectConverter3To4::rename_common(const char *array[][2], String &file_content) { - int current_index = 0; - while (array[current_index][0]) { - RegEx reg = RegEx(String("\\b") + array[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); - file_content = reg.sub(file_content, array[current_index][1], true); - current_index++; +void ProjectConverter3To4::rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines) { + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + for (unsigned int current_index = 0; current_index < cached_regexes.size(); current_index++) { + if (line.contains(array[current_index][0])) { + line = cached_regexes[current_index]->sub(line, array[current_index][1], true); + } + } + } } } -// Common renaming, -Vector<String> ProjectConverter3To4::check_for_rename_common(const char *array[][2], Vector<String> &file_content) { - int current_index = 0; - - Vector<String> found_things; +Vector<String> ProjectConverter3To4::check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines) { + Vector<String> found_renames; - while (array[current_index][0]) { - RegEx reg = RegEx(String("\\b") + array[current_index][0] + "\\b"); - CRASH_COND(!reg.is_valid()); + int current_line = 1; - int current_line = 1; - for (String &line : file_content) { - TypedArray<RegExMatch> reg_match = reg.search_all(line); - if (reg_match.size() > 0) { - found_things.append(line_formatter(current_line, array[current_index][0], array[current_index][1], line)); + for (String &line : lines) { + if (uint64_t(line.length()) <= maximum_line_length) { + for (unsigned int current_index = 0; current_index < cached_regexes.size(); current_index++) { + if (line.contains(array[current_index][0])) { + TypedArray<RegExMatch> reg_match = cached_regexes[current_index]->search_all(line); + if (reg_match.size() > 0) { + found_renames.append(line_formatter(current_line, array[current_index][0], array[current_index][1], line)); + } + } } - current_line++; } - current_index++; + current_line++; } - return found_things; + + return found_renames; } -// Formats data to print them into user console when trying to convert data +// Prints full info about renamed things e.g.: +// Line (67) remove -> remove_at - LINE """ doubler._blacklist.remove(0) """ String ProjectConverter3To4::line_formatter(int current_line, String from, String to, String line) { if (from.size() > 200) { from = from.substr(0, 197) + "..."; @@ -3727,6 +3880,8 @@ String ProjectConverter3To4::line_formatter(int current_line, String from, Strin return String("Line (") + itos(current_line) + ") " + from.replace("\r", "").replace("\n", "") + " -> " + to.replace("\r", "").replace("\n", "") + " - LINE \"\"\" " + line.replace("\r", "").replace("\n", "").strip_edges() + " \"\"\""; } +// Prints only full lines e.g.: +// Line (1) - FULL LINES - """yield(get_tree().create_timer(3), 'timeout')""" =====> """ await get_tree().create_timer(3).timeout """ String ProjectConverter3To4::simple_line_formatter(int current_line, String old_line, String line) { if (old_line.size() > 1000) { old_line = old_line.substr(0, 997) + "..."; @@ -3737,6 +3892,19 @@ String ProjectConverter3To4::simple_line_formatter(int current_line, String old_ return String("Line (") + itos(current_line) + ") - FULL LINES - \"\"\"" + old_line.replace("\r", "").replace("\n", "").strip_edges() + "\"\"\" =====> \"\"\" " + line.replace("\r", "").replace("\n", "").strip_edges() + " \"\"\""; } +// Collects string from vector strings +String ProjectConverter3To4::collect_string_from_vector(Vector<String> &vector) { + String string = ""; + for (int i = 0; i < vector.size(); i++) { + string += vector[i]; + + if (i != vector.size() - 1) { + string += "\n"; + } + } + return string; +} + #else // No regex. int ProjectConverter3To4::convert() { diff --git a/editor/project_converter_3_to_4.h b/editor/project_converter_3_to_4.h index 8526e2ceb9..fc6d66c9a8 100644 --- a/editor/project_converter_3_to_4.h +++ b/editor/project_converter_3_to_4.h @@ -35,37 +35,43 @@ #include "core/io/file_access.h" #include "core/object/ref_counted.h" #include "core/string/ustring.h" +#include "core/templates/local_vector.h" + +class RegEx; class ProjectConverter3To4 { public: class RegExContainer; private: - void rename_enums(String &file_content); - Vector<String> check_for_rename_enums(Vector<String> &file_content); + uint64_t maximum_file_size; + uint64_t maximum_line_length; + + void rename_colors(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_colors(Vector<String> &lines, const RegExContainer ®_container); - void rename_classes(String &file_content); - Vector<String> check_for_rename_classes(Vector<String> &file_content); + void rename_classes(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_classes(Vector<String> &lines, const RegExContainer ®_container); - void rename_gdscript_functions(String &file_content, const RegExContainer ®_container, bool builtin); - Vector<String> check_for_rename_gdscript_functions(Vector<String> &file_content, const RegExContainer ®_container, bool builtin); + void rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin); + Vector<String> check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin); void process_gdscript_line(String &line, const RegExContainer ®_container, bool builtin); - void rename_csharp_functions(String &file_content); - Vector<String> check_for_rename_csharp_functions(Vector<String> &file_content); - void process_csharp_line(String &line); + void rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container); + void process_csharp_line(String &line, const RegExContainer ®_container); - void rename_csharp_attributes(String &file_content); - Vector<String> check_for_rename_csharp_attributes(Vector<String> &file_content); + void rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer ®_container); - void rename_gdscript_keywords(String &file_content); - Vector<String> check_for_rename_gdscript_keywords(Vector<String> &file_content); + void rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container); + Vector<String> check_for_rename_gdscript_keywords(Vector<String> &lines, const RegExContainer ®_container); - void custom_rename(String &file_content, String from, String to); - Vector<String> check_for_custom_rename(Vector<String> &file_content, String from, String to); + void custom_rename(Vector<String> &lines, String from, String to); + Vector<String> check_for_custom_rename(Vector<String> &lines, String from, String to); - void rename_common(const char *array[][2], String &file_content); - Vector<String> check_for_rename_common(const char *array[][2], Vector<String> &file_content); + void rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines); + Vector<String> check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines); Vector<String> check_for_files(); @@ -77,15 +83,17 @@ private: String line_formatter(int current_line, String from, String to, String line); String simple_line_formatter(int current_line, String old_line, String line); + String collect_string_from_vector(Vector<String> &vector); bool test_single_array(const char *array[][2], bool ignore_second_check = false); - bool test_conversion_single_additional(String name, String expected, void (ProjectConverter3To4::*func)(String &), String what); - bool test_conversion_single_additional_builtin(String name, String expected, void (ProjectConverter3To4::*func)(String &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin); - bool test_conversion_single_normal(String name, String expected, const char *array[][2], String what); + bool test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &, bool), String what, const RegExContainer ®_container, bool builtin); + bool test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &), String what, const RegExContainer ®_container); + bool test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> ®ex_cache, String what); bool test_array_names(); - bool test_conversion(const RegExContainer ®_container); + bool test_conversion(RegExContainer ®_container); public: + ProjectConverter3To4(int, int); int validate_conversion(); int convert(); }; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 6623792fc0..9909ab378a 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -438,7 +438,7 @@ private: ProjectSettings::CustomMap edited_settings; edited_settings["application/config/name"] = project_name->get_text().strip_edges(); - if (current->save_custom(dir2.plus_file("project.godot"), edited_settings, Vector<String>(), true) != OK) { + if (current->save_custom(dir2.path_join("project.godot"), edited_settings, Vector<String>(), true) != OK) { set_message(TTR("Couldn't edit project.godot in project path."), MESSAGE_ERROR); } } @@ -486,12 +486,12 @@ private: initial_settings["application/config/name"] = project_name->get_text().strip_edges(); initial_settings["application/config/icon"] = "res://icon.svg"; - if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("project.godot"), initial_settings, Vector<String>(), false) != OK) { + if (ProjectSettings::get_singleton()->save_custom(dir.path_join("project.godot"), initial_settings, Vector<String>(), false) != OK) { set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { // Store default project icon in SVG format. Error err; - Ref<FileAccess> fa_icon = FileAccess::open(dir.plus_file("icon.svg"), FileAccess::WRITE, &err); + Ref<FileAccess> fa_icon = FileAccess::open(dir.path_join("icon.svg"), FileAccess::WRITE, &err); fa_icon->store_string(get_default_project_icon()); if (err != OK) { @@ -556,7 +556,7 @@ private: String rel_path = path.substr(zip_root.length()); Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - da->make_dir(dir.plus_file(rel_path)); + da->make_dir(dir.path_join(rel_path)); } else { Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -568,7 +568,7 @@ private: 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.plus_file(rel_path), FileAccess::WRITE); + Ref<FileAccess> f = FileAccess::open(dir.path_join(rel_path), FileAccess::WRITE); if (f.is_valid()) { f->store_buffer(data.ptr(), data.size()); } else { @@ -962,12 +962,12 @@ public: switch (p_what) { case NOTIFICATION_MOUSE_ENTER: { hover = true; - update(); + queue_redraw(); } break; case NOTIFICATION_MOUSE_EXIT: { hover = false; - update(); + queue_redraw(); } break; case NOTIFICATION_DRAW: { @@ -1126,7 +1126,7 @@ ProjectList::ProjectList() { _icon_load_index = 0; project_opening_initiated = false; - _config_path = EditorPaths::get_singleton()->get_data_dir().plus_file("projects.cfg"); + _config_path = EditorPaths::get_singleton()->get_data_dir().path_join("projects.cfg"); } ProjectList::~ProjectList() { @@ -1185,7 +1185,7 @@ void ProjectList::load_project_icon(int p_index) { // Load project data from p_property_key and return it in a ProjectList::Item. p_favorite is passed directly into the Item. ProjectList::Item ProjectList::load_project_data(const String &p_path, bool p_favorite) { - String conf = p_path.plus_file("project.godot"); + String conf = p_path.path_join("project.godot"); bool grayed = false; bool missing = false; @@ -1221,7 +1221,7 @@ ProjectList::Item ProjectList::load_project_data(const String &p_path, bool p_fa // when editing a project (but not when running it). last_edited = FileAccess::get_modified_time(conf); - String fscache = p_path.plus_file(".fscache"); + String fscache = p_path.path_join(".fscache"); if (FileAccess::exists(fscache)) { uint64_t cache_modified = FileAccess::get_modified_time(fscache); if (cache_modified > last_edited) { @@ -1341,7 +1341,7 @@ void ProjectList::_global_menu_open_project(const Variant &p_tag) { int idx = (int)p_tag; if (idx >= 0 && idx < _projects.size()) { - String conf = _projects[idx].path.plus_file("project.godot"); + String conf = _projects[idx].path.path_join("project.godot"); List<String> args; args.push_back(conf); OS::get_singleton()->create_instance(args); @@ -1682,7 +1682,7 @@ void ProjectList::select_project(int p_index) { _selected_project_paths.clear(); for (int i = 0; i < previous_selected_items.size(); ++i) { - previous_selected_items[i].control->update(); + previous_selected_items[i].control->queue_redraw(); } toggle_select(p_index); @@ -1728,7 +1728,7 @@ void ProjectList::toggle_select(int p_index) { } else { _selected_project_paths.insert(item.path); } - item.control->update(); + item.control->queue_redraw(); } void ProjectList::erase_selected_projects(bool p_delete_project_contents) { @@ -1860,7 +1860,7 @@ void ProjectManager::_notification(int p_what) { case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { settings_hb->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT); - update(); + queue_redraw(); } break; case NOTIFICATION_ENTER_TREE: { @@ -2112,7 +2112,7 @@ void ProjectManager::_open_selected_projects() { const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); for (const String &path : selected_list) { - String conf = path.plus_file("project.godot"); + String conf = path.path_join("project.godot"); if (!FileAccess::exists(conf)) { dialog_error->set_text(vformat(TTR("Can't open project at '%s'."), path)); @@ -2162,7 +2162,7 @@ void ProjectManager::_open_selected_projects_ask() { } // Update the project settings or don't open - const String conf = project.path.plus_file("project.godot"); + const String conf = project.path.path_join("project.godot"); const int config_version = project.version; PackedStringArray unsupported_features = project.unsupported_features; @@ -2235,7 +2235,7 @@ void ProjectManager::_run_project_confirm() { const String &path = selected_list[i].path; // `.substr(6)` on `ProjectSettings::get_singleton()->get_imported_files_path()` strips away the leading "res://". - if (!DirAccess::exists(path.plus_file(ProjectSettings::get_singleton()->get_imported_files_path().substr(6)))) { + if (!DirAccess::exists(path.path_join(ProjectSettings::get_singleton()->get_imported_files_path().substr(6)))) { run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import.")); run_error_diag->popup_centered(); continue; @@ -2280,7 +2280,7 @@ void ProjectManager::_scan_dir(const String &path) { String n = da->get_next(); while (!n.is_empty()) { if (da->current_is_dir() && !n.begins_with(".")) { - _scan_dir(da->get_current_dir().plus_file(n)); + _scan_dir(da->get_current_dir().path_join(n)); } else if (n == "project.godot") { _project_list->add_project(da->get_current_dir(), false); } diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 7b4df696b7..300a3d0f05 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -500,7 +500,7 @@ String RenameDialog::_postprocess(const String &subject) { if (style_id == 1) { // PascalCase to snake_case - result = result.camelcase_to_underscore(true); + result = result.to_snake_case(); result = _regex("_+", result, "_"); } else if (style_id == 2) { @@ -521,7 +521,7 @@ String RenameDialog::_postprocess(const String &subject) { end = start + 1; } buffer += result.substr(end, result.size() - (end + 1)); - result = buffer.replace("_", "").capitalize(); + result = buffer.to_pascal_case(); } } diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp index 94a5c07709..9b8684b7b8 100644 --- a/editor/scene_create_dialog.cpp +++ b/editor/scene_create_dialog.cpp @@ -111,7 +111,7 @@ void SceneCreateDialog::update_dialog() { } if (is_valid) { - scene_name = directory.plus_file(scene_name); + scene_name = directory.path_join(scene_name); Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (da->file_exists(scene_name)) { update_error(file_error_label, MSG_ERROR, TTR("File already exists.")); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c7c713fc67..e2265f2f83 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -240,7 +240,7 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N String new_name = parent->validate_child_name(instantiated_scene); EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton(); editor_data->get_undo_redo()->add_do_method(ed, "live_debug_instance_node", edited_scene->get_path_to(parent), p_files[i], new_name); - editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(new_name))); + editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).path_join(new_name))); } editor_data->get_undo_redo()->commit_action(); @@ -691,7 +691,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton(); editor_data->get_undo_redo()->add_do_method(ed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name()); - editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(dup->get_name()))); + editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).path_join(dup->get_name()))); add_below_node = dup; } @@ -1068,24 +1068,61 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } break; case TOOL_TOGGLE_SCENE_UNIQUE_NAME: { - List<Node *> selection = editor_selection->get_selected_node_list(); - List<Node *>::Element *e = selection.front(); - if (e) { - Ref<EditorUndoRedoManager> undo_redo = editor_data->get_undo_redo(); - Node *node = e->get(); - bool enabled = node->is_unique_name_in_owner(); - if (!enabled && get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(node->get_name())) != nullptr) { - accept->set_text(TTR("Another node already uses this unique name in the scene.")); + // Enabling/disabling based on the same node based on which the checkbox in the menu is checked/unchecked. + List<Node *>::Element *first_selected = editor_selection->get_selected_node_list().front(); + if (first_selected == nullptr) { + return; + } + bool enabling = !first_selected->get()->is_unique_name_in_owner(); + + List<Node *> full_selection = editor_selection->get_full_selected_node_list(); + Ref<EditorUndoRedoManager> undo_redo = editor_data->get_undo_redo(); + + if (enabling) { + Vector<Node *> new_unique_nodes; + Vector<StringName> new_unique_names; + Vector<StringName> cant_be_set_unique_names; + + for (Node *node : full_selection) { + if (node->is_unique_name_in_owner()) { + continue; + } + StringName name = node->get_name(); + if (new_unique_names.find(name) != -1 || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) { + cant_be_set_unique_names.push_back(name); + } else { + new_unique_nodes.push_back(node); + new_unique_names.push_back(name); + } + } + + if (new_unique_nodes.size()) { + undo_redo->create_action(TTR("Enable Scene Unique Name(s)")); + for (Node *node : new_unique_nodes) { + undo_redo->add_do_method(node, "set_unique_name_in_owner", true); + undo_redo->add_undo_method(node, "set_unique_name_in_owner", false); + } + undo_redo->commit_action(); + } + + if (cant_be_set_unique_names.size()) { + String popup_text = TTR("Unique names already used by another node in the scene:"); + popup_text += "\n"; + for (StringName name : cant_be_set_unique_names) { + popup_text += "\n" + String(name); + } + accept->set_text(popup_text); accept->popup_centered(); - return; } - if (!enabled) { - undo_redo->create_action(TTR("Enable Scene Unique Name")); - } else { - undo_redo->create_action(TTR("Disable Scene Unique Name")); + } else { // Disabling. + undo_redo->create_action(TTR("Disable Scene Unique Name(s)")); + for (Node *node : full_selection) { + if (!node->is_unique_name_in_owner()) { + continue; + } + undo_redo->add_do_method(node, "set_unique_name_in_owner", false); + undo_redo->add_undo_method(node, "set_unique_name_in_owner", true); } - undo_redo->add_do_method(node, "set_unique_name_in_owner", !enabled); - undo_redo->add_undo_method(node, "set_unique_name_in_owner", enabled); undo_redo->commit_action(); } } break; @@ -1200,7 +1237,7 @@ void SceneTreeDock::_notification(int p_what) { if (canvas_item_plugin) { canvas_item_plugin->get_canvas_item_editor()->connect("item_lock_status_changed", Callable(scene_tree, "_update_tree")); canvas_item_plugin->get_canvas_item_editor()->connect("item_group_status_changed", Callable(scene_tree, "_update_tree")); - scene_tree->connect("node_changed", callable_mp((CanvasItem *)canvas_item_plugin->get_canvas_item_editor()->get_viewport_control(), &CanvasItem::update)); + scene_tree->connect("node_changed", callable_mp((CanvasItem *)canvas_item_plugin->get_canvas_item_editor()->get_viewport_control(), &CanvasItem::queue_redraw)); } Node3DEditorPlugin *spatial_editor_plugin = Object::cast_to<Node3DEditorPlugin>(editor_data->get_editor("3D")); @@ -1469,7 +1506,7 @@ bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path, if (found_root_path) { NodePath root_path_new = found_root_path->value; if (!root_path_new.is_empty()) { - NodePath old_abs_path = NodePath(String(p_root_node->get_path()).plus_file(r_node_path)); + NodePath old_abs_path = NodePath(String(p_root_node->get_path()).path_join(r_node_path)); old_abs_path.simplify(); r_node_path = root_path_new.rel_path_to(old_abs_path); } @@ -1839,7 +1876,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V } editor_data->get_undo_redo()->add_do_method(ed, "live_debug_reparent_node", edited_scene->get_path_to(node), edited_scene->get_path_to(new_parent), new_name, p_position_in_parent + inc); - editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)).plus_file(new_name)), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index()); + editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)).path_join(new_name)), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index()); if (p_keep_global_xform) { if (Object::cast_to<Node2D>(node)) { @@ -2127,7 +2164,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { // hack, force 2d editor viewport to refresh after deletion if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) { - editor->get_viewport_control()->update(); + editor->get_viewport_control()->queue_redraw(); } _push_item(nullptr); @@ -2202,7 +2239,7 @@ void SceneTreeDock::_do_create(Node *p_parent) { String new_name = p_parent->validate_child_name(child); EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton(); editor_data->get_undo_redo()->add_do_method(ed, "live_debug_create_node", edited_scene->get_path_to(p_parent), child->get_class(), new_name); - editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(p_parent)).plus_file(new_name))); + editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(p_parent)).path_join(new_name))); } else { editor_data->get_undo_redo()->add_do_method(EditorNode::get_singleton(), "set_edited_scene", child); @@ -2821,14 +2858,26 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_separator(); menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); } + } - if (selection[0]->get_owner() == EditorNode::get_singleton()->get_edited_scene()) { - // Only for nodes owned by the edited scene root. + if (profile_allow_editing) { + // Allow multi-toggling scene unique names but only if all selected nodes are owned by the edited scene root. + bool all_owned = true; + for (Node *node : full_selection) { + if (node->get_owner() != EditorNode::get_singleton()->get_edited_scene()) { + all_owned = false; + break; + } + } + if (all_owned) { menu->add_separator(); menu->add_icon_check_item(get_theme_icon(SNAME("SceneUniqueName"), SNAME("EditorIcons")), TTR("Access as Scene Unique Name"), TOOL_TOGGLE_SCENE_UNIQUE_NAME); + // Checked based on `selection[0]` because `full_selection` has undesired ordering. menu->set_item_checked(menu->get_item_index(TOOL_TOGGLE_SCENE_UNIQUE_NAME), selection[0]->is_unique_name_in_owner()); } + } + if (selection.size() == 1) { bool is_external = (!selection[0]->get_scene_file_path().is_empty()); if (is_external) { bool is_inherited = selection[0]->get_scene_inherited_state() != nullptr; @@ -2938,9 +2987,9 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) { if (path.is_empty()) { String root_path = editor_data->get_edited_scene_root()->get_scene_file_path(); if (root_path.is_empty()) { - path = String("res://").plus_file(selected->get_name()); + path = String("res://").path_join(selected->get_name()); } else { - path = root_path.get_base_dir().plus_file(selected->get_name()); + path = root_path.get_base_dir().path_join(selected->get_name()); } } @@ -2997,9 +3046,9 @@ void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) { shader_name = selected_shader_material->get_name(); } if (root_path.is_empty()) { - path = String("res://").plus_file(shader_name); + path = String("res://").path_join(shader_name); } else { - path = root_path.get_base_dir().plus_file(shader_name); + path = root_path.get_base_dir().path_join(shader_name); } } @@ -3199,7 +3248,7 @@ void SceneTreeDock::_update_create_root_dialog() { favorite_nodes->get_child(i)->queue_delete(); } - Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().plus_file("favorites.Node"), FileAccess::READ); + Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites.Node"), FileAccess::READ); if (f.is_valid()) { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 00fd0c3aac..88ca371fac 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -354,7 +354,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { tooltip += "\n\n" + p_node->get_editor_description(); } - item->set_tooltip(0, tooltip); + item->set_tooltip_text(0, tooltip); } else if (p_node != get_scene_node() && !p_node->get_scene_file_path().is_empty() && can_open_instance) { item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); @@ -363,7 +363,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { tooltip += "\n\n" + p_node->get_editor_description(); } - item->set_tooltip(0, tooltip); + item->set_tooltip_text(0, tooltip); } else { StringName type = EditorNode::get_singleton()->get_object_custom_type_name(p_node); if (type == StringName()) { @@ -375,7 +375,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { tooltip += "\n\n" + p_node->get_editor_description(); } - item->set_tooltip(0, tooltip); + item->set_tooltip_text(0, tooltip); } if (can_open_instance && undo_redo.is_valid()) { //Show buttons only when necessary(SceneTreeDock) to avoid crashes @@ -505,7 +505,7 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { if (p_node->is_class("CanvasItem") || p_node->is_class("CanvasLayer") || p_node->is_class("Window")) { visible = p_node->call("is_visible"); - CanvasItemEditor::get_singleton()->get_viewport_control()->update(); + CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw(); } else if (p_node->is_class("Node3D")) { visible = p_node->call("is_visible"); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 15e992ce18..7d065b4920 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -824,7 +824,7 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c Vector<ScriptLanguage::ScriptTemplate> user_templates; String extension = language->get_extension(); - String dir_path = p_dir.plus_file(p_object); + String dir_path = p_dir.path_join(p_object); Ref<DirAccess> d = DirAccess::open(dir_path); if (d.is_valid()) { @@ -860,7 +860,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL // Parse file for meta-information and script content Error err; - Ref<FileAccess> file = FileAccess::open(p_path.plus_file(p_filename), FileAccess::READ, &err); + Ref<FileAccess> file = FileAccess::open(p_path.path_join(p_filename), FileAccess::READ, &err); if (!err) { while (!file->eof_reached()) { String line = file->get_line(); @@ -898,7 +898,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL // Get name from file name if no name in meta information if (script_template.name == String()) { - script_template.name = p_filename.get_basename().replace("_", " ").capitalize(); + script_template.name = p_filename.get_basename().capitalize(); } return script_template; diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index 8c4a231e8a..522fd7c645 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -161,7 +161,7 @@ void ShaderCreateDialog::_create_new() { shader = text_shader; StringBuilder code; - code += vformat("shader_type %s;\n", mode_menu->get_text().replace(" ", "").camelcase_to_underscore()); + code += vformat("shader_type %s;\n", mode_menu->get_text().to_snake_case()); if (current_template == 0) { // Default template. code += "\n"; diff --git a/editor/translations/extract.py b/editor/translations/extract.py index 7f3da400e7..07026baee2 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -139,7 +139,7 @@ theme_property_patterns = { } -# See String::camelcase_to_underscore(). +# See String::_camelcase_to_underscore(). capitalize_re = re.compile(r"(?<=\D)(?=\d)|(?<=\d)(?=\D([a-z]|\d))") |