Add resource load and save functions for animations.

This commit is contained in:
Aster Jian 2014-04-02 19:53:08 +08:00 committed by aster2013
parent fc2ce2f3de
commit 21ddb94b52
4 changed files with 46 additions and 0 deletions

View File

@ -60,6 +60,25 @@ void AttributeAnimation::RegisterObject(Context* context)
context->RegisterFactory<AttributeAnimation>();
}
bool AttributeAnimation::Load(Deserializer& source)
{
XMLFile xmlFile(context_);
if (!xmlFile.Load(source))
return false;
return LoadXML(xmlFile.GetRoot());
}
bool AttributeAnimation::Save(Serializer& dest) const
{
XMLFile xmlFile(context_);
if (!SaveXML(xmlFile.CreateRoot("attributeAnimation")))
return false;
return xmlFile.Save(dest);
}
bool AttributeAnimation::LoadXML(const XMLElement& source)
{
valueType_ = VAR_NONE;

View File

@ -75,6 +75,10 @@ public:
/// Register object factory.
static void RegisterObject(Context* context);
/// Load resource. Return true if successful.
virtual bool Load(Deserializer& source);
/// Save resource. Return true if successful.
virtual bool Save(Serializer& dest) const;
/// Load from XML data. Return true if successful.
bool LoadXML(const XMLElement& source);
/// Save as XML data. Return true if successful.

View File

@ -45,6 +45,25 @@ void ObjectAnimation::RegisterObject(Context* context)
context->RegisterFactory<ObjectAnimation>();
}
bool ObjectAnimation::Load(Deserializer& source)
{
XMLFile xmlFile(context_);
if (!xmlFile.Load(source))
return false;
return LoadXML(xmlFile.GetRoot());
}
bool ObjectAnimation::Save(Serializer& dest) const
{
XMLFile xmlFile(context_);
if (!SaveXML(xmlFile.CreateRoot("objectAnimation")))
return false;
return xmlFile.Save(dest);
}
bool ObjectAnimation::LoadXML(const XMLElement& source)
{
attributeAnimations_.Clear();

View File

@ -42,6 +42,10 @@ public:
/// Register object factory.
static void RegisterObject(Context* context);
/// Load resource. Return true if successful.
virtual bool Load(Deserializer& source);
/// Save resource. Return true if successful.
virtual bool Save(Serializer& dest) const;
/// Load from XML data. Return true if successful.
bool LoadXML(const XMLElement& source);
/// Save as XML data. Return true if successful.