From 0958c5a2996ecd9781ecc900c814e6162d74524a Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 3 Nov 2021 15:39:32 +0100 Subject: [PATCH] Remove support for built-in scripts in the editor Built-in scripts have many limitations that users tend to discover late in their project. This causes a lot of pain as scripts must be replaced by their non-built-in variants one by one. Note that this only unexposes the ability to create and edit built-in scripts from the editor. It's still possible to save a scene that contains executable built-in scripts using PackedScene or external tools. This is a compatibility-breaking change, as built-in scripts need to be turned into non-built-in-scripts before upgrading a project to Godot 4.0. --- core/object/script_language.h | 1 - editor/editor_data.cpp | 4 - editor/editor_inspector.cpp | 2 +- editor/filesystem_dock.cpp | 2 +- editor/plugins/script_editor_plugin.cpp | 75 +------------ editor/plugins/script_editor_plugin.h | 2 - editor/script_create_dialog.cpp | 105 +++--------------- editor/script_create_dialog.h | 8 +- .../include/pluginscript/godot_pluginscript.h | 1 - .../gdnative/nativescript/nativescript.cpp | 4 - modules/gdnative/nativescript/nativescript.h | 1 - .../pluginscript/pluginscript_language.cpp | 4 - .../pluginscript/pluginscript_language.h | 1 - modules/gdscript/gdscript.cpp | 6 +- modules/mono/csharp_script.cpp | 4 - modules/mono/csharp_script.h | 3 - modules/visual_script/visual_script.cpp | 4 - modules/visual_script/visual_script.h | 1 - 18 files changed, 29 insertions(+), 199 deletions(-) diff --git a/core/object/script_language.h b/core/object/script_language.h index 8d76cbf47956..0b49a6f37b2b 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -286,7 +286,6 @@ class ScriptLanguage { virtual String validate_path(const String &p_path) const { return ""; } virtual Script *create_script() const = 0; virtual bool has_named_classes() const = 0; - virtual bool supports_builtin_mode() const = 0; virtual bool supports_documentation() const { return false; } virtual bool can_inherit_from_file() const { return false; } virtual int find_function(const String &p_function, const String &p_code) const = 0; diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index aee9c2100733..f0948e506dbf 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -566,10 +566,6 @@ void EditorData::remove_scene(int p_idx) { current_edited_scene--; } - if (edited_scene[p_idx].path != String()) { - ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(edited_scene[p_idx].path); - } - edited_scene.remove(p_idx); } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 9f049a0e5820..852439ad232b 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2506,7 +2506,7 @@ void EditorInspector::update_tree() { } } if (category->icon.is_null()) { - if (type != String()) { // Can happen for built-in scripts. + if (type != String()) { category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object"); } } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index f2a3aa3b4445..39d8d4c453c3 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1942,7 +1942,7 @@ void FileSystemDock::_file_option(int p_option, const Vector &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.plus_file("new_script.gd"), false); make_script_dialog->popup_centered(); } break; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 3f98560a2f0d..e984a92ef4cf 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -227,12 +227,6 @@ void ScriptEditorBase::_bind_methods() { ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text"))); } -static bool _is_built_in_script(Script *p_script) { - String path = p_script->get_path(); - - return path.find("::") != -1; -} - class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache { struct Cache { uint64_t time_loaded = 0; @@ -1159,7 +1153,7 @@ void ScriptEditor::_menu_option(int p_option) { ScriptEditorBase *current = _get_current_editor(); switch (p_option) { case FILE_NEW: { - script_create_dialog->config("Node", "new_script", false, false); + script_create_dialog->config("Node", "new_script", false); script_create_dialog->popup_centered(); } break; case FILE_NEW_TEXTFILE: { @@ -1205,23 +1199,8 @@ void ScriptEditor::_menu_option(int p_option) { List extensions; ResourceLoader::get_recognized_extensions_for_type("Script", &extensions); - bool built_in = !path.is_resource_file(); - - if (extensions.find(path.get_extension()) || built_in) { - if (built_in) { - String res_path = path.get_slice("::", 0); - if (ResourceLoader::get_resource_type(res_path) == "PackedScene") { - if (!EditorNode::get_singleton()->is_scene_open(res_path)) { - EditorNode::get_singleton()->load_scene(res_path); - script_editor->call_deferred(SNAME("_menu_option"), p_option); - previous_scripts.push_back(path); //repeat the operation - return; - } - } else { - EditorNode::get_singleton()->load_resource(res_path); - } - } + if (extensions.find(path.get_extension())) { Ref