From 9cd2927fcce5c6b2063f5f3c94f5e9ffdc312246 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 17 Feb 2023 20:57:16 +0100 Subject: [PATCH] Move the editor's script text editor into the new code_editor module. --- editor/connections_dialog.cpp | 7 ++++++- editor/editor_data.cpp | 7 ++++++- editor/editor_data.h | 7 ++++++- editor/editor_export.cpp | 7 ++++++- editor/editor_help.cpp | 7 ++++++- editor/editor_node.cpp | 13 +++++++++---- editor/editor_plugin.cpp | 7 ++++++- editor/editor_resource_picker.cpp | 7 ++++++- editor/editor_run.cpp | 7 ++++++- editor/plugins/canvas_item_editor_plugin.cpp | 7 ++++++- editor/plugins/spatial_editor_plugin.cpp | 7 ++++++- editor/scene_tree_dock.cpp | 7 ++++++- editor/scene_tree_editor.cpp | 7 ++++++- editor/settings_config_dialog.cpp | 7 ++++++- .../text_editor/text_editor_vanilla_editor.cpp | 2 +- modules/code_editor/SCsub | 16 ++++++++++++++++ {editor => modules/code_editor}/code_editor.cpp | 6 +++--- {editor => modules/code_editor}/code_editor.h | 0 modules/code_editor/config.py | 15 +++++++++++++++ modules/code_editor/register_types.cpp | 11 +++++++++++ modules/code_editor/register_types.h | 9 +++++++++ .../code_editor}/script_editor_plugin.cpp | 2 +- .../code_editor}/script_editor_plugin.h | 0 .../code_editor}/script_text_editor.cpp | 2 +- .../code_editor}/script_text_editor.h | 2 +- .../code_editor}/shader_editor_plugin.cpp | 0 .../code_editor}/shader_editor_plugin.h | 2 +- .../code_editor}/text_editor.cpp | 1 - .../code_editor}/text_editor.h | 2 +- 29 files changed, 147 insertions(+), 27 deletions(-) create mode 100644 modules/code_editor/SCsub rename {editor => modules/code_editor}/code_editor.cpp (99%) rename {editor => modules/code_editor}/code_editor.h (100%) create mode 100644 modules/code_editor/config.py create mode 100644 modules/code_editor/register_types.cpp create mode 100644 modules/code_editor/register_types.h rename {editor/plugins => modules/code_editor}/script_editor_plugin.cpp (99%) rename {editor/plugins => modules/code_editor}/script_editor_plugin.h (100%) rename {editor/plugins => modules/code_editor}/script_text_editor.cpp (99%) rename {editor/plugins => modules/code_editor}/script_text_editor.h (99%) rename {editor/plugins => modules/code_editor}/shader_editor_plugin.cpp (100%) rename {editor/plugins => modules/code_editor}/shader_editor_plugin.h (99%) rename {editor/plugins => modules/code_editor}/text_editor.cpp (99%) rename {editor/plugins => modules/code_editor}/text_editor.h (99%) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index bec64a461..bd594cfc6 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -58,7 +58,6 @@ #include "editor_node.h" #include "editor_scale.h" #include "editor_settings.h" -#include "plugins/script_editor_plugin.h" #include "scene/gui/button.h" #include "scene/gui/check_box.h" #include "scene/gui/check_button.h" @@ -73,6 +72,12 @@ #include "scene/main/scene_tree.h" #include "scene/resources/texture.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + static Node *_find_first_script(Node *p_root, Node *p_node) { if (p_node != p_root && p_node->get_owner() != p_root) { return nullptr; diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 33a253947..b0cbed1e7 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -39,11 +39,16 @@ #include "core/os/memory.h" #include "core/config/project_settings.h" #include "editor/editor_plugin.h" -#include "editor/plugins/script_editor_plugin.h" #include "editor_node.h" #include "scene/main/node.h" #include "scene/resources/packed_scene.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + class Resource; void EditorHistory::cleanup_history() { diff --git a/editor/editor_data.h b/editor/editor_data.h index 495d4a12c..876b1f0db 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -32,7 +32,6 @@ #include "core/object/object.h" -#include "editor/plugins/script_editor_plugin.h" #include "scene/resources/texture.h" #include "core/containers/list.h" @@ -53,6 +52,12 @@ #include "core/variant/variant.h" #include "core/containers/vector.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + class ConfigFile; class EditorPlugin; class Node; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 71f841385..6b9fd3258 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -46,7 +46,6 @@ #include "core/version.h" #include "core/version_generated.gen.h" #include "editor/editor_file_system.h" -#include "editor/plugins/script_editor_plugin.h" #include "editor_node.h" #include "editor_scale.h" #include "editor_settings.h" @@ -58,6 +57,12 @@ #include "thirdparty/minizip/zip.h" #include "zlib.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + static int _get_pad(int p_alignment, int p_n) { int rest = p_n % p_alignment; int pad = 0; diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 38af285e9..4a7805da4 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -34,7 +34,6 @@ #include "core/os/keyboard.h" #include "core/version_generated.gen.h" #include "doc_data_compressed.gen.h" -#include "editor/plugins/script_editor_plugin.h" #include "editor_node.h" #include "editor_scale.h" #include "editor_settings.h" @@ -64,6 +63,12 @@ #include "scene/resources/style_box.h" #include "scene/resources/texture.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + #define CONTRIBUTE_URL vformat("%s/community/contributing/updating_the_class_reference.html", VERSION_DOCS_URL) DocData *EditorHelp::doc = nullptr; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 26fb383e2..b686de716 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -134,14 +134,10 @@ #include "editor/plugins/resource_preloader_editor_plugin.h" #include "editor/plugins/room_manager_editor_plugin.h" #include "editor/plugins/root_motion_editor_plugin.h" -#include "editor/plugins/script_editor_plugin.h" -#include "editor/plugins/script_text_editor.h" -#include "editor/plugins/shader_editor_plugin.h" #include "editor/plugins/spatial_editor_plugin.h" #include "editor/plugins/sprite_editor_plugin.h" #include "editor/plugins/sprite_frames_editor_plugin.h" #include "editor/plugins/style_box_editor_plugin.h" -#include "editor/plugins/text_editor.h" #include "editor/plugins/texture_editor_plugin.h" #include "editor/plugins/texture_region_editor_plugin.h" #include "editor/plugins/theme_editor_plugin.h" @@ -193,6 +189,15 @@ #include "servers/physics_server.h" #include "servers/rendering_server.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_text_editor.h" +#include "modules/code_editor/shader_editor_plugin.h" +#include "modules/code_editor/text_editor.h" +#include "modules/code_editor/script_editor_plugin.h" +#endif + class Camera; EditorNode *EditorNode::singleton = nullptr; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 40fa72184..e264593e8 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -57,7 +57,6 @@ #include "editor/filesystem_dock.h" #include "editor/import/editor_import_plugin.h" #include "editor/import/resource_importer_scene.h" -#include "editor/plugins/script_editor_plugin.h" #include "editor/project_settings_editor.h" #include "editor/script_create_dialog.h" #include "editor_resource_preview.h" @@ -75,6 +74,12 @@ #include "scene/resources/texture.h" #include "servers/rendering_server.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + class ConfigFile; class ScriptCreateDialog; class ToolButton; diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 9c9edce53..44cf83ee8 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -54,7 +54,6 @@ #include "editor/editor_data.h" #include "editor/editor_file_dialog.h" #include "editor/editor_file_system.h" -#include "editor/plugins/script_editor_plugin.h" #include "editor/property_editor.h" #include "editor/quick_open.h" #include "editor/scene_tree_dock.h" @@ -70,6 +69,12 @@ #include "scene/resources/style_box.h" #include "scene/resources/texture.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + HashMap> EditorResourcePicker::allowed_types_cache; void EditorResourcePicker::clear_caches() { diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index d1d0c09d4..dca840933 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -40,9 +40,14 @@ #include "core/math/vector2.h" #include "core/variant/variant.h" #include "editor_settings.h" -#include "plugins/script_editor_plugin.h" #include "script_editor_debugger.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + EditorRun::Status EditorRun::get_status() const { return status; } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 8a79cdf4d..b8aff0f89 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -62,7 +62,6 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/plugins/animation_player_editor_plugin.h" -#include "editor/plugins/script_editor_plugin.h" #include "editor/scene_tree_dock.h" #include "editor/script_editor_debugger.h" #include "scene/2d/light_2d.h" @@ -101,6 +100,12 @@ #include "scene/resources/theme.h" #include "servers/rendering_server.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + // Min and Max are power of two in order to play nicely with successive increment. // That way, we can naturally reach a 100% zoom from boundaries. #define MIN_ZOOM 1. / 128 diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 60001c298..6cc14dbc8 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -62,7 +62,6 @@ #include "editor/editor_settings.h" #include "editor/inspector_dock.h" #include "editor/plugins/animation_player_editor_plugin.h" -#include "editor/plugins/script_editor_plugin.h" #include "editor/scene_tree_dock.h" #include "editor/scene_tree_editor.h" #include "editor/script_editor_debugger.h" @@ -100,6 +99,12 @@ #include "scene/resources/world_3d.h" #include "servers/physics_server.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + #define DISTANCE_DEFAULT 4 #define GIZMO_ARROW_SIZE 0.35 diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index e20266f02..75d4abb0f 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -66,7 +66,6 @@ #include "editor/multi_node_edit.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" -#include "editor/plugins/script_editor_plugin.h" #include "editor/plugins/spatial_editor_plugin.h" #include "editor/quick_open.h" #include "editor/rename_dialog.h" @@ -97,6 +96,12 @@ #include "scene/resources/packed_scene.h" #include "scene/resources/texture.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + void SceneTreeDock::_nodes_drag_begin() { pending_click_select = nullptr; } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 45f813550..a8e7faec2 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -51,7 +51,6 @@ #include "editor/node_dock.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" -#include "editor/plugins/script_editor_plugin.h" #include "scene/2d/canvas_item.h" #include "scene/animation/animation_player.h" #include "scene/gui/box_container.h" @@ -65,6 +64,12 @@ #include "scene/resources/packed_scene.h" #include "scene/resources/texture.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + Node *SceneTreeEditor::get_scene_node() { ERR_FAIL_COND_V(!is_inside_tree(), nullptr); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 8a97bb959..1df218f65 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -52,7 +52,6 @@ #include "core/variant/variant.h" #include "editor/editor_inspector.h" #include "editor/editor_sectioned_inspector.h" -#include "editor/plugins/script_editor_plugin.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/control.h" @@ -68,6 +67,12 @@ #include "scene/main/node.h" #include "scene/main/timer.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_CODE_EDITOR_ENABLED +#include "modules/code_editor/script_editor_plugin.h" +#endif + void EditorSettingsDialog::ok_pressed() { if (!EditorSettings::get_singleton()) { return; diff --git a/editor_modules/text_editor/text_editor_vanilla_editor.cpp b/editor_modules/text_editor/text_editor_vanilla_editor.cpp index 5b7d56570..e524e733f 100644 --- a/editor_modules/text_editor/text_editor_vanilla_editor.cpp +++ b/editor_modules/text_editor/text_editor_vanilla_editor.cpp @@ -14,7 +14,7 @@ #include "scene/gui/text_edit.h" #include "scene/gui/texture_rect.h" -#include "editor/code_editor.h" +#include "modules/code_editor/code_editor.h" #include "scene/resources/dynamic_font.h" diff --git a/modules/code_editor/SCsub b/modules/code_editor/SCsub new file mode 100644 index 000000000..f1a6f19a0 --- /dev/null +++ b/modules/code_editor/SCsub @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +Import("env") + +env_mlp = env.Clone() + +sources = [ + "register_types.cpp", + "code_editor.cpp", + "script_editor_plugin.cpp", + "script_text_editor.cpp", + "shader_editor_plugin.cpp", + "text_editor.cpp", +] + +env_mlp.add_source_files(env.modules_sources, sources) diff --git a/editor/code_editor.cpp b/modules/code_editor/code_editor.cpp similarity index 99% rename from editor/code_editor.cpp rename to modules/code_editor/code_editor.cpp index 2b1551d11..a3c1d18c5 100644 --- a/editor/code_editor.cpp +++ b/modules/code_editor/code_editor.cpp @@ -45,9 +45,9 @@ #include "core/typedefs.h" #include "core/containers/vector.h" #include "editor/editor_scale.h" -#include "editor/plugins/script_editor_plugin.h" -#include "editor_node.h" -#include "editor_settings.h" +#include "script_editor_plugin.h" +#include "editor/editor_node.h" +#include "editor/editor_settings.h" #include "scene/2d/canvas_item.h" #include "scene/gui/button.h" #include "scene/gui/check_box.h" diff --git a/editor/code_editor.h b/modules/code_editor/code_editor.h similarity index 100% rename from editor/code_editor.h rename to modules/code_editor/code_editor.h diff --git a/modules/code_editor/config.py b/modules/code_editor/config.py new file mode 100644 index 000000000..c5fdf5b8e --- /dev/null +++ b/modules/code_editor/config.py @@ -0,0 +1,15 @@ + + +def can_build(env, platform): + return True + +def configure(env): + pass + + +def get_doc_classes(): + return [ + ] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/code_editor/register_types.cpp b/modules/code_editor/register_types.cpp new file mode 100644 index 000000000..04f473668 --- /dev/null +++ b/modules/code_editor/register_types.cpp @@ -0,0 +1,11 @@ + +#include "register_types.h" + +void register_code_editor_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) { + //ClassDB::register_class<>(); + } +} + +void unregister_code_editor_types(ModuleRegistrationLevel p_level) { +} diff --git a/modules/code_editor/register_types.h b/modules/code_editor/register_types.h new file mode 100644 index 000000000..69abe4bdc --- /dev/null +++ b/modules/code_editor/register_types.h @@ -0,0 +1,9 @@ +#ifndef CODE_EDITOR_REGISTER_TYPES_H +#define CODE_EDITOR_REGISTER_TYPES_H + +#include "modules/register_module_types.h" + +void register_code_editor_types(ModuleRegistrationLevel p_level); +void unregister_code_editor_types(ModuleRegistrationLevel p_level); + +#endif diff --git a/editor/plugins/script_editor_plugin.cpp b/modules/code_editor/script_editor_plugin.cpp similarity index 99% rename from editor/plugins/script_editor_plugin.cpp rename to modules/code_editor/script_editor_plugin.cpp index 4bad098cb..937b3e5d0 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/modules/code_editor/script_editor_plugin.cpp @@ -43,7 +43,7 @@ #include "editor/filesystem_dock.h" #include "editor/find_in_files.h" #include "editor/node_dock.h" -#include "editor/plugins/shader_editor_plugin.h" +#include "shader_editor_plugin.h" #include "editor/script_editor_debugger.h" #include "scene/main/viewport.h" #include "scene/scene_string_names.h" diff --git a/editor/plugins/script_editor_plugin.h b/modules/code_editor/script_editor_plugin.h similarity index 100% rename from editor/plugins/script_editor_plugin.h rename to modules/code_editor/script_editor_plugin.h diff --git a/editor/plugins/script_text_editor.cpp b/modules/code_editor/script_text_editor.cpp similarity index 99% rename from editor/plugins/script_text_editor.cpp rename to modules/code_editor/script_text_editor.cpp index 559f910ea..d604341d0 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/modules/code_editor/script_text_editor.cpp @@ -53,7 +53,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" -#include "editor/plugins/script_editor_plugin.h" +#include "script_editor_plugin.h" #include "editor/script_editor_debugger.h" #include "scene/gui/box_container.h" #include "scene/gui/color_picker.h" diff --git a/editor/plugins/script_text_editor.h b/modules/code_editor/script_text_editor.h similarity index 99% rename from editor/plugins/script_text_editor.h rename to modules/code_editor/script_text_editor.h index e2f6a2c66..ff27a7411 100644 --- a/editor/plugins/script_text_editor.h +++ b/modules/code_editor/script_text_editor.h @@ -44,7 +44,7 @@ #include "core/object/resource.h" #include "core/string/ustring.h" #include "core/variant/variant.h" -#include "editor/code_editor.h" +#include "code_editor.h" class ColorPicker; class Control; diff --git a/editor/plugins/shader_editor_plugin.cpp b/modules/code_editor/shader_editor_plugin.cpp similarity index 100% rename from editor/plugins/shader_editor_plugin.cpp rename to modules/code_editor/shader_editor_plugin.cpp diff --git a/editor/plugins/shader_editor_plugin.h b/modules/code_editor/shader_editor_plugin.h similarity index 99% rename from editor/plugins/shader_editor_plugin.h rename to modules/code_editor/shader_editor_plugin.h index ee4efd6c6..0b3ef24a9 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/modules/code_editor/shader_editor_plugin.h @@ -30,7 +30,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "editor/code_editor.h" +#include "code_editor.h" #include "editor/editor_plugin.h" #include "scene/gui/margin_container.h" diff --git a/editor/plugins/text_editor.cpp b/modules/code_editor/text_editor.cpp similarity index 99% rename from editor/plugins/text_editor.cpp rename to modules/code_editor/text_editor.cpp index cb3b3e697..80e98f5d7 100644 --- a/editor/plugins/text_editor.cpp +++ b/modules/code_editor/text_editor.cpp @@ -42,7 +42,6 @@ #include "core/os/memory.h" #include "core/typedefs.h" #include "editor/editor_settings.h" -#include "editor/plugins/script_editor_plugin.h" #include "scene/gui/box_container.h" #include "scene/gui/control.h" #include "scene/gui/menu_button.h" diff --git a/editor/plugins/text_editor.h b/modules/code_editor/text_editor.h similarity index 99% rename from editor/plugins/text_editor.h rename to modules/code_editor/text_editor.h index cef051f2a..218c404c9 100644 --- a/editor/plugins/text_editor.h +++ b/modules/code_editor/text_editor.h @@ -41,7 +41,7 @@ #include "core/string/ustring.h" #include "core/variant/variant.h" #include "core/containers/vector.h" -#include "editor/code_editor.h" +#include "code_editor.h" class Control; class HBoxContainer;