Fix support for multiple base types in the quick load dialog

(cherry picked from commit bb7888debb)
This commit is contained in:
Robin Arys 2021-10-22 23:27:46 +02:00 committed by Rémi Verschelde
parent ea844046c3
commit 5bc44b53f6
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -126,17 +126,24 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
String search_text = search_box->get_text(); String search_text = search_box->get_text();
Vector<String> base_types = String(base_type).split(String(","));
for (int i = 0; i < efsd->get_file_count(); i++) { for (int i = 0; i < efsd->get_file_count(); i++) {
String file = efsd->get_file_path(i); String file = efsd->get_file_path(i);
file = file.substr(6, file.length()); file = file.substr(6, file.length());
StringName file_type = efsd->get_file_type(i); StringName file_type = efsd->get_file_type(i);
if (ClassDB::is_parent_class(file_type, base_type) && search_text.is_subsequence_ofi(file)) { // Iterate all possible base types.
Pair<String, Ref<Texture>> pair; for (int j = 0; j < base_types.size(); j++) {
pair.first = file; if (ClassDB::is_parent_class(file_type, base_types[j]) && search_text.is_subsequence_ofi(file)) {
StringName icon_name = search_options->has_icon(file_type, ei) ? file_type : ot; Pair<String, Ref<Texture>> pair;
pair.second = search_options->get_icon(icon_name, ei); pair.first = file;
list.push_back(pair); StringName icon_name = search_options->has_icon(file_type, ei) ? file_type : ot;
pair.second = search_options->get_icon(icon_name, ei);
list.push_back(pair);
// Stop testing base types as soon as we got a match.
break;
}
} }
} }
} }