-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Don't grab theme icons for scripts #79203
Conversation
Fixes #76983 ? |
This is fine as a temporary fix, but... This was a part of the old The method that you've changed deals with the script, so I think it should still do the look up for the base class in the theme. The discrepancy must be handled at a higher level, in |
What unwanted side-effects would my change cause? Note that |
I suppose, scripts without custom icons will display a generic icon rather than an icon corresponding to their base type. And I mean scripts themselves rather than nodes with these scripts attached.
We could cache base types in |
Do we even display custom icons for Script resources? I think it's always based on the language only. |
|
Just wanted to point out, that I have a PR which addresses the same issue: #76993. |
I looked at the code again, and just as I noted in a previous comment, Lines 4308 to 4318 in 8f175a8
And this part of code actually checks if the returned script icon is valid and tries further if not: Lines 4285 to 4290 in 8f175a8
So not sure what should I change. Am I missing something? |
The bit that you removed looks if the base type of the script has an icon in the theme. That's the only place where we try to find an icon for the base type. The snippets that you've highlighted don't use the base type of the script, they use the class name passed to the function. This means that after your changes if you call When I unified them, I used a combination of checks from both methods. That's how we have this check that you're removing in there. I took the code from the old But if we want to preserve the old logic correctly, Lines 4285 to 4290 in 8f175a8
Something like if (p_script.is_valid()) {
Ref<Texture2D> script_icon = ed.get_script_icon(p_script);
if (script_icon.is_valid()) {
return script_icon;
}
// Look for the base type in the editor theme.
// This is only relevant for built-in classes.
String base_type;
p_script->get_language()->get_global_class_name(p_script->get_path(), &base_type);
if (gui_base && gui_base->has_theme_icon(base_type, SNAME("EditorIcons"))) {
return gui_base->get_theme_icon(base_type, SNAME("EditorIcons"));
}
} |
10804b9
to
51f92d1
Compare
Ok I pushed something, but idk how to test it. |
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.
I think this is good now. At the very least it preserves the original logic and reverts my incorrect changes. We can see if there are any new complaints or if we notice any issues naturally.
Thanks! |
Cherry-picked for 4.1.2. |
When a node is extending a different class from it's actual type, the scene tree dock will show the script class instead. Extending a different class is a common use-case, e.g. you might have a Container-based node, but make the script extend Control to avoid problems with changing type etc. Scene tree displaying script type means that you don't know what Container type this node represents unless you hover it and check the tooltip. It's confusing and annoying.
This PR gets rid of this behavior. Custom types are unaffected.
Before
After
EDIT:
Fixes #76983