| 169 | } |
| 170 | |
| 171 | bool EditorWidgets::saveToProject(const MyGUI::UString& _fileName, size_t _index) |
| 172 | { |
| 173 | mCurrentFileName = _fileName; |
| 174 | |
| 175 | MyGUI::xml::Document doc; |
| 176 | if (!doc.open(_fileName)) |
| 177 | { |
| 178 | MYGUI_LOGGING(LogSection, Error, getClassTypeName() << " : " << doc.getLastError()); |
| 179 | return false; |
| 180 | } |
| 181 | |
| 182 | MyGUI::xml::ElementPtr root = doc.getRoot(); |
| 183 | if ((nullptr == root) || (root->getName() != "MyGUI")) |
| 184 | { |
| 185 | MYGUI_LOGGING(LogSection, Error, getClassTypeName() << " : '" << _fileName << "', tag 'MyGUI' not found"); |
| 186 | return false; |
| 187 | } |
| 188 | |
| 189 | if (root->findAttribute("type") == "Resource") |
| 190 | { |
| 191 | // берем детей и крутимся |
| 192 | MyGUI::xml::ElementEnumerator element = root->getElementEnumerator(); |
| 193 | while (element.next("Resource")) |
| 194 | { |
| 195 | if (element->findAttribute("type") == "ResourceLayout") |
| 196 | { |
| 197 | if (_index == 0) |
| 198 | { |
| 199 | mCurrentItemName.assign(element->findAttribute("name")); |
| 200 | |
| 201 | element->clear(); |
| 202 | element->addAttribute("type", "ResourceLayout"); |
| 203 | element->addAttribute("name", mCurrentItemName); |
| 204 | |
| 205 | saveWidgetsToXmlNode(element.current(), true); |
| 206 | |
| 207 | if (!doc.save(_fileName)) |
| 208 | { |
| 209 | MYGUI_LOGGING(LogSection, Error, getClassTypeName() << " : " << doc.getLastError()); |
| 210 | return false; |
| 211 | } |
| 212 | |
| 213 | return true; |
| 214 | } |
| 215 | |
| 216 | _index--; |
| 217 | } |
| 218 | } |
| 219 | return false; |
| 220 | } |
| 221 | |
| 222 | return false; |
| 223 | } |
| 224 | |
| 225 | void EditorWidgets::loadxmlDocument(MyGUI::xml::Document* doc, bool _testMode) |
| 226 | { |
nothing calls this directly
no test coverage detected