| 301 | } |
| 302 | |
| 303 | static void generateTree(Node* node, unsigned int i = 0) |
| 304 | { |
| 305 | std::string str = fmt::format("[{}] {} : {}", i, getNodeName(node), node->getName()); |
| 306 | |
| 307 | if (dynamic_cast<GameObject*>(node) != nullptr) |
| 308 | { |
| 309 | auto gm = dynamic_cast<GameObject*>(node); |
| 310 | str += fmt::format(" id {} uid {}", gm->getID(), gm->_uniqueID); |
| 311 | } |
| 312 | |
| 313 | if (node->getTag() != -1) |
| 314 | str += fmt::format(" ({})", node->getTag()); |
| 315 | const auto childrenCount = node->getChildrenCount(); |
| 316 | if (childrenCount) |
| 317 | str += fmt::format(" {{{}}}", childrenCount); |
| 318 | |
| 319 | auto flags = ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth; |
| 320 | if (selected_node == node) |
| 321 | { |
| 322 | flags |= ImGuiTreeNodeFlags_Selected; |
| 323 | reached_selected_node = true; |
| 324 | } |
| 325 | if (node->getChildrenCount() == 0) |
| 326 | flags |= ImGuiTreeNodeFlags_Leaf; |
| 327 | |
| 328 | const bool is_open = ImGui::TreeNodeEx(node, flags, "%s", str.c_str()); |
| 329 | |
| 330 | if (ImGui::IsItemClicked()) |
| 331 | { |
| 332 | if (node == selected_node && ImGui::GetIO().KeyAlt) |
| 333 | { |
| 334 | selected_node = nullptr; |
| 335 | reached_selected_node = false; |
| 336 | } |
| 337 | else |
| 338 | { |
| 339 | selected_node = node; |
| 340 | reached_selected_node = true; |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | const auto children_count = node->getChildrenCount(); |
| 345 | |
| 346 | if (ImGui::IsItemHovered()) |
| 347 | hovered_node = node; |
| 348 | |
| 349 | if (is_open) |
| 350 | { |
| 351 | auto children = node->getChildren(); |
| 352 | for (unsigned int i = 0; i < children_count; ++i) |
| 353 | { |
| 354 | auto child = children.at(i); |
| 355 | generateTree(static_cast<ax::Node*>(child), i); |
| 356 | } |
| 357 | ImGui::TreePop(); |
| 358 | } |
| 359 | } |
| 360 |
no test coverage detected