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

Remove most EditorNode constructor parameters and fields #57306

Merged
merged 1 commit into from
Feb 14, 2022
Merged
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
7 changes: 3 additions & 4 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ void ConnectionsDock::_make_or_edit_connection() {
it = nullptr;

if (add_script_function) {
editor->emit_signal(SNAME("script_add_function_request"), target, cd.method, script_function_args);
EditorNode::get_singleton()->emit_signal(SNAME("script_add_function_request"), target, cd.method, script_function_args);
hide();
}

Expand Down Expand Up @@ -852,7 +852,7 @@ void ConnectionsDock::_go_to_script(TreeItem &p_item) {
}

if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, cd.method)) {
editor->call("_editor_select", EditorNode::EDITOR_SCRIPT);
EditorNode::get_singleton()->call("_editor_select", EditorNode::EDITOR_SCRIPT);
}
}

Expand Down Expand Up @@ -1147,8 +1147,7 @@ void ConnectionsDock::update_tree() {
connect_button->set_disabled(true);
}

ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
editor = p_editor;
ConnectionsDock::ConnectionsDock() {
set_name(TTR("Signals"));

VBoxContainer *vbc = this;
Expand Down
3 changes: 1 addition & 2 deletions editor/connections_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class ConnectionsDock : public VBoxContainer {

Node *selected_node;
ConnectionsDockTree *tree;
EditorNode *editor;

ConfirmationDialog *disconnect_all_dialog;
ConnectDialog *connect_dialog;
Expand Down Expand Up @@ -224,7 +223,7 @@ class ConnectionsDock : public VBoxContainer {
void set_node(Node *p_node);
void update_tree();

ConnectionsDock(EditorNode *p_editor = nullptr);
ConnectionsDock();
~ConnectionsDock();
};

Expand Down
2 changes: 1 addition & 1 deletion editor/debugger/editor_debugger_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ EditorDebuggerNode::EditorDebuggerNode() {
}

ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
ScriptEditorDebugger *node = memnew(ScriptEditorDebugger(EditorNode::get_singleton()));
ScriptEditorDebugger *node = memnew(ScriptEditorDebugger);

int id = tabs->get_tab_count();
node->connect("stop_requested", callable_mp(this, &EditorDebuggerNode::_debugger_wants_stop), varray(id));
Expand Down
30 changes: 13 additions & 17 deletions editor/debugger/script_editor_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
peer->poll();

if (camera_override == CameraOverride::OVERRIDE_2D) {
CanvasItemEditor *editor = CanvasItemEditor::get_singleton();

Dictionary state = editor->get_state();
Dictionary state = CanvasItemEditor::get_singleton()->get_state();
float zoom = state["zoom"];
Point2 offset = state["ofs"];
Transform2D transform;
Expand Down Expand Up @@ -861,7 +859,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (tabs->has_theme_stylebox_override("panel")) {
tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
}

copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")));
Expand Down Expand Up @@ -1066,7 +1064,7 @@ int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) {
}

void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
if (!p_base || !live_debug || !is_session_active() || !editor->get_edited_scene()) {
if (!p_base || !live_debug || !is_session_active() || !EditorNode::get_singleton()->get_edited_scene()) {
return;
}

Expand All @@ -1082,7 +1080,7 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
}

if (node) {
NodePath path = editor->get_edited_scene()->get_path_to(node);
NodePath path = EditorNode::get_singleton()->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);

Array msg;
Expand Down Expand Up @@ -1117,14 +1115,14 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
}

void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p_property, const Variant &p_value) {
if (!p_base || !live_debug || !editor->get_edited_scene()) {
if (!p_base || !live_debug || !EditorNode::get_singleton()->get_edited_scene()) {
return;
}

Node *node = Object::cast_to<Node>(p_base);

if (node) {
NodePath path = editor->get_edited_scene()->get_path_to(node);
NodePath path = EditorNode::get_singleton()->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);

if (p_value.is_ref_counted()) {
Expand Down Expand Up @@ -1242,25 +1240,25 @@ void ScriptEditorDebugger::_live_edit_set() {

NodePath np = path;

editor->get_editor_data().set_edited_scene_live_edit_root(np);
EditorNode::get_singleton()->get_editor_data().set_edited_scene_live_edit_root(np);

update_live_edit_root();
}

void ScriptEditorDebugger::_live_edit_clear() {
NodePath np = NodePath("/root");
editor->get_editor_data().set_edited_scene_live_edit_root(np);
EditorNode::get_singleton()->get_editor_data().set_edited_scene_live_edit_root(np);

update_live_edit_root();
}

void ScriptEditorDebugger::update_live_edit_root() {
NodePath np = editor->get_editor_data().get_edited_scene_live_edit_root();
NodePath np = EditorNode::get_singleton()->get_editor_data().get_edited_scene_live_edit_root();

Array msg;
msg.push_back(np);
if (editor->get_edited_scene()) {
msg.push_back(editor->get_edited_scene()->get_scene_file_path());
if (EditorNode::get_singleton()->get_edited_scene()) {
msg.push_back(EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path());
} else {
msg.push_back("");
}
Expand Down Expand Up @@ -1657,12 +1655,10 @@ bool ScriptEditorDebugger::has_capture(const StringName &p_name) {
return captures.has(p_name);
}

ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
editor = p_editor;

ScriptEditorDebugger::ScriptEditorDebugger() {
tabs = memnew(TabContainer);
tabs->set_tab_alignment(TabContainer::ALIGNMENT_LEFT);
tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed));

add_child(tabs);
Expand Down
4 changes: 1 addition & 3 deletions editor/debugger/script_editor_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ class ScriptEditorDebugger : public MarginContainer {
EditorNetworkProfiler *network_profiler;
EditorPerformanceProfiler *performance_profiler;

EditorNode *editor;

OS::ProcessID remote_pid = 0;
bool breaked = false;
bool can_debug = false;
Expand Down Expand Up @@ -298,7 +296,7 @@ class ScriptEditorDebugger : public MarginContainer {
void unregister_message_capture(const StringName &p_name);
bool has_capture(const StringName &p_name);

ScriptEditorDebugger(EditorNode *p_editor = nullptr);
ScriptEditorDebugger();
~ScriptEditorDebugger();
};

Expand Down
6 changes: 2 additions & 4 deletions editor/dependency_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void DependencyEditorOwners::_select_file(int p_idx) {
String fpath = owners->get_item_text(p_idx);

if (ResourceLoader::get_resource_type(fpath) == "PackedScene") {
editor->open_request(fpath);
EditorNode::get_singleton()->open_request(fpath);
hide();
emit_signal(SNAME("confirmed"));
}
Expand Down Expand Up @@ -345,9 +345,7 @@ void DependencyEditorOwners::show(const String &p_path) {
set_title(TTR("Owners Of:") + " " + p_path.get_file());
}

DependencyEditorOwners::DependencyEditorOwners(EditorNode *p_editor) {
editor = p_editor;

DependencyEditorOwners::DependencyEditorOwners() {
file_options = memnew(PopupMenu);
add_child(file_options);
file_options->connect("id_pressed", callable_mp(this, &DependencyEditorOwners::_file_option));
Expand Down
4 changes: 1 addition & 3 deletions editor/dependency_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

class EditorFileDialog;
class EditorFileSystemDirectory;
class EditorNode;

class DependencyEditor : public AcceptDialog {
GDCLASS(DependencyEditor, AcceptDialog);
Expand Down Expand Up @@ -74,7 +73,6 @@ class DependencyEditorOwners : public AcceptDialog {

ItemList *owners;
PopupMenu *file_options;
EditorNode *editor;
String editing;

void _fill_owners(EditorFileSystemDirectory *efsd);
Expand All @@ -91,7 +89,7 @@ class DependencyEditorOwners : public AcceptDialog {

public:
void show(const String &p_path);
DependencyEditorOwners(EditorNode *p_editor);
DependencyEditorOwners();
};

class DependencyRemoveDialog : public ConfirmationDialog {
Expand Down
124 changes: 62 additions & 62 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6701,12 +6701,12 @@ EditorNode::EditorNode() {

// Instantiate and place editor docks

memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data));
memnew(InspectorDock(this, editor_data));
memnew(SceneTreeDock(scene_root, editor_selection, editor_data));
memnew(InspectorDock(editor_data));
memnew(ImportDock);
memnew(NodeDock);

FileSystemDock *filesystem_dock = memnew(FileSystemDock(this));
FileSystemDock *filesystem_dock = memnew(FileSystemDock);
filesystem_dock->connect("inherit", callable_mp(this, &EditorNode::_inherit_request));
filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instantiate_request));
filesystem_dock->connect("display_mode_changed", callable_mp(this, &EditorNode::_save_docks));
Expand Down Expand Up @@ -6926,7 +6926,7 @@ EditorNode::EditorNode() {
preview_gen = memnew(AudioStreamPreviewGenerator);
add_child(preview_gen);

add_editor_plugin(memnew(DebuggerEditorPlugin(this, debug_menu)));
add_editor_plugin(memnew(DebuggerEditorPlugin(debug_menu)));
add_editor_plugin(memnew(DebugAdapterServer()));

disk_changed = memnew(ConfirmationDialog);
Expand All @@ -6952,18 +6952,18 @@ EditorNode::EditorNode() {

gui_base->add_child(disk_changed);

add_editor_plugin(memnew(AnimationPlayerEditorPlugin(this)));
add_editor_plugin(memnew(CanvasItemEditorPlugin(this)));
add_editor_plugin(memnew(Node3DEditorPlugin(this)));
add_editor_plugin(memnew(ScriptEditorPlugin(this)));
add_editor_plugin(memnew(AnimationPlayerEditorPlugin));
add_editor_plugin(memnew(CanvasItemEditorPlugin));
add_editor_plugin(memnew(Node3DEditorPlugin));
add_editor_plugin(memnew(ScriptEditorPlugin));

EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor();

ScriptTextEditor::register_editor(); // register one for text scripts
TextEditor::register_editor();

if (StreamPeerSSL::is_available()) {
add_editor_plugin(memnew(AssetLibraryEditorPlugin(this)));
add_editor_plugin(memnew(AssetLibraryEditorPlugin));
} else {
WARN_PRINT("Asset Library not available, as it requires SSL to work.");
}
Expand All @@ -6975,62 +6975,62 @@ EditorNode::EditorNode() {

// more visually meaningful to have this later
raise_bottom_panel_item(AnimationPlayerEditor::get_singleton());
add_editor_plugin(memnew(ReplicationEditorPlugin(this)));
add_editor_plugin(memnew(ReplicationEditorPlugin));

add_editor_plugin(VersionControlEditorPlugin::get_singleton());
add_editor_plugin(memnew(ShaderEditorPlugin(this)));
add_editor_plugin(memnew(ShaderFileEditorPlugin(this)));
add_editor_plugin(memnew(VisualShaderEditorPlugin(this)));

add_editor_plugin(memnew(Camera3DEditorPlugin(this)));
add_editor_plugin(memnew(ThemeEditorPlugin(this)));
add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
add_editor_plugin(memnew(MeshInstance3DEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreeEditorPlugin(this)));
add_editor_plugin(memnew(MeshLibraryEditorPlugin(this)));
add_editor_plugin(memnew(StyleBoxEditorPlugin(this)));
add_editor_plugin(memnew(Sprite2DEditorPlugin(this)));
add_editor_plugin(memnew(Skeleton2DEditorPlugin(this)));
add_editor_plugin(memnew(GPUParticles2DEditorPlugin(this)));
add_editor_plugin(memnew(GPUParticles3DEditorPlugin(this)));
add_editor_plugin(memnew(CPUParticles2DEditorPlugin(this)));
add_editor_plugin(memnew(CPUParticles3DEditorPlugin(this)));
add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this)));
add_editor_plugin(memnew(Polygon3DEditorPlugin(this)));
add_editor_plugin(memnew(CollisionPolygon2DEditorPlugin(this)));
add_editor_plugin(memnew(TilesEditorPlugin(this)));
add_editor_plugin(memnew(SpriteFramesEditorPlugin(this)));
add_editor_plugin(memnew(TextureRegionEditorPlugin(this)));
add_editor_plugin(memnew(VoxelGIEditorPlugin(this)));
add_editor_plugin(memnew(LightmapGIEditorPlugin(this)));
add_editor_plugin(memnew(OccluderInstance3DEditorPlugin(this)));
add_editor_plugin(memnew(Path2DEditorPlugin(this)));
add_editor_plugin(memnew(Path3DEditorPlugin(this)));
add_editor_plugin(memnew(Line2DEditorPlugin(this)));
add_editor_plugin(memnew(Polygon2DEditorPlugin(this)));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this)));
add_editor_plugin(memnew(NavigationPolygonEditorPlugin(this)));
add_editor_plugin(memnew(GradientEditorPlugin(this)));
add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this)));
add_editor_plugin(memnew(CurveEditorPlugin(this)));
add_editor_plugin(memnew(FontEditorPlugin(this)));
add_editor_plugin(memnew(OpenTypeFeaturesEditorPlugin(this)));
add_editor_plugin(memnew(TextureEditorPlugin(this)));
add_editor_plugin(memnew(TextureLayeredEditorPlugin(this)));
add_editor_plugin(memnew(Texture3DEditorPlugin(this)));
add_editor_plugin(memnew(AudioStreamEditorPlugin(this)));
add_editor_plugin(memnew(AudioStreamRandomizerEditorPlugin(this)));
add_editor_plugin(memnew(ShaderEditorPlugin));
add_editor_plugin(memnew(ShaderFileEditorPlugin));
add_editor_plugin(memnew(VisualShaderEditorPlugin));

add_editor_plugin(memnew(Camera3DEditorPlugin));
add_editor_plugin(memnew(ThemeEditorPlugin));
add_editor_plugin(memnew(MultiMeshEditorPlugin));
add_editor_plugin(memnew(MeshInstance3DEditorPlugin));
add_editor_plugin(memnew(AnimationTreeEditorPlugin));
add_editor_plugin(memnew(MeshLibraryEditorPlugin));
add_editor_plugin(memnew(StyleBoxEditorPlugin));
add_editor_plugin(memnew(Sprite2DEditorPlugin));
add_editor_plugin(memnew(Skeleton2DEditorPlugin));
add_editor_plugin(memnew(GPUParticles2DEditorPlugin));
add_editor_plugin(memnew(GPUParticles3DEditorPlugin));
add_editor_plugin(memnew(CPUParticles2DEditorPlugin));
add_editor_plugin(memnew(CPUParticles3DEditorPlugin));
add_editor_plugin(memnew(ResourcePreloaderEditorPlugin));
add_editor_plugin(memnew(Polygon3DEditorPlugin));
add_editor_plugin(memnew(CollisionPolygon2DEditorPlugin));
add_editor_plugin(memnew(TilesEditorPlugin));
add_editor_plugin(memnew(SpriteFramesEditorPlugin));
add_editor_plugin(memnew(TextureRegionEditorPlugin));
add_editor_plugin(memnew(VoxelGIEditorPlugin));
add_editor_plugin(memnew(LightmapGIEditorPlugin));
add_editor_plugin(memnew(OccluderInstance3DEditorPlugin));
add_editor_plugin(memnew(Path2DEditorPlugin));
add_editor_plugin(memnew(Path3DEditorPlugin));
add_editor_plugin(memnew(Line2DEditorPlugin));
add_editor_plugin(memnew(Polygon2DEditorPlugin));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin));
add_editor_plugin(memnew(NavigationPolygonEditorPlugin));
add_editor_plugin(memnew(GradientEditorPlugin));
add_editor_plugin(memnew(CollisionShape2DEditorPlugin));
add_editor_plugin(memnew(CurveEditorPlugin));
add_editor_plugin(memnew(FontEditorPlugin));
add_editor_plugin(memnew(OpenTypeFeaturesEditorPlugin));
add_editor_plugin(memnew(TextureEditorPlugin));
add_editor_plugin(memnew(TextureLayeredEditorPlugin));
add_editor_plugin(memnew(Texture3DEditorPlugin));
add_editor_plugin(memnew(AudioStreamEditorPlugin));
add_editor_plugin(memnew(AudioStreamRandomizerEditorPlugin));
add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
add_editor_plugin(memnew(Skeleton3DEditorPlugin(this)));
add_editor_plugin(memnew(SkeletonIK3DEditorPlugin(this)));
add_editor_plugin(memnew(PhysicalBone3DEditorPlugin(this)));
add_editor_plugin(memnew(MeshEditorPlugin(this)));
add_editor_plugin(memnew(MaterialEditorPlugin(this)));
add_editor_plugin(memnew(GPUParticlesCollisionSDF3DEditorPlugin(this)));
add_editor_plugin(memnew(InputEventEditorPlugin(this)));
add_editor_plugin(memnew(SubViewportPreviewEditorPlugin(this)));
add_editor_plugin(memnew(TextControlEditorPlugin(this)));
add_editor_plugin(memnew(ControlEditorPlugin(this)));
add_editor_plugin(memnew(Skeleton3DEditorPlugin));
add_editor_plugin(memnew(SkeletonIK3DEditorPlugin));
add_editor_plugin(memnew(PhysicalBone3DEditorPlugin));
add_editor_plugin(memnew(MeshEditorPlugin));
add_editor_plugin(memnew(MaterialEditorPlugin));
add_editor_plugin(memnew(GPUParticlesCollisionSDF3DEditorPlugin));
add_editor_plugin(memnew(InputEventEditorPlugin));
add_editor_plugin(memnew(SubViewportPreviewEditorPlugin));
add_editor_plugin(memnew(TextControlEditorPlugin));
add_editor_plugin(memnew(ControlEditorPlugin));

for (int i = 0; i < EditorPlugins::get_plugin_count(); i++) {
add_editor_plugin(EditorPlugins::create(i, this));
Expand Down
Loading