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

Handle multiple editor plugins that target the same resource #11009

Open
YeldhamDev opened this issue Oct 21, 2024 · 4 comments
Open

Handle multiple editor plugins that target the same resource #11009

YeldhamDev opened this issue Oct 21, 2024 · 4 comments

Comments

@YeldhamDev
Copy link
Member

Describe the project you are working on

The Godot Engine.

Describe the problem or limitation you are having in your project

The are a few editors that can handle the same resource, this causes the issue of which one gets the priority to handle it first. You can see it happen with the AnimationTree node in godotengine/godot#93455.

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

I have two possible solutions for this problem:

  • A priority system.
    An optional integer could be given to an editor plugin, and when one is being picked to handle a resource, the one with the highest integer would be selected.
  • A sister function to handles(): opens().
    Currently, the handles() function is used to check if an editor plugin can handle a resource, and all plugins that edit resources have it. The idea is that an opens() function is created, and plugins that shouldn't take priority to edit a resource (as in, opened automatically), should use it instead, so they will only edit a resource when the plugin is opened manually.

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

  • Priority system:
    All editor plugins start with a priority of "0" as the default, a function named set_priority() would be used to edit it. When fetching the list of available plugins for a resource, this priority will be checked to decide which one edits it.
  • opens():
    Editor plugins that should take priority when editing a resource would still use handles() as usual. Those that don't would use opens() instead, and this function would be used to check if a plugin opened manually can edit a resource.

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

No.

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

An add-on wouldn't be able to fix this.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 22, 2024

For the purpose of fixing Animation issue, priority system is enough and sounds like very simple to implement.
I don't fully understand how opens() is supposed to work 🤔

I remember attempting to fix the same issue and my solution was conditional handles() (i.e. plugin returns true only when it can handle the node/resource right now), but I think it didn't work well and I can't find the code anywhere.

@fire
Copy link
Member

fire commented Oct 25, 2024

resource system has a priority system already.

https://github.com/godotengine/godot/blob/6732a0fd867f40751c53f8ed7a3a15bf1b45323f/core/io/resource_importer.h#L119

@YeldhamDev
Copy link
Member Author

@KoBeWi

I don't fully understand how opens() is supposed to work 🤔

To keep it short: if a plugin should automatically open when a resourced is edited, use handles(), if not, opens().

@fire

resource system has a priority system already.

This is only available for ResourceImporter currently.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 26, 2024

To keep it short: if a plugin should automatically open when a resourced is edited, use handles(), if not, opens().

In the end it's the plugin that opens its editor (via make_visible()), so you can handle that with custom logic. Though not sure if it's possible with bottom panel.

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

3 participants