diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/connections_dialog.cpp | 6 | ||||
-rw-r--r-- | editor/connections_dialog.h | 1 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_tree.h | 4 | ||||
-rw-r--r-- | editor/editor_node.cpp | 39 | ||||
-rw-r--r-- | editor/editor_settings_dialog.cpp | 1 | ||||
-rw-r--r-- | editor/export/editor_export_platform.cpp | 2 | ||||
-rw-r--r-- | editor/icons/MemberAnnotation.svg | 2 | ||||
-rw-r--r-- | editor/icons/MethodOverride.svg | 1 | ||||
-rw-r--r-- | editor/icons/MethodOverrideAndSlot.svg | 1 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 11 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 47 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 97 | ||||
-rw-r--r-- | editor/project_converter_3_to_4.cpp | 32 |
14 files changed, 179 insertions, 67 deletions
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 236f3d7b08..ddeb8643b8 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -367,6 +367,10 @@ void ConnectDialog::popup_dialog(const String &p_for_signal) { error_label->set_visible(!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root())); } + if (first_popup) { + first_popup = false; + _advanced_pressed(); + } popup_centered(); } @@ -389,6 +393,7 @@ void ConnectDialog::_advanced_pressed() { } _update_ok_enabled(); + EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "use_advanced_connections", advanced->is_pressed()); popup_centered(); } @@ -480,6 +485,7 @@ ConnectDialog::ConnectDialog() { vbc_left->add_child(advanced); advanced->set_text(TTR("Advanced")); advanced->set_h_size_flags(Control::SIZE_SHRINK_BEGIN | Control::SIZE_EXPAND); + advanced->set_pressed(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "use_advanced_connections", false)); advanced->connect("pressed", callable_mp(this, &ConnectDialog::_advanced_pressed)); HBoxContainer *hbox = memnew(HBoxContainer); diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index e37246e7a0..db2f855617 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -112,6 +112,7 @@ private: LineEdit *dst_method = nullptr; ConnectDialogBinds *cdbinds = nullptr; bool edit_mode = false; + bool first_popup = true; NodePath dst_path; VBoxContainer *vbc_right = nullptr; diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index 5b2df8abd5..5af3a0d84a 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -28,11 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene/gui/tree.h" - #ifndef EDITOR_DEBUGGER_TREE_H #define EDITOR_DEBUGGER_TREE_H +#include "scene/gui/tree.h" + class SceneDebuggerTree; class EditorFileDialog; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 673fa3404c..28768b7f34 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6901,23 +6901,24 @@ EditorNode::EditorNode() { play_button->set_toggle_mode(true); play_button->set_focus_mode(Control::FOCUS_NONE); play_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY)); + play_button->set_tooltip_text(TTR("Run the project's default scene.")); - ED_SHORTCUT_AND_COMMAND("editor/play", TTR("Play"), Key::F5); - ED_SHORTCUT_OVERRIDE("editor/play", "macos", KeyModifierMask::META | Key::B); - play_button->set_shortcut(ED_GET_SHORTCUT("editor/play")); + ED_SHORTCUT_AND_COMMAND("editor/run_project", TTR("Run Project"), Key::F5); + ED_SHORTCUT_OVERRIDE("editor/run_project", "macos", KeyModifierMask::META | Key::B); + play_button->set_shortcut(ED_GET_SHORTCUT("editor/run_project")); pause_button = memnew(Button); pause_button->set_flat(true); pause_button->set_toggle_mode(true); pause_button->set_icon(gui_base->get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); pause_button->set_focus_mode(Control::FOCUS_NONE); - pause_button->set_tooltip_text(TTR("Pause the scene execution for debugging.")); + pause_button->set_tooltip_text(TTR("Pause the running project's execution for debugging.")); pause_button->set_disabled(true); launch_pad_hb->add_child(pause_button); - ED_SHORTCUT("editor/pause_scene", TTR("Pause Scene"), Key::F7); - ED_SHORTCUT_OVERRIDE("editor/pause_scene", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::Y); - pause_button->set_shortcut(ED_GET_SHORTCUT("editor/pause_scene")); + ED_SHORTCUT("editor/pause_running_project", TTR("Pause Running Project"), Key::F7); + ED_SHORTCUT_OVERRIDE("editor/pause_running_project", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::Y); + pause_button->set_shortcut(ED_GET_SHORTCUT("editor/pause_running_project")); stop_button = memnew(Button); stop_button->set_flat(true); @@ -6925,12 +6926,12 @@ EditorNode::EditorNode() { stop_button->set_focus_mode(Control::FOCUS_NONE); stop_button->set_icon(gui_base->get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); stop_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_STOP)); - stop_button->set_tooltip_text(TTR("Stop the scene.")); + stop_button->set_tooltip_text(TTR("Stop the currently running project.")); stop_button->set_disabled(true); - ED_SHORTCUT("editor/stop", TTR("Stop"), Key::F8); - ED_SHORTCUT_OVERRIDE("editor/stop", "macos", KeyModifierMask::META | Key::PERIOD); - stop_button->set_shortcut(ED_GET_SHORTCUT("editor/stop")); + ED_SHORTCUT("editor/stop_running_project", TTR("Stop Running Project"), Key::F8); + ED_SHORTCUT_OVERRIDE("editor/stop_running_project", "macos", KeyModifierMask::META | Key::PERIOD); + stop_button->set_shortcut(ED_GET_SHORTCUT("editor/stop_running_project")); run_native = memnew(EditorRunNative); launch_pad_hb->add_child(run_native); @@ -6942,10 +6943,11 @@ EditorNode::EditorNode() { play_scene_button->set_toggle_mode(true); play_scene_button->set_focus_mode(Control::FOCUS_NONE); play_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY_SCENE)); + play_scene_button->set_tooltip_text(TTR("Run the currently edited scene.")); - ED_SHORTCUT_AND_COMMAND("editor/play_scene", TTR("Play Scene"), Key::F6); - ED_SHORTCUT_OVERRIDE("editor/play_scene", "macos", KeyModifierMask::META | Key::R); - play_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/play_scene")); + ED_SHORTCUT_AND_COMMAND("editor/run_current_scene", TTR("Run Current Scene"), Key::F6); + ED_SHORTCUT_OVERRIDE("editor/run_current_scene", "macos", KeyModifierMask::META | Key::R); + play_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/run_current_scene")); play_custom_scene_button = memnew(Button); play_custom_scene_button->set_flat(true); @@ -6953,12 +6955,11 @@ EditorNode::EditorNode() { play_custom_scene_button->set_toggle_mode(true); play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE); play_custom_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option).bind(RUN_PLAY_CUSTOM_SCENE)); + play_custom_scene_button->set_tooltip_text(TTR("Run a specific scene.")); - _reset_play_buttons(); - - ED_SHORTCUT_AND_COMMAND("editor/play_custom_scene", TTR("Play Custom Scene"), KeyModifierMask::CTRL | KeyModifierMask::SHIFT | Key::F5); - ED_SHORTCUT_OVERRIDE("editor/play_custom_scene", "macos", KeyModifierMask::META | KeyModifierMask::SHIFT | Key::R); - play_custom_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/play_custom_scene")); + ED_SHORTCUT_AND_COMMAND("editor/run_specific_scene", TTR("Run Specific Scene"), KeyModifierMask::META | KeyModifierMask::SHIFT | Key::F5); + ED_SHORTCUT_OVERRIDE("editor/run_specific_scene", "macos", KeyModifierMask::META | KeyModifierMask::SHIFT | Key::R); + play_custom_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/run_specific_scene")); write_movie_panel = memnew(PanelContainer); write_movie_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("MovieWriterButtonNormal"), SNAME("EditorStyles"))); diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 48e746ac36..2c09543d92 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -772,6 +772,7 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcut_editor = memnew(InputEventConfigurationDialog); shortcut_editor->connect("confirmed", callable_mp(this, &EditorSettingsDialog::_event_config_confirmed)); shortcut_editor->set_allowed_input_types(InputEventConfigurationDialog::InputType::INPUT_KEY); + shortcut_editor->set_close_on_escape(false); add_child(shortcut_editor); set_hide_on_ok(true); diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index bcc85570ed..13ab5cebf6 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -710,7 +710,7 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector if (type == "PackedScene") { // Its a scene. Ref<PackedScene> ps = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_IGNORE); ERR_FAIL_COND_V(ps.is_null(), p_path); - Node *node = ps->instantiate(); + Node *node = ps->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); // Make sure the child scene root gets the correct inheritance chain. ERR_FAIL_COND_V(node == nullptr, p_path); if (customize_scenes_plugins.size()) { for (uint32_t i = 0; i < customize_scenes_plugins.size(); i++) { diff --git a/editor/icons/MemberAnnotation.svg b/editor/icons/MemberAnnotation.svg index c73ebf7b9b..39bef6d9ee 100644 --- a/editor/icons/MemberAnnotation.svg +++ b/editor/icons/MemberAnnotation.svg @@ -1 +1 @@ -<svg width="16" height="16" version="1.0" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><script id="custom-useragent-string-page-script"/><path d="m13.821 12.756c-5.0033 3.9148-12.551 2.248-12.49-4.538 0.67424-11.471 17.312-7.4502 12.446 2.1173-1.0549 1.1955-2.0737 1.4617-3.1983 0.4329-0.21023-0.19282-0.44783-1.1594-0.3819-1.5089 0.35827-1.8946 1.0885-4.0778-0.72151-4.7234-2.4171-0.86457-4.5592 1.6495-4.9697 4.0193-0.47396 2.7343 2.284 3.3749 4.1487 1.9879 0.4553-0.36324 1.6433-1.3796 1.6806-1.9742" fill="none" stroke="#e0e0e0" stroke-linejoin="round" stroke-width="1.4928"/></svg> +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m13.821 12.756c-5.0033 3.9148-12.551 2.248-12.49-4.538.67424-11.471 17.312-7.4502 12.446 2.1173-1.0549 1.1955-2.0737 1.4617-3.1983.4329-.21023-.19282-.44783-1.1594-.3819-1.5089.35827-1.8946 1.0885-4.0778-.72151-4.7234-2.4171-.86457-4.5592 1.6495-4.9697 4.0193-.47396 2.7343 2.284 3.3749 4.1487 1.9879.4553-.36324 1.6433-1.3796 1.6806-1.9742" fill="none" stroke="#e0e0e0" stroke-linejoin="round" stroke-width="1.4928"/></svg> diff --git a/editor/icons/MethodOverride.svg b/editor/icons/MethodOverride.svg new file mode 100644 index 0000000000..004b9bf283 --- /dev/null +++ b/editor/icons/MethodOverride.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 4.2333332 4.2333332" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m.49005985 3.3580432.83285685-.0000001v-.7093212c.0027125-.6681099.2054076-1.1321001 1.0021593-1.1328214h.3207573v-.79375l1.3229167 1.0648649-1.3229167 1.0518017v-.79375h-.3364788c-.2888876 0-.4514151.2436282-.4573001.5980603 0 .2833012.0000193.4455045.0000289.7134508h.79375v.4907171l-2.15577345.00147z" fill="#5fb2ff"/></svg> diff --git a/editor/icons/MethodOverrideAndSlot.svg b/editor/icons/MethodOverrideAndSlot.svg new file mode 100644 index 0000000000..d3bd9f0253 --- /dev/null +++ b/editor/icons/MethodOverrideAndSlot.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 4.2333332 4.2333332" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m.15761184 3.636193h.37155483l.004252-.7093212c.0027092-.6681099.12999225-1.1321001.92674393-1.1328214h.1273374l.0042585-.7357171 1.3186582 1.006832-1.3229167 1.0700676v-.8531081h-.1260545c-.2888876 0-.3972562.2847204-.4031411.6391525 0 .2833012.0000193.4455045.0000289.7134508h1.2412654v.4907171h-2.14198686z" fill="#5fb2ff"/><path d="m2.38125.79375h1.5875v2.6458333h-1.5875v-.5291666h1.0583333v-1.5875h-1.0583333z" fill="#5fff97"/></svg> diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 77bc06533c..386519bc59 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -35,11 +35,13 @@ #include "core/io/resource_importer.h" #include "core/variant/dictionary.h" #include "scene/3d/importer_mesh_instance_3d.h" -#include "scene/3d/node_3d.h" #include "scene/resources/animation.h" +#include "scene/resources/box_shape_3d.h" +#include "scene/resources/capsule_shape_3d.h" +#include "scene/resources/cylinder_shape_3d.h" #include "scene/resources/mesh.h" #include "scene/resources/shape_3d.h" -#include "scene/resources/skin.h" +#include "scene/resources/sphere_shape_3d.h" class Material; class AnimationPlayer; @@ -311,11 +313,6 @@ public: virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override; }; -#include "scene/resources/box_shape_3d.h" -#include "scene/resources/capsule_shape_3d.h" -#include "scene/resources/cylinder_shape_3d.h" -#include "scene/resources/sphere_shape_3d.h" - template <class M> Vector<Ref<Shape3D>> ResourceImporterScene::get_collision_shapes(const Ref<Mesh> &p_mesh, const M &p_options) { ShapeType generate_shape_type = SHAPE_TYPE_DECOMPOSE_CONVEX; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 8791da8245..3679657567 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -227,6 +227,7 @@ void ScriptEditorBase::_bind_methods() { // TODO: This signal is no use for VisualScript. ADD_SIGNAL(MethodInfo("search_in_files_requested", PropertyInfo(Variant::STRING, "text"))); ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text"))); + ADD_SIGNAL(MethodInfo("go_to_method", PropertyInfo(Variant::OBJECT, "script"), PropertyInfo(Variant::STRING, "method"))); } class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache { @@ -2380,6 +2381,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, se->connect("request_save_history", callable_mp(this, &ScriptEditor::_save_history)); se->connect("search_in_files_requested", callable_mp(this, &ScriptEditor::_on_find_in_files_requested)); se->connect("replace_in_files_requested", callable_mp(this, &ScriptEditor::_on_replace_in_files_requested)); + se->connect("go_to_method", callable_mp(this, &ScriptEditor::script_goto_method)); //test for modification, maybe the script was not edited but was loaded @@ -2544,7 +2546,7 @@ void ScriptEditor::apply_scripts() const { } } -void ScriptEditor::reload_scripts() { +void ScriptEditor::reload_scripts(bool p_refresh_only) { for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (!se) { @@ -2557,30 +2559,33 @@ void ScriptEditor::reload_scripts() { continue; //internal script, who cares } - uint64_t last_date = edited_res->get_last_modified_time(); - uint64_t date = FileAccess::get_modified_time(edited_res->get_path()); + if (!p_refresh_only) { + uint64_t last_date = edited_res->get_last_modified_time(); + uint64_t date = FileAccess::get_modified_time(edited_res->get_path()); - if (last_date == date) { - continue; - } + if (last_date == date) { + continue; + } - Ref<Script> script = edited_res; - if (script != nullptr) { - Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); - ERR_CONTINUE(!rel_script.is_valid()); - script->set_source_code(rel_script->get_source_code()); - script->set_last_modified_time(rel_script->get_last_modified_time()); - script->reload(true); - } + Ref<Script> script = edited_res; + if (script != nullptr) { + Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); + ERR_CONTINUE(!rel_script.is_valid()); + script->set_source_code(rel_script->get_source_code()); + script->set_last_modified_time(rel_script->get_last_modified_time()); + script->reload(true); + } - Ref<TextFile> text_file = edited_res; - if (text_file != nullptr) { - Error err; - Ref<TextFile> rel_text_file = _load_text_file(text_file->get_path(), &err); - ERR_CONTINUE(!rel_text_file.is_valid()); - text_file->set_text(rel_text_file->get_text()); - text_file->set_last_modified_time(rel_text_file->get_last_modified_time()); + Ref<TextFile> text_file = edited_res; + if (text_file != nullptr) { + Error err; + Ref<TextFile> rel_text_file = _load_text_file(text_file->get_path(), &err); + ERR_CONTINUE(!rel_text_file.is_valid()); + text_file->set_text(rel_text_file->get_text()); + text_file->set_last_modified_time(rel_text_file->get_last_modified_time()); + } } + se->reload_text(); } diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 59191b8891..1e78dc4ec4 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -477,7 +477,7 @@ public: bool toggle_scripts_panel(); bool is_scripts_panel_toggled(); void apply_scripts() const; - void reload_scripts(); + void reload_scripts(bool p_refresh_only = false); void open_script_create_dialog(const String &p_base_name, const String &p_base_path); void open_text_file_create_dialog(const String &p_base_path, const String &p_base_name = ""); Ref<Resource> open_file(const String &p_file); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index ad07ac180b..7a57f8a1e2 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -956,10 +956,7 @@ void ScriptTextEditor::_update_connected_methods() { CodeEdit *text_edit = code_editor->get_text_editor(); text_edit->set_gutter_width(connection_gutter, text_edit->get_line_height()); for (int i = 0; i < text_edit->get_line_count(); i++) { - if (text_edit->get_line_gutter_metadata(i, connection_gutter) == "") { - continue; - } - text_edit->set_line_gutter_metadata(i, connection_gutter, ""); + text_edit->set_line_gutter_metadata(i, connection_gutter, Dictionary()); text_edit->set_line_gutter_icon(i, connection_gutter, nullptr); text_edit->set_line_gutter_clickable(i, connection_gutter, false); } @@ -974,6 +971,7 @@ void ScriptTextEditor::_update_connected_methods() { return; } + // Add connection icons to methods. Vector<Node *> nodes = _find_all_node_for_script(base, base, script); HashSet<StringName> methods_found; for (int i = 0; i < nodes.size(); i++) { @@ -1002,8 +1000,11 @@ void ScriptTextEditor::_update_connected_methods() { for (int j = 0; j < functions.size(); j++) { String name = functions[j].get_slice(":", 0); if (name == method) { + Dictionary line_meta; + line_meta["type"] = "connection"; + line_meta["method"] = method; line = functions[j].get_slice(":", 1).to_int() - 1; - text_edit->set_line_gutter_metadata(line, connection_gutter, method); + text_edit->set_line_gutter_metadata(line, connection_gutter, line_meta); text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); text_edit->set_line_gutter_clickable(line, connection_gutter, true); methods_found.insert(method); @@ -1033,6 +1034,58 @@ void ScriptTextEditor::_update_connected_methods() { } } } + + // Add override icons to methods. + methods_found.clear(); + for (int i = 0; i < functions.size(); i++) { + StringName name = StringName(functions[i].get_slice(":", 0)); + if (methods_found.has(name)) { + continue; + } + + String found_base_class; + StringName base_class = script->get_instance_base_type(); + Ref<Script> inherited_script = script->get_base_script(); + while (!inherited_script.is_null()) { + if (inherited_script->has_method(name)) { + found_base_class = "script:" + inherited_script->get_path(); + break; + } + + base_class = inherited_script->get_instance_base_type(); + inherited_script = inherited_script->get_base_script(); + } + + if (found_base_class.is_empty() && base_class) { + List<MethodInfo> methods; + ClassDB::get_method_list(base_class, &methods); + for (int j = 0; j < methods.size(); j++) { + if (methods[j].name == name) { + found_base_class = "builtin:" + base_class; + break; + } + } + } + + if (!found_base_class.is_empty()) { + int line = functions[i].get_slice(":", 1).to_int() - 1; + + Dictionary line_meta = text_edit->get_line_gutter_metadata(line, connection_gutter); + if (line_meta.is_empty()) { + // Add override icon to gutter. + line_meta["type"] = "inherits"; + line_meta["method"] = name; + line_meta["base_class"] = found_base_class; + text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("MethodOverride"), SNAME("EditorIcons"))); + text_edit->set_line_gutter_clickable(line, connection_gutter, true); + } else { + // If method is also connected to signal, then merge icons and keep the click behavior of the slot. + text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("MethodOverrideAndSlot"), SNAME("EditorIcons"))); + } + + methods_found.insert(name); + } + } } void ScriptTextEditor::_update_gutter_indexes() { @@ -1054,18 +1107,40 @@ void ScriptTextEditor::_gutter_clicked(int p_line, int p_gutter) { return; } - String method = code_editor->get_text_editor()->get_line_gutter_metadata(p_line, p_gutter); - if (method.is_empty()) { + Dictionary meta = code_editor->get_text_editor()->get_line_gutter_metadata(p_line, p_gutter); + String type = meta.get("type", ""); + if (type.is_empty()) { return; } - Node *base = get_tree()->get_edited_scene_root(); - if (!base) { + // All types currently need a method name. + String method = meta.get("method", ""); + if (method.is_empty()) { return; } - Vector<Node *> nodes = _find_all_node_for_script(base, base, script); - connection_info_dialog->popup_connections(method, nodes); + if (type == "connection") { + Node *base = get_tree()->get_edited_scene_root(); + if (!base) { + return; + } + + Vector<Node *> nodes = _find_all_node_for_script(base, base, script); + connection_info_dialog->popup_connections(method, nodes); + } else if (type == "inherits") { + String base_class_raw = meta["base_class"]; + PackedStringArray base_class_split = base_class_raw.split(":", true, 1); + + if (base_class_split[0] == "script") { + // Go to function declaration. + Ref<Script> base_script = ResourceLoader::load(base_class_split[1]); + ERR_FAIL_COND(!base_script.is_valid()); + emit_signal(SNAME("go_to_method"), base_script, method); + } else if (base_class_split[0] == "builtin") { + // Open method documentation. + emit_signal(SNAME("go_to_help"), "class_method:" + base_class_split[1] + ":" + method); + } + } } void ScriptTextEditor::_edit_option(int p_op) { diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index 253c3062b8..f8ba3f0354 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -217,6 +217,7 @@ static const char *gdscript_function_renames[][2] = { { "_get_configuration_warning", "_get_configuration_warnings" }, // Node { "_set_current", "set_current" }, // Camera2D { "_set_editor_description", "set_editor_description" }, // Node + { "_set_playing", "set_playing" }, // AnimatedSprite3D { "_toplevel_raise_self", "_top_level_raise_self" }, // CanvasItem { "_update_wrap_at", "_update_wrap_at_column" }, // TextEdit { "add_animation", "add_animation_library" }, // AnimationPlayer @@ -231,6 +232,7 @@ static const char *gdscript_function_renames[][2] = { { "add_scene_import_plugin", "add_scene_format_importer_plugin" }, //EditorPlugin { "add_stylebox_override", "add_theme_stylebox_override" }, // Control { "add_torque", "apply_torque" }, //RigidBody2D + { "agent_set_neighbor_dist", "agent_set_neighbor_distance" }, // NavigationServer2D, NavigationServer3D { "apply_changes", "_apply_changes" }, // EditorPlugin { "body_add_force", "body_apply_force" }, // PhysicsServer2D { "body_add_torque", "body_apply_torque" }, // PhysicsServer2D @@ -332,6 +334,7 @@ static const char *gdscript_function_renames[][2] = { { "get_metakey", "is_meta_pressed" }, // InputEventWithModifiers { "get_mid_height", "get_height" }, // CapsuleMesh { "get_motion_remainder", "get_remainder" }, // PhysicsTestMotionResult2D + { "get_neighbor_dist", "get_neighbor_distance" }, // NavigationAgent2D, NavigationAgent3D { "get_network_connected_peers", "get_peers" }, // Multiplayer API { "get_network_master", "get_multiplayer_authority" }, // Node { "get_network_peer", "get_multiplayer_peer" }, // Multiplayer API @@ -512,6 +515,7 @@ static const char *gdscript_function_renames[][2] = { { "set_max_atlas_size", "set_max_texture_size" }, // LightmapGI { "set_metakey", "set_meta_pressed" }, // InputEventWithModifiers { "set_mid_height", "set_height" }, // CapsuleMesh + { "set_neighbor_dist", "set_neighbor_distance" }, // NavigationAgent2D, NavigationAgent3D { "set_network_master", "set_multiplayer_authority" }, // Node { "set_network_peer", "set_multiplayer_peer" }, // Multiplayer API { "set_oneshot", "set_one_shot" }, // AnimatedTexture @@ -652,6 +656,7 @@ static const char *csharp_function_renames[][2] = { { "_GetConfigurationWarning", "_GetConfigurationWarnings" }, // Node { "_SetCurrent", "SetCurrent" }, // Camera2D { "_SetEditorDescription", "SetEditorDescription" }, // Node + { "_SetPlaying", "SetPlaying" }, // AnimatedSprite3D { "_ToplevelRaiseSelf", "_TopLevelRaiseSelf" }, // CanvasItem { "_UpdateWrapAt", "_UpdateWrapAtColumn" }, // TextEdit { "AddAnimation", "AddAnimationLibrary" }, // AnimationPlayer @@ -666,6 +671,7 @@ static const char *csharp_function_renames[][2] = { { "AddSceneImportPlugin", "AddSceneFormatImporterPlugin" }, //EditorPlugin { "AddStyleboxOverride", "AddThemeStyleboxOverride" }, // Control { "AddTorque", "AddConstantTorque" }, //RigidBody2D + { "AgentSetNeighborDist", "AgentSetNeighborDistance" }, // NavigationServer2D, NavigationServer3D { "BindChildNodeToBone", "SetBoneChildren" }, // Skeleton3D { "BumpmapToNormalmap", "BumpMapToNormalMap" }, // Image { "CanBeHidden", "_CanBeHidden" }, // EditorNode3DGizmoPlugin @@ -759,6 +765,7 @@ static const char *csharp_function_renames[][2] = { { "GetMetakey", "IsMetaPressed" }, // InputEventWithModifiers { "GetMidHeight", "GetHeight" }, // CapsuleMesh { "GetMotionRemainder", "GetRemainder" }, // PhysicsTestMotionResult2D + { "GetNeighborDist", "GetNeighborDistance" }, // NavigationAgent2D, NavigationAgent3D { "GetNetworkConnectedPeers", "GetPeers" }, // Multiplayer API { "GetNetworkMaster", "GetMultiplayerAuthority" }, // Node { "GetNetworkPeer", "GetMultiplayerPeer" }, // Multiplayer API @@ -929,6 +936,7 @@ static const char *csharp_function_renames[][2] = { { "SetMaxAtlasSize", "SetMaxTextureSize" }, // LightmapGI { "SetMetakey", "SetMetaPressed" }, // InputEventWithModifiers { "SetMidHeight", "SetHeight" }, // CapsuleMesh + { "SetNeighborDist", "SetNeighborDistance" }, // NavigationAgent2D, NavigationAgent3D { "SetNetworkMaster", "SetMultiplayerAuthority" }, // Node { "SetNetworkPeer", "SetMultiplayerPeer" }, // Multiplayer API { "SetOneshot", "SetOneShot" }, // AnimatedTexture @@ -1064,6 +1072,7 @@ static const char *gdscript_properties_renames[][2] = { { "focus_neighbour_left", "focus_neighbor_left" }, // Control { "focus_neighbour_right", "focus_neighbor_right" }, // Control { "focus_neighbour_top", "focus_neighbor_top" }, // Control + { "follow_viewport_enable", "follow_viewport_enabled" }, // CanvasItem { "file_icon_modulate", "file_icon_color" }, // Theme { "files_disabled", "file_disabled_color" }, // Theme { "folder_icon_modulate", "folder_icon_color" }, // Theme @@ -1079,6 +1088,7 @@ static const char *gdscript_properties_renames[][2] = { { "margin_right", "offset_right" }, // Control broke NinePatchRect, StyleBox { "margin_top", "offset_top" }, // Control broke NinePatchRect, StyleBox { "mid_height", "height" }, // CapsuleMesh + { "neighbor_dist", "neighbor_distance" }, // NavigationAgent2D, NavigationAgent3D { "offset_h", "drag_horizontal_offset" }, // Camera2D { "offset_v", "drag_vertical_offset" }, // Camera2D { "off", "unchecked" }, // Theme @@ -1167,6 +1177,7 @@ static const char *csharp_properties_renames[][2] = { { "FocusNeighbourLeft", "FocusNeighborLeft" }, // Control { "FocusNeighbourRight", "FocusNeighborRight" }, // Control { "FocusNeighbourTop", "FocusNeighborTop" }, // Control + { "FollowViewportEnable", "FollowViewportEnabled" }, // CanvasItem { "GlobalRateScale", "PlaybackSpeedScale" }, // AudioServer { "GravityDistanceScale", "GravityPointDistanceScale" }, // Area2D { "GravityVec", "GravityDirection" }, // Area2D @@ -1179,6 +1190,7 @@ static const char *csharp_properties_renames[][2] = { { "MarginRight", "OffsetRight" }, // Control broke NinePatchRect, StyleBox { "MarginTop", "OffsetTop" }, // Control broke NinePatchRect, StyleBox { "MidHeight", "Height" }, // CapsuleMesh + { "NeighborDist", "NeighborDistance" }, // NavigationAgent2D, NavigationAgent3D { "OffsetH", "DragHorizontalOffset" }, // Camera2D { "OffsetV", "DragVerticalOffset" }, // Camera2D { "Ofs", "Offset" }, // Theme @@ -2339,7 +2351,9 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) { 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("\tmove_and_slide( a, b, c, d, e, f ) # Roman", "\tset_velocity(a)\n\tset_up_direction(b)\n\tset_floor_stop_on_slope_enabled(c)\n\tset_max_slides(d)\n\tset_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tmove_and_slide() # 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("\tmove_and_slide_with_snap( a, g, b, c, d, e, f ) # Roman", "\tset_velocity(a)\n\t# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `g`\n\tset_up_direction(b)\n\tset_floor_stop_on_slope_enabled(c)\n\tset_max_slides(d)\n\tset_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tmove_and_slide() # 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); @@ -3143,8 +3157,13 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[5] + "`\n"; } - line_new += starting_space + base_obj + "move_and_slide()\n"; - line = line_new + line.substr(0, start) + "velocity" + line.substr(end + start); + line_new += starting_space + base_obj + "move_and_slide()"; + + if (!line.begins_with(starting_space + "move_and_slide")) { + line = line_new + "\n" + line.substr(0, start) + "velocity" + line.substr(end + start); + } else { + line = line_new + line.substr(end + start); + } } } } @@ -3194,8 +3213,13 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[6] + "`\n"; } - line_new += starting_space + base_obj + "move_and_slide()\n"; - line = line_new + line.substr(0, start) + "velocity" + line.substr(end + start); // move_and_slide used to return velocity + line_new += starting_space + base_obj + "move_and_slide()"; + + if (!line.begins_with(starting_space + "move_and_slide_with_snap")) { + line = line_new + "\n" + line.substr(0, start) + "velocity" + line.substr(end + start); + } else { + line = line_new + line.substr(end + start); + } } } } |