Kaynağa Gözat

Minor cleanup and add script API bindings.
Close #2360

Yao Wei Tjong 姚伟忠 7 yıl önce
ebeveyn
işleme
4faf970643

+ 1 - 0
Source/Urho3D/AngelScript/ResourceAPI.cpp

@@ -435,6 +435,7 @@ static void RegisterJSONFile(asIScriptEngine* engine)
 {
     RegisterResource<JSONFile>(engine, "JSONFile");
     engine->RegisterObjectMethod("JSONFile", "bool FromString(const String&in)", asMETHOD(JSONFile, FromString), asCALL_THISCALL);
+    engine->RegisterObjectMethod("JSONFile", "String ToString(const String&in = String(\"\t\")) const", asMETHOD(JSONFile, ToString), asCALL_THISCALL);
     engine->RegisterObjectMethod("JSONFile", "JSONValue& GetRoot()", asMETHODPR(JSONFile, GetRoot, () const, const JSONValue&), asCALL_THISCALL);
     engine->RegisterObjectMethod("JSONFile", "bool Save(File@+, const String&in) const", asFUNCTION(JSONFileSave), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("JSONFile", "JSONValue& get_root()", asMETHODPR(JSONFile, GetRoot, () const, const JSONValue&), asCALL_THISCALL);

+ 1 - 0
Source/Urho3D/LuaScript/pkgs/Resource/JSONFile.pkg

@@ -6,6 +6,7 @@ class JSONFile : Resource
     ~JSONFile();
 
     bool FromString(const String source);
+    String ToString(const String indendation = "\t") const;
     const JSONValue& GetRoot() const;
 
     tolua_outside bool JSONFileSave @ Save(const String fileName, const String indentation = "\t") const;

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

@@ -238,7 +238,7 @@ bool JSONFile::FromString(const String & source)
     return Load(buffer);
 }
 
-String JSONFile::ToString(const String& indendation)
+String JSONFile::ToString(const String& indendation) const
 {
     rapidjson::Document document;
     ToRapidjsonValue(document, root_, document.GetAllocator());

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

@@ -51,7 +51,7 @@ public:
     /// Deserialize from a string. Return true if successful.
     bool FromString(const String& source);
     /// Save to a string.
-    String ToString(const String& indendation = "\t");
+    String ToString(const String& indendation = "\t") const;
 
     /// Return root value.
     JSONValue& GetRoot() { return root_; }