WIP start of property serialization support
This commit is contained in:
parent
148449e50b
commit
6a72bae97a
|
@ -109,6 +109,7 @@ private:
|
|||
public:
|
||||
CScriptTemplate(CMasterTemplate *pMaster);
|
||||
~CScriptTemplate();
|
||||
void Serialize(IArchive& rArc);
|
||||
void PostLoad();
|
||||
EGame Game() const;
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ void* IPropertyNew::GetChildDataPointer(void* pPropertyData) const
|
|||
return pPropertyData;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void IPropertyNew::Serialize(IArchive& rArc)
|
||||
{
|
||||
if (rArc.Game() <= ePrime)
|
||||
|
@ -101,13 +100,12 @@ void IPropertyNew::Serialize(IArchive& rArc)
|
|||
|
||||
rArc << SERIAL_HEX("ID", mID)
|
||||
<< SERIAL("Description", mDescription)
|
||||
<< SERIAL("CookPref", mCookPref)
|
||||
<< SERIAL("CookPref", mCookPreference)
|
||||
<< SERIAL("MinVersion", mMinVersion)
|
||||
<< SERIAL("MaxVersion", mMaxVersion);
|
||||
|
||||
// Children don't get serialized for most property types
|
||||
}
|
||||
#endif
|
||||
|
||||
void IPropertyNew::InitFromArchetype(IPropertyNew* pOther)
|
||||
{
|
||||
|
|
|
@ -190,9 +190,7 @@ public:
|
|||
|
||||
virtual const char* HashableTypeName() const;
|
||||
virtual void* GetChildDataPointer(void* pPropertyData) const;
|
||||
#if 0
|
||||
virtual void Serialize(IArchive& rArc);
|
||||
#endif
|
||||
virtual void InitFromArchetype(IPropertyNew* pOther);
|
||||
virtual TString GetTemplateFileName();
|
||||
|
||||
|
@ -215,7 +213,6 @@ public:
|
|||
inline IPropertyNew* RootParent();
|
||||
inline IPropertyNew* Archetype() const;
|
||||
inline CScriptTemplate* ScriptTemplate() const;
|
||||
inline CMasterTemplate* MasterTemplate() const;
|
||||
inline TString Name() const;
|
||||
inline TString Description() const;
|
||||
inline TString Suffix() const;
|
||||
|
@ -349,14 +346,6 @@ public:
|
|||
|
||||
virtual bool CanHaveDefault() const { return true; }
|
||||
|
||||
#if 0
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
IPropertyNew::Serialize(rArc);
|
||||
rArc << SERIAL("DefaultValue", mDefaultValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void InitFromArchetype(IPropertyNew* pOther)
|
||||
{
|
||||
IPropertyNew::InitFromArchetype(pOther);
|
||||
|
@ -382,7 +371,23 @@ public:
|
|||
};
|
||||
|
||||
template<typename PropType, EPropertyTypeNew PropEnum>
|
||||
class TNumericalPropertyNew : public TTypedPropertyNew<PropType, PropEnum>
|
||||
class TSerializeableTypedProperty : public TTypedPropertyNew<PropType, PropEnum>
|
||||
{
|
||||
protected:
|
||||
TSerializeableTypedProperty()
|
||||
: TTypedPropertyNew()
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
IPropertyNew::Serialize(rArc);
|
||||
rArc << SERIAL("DefaultValue", mDefaultValue);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename PropType, EPropertyTypeNew PropEnum>
|
||||
class TNumericalPropertyNew : public TSerializeableTypedProperty<PropType, PropEnum>
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
friend class CTemplateLoader;
|
||||
|
@ -392,20 +397,18 @@ protected:
|
|||
PropType mMaxValue;
|
||||
|
||||
TNumericalPropertyNew()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
, mMinValue( -1 )
|
||||
, mMaxValue( -1 )
|
||||
{}
|
||||
|
||||
public:
|
||||
#if 0
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TTypedPropertyNew::Serialize(rArc);
|
||||
rArc << SERIAL("Min", mMin)
|
||||
<< SERIAL("Max", mMax);
|
||||
rArc << SERIAL("Min", mMinValue)
|
||||
<< SERIAL("Max", mMaxValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void InitFromArchetype(IPropertyNew* pOther)
|
||||
{
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CAnimationProperty : public TTypedPropertyNew< int, EPropertyTypeNew::Animation >
|
||||
class CAnimationProperty : public TSerializeableTypedProperty< u32, EPropertyTypeNew::Animation >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
protected:
|
||||
CAnimationProperty()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
{}
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CAnimationSetProperty : public TTypedPropertyNew< CAnimationParameters, EPropertyTypeNew::AnimationSet >
|
||||
class CAnimationSetProperty : public TSerializeableTypedProperty< CAnimationParameters, EPropertyTypeNew::AnimationSet >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
protected:
|
||||
CAnimationSetProperty()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
{}
|
||||
|
||||
public:
|
||||
|
|
|
@ -20,7 +20,7 @@ struct SScriptArray
|
|||
|
||||
/** You probably shouldn't use this on intrinsic classes; script only */
|
||||
/** @todo proper support of default values for arrays (this would be used for prefabs) */
|
||||
class CArrayProperty : public TTypedPropertyNew<int, EPropertyTypeNew::Array>
|
||||
class CArrayProperty : public TTypedPropertyNew<u32, EPropertyTypeNew::Array>
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
friend class CTemplateLoader;
|
||||
|
@ -105,6 +105,12 @@ public:
|
|||
Resize(pPropertyData, rArray.Count);
|
||||
}
|
||||
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TTypedPropertyNew::Serialize(rArc);
|
||||
//rArc << SERIAL("ItemArchetype", mpItemArchetype);
|
||||
}
|
||||
|
||||
virtual void SerializeValue(void* pData, IArchive& Arc) const
|
||||
{
|
||||
u32 Count = ArrayCount(pData);
|
||||
|
|
|
@ -4,19 +4,17 @@
|
|||
#include "../IPropertyNew.h"
|
||||
#include "Core/Resource/CResTypeFilter.h"
|
||||
|
||||
class CAssetProperty : public TTypedPropertyNew<CAssetID, EPropertyTypeNew::Asset>
|
||||
class CAssetProperty : public TSerializeableTypedProperty<CAssetID, EPropertyTypeNew::Asset>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
CResTypeFilter mTypeFilter;
|
||||
|
||||
public:
|
||||
#if 0
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TTypedPropertyNew::Serialize(rArc);
|
||||
TSerializeableTypedProperty::Serialize(rArc);
|
||||
rArc << SERIAL("AcceptedTypes", mTypeFilter);
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void InitFromArchetype(IPropertyNew* pOther)
|
||||
{
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CBoolProperty : public TTypedPropertyNew< bool, EPropertyTypeNew::Bool >
|
||||
class CBoolProperty : public TSerializeableTypedProperty< bool, EPropertyTypeNew::Bool >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
protected:
|
||||
CBoolProperty()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
{}
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CByteProperty : public TNumericalPropertyNew< char, EPropertyTypeNew::Byte >
|
||||
class CByteProperty : public TNumericalPropertyNew< s8, EPropertyTypeNew::Byte >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CColorProperty : public TTypedPropertyNew< CColor, EPropertyTypeNew::Color >
|
||||
class CColorProperty : public TSerializeableTypedProperty< CColor, EPropertyTypeNew::Color >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
protected:
|
||||
CColorProperty()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
{}
|
||||
|
||||
public:
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* In PWE, however, they are both implemented the same way under the hood.
|
||||
*/
|
||||
template<EPropertyTypeNew TypeEnum>
|
||||
class TEnumPropertyBase : public TTypedPropertyNew<int, TypeEnum>
|
||||
class TEnumPropertyBase : public TSerializeableTypedProperty<s32, TypeEnum>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
struct SEnumValue
|
||||
|
@ -19,13 +19,24 @@ class TEnumPropertyBase : public TTypedPropertyNew<int, TypeEnum>
|
|||
TString Name;
|
||||
u32 ID;
|
||||
|
||||
SEnumValue()
|
||||
: ID(0)
|
||||
{}
|
||||
|
||||
SEnumValue(const TString& rkInName, u32 InID)
|
||||
: Name(rkInName), ID(InID) {}
|
||||
|
||||
|
||||
inline bool operator==(const SEnumValue& rkOther) const
|
||||
{
|
||||
return( Name == rkOther.Name && ID == rkOther.ID );
|
||||
}
|
||||
|
||||
void Serialize(IArchive& rArc)
|
||||
{
|
||||
rArc << SERIAL_AUTO(Name)
|
||||
<< SERIAL_HEX_AUTO(ID);
|
||||
}
|
||||
};
|
||||
std::vector<SEnumValue> mValues;
|
||||
|
||||
|
@ -41,6 +52,12 @@ public:
|
|||
return "choice";
|
||||
}
|
||||
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TSerializeableTypedProperty::Serialize(rArc);
|
||||
rArc << SERIAL_CONTAINER("Values", mValues, "Values");
|
||||
}
|
||||
|
||||
virtual void SerializeValue(void* pData, IArchive& Arc) const
|
||||
{
|
||||
Arc.SerializePrimitive( (u32&) ValueRef(pData) );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CFlagsProperty : public TTypedPropertyNew<int, EPropertyTypeNew::Flags>
|
||||
class CFlagsProperty : public TSerializeableTypedProperty<u32, EPropertyTypeNew::Flags>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class IPropertyNew;
|
||||
|
@ -13,6 +13,10 @@ class CFlagsProperty : public TTypedPropertyNew<int, EPropertyTypeNew::Flags>
|
|||
TString Name;
|
||||
u32 Mask;
|
||||
|
||||
SBitFlag()
|
||||
: Mask(0)
|
||||
{}
|
||||
|
||||
SBitFlag(const TString& rkInName, u32 InMask)
|
||||
: Name(rkInName), Mask(InMask)
|
||||
{}
|
||||
|
@ -22,13 +26,11 @@ class CFlagsProperty : public TTypedPropertyNew<int, EPropertyTypeNew::Flags>
|
|||
return( Name == rkOther.Name && Mask == rkOther.Mask );
|
||||
}
|
||||
|
||||
#if 0
|
||||
void Serialize(IArchive& rArc)
|
||||
{
|
||||
rArc << SERIAL("FlagName", Name)
|
||||
<< SERIAL_HEX("FlagMask", Mask);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
std::vector<SBitFlag> mBitFlags;
|
||||
u32 mAllFlags;
|
||||
|
@ -37,7 +39,7 @@ class CFlagsProperty : public TTypedPropertyNew<int, EPropertyTypeNew::Flags>
|
|||
TString mSourceFile;
|
||||
|
||||
CFlagsProperty()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
, mAllFlags(0)
|
||||
{}
|
||||
|
||||
|
@ -59,21 +61,11 @@ public:
|
|||
return mBitFlags[Idx].Mask;
|
||||
}
|
||||
|
||||
#if 0
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TTypedPropertyNew::Serialize(rArc);
|
||||
rArc << SERIAL_CONTAINER("Flags", mFlags, "Flag");
|
||||
|
||||
// Initialize the "all flags" cache
|
||||
if (rArc.IsReader())
|
||||
{
|
||||
mAllFlags = 0;
|
||||
for (u32 FlagIdx = 0; FlagIdx < mFlags.size(); FlagIdx++)
|
||||
mAllFlags |= mFlags[FlagIdx].Mask;
|
||||
TSerializeableTypedProperty::Serialize(rArc);
|
||||
rArc << SERIAL_CONTAINER("Flags", mBitFlags, "Flag");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void PostInitialize()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CIntProperty : public TNumericalPropertyNew< int, EPropertyTypeNew::Int >
|
||||
class CIntProperty : public TNumericalPropertyNew< s32, EPropertyTypeNew::Int >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CSequenceProperty : public TTypedPropertyNew< int, EPropertyTypeNew::Sequence >
|
||||
class CSequenceProperty : public TTypedPropertyNew< s32, EPropertyTypeNew::Sequence >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CShortProperty : public TNumericalPropertyNew< short, EPropertyTypeNew::Short >
|
||||
class CShortProperty : public TNumericalPropertyNew< s16, EPropertyTypeNew::Short >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CSoundProperty : public TTypedPropertyNew< int, EPropertyTypeNew::Sound >
|
||||
class CSoundProperty : public TSerializeableTypedProperty< s32, EPropertyTypeNew::Sound >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
protected:
|
||||
CSoundProperty()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
{}
|
||||
|
||||
public:
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CStringProperty : public TTypedPropertyNew< TString, EPropertyTypeNew::String >
|
||||
class CStringProperty : public TSerializeableTypedProperty< TString, EPropertyTypeNew::String >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
protected:
|
||||
CStringProperty()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
{}
|
||||
|
||||
public:
|
||||
|
|
|
@ -87,14 +87,13 @@ public:
|
|||
return mpArchetype->HashableTypeName();
|
||||
}
|
||||
|
||||
#if 0
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
IPropertyNew::Serialize(rArc);
|
||||
|
||||
if (rArc.ParamBegin("SubProperties"))
|
||||
{
|
||||
u32 NumChildren;
|
||||
u32 NumChildren = mChildren.size();
|
||||
rArc.SerializeContainerSize(NumChildren, "Property");
|
||||
|
||||
if (rArc.IsReader())
|
||||
|
@ -111,7 +110,7 @@ public:
|
|||
|
||||
if (rArc.IsReader())
|
||||
{
|
||||
mChildren[ChildIdx] = Create(Type, this, mpMasterTemplate, mpScriptTemplate);
|
||||
mChildren[ChildIdx] = Create(Type, this, mGame, mpScriptTemplate);
|
||||
}
|
||||
|
||||
mChildren[ChildIdx]->Serialize(rArc);
|
||||
|
@ -122,7 +121,6 @@ public:
|
|||
rArc.ParamEnd();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void SerializeValue(void* pData, IArchive& Arc) const
|
||||
{
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
class CVectorProperty : public TTypedPropertyNew< CVector3f, EPropertyTypeNew::Vector >
|
||||
class CVectorProperty : public TSerializeableTypedProperty< CVector3f, EPropertyTypeNew::Vector >
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
|
||||
protected:
|
||||
CVectorProperty()
|
||||
: TTypedPropertyNew()
|
||||
: TSerializeableTypedProperty()
|
||||
{}
|
||||
|
||||
public:
|
||||
|
|
|
@ -132,7 +132,7 @@ void CTemplateEditDialog::AddTemplate(IPropertyNew* pProp)
|
|||
|
||||
if (!Source.IsEmpty())
|
||||
{
|
||||
CStructPropertyNew* pStruct = pProp->MasterTemplate()->StructAtSource(Source);
|
||||
CStructPropertyNew* pStruct = CMasterTemplate::MasterForGame(pProp->Game())->StructAtSource(Source);
|
||||
|
||||
if (!mStructTemplatesToResave.contains(pStruct))
|
||||
mStructTemplatesToResave << pStruct;
|
||||
|
@ -161,7 +161,7 @@ void CTemplateEditDialog::UpdateDescription(const TString& rkNewDesc)
|
|||
AddTemplate(mpProperty);
|
||||
|
||||
// Update all copies of this property in memory with the new description
|
||||
TString SourceFile = mpProperty->FindStructSource();
|
||||
TString SourceFile = mpProperty->GetTemplateFileName();
|
||||
|
||||
if (!SourceFile.IsEmpty())
|
||||
{
|
||||
|
@ -171,10 +171,10 @@ void CTemplateEditDialog::UpdateDescription(const TString& rkNewDesc)
|
|||
{
|
||||
for (u32 TemplateIdx = 0; TemplateIdx < pkTemplates->size(); TemplateIdx++)
|
||||
{
|
||||
IPropertyNew* pTemp = pkTemplates->at(TemplateIdx);
|
||||
IPropertyNew* pProp = pkTemplates->at(TemplateIdx);
|
||||
|
||||
if (pTemp->FindStructSource() == SourceFile && pTemp->Description() == mOriginalDescription)
|
||||
pTemp->SetDescription(rkNewDesc);
|
||||
if (pProp->GetTemplateFileName() == SourceFile && pProp->Description() == mOriginalDescription)
|
||||
pProp->SetDescription(rkNewDesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue