| 199 | } |
| 200 | |
| 201 | void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int p_debugger) { |
| 202 | set_hide_root(false); |
| 203 | |
| 204 | updating_scene_tree = true; |
| 205 | const String last_path = get_selected_path(); |
| 206 | const String filter = SceneTreeDock::get_singleton()->get_filter(); |
| 207 | LocalVector<TreeItem *> select_items; |
| 208 | bool hide_filtered_out_parents = EDITOR_GET("docks/scene_tree/hide_filtered_out_parents"); |
| 209 | |
| 210 | bool should_scroll = scrolling_to_item || filter != last_filter; |
| 211 | scrolling_to_item = false; |
| 212 | TreeItem *scroll_item = nullptr; |
| 213 | TypedArray<uint64_t> ids_present; |
| 214 | |
| 215 | // Nodes are in a flatten list, depth first. Use a stack of parents, avoid recursion. |
| 216 | List<ParentItem> parents; |
| 217 | for (const SceneDebuggerTree::RemoteNode &node : p_tree->nodes) { |
| 218 | TreeItem *parent = nullptr; |
| 219 | Pair<TreeItem *, TreeItem *> move_from_to; |
| 220 | if (parents.size()) { // Find last parent. |
| 221 | ParentItem &p = parents.front()->get(); |
| 222 | parent = p.tree_item; |
| 223 | if (!(--p.child_count)) { // If no child left, remove it. |
| 224 | parents.pop_front(); |
| 225 | |
| 226 | if (hide_filtered_out_parents && !filter.is_subsequence_ofn(parent->get_text(0))) { |
| 227 | if (parent == get_root()) { |
| 228 | set_hide_root(true); |
| 229 | } else { |
| 230 | move_from_to.first = parent; |
| 231 | // Find the closest ancestor that matches the filter. |
| 232 | for (const ParentItem p2 : parents) { |
| 233 | move_from_to.second = p2.tree_item; |
| 234 | if (p2.matches_filter || move_from_to.second == get_root()) { |
| 235 | break; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | if (!move_from_to.second) { |
| 240 | move_from_to.second = get_root(); |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | // Add this node. |
| 248 | TreeItem *item = create_item(parent); |
| 249 | item->set_text(0, node.name); |
| 250 | if (node.scene_file_path.is_empty()) { |
| 251 | item->set_tooltip_text(0, node.name + "\n" + TTR("Type:") + " " + node.type_name); |
| 252 | } else { |
| 253 | item->set_tooltip_text(0, node.name + "\n" + TTR("Instance:") + " " + node.scene_file_path + "\n" + TTR("Type:") + " " + node.type_name); |
| 254 | } |
| 255 | Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(node.type_name, ""); |
| 256 | if (icon.is_valid()) { |
| 257 | item->set_icon(0, icon); |
| 258 | } |
no test coverage detected