summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-06 00:11:59 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-06 00:11:59 +0100
commite070362bd0e8213d121fb9be5c11f1b58c7562e4 (patch)
treea6aa337ebdb63ed96f4ecf8de11b364fb1431a8e
parent1816f49886c32c89e328edfe4fbd99fcf9292530 (diff)
parent82c00c21e6d907a4be81f6cc404181acc7060265 (diff)
Merge pull request #70963 from YuriSizov/editor-dead-codes-society
Simplify some editor plugin logic and remove dead code
-rw-r--r--doc/classes/AnimationNode.xml5
-rw-r--r--editor/editor_node.cpp58
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/editor_properties.cpp3
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp6
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.h2
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp8
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.h1
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp5
-rw-r--r--editor/plugins/animation_state_machine_editor.h2
-rw-r--r--scene/animation/animation_tree.cpp1
11 files changed, 19 insertions, 73 deletions
diff --git a/doc/classes/AnimationNode.xml b/doc/classes/AnimationNode.xml
index 79deb008d2..a33ec2f6dc 100644
--- a/doc/classes/AnimationNode.xml
+++ b/doc/classes/AnimationNode.xml
@@ -165,11 +165,6 @@
</member>
</members>
<signals>
- <signal name="removed_from_graph">
- <description>
- Emitted when the node was removed from the graph.
- </description>
- </signal>
<signal name="tree_changed">
<description>
Emitted by nodes that inherit from this class and that have an internal tree when one of their nodes changes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 9110238370..30a2a2143c 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2041,18 +2041,6 @@ void EditorNode::_dialog_action(String p_file) {
}
}
-bool EditorNode::item_has_editor(Object *p_object) {
- if (_is_class_editor_disabled_by_feature_profile(p_object->get_class())) {
- return false;
- }
-
- return editor_data.get_subeditors(p_object).size() > 0;
-}
-
-void EditorNode::edit_item_resource(Ref<Resource> p_resource) {
- edit_item(p_resource.ptr());
-}
-
bool EditorNode::_is_class_editor_disabled_by_feature_profile(const StringName &p_class) {
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
if (profile.is_null()) {
@@ -2075,37 +2063,43 @@ bool EditorNode::_is_class_editor_disabled_by_feature_profile(const StringName &
}
void EditorNode::edit_item(Object *p_object) {
- Vector<EditorPlugin *> sub_plugins;
+ if (p_object && _is_class_editor_disabled_by_feature_profile(p_object->get_class())) {
+ return;
+ }
+ Vector<EditorPlugin *> top_plugins = editor_plugins_over->get_plugins_list();
+ Vector<EditorPlugin *> item_plugins;
if (p_object) {
- if (_is_class_editor_disabled_by_feature_profile(p_object->get_class())) {
- return;
- }
- sub_plugins = editor_data.get_subeditors(p_object);
+ item_plugins = editor_data.get_subeditors(p_object);
}
- if (!sub_plugins.is_empty()) {
+ if (!item_plugins.is_empty()) {
bool same = true;
- if (sub_plugins.size() == editor_plugins_over->get_plugins_list().size()) {
- for (int i = 0; i < sub_plugins.size(); i++) {
- if (sub_plugins[i] != editor_plugins_over->get_plugins_list()[i]) {
+ if (item_plugins.size() == top_plugins.size()) {
+ for (int i = 0; i < item_plugins.size(); i++) {
+ if (item_plugins[i] != top_plugins[i]) {
same = false;
}
}
} else {
same = false;
}
+
if (!same) {
_display_top_editors(false);
- _set_top_editors(sub_plugins);
+ _set_top_editors(item_plugins);
}
_set_editing_top_editors(p_object);
_display_top_editors(true);
- } else {
+ } else if (!top_plugins.is_empty()) {
hide_top_editors();
}
}
+void EditorNode::edit_item_resource(Ref<Resource> p_resource) {
+ edit_item(p_resource.ptr());
+}
+
void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) {
if (!p_object) {
InspectorDock::get_inspector_singleton()->edit(nullptr);
@@ -2351,21 +2345,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
}
}
- Vector<EditorPlugin *> sub_plugins;
-
- if (!_is_class_editor_disabled_by_feature_profile(current_obj->get_class())) {
- sub_plugins = editor_data.get_subeditors(current_obj);
- }
-
- if (!sub_plugins.is_empty()) {
- _display_top_editors(false);
-
- _set_top_editors(sub_plugins);
- _set_editing_top_editors(current_obj);
- _display_top_editors(true);
- } else if (!editor_plugins_over->get_plugins_list().is_empty()) {
- hide_top_editors();
- }
+ edit_item(current_obj);
}
InspectorDock::get_singleton()->update(current_obj);
@@ -5939,8 +5919,6 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state);
ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes);
- ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource);
-
ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
ADD_SIGNAL(MethodInfo("play_pressed"));
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 5af3e88556..f3dad8e223 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -795,7 +795,6 @@ public:
void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false);
void edit_item(Object *p_object);
void edit_item_resource(Ref<Resource> p_resource);
- bool item_has_editor(Object *p_object);
void hide_top_editors();
void select_editor_by_name(const String &p_name);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 45de5cde47..ba42bbf3bd 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -3925,7 +3925,7 @@ void EditorPropertyResource::_open_editor_pressed() {
Ref<Resource> res = get_edited_object()->get(get_edited_property());
if (res.is_valid()) {
// May clear the editor so do it deferred.
- EditorNode::get_singleton()->call_deferred(SNAME("edit_item_resource"), res);
+ callable_mp(EditorNode::get_singleton(), &EditorNode::edit_item_resource).bind(res).call_deferred();
}
}
@@ -4189,7 +4189,6 @@ void EditorPropertyResource::_notification(int p_what) {
}
void EditorPropertyResource::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_open_editor_pressed"), &EditorPropertyResource::_open_editor_pressed);
ClassDB::bind_method(D_METHOD("_fold_other_editors"), &EditorPropertyResource::_fold_other_editors);
}
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 36eb765979..00e7f28bb5 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -855,10 +855,6 @@ void AnimationNodeBlendSpace2DEditor::_open_editor() {
}
}
-void AnimationNodeBlendSpace2DEditor::_removed_from_graph() {
- EditorNode::get_singleton()->edit_item(nullptr);
-}
-
void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() {
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Toggle Auto Triangles"));
@@ -874,8 +870,6 @@ void AnimationNodeBlendSpace2DEditor::_bind_methods() {
ClassDB::bind_method("_update_tool_erase", &AnimationNodeBlendSpace2DEditor::_update_tool_erase);
ClassDB::bind_method("_update_edited_point_pos", &AnimationNodeBlendSpace2DEditor::_update_edited_point_pos);
-
- ClassDB::bind_method("_removed_from_graph", &AnimationNodeBlendSpace2DEditor::_removed_from_graph);
}
AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = nullptr;
diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h
index 1977787a24..f11cccabc1 100644
--- a/editor/plugins/animation_blend_space_2d_editor.h
+++ b/editor/plugins/animation_blend_space_2d_editor.h
@@ -121,8 +121,6 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin {
void _edit_point_pos(double);
void _open_editor();
- void _removed_from_graph();
-
void _auto_triangles_toggled();
StringName get_blend_position_path() const;
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 3ebb1e38e9..0ebc780604 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -815,12 +815,6 @@ void AnimationNodeBlendTreeEditor::_inspect_filters(const String &p_which) {
filter_dialog->popup_centered(Size2(500, 500) * EDSCALE);
}
-void AnimationNodeBlendTreeEditor::_removed_from_graph() {
- if (is_visible()) {
- EditorNode::get_singleton()->edit_item(nullptr);
- }
-}
-
void AnimationNodeBlendTreeEditor::_update_editor_settings() {
graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning")));
graph->set_warped_panning(bool(EDITOR_GET("editors/panning/warped_mouse_panning")));
@@ -1050,7 +1044,6 @@ bool AnimationNodeBlendTreeEditor::can_edit(const Ref<AnimationNode> &p_node) {
void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) {
if (blend_tree.is_valid()) {
blend_tree->disconnect("node_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_changed));
- blend_tree->disconnect("removed_from_graph", callable_mp(this, &AnimationNodeBlendTreeEditor::_removed_from_graph));
}
blend_tree = p_node;
@@ -1063,7 +1056,6 @@ void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) {
read_only = EditorNode::get_singleton()->is_resource_read_only(blend_tree);
blend_tree->connect("node_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_changed));
- blend_tree->connect("removed_from_graph", callable_mp(this, &AnimationNodeBlendTreeEditor::_removed_from_graph));
update_graph();
}
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h
index fe7b2efc1c..b471d47df6 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.h
+++ b/editor/plugins/animation_blend_tree_editor_plugin.h
@@ -123,7 +123,6 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin {
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing);
- void _removed_from_graph();
void _update_editor_settings();
void _update_theme();
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index ff45c526c3..4ea2f0c561 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -1760,10 +1760,6 @@ void AnimationNodeStateMachineEditor::_open_editor(const String &p_name) {
AnimationTreeEditor::get_singleton()->enter_editor(p_name);
}
-void AnimationNodeStateMachineEditor::_removed_from_graph() {
- EditorNode::get_singleton()->edit_item(nullptr);
-}
-
void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
const String &new_name = p_text;
@@ -1942,7 +1938,6 @@ void AnimationNodeStateMachineEditor::_update_mode() {
void AnimationNodeStateMachineEditor::_bind_methods() {
ClassDB::bind_method("_update_graph", &AnimationNodeStateMachineEditor::_update_graph);
- ClassDB::bind_method("_removed_from_graph", &AnimationNodeStateMachineEditor::_removed_from_graph);
ClassDB::bind_method("_open_editor", &AnimationNodeStateMachineEditor::_open_editor);
ClassDB::bind_method("_connect_to", &AnimationNodeStateMachineEditor::_connect_to);
ClassDB::bind_method("_stop_connecting", &AnimationNodeStateMachineEditor::_stop_connecting);
diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h
index 32a6539aed..46fe13ccc1 100644
--- a/editor/plugins/animation_state_machine_editor.h
+++ b/editor/plugins/animation_state_machine_editor.h
@@ -127,8 +127,6 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin {
void _add_animation_type(int p_index);
void _connect_to(int p_index);
- void _removed_from_graph();
-
struct NodeRect {
StringName node_name;
Rect2 node;
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 0fb307eaf5..ab341797c7 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -431,7 +431,6 @@ void AnimationNode::_bind_methods() {
GDVIRTUAL_BIND(_get_caption);
GDVIRTUAL_BIND(_has_filter);
- ADD_SIGNAL(MethodInfo("removed_from_graph"));
ADD_SIGNAL(MethodInfo("tree_changed"));
BIND_ENUM_CONSTANT(FILTER_IGNORE);