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

Method convertProjectName

Tools/LayoutEditor/EditorState.cpp:532–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530 }
531
532 MyGUI::UString EditorState::convertProjectName(const MyGUI::UString& _fileName)
533 {
534 size_t pos = mFileName.find_last_of("\\/");
535 MyGUI::UString shortName = pos == MyGUI::UString::npos ? mFileName : mFileName.substr(pos + 1);
536 addUserTag("ResourceName", shortName);
537
538 size_t index = _fileName.find("|");
539 if (index == MyGUI::UString::npos)
540 return _fileName;
541
542 MyGUI::UString fileName = _fileName.substr(0, index);
543 MyGUI::UString itemIndexName = _fileName.substr(index + 1);
544 size_t itemIndex = MyGUI::utility::parseValue<size_t>(itemIndexName);
545
546 MyGUI::xml::Document doc;
547 if (!doc.open(fileName))
548 return _fileName;
549
550 MyGUI::xml::ElementPtr root = doc.getRoot();
551 if ((nullptr == root) || (root->getName() != "MyGUI"))
552 return _fileName;
553
554 if (root->findAttribute("type") == "Resource")
555 {
556 // берем детей и крутимся
557 MyGUI::xml::ElementEnumerator element = root->getElementEnumerator();
558 while (element.next("Resource"))
559 {
560 if (element->findAttribute("type") == "ResourceLayout")
561 {
562 if (itemIndex == 0)
563 {
564 // поменять на теги
565 std::string_view resourceName = element->findAttribute("name");
566 addUserTag("ResourceName", MyGUI::UString(resourceName));
567 return MyGUI::utility::toString(fileName, " [", resourceName, "]");
568 }
569
570 itemIndex--;
571 }
572 }
573 }
574
575 return _fileName;
576 }
577
578 bool EditorState::isProjectFile(const MyGUI::UString& _fileName)
579 {

Callers

nothing calls this directly

Calls 11

addUserTagFunction · 0.85
UStringFunction · 0.85
toStringFunction · 0.85
find_last_ofMethod · 0.80
substrMethod · 0.80
findAttributeMethod · 0.80
getElementEnumeratorMethod · 0.80
findMethod · 0.45
openMethod · 0.45
getRootMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected