Fix material JSON save in editor. Fix AngelScript API bindings where XMLElement or JSONValue is passed as reference and should be modified (needs to be unsafe inout reference.)
This commit is contained in:
parent
5165aa91fb
commit
42ba4f9824
@ -835,7 +835,9 @@ static void RegisterMaterial(asIScriptEngine* engine)
|
||||
|
||||
RegisterResource<Material>(engine, "Material");
|
||||
engine->RegisterObjectMethod("Material", "bool Load(const XMLElement&in)", asMETHODPR(Material, Load, (const XMLElement&), bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Material", "bool Save(XMLElement&in) const", asMETHODPR(Material, Save, (XMLElement&) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Material", "bool Load(const JSONValue&in)", asMETHODPR(Material, Load, (const JSONValue&), bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Material", "bool Save(XMLElement&) const", asMETHODPR(Material, Save, (XMLElement&) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Material", "bool Save(JSONValue&) const", asMETHODPR(Material, Save, (JSONValue&) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Material", "void SetTechnique(uint, Technique@+, uint qualityLevel = 0, float lodDistance = 0.0)", asMETHOD(Material, SetTechnique), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Material", "void SetUVTransform(const Vector2&in, float, const Vector2&in)", asMETHODPR(Material, SetUVTransform, (const Vector2&, float, const Vector2&), void), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Material", "void SetUVTransform(const Vector2&in, float, float)", asMETHODPR(Material, SetUVTransform, (const Vector2&, float, float), void), asCALL_THISCALL);
|
||||
@ -1368,7 +1370,7 @@ static void RegisterParticleEffect(asIScriptEngine* engine)
|
||||
|
||||
RegisterResource<ParticleEffect>(engine, "ParticleEffect");
|
||||
engine->RegisterObjectMethod("ParticleEffect", "bool Load(const XMLElement&in)", asMETHODPR(ParticleEffect, Load, (const XMLElement&), bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("ParticleEffect", "bool Save(XMLElement&in) const", asMETHODPR(ParticleEffect, Save, (XMLElement&) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("ParticleEffect", "bool Save(XMLElement&) const", asMETHODPR(ParticleEffect, Save, (XMLElement&) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("ParticleEffect", "void set_material(Material@+)", asMETHOD(ParticleEffect, SetMaterial), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("ParticleEffect", "Material@+ get_material() const", asMETHOD(ParticleEffect, GetMaterial), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("ParticleEffect", "void set_numParticles(uint) const", asMETHOD(ParticleEffect, SetNumParticles), asCALL_THISCALL);
|
||||
|
@ -360,8 +360,9 @@ static bool JSONFileSave(File* file, const String& indendation, JSONFile* ptr)
|
||||
static void RegisterJSONFile(asIScriptEngine* engine)
|
||||
{
|
||||
RegisterResource<JSONFile>(engine, "JSONFile");
|
||||
engine->RegisterObjectMethod("JSONFile", "const JSONValue& GetRoot() const", asMETHODPR(JSONFile, GetRoot, () const, const JSONValue&), 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);
|
||||
}
|
||||
|
||||
static void ConstructXMLElement(XMLElement* ptr)
|
||||
|
@ -701,12 +701,6 @@ bool Material::Save(XMLElement& dest) const
|
||||
|
||||
bool Material::Save(JSONValue& dest) const
|
||||
{
|
||||
if (dest.IsNull())
|
||||
{
|
||||
URHO3D_LOGERROR("Can not save material to null JSON value");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write techniques
|
||||
JSONArray techniquesArray;
|
||||
techniquesArray.Reserve(techniques_.Size());
|
||||
|
@ -436,7 +436,15 @@ void SaveMaterial()
|
||||
|
||||
MakeBackup(fullName);
|
||||
File saveFile(fullName, FILE_WRITE);
|
||||
bool success = editMaterial.Save(saveFile);
|
||||
bool success;
|
||||
if (GetExtension(fullName) == ".json")
|
||||
{
|
||||
JSONFile json;
|
||||
editMaterial.Save(json.root);
|
||||
success = json.Save(saveFile);
|
||||
}
|
||||
else
|
||||
success = editMaterial.Save(saveFile);
|
||||
RemoveBackup(success, fullName);
|
||||
}
|
||||
|
||||
@ -480,7 +488,17 @@ void SaveMaterialAsDone(StringHash eventType, VariantMap& eventData)
|
||||
|
||||
MakeBackup(fullName);
|
||||
File saveFile(fullName, FILE_WRITE);
|
||||
if (editMaterial.Save(saveFile))
|
||||
bool success;
|
||||
if (GetExtension(fullName) == ".json")
|
||||
{
|
||||
JSONFile json;
|
||||
editMaterial.Save(json.root);
|
||||
success = json.Save(saveFile);
|
||||
}
|
||||
else
|
||||
success = editMaterial.Save(saveFile);
|
||||
|
||||
if (success)
|
||||
{
|
||||
saveFile.Close();
|
||||
RemoveBackup(true, fullName);
|
||||
|
@ -500,7 +500,7 @@ void StopSceneUpdate()
|
||||
{
|
||||
suppressSceneChanges = true;
|
||||
editorScene.Clear();
|
||||
editorScene.LoadXML(revertData.GetRoot());
|
||||
editorScene.LoadXML(revertData.root);
|
||||
CreateGrid();
|
||||
UpdateHierarchyItem(editorScene, true);
|
||||
ClearEditActions();
|
||||
|
Loading…
Reference in New Issue
Block a user