From 8d7090241a99739262c3cd5f002b714fa91f8a68 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 17 Feb 2023 23:20:10 +0100 Subject: [PATCH] Make sure that the editor can be built even when the new code_editor module is disabled. --- editor/connections_dialog.cpp | 14 +++--- editor/editor_data.cpp | 6 ++- editor/editor_export.cpp | 10 +++- editor/editor_help.cpp | 32 +++++++------ editor/editor_node.cpp | 31 ++++++++++-- editor/editor_node.h | 2 + editor/editor_plugin.cpp | 12 +++-- editor/editor_plugin.h | 4 ++ editor/editor_resource_picker.cpp | 48 ++++++++++--------- editor/editor_run.cpp | 2 + editor/plugins/canvas_item_editor_plugin.cpp | 8 ++++ editor/plugins/spatial_editor_plugin.cpp | 13 +++-- editor/scene_tree_dock.cpp | 16 ++++++- editor/scene_tree_editor.cpp | 16 ++++--- editor/settings_config_dialog.cpp | 36 +++++++------- editor_modules/text_editor/config.py | 1 + main/main.cpp | 4 ++ modules/code_editor/register_types.cpp | 1 + modules/cscript/register_types.cpp | 4 ++ modules/gdscript/register_types.cpp | 4 ++ modules/gridmap/grid_map_editor_plugin.h | 2 + .../navigation_mesh_editor_plugin.cpp | 2 + modules/terraman/world/terrain_world_editor.h | 2 + .../world/terrain_2d_world_editor.h | 2 + modules/voxelman/world/voxel_world_editor.h | 2 + 25 files changed, 192 insertions(+), 82 deletions(-) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index bd594cfc6..83824a8ea 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -30,25 +30,25 @@ #include "connections_dialog.h" -#include "core/object/class_db.h" -#include "core/math/color.h" -#include "core/variant/dictionary.h" -#include "core/error/error_macros.h" #include "core/containers/list.h" +#include "core/error/error_macros.h" #include "core/math/aabb.h" #include "core/math/basis.h" +#include "core/math/color.h" #include "core/math/plane.h" #include "core/math/quaternion.h" #include "core/math/rect2.h" #include "core/math/transform.h" #include "core/math/vector2.h" #include "core/math/vector3.h" -#include "core/os/memory.h" +#include "core/object/class_db.h" #include "core/object/ref_ptr.h" #include "core/object/reference.h" #include "core/object/script_language.h" -#include "core/typedefs.h" #include "core/object/undo_redo.h" +#include "core/os/memory.h" +#include "core/typedefs.h" +#include "core/variant/dictionary.h" #include "core/variant/variant.h" #include "editor/doc/doc_data.h" #include "editor/editor_help.h" @@ -816,9 +816,11 @@ void ConnectionsDock::_go_to_script(TreeItem &item) { return; } +#ifdef MODULE_CODE_EDITOR_ENABLED if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, c.method)) { editor->call("_editor_select", EditorNode::EDITOR_SCRIPT); } +#endif } void ConnectionsDock::_handle_signal_menu_option(int option) { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index b0cbed1e7..67a0218b8 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -30,14 +30,14 @@ #include "editor_data.h" -#include "core/object/class_db.h" +#include "core/config/project_settings.h" #include "core/error/error_list.h" #include "core/error/error_macros.h" #include "core/io/config_file.h" #include "core/io/resource_loader.h" +#include "core/object/class_db.h" #include "core/os/file_access.h" #include "core/os/memory.h" -#include "core/config/project_settings.h" #include "editor/editor_plugin.h" #include "editor_node.h" #include "scene/main/node.h" @@ -557,9 +557,11 @@ void EditorData::remove_scene(int p_idx) { current_edited_scene--; } +#ifdef MODULE_CODE_EDITOR_ENABLED if (edited_scene[p_idx].path != String()) { ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(edited_scene[p_idx].path); } +#endif edited_scene.remove(p_idx); } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 6b9fd3258..45c533062 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -317,7 +317,6 @@ bool EditorExportPlatform::fill_log_messages(RichTextLabel *p_log, Error p_err) void EditorExportPlatform::gen_debug_flags(Vector &r_flags, int p_flags) { String host = EditorSettings::get_singleton()->get("network/debug/remote_host"); - int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) { host = "localhost"; @@ -334,6 +333,9 @@ void EditorExportPlatform::gen_debug_flags(Vector &r_flags, int p_flags) } } +#ifdef MODULE_CODE_EDITOR_ENABLED + int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); + if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) { r_flags.push_back("--remote-debug"); @@ -355,6 +357,7 @@ void EditorExportPlatform::gen_debug_flags(Vector &r_flags, int p_flags) r_flags.push_back(bpoints); } } +#endif if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) { r_flags.push_back("--debug-collisions"); @@ -1241,7 +1244,6 @@ Error EditorExportPlatform::export_zip(const Ref &p_preset, void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags) { String host = EditorSettings::get_singleton()->get("network/debug/remote_host"); - int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) { host = "localhost"; @@ -1258,6 +1260,9 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags } } +#ifdef MODULE_CODE_EDITOR_ENABLED + int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); + if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) { r_flags.push_back("--remote-debug"); @@ -1279,6 +1284,7 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags r_flags.push_back(bpoints); } } +#endif if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) { r_flags.push_back("--debug-collisions"); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 4a7805da4..4c4b65a6d 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -30,33 +30,33 @@ #include "editor_help.h" +#include "core/containers/list.h" +#include "core/containers/pair.h" +#include "core/containers/rb_set.h" #include "core/input/input.h" +#include "core/input/input_event.h" +#include "core/io/resource_loader.h" +#include "core/math/math_defs.h" +#include "core/math/math_funcs.h" +#include "core/math/rect2.h" +#include "core/math/vector2.h" +#include "core/object/class_db.h" #include "core/os/keyboard.h" +#include "core/os/memory.h" +#include "core/os/os.h" +#include "core/typedefs.h" +#include "core/variant/variant.h" #include "core/version_generated.gen.h" #include "doc_data_compressed.gen.h" #include "editor_node.h" #include "editor_scale.h" #include "editor_settings.h" -#include "scene/gui/texture_button.h" -#include "core/object/class_db.h" -#include "core/io/resource_loader.h" -#include "core/containers/list.h" -#include "core/math/math_defs.h" -#include "core/math/math_funcs.h" -#include "core/math/rect2.h" -#include "core/math/vector2.h" -#include "core/input/input_event.h" -#include "core/os/memory.h" -#include "core/os/os.h" -#include "core/containers/pair.h" -#include "core/containers/rb_set.h" -#include "core/typedefs.h" -#include "core/variant/variant.h" #include "scene/2d/canvas_item.h" #include "scene/gui/control.h" #include "scene/gui/label.h" #include "scene/gui/line_edit.h" #include "scene/gui/scroll_bar.h" +#include "scene/gui/texture_button.h" #include "scene/gui/tool_button.h" #include "scene/main/node.h" #include "scene/resources/font.h" @@ -1703,7 +1703,9 @@ EditorHelp::~EditorHelp() { void EditorHelpBit::_go_to_help(String p_what) { EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); +#ifdef MODULE_CODE_EDITOR_ENABLED ScriptEditor::get_singleton()->goto_help(p_what); +#endif emit_signal("request_hide"); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ae053a552..3b03a5e8c 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -100,6 +100,7 @@ #include "editor/import/resource_importer_texture_atlas.h" #include "editor/import/resource_importer_wav.h" #include "editor/import_dock.h" +#include "editor/inspector_dock.h" #include "editor/multi_node_edit.h" #include "editor/node_dock.h" #include "editor/plugin_config_dialog.h" @@ -588,10 +589,12 @@ void EditorNode::_notification(int p_what) { recent_scenes->set_as_minsize(); +#ifdef MODULE_CODE_EDITOR_ENABLED // debugger area if (ScriptEditor::get_singleton()->get_debugger()->is_visible()) { bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); } +#endif // update_icons for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { @@ -2009,7 +2012,9 @@ void EditorNode::_edit_current(bool p_skip_foreign) { Object *prev_inspected_object = get_inspector()->get_edited_object(); bool disable_folding = bool(EDITOR_GET("interface/inspector/disable_folding")); +#ifdef MODULE_CODE_EDITOR_ENABLED bool stay_in_script_editor_on_node_selected = bool(EDITOR_GET("text_editor/navigation/stay_in_script_editor_on_node_selected")); +#endif bool is_resource = current_obj->is_class("Resource"); bool is_node = current_obj->is_class("Node"); @@ -2048,9 +2053,11 @@ void EditorNode::_edit_current(bool p_skip_foreign) { node_dock->set_node(current_node); scene_tree_dock->set_selected(current_node); inspector_dock->update(current_node); +#ifdef MODULE_CODE_EDITOR_ENABLED if (!inspector_only) { inspector_only = stay_in_script_editor_on_node_selected && ScriptEditor::get_singleton()->is_visible_in_tree(); } +#endif } else { node_dock->set_node(nullptr); scene_tree_dock->set_selected(nullptr); @@ -2128,12 +2135,12 @@ void EditorNode::_edit_current(bool p_skip_foreign) { if (!changing_scene) { main_plugin->edit(current_obj); } - } - - else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) { +#ifdef MODULE_CODE_EDITOR_ENABLED + } else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) { // update screen main_plugin _editor_select(plugin_index); main_plugin->edit(current_obj); +#endif } else { editor_plugin_screen->edit(current_obj); } @@ -2233,7 +2240,10 @@ void EditorNode::_run(bool p_current, const String &p_custom) { editor_data.get_editor_breakpoints(&breakpoints); args = ProjectSettings::get_singleton()->get("editor/main_run_args"); + +#ifdef MODULE_CODE_EDITOR_ENABLED skip_breakpoints = ScriptEditor::get_singleton()->get_debugger()->is_skip_breakpoints(); +#endif emit_signal("play_pressed"); Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints); @@ -2400,9 +2410,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (!scene) { if (p_option == FILE_SAVE_SCENE) { +#ifdef MODULE_CODE_EDITOR_ENABLED // Pressing Ctrl + S saves the current script if a scene is currently open, but it won't if the scene has no root node. // Work around this by explicitly saving the script in this case (similar to pressing Ctrl + Alt + S). ScriptEditor::get_singleton()->save_current_script(); +#endif } const int saved = _save_external_resources(); @@ -2719,7 +2731,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_LIVE_DEBUG)); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_LIVE_DEBUG), !ischecked); +#ifdef MODULE_CODE_EDITOR_ENABLED ScriptEditor::get_singleton()->get_debugger()->set_live_debugging(!ischecked); +#endif EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked); } break; @@ -2757,7 +2771,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS)); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS), !ischecked); +#ifdef MODULE_CODE_EDITOR_ENABLED ScriptEditor::get_singleton()->set_live_auto_reload_running_scripts(!ischecked); +#endif EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_reload_scripts", !ischecked); } break; @@ -3449,8 +3465,10 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { //this should only happen at the very end +#ifdef MODULE_CODE_EDITOR_ENABLED ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root(); ScriptEditor::get_singleton()->set_scene_root_script(editor_data.get_scene_root_script(editor_data.get_edited_scene())); +#endif editor_data.notify_edited_scene_changed(); } @@ -3681,7 +3699,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b opening_prev = false; scene_tree_dock->set_selected(new_scene); +#ifdef MODULE_CODE_EDITOR_ENABLED ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root(); +#endif push_item(new_scene); @@ -3865,7 +3885,6 @@ void EditorNode::register_editor_types() { ClassDB::register_class(); ClassDB::register_virtual_class(); ClassDB::register_class(); - ClassDB::register_virtual_class(); ClassDB::register_virtual_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -5110,11 +5129,15 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_items[i].button->set_pressed(i == p_idx); bottom_panel_items[i].control->set_visible(i == p_idx); } + +#ifdef MODULE_CODE_EDITOR_ENABLED if (ScriptEditor::get_singleton()->get_debugger() == bottom_panel_items[p_idx].control) { // this is the debug panel which uses tabs, so the top section should be smaller bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); } else { bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); } +#endif + center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); if (bottom_panel_raise->is_pressed()) { diff --git a/editor/editor_node.h b/editor/editor_node.h index 1e38e4bd1..1d64acf01 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -38,6 +38,8 @@ #include "editor/inspector_dock.h" #include "editor/scene_tree_dock.h" +#include "editor_plugin.h" + #include "scene/gui/menu_button.h" #include "scene/gui/split_container.h" diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index e264593e8..ae9a0a609 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -211,7 +211,9 @@ void EditorInterface::edit_node(Node *p_node) { } void EditorInterface::edit_script(const Ref