From a166dd8ac3d65f0cbb488b8d397f39d37e6a5906 Mon Sep 17 00:00:00 2001 From: parax0 Date: Wed, 24 Feb 2016 04:01:03 -0700 Subject: [PATCH] Fixed incorrect LayerSwitch/LayerID templates, made IPropertyTemplate::CookPreference() virtual and overrode it for certain types, fixed a CAnimationParameters bug --- src/Core/Resource/CAnimationParameters.cpp | 9 +++ src/Core/Resource/CAnimationParameters.h | 1 + src/Core/Resource/Script/IPropertyTemplate.h | 73 ++++++++++++++++++-- templates/Properties.xml | 2 +- templates/dkcr/Script/PathControl.xml | 3 + templates/dkcr/Script/SplinePath.xml | 2 +- templates/dkcr/Structs/Convergence.xml | 10 +++ templates/dkcr/Structs/LayerID.xml | 8 +-- templates/dkcr/Structs/LayerSwitch.xml | 4 +- templates/mp3/Structs/LayerID.xml | 8 +-- templates/mp3/Structs/LayerSwitch.xml | 4 +- templates/mp3proto/Structs/LayerID.xml | 17 +++++ templates/mp3proto/Structs/LayerSwitch.xml | 4 +- 13 files changed, 122 insertions(+), 23 deletions(-) create mode 100644 templates/mp3proto/Structs/LayerID.xml diff --git a/src/Core/Resource/CAnimationParameters.cpp b/src/Core/Resource/CAnimationParameters.cpp index ab7f8558..6ab4ac6f 100644 --- a/src/Core/Resource/CAnimationParameters.cpp +++ b/src/Core/Resource/CAnimationParameters.cpp @@ -14,6 +14,15 @@ CAnimationParameters::CAnimationParameters() mUnknown3 = 0; } +CAnimationParameters::CAnimationParameters(EGame Game) +{ + mGame = Game; + mNodeIndex = 0; + mUnknown1 = 0; + mUnknown2 = 0; + mUnknown3 = 0; +} + CAnimationParameters::CAnimationParameters(IInputStream& SCLY, EGame Game) { mGame = Game; diff --git a/src/Core/Resource/CAnimationParameters.h b/src/Core/Resource/CAnimationParameters.h index 97ba3877..58c9101e 100644 --- a/src/Core/Resource/CAnimationParameters.h +++ b/src/Core/Resource/CAnimationParameters.h @@ -19,6 +19,7 @@ class CAnimationParameters public: CAnimationParameters(); + CAnimationParameters(EGame Game); CAnimationParameters(IInputStream& SCLY, EGame Game); void Write(IOutputStream& rSCLY); diff --git a/src/Core/Resource/Script/IPropertyTemplate.h b/src/Core/Resource/Script/IPropertyTemplate.h index c49be50c..df1166da 100644 --- a/src/Core/Resource/Script/IPropertyTemplate.h +++ b/src/Core/Resource/Script/IPropertyTemplate.h @@ -92,6 +92,7 @@ public: virtual bool HasValidRange() const { return false; } virtual TString RangeToString() const { return ""; } virtual TString Suffix() const { return ""; } + virtual ECookPreference CookPreference() const { return mCookPreference; } virtual void SetParam(const TString& rkParamName, const TString& rkValue) { @@ -123,7 +124,6 @@ public: inline TString Name() const { return mName; } inline TString Description() const { return mDescription; } inline u32 PropertyID() const { return mID; } - inline ECookPreference CookPreference() const { return mCookPreference; } inline CStructTemplate* Parent() const { return mpParent; } inline CScriptTemplate* ScriptTemplate() const { return mpScriptTemplate; } inline CMasterTemplate* MasterTemplate() const { return mpMasterTemplate; } @@ -307,11 +307,10 @@ typedef TNumericalPropertyTemplate typedef TNumericalPropertyTemplate TShortTemplate; typedef TNumericalPropertyTemplate TLongTemplate; typedef TNumericalPropertyTemplate TFloatTemplate; -typedef TTypedPropertyTemplate TStringTemplate; typedef TTypedPropertyTemplate TVector3Template; typedef TTypedPropertyTemplate TColorTemplate; -// TCharacterTemplate and TMayaSplineTemplate - quick subclasses in order to reimplement InstantiateProperty +// TCharacterTemplate, TStringTemplate, and TMayaSplineTemplate get their own subclasses so they can reimplement a couple functions class TCharacterTemplate : public TTypedPropertyTemplate { friend class CTemplateLoader; @@ -326,7 +325,41 @@ public: IProperty* InstantiateProperty(CPropertyStruct *pParent) { - return new TCharacterProperty(this, pParent); + return new TCharacterProperty(this, pParent, CAnimationParameters(Game())); + } + + ECookPreference CookPreference() const + { + if (mCookPreference != eNoCookPreference) + return mCookPreference; + else + return eAlwaysCook; + } +}; + +class TStringTemplate : public TTypedPropertyTemplate +{ + friend class CTemplateLoader; + friend class CTemplateWriter; + +public: + TStringTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) + : TTypedPropertyTemplate(ID, pScript, pMaster, pParent) {} + + TStringTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) + : TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {} + + IProperty* InstantiateProperty(CPropertyStruct *pParent) + { + return new TStringProperty(this, pParent); + } + + ECookPreference CookPreference() const + { + if (mCookPreference != eNoCookPreference) + return mCookPreference; + else + return eAlwaysCook; } }; @@ -388,6 +421,14 @@ public: (mAcceptedExtensions == pkFile->mAcceptedExtensions) ); } + ECookPreference CookPreference() const + { + if (mCookPreference != eNoCookPreference) + return mCookPreference; + else + return eAlwaysCook; + } + bool AcceptsExtension(const TString& rkExtension) { for (auto it = mAcceptedExtensions.begin(); it != mAcceptedExtensions.end(); it++) @@ -653,6 +694,22 @@ public: return false; } + virtual ECookPreference CookPreference() const + { + if (mCookPreference != eNoCookPreference) return mCookPreference; + bool SubsNeverCook = true; + + for (u32 iProp = 0; iProp < mSubProperties.size(); iProp++) + { + IPropertyTemplate *pProp = mSubProperties[iProp]; + ECookPreference Pref = pProp->CookPreference(); + if (Pref != eNeverCook) SubsNeverCook = false; + if (Pref == eAlwaysCook) return eAlwaysCook; + } + + return (SubsNeverCook ? eNeverCook : eNoCookPreference); + } + inline TString SourceFile() const { return mSourceFile; } inline bool IsSingleProperty() const { return mIsSingleProperty; } inline u32 Count() const { return mSubProperties.size(); } @@ -714,6 +771,14 @@ public: (CStructTemplate::Matches(pkTemp)) ); } + ECookPreference CookPreference() + { + if (mCookPreference != eNoCookPreference) + return mCookPreference; + else + return eAlwaysCook; + } + void SetParam(const TString& rkParamName, const TString& rkValue) { if (rkParamName == "element_name") diff --git a/templates/Properties.xml b/templates/Properties.xml index aba3f270..7e39fecb 100644 --- a/templates/Properties.xml +++ b/templates/Properties.xml @@ -8662,7 +8662,7 @@ - + diff --git a/templates/dkcr/Script/PathControl.xml b/templates/dkcr/Script/PathControl.xml index 010bc200..99099282 100644 --- a/templates/dkcr/Script/PathControl.xml +++ b/templates/dkcr/Script/PathControl.xml @@ -8,6 +8,9 @@ always + + 1.0, 1.0, 1.0, 1.0 + diff --git a/templates/dkcr/Script/SplinePath.xml b/templates/dkcr/Script/SplinePath.xml index 09eae401..94254a4c 100644 --- a/templates/dkcr/Script/SplinePath.xml +++ b/templates/dkcr/Script/SplinePath.xml @@ -8,7 +8,7 @@ - 1.0, 0.0, 1.0, 1.0 + 1.0, 1.0, 1.0, 1.0 diff --git a/templates/dkcr/Structs/Convergence.xml b/templates/dkcr/Structs/Convergence.xml index 07304a62..316a45b8 100644 --- a/templates/dkcr/Structs/Convergence.xml +++ b/templates/dkcr/Structs/Convergence.xml @@ -24,6 +24,16 @@ + + never + + + always + false + + + + diff --git a/templates/dkcr/Structs/LayerID.xml b/templates/dkcr/Structs/LayerID.xml index 3c964dd2..f6488264 100644 --- a/templates/dkcr/Structs/LayerID.xml +++ b/templates/dkcr/Structs/LayerID.xml @@ -1,16 +1,16 @@ - + 0 - + 0 - + 0 - + 0 diff --git a/templates/dkcr/Structs/LayerSwitch.xml b/templates/dkcr/Structs/LayerSwitch.xml index eb9604f2..88ab8311 100644 --- a/templates/dkcr/Structs/LayerSwitch.xml +++ b/templates/dkcr/Structs/LayerSwitch.xml @@ -2,8 +2,6 @@ - - 0 - + diff --git a/templates/mp3/Structs/LayerID.xml b/templates/mp3/Structs/LayerID.xml index 3c964dd2..f6488264 100644 --- a/templates/mp3/Structs/LayerID.xml +++ b/templates/mp3/Structs/LayerID.xml @@ -1,16 +1,16 @@ - + 0 - + 0 - + 0 - + 0 diff --git a/templates/mp3/Structs/LayerSwitch.xml b/templates/mp3/Structs/LayerSwitch.xml index eb9604f2..88ab8311 100644 --- a/templates/mp3/Structs/LayerSwitch.xml +++ b/templates/mp3/Structs/LayerSwitch.xml @@ -2,8 +2,6 @@ - - 0 - + diff --git a/templates/mp3proto/Structs/LayerID.xml b/templates/mp3proto/Structs/LayerID.xml new file mode 100644 index 00000000..f6488264 --- /dev/null +++ b/templates/mp3proto/Structs/LayerID.xml @@ -0,0 +1,17 @@ + + + + + 0 + + + 0 + + + 0 + + + 0 + + + diff --git a/templates/mp3proto/Structs/LayerSwitch.xml b/templates/mp3proto/Structs/LayerSwitch.xml index eb9604f2..88ab8311 100644 --- a/templates/mp3proto/Structs/LayerSwitch.xml +++ b/templates/mp3proto/Structs/LayerSwitch.xml @@ -2,8 +2,6 @@ - - 0 - +