Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert usages of EditorNode to EditorPlugin #58506

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions editor/editor_audio_buses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,9 +1367,6 @@ bool AudioBusesEditorPlugin::handles(Object *p_node) const {
return (Object::cast_to<AudioBusLayout>(p_node) != nullptr);
}

void AudioBusesEditorPlugin::make_visible(bool p_visible) {
}

AudioBusesEditorPlugin::AudioBusesEditorPlugin(EditorAudioBuses *p_node) {
audio_bus_editor = p_node;
}
Expand Down
3 changes: 2 additions & 1 deletion editor/editor_audio_buses.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include "scene/gui/texture_rect.h"
#include "scene/gui/tree.h"

class EditorFileDialog;

class EditorAudioBuses;

class EditorAudioBus : public PanelContainer {
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_feature_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#include "scene/gui/split_container.h"
#include "scene/gui/tree.h"

class EditorFileDialog;

class EditorFeatureProfile : public RefCounted {
GDCLASS(EditorFeatureProfile, RefCounted);

Expand Down
1 change: 1 addition & 0 deletions editor/editor_locale_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 13 additions & 6 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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()));

Expand All @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class EditorNode : public Node {
ProjectExportDialog *project_export = nullptr;
ProjectSettingsEditor *project_settings_editor = nullptr;

Node *editor_plugins_container = nullptr;
Vector<EditorPlugin *> editor_plugins;
bool _initializing_plugins = false;
Map<String, EditorPlugin *> addon_name_to_plugin;
Expand Down
10 changes: 9 additions & 1 deletion editor/editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<Script> &p_script, const Ref<Texture2D> &p_icon) {
EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
Expand Down Expand Up @@ -881,7 +889,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item"), &EditorPlugin::make_bottom_panel_item_visible);
ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);

ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::_get_undo_redo);
ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::get_undo_redo);
ClassDB::bind_method(D_METHOD("add_undo_redo_inspector_hook_callback", "callable"), &EditorPlugin::add_undo_redo_inspector_hook_callback);
ClassDB::bind_method(D_METHOD("remove_undo_redo_inspector_hook_callback", "callable"), &EditorPlugin::remove_undo_redo_inspector_hook_callback);
ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
Expand Down
29 changes: 16 additions & 13 deletions editor/editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@
#define EDITOR_PLUGIN_H

#include "core/io/config_file.h"
#include "core/object/undo_redo.h"
#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_inspector.h"
#include "editor/editor_translation_parser.h"
#include "editor/import/editor_import_plugin.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/script_create_dialog.h"
#include "scene/3d/camera_3d.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
#include "scene/gui/control.h"

class UndoRedo;
class Node3D;
class Camera3D;
class Button;
class PopupMenu;
class EditorImportPlugin;
class EditorInspectorPlugin;
class EditorInspector;
class EditorTranslationParserPlugin;
class EditorImportPlugin;
class EditorExportPlugin;
class EditorSceneFormatImporter;
class EditorScenePostImportPlugin;
class ScriptCreateDialog;
class EditorCommandPalette;
class EditorSelection;
class EditorExport;
Expand Down Expand Up @@ -124,15 +127,14 @@ class EditorInterface : public Node {
bool is_distraction_free_mode_enabled() const;

EditorInterface();
~EditorInterface();
};

class EditorPlugin : public Node {
GDCLASS(EditorPlugin, Node);
friend class EditorData;
UndoRedo *undo_redo = nullptr;

UndoRedo *_get_undo_redo() { return undo_redo; }

bool input_event_forwarding_always_enabled = false;
bool force_draw_over_forwarding_enabled = false;

Expand All @@ -144,7 +146,6 @@ class EditorPlugin : public Node {
void _notification(int p_what);

static void _bind_methods();
UndoRedo &get_undo_redo() { return *undo_redo; }

void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon);
void remove_custom_type(const String &p_type);
Expand Down Expand Up @@ -207,6 +208,8 @@ class EditorPlugin : public Node {
AFTER_GUI_INPUT_DESELECT
};

UndoRedo *get_undo_redo() { return undo_redo; }

//TODO: send a resource for editing to the editor node?

void add_control_to_container(CustomControlContainer p_location, Control *p_control);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "editor_run.h"

#include "core/config/project_settings.h"
#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "servers/display_server.h"
Expand Down
2 changes: 2 additions & 0 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/import/editor_import_plugin.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/import_dock.h"
#include "editor/scene_tree_dock.h"
#include "editor/shader_create_dialog.h"
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/abstract_polygon_2d_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "editor/editor_plugin.h"
#include "scene/2d/polygon_2d.h"
#include "scene/gui/box_container.h"
#include "scene/gui/dialogs.h"

class CanvasItemEditor;

Expand Down
1 change: 1 addition & 0 deletions editor/plugins/animation_blend_space_1d_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "scene/animation/animation_blend_space_1d.h"
#include "scene/gui/button.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/popup.h"
#include "scene/gui/tree.h"

Expand Down
1 change: 1 addition & 0 deletions editor/plugins/animation_blend_space_2d_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "scene/animation/animation_blend_space_2d.h"
#include "scene/gui/button.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/popup.h"
#include "scene/gui/tree.h"

Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/animation_blend_tree_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
#define ANIMATION_BLEND_TREE_EDITOR_PLUGIN_H

#include "editor/editor_plugin.h"
#include "editor/editor_properties.h"
#include "editor/plugins/animation_tree_editor_plugin.h"
#include "editor/property_editor.h"
#include "scene/animation/animation_blend_tree.h"
#include "scene/gui/button.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/popup.h"
#include "scene/gui/tree.h"

Expand Down
Loading