1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Add support for icons in GDExtension classes

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
Yuri Sizov
2023-03-31 21:17:59 +02:00
parent 1522762dc9
commit ee2cc347c6
7 changed files with 71 additions and 7 deletions

View File

@@ -4477,21 +4477,33 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons
return script_icon;
}
// No custom icon was found in the inheritance chain, so check the built-in
// base class instead.
// No custom icon was found in the inheritance chain, so check the base
// class of the script instead.
String base_type;
p_script->get_language()->get_global_class_name(p_script->get_path(), &base_type);
if (gui_base) {
if (gui_base->has_theme_icon(base_type, "EditorIcons")) {
return gui_base->get_theme_icon(base_type, "EditorIcons");
}
return gui_base->get_theme_icon(p_fallback, "EditorIcons");
// Check if the base type is an extension-defined type.
Ref<Texture2D> ext_icon = ed.extension_class_get_icon(base_type);
if (ext_icon.is_valid()) {
return ext_icon;
}
// Look for the base type in the editor theme.
// This is only relevant for built-in classes.
if (gui_base && gui_base->has_theme_icon(base_type, "EditorIcons")) {
return gui_base->get_theme_icon(base_type, "EditorIcons");
}
}
// Script was not valid or didn't yield any useful values, try the class name
// directly.
// Check if the class name is an extension-defined type.
Ref<Texture2D> ext_icon = ed.extension_class_get_icon(p_class);
if (ext_icon.is_valid()) {
return ext_icon;
}
// Check if the class name is a custom type.
// TODO: Should probably be deprecated in 4.x
const EditorData::CustomType *ctype = ed.get_custom_type_by_name(p_class);