Renamed file properties to asset properties and modified asset properties to store a CAssetID instead of a CResourceInfo

This commit is contained in:
parax0
2016-09-01 00:24:46 -06:00
parent f6ae1376ac
commit 0929b20ba1
556 changed files with 2992 additions and 3461 deletions

View File

@@ -185,8 +185,9 @@ CResource* CScriptTemplate::FindDisplayAsset(CPropertyStruct *pProperties, u32&
else
{
TFileProperty *pFile = static_cast<TFileProperty*>(pProp);
pRes = pFile->Get().Load();
TAssetProperty *pAsset = static_cast<TAssetProperty*>(pProp);
CResourceEntry *pEntry = gpResourceStore->FindEntry(pAsset->Get());
if (pEntry) pRes = pEntry->Load();
}
}
@@ -218,10 +219,10 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(CPropertyStruct *pProperties
{
IProperty *pProp = pProperties->PropertyByIDString(it->AssetLocation);
if (pProp->Type() == eFileProperty)
if (pProp->Type() == eAssetProperty)
{
TFileProperty *pFile = static_cast<TFileProperty*>(pProp);
pRes = pFile->Get().Load();
TAssetProperty *pAsset = static_cast<TAssetProperty*>(pProp);
pRes = gpResourceStore->LoadResource( pAsset->Get(), "DCLN" );
}
}

View File

@@ -15,7 +15,7 @@ enum EPropertyType
eStringProperty,
eVector3Property,
eColorProperty,
eFileProperty,
eAssetProperty,
eStructProperty,
eArrayProperty,
eCharacterProperty,

View File

@@ -124,7 +124,7 @@ typedef TTypedProperty<CColor, eColorProperty, CColorValue>
typedef TTypedProperty<std::vector<u8>, eUnknownProperty, CUnknownValue> TUnknownProperty;
/*
* TStringProperty, TFileProperty, and TCharacterProperty get little subclasses in order to override some virtual functions.
* TStringProperty, TAssetProperty, and TCharacterProperty get little subclasses in order to override some virtual functions.
*/
#define IMPLEMENT_PROPERTY_CTORS(ClassName, ValueType) \
ClassName(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent) \
@@ -142,11 +142,11 @@ public:
virtual bool ShouldCook() { return true; }
};
class TFileProperty : public TTypedProperty<CResourceInfo, eFileProperty, CFileValue>
class TAssetProperty : public TTypedProperty<CAssetID, eAssetProperty, CAssetValue>
{
public:
IMPLEMENT_PROPERTY_CTORS(TFileProperty, CResourceInfo)
IMPLEMENT_PROPERTY_CLONE(TFileProperty)
IMPLEMENT_PROPERTY_CTORS(TAssetProperty, CAssetID)
IMPLEMENT_PROPERTY_CLONE(TAssetProperty)
virtual bool MatchesDefault() { return !Get().IsValid(); }
virtual bool ShouldCook() { return true; }
};

View File

@@ -229,7 +229,7 @@ TString PropEnumToPropString(EPropertyType Prop)
case eStringProperty: return "string";
case eColorProperty: return "color";
case eVector3Property: return "vector3f";
case eFileProperty: return "file";
case eAssetProperty: return "asset";
case eStructProperty: return "struct";
case eArrayProperty: return "array";
case eCharacterProperty: return "character";
@@ -255,7 +255,7 @@ EPropertyType PropStringToPropEnum(TString Prop)
if (Prop == "string") return eStringProperty;
if (Prop == "color") return eColorProperty;
if (Prop == "vector3f") return eVector3Property;
if (Prop == "file") return eFileProperty;
if (Prop == "asset") return eAssetProperty;
if (Prop == "struct") return eStructProperty;
if (Prop == "array") return eArrayProperty;
if (Prop == "character") return eCharacterProperty;

View File

@@ -363,44 +363,44 @@ public:
}
};
// CFileTemplate - Property template for files. Tracks a list of file types that
// CAssetTemplate - Property template for assets. Tracks a list of resource types that
// the property is allowed to accept.
class CFileTemplate : public IPropertyTemplate
class CAssetTemplate : public IPropertyTemplate
{
friend class CTemplateLoader;
friend class CTemplateWriter;
TStringList mAcceptedExtensions;
public:
CFileTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
CAssetTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
: IPropertyTemplate(ID, pScript, pMaster, pParent) {}
CFileTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
CAssetTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
: IPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {}
virtual EPropertyType Type() const { return eFileProperty; }
virtual EPropertyType Type() const { return eAssetProperty; }
virtual bool CanHaveDefault() const { return false; }
virtual bool IsNumerical() const { return false; }
IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent)
{
return new TFileProperty(this, pInstance, pParent);
return new TAssetProperty(this, pInstance, pParent);
}
IMPLEMENT_TEMPLATE_CLONE(CFileTemplate)
IMPLEMENT_TEMPLATE_CLONE(CAssetTemplate)
virtual void Copy(const IPropertyTemplate *pkTemp)
{
IPropertyTemplate::Copy(pkTemp);
mAcceptedExtensions = static_cast<const CFileTemplate*>(pkTemp)->mAcceptedExtensions;
mAcceptedExtensions = static_cast<const CAssetTemplate*>(pkTemp)->mAcceptedExtensions;
}
virtual bool Matches(const IPropertyTemplate *pkTemp) const
{
const CFileTemplate *pkFile = static_cast<const CFileTemplate*>(pkTemp);
const CAssetTemplate *pkAsset = static_cast<const CAssetTemplate*>(pkTemp);
return ( (IPropertyTemplate::Matches(pkTemp)) &&
(mAcceptedExtensions == pkFile->mAcceptedExtensions) );
(mAcceptedExtensions == pkAsset->mAcceptedExtensions) );
}
bool AcceptsExtension(const TString& rkExtension)
@@ -411,7 +411,7 @@ public:
}
void SetAllowedExtensions(const TStringList& rkExtensions) { mAcceptedExtensions = rkExtensions; }
const TStringList& Extensions() const { return mAcceptedExtensions; }
const TStringList& AllowedExtensions() const { return mAcceptedExtensions; }
};
// CEnumTemplate - Property template for enums. Tracks a list of possible values (enumerators).

View File

@@ -2,10 +2,10 @@
#define IPROPERTYVALUE_H
#include "EPropertyType.h"
#include <Common/CAssetID.h>
#include <Common/Log.h>
#include "Core/Resource/CAnimationParameters.h"
#include "Core/Resource/CResource.h"
#include "Core/Resource/CResourceInfo.h"
#include "Core/Resource/TResPtr.h"
#include <Common/CColor.h>
@@ -342,18 +342,18 @@ public:
}
};
class CFileValue : public TTypedPropertyValue<CResourceInfo>
class CAssetValue : public TTypedPropertyValue<CAssetID>
{
public:
CFileValue() {}
CFileValue(const CResourceInfo& rkInfo) { mValue = rkInfo; }
CAssetValue() {}
CAssetValue(const CAssetID& rkID) { mValue = rkID; }
TString ToString() const { return ""; }
void FromString(const TString&) {}
IPropertyValue* Clone() const
{
return new CFileValue(mValue);
return new CAssetValue(mValue);
}
};