From 508aa89ab7075ee678a4e49bbdbf19d00777a5d4 Mon Sep 17 00:00:00 2001 From: trollodel <33117082+trollodel@users.noreply.github.com> Date: Sun, 20 Mar 2022 13:04:49 +0100 Subject: [PATCH] Convert usages of EditorNode to EditorPlugin --- editor/animation_track_editor.cpp | 1 + editor/editor_audio_buses.cpp | 3 - editor/editor_audio_buses.h | 3 +- editor/editor_feature_profile.h | 2 + editor/editor_locale_dialog.cpp | 1 + editor/editor_node.cpp | 19 +- editor/editor_node.h | 1 + editor/editor_plugin.cpp | 10 +- editor/editor_plugin.h | 29 +-- editor/editor_run.cpp | 1 + editor/filesystem_dock.cpp | 2 + editor/plugins/abstract_polygon_2d_editor.h | 1 + .../plugins/animation_blend_space_1d_editor.h | 1 + .../plugins/animation_blend_space_2d_editor.h | 1 + .../animation_blend_tree_editor_plugin.h | 2 + .../animation_player_editor_plugin.cpp | 33 +-- .../plugins/animation_player_editor_plugin.h | 3 +- .../plugins/animation_state_machine_editor.h | 1 + .../plugins/animation_tree_editor_plugin.cpp | 7 +- .../plugins/asset_library_editor_plugin.cpp | 3 +- editor/plugins/audio_stream_editor_plugin.cpp | 18 +- editor/plugins/audio_stream_editor_plugin.h | 2 +- editor/plugins/camera_3d_editor_plugin.cpp | 1 - editor/plugins/canvas_item_editor_plugin.cpp | 197 ++++++++++-------- editor/plugins/canvas_item_editor_plugin.h | 12 +- .../collision_shape_2d_editor_plugin.cpp | 29 ++- .../collision_shape_2d_editor_plugin.h | 5 +- editor/plugins/control_editor_plugin.cpp | 13 +- editor/plugins/control_editor_plugin.h | 7 +- .../cpu_particles_2d_editor_plugin.cpp | 2 - .../plugins/cpu_particles_2d_editor_plugin.h | 6 +- .../cpu_particles_3d_editor_plugin.cpp | 3 +- editor/plugins/curve_editor_plugin.cpp | 73 ++++--- editor/plugins/curve_editor_plugin.h | 9 +- editor/plugins/debugger_editor_plugin.cpp | 4 +- editor/plugins/font_editor_plugin.cpp | 2 +- editor/plugins/font_editor_plugin.h | 1 + .../gpu_particles_2d_editor_plugin.cpp | 9 +- .../plugins/gpu_particles_2d_editor_plugin.h | 5 +- .../gpu_particles_3d_editor_plugin.cpp | 11 +- .../plugins/gpu_particles_3d_editor_plugin.h | 7 +- ..._particles_collision_sdf_editor_plugin.cpp | 2 +- ...pu_particles_collision_sdf_editor_plugin.h | 1 + editor/plugins/gradient_editor_plugin.cpp | 21 +- editor/plugins/gradient_editor_plugin.h | 8 +- .../gradient_texture_2d_editor_plugin.h | 2 + .../light_occluder_2d_editor_plugin.cpp | 3 +- editor/plugins/lightmap_gi_editor_plugin.cpp | 2 +- editor/plugins/line_2d_editor_plugin.cpp | 3 + editor/plugins/material_editor_plugin.h | 1 + editor/plugins/mesh_editor_plugin.h | 3 + .../mesh_instance_3d_editor_plugin.cpp | 27 +-- .../plugins/mesh_instance_3d_editor_plugin.h | 6 +- editor/plugins/mesh_library_editor_plugin.cpp | 10 +- editor/plugins/mesh_library_editor_plugin.h | 2 +- editor/plugins/multimesh_editor_plugin.cpp | 11 +- editor/plugins/multimesh_editor_plugin.h | 5 +- .../navigation_polygon_editor_plugin.cpp | 2 + editor/plugins/node_3d_editor_plugin.cpp | 62 +++--- editor/plugins/node_3d_editor_plugin.h | 12 +- .../occluder_instance_3d_editor_plugin.cpp | 2 +- editor/plugins/path_2d_editor_plugin.cpp | 10 +- editor/plugins/path_2d_editor_plugin.h | 4 +- editor/plugins/path_3d_editor_plugin.cpp | 13 +- editor/plugins/path_3d_editor_plugin.h | 1 + editor/plugins/polygon_2d_editor_plugin.cpp | 1 + editor/plugins/polygon_2d_editor_plugin.h | 4 + editor/plugins/polygon_3d_editor_plugin.cpp | 10 +- editor/plugins/polygon_3d_editor_plugin.h | 4 +- editor/plugins/replication_editor_plugin.cpp | 21 +- editor/plugins/replication_editor_plugin.h | 7 +- .../resource_preloader_editor_plugin.cpp | 25 ++- .../resource_preloader_editor_plugin.h | 9 +- editor/plugins/script_editor_plugin.cpp | 29 +-- editor/plugins/script_editor_plugin.h | 5 +- editor/plugins/shader_editor_plugin.cpp | 25 ++- editor/plugins/shader_editor_plugin.h | 6 +- editor/plugins/shader_file_editor_plugin.cpp | 8 +- editor/plugins/skeleton_2d_editor_plugin.cpp | 17 +- editor/plugins/skeleton_2d_editor_plugin.h | 5 +- editor/plugins/skeleton_3d_editor_plugin.cpp | 41 ++-- editor/plugins/skeleton_3d_editor_plugin.h | 14 +- .../plugins/skeleton_ik_3d_editor_plugin.cpp | 4 +- editor/plugins/sprite_2d_editor_plugin.cpp | 16 +- editor/plugins/sprite_2d_editor_plugin.h | 6 +- .../plugins/sprite_frames_editor_plugin.cpp | 31 ++- editor/plugins/sprite_frames_editor_plugin.h | 8 +- .../sub_viewport_preview_editor_plugin.h | 1 + editor/plugins/text_control_editor_plugin.cpp | 20 +- editor/plugins/text_control_editor_plugin.h | 4 +- editor/plugins/texture_3d_editor_plugin.h | 1 + editor/plugins/texture_editor_plugin.h | 3 + .../plugins/texture_layered_editor_plugin.h | 1 + .../plugins/texture_region_editor_plugin.cpp | 36 ++-- editor/plugins/texture_region_editor_plugin.h | 12 +- editor/plugins/theme_editor_plugin.cpp | 85 ++++---- editor/plugins/theme_editor_plugin.h | 17 +- editor/plugins/theme_editor_preview.cpp | 5 + editor/plugins/tiles/tile_data_editors.cpp | 2 + editor/plugins/tiles/tiles_editor_plugin.cpp | 18 +- .../plugins/version_control_editor_plugin.cpp | 43 ++-- .../plugins/version_control_editor_plugin.h | 2 + .../plugins/visual_shader_editor_plugin.cpp | 123 ++++++----- editor/plugins/visual_shader_editor_plugin.h | 7 +- editor/plugins/voxel_gi_editor_plugin.cpp | 2 +- editor/plugins/voxel_gi_editor_plugin.h | 1 + editor/scene_tree_dock.h | 3 +- main/main.cpp | 1 + modules/csg/editor/csg_gizmos.cpp | 1 + .../editor_scene_exporter_gltf_plugin.cpp | 6 +- .../editor_scene_exporter_gltf_plugin.h | 1 + .../gridmap/editor/grid_map_editor_plugin.cpp | 6 +- .../gridmap/editor/grid_map_editor_plugin.h | 5 +- .../editor/navigation_mesh_editor_plugin.cpp | 3 +- .../editor/navigation_mesh_editor_plugin.h | 1 + 115 files changed, 865 insertions(+), 594 deletions(-) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 53631c1e3b4e..f90fdff48fba 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -37,6 +37,7 @@ #include "editor/editor_scale.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "scene/animation/animation_player.h" +#include "scene/gui/option_button.h" #include "scene/gui/view_panner.h" #include "scene/main/window.h" #include "scene/scene_string_names.h" diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 4474d6893ad3..ac77695790ea 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -1367,9 +1367,6 @@ bool AudioBusesEditorPlugin::handles(Object *p_node) const { return (Object::cast_to(p_node) != nullptr); } -void AudioBusesEditorPlugin::make_visible(bool p_visible) { -} - AudioBusesEditorPlugin::AudioBusesEditorPlugin(EditorAudioBuses *p_node) { audio_bus_editor = p_node; } diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index 81a6e5b86d02..586975650f9e 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -46,6 +46,8 @@ #include "scene/gui/texture_rect.h" #include "scene/gui/tree.h" +class EditorFileDialog; + class EditorAudioBuses; class EditorAudioBus : public PanelContainer { @@ -269,7 +271,6 @@ class AudioBusesEditorPlugin : public EditorPlugin { bool has_main_screen() const override { return false; } virtual void edit(Object *p_node) override; virtual bool handles(Object *p_node) const override; - virtual void make_visible(bool p_visible) override; AudioBusesEditorPlugin(EditorAudioBuses *p_node); ~AudioBusesEditorPlugin(); diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index 19df8a968677..5e8c8f17a4c2 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -40,6 +40,8 @@ #include "scene/gui/split_container.h" #include "scene/gui/tree.h" +class EditorFileDialog; + class EditorFeatureProfile : public RefCounted { GDCLASS(EditorFeatureProfile, RefCounted); diff --git a/editor/editor_locale_dialog.cpp b/editor/editor_locale_dialog.cpp index abef0dc35367..2d0263cb8395 100644 --- a/editor/editor_locale_dialog.cpp +++ b/editor/editor_locale_dialog.cpp @@ -33,6 +33,7 @@ #include "core/config/project_settings.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "scene/gui/box_container.h" #include "scene/gui/check_button.h" #include "scene/gui/line_edit.h" #include "scene/gui/option_button.h" diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 99e30593a99b..7fdfea2a9db0 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -107,6 +107,7 @@ #include "editor/filesystem_dock.h" #include "editor/import/dynamic_font_import_settings.h" #include "editor/import/editor_import_collada.h" +#include "editor/import/editor_import_plugin.h" #include "editor/import/resource_importer_bitmask.h" #include "editor/import/resource_importer_bmfont.h" #include "editor/import/resource_importer_csv_translation.h" @@ -3236,7 +3237,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed singleton->distraction_free->raise(); } singleton->editor_data.add_editor_plugin(p_editor); - singleton->add_child(p_editor); + singleton->editor_plugins_container->add_child(p_editor); if (p_config_changed) { p_editor->enable_plugin(); } @@ -6956,6 +6957,9 @@ EditorNode::EditorNode() { audio_preview_gen = memnew(AudioStreamPreviewGenerator); add_child(audio_preview_gen); + editor_plugins_container = memnew(Node); + add_child(editor_plugins_container); + add_editor_plugin(memnew(DebuggerEditorPlugin(debug_menu))); add_editor_plugin(memnew(DebugAdapterServer())); @@ -6982,6 +6986,10 @@ EditorNode::EditorNode() { gui_base->add_child(disk_changed); + // Add interface before adding plugins + editor_interface = memnew(EditorInterface); + add_child(editor_interface); + add_editor_plugin(memnew(AnimationPlayerEditorPlugin)); add_editor_plugin(memnew(CanvasItemEditorPlugin)); add_editor_plugin(memnew(Node3DEditorPlugin)); @@ -6998,11 +7006,6 @@ EditorNode::EditorNode() { WARN_PRINT("Asset Library not available, as it requires SSL to work."); } - // Add interface before adding plugins. - - editor_interface = memnew(EditorInterface); - add_child(editor_interface); - // More visually meaningful to have this later. raise_bottom_panel_item(AnimationPlayerEditor::get_singleton()); add_editor_plugin(memnew(ReplicationEditorPlugin)); @@ -7240,6 +7243,10 @@ EditorNode::EditorNode() { String exec = OS::get_singleton()->get_executable_path(); // Save editor executable path for third-party tools. EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "executable_path", exec); + + // Move EditorInterface and the EditorPlugin container to the top, so they are the last nodes to free. + editor_interface->raise(); + editor_plugins_container->raise(); } EditorNode::~EditorNode() { diff --git a/editor/editor_node.h b/editor/editor_node.h index c6c1f09938f4..40965da93eec 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -271,6 +271,7 @@ class EditorNode : public Node { ProjectExportDialog *project_export = nullptr; ProjectSettingsEditor *project_settings_editor = nullptr; + Node *editor_plugins_container = nullptr; Vector editor_plugins; bool _initializing_plugins = false; Map addon_name_to_plugin; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 5166200ee3ef..93ba095a6d4a 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -30,13 +30,17 @@ #include "editor_plugin.h" +#include "editor/debugger/editor_debugger_node.h" #include "editor/editor_command_palette.h" #include "editor/editor_export.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_resource_preview.h" #include "editor/editor_settings.h" +#include "editor/editor_translation_parser.h" #include "editor/filesystem_dock.h" +#include "editor/import/editor_import_plugin.h" +#include "editor/import/resource_importer_scene.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/node_3d_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" @@ -373,6 +377,10 @@ EditorInterface::EditorInterface() { singleton = this; } +EditorInterface::~EditorInterface() { + singleton = nullptr; +} + /////////////////////////////////////////// void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref