| 629 | } |
| 630 | |
| 631 | bool ProjectControl::addItemToProject(const MyGUI::UString& _name, size_t& _index) |
| 632 | { |
| 633 | MyGUI::UString fileName = common::concatenatePath(mProjectPath, mProjectName); |
| 634 | |
| 635 | MyGUI::xml::Document doc; |
| 636 | if (!doc.open(fileName)) |
| 637 | { |
| 638 | MYGUI_LOGGING(LogSection, Error, doc.getLastError()); |
| 639 | return false; |
| 640 | } |
| 641 | |
| 642 | MyGUI::xml::ElementPtr root = doc.getRoot(); |
| 643 | if ((nullptr == root) || (root->getName() != "MyGUI")) |
| 644 | { |
| 645 | MYGUI_LOGGING(LogSection, Error, "'" << fileName << "', tag 'MyGUI' not found"); |
| 646 | return false; |
| 647 | } |
| 648 | |
| 649 | if (root->findAttribute("type") == "Resource") |
| 650 | { |
| 651 | MyGUI::xml::ElementPtr node = root->createChild("Resource"); |
| 652 | node->addAttribute("type", "ResourceLayout"); |
| 653 | node->addAttribute("name", _name); |
| 654 | |
| 655 | _index = 0; |
| 656 | |
| 657 | MyGUI::xml::ElementEnumerator element = root->getElementEnumerator(); |
| 658 | while (element.next("Resource")) |
| 659 | { |
| 660 | if (element->findAttribute("type") == "ResourceLayout") |
| 661 | { |
| 662 | _index++; |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | if (_index == 0) |
| 667 | _index = MyGUI::ITEM_NONE; |
| 668 | else |
| 669 | _index--; |
| 670 | } |
| 671 | |
| 672 | return doc.save(fileName); |
| 673 | } |
| 674 | |
| 675 | void ProjectControl::loadLastProject() |
| 676 | { |
nothing calls this directly
no test coverage detected