X Tutup
Skip to content

Fall back to parent class icon by default for GDExtension#108607

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
beicause:icon-parent-class-by-default
Oct 31, 2025
Merged

Fall back to parent class icon by default for GDExtension#108607
Repiteo merged 1 commit intogodotengine:masterfrom
beicause:icon-parent-class-by-default

Conversation

@beicause
Copy link
Contributor

@beicause beicause commented Jul 14, 2025

This PR makes gdextension classes to use parent class icon recursively by default, instead of the Node or Object icon

@beicause beicause requested a review from a team July 14, 2025 15:29
@beicause beicause requested a review from a team as a code owner July 14, 2025 15:29
@beicause beicause requested a review from a team July 14, 2025 15:29
@beicause beicause requested review from a team as code owners July 14, 2025 15:29
@beicause beicause marked this pull request as draft July 14, 2025 17:11
@beicause beicause force-pushed the icon-parent-class-by-default branch 2 times, most recently from 16c1f28 to 3f57196 Compare July 14, 2025 18:22
@beicause beicause marked this pull request as ready for review July 14, 2025 18:58
@KoBeWi
Copy link
Member

KoBeWi commented Jul 18, 2025

Any minimal project to make testing this easier?

@beicause
Copy link
Contributor Author

Any minimal project to make testing this easier?

https://github.com/beicause/godot-cpp-template/tree/test-class-icon

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine.
I'm not sure if it resolves the proposal though.

@sylbeth
Copy link

sylbeth commented Jul 19, 2025

I am not sure it supersedes my implementation, it seems more like a parallel functionality. From what I take from the code, is that you take the parent class, and use that icon, right? I didn't go this route because I was told it wasn't possible back when I implemented this, but that would've been a previous default. Correct me if I'm wrong, reading Godot code feels like a puzzle most times, but I don't think your pr gives the user the ability to use the icon "Sprite3D" on a subclass of "CharacterBody2D", and that was indeed my intention. I find most times I don't want to just use the superclass icon, but an icon that best represents the new class I'm making, and I always find myself having to go through godot/editor/icons, choose an icon, copy and paste. I believe the algorithm should work like this:

  • If path to icon provided
    • If icon exists, use icon
    • If icon doesn't exist, but has the same name as an editor icon, use that
    • If none of that works, treat the path as nonexistent
  • In case it doesn't exist, or if the previous step failed
    • Use superclass if found
    • Use default fallback otherwise

I suggest we work together to implement this algorithm to cover all of it in one go, if you'd want, otherwise you can do it or I can do it

@beicause
Copy link
Contributor Author

Yes, I believe this PR is compatible with yours.

In my opinion automatically using the parent class icon is sufficient. Exposing the editor icons means additional compatibility burden. I'm not sure if it's actually useful.

If you want to implement that, I think you can make the changes in extension_class_get_icon.

@sylbeth
Copy link

sylbeth commented Jul 20, 2025

I did implement it in my PR, so it's just matching both codes.

In any case, yes, it is really useful. If I make a Node that represents a Ball, I'm going to be using Sphere3D instead of probably anything I've inherited, it gives better visual information.

Plus, I believe it's needed for feature parity with GDScript, since GDExtension should be a first class citizen of Godot.

@beicause
Copy link
Contributor Author

You can continue implementing it in #100298 based on this PR and resolve the conflicts - just make sure to return the icon before falling back to parent class icon.

In any case, yes, it is really useful. If I make a Node that represents a Ball, I'm going to be using Sphere3D instead of probably anything I've inherited, it gives better visual information.

In this case, I think it's better to copy&paste it or make one.

@sylbeth
Copy link

sylbeth commented Jul 20, 2025

You can continue implementing it in #100298 based on this PR and resolve the conflicts - just make sure to return the icon before falling back to parent class icon.

Sure, when I have the time, then.

In this case, I think it's better to copy&paste it or make one.

But that's the whole problem all the time, we'd like to access the already made icons instead of having to source a new icon for every new node we make. Sure, using the parent icon is better, than a blank node, but it still can be used to pack more information. Right now I have to update a line of code and search through godot/editor/icons for it, copy, and paste it. It would be much easier to just have to update the code, since it's easily accessible data for Godot, and clutters less the project with things that are already there.

@AThousandShips AThousandShips changed the title Fallback to parent class icon by default for gdextension Fall back to parent class icon by default for GDExtension Jul 29, 2025
@akien-mga akien-mga requested a review from a team October 29, 2025 21:00
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I'm not really qualified to review the code, because this changes parts of the editor that I'm not familiar with.

However, I tested this PR with godot-cpp, and it seems to work great!

So, if you combine my review with @KoBeWi's (who reviewed the code, but couldn't say if this fixes the issue or not), I think we should be good :-)

@akien-mga
Copy link
Member

Great! I'd suggest a rebase before merging as the last update was 3 months ago (and a quick check that no new code needs similar changes).

@beicause beicause force-pushed the icon-parent-class-by-default branch from 3f57196 to ce2fae7 Compare October 31, 2025 10:13
@Repiteo Repiteo merged commit 72a1b5a into godotengine:master Oct 31, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 31, 2025

Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

X Tutup