Add builtin icons as a fallback option and as a way to use the editor's icons #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This check makes it so, in case any custom icon finding or opening were to fail, it fallbacks on a builtin icon in the theme with the same name. This way, we can specify an icon that's already in the engine instead of having to provide it. For example, if you wanted your CustomNode icon to be that of a CharacterBody2D, you could specify it as a path with "CharacterBody2D".
This would palliate the need to automatically find the base class to use as the icon. Not only that, but it also covers more use cases. Let's say you make a node that's akin to a person, but you use Node2D as the base instead. You could specify the icon to be that of CharacterBody2D instead.
This allows users not to have to provide the icon, saving space on the computer and also stopping them from bloating the project folders.
In this implementation though, worst case scenario the GDExtension::get_singleton()->class_get_icon_path(p_class) gets called twice, but this can easily be changed if that's what's wanted here, and I can change it myself.
Original proposal: godotengine/godot-proposals#11336