mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 02:39:17 +00:00
Renamed file properties to asset properties and modified asset properties to store a CAssetID instead of a CResourceInfo
This commit is contained in:
@@ -47,13 +47,13 @@ CModel* CAreaAttributes::SkyModel() const
|
||||
switch (mGame)
|
||||
{
|
||||
case ePrime:
|
||||
return (CModel*) static_cast<TFileProperty*>(pBaseStruct->PropertyByIndex(7))->Get().Load();
|
||||
return (CModel*) gpResourceStore->LoadResource( static_cast<TAssetProperty*>(pBaseStruct->PropertyByIndex(7))->Get(), "CMDL" );
|
||||
case eEchoesDemo:
|
||||
case eEchoes:
|
||||
case eCorruptionProto:
|
||||
case eCorruption:
|
||||
case eReturns:
|
||||
return (CModel*) static_cast<TFileProperty*>(pBaseStruct->PropertyByID(0xD208C9FA))->Get().Load();
|
||||
return (CModel*) gpResourceStore->LoadResource( static_cast<TAssetProperty*>(pBaseStruct->PropertyByID(0xD208C9FA))->Get(), "CMDL" );
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,6 @@ HEADERS += \
|
||||
Scene/FShowFlags.h \
|
||||
Scene/CScene.h \
|
||||
Scene/CSceneIterator.h \
|
||||
Resource/CResourceInfo.h \
|
||||
Resource/CPoiToWorld.h \
|
||||
Resource/Factory/CPoiToWorldLoader.h \
|
||||
Resource/Cooker/CPoiToWorldCooker.h \
|
||||
|
||||
@@ -120,9 +120,9 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
|
||||
if (Type == eStructProperty || Type == eArrayProperty)
|
||||
ParseStructDependencies(pInst, static_cast<CPropertyStruct*>(pProp));
|
||||
|
||||
else if (Type == eFileProperty)
|
||||
else if (Type == eAssetProperty)
|
||||
{
|
||||
CAssetID ID = static_cast<TFileProperty*>(pProp)->Get().ID();
|
||||
CAssetID ID = static_cast<TAssetProperty*>(pProp)->Get();
|
||||
|
||||
if (ID.IsValid())
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "CAnimationParameters.h"
|
||||
#include "CAnimSet.h"
|
||||
#include "CResourceInfo.h"
|
||||
#include "Core/GameProject/CResourceStore.h"
|
||||
#include <Common/Log.h>
|
||||
#include <iostream>
|
||||
@@ -32,14 +31,14 @@ CAnimationParameters::CAnimationParameters(IInputStream& rSCLY, EGame Game)
|
||||
{
|
||||
if (Game <= eEchoes)
|
||||
{
|
||||
mCharacter = CResourceInfo(rSCLY.ReadLong(), "ANCS");
|
||||
mCharacterID = CAssetID(rSCLY, Game);
|
||||
mCharIndex = rSCLY.ReadLong();
|
||||
mAnimIndex = rSCLY.ReadLong();
|
||||
}
|
||||
|
||||
else if (Game <= eCorruption)
|
||||
{
|
||||
mCharacter = CResourceInfo(rSCLY.ReadLongLong(), "CHAR");
|
||||
mCharacterID = CAssetID(rSCLY, Game);
|
||||
mAnimIndex = rSCLY.ReadLong();
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ CAnimationParameters::CAnimationParameters(IInputStream& rSCLY, EGame Game)
|
||||
return;
|
||||
}
|
||||
|
||||
mCharacter = CResourceInfo(rSCLY.ReadLongLong(), "CHAR");
|
||||
mCharacterID = CAssetID(rSCLY, Game);
|
||||
|
||||
// 0x20 - Default Anim is present
|
||||
if (Flags & 0x20)
|
||||
@@ -82,9 +81,9 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
||||
{
|
||||
if (mGame <= eEchoes)
|
||||
{
|
||||
if (mCharacter.IsValid())
|
||||
if (mCharacterID.IsValid())
|
||||
{
|
||||
rSCLY.WriteLong(mCharacter.ID().ToLong());
|
||||
mCharacterID.Write(rSCLY);
|
||||
rSCLY.WriteLong(mCharIndex);
|
||||
rSCLY.WriteLong(mAnimIndex);
|
||||
}
|
||||
@@ -98,9 +97,9 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
||||
|
||||
else if (mGame <= eCorruption)
|
||||
{
|
||||
if (mCharacter.IsValid())
|
||||
if (mCharacterID.IsValid())
|
||||
{
|
||||
rSCLY.WriteLongLong(mCharacter.ID().ToLongLong());
|
||||
mCharacterID.Write(rSCLY);
|
||||
rSCLY.WriteLong(mAnimIndex);
|
||||
}
|
||||
|
||||
@@ -113,7 +112,7 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
||||
|
||||
else
|
||||
{
|
||||
if (!mCharacter.IsValid())
|
||||
if (!mCharacterID.IsValid())
|
||||
rSCLY.WriteByte((u8) 0x80);
|
||||
|
||||
else
|
||||
@@ -123,7 +122,7 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
||||
if (mUnknown2 != 0 || mUnknown3 != 0) Flag |= 0x40;
|
||||
|
||||
rSCLY.WriteByte(Flag);
|
||||
rSCLY.WriteLongLong(mCharacter.ID().ToLongLong());
|
||||
mCharacterID.Write(rSCLY);
|
||||
|
||||
if (Flag & 0x20)
|
||||
rSCLY.WriteLong(mAnimIndex);
|
||||
@@ -139,9 +138,9 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
||||
|
||||
CModel* CAnimationParameters::GetCurrentModel(s32 NodeIndex /*= -1*/)
|
||||
{
|
||||
if (!mCharacter.IsValid()) return nullptr;
|
||||
if (!mCharacterID.IsValid()) return nullptr;
|
||||
|
||||
CAnimSet *pSet = (CAnimSet*) mCharacter.Load();
|
||||
CAnimSet *pSet = AnimSet();
|
||||
if (!pSet) return nullptr;
|
||||
if (pSet->Type() != eAnimSet) return nullptr;
|
||||
if (NodeIndex == -1) NodeIndex = mCharIndex;
|
||||
@@ -152,9 +151,9 @@ CModel* CAnimationParameters::GetCurrentModel(s32 NodeIndex /*= -1*/)
|
||||
|
||||
TString CAnimationParameters::GetCurrentCharacterName(s32 NodeIndex /*= -1*/)
|
||||
{
|
||||
if (!mCharacter.IsValid()) return "";
|
||||
if (!mCharacterID.IsValid()) return "";
|
||||
|
||||
CAnimSet *pSet = (CAnimSet*) mCharacter.Load();
|
||||
CAnimSet *pSet = AnimSet();
|
||||
if (!pSet) return "";
|
||||
if (pSet->Type() != eAnimSet) return "";
|
||||
if (NodeIndex == -1) NodeIndex = mCharIndex;
|
||||
@@ -177,15 +176,22 @@ u32 CAnimationParameters::Unknown(u32 Index)
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimationParameters::SetResource(CResourceInfo Res)
|
||||
void CAnimationParameters::SetResource(const CAssetID& rkID)
|
||||
{
|
||||
if (Res.Type() == "ANCS" || Res.Type() == "CHAR")
|
||||
mCharacterID = rkID;
|
||||
mCharIndex = 0;
|
||||
mAnimIndex = 0;
|
||||
|
||||
// Validate ID
|
||||
if (mCharacterID.IsValid())
|
||||
{
|
||||
mCharacter = Res;
|
||||
mCharIndex = 0;
|
||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(rkID);
|
||||
|
||||
if (!pEntry)
|
||||
Log::Error("Invalid resource ID passed to CAnimationParameters: " + rkID.ToString());
|
||||
else if (pEntry->ResourceType() != eAnimSet)
|
||||
Log::Error("Resource with invalid type passed to CAnimationParameters: " + pEntry->CookedAssetPath().GetFileName());
|
||||
}
|
||||
else
|
||||
Log::Error("Resource with invalid type passed to CAnimationParameters: " + Res.ToString());
|
||||
}
|
||||
|
||||
void CAnimationParameters::SetUnknown(u32 Index, u32 Value)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define CANIMATIONPARAMETERS_H
|
||||
|
||||
#include "CAnimSet.h"
|
||||
#include "CResourceInfo.h"
|
||||
#include "TResPtr.h"
|
||||
#include "Core/Resource/Model/CModel.h"
|
||||
#include <Common/EGame.h>
|
||||
@@ -10,7 +9,7 @@
|
||||
class CAnimationParameters
|
||||
{
|
||||
EGame mGame;
|
||||
CResourceInfo mCharacter;
|
||||
CAssetID mCharacterID;
|
||||
|
||||
u32 mCharIndex;
|
||||
u32 mAnimIndex;
|
||||
@@ -28,22 +27,22 @@ public:
|
||||
|
||||
// Accessors
|
||||
inline EGame Version() const { return mGame; }
|
||||
inline CAssetID ID() const { return mCharacter.ID(); }
|
||||
inline CAnimSet* AnimSet() const { return (CAnimSet*) mCharacter.Load(); }
|
||||
inline CAssetID ID() const { return mCharacterID; }
|
||||
inline CAnimSet* AnimSet() const { return (CAnimSet*) gpResourceStore->LoadResource(mCharacterID, (mGame < eCorruptionProto ? "ANCS" : "CHAR")); }
|
||||
inline u32 CharacterIndex() const { return mCharIndex; }
|
||||
inline u32 AnimIndex() const { return mAnimIndex; }
|
||||
inline void SetCharIndex(u32 Index) { mCharIndex = Index; }
|
||||
inline void SetAnimIndex(u32 Index) { mAnimIndex = Index; }
|
||||
|
||||
u32 Unknown(u32 Index);
|
||||
void SetResource(CResourceInfo Res);
|
||||
void SetResource(const CAssetID& rkID);
|
||||
void SetUnknown(u32 Index, u32 Value);
|
||||
|
||||
// Operators
|
||||
inline bool operator==(const CAnimationParameters& rkOther) const
|
||||
{
|
||||
return ( (mGame == rkOther.mGame) &&
|
||||
(mCharacter == rkOther.mCharacter) &&
|
||||
(mCharacterID == rkOther.mCharacterID) &&
|
||||
(mCharIndex == rkOther.mCharIndex) &&
|
||||
(mAnimIndex == rkOther.mAnimIndex) &&
|
||||
(mUnknown2 == rkOther.mUnknown2) &&
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
#ifndef CRESOURCEINFO
|
||||
#define CRESOURCEINFO
|
||||
|
||||
#include "CResource.h"
|
||||
#include "Core/GameProject/CResourceStore.h"
|
||||
#include <Common/CAssetID.h>
|
||||
#include <Common/CFourCC.h>
|
||||
#include <Common/FileUtil.h>
|
||||
|
||||
class CResourceInfo
|
||||
{
|
||||
TString mPath;
|
||||
bool mIsPath;
|
||||
bool mIsValidPath;
|
||||
|
||||
public:
|
||||
CResourceInfo()
|
||||
: mPath("FFFFFFFFFFFFFFFF"), mIsPath(false), mIsValidPath(false) {}
|
||||
|
||||
CResourceInfo(const TString& rkPath)
|
||||
: mPath(rkPath), mIsPath(true)
|
||||
{
|
||||
mIsValidPath = FileUtil::Exists(rkPath);
|
||||
}
|
||||
|
||||
CResourceInfo(const CAssetID& rkID, CFourCC Type)
|
||||
: mIsPath(false), mIsValidPath(false)
|
||||
{
|
||||
mPath = rkID.ToString() + "." + Type.ToString();
|
||||
}
|
||||
|
||||
inline CAssetID ID() const
|
||||
{
|
||||
TString FileName = mPath.GetFileName(false);
|
||||
|
||||
if (!mIsPath)
|
||||
return CAssetID::FromString(FileName);
|
||||
|
||||
else
|
||||
{
|
||||
if (FileName.IsHexString() && (FileName.Size() == 8 || FileName.Size() == 16))
|
||||
return CAssetID::FromString(FileName);
|
||||
else
|
||||
return CAssetID::skInvalidID64;
|
||||
}
|
||||
}
|
||||
|
||||
inline CFourCC Type() const
|
||||
{
|
||||
return mPath.GetFileExtension();
|
||||
}
|
||||
|
||||
inline TString ToString() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
inline CResource* Load() const
|
||||
{
|
||||
if (!IsValid())
|
||||
return nullptr;
|
||||
if (mIsPath)
|
||||
return gpResourceStore->LoadResource(mPath);
|
||||
else
|
||||
return gpResourceStore->LoadResource(ID(), Type());
|
||||
}
|
||||
|
||||
inline bool IsValid() const
|
||||
{
|
||||
if (!mIsPath)
|
||||
return ID().IsValid();
|
||||
else
|
||||
return mIsValidPath;
|
||||
}
|
||||
|
||||
inline bool operator==(const CResourceInfo& rkOther) const
|
||||
{
|
||||
return (mPath.GetFileName() == rkOther.mPath.GetFileName());
|
||||
}
|
||||
|
||||
inline bool operator!=(const CResourceInfo& rkOther) const
|
||||
{
|
||||
return (!(*this == rkOther));
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CRESOURCEINFO
|
||||
|
||||
@@ -86,13 +86,10 @@ void CScriptCooker::WriteProperty(IProperty *pProp, bool InSingleStruct)
|
||||
break;
|
||||
}
|
||||
|
||||
case eFileProperty:
|
||||
case eAssetProperty:
|
||||
{
|
||||
TFileProperty *pFileCast = static_cast<TFileProperty*>(pProp);
|
||||
if (mVersion <= eEchoes)
|
||||
mpSCLY->WriteLong(pFileCast->Get().ID().ToLong());
|
||||
else
|
||||
mpSCLY->WriteLongLong(pFileCast->Get().ID().ToLongLong());
|
||||
TAssetProperty *pAssetCast = static_cast<TAssetProperty*>(pProp);
|
||||
pAssetCast->Get().Write(*mpSCLY);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -620,11 +620,11 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
pElem->LinkEndChild(pCookPref);
|
||||
}
|
||||
|
||||
// File-specific parameters
|
||||
if (pProp->Type() == eFileProperty)
|
||||
// Asset-specific parameters
|
||||
if (pProp->Type() == eAssetProperty)
|
||||
{
|
||||
CFileTemplate *pFile = static_cast<CFileTemplate*>(pProp);
|
||||
const TStringList& rkExtensions = pFile->Extensions();
|
||||
CAssetTemplate *pAsset = static_cast<CAssetTemplate*>(pProp);
|
||||
const TStringList& rkExtensions = pAsset->AllowedExtensions();
|
||||
TString ExtensionsString;
|
||||
|
||||
for (auto it = rkExtensions.begin(); it != rkExtensions.end(); it++)
|
||||
@@ -790,17 +790,17 @@ void CTemplateWriter::SavePropertyOverrides(XMLDocument *pDoc, XMLElement *pPare
|
||||
pElem->LinkEndChild(pCookPref);
|
||||
}
|
||||
|
||||
// File-specific parameters
|
||||
if (pProp->Type() == eFileProperty)
|
||||
// Asset-specific parameters
|
||||
if (pProp->Type() == eAssetProperty)
|
||||
{
|
||||
CFileTemplate *pFile = static_cast<CFileTemplate*>(pProp);
|
||||
CFileTemplate *pSourceFile = static_cast<CFileTemplate*>(pSource);
|
||||
CAssetTemplate *pAsset = static_cast<CAssetTemplate*>(pProp);
|
||||
CAssetTemplate *pSourceAsset = static_cast<CAssetTemplate*>(pSource);
|
||||
|
||||
if (pFile->Extensions() != pSourceFile->Extensions())
|
||||
if (pAsset->AllowedExtensions() != pSourceAsset->AllowedExtensions())
|
||||
{
|
||||
TString ExtensionsString;
|
||||
|
||||
for (auto it = pFile->Extensions().begin(); it != pFile->Extensions().end(); it++)
|
||||
for (auto it = pAsset->AllowedExtensions().begin(); it != pAsset->AllowedExtensions().end(); it++)
|
||||
ExtensionsString += *it + ",";
|
||||
|
||||
ExtensionsString = ExtensionsString.ChopBack(1);
|
||||
|
||||
@@ -106,22 +106,37 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
|
||||
break;
|
||||
}
|
||||
|
||||
case eFileProperty:
|
||||
case eAssetProperty:
|
||||
{
|
||||
TFileProperty *pFileCast = static_cast<TFileProperty*>(pProp);
|
||||
TAssetProperty *pAssetCast = static_cast<TAssetProperty*>(pProp);
|
||||
CAssetID ID(rSCLY, mVersion);
|
||||
pAssetCast->Set(ID);
|
||||
|
||||
CAssetID ResID(rSCLY, mVersion);
|
||||
const TStringList& rkExtensions = static_cast<CFileTemplate*>(pTemp)->Extensions();
|
||||
|
||||
CResourceInfo Info(ResID, CFourCC(!rkExtensions.empty() ? rkExtensions.front() : "UNKN"));
|
||||
|
||||
if (ResID.IsValid())
|
||||
// Verify this is a valid resource type for this property
|
||||
if (ID.IsValid())
|
||||
{
|
||||
CFourCC Type = gpResourceStore->ResourceTypeByID(ResID, rkExtensions);
|
||||
Info = CResourceInfo(ResID, Type);
|
||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
||||
|
||||
if (pEntry)
|
||||
{
|
||||
TString CookedExt = pEntry->CookedExtension().ToString();
|
||||
const TStringList& rkExtensions = static_cast<CAssetTemplate*>(pTemp)->AllowedExtensions();
|
||||
bool Valid = false;
|
||||
|
||||
for (auto It = rkExtensions.begin(); It != rkExtensions.end(); It++)
|
||||
{
|
||||
if (*It == CookedExt)
|
||||
{
|
||||
Valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Valid)
|
||||
Log::FileWarning(rSCLY.GetSourceString(), rSCLY.Tell() - ID.Length(), "Asset property " + pTemp->IDString(true) + " in object " + pTemp->ScriptTemplate()->Name() + " has a reference to an illegal asset type: " + CookedExt);
|
||||
}
|
||||
}
|
||||
|
||||
pFileCast->Set(Info);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,12 +106,16 @@ IPropertyTemplate* CTemplateLoader::LoadProperty(XMLElement *pElem, CScriptTempl
|
||||
}
|
||||
|
||||
// File-specific parameters
|
||||
if (Type == eFileProperty)
|
||||
if (Type == eAssetProperty)
|
||||
{
|
||||
CFileTemplate *pFile = static_cast<CFileTemplate*>(pProp);
|
||||
TString ExtensionsAttr = pElem->Attribute("extensions");
|
||||
TStringList ExtensionsList = ExtensionsAttr.Split(", ");
|
||||
pFile->SetAllowedExtensions(ExtensionsList);
|
||||
|
||||
if (!ExtensionsAttr.IsEmpty())
|
||||
{
|
||||
TStringList ExtensionsList = ExtensionsAttr.Split(", ");
|
||||
CAssetTemplate *pAsset = static_cast<CAssetTemplate*>(pProp);
|
||||
pAsset->SetAllowedExtensions(ExtensionsList);
|
||||
}
|
||||
}
|
||||
|
||||
// Enum-specific parameters
|
||||
@@ -186,7 +190,7 @@ IPropertyTemplate* CTemplateLoader::CreateProperty(u32 ID, EPropertyType Type, c
|
||||
case eStringProperty: pOut = CREATE_PROP_TEMP(TStringTemplate); break;
|
||||
case eVector3Property: pOut = CREATE_PROP_TEMP(TVector3Template); break;
|
||||
case eColorProperty: pOut = CREATE_PROP_TEMP(TColorTemplate); break;
|
||||
case eFileProperty: pOut = CREATE_PROP_TEMP(CFileTemplate); break;
|
||||
case eAssetProperty: pOut = CREATE_PROP_TEMP(CAssetTemplate); break;
|
||||
case eCharacterProperty: pOut = CREATE_PROP_TEMP(TCharacterTemplate); break;
|
||||
case eMayaSplineProperty: pOut = CREATE_PROP_TEMP(TMayaSplineTemplate); break;
|
||||
case eEnumProperty: pOut = CREATE_PROP_TEMP(CEnumTemplate); break;
|
||||
@@ -601,7 +605,7 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TS
|
||||
|
||||
if (!pProp)
|
||||
Log::Error(rkTemplateName + ": Invalid property for attachment " + TString::FromInt32(AttachIdx) + ": " + Attachment.AttachProperty);
|
||||
else if (pProp->Type() != eCharacterProperty && (pProp->Type() != eFileProperty || !static_cast<CFileTemplate*>(pProp)->AcceptsExtension("CMDL")))
|
||||
else if (pProp->Type() != eCharacterProperty && (pProp->Type() != eAssetProperty || !static_cast<CAssetTemplate*>(pProp)->AcceptsExtension("CMDL")))
|
||||
Log::Error(rkTemplateName + ": Property referred to by attachment " + TString::FromInt32(AttachIdx) + " is not an attachable asset! Must be a file property that accepts CMDLs, or a character property.");
|
||||
|
||||
else
|
||||
|
||||
@@ -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" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ enum EPropertyType
|
||||
eStringProperty,
|
||||
eVector3Property,
|
||||
eColorProperty,
|
||||
eFileProperty,
|
||||
eAssetProperty,
|
||||
eStructProperty,
|
||||
eArrayProperty,
|
||||
eCharacterProperty,
|
||||
|
||||
@@ -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; }
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ void CScriptAttachNode::AttachPropertyModified()
|
||||
{
|
||||
if (mpAttachAssetProp)
|
||||
{
|
||||
if (mpAttachAssetProp->Type() == eFileProperty)
|
||||
mpAttachAsset = TPropCast<TFileProperty>(mpAttachAssetProp)->Get().Load();
|
||||
if (mpAttachAssetProp->Type() == eAssetProperty)
|
||||
mpAttachAsset = gpResourceStore->LoadResource( TPropCast<TAssetProperty>(mpAttachAssetProp)->Get(), "CMDL" );
|
||||
else if (mpAttachAssetProp->Type() == eCharacterProperty)
|
||||
mpAttachAsset = TPropCast<TCharacterProperty>(mpAttachAssetProp)->Get().AnimSet();
|
||||
|
||||
|
||||
@@ -472,16 +472,16 @@ void CScriptNode::PropertyModified(IProperty *pProp)
|
||||
SetDisplayAsset(mpInstance->DisplayAsset());
|
||||
}
|
||||
|
||||
else if (pProp->Type() == eFileProperty)
|
||||
else if (pProp->Type() == eAssetProperty)
|
||||
{
|
||||
CFileTemplate *pFileTemp = static_cast<CFileTemplate*>(pProp->Template());
|
||||
CAssetTemplate *pAssetTemp = static_cast<CAssetTemplate*>(pProp->Template());
|
||||
|
||||
if (pFileTemp->AcceptsExtension("CMDL") || pFileTemp->AcceptsExtension("TXTR") || pFileTemp->AcceptsExtension("ANCS") || pFileTemp->AcceptsExtension("CHAR"))
|
||||
if (pAssetTemp->AcceptsExtension("CMDL") || pAssetTemp->AcceptsExtension("TXTR") || pAssetTemp->AcceptsExtension("ANCS") || pAssetTemp->AcceptsExtension("CHAR"))
|
||||
{
|
||||
mpInstance->EvaluateDisplayAsset();
|
||||
SetDisplayAsset(mpInstance->DisplayAsset());
|
||||
}
|
||||
else if (pFileTemp->AcceptsExtension("DCLN"))
|
||||
else if (pAssetTemp->AcceptsExtension("DCLN"))
|
||||
{
|
||||
mpInstance->EvaluateCollisionModel();
|
||||
mpCollisionNode->SetCollision(mpInstance->Collision());
|
||||
|
||||
@@ -28,7 +28,7 @@ CDamageableTriggerExtra::CDamageableTriggerExtra(CScriptObject *pInstance, CScen
|
||||
// Fetch textures
|
||||
for (u32 iTex = 0; iTex < 3; iTex++)
|
||||
{
|
||||
mpTextureProps[iTex] = TPropCast<TFileProperty>(pBaseStruct->PropertyByIndex(0x6 + iTex));
|
||||
mpTextureProps[iTex] = TPropCast<TAssetProperty>(pBaseStruct->PropertyByIndex(0x6 + iTex));
|
||||
if (mpTextureProps[iTex]) PropertyModified(mpTextureProps[iTex]);
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ void CDamageableTriggerExtra::PropertyModified(IProperty *pProperty)
|
||||
{
|
||||
if (pProperty == mpTextureProps[iTex])
|
||||
{
|
||||
mpTextures[iTex] = mpTextureProps[iTex]->Get().Load();
|
||||
mpTextures[iTex] = gpResourceStore->LoadResource( mpTextureProps[iTex]->Get(), "TXTR" );
|
||||
|
||||
if (mpTextures[iTex] && mpTextures[iTex]->Type() != eTexture)
|
||||
mpTextures[iTex] = nullptr;
|
||||
|
||||
@@ -19,7 +19,7 @@ class CDamageableTriggerExtra : public CScriptExtra
|
||||
|
||||
TVector3Property *mpSizeProp;
|
||||
TEnumProperty *mpRenderSideProp;
|
||||
TFileProperty *mpTextureProps[3];
|
||||
TAssetProperty *mpTextureProps[3];
|
||||
|
||||
CVector3f mPlaneSize;
|
||||
ERenderSide mRenderSide;
|
||||
|
||||
@@ -9,7 +9,7 @@ CDoorExtra::CDoorExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pP
|
||||
{
|
||||
CPropertyStruct *pBaseStruct = pInstance->Properties();
|
||||
|
||||
mpShieldModelProp = TPropCast<TFileProperty>(pBaseStruct->PropertyByID(0xB20CC271));
|
||||
mpShieldModelProp = TPropCast<TAssetProperty>(pBaseStruct->PropertyByID(0xB20CC271));
|
||||
if (mpShieldModelProp) PropertyModified(mpShieldModelProp);
|
||||
|
||||
if (mGame >= eEchoes)
|
||||
@@ -29,7 +29,7 @@ void CDoorExtra::PropertyModified(IProperty *pProperty)
|
||||
{
|
||||
if (pProperty == mpShieldModelProp)
|
||||
{
|
||||
mpShieldModel = mpShieldModelProp->Get().Load();
|
||||
mpShieldModel = gpResourceStore->LoadResource( mpShieldModelProp->Get(), "CMDL" );
|
||||
|
||||
if (mpShieldModel)
|
||||
mLocalAABox = mpShieldModel->AABox();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
class CDoorExtra : public CScriptExtra
|
||||
{
|
||||
// Render colored door shield in MP2/3
|
||||
TFileProperty *mpShieldModelProp;
|
||||
TAssetProperty *mpShieldModelProp;
|
||||
TColorProperty *mpShieldColorProp;
|
||||
TBoolProperty *mpDisabledProp;
|
||||
TResPtr<CModel> mpShieldModel;
|
||||
|
||||
@@ -11,15 +11,15 @@ CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CScene *p
|
||||
// Fetch scan data property
|
||||
CPropertyStruct *pBaseProp = pInstance->Properties();
|
||||
|
||||
if (mGame <= ePrime) mpScanProperty = TPropCast<TFileProperty>(pBaseProp->PropertyByIDString("0x04:0x00"));
|
||||
else mpScanProperty = (TFileProperty*) pBaseProp->PropertyByIDString("0xBDBEC295:0xB94E9BE7");
|
||||
if (mGame <= ePrime) mpScanProperty = TPropCast<TAssetProperty>(pBaseProp->PropertyByIDString("0x04:0x00"));
|
||||
else mpScanProperty = (TAssetProperty*) pBaseProp->PropertyByIDString("0xBDBEC295:0xB94E9BE7");
|
||||
if (mpScanProperty) PropertyModified(mpScanProperty);
|
||||
}
|
||||
|
||||
void CPointOfInterestExtra::PropertyModified(IProperty* pProperty)
|
||||
{
|
||||
if (mpScanProperty == pProperty)
|
||||
mpScanData = mpScanProperty->Get().Load();
|
||||
mpScanData = gpResourceStore->LoadResource( mpScanProperty->Get(), "SCAN" );
|
||||
}
|
||||
|
||||
void CPointOfInterestExtra::ModifyTintColor(CColor& Color)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class CPointOfInterestExtra : public CScriptExtra
|
||||
{
|
||||
// Tint POI billboard orange/red depending on scan importance
|
||||
TFileProperty *mpScanProperty;
|
||||
TAssetProperty *mpScanProperty;
|
||||
TResPtr<CScan> mpScanData;
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user