mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-14 23:56:23 +00:00
Added support for sound properties, labelled most MP1 sound properties
This commit is contained in:
@@ -15,6 +15,7 @@ enum EPropertyType
|
||||
eStringProperty,
|
||||
eVector3Property,
|
||||
eColorProperty,
|
||||
eSoundProperty,
|
||||
eAssetProperty,
|
||||
eStructProperty,
|
||||
eArrayProperty,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user