Bladeren bron

Merge pull request #46389 from Shatur95/additional-plugin-path-checks

Add additional plugin path checks (3.2)
Rémi Verschelde 4 jaren geleden
bovenliggende
commit
d33ee6fa95
2 gewijzigde bestanden met toevoegingen van 18 en 8 verwijderingen
  1. 15 7
      editor/editor_node.cpp
  2. 3 1
      editor/editor_node.h

+ 15 - 7
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<ImageTexture> 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<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const {
 	ERR_FAIL_COND_V(!p_object || !gui_base, NULL);
 

+ 3 - 1
editor/editor_node.h

@@ -653,6 +653,8 @@ private:
 	bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class);
 	Ref<ImageTexture> _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);