| 384 | } |
| 385 | |
| 386 | void DemoKeeper::loadFromFile(const std::string& _filename) |
| 387 | { |
| 388 | MyGUI::xml::Document doc; |
| 389 | |
| 390 | if (!doc.open(_filename)) |
| 391 | return; |
| 392 | |
| 393 | MyGUI::xml::ElementPtr root = doc.getRoot(); |
| 394 | if (root == nullptr || root->getName() != "AnimationGraph") |
| 395 | return; |
| 396 | |
| 397 | MyGUI::xml::ElementEnumerator node = root->getElementEnumerator(); |
| 398 | while (node.next()) |
| 399 | { |
| 400 | if (node->getName() == "Node") |
| 401 | { |
| 402 | BaseAnimationNode* anim_node = createNode(node->findAttribute("type"), node->findAttribute("name")); |
| 403 | anim_node->deserialization(node.current()); |
| 404 | } |
| 405 | else if (node->getName() == "Connections") |
| 406 | { |
| 407 | MyGUI::xml::ElementEnumerator conn = node->getElementEnumerator(); |
| 408 | BaseAnimationNode* anim_node = getNodeByName(node.current()->findAttribute("node")); |
| 409 | if (anim_node) |
| 410 | { |
| 411 | while (conn.next("Connection")) |
| 412 | { |
| 413 | BaseAnimationNode* anim_node2 = getNodeByName(conn.current()->findAttribute("node")); |
| 414 | if (anim_node2) |
| 415 | { |
| 416 | //соединить точки в ноде |
| 417 | std::string_view from_point = conn.current()->findAttribute("from"); |
| 418 | std::string_view to_point = conn.current()->findAttribute("to"); |
| 419 | |
| 420 | wraps::BaseGraphConnection* from_conn = |
| 421 | anim_node->getConnectionByName(from_point, "EventOut"); |
| 422 | if (!from_conn) |
| 423 | from_conn = anim_node->getConnectionByName(from_point, "PositionOut"); |
| 424 | if (!from_conn) |
| 425 | from_conn = anim_node->getConnectionByName(from_point, "WeightOut"); |
| 426 | |
| 427 | wraps::BaseGraphConnection* to_conn = anim_node2->getConnectionByName(to_point, "EventIn"); |
| 428 | if (!to_conn) |
| 429 | to_conn = anim_node2->getConnectionByName(to_point, "PositionIn"); |
| 430 | if (!to_conn) |
| 431 | to_conn = anim_node2->getConnectionByName(to_point, "WeightIn"); |
| 432 | |
| 433 | if (from_conn && to_conn) |
| 434 | { |
| 435 | from_conn->addConnectionPoint(to_conn); |
| 436 | connectPoints(anim_node, anim_node2, from_point, to_point); |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | else if (node->getName() == "EditorData") |
| 443 | { |
no test coverage detected