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

Method load

Tools/LayoutEditor/ProjectControl.cpp:319–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317 }
318
319 bool ProjectControl::load()
320 {
321 mList->removeAllItems();
322 MyGUI::VectorString items;
323
324 MyGUI::UString fileName = common::concatenatePath(mProjectPath, mProjectName);
325
326 MyGUI::xml::Document doc;
327 if (!doc.open(fileName))
328 {
329 MYGUI_LOGGING(LogSection, Error, doc.getLastError());
330 return false;
331 }
332
333 MyGUI::xml::ElementPtr root = doc.getRoot();
334 if ((nullptr == root) || (root->getName() != "MyGUI"))
335 {
336 MYGUI_LOGGING(LogSection, Error, "'" << fileName << "', tag 'MyGUI' not found");
337 return false;
338 }
339
340 if (root->findAttribute("type") == "Resource")
341 {
342 // берем детей и крутимся
343 MyGUI::xml::ElementEnumerator element = root->getElementEnumerator();
344 while (element.next("Resource"))
345 {
346 if (element->findAttribute("type") == "ResourceLayout")
347 items.emplace_back(element->findAttribute("name"));
348 }
349 }
350 else
351 {
352 return false;
353 }
354
355 const MyGUI::UString& colour_error = MyGUI::LanguageManager::getInstance().getTag("ColourError");
356
357 for (MyGUI::VectorString::const_iterator item = items.begin(); item != items.end(); ++item)
358 {
359 bool successItem = checkItem(*item, items);
360 if (successItem)
361 mList->addItem(*item);
362 else
363 mList->addItem(colour_error + (*item));
364 }
365
366 RecentFilesManager::getInstance().addRecentProject(fileName);
367
368 return true;
369 }
370
371 bool ProjectControl::checkItem(std::string_view _name, const MyGUI::VectorString& _items)
372 {

Callers 1

updateProjectSkinsMethod · 0.45

Calls 13

concatenatePathFunction · 0.85
getLastErrorMethod · 0.80
findAttributeMethod · 0.80
getElementEnumeratorMethod · 0.80
getTagMethod · 0.80
addRecentProjectMethod · 0.80
removeAllItemsMethod · 0.45
openMethod · 0.45
getRootMethod · 0.45
nextMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected