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

Automatically enable newly-installed plugins #94481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wjt
Copy link
Contributor

@wjt wjt commented Jul 17, 2024

While installing an asset, check whether it installs any files matching the target pattern res://addons/*/plugin.cfg. If so, and providing that no errors are encountered while unpacking the asset, enable each plugin plugin once the new files have been scanned and scripts within added to the class database.

Inspired by #35234.

Fixes godotengine/godot-proposals#324.


We at Endless are developing a block coding plugin and other learning tools targeting young people who are new to Godot. We keep seeing people (including our colleagues, in one case twice in a single playtesting session) forget to enable the plugin after installing it, and then wondering why the plugin isn't working.

Unlike #35234 I have not included a way to add an asset without enabling any included plugins, on the basis that there is a clear intent to use the plugin – otherwise, why would one be installing it? I guess the counterargument is that someone may wish to review the code before executing it – but the asset library review process is presumably intended in part to catch malicious plugins, and in reality I think it's unlikely that people are reviewing every plugin they use in detail before enabling it. I feel strongly that the default should be to enable the plugin, even if there were a way to download without enabling.

I am very new to this codebase so I'm sure there are shortcomings in the implementation here! It seems to work in testing so far but this is perhaps more of a proof-of-concept/request-for-comment.

While installing an asset, check whether it installs any files matching
the target pattern res://addons/*/plugin.cfg. If so, and providing that
no errors are encountered while unpacking the asset, enable each plugin
plugin once the new files have been scanned and scripts within added to
the class database.

Inspired by godotengine#35234.

Fixes godotengine/godot-proposals#324
@adamscott
Copy link
Member

adamscott commented Jul 24, 2024

Thank you for your first PR!

Yes, this is a missing feature that should help streamlining the use of plugins. I myself get surprised, sometimes, that my installed plugin isn't active.

As we discussed on the dev chat, there's two types of assets in the asset lib:

  1. Packages of simple files to download, like images and such.
  2. Plugins.

And there's also the risk of running untrusted code automatically, without the ability to review the files on your disk first.

What I suggest is the following. It resembles what was already proposed in godotengine/godot-proposals#324:

Capture d’écran, le 2024-07-24 à 08 58 38

I would check in the downloaded files if there's a plugin.cfg file. If so, then we can add a "Install and enable" button that does exactly what your PR does, but keep the ability to install without executing. But if there's no plugin, then we hide/disable the "Install and enable" button.

@@ -553,6 +554,12 @@ void EditorAssetInstaller::_install_asset() {
Ref<FileAccess> f = FileAccess::open(target_path, FileAccess::WRITE);
if (f.is_valid()) {
f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
if (target_path.begins_with("res://addons/")) {
Vector<String> separated = target_path.substr(13).split("/");
if (separated.size() == 2 && separated[1] == "plugin.cfg") {
Copy link
Member

@KoBeWi KoBeWi Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this won't work for addons inside subfolders. Check #91337 to see how it can be done more reliably.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this pointer! I'm happy to see an existing use of the magic number 13 :)

@wjt
Copy link
Contributor Author

wjt commented Jul 24, 2024

I would check in the downloaded files if there's a plugin.cfg file. If so, then we can add a "Install and enable" button that does exactly what your PR does, but keep the ability to install without executing. But if there's no plugin, then we hide/disable the "Install and enable" button.

Here's what I have in mind. If there's one or more plugin, the dialog would look like this:

“Configure Asset Before Installing” dialog with three buttons: “Cancel”, “Install Without Enabling”, “Install and Enable”

with “Install and Enable” focused by default. Otherwise, the two buttons would read “Cancel” and “Install” as today.

It's slightly weird that changing the install folder and/or toggling “Ignore asset root” would make one of the buttons appear and disappear. I guess I'll see how this feels. But it would seem weirder to have an always-insensitive button for non-plugin assets.

Is there any style guide for UI elements in Godot, similar to the GNOME HIG’s Writing Style guide which specifies that button labels should be titlecased (and sets out what that actually means). Having searched the code a little further, the prevailing style seems to be to use titlecase in button labels but use “&” rather than “and”, so the button would be “Install & Enable”.

@Calinou
Copy link
Member

Calinou commented Jul 24, 2024

Is there any style guide for UI elements in Godot

Yes: Editor style guide

Some existing messages in Godot don't follow this style guide yet though, especially when it comes to single quotes versus double quotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically enable newly installed addons
4 participants