| 63 | } |
| 64 | |
| 65 | void ResourceManager::loadFromXmlNode(xml::ElementPtr _node, std::string_view /*unused*/, Version _version) |
| 66 | { |
| 67 | FactoryManager& factory = FactoryManager::getInstance(); |
| 68 | |
| 69 | // берем детей и крутимся, основной цикл |
| 70 | xml::ElementEnumerator root = _node->getElementEnumerator(); |
| 71 | while (root.next(mCategoryName)) |
| 72 | { |
| 73 | // парсим атрибуты |
| 74 | std::string type; |
| 75 | std::string name; |
| 76 | root->findAttribute("type", type); |
| 77 | root->findAttribute("name", name); |
| 78 | |
| 79 | if (name.empty()) |
| 80 | continue; |
| 81 | |
| 82 | IObject* object = factory.createObject(mCategoryName, type); |
| 83 | if (object == nullptr) |
| 84 | { |
| 85 | MYGUI_LOG(Error, "resource type '" << type << "' not found"); |
| 86 | continue; |
| 87 | } |
| 88 | |
| 89 | MapResource::iterator item = mResources.find(name); |
| 90 | if (item != mResources.end()) |
| 91 | { |
| 92 | MYGUI_LOG(Warning, "duplicate resource name '" << name << "'"); |
| 93 | |
| 94 | // ресурсами могут пользоваться |
| 95 | mRemovedResources.push_back((*item).second); |
| 96 | mResources.erase(item); |
| 97 | } |
| 98 | |
| 99 | IResourcePtr resource = object->castType<IResource>(); |
| 100 | resource->deserialization(root.current(), _version); |
| 101 | |
| 102 | mResources[name] = resource; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | void ResourceManager::_loadList(xml::ElementPtr _node, std::string_view /*unused*/, Version _version) |
| 107 | { |