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

Rework global class hiding in addons #91337

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Apr 29, 2024

Fixes #78400
Supersedes #86325

Currently when global class scrip is inside addons folder, the editor will check whether the middle directory is an enabled addon. This is a legacy code; now addons are enabled by their full path to plugin.cfg, which can be inside a sub-folder. With this PR it is taken into account by scanning script's parent directories for plugin config. I also added extra check for the config existence - if a script is inside addons subfolder that isn't actually an addon, the class will always be visible. This allows creating custom class addons without making a plugin. CC @Calinou I remember you requested it once.

@ajreckof
Copy link
Member

This is compat breaking for nested plugins you should go from bottom up as previous PR was doing or else it will check the wrong plugin.

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 29, 2024

Well it checks the top-most plugin. If it's inside another plugin, the parent plugin is ignored. Isn't it expected behavior?

@ajreckof
Copy link
Member

No expected behaviour is that nested plugins are ignored and considered part of the parent plugin. At least this how it is treated right now meaning you can't enable them at all.

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 29, 2024

you can't enable them at all.

You can, using set_plugin_enabled(). I use this trick to have more than 1 plugin per addon.
I forgot this is a thing tbh, and I'm not even sure why would someone make a nested plugin if they can't (won't) enable it.

@ajreckof
Copy link
Member

I'm using it when I use another person add-ons and I just add it as a submodule meaning I get everything but I don't care about the plugin in itself and just want some of the global classes.

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 30, 2024

But is the plugin nested? Can you show how does your folder structure look?

@ajreckof
Copy link
Member

ajreckof commented Apr 30, 2024

Capture d’écran 2024-05-01 à 00 39 34

Something like that the goal is to have acces to the UsefullGlobalClass without having to manually enable this other plugin it will just be included when adding the main one

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 30, 2024

Was Test2 originally in Test1, or you put it there as a sub-module like you said? I assume the latter, but not sure why would you do that, other than maybe hiding the plugin from project settings list.

@ajreckof
Copy link
Member

In general Test2 is a plugin I didn't make myself that I'm adding as submodule so that it does not appear in the list and class from it are added whenever the parent addon is enabled

@KoBeWi
Copy link
Member Author

KoBeWi commented May 8, 2024

Changed to check base folder first, though I think the check is more expensive this way (probably shouldn't matter).

editor/create_dialog.cpp Outdated Show resolved Hide resolved
editor/create_dialog.cpp Outdated Show resolved Hide resolved
@akien-mga akien-mga merged commit 2d22dfa into godotengine:master Jun 26, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@emklasson
Copy link
Contributor

This code only looks at the outermost plugin. If that one is enabled then all global classes inside it are shown even if they're inside a disabled nested plugin.

My earlier PR (#86325) hides a global class if any plugin in it's path is disabled. Doesn't that make more sense conceptually?

If one wants the inner global classes but not the plugin they're in then I would argue they shouldn't be in a disabled plugin. Just delete the plugin.cfg in that case? And if the global classes should be shown even when they're in a disabled plugin (nested), then why not show them even if the outermost one is disabled as well?

I.e. either respect the disabled status of plugins fully or not at all.

Just a thought, doesn't matter for my usage.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jun 28, 2024

That's how it was originally implemented, no? See the above discussion.

@emklasson
Copy link
Contributor

That's how it was originally implemented, no? See the above discussion.

True. That still seems like quirky, unintuitive mechanics to me that's better off changed, but I can see the case for not disturbing existing workflows as well.

@romifauzi
Copy link

I'm not sure what I'm doing wrong, but it seems that a C# Resource class, that is inside a subfolder, still gets hidden. It is only shown on the "New Dialog" window if its placed on the root "addons" folder. I'm on 4.3 RC3

@Blank113
Copy link

I cant get mine to show at all in the new resource dialog. not sure if i am missing some setup, but i am trying to learn c# while creating a simple game, but i need custom nodes and resources. so how can i make them available in the editor dialogs? i am using

[GlobalClass]
public partial class EntityMovementStats : Resource

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.

Create dialog does not show global classes from addons inside subfolders
6 participants