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

Method saveToProject

Tools/LayoutEditor/EditorWidgets.cpp:171–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 11

getClassTypeNameFunction · 0.85
getLastErrorMethod · 0.80
findAttributeMethod · 0.80
getElementEnumeratorMethod · 0.80
addAttributeMethod · 0.80
openMethod · 0.45
getRootMethod · 0.45
nextMethod · 0.45
clearMethod · 0.45
currentMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected