@@ -984,20 +984,6 @@ bool EditorData::script_class_is_parent(const String &p_class, const String &p_i
984
984
return true ;
985
985
}
986
986
987
- StringName EditorData::script_class_get_base (const String &p_class) const {
988
- Ref<Script> script = script_class_load_script (p_class);
989
- if (script.is_null ()) {
990
- return StringName ();
991
- }
992
-
993
- Ref<Script> base_script = script->get_base_script ();
994
- if (base_script.is_null ()) {
995
- return ScriptServer::get_global_class_base (p_class);
996
- }
997
-
998
- return script->get_language ()->get_global_class_name (base_script->get_path ());
999
- }
1000
-
1001
987
Variant EditorData::script_class_instance (const String &p_class) {
1002
988
if (ScriptServer::is_global_class (p_class)) {
1003
989
Ref<Script> script = script_class_load_script (p_class);
@@ -1034,7 +1020,7 @@ String EditorData::script_class_get_icon_path(const String &p_class) const {
1034
1020
String current = p_class;
1035
1021
String ret = _script_class_icon_paths[current];
1036
1022
while (ret.is_empty ()) {
1037
- current = script_class_get_base (current);
1023
+ current = ScriptServer::get_global_class_base (current);
1038
1024
if (!ScriptServer::is_global_class (current)) {
1039
1025
return String ();
1040
1026
}
@@ -1105,15 +1091,11 @@ void EditorData::script_class_load_icon_paths() {
1105
1091
}
1106
1092
}
1107
1093
1108
- Ref<Texture2D> EditorData::extension_class_get_icon (const String &p_class) const {
1094
+ String EditorData::extension_class_get_icon_path (const String &p_class) const {
1109
1095
if (GDExtensionManager::get_singleton ()->class_has_icon_path (p_class)) {
1110
- String icon_path = GDExtensionManager::get_singleton ()->class_get_icon_path (p_class);
1111
- Ref<Texture2D> icon = _load_script_icon (icon_path);
1112
- if (icon.is_valid ()) {
1113
- return icon;
1114
- }
1096
+ return GDExtensionManager::get_singleton ()->class_get_icon_path (p_class);
1115
1097
}
1116
- return nullptr ;
1098
+ return String () ;
1117
1099
}
1118
1100
1119
1101
Ref<Texture2D> EditorData::_load_script_icon (const String &p_path) const {
@@ -1126,58 +1108,19 @@ Ref<Texture2D> EditorData::_load_script_icon(const String &p_path) const {
1126
1108
return nullptr ;
1127
1109
}
1128
1110
1129
- Ref<Texture2D> EditorData::get_script_icon (const Ref<Script> &p_script ) {
1111
+ Ref<Texture2D> EditorData::get_script_icon (const String &p_script_path ) {
1130
1112
// Take from the local cache, if available.
1131
- if (_script_icon_cache.has (p_script )) {
1113
+ if (_script_icon_cache.has (p_script_path )) {
1132
1114
// Can be an empty value if we can't resolve any icon for this script.
1133
1115
// An empty value is still cached to avoid unnecessary attempts at resolving it again.
1134
- return _script_icon_cache[p_script ];
1116
+ return _script_icon_cache[p_script_path ];
1135
1117
}
1136
1118
1137
- Ref<Script> base_scr = p_script;
1138
- while (base_scr.is_valid ()) {
1139
- // Check for scripted classes.
1140
- String icon_path;
1141
- StringName class_name = script_class_get_name (base_scr->get_path ());
1142
- if (base_scr->is_built_in () || class_name == StringName ()) {
1143
- icon_path = base_scr->get_class_icon_path ();
1144
- } else {
1145
- icon_path = script_class_get_icon_path (class_name);
1146
- }
1147
-
1148
- Ref<Texture2D> icon = _load_script_icon (icon_path);
1149
- if (icon.is_valid ()) {
1150
- _script_icon_cache[p_script] = icon;
1151
- return icon;
1152
- }
1153
-
1154
- // Check for legacy custom classes defined by plugins.
1155
- // TODO: Should probably be deprecated in 4.x
1156
- const EditorData::CustomType *ctype = get_custom_type_by_path (base_scr->get_path ());
1157
- if (ctype && ctype->icon .is_valid ()) {
1158
- _script_icon_cache[p_script] = ctype->icon ;
1159
- return ctype->icon ;
1160
- }
1161
-
1162
- // Move to the base class.
1163
- base_scr = base_scr->get_base_script ();
1164
- }
1165
-
1166
- // No custom icon was found in the inheritance chain, so check the base
1167
- // class of the script instead.
1168
- String base_type;
1169
- p_script->get_language ()->get_global_class_name (p_script->get_path (), &base_type);
1170
-
1171
- // Check if the base type is an extension-defined type.
1172
- Ref<Texture2D> ext_icon = extension_class_get_icon (base_type);
1173
- if (ext_icon.is_valid ()) {
1174
- _script_icon_cache[p_script] = ext_icon;
1175
- return ext_icon;
1176
- }
1177
-
1178
- // If no icon found, cache it as null.
1179
- _script_icon_cache[p_script] = Ref<Texture>();
1180
- return nullptr ;
1119
+ StringName class_name = script_class_get_name (p_script_path);
1120
+ String icon_path = script_class_get_icon_path (class_name);
1121
+ Ref<Texture2D> icon = _load_script_icon (icon_path);
1122
+ _script_icon_cache[p_script_path] = icon;
1123
+ return icon;
1181
1124
}
1182
1125
1183
1126
void EditorData::clear_script_icon_cache () {
0 commit comments