Include inherited classes in Filter Nodes' "type:" filter & fix "group:"

Also fixes not all private, internal groups being skipped in the "group:" filter.
This commit is contained in:
Micky 2022-09-16 23:01:33 +02:00
parent 61021c08f8
commit 44738e1e15

View file

@ -673,27 +673,37 @@ bool SceneTreeEditor::_item_matches_all_terms(TreeItem *p_item, PackedStringArra
if (parameter == "type" || parameter == "t") { if (parameter == "type" || parameter == "t") {
// Filter by Type. // Filter by Type.
String node_type = get_node(p_item->get_metadata(0))->get_class().to_lower(); String type = get_node(p_item->get_metadata(0))->get_class();
bool term_in_inherited_class = false;
// Every Node is is a Node, duh!
while (type != "Node") {
if (type.to_lower().contains(argument)) {
term_in_inherited_class = true;
break;
}
if (!node_type.contains(argument)) { type = ClassDB::get_parent_class(type);
}
if (!term_in_inherited_class) {
return false; return false;
} }
} else if (parameter == "group" || parameter == "g") { } else if (parameter == "group" || parameter == "g") {
// Filter by Group. // Filter by Group.
Node *node = get_node(p_item->get_metadata(0)); Node *node = get_node(p_item->get_metadata(0));
List<Node::GroupInfo> group_info_list; if (argument.is_empty()) {
node->get_groups(&group_info_list); // When argument is empty, match all Nodes belonging to any exposed group.
if (group_info_list.is_empty()) { if (node->get_persistent_group_count() == 0) {
return false; return false;
} }
// When argument is empty, match all Nodes belonging to any group. } else {
if (!argument.is_empty()) { List<Node::GroupInfo> group_info_list;
node->get_groups(&group_info_list);
bool term_in_groups = false; bool term_in_groups = false;
for (int j = 0; j < group_info_list.size(); j++) { for (int j = 0; j < group_info_list.size(); j++) {
// Ignore private groups. if (!group_info_list[j].persistent) {
if (String(group_info_list[j].name).begins_with("__")) { continue; // Ignore internal groups.
continue;
} }
if (String(group_info_list[j].name).to_lower().contains(argument)) { if (String(group_info_list[j].name).to_lower().contains(argument)) {
term_in_groups = true; term_in_groups = true;