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

Add additional plugin path checks (3.2) #46389

Merged
merged 1 commit into from
Feb 24, 2021
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
22 changes: 15 additions & 7 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ class EditorNode : public Node {
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);

Expand Down Expand Up @@ -705,7 +707,7 @@ class EditorNode : public Node {
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);
Expand Down