Add metadata to resource previews#64628
Conversation
There was a problem hiding this comment.
This is just a bonus refactoring.
|
Ok this is probably ready to review. The metadata is correctly saved and loaded. Not sure how to force cache invalidation though; old previews don't have metadata stored. |
356e480 to
bcf9851
Compare
There was a problem hiding this comment.
Seems good to me. Lacking @reduz's explicit go but it doesn't seem too critical, he can validate later if needed.
Edit: Discussed it with reduz:
I am just not happy with the approach in general, but thinking how to do this properly is a good amount of work
we can probably still merge it anyway
If its important, it can be merged as-is, its fine
Needs a rebase. Might also be good to clarify what [param metadata] is used for in the docs.
|
Rebased. I clarified the |
|
Needs another rebase to fix CI. |
|
I promise the CI failure isn't my fault this time :P |
|
Thanks! |
| #include "core/io/resource_loader.h" | ||
| #include "core/io/resource_saver.h" | ||
| #include "core/object/message_queue.h" | ||
| #include "core/variant/variant_utility.cpp" |
|
The new required argument breaks compatibility, my plugin that was working from Godot 4.0 is no longer working in 4.1:
And if I fix this, it won't work in 4.0 anymore. |
Prerequisite for #63263
This PR adds preview metadata to EditorResourcePreview. A metadata can be image dimensions, audio stream length, model triangle count etc. In #63263 I want to display this information in a tooltip, but the problem is that fetching this information requires loading the resource, which can be costly sometimes. This PR allows to easily retrieve and cache the metadata, because generators already load the resource to make the preview.
What I do is pass a HashMap to the
generate()method of EditorResourcePreviewGenerator and the generator can add any metadata to that hashmap. It can be later retrieved by using resource path + metadata name. For now I only added "dimensions" metadata for textures.Marking as draft because:
Any advice on these welcome, but I'll try to figure it out myself.