Added support for sound properties, labelled most MP1 sound properties

This commit is contained in:
parax0
2016-09-01 18:02:26 -06:00
parent 0929b20ba1
commit 2e1add84be
43 changed files with 221 additions and 106 deletions

View File

@@ -16,7 +16,7 @@ public:
inline u16 FindSoundDefineID(u32 SoundID)
{
ASSERT(SoundID >= 0 && SoundID < mDefineIDs.size());
if (SoundID >= mDefineIDs.size()) return -1;
return mDefineIDs[SoundID];
}
};

View File

@@ -86,6 +86,13 @@ void CScriptCooker::WriteProperty(IProperty *pProp, bool InSingleStruct)
break;
}
case eSoundProperty:
{
TSoundProperty *pSoundCast = static_cast<TSoundProperty*>(pProp);
mpSCLY->WriteLong(pSoundCast->Get());
break;
}
case eAssetProperty:
{
TAssetProperty *pAssetCast = static_cast<TAssetProperty*>(pProp);

View File

@@ -106,6 +106,13 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
break;
}
case eSoundProperty:
{
TSoundProperty *pSoundCast = static_cast<TSoundProperty*>(pProp);
pSoundCast->Set(rSCLY.ReadLong());
break;
}
case eAssetProperty:
{
TAssetProperty *pAssetCast = static_cast<TAssetProperty*>(pProp);

View File

@@ -190,6 +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 eSoundProperty: pOut = CREATE_PROP_TEMP(TSoundTemplate); 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;

View File

@@ -15,6 +15,7 @@ enum EPropertyType
eStringProperty,
eVector3Property,
eColorProperty,
eSoundProperty,
eAssetProperty,
eStructProperty,
eArrayProperty,

View File

@@ -22,8 +22,6 @@ typedef TString TIDString;
*/
class IProperty
{
friend class CScriptLoader;
protected:
class CPropertyStruct *mpParent;
CScriptObject *mpInstance;
@@ -78,7 +76,6 @@ public:
template <typename ValueType, EPropertyType TypeEnum, class ValueClass>
class TTypedProperty : public IProperty
{
friend class CScriptLoader;
ValueClass mValue;
public:
TTypedProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent)
@@ -124,7 +121,7 @@ typedef TTypedProperty<CColor, eColorProperty, CColorValue>
typedef TTypedProperty<std::vector<u8>, eUnknownProperty, CUnknownValue> TUnknownProperty;
/*
* TStringProperty, TAssetProperty, and TCharacterProperty get little subclasses in order to override some virtual functions.
* TStringProperty, TSoundProperty, 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,6 +139,15 @@ public:
virtual bool ShouldCook() { return true; }
};
class TSoundProperty : public TTypedProperty<u32, eSoundProperty, CSoundValue>
{
public:
IMPLEMENT_PROPERTY_CTORS(TSoundProperty, u32)
IMPLEMENT_PROPERTY_CLONE(TSoundProperty)
virtual bool MatchesDefault() { return Get() == -1; }
virtual bool ShouldCook() { return MatchesDefault(); }
};
class TAssetProperty : public TTypedProperty<CAssetID, eAssetProperty, CAssetValue>
{
public:

View File

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

View File

@@ -308,7 +308,7 @@ typedef TNumericalPropertyTemplate<float, eFloatProperty, CFloatValue>
typedef TTypedPropertyTemplate<CVector3f, eVector3Property, CVector3Value, true> TVector3Template;
typedef TTypedPropertyTemplate<CColor, eColorProperty, CColorValue, true> TColorTemplate;
// TCharacterTemplate, TStringTemplate, and TMayaSplineTemplate get their own subclasses so they can reimplement a couple functions
// TCharacterTemplate, TSoundTemplate, TStringTemplate, and TMayaSplineTemplate get their own subclasses so they can reimplement a couple functions
class TCharacterTemplate : public TTypedPropertyTemplate<CAnimationParameters, eCharacterProperty, CCharacterValue, false>
{
friend class CTemplateLoader;
@@ -327,6 +327,24 @@ public:
}
};
class TSoundTemplate : public TTypedPropertyTemplate<u32, eSoundProperty, CSoundValue, false>
{
friend class CTemplateLoader;
friend class CTemplateWriter;
public:
TSoundTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
: TTypedPropertyTemplate(ID, pScript, pMaster, pParent) {}
TSoundTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
: TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {}
IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent)
{
return new TSoundProperty(this, pInstance, pParent, -1);
}
};
class TStringTemplate : public TTypedPropertyTemplate<TString, eStringProperty, CStringValue, false>
{
friend class CTemplateLoader;

View File

@@ -342,6 +342,21 @@ public:
}
};
class CSoundValue : public TTypedPropertyValue<u32>
{
public:
CSoundValue() {}
CSoundValue(u32 SoundID) { mValue = SoundID; }
TString ToString() const { return TString::FromInt32(mValue, 0, 10); }
void FromString(const TString& rkString) { mValue = rkString.ToInt32(10); }
IPropertyValue* Clone() const
{
return new CSoundValue(mValue);
}
};
class CAssetValue : public TTypedPropertyValue<CAssetID>
{
public: