Fix support for multiple base types in the quick load dialog

This commit is contained in:
Robin Arys 2021-10-22 23:27:46 +02:00
parent 92cab5f622
commit bb7888debb

View file

@ -55,9 +55,12 @@ void EditorQuickOpen::_build_search_cache(EditorFileSystemDirectory *p_efsd) {
_build_search_cache(p_efsd->get_subdir(i)); _build_search_cache(p_efsd->get_subdir(i));
} }
Vector<String> base_types = String(base_type).split(String(","));
for (int i = 0; i < p_efsd->get_file_count(); i++) { for (int i = 0; i < p_efsd->get_file_count(); i++) {
String file_type = p_efsd->get_file_type(i); String file_type = p_efsd->get_file_type(i);
if (ClassDB::is_parent_class(file_type, base_type)) { // Iterate all possible base types.
for (String &parent_type : base_types) {
if (ClassDB::is_parent_class(file_type, parent_type)) {
String file = p_efsd->get_file_path(i); String file = p_efsd->get_file_path(i);
files.push_back(file.substr(6, file.length())); files.push_back(file.substr(6, file.length()));
@ -66,6 +69,10 @@ void EditorQuickOpen::_build_search_cache(EditorFileSystemDirectory *p_efsd) {
if (!icons.has(ext)) { if (!icons.has(ext)) {
icons.insert(ext, get_theme_icon((has_theme_icon(file_type, SNAME("EditorIcons")) ? file_type : String("Object")), SNAME("EditorIcons"))); icons.insert(ext, get_theme_icon((has_theme_icon(file_type, SNAME("EditorIcons")) ? file_type : String("Object")), SNAME("EditorIcons")));
} }
// Stop testing base types as soon as we got a match.
break;
}
} }
} }
} }