Browse Source

Added file modification remark with credit to prettywriter.h. Added indentation parameter to several SaveXML() functions including Node & Scene. Code convention edit to use String& throughout. Removed outdated remark of being only able to save to File.

Lasse Öörni 11 years ago
parent
commit
5e133eb639

+ 2 - 0
Source/ThirdParty/rapidjson/include/rapidjson/prettywriter.h

@@ -1,6 +1,8 @@
 #ifndef RAPIDJSON_PRETTYWRITER_H_
 #define RAPIDJSON_PRETTYWRITER_H_
 
+// Modified by Ali Kamarainen for Urho3D
+
 #include "writer.h"
 
 namespace rapidjson {

+ 3 - 3
Source/Urho3D/LuaScript/pkgs/Scene/Node.pkg

@@ -22,7 +22,7 @@ class Node : public Animatable
     Node();
     virtual ~Node();
 
-    tolua_outside bool NodeSaveXML @ SaveXML(File* dest) const;
+    tolua_outside bool NodeSaveXML @ SaveXML(File* dest, const String indentation = "\t") const;
     void SetName(const String name);
     
     void SetPosition(const Vector3& position);
@@ -231,9 +231,9 @@ static int tolua_SceneLuaAPI_Node_new00_local(lua_State* tolua_S)
     return ToluaNewObjectGC<Node>(tolua_S);
 }
 
-static bool NodeSaveXML(const Node* node, File* file)
+static bool NodeSaveXML(const Node* node, File* file, const String& indentation)
 {
-    return file ? node->SaveXML(*file) : false;
+    return file ? node->SaveXML(*file, indentation) : false;
 }
 
 #define TOLUA_DISABLE_tolua_SceneLuaAPI_Node_CreateScriptObject00

+ 6 - 6
Source/Urho3D/LuaScript/pkgs/Scene/Scene.pkg

@@ -22,9 +22,9 @@ class Scene : public Node
     tolua_outside bool SceneLoad @ Load(const String fileName);
     tolua_outside bool SceneSave @ Save(const String fileName) const;
     tolua_outside bool SceneLoadXML @ LoadXML(File* source);
-    tolua_outside bool SceneSaveXML @ SaveXML(File* dest) const;
+    tolua_outside bool SceneSaveXML @ SaveXML(File* dest, const String indentation = "\t") const;
     tolua_outside bool SceneLoadXML @ LoadXML(const String fileName);
-    tolua_outside bool SceneSaveXML @ SaveXML(const String fileName) const;
+    tolua_outside bool SceneSaveXML @ SaveXML(const String fileName, const String indentation = "\t") const;
     tolua_outside Node* SceneInstantiate @ Instantiate(File* source, const Vector3& position, const Quaternion& rotation, CreateMode mode = REPLICATED);
     tolua_outside Node* SceneInstantiate @ Instantiate(const String fileName, const Vector3& position, const Quaternion& rotation, CreateMode mode = REPLICATED);
     tolua_outside Node* SceneInstantiateXML @ InstantiateXML(File* source, const Vector3& position, const Quaternion& rotation, CreateMode mode = REPLICATED);
@@ -133,9 +133,9 @@ static bool SceneLoadXML(Scene* scene, File* file)
     return file ? scene->LoadXML(*file) : false;
 }
 
-static bool SceneSaveXML(const Scene* scene, File* file)
+static bool SceneSaveXML(const Scene* scene, File* file, const String& indentation)
 {
-    return file ? scene->SaveXML(*file) : false;
+    return file ? scene->SaveXML(*file, indentation) : false;
 }
 
 static bool SceneLoadXML(Scene* scene, const String& fileName)
@@ -144,12 +144,12 @@ static bool SceneLoadXML(Scene* scene, const String& fileName)
     return file.IsOpen() && scene->LoadXML(file);
 }
 
-static bool SceneSaveXML(const Scene* scene, const String& fileName)
+static bool SceneSaveXML(const Scene* scene, const String& fileName, const String& indentation)
 {
     File file(scene->GetContext(), fileName, FILE_WRITE);
     if (!file.IsOpen())
         return false;
-    return scene->SaveXML(file);
+    return scene->SaveXML(file, indentation);
 }
 
 static bool SceneLoadAsync(Scene* scene, const String& fileName, LoadMode mode)

+ 4 - 4
Source/Urho3D/LuaScript/pkgs/UI/UIElement.pkg

@@ -64,9 +64,9 @@ class UIElement : public Animatable
     virtual const IntVector2& GetScreenPosition() const;
 
     bool LoadXML(Deserializer& source);
-    bool SaveXML(Serializer& dest) const;
+    bool SaveXML(Serializer& dest, const String indentation = "\t") const;
     tolua_outside bool UIElementLoadXML @ LoadXML(const String fileName);
-    tolua_outside bool UIElementSaveXML @ SaveXML(const String fileName) const;
+    tolua_outside bool UIElementSaveXML @ SaveXML(const String fileName, const String indentation = "\t") const;
 
     bool FilterAttributes(XMLElement& dest) const;
 
@@ -303,7 +303,7 @@ static bool UIElementLoadXML(UIElement* element, const String& fileName)
     return element->LoadXML(file);
 }
 
-static bool UIElementSaveXML(const UIElement* element, const String& fileName)
+static bool UIElementSaveXML(const UIElement* element, const String& fileName, const String& indentation)
 {
     if (!element)
         return false;
@@ -312,7 +312,7 @@ static bool UIElementSaveXML(const UIElement* element, const String& fileName)
     if (!file.Open(fileName, FILE_WRITE))
         return false;
 
-    return element->SaveXML(file);
+    return element->SaveXML(file, indentation);
 }
 
 #define GetStyle GetAppliedStyle

+ 1 - 1
Source/Urho3D/Resource/JSONFile.cpp

@@ -86,7 +86,7 @@ bool JSONFile::Save(Serializer& dest) const
     return Save(dest, "\t");
 }
 
-bool JSONFile::Save(Serializer& dest, const String &indendation) const
+bool JSONFile::Save(Serializer& dest, const String& indendation) const
 {
     StringBuffer buffer;
     PrettyWriter<StringBuffer> writer(buffer, &(document_->GetAllocator()));

+ 3 - 3
Source/Urho3D/Resource/JSONFile.h

@@ -49,10 +49,10 @@ public:
 
     /// Load resource from stream. May be called from a worker thread. Return true if successful.
     virtual bool BeginLoad(Deserializer& source);
-    /// Save resource with default indentation (one tab). Return true if successful. Only supports saving to a File.
+    /// Save resource with default indentation (one tab). Return true if successful.
     virtual bool Save(Serializer& dest) const;
-    /// Save resource with user-defined indentation, only the first character (if any) of the string is used and the length of the string defines the character count. Return true if successful. Only supports saving to a File.
-    bool Save(Serializer& dest, const String &indendation) const;
+    /// Save resource with user-defined indentation, only the first character (if any) of the string is used and the length of the string defines the character count. Return true if successful.
+    bool Save(Serializer& dest, const String& indendation) const;
 
     /// Clear the document and create a root value, default is object type.
     JSONValue CreateRoot(JSONValueType valueType = JSON_OBJECT);

+ 2 - 2
Source/Urho3D/Resource/XMLFile.cpp

@@ -136,7 +136,7 @@ bool XMLFile::Save(Serializer& dest) const
     return Save(dest, "\t");
 }
 
-bool XMLFile::Save(Serializer& dest, const String &indendation) const
+bool XMLFile::Save(Serializer& dest, const String& indendation) const
 {
     XMLWriter writer(dest);
     document_->save(writer, indendation.CString());
@@ -171,7 +171,7 @@ XMLElement XMLFile::GetRoot(const String& name)
         return XMLElement(this, root.internal_object());
 }
 
-String XMLFile::ToString(const String &indendation) const
+String XMLFile::ToString(const String& indendation) const
 {
     VectorBuffer dest;
     XMLWriter writer(dest);

+ 4 - 4
Source/Urho3D/Resource/XMLFile.h

@@ -50,10 +50,10 @@ public:
     
     /// Load resource from stream. May be called from a worker thread. Return true if successful.
     virtual bool BeginLoad(Deserializer& source);
-    /// Save resource with default indentation (one tab). Return true if successful. Only supports saving to a File.
+    /// Save resource with default indentation (one tab). Return true if successful.
     virtual bool Save(Serializer& dest) const;
-    /// Save resource with user-defined indentation. Return true if successful. Only supports saving to a File.
-    bool Save(Serializer& dest, const String &indendation) const;
+    /// Save resource with user-defined indentation. Return true if successful.
+    bool Save(Serializer& dest, const String& indendation) const;
 
     /// Deserialize from a string. Return true if successful.
     bool FromString(const String& source);
@@ -65,7 +65,7 @@ public:
     /// Return the pugixml document.
     pugi::xml_document* GetDocument() const { return document_; }
     /// Serialize the XML content to a string.
-    String ToString(const String &indendation = "\t") const;
+    String ToString(const String& indendation = "\t") const;
 
     /// Patch the XMLFile with another XMLFile. Based on RFC 5261.
     void Patch(XMLFile* patchFile);

+ 2 - 2
Source/Urho3D/Scene/Node.cpp

@@ -223,14 +223,14 @@ void Node::AddReplicationState(NodeReplicationState* state)
     networkState_->replicationStates_.Push(state);
 }
 
-bool Node::SaveXML(Serializer& dest) const
+bool Node::SaveXML(Serializer& dest, const String& indentation) const
 {
     SharedPtr<XMLFile> xml(new XMLFile(context_));
     XMLElement rootElem = xml->CreateRoot("node");
     if (!SaveXML(rootElem))
         return false;
 
-    return xml->Save(dest);
+    return xml->Save(dest, indentation);
 }
 
 void Node::SetName(const String& name)

+ 1 - 1
Source/Urho3D/Scene/Node.h

@@ -85,7 +85,7 @@ public:
     virtual void AddReplicationState(NodeReplicationState* state);
 
     /// Save to an XML file. Return true if successful.
-    bool SaveXML(Serializer& dest) const;
+    bool SaveXML(Serializer& dest, const String& indentation = "\t") const;
     /// Set name of the scene node. Names are not required to be unique.
     void SetName(const String& name);
     /// Set position in parent space. If the scene node is on the root level (is child of the scene itself), this is same as world space.

+ 2 - 2
Source/Urho3D/Scene/Scene.cpp

@@ -216,7 +216,7 @@ bool Scene::LoadXML(Deserializer& source)
         return false;
 }
 
-bool Scene::SaveXML(Serializer& dest) const
+bool Scene::SaveXML(Serializer& dest, const String& indentation) const
 {
     PROFILE(SaveSceneXML);
 
@@ -229,7 +229,7 @@ bool Scene::SaveXML(Serializer& dest) const
     if (ptr)
         LOGINFO("Saving scene to " + ptr->GetName());
 
-    if (xml->Save(dest))
+    if (xml->Save(dest, indentation))
     {
         FinishSaving(&dest);
         return true;

+ 1 - 1
Source/Urho3D/Scene/Scene.h

@@ -103,7 +103,7 @@ public:
     /// Load from an XML file. Return true if successful.
     bool LoadXML(Deserializer& source);
     /// Save to an XML file. Return true if successful.
-    bool SaveXML(Serializer& dest) const;
+    bool SaveXML(Serializer& dest, const String& indentation = "\t") const;
     /// Load from a binary file asynchronously. Return true if started successfully. The LOAD_RESOURCES_ONLY mode can also be used to preload resources from object prefab files.
     bool LoadAsync(File* file, LoadMode mode = LOAD_SCENE_AND_RESOURCES);
     /// Load from an XML file asynchronously. Return true if started successfully. The LOAD_RESOURCES_ONLY mode can also be used to preload resources from object prefab files.

+ 4 - 4
Source/Urho3D/Script/APITemplates.h

@@ -897,12 +897,12 @@ static bool UIElementLoadChildXML(XMLFile* file, XMLFile* styleFile, UIElement*
         return false;
 }
 
-static bool UIElementSaveXML(File* file, UIElement* ptr)
+static bool UIElementSaveXML(File* file, const String& indentation, UIElement* ptr)
 {
     return file && ptr->SaveXML(*file);
 }
 
-static bool UIElementSaveXMLVectorBuffer(VectorBuffer& buffer, UIElement* ptr)
+static bool UIElementSaveXMLVectorBuffer(VectorBuffer& buffer, const String& indentation, UIElement* ptr)
 {
     return ptr->SaveXML(buffer);
 }
@@ -979,8 +979,8 @@ template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* c
     engine->RegisterObjectMethod(className, "bool LoadXML(XMLFile@+, XMLFile@+)", asFUNCTIONPR(UIElementLoadXML, (XMLFile*, XMLFile*, UIElement*), bool), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "bool LoadChildXML(const XMLElement&in, XMLFile@+ arg1 = null, bool arg2 = false)", asMETHOD(T, LoadChildXML), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool LoadChildXML(XMLFile@+, XMLFile@+ arg1 = null)", asFUNCTION(UIElementLoadChildXML), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod(className, "bool SaveXML(File@+)", asFUNCTION(UIElementSaveXML), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod(className, "bool SaveXML(VectorBuffer&)", asFUNCTION(UIElementSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod(className, "bool SaveXML(File@+, const String&in indentation = \"\t\")", asFUNCTION(UIElementSaveXML), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod(className, "bool SaveXML(VectorBuffer&, const String&in indentation = \"\t\")", asFUNCTION(UIElementSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "bool SetStyle(const XMLElement&in)", asMETHODPR(T, SetStyle, (const XMLElement&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool SetStyle(const String&in, XMLFile@+ arg1 = null)", asMETHODPR(T, SetStyle, (const String&, XMLFile*), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool SetStyleAuto(XMLFile@+ arg0 = null)", asMETHOD(T, SetStyleAuto), asCALL_THISCALL);

+ 2 - 2
Source/Urho3D/Script/ResourceAPI.cpp

@@ -331,7 +331,7 @@ static void RegisterJSONValue(asIScriptEngine* engine)
     engine->RegisterObjectMethod("JSONValue", "Variant GetVariantValue(uint, VariantType type) const", asMETHODPR(JSONValue, GetVariantValue, (unsigned, VariantType) const, Variant), asCALL_THISCALL);
 }
 
-static bool JSONFileSave(File* file, const String &indendation, JSONFile* ptr)
+static bool JSONFileSave(File* file, const String& indendation, JSONFile* ptr)
 {
     return file && ptr->Save(*file, indendation);
 }
@@ -522,7 +522,7 @@ static XMLElement XMLFileGetRootDefault(XMLFile* ptr)
     return ptr->GetRoot();
 }
 
-static bool XMLFileSave(File* file, const String &indendation, XMLFile* ptr)
+static bool XMLFileSave(File* file, const String& indendation, XMLFile* ptr)
 {
     return file && ptr->Save(*file, indendation);
 }

+ 12 - 12
Source/Urho3D/Script/SceneAPI.cpp

@@ -95,14 +95,14 @@ static void RegisterAnimatable(asIScriptEngine* engine)
     RegisterAnimatable<Animatable>(engine, "Animatable");
 }
 
-static bool NodeSaveXML(File* file, Node* ptr)
+static bool NodeSaveXML(File* file, const String& indentation, Node* ptr)
 {
-    return file && ptr->SaveXML(*file);
+    return file && ptr->SaveXML(*file, indentation);
 }
 
-static bool NodeSaveXMLVectorBuffer(VectorBuffer& buffer, Node* ptr)
+static bool NodeSaveXMLVectorBuffer(VectorBuffer& buffer, const String& indentation, Node* ptr)
 {
-    return ptr->SaveXML(buffer);
+    return ptr->SaveXML(buffer, indentation);
 }
 
 static void RegisterNode(asIScriptEngine* engine)
@@ -126,8 +126,8 @@ static void RegisterNode(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Node", "void set_enabled(bool)", asMETHODPR(Node, SetEnabled, (bool), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("Node", "bool get_enabled() const", asMETHOD(Node, IsEnabled), asCALL_THISCALL);
     engine->RegisterObjectMethod("Node", "bool get_enabledSelf() const", asMETHOD(Node, IsEnabledSelf), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Node", "bool SaveXML(File@+)", asFUNCTION(NodeSaveXML), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("Node", "bool SaveXML(VectorBuffer&)", asFUNCTION(NodeSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Node", "bool SaveXML(File@+, const String&in indentation = \"\t\")", asFUNCTION(NodeSaveXML), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Node", "bool SaveXML(VectorBuffer&, const String&in indentation = \"\t\")", asFUNCTION(NodeSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Node", "Node@+ Clone(CreateMode mode = REPLICATED)", asMETHOD(Node, Clone), asCALL_THISCALL);
     RegisterObjectConstructor<Node>(engine, "Node");
     RegisterNamedObjectConstructor<Node>(engine, "Node");
@@ -152,14 +152,14 @@ static bool SceneLoadXMLVectorBuffer(VectorBuffer& buffer, Scene* ptr)
     return ptr->LoadXML(buffer);
 }
 
-static bool SceneSaveXML(File* file, Scene* ptr)
+static bool SceneSaveXML(File* file, const String& indentation, Scene* ptr)
 {
-    return file && ptr->SaveXML(*file);
+    return file && ptr->SaveXML(*file, indentation);
 }
 
-static bool SceneSaveXMLVectorBuffer(VectorBuffer& buffer, Scene* ptr)
+static bool SceneSaveXMLVectorBuffer(VectorBuffer& buffer, const String& indentation, Scene* ptr)
 {
-    return ptr->SaveXML(buffer);
+    return ptr->SaveXML(buffer, indentation);
 }
 
 static Node* SceneInstantiate(File* file, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr)
@@ -275,8 +275,8 @@ static void RegisterScene(asIScriptEngine* engine)
     RegisterNamedObjectConstructor<Scene>(engine, "Scene");
     engine->RegisterObjectMethod("Scene", "bool LoadXML(File@+)", asFUNCTION(SceneLoadXML), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Scene", "bool LoadXML(VectorBuffer&)", asFUNCTION(SceneLoadXMLVectorBuffer), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("Scene", "bool SaveXML(File@+)", asFUNCTION(SceneSaveXML), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("Scene", "bool SaveXML(VectorBuffer&)", asFUNCTION(SceneSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Scene", "bool SaveXML(File@+, const String&in indentation = \"\t\")", asFUNCTION(SceneSaveXML), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Scene", "bool SaveXML(VectorBuffer&, const String&in indentation = \"\t\")", asFUNCTION(SceneSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Scene", "bool LoadAsync(File@+, LoadMode mode = LOAD_SCENE_AND_RESOURCES)", asMETHOD(Scene, LoadAsync), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "bool LoadAsyncXML(File@+, LoadMode mode = LOAD_SCENE_AND_RESOURCES)", asMETHOD(Scene, LoadAsyncXML), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "void StopAsyncLoading()", asMETHOD(Scene, StopAsyncLoading), asCALL_THISCALL);

+ 7 - 7
Source/Urho3D/Script/UIAPI.cpp

@@ -45,26 +45,26 @@
 namespace Urho3D
 {
 
-static bool FontSaveXMLVectorBuffer(VectorBuffer& buffer, int pointSize, bool usedGlyphs, Font* ptr)
+static bool FontSaveXMLVectorBuffer(VectorBuffer& buffer, int pointSize, bool usedGlyphs, const String& indentation, Font* ptr)
 {
-    return ptr->SaveXML(buffer, pointSize, usedGlyphs);
+    return ptr->SaveXML(buffer, pointSize, usedGlyphs, indentation);
 }
 
-static bool FontSaveXML(const String& fileName, int pointSize, bool usedGlyphs, Font* ptr)
+static bool FontSaveXML(const String& fileName, int pointSize, bool usedGlyphs, const String& indentation, Font* ptr)
 {
     if (fileName.Empty())
         return false;
 
     File file(ptr->GetContext(), fileName, FILE_WRITE);
-    return ptr->SaveXML(file, pointSize, usedGlyphs);
+    return ptr->SaveXML(file, pointSize, usedGlyphs, indentation);
 }
 
 static void RegisterFont(asIScriptEngine* engine)
 {
     RegisterResource<Font>(engine, "Font");
-    engine->RegisterObjectMethod("Font", "bool SaveXML(File@+, int, bool arg2 = false)", asMETHOD(Font, SaveXML), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Font", "bool SaveXML(VectorBuffer&, int, bool arg2 = false)", asFUNCTION(FontSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("Font", "bool SaveXML(const String&in, int, bool arg2 = false)", asFUNCTION(FontSaveXML), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Font", "bool SaveXML(File@+, int, bool usedGlyphs = false, const String&in indentation = \"\t\")", asMETHOD(Font, SaveXML), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Font", "bool SaveXML(VectorBuffer&, int, bool usedGlyphs = false, const String&in indentation = \"\t\")", asFUNCTION(FontSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Font", "bool SaveXML(const String&in, int, bool usedGlyphs = false, const String&in indentation = \"\t\")", asFUNCTION(FontSaveXML), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Font", "IntVector2 GetTotalGlyphOffset(int) const", asMETHOD(Font, GetTotalGlyphOffset), asCALL_THISCALL);
     engine->RegisterObjectMethod("Font", "void set_absoluteGlyphOffset(const IntVector2&)", asMETHOD(Font, SetAbsoluteGlyphOffset), asCALL_THISCALL);
     engine->RegisterObjectMethod("Font", "const IntVector2& get_absoluteGlyphOffset() const", asMETHOD(Font, GetAbsoluteGlyphOffset), asCALL_THISCALL);

+ 2 - 2
Source/Urho3D/UI/Font.cpp

@@ -100,7 +100,7 @@ bool Font::BeginLoad(Deserializer& source)
     return true;
 }
 
-bool Font::SaveXML(Serializer& dest, int pointSize, bool usedGlyphs)
+bool Font::SaveXML(Serializer& dest, int pointSize, bool usedGlyphs, const String& indentation)
 {
     FontFace* fontFace = GetFace(pointSize);
     if (!fontFace)
@@ -112,7 +112,7 @@ bool Font::SaveXML(Serializer& dest, int pointSize, bool usedGlyphs)
     if (!packedFontFace->Load(fontFace, usedGlyphs))
         return false;
 
-    return packedFontFace->Save(dest, pointSize);
+    return packedFontFace->Save(dest, pointSize, indentation);
 }
 
 void Font::SetAbsoluteGlyphOffset(const IntVector2& offset)

+ 1 - 1
Source/Urho3D/UI/Font.h

@@ -58,7 +58,7 @@ public:
     /// Load resource from stream. May be called from a worker thread. Return true if successful.
     virtual bool BeginLoad(Deserializer& source);
     /// Save resource as a new bitmap font type in XML format. Return true if successful.
-    bool SaveXML(Serializer& dest, int pointSize, bool usedGlyphs = false);
+    bool SaveXML(Serializer& dest, int pointSize, bool usedGlyphs = false, const String& indentation = "\t");
     /// Set absolute (in pixels) position adjustment for glyphs.
     void SetAbsoluteGlyphOffset(const IntVector2& offset);
     /// Set point size scaled position adjustment for glyphs.

+ 2 - 2
Source/Urho3D/UI/FontFaceBitmap.cpp

@@ -261,7 +261,7 @@ bool FontFaceBitmap::Load(FontFace* fontFace, bool usedGlyphs)
     return true;
 }
 
-bool FontFaceBitmap::Save(Serializer& dest, int pointSize)
+bool FontFaceBitmap::Save(Serializer& dest, int pointSize, const String& indentation)
 {
     Context* context = font_->GetContext();
 
@@ -337,7 +337,7 @@ bool FontFaceBitmap::Save(Serializer& dest, int pointSize)
         }
     }
 
-    return xml->Save(dest);
+    return xml->Save(dest, indentation);
 }
 
 unsigned FontFaceBitmap::ConvertFormatToNumComponents(unsigned format)

+ 1 - 1
Source/Urho3D/UI/FontFaceBitmap.h

@@ -44,7 +44,7 @@ public:
     /// Load from existed font face, pack used glyphs into smallest texture size and smallest number of texture.
     bool Load(FontFace* fontFace, bool usedGlyphs);
     /// Save as a new bitmap font type in XML format. Return true if successful.
-    bool Save(Serializer& dest, int pontSize);
+    bool Save(Serializer& dest, int pointSize, const String& indentation = "\t");
 
 private:
     /// Convert graphics format to number of components.

+ 2 - 2
Source/Urho3D/UI/UIElement.cpp

@@ -537,11 +537,11 @@ bool UIElement::LoadXML(Deserializer& source)
     return xml->Load(source) && LoadXML(xml->GetRoot());
 }
 
-bool UIElement::SaveXML(Serializer& dest) const
+bool UIElement::SaveXML(Serializer& dest, const String& indentation) const
 {
     SharedPtr<XMLFile> xml(new XMLFile(context_));
     XMLElement rootElem = xml->CreateRoot("element");
-    return SaveXML(rootElem) && xml->Save(dest);
+    return SaveXML(rootElem) && xml->Save(dest, indentation);
 }
 
 bool UIElement::FilterAttributes(XMLElement& dest) const

+ 1 - 1
Source/Urho3D/UI/UIElement.h

@@ -183,7 +183,7 @@ public:
     /// Load from an XML file. Return true if successful.
     bool LoadXML(Deserializer& source);
     /// Save to an XML file. Return true if successful.
-    bool SaveXML(Serializer& dest) const;
+    bool SaveXML(Serializer& dest, const String& indentation = "\t") const;
     /// Filter attributes in serialization process.
     bool FilterAttributes(XMLElement& dest) const;