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

Allow hiding experimental and deprecated classes from the "Create New Node" and "Create New Resource" dialogs #9298

Open
theraot opened this issue Mar 14, 2024 · 0 comments

Comments

@theraot
Copy link

theraot commented Mar 14, 2024

Describe the project you are working on

Organizing code that has grown organically by being copied from project to project.

Describe the problem or limitation you are having in your project

There are classes that I want to reference from code, but I do not want to give a class_name because they show up in the "Create New Node" dialog. This has led me to reference them via preload, but I've ended up with relative paths which are easy to break as I reorganize my code into folders.

Notably:

  • A class that must be instantiated as a child of a Viewport, and there must be only one per Viewport, which will optionally capture all input.
  • A class that must be instantiated as a child of a Window, and there must be only one per Window, which will optionally capture the mouse pointer.

These classes will be instantiated from code (the designer should not be adding them to any scene). So they do not have a class_name. And there are multiple places where I check for them, so there are multiple preloads with relative paths for them.

This also means that @abstract (see #4493 (comment), #5641) would not be appropriate for my use case.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Originally I wanted this:

I see this pull request where an annotation is added to allow classes to show up:

However, I agree with this comment godotengine/godot#63758 (comment) because in practice most classes that have a class_name are OK to show up in the dialogs to create nodes or resources. So, I would prefer a negative annotation...

But we already have something similar: We can mark a class as obsolete or experimental. And the dialogs are already aware of them. Thus, I propose to hide them.

Related:

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

An option either in project settings or a toggle in the "Create New Node" and "Create New Resource" dialogs, which results in the dialog hiding any classes that are marked experimental or deprecated.

Plus we might extend these comment documentation marks to annotate other reasons to not use the class.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I think we might be able to monkey patch the dialogs, however that won't be a few lines of code.

Right now I'm wondering if it is better to:

- Have the instance check if they are the ones created from code, and if they are then disable themselves and put a configuration warning saying to not use them.
- Or figure out how to monkey patch these dialogs to remove my classes.

For my use case it seems simpler to have the instances check if they have an owner, and if so disable themselves and have a configuration warning.

Is there a reason why this should be core and not an add-on in the asset library?

This might be possible via an addon. However I believe this better in core.

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

No branches or pull requests

2 participants