| 311 | } |
| 312 | |
| 313 | void DemoKeeper::saveToFile(const std::string& _filename) |
| 314 | { |
| 315 | MyGUI::xml::Document doc; |
| 316 | |
| 317 | // есть такой файл |
| 318 | if (!doc.open(_filename)) |
| 319 | { |
| 320 | doc.clear(); |
| 321 | } |
| 322 | |
| 323 | doc.createDeclaration(); |
| 324 | MyGUI::xml::ElementPtr root = doc.createRoot("AnimationGraph"); |
| 325 | |
| 326 | // сохраняем сами ноды |
| 327 | wraps::BaseGraphView::EnumeratorNode node = mGraphView->getNodeEnumerator(); |
| 328 | while (node.next()) |
| 329 | { |
| 330 | BaseAnimationNode* anim_node = dynamic_cast<BaseAnimationNode*>(node.current()); |
| 331 | if (anim_node) |
| 332 | { |
| 333 | MyGUI::xml::ElementPtr node_type = root->createChild("Node"); |
| 334 | node_type->addAttribute("type", anim_node->getType()); |
| 335 | node_type->addAttribute("name", anim_node->getName()); |
| 336 | anim_node->serialization(node_type); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | // сохраняем соединения |
| 341 | node = mGraphView->getNodeEnumerator(); |
| 342 | while (node.next()) |
| 343 | { |
| 344 | BaseAnimationNode* anim_node = dynamic_cast<BaseAnimationNode*>(node.current()); |
| 345 | if (anim_node && anim_node->isAnyConnection()) |
| 346 | { |
| 347 | MyGUI::xml::ElementPtr connection = root->createChild("Connections"); |
| 348 | connection->addAttribute("node", anim_node->getName()); |
| 349 | |
| 350 | wraps::EnumeratorConnection node_conn = anim_node->getConnectionEnumerator(); |
| 351 | while (node_conn.next()) |
| 352 | { |
| 353 | wraps::EnumeratorConnection conn = node_conn->getConnectionEnumerator(); |
| 354 | while (conn.next()) |
| 355 | { |
| 356 | BaseAnimationNode* anim_node2 = dynamic_cast<BaseAnimationNode*>(conn->getOwnerNode()); |
| 357 | if (anim_node2) |
| 358 | { |
| 359 | MyGUI::xml::ElementPtr item = connection->createChild("Connection"); |
| 360 | item->addAttribute("node", anim_node2->getName()); |
| 361 | item->addAttribute("from", node_conn->getName()); |
| 362 | item->addAttribute("to", conn->getName()); |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | // сохраняем данные для редактора |
| 370 | MyGUI::xml::ElementPtr data = root->createChild("EditorData"); |
no test coverage detected