| 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 | { |
no test coverage detected