-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
GDExtension: Add method to set the class icon #100193
GDExtension: Add method to set the class icon #100193
Conversation
Thanks! Having a way to set the icon via code is a much requested feature from GDExtension bindings authors, so I'm in support of the feature in general. However, I'm not sure this is the right API. On the godot-cpp side, we'd want to emulate the workflow that Godot module developers use, so pointing the build-system at a directory and having godot-cpp automatically register the icons it finds there. (Or, if we wanted to add a new workflow, we'd want for it to be available to both GDExtensions and modules, but I think the existing workflow of the icons getting picked up automatically is pretty good.) And then for other language bindings, we'd want them to be able to either (1) implement a similar automatic workflow, or (2) allow them to include setting the icon as part of their usual registration process (for example, if a Python binding used class decorators to register classes, the icon path could be an argument to the decorator) I think the function added to the GDExtension interface here could be used. For godot-cpp, we could have the build-system generate a |
Thanks for the review. My intention is to use this on the C# bindings which, similar to how it works today, would allow you to specify the icon path with an attribute: [Icon("res://MyNode.svg")]
public class MyNode : Node { } The necessary calls to the GDExtension API to register the icon are generated by the C# source generators at build time. I have no intention of changing the icon at runtime. This likely works similar to the Python example you mentioned.
That works for me too. The current implementation is just the first thing that came to mind, but I'm totally fine with changing the implementation to whatever the team prefers. It may be a bit more complicated though. In C# we have a configuration method where we bind all the methods/properties/signals (similar to |
Hm. There is no way to stash the path to the icon somewhere and use it as part of the class registration? For better or worse, binding methods/properties/signals does work at any time. You really shouldn't do it - it's intended that those are bound shortly after registering the class - but it works. :-) So, I think if we do implement setting the icon as a function to be called like binding a method/property/signal, it should also work at any time. We really have no way of restricting developers to calling those functions only during a (We could have maybe constructed the GDExtension interface such that we'd pass a callback to Godot that would call a |
Yes, I think I'll end up making our "_bind_methods"-like function not really register anything and just stash the icon/methods/properties/signals somewhere, then we should be able to register everything in whatever order we want at a later point.
That sounds good to me, and as I said I think I'll end up implementing something like that on the C# side. If GDExtension does this then it'd be less work for me on the bindings side, but I can make it work either way. |
2f9f60b
to
b0c4e74
Compare
Allows GDExtensions to set the icon of a class programmatically, which is useful for extensions that don't use a `.gdextension` file.
b0c4e74
to
69f1cc1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is looking good to me!
@raulsntos Let me know if you plan to update the godot-cpp PR, or if you'd like me to take that over?
Sure. I updated the |
I'd like to add something to the build system that will automatically pull in icons from a directory, allowing the same workflow as with Godot modules. I'd be happy to take over the godot-cpp changes and add that in :-) |
Thanks! |
Allows GDExtensions to set the icon of a class programmatically, which is useful for extensions that don't use a
.gdextension
file.godot-cpp
repo: Add a method to set the class icon godot-cpp#1666