Fixed incorrect LayerSwitch/LayerID templates, made IPropertyTemplate::CookPreference() virtual and overrode it for certain types, fixed a CAnimationParameters bug

This commit is contained in:
parax0 2016-02-24 04:01:03 -07:00
parent dd4341d251
commit a166dd8ac3
13 changed files with 122 additions and 23 deletions

View File

@ -14,6 +14,15 @@ CAnimationParameters::CAnimationParameters()
mUnknown3 = 0; mUnknown3 = 0;
} }
CAnimationParameters::CAnimationParameters(EGame Game)
{
mGame = Game;
mNodeIndex = 0;
mUnknown1 = 0;
mUnknown2 = 0;
mUnknown3 = 0;
}
CAnimationParameters::CAnimationParameters(IInputStream& SCLY, EGame Game) CAnimationParameters::CAnimationParameters(IInputStream& SCLY, EGame Game)
{ {
mGame = Game; mGame = Game;

View File

@ -19,6 +19,7 @@ class CAnimationParameters
public: public:
CAnimationParameters(); CAnimationParameters();
CAnimationParameters(EGame Game);
CAnimationParameters(IInputStream& SCLY, EGame Game); CAnimationParameters(IInputStream& SCLY, EGame Game);
void Write(IOutputStream& rSCLY); void Write(IOutputStream& rSCLY);

View File

@ -92,6 +92,7 @@ public:
virtual bool HasValidRange() const { return false; } virtual bool HasValidRange() const { return false; }
virtual TString RangeToString() const { return ""; } virtual TString RangeToString() const { return ""; }
virtual TString Suffix() const { return ""; } virtual TString Suffix() const { return ""; }
virtual ECookPreference CookPreference() const { return mCookPreference; }
virtual void SetParam(const TString& rkParamName, const TString& rkValue) virtual void SetParam(const TString& rkParamName, const TString& rkValue)
{ {
@ -123,7 +124,6 @@ public:
inline TString Name() const { return mName; } inline TString Name() const { return mName; }
inline TString Description() const { return mDescription; } inline TString Description() const { return mDescription; }
inline u32 PropertyID() const { return mID; } inline u32 PropertyID() const { return mID; }
inline ECookPreference CookPreference() const { return mCookPreference; }
inline CStructTemplate* Parent() const { return mpParent; } inline CStructTemplate* Parent() const { return mpParent; }
inline CScriptTemplate* ScriptTemplate() const { return mpScriptTemplate; } inline CScriptTemplate* ScriptTemplate() const { return mpScriptTemplate; }
inline CMasterTemplate* MasterTemplate() const { return mpMasterTemplate; } inline CMasterTemplate* MasterTemplate() const { return mpMasterTemplate; }
@ -307,11 +307,10 @@ typedef TNumericalPropertyTemplate<s8, eByteProperty, CByteValue>
typedef TNumericalPropertyTemplate<s16, eShortProperty, CShortValue> TShortTemplate; typedef TNumericalPropertyTemplate<s16, eShortProperty, CShortValue> TShortTemplate;
typedef TNumericalPropertyTemplate<s32, eLongProperty, CLongValue> TLongTemplate; typedef TNumericalPropertyTemplate<s32, eLongProperty, CLongValue> TLongTemplate;
typedef TNumericalPropertyTemplate<float, eFloatProperty, CFloatValue> TFloatTemplate; typedef TNumericalPropertyTemplate<float, eFloatProperty, CFloatValue> TFloatTemplate;
typedef TTypedPropertyTemplate<TString, eStringProperty, CStringValue, false> TStringTemplate;
typedef TTypedPropertyTemplate<CVector3f, eVector3Property, CVector3Value, true> TVector3Template; typedef TTypedPropertyTemplate<CVector3f, eVector3Property, CVector3Value, true> TVector3Template;
typedef TTypedPropertyTemplate<CColor, eColorProperty, CColorValue, true> TColorTemplate; typedef TTypedPropertyTemplate<CColor, eColorProperty, CColorValue, true> 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<CAnimationParameters, eCharacterProperty, CCharacterValue, false> class TCharacterTemplate : public TTypedPropertyTemplate<CAnimationParameters, eCharacterProperty, CCharacterValue, false>
{ {
friend class CTemplateLoader; friend class CTemplateLoader;
@ -326,7 +325,41 @@ public:
IProperty* InstantiateProperty(CPropertyStruct *pParent) 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<TString, eStringProperty, CStringValue, false>
{
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) ); (mAcceptedExtensions == pkFile->mAcceptedExtensions) );
} }
ECookPreference CookPreference() const
{
if (mCookPreference != eNoCookPreference)
return mCookPreference;
else
return eAlwaysCook;
}
bool AcceptsExtension(const TString& rkExtension) bool AcceptsExtension(const TString& rkExtension)
{ {
for (auto it = mAcceptedExtensions.begin(); it != mAcceptedExtensions.end(); it++) for (auto it = mAcceptedExtensions.begin(); it != mAcceptedExtensions.end(); it++)
@ -653,6 +694,22 @@ public:
return false; 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 TString SourceFile() const { return mSourceFile; }
inline bool IsSingleProperty() const { return mIsSingleProperty; } inline bool IsSingleProperty() const { return mIsSingleProperty; }
inline u32 Count() const { return mSubProperties.size(); } inline u32 Count() const { return mSubProperties.size(); }
@ -714,6 +771,14 @@ public:
(CStructTemplate::Matches(pkTemp)) ); (CStructTemplate::Matches(pkTemp)) );
} }
ECookPreference CookPreference()
{
if (mCookPreference != eNoCookPreference)
return mCookPreference;
else
return eAlwaysCook;
}
void SetParam(const TString& rkParamName, const TString& rkValue) void SetParam(const TString& rkParamName, const TString& rkValue)
{ {
if (rkParamName == "element_name") if (rkParamName == "element_name")

View File

@ -8662,7 +8662,7 @@
<property ID="0xC271CFBC" name="Dark Agon Key 1"/> <property ID="0xC271CFBC" name="Dark Agon Key 1"/>
<property ID="0xC271EAF5" name="Unknown"/> <property ID="0xC271EAF5" name="Unknown"/>
<property ID="0xC2784287" name="Unknown"/> <property ID="0xC2784287" name="Unknown"/>
<property ID="0xC27FFA8F" name="CMDL"/> <property ID="0xC27FFA8F" name="Model"/>
<property ID="0xC287B5AF" name="Unknown"/> <property ID="0xC287B5AF" name="Unknown"/>
<property ID="0xC288AE69" name="CMDL"/> <property ID="0xC288AE69" name="CMDL"/>
<property ID="0xC28B285E" name="Unknown"/> <property ID="0xC28B285E" name="Unknown"/>

View File

@ -8,6 +8,9 @@
<should_cook>always</should_cook> <should_cook>always</should_cook>
</property> </property>
<struct ID="0x20091B54" template="Structs/SplineType.xml"/> <struct ID="0x20091B54" template="Structs/SplineType.xml"/>
<property ID="0x00DD86E2" type="color">
<default>1.0, 1.0, 1.0, 1.0</default>
</property>
</properties> </properties>
<states/> <states/>
<messages/> <messages/>

View File

@ -8,7 +8,7 @@
</property> </property>
<struct ID="0x20091B54" template="Structs/SplineType.xml"/> <struct ID="0x20091B54" template="Structs/SplineType.xml"/>
<property ID="0x00DD86E2" type="color"> <property ID="0x00DD86E2" type="color">
<default>1.0, 0.0, 1.0, 1.0</default> <default>1.0, 1.0, 1.0, 1.0</default>
</property> </property>
</properties> </properties>
<states/> <states/>

View File

@ -24,6 +24,16 @@
</property> </property>
</properties> </properties>
</struct> </struct>
<struct ID="0x1FF47DDF" type="multi">
<should_cook>never</should_cook>
<properties>
<property ID="0x18C7396A" type="bool">
<should_cook>always</should_cook>
<default>false</default>
</property>
<property ID="0xBD0B7EDE" type="string"/>
</properties>
</struct>
<struct ID="0x0CF33816" type="multi"> <struct ID="0x0CF33816" type="multi">
<properties> <properties>
<property ID="0x6FA2F8BC" type="bool"> <property ID="0x6FA2F8BC" type="bool">

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<struct name="LayerID" type="single"> <struct name="LayerID" type="single">
<properties> <properties>
<property ID="0x00" name="Layer ID Part 1" type="long"> <property ID="0x00" name="Layer ID 1" type="long">
<default>0</default> <default>0</default>
</property> </property>
<property ID="0x01" name="Layer ID Part 2" type="long"> <property ID="0x01" name="Layer ID 2" type="long">
<default>0</default> <default>0</default>
</property> </property>
<property ID="0x02" name="Layer ID Part 3" type="long"> <property ID="0x02" name="Layer ID 3" type="long">
<default>0</default> <default>0</default>
</property> </property>
<property ID="0x03" name="Layer ID Part 4" type="long"> <property ID="0x03" name="Layer ID 4" type="long">
<default>0</default> <default>0</default>
</property> </property>
</properties> </properties>

View File

@ -2,8 +2,6 @@
<struct name="LayerSwitch" type="single"> <struct name="LayerSwitch" type="single">
<properties> <properties>
<property ID="0x00" name="Area ID" type="file" extensions="UNKN"/> <property ID="0x00" name="Area ID" type="file" extensions="UNKN"/>
<property ID="0x01" name="Layer #" type="long"> <struct ID="0x01" name="Layer ID" template="Structs/LayerID.xml"/>
<default>0</default>
</property>
</properties> </properties>
</struct> </struct>

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<struct name="LayerID" type="single"> <struct name="LayerID" type="single">
<properties> <properties>
<property ID="0x00" name="Layer ID Part 1" type="long"> <property ID="0x00" name="Layer ID 1" type="long">
<default>0</default> <default>0</default>
</property> </property>
<property ID="0x01" name="Layer ID Part 2" type="long"> <property ID="0x01" name="Layer ID 2" type="long">
<default>0</default> <default>0</default>
</property> </property>
<property ID="0x02" name="Layer ID Part 3" type="long"> <property ID="0x02" name="Layer ID 3" type="long">
<default>0</default> <default>0</default>
</property> </property>
<property ID="0x03" name="Layer ID Part 4" type="long"> <property ID="0x03" name="Layer ID 4" type="long">
<default>0</default> <default>0</default>
</property> </property>
</properties> </properties>

View File

@ -2,8 +2,6 @@
<struct name="LayerSwitch" type="single"> <struct name="LayerSwitch" type="single">
<properties> <properties>
<property ID="0x00" name="Area ID" type="file" extensions="UNKN"/> <property ID="0x00" name="Area ID" type="file" extensions="UNKN"/>
<property ID="0x01" name="Layer #" type="long"> <struct ID="0x01" name="Layer ID" template="Structs/LayerID.xml"/>
<default>0</default>
</property>
</properties> </properties>
</struct> </struct>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<struct name="LayerID" type="single">
<properties>
<property ID="0x00" name="Layer ID 1" type="long">
<default>0</default>
</property>
<property ID="0x01" name="Layer ID 2" type="long">
<default>0</default>
</property>
<property ID="0x02" name="Layer ID 3" type="long">
<default>0</default>
</property>
<property ID="0x03" name="Layer ID 4" type="long">
<default>0</default>
</property>
</properties>
</struct>

View File

@ -2,8 +2,6 @@
<struct name="LayerSwitch" type="single"> <struct name="LayerSwitch" type="single">
<properties> <properties>
<property ID="0x00" name="Area ID" type="file" extensions="UNKN"/> <property ID="0x00" name="Area ID" type="file" extensions="UNKN"/>
<property ID="0x01" name="Layer #" type="long"> <struct ID="0x01" name="Layer ID" template="Structs/LayerID.xml"/>
<default>0</default>
</property>
</properties> </properties>
</struct> </struct>