From eb98ddf2c76863ddc21f3b24236b802b38407886 Mon Sep 17 00:00:00 2001 From: Shatur95 Date: Wed, 24 Feb 2021 19:29:58 +0200 Subject: [PATCH] Add additional plugin path checks (3.2) Need for compatibility after #45316. --- editor/editor_node.cpp | 22 +++++++++++++++------- editor/editor_node.h | 4 +++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 478fd8ea07d..a015752a736 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -491,11 +491,7 @@ void EditorNode::_notification(int p_what) { } for (int i = 0; i < addons.size(); i++) { - if (addons[i].begins_with("res://")) { - set_addon_plugin_enabled(addons[i], true); - } else { - set_addon_plugin_enabled("res://addons/" + addons[i] + "/plugin.cfg", true); - } + set_addon_plugin_enabled(addons[i], true); } _initializing_addons = false; } @@ -3210,7 +3206,11 @@ void EditorNode::_update_addon_config() { project_settings->queue_save(); } -void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed) { +void EditorNode::set_addon_plugin_enabled(String p_addon, bool p_enabled, bool p_config_changed) { + + if (!p_addon.begins_with("res://")) { + p_addon = _to_absolute_plugin_path(p_addon); + } ERR_FAIL_COND(p_enabled && plugin_addons.has(p_addon)); ERR_FAIL_COND(!p_enabled && !plugin_addons.has(p_addon)); @@ -3293,7 +3293,11 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool EditorNode::is_addon_plugin_enabled(const String &p_addon) const { - return plugin_addons.has(p_addon); + if (p_addon.begins_with("res://")) { + return plugin_addons.has(p_addon); + } + + return plugin_addons.has(_to_absolute_plugin_path(p_addon)); } void EditorNode::_remove_edited_scene(bool p_change_tab) { @@ -3968,6 +3972,10 @@ Ref EditorNode::_load_custom_class_icon(const String &p_path) cons return NULL; } +String EditorNode::_to_absolute_plugin_path(const String &p_plugin_name) { + return "res://addons/" + p_plugin_name + "/plugin.cfg"; +} + Ref EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { ERR_FAIL_COND_V(!p_object || !gui_base, NULL); diff --git a/editor/editor_node.h b/editor/editor_node.h index cddc0c84e49..2448da196ae 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -653,6 +653,8 @@ private: bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class); Ref _load_custom_class_icon(const String &p_path) const; + static String _to_absolute_plugin_path(const String &p_path); + protected: void _notification(int p_what); @@ -705,7 +707,7 @@ public: void add_control_to_dock(DockSlot p_slot, Control *p_control); void remove_control_from_dock(Control *p_control); - void set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed = false); + void set_addon_plugin_enabled(String p_addon, bool p_enabled, bool p_config_changed = false); bool is_addon_plugin_enabled(const String &p_addon) const; void edit_node(Node *p_node);