MCPcopy Create free account
hub / github.com/MyGUI/mygui / addItemToProject

Method addItemToProject

Tools/LayoutEditor/ProjectControl.cpp:631–673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 10

concatenatePathFunction · 0.85
getLastErrorMethod · 0.80
findAttributeMethod · 0.80
createChildMethod · 0.80
addAttributeMethod · 0.80
getElementEnumeratorMethod · 0.80
openMethod · 0.45
getRootMethod · 0.45
nextMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected