mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 17:05:37 +00:00
Added "support" for MayaSpline properties
This commit is contained in:
@@ -92,6 +92,14 @@ void CScriptCooker::WriteProperty(IProperty *pProp)
|
||||
break;
|
||||
}
|
||||
|
||||
case eMayaSplineProperty:
|
||||
{
|
||||
TMayaSplineProperty *pSplineCast = static_cast<TMayaSplineProperty*>(pProp);
|
||||
std::vector<u8> Buffer = pSplineCast->Get();
|
||||
mpSCLY->WriteBytes(Buffer.data(), Buffer.size());
|
||||
break;
|
||||
}
|
||||
|
||||
case eStructProperty:
|
||||
case eArrayProperty:
|
||||
{
|
||||
|
||||
@@ -146,6 +146,14 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& SCLY)
|
||||
break;
|
||||
}
|
||||
|
||||
case eMayaSplineProperty: {
|
||||
TMayaSplineProperty *pSplineCast = static_cast<TMayaSplineProperty*>(pProp);
|
||||
std::vector<u8> Buffer(Size);
|
||||
SCLY.ReadBytes(Buffer.data(), Buffer.size());
|
||||
pSplineCast->Set(Buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
case eUnknownProperty: {
|
||||
TUnknownProperty *pUnknownCast = static_cast<TUnknownProperty*>(pProp);
|
||||
std::vector<u8> Buffer(Size);
|
||||
|
||||
@@ -176,20 +176,21 @@ IPropertyTemplate* CTemplateLoader::CreateProperty(u32 ID, EPropertyType Type, c
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case eBoolProperty: pOut = CREATE_PROP_TEMP(TBoolTemplate); break;
|
||||
case eByteProperty: pOut = CREATE_PROP_TEMP(TByteTemplate); break;
|
||||
case eShortProperty: pOut = CREATE_PROP_TEMP(TShortTemplate); break;
|
||||
case eLongProperty: pOut = CREATE_PROP_TEMP(TLongTemplate); break;
|
||||
case eFloatProperty: pOut = CREATE_PROP_TEMP(TFloatTemplate); break;
|
||||
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 eCharacterProperty: pOut = CREATE_PROP_TEMP(TCharacterTemplate); break;
|
||||
case eEnumProperty: pOut = CREATE_PROP_TEMP(CEnumTemplate); break;
|
||||
case eBitfieldProperty: pOut = CREATE_PROP_TEMP(CBitfieldTemplate); break;
|
||||
case eArrayProperty: pOut = CREATE_PROP_TEMP(CArrayTemplate); break;
|
||||
case eStructProperty: pOut = CREATE_PROP_TEMP(CStructTemplate); break;
|
||||
case eBoolProperty: pOut = CREATE_PROP_TEMP(TBoolTemplate); break;
|
||||
case eByteProperty: pOut = CREATE_PROP_TEMP(TByteTemplate); break;
|
||||
case eShortProperty: pOut = CREATE_PROP_TEMP(TShortTemplate); break;
|
||||
case eLongProperty: pOut = CREATE_PROP_TEMP(TLongTemplate); break;
|
||||
case eFloatProperty: pOut = CREATE_PROP_TEMP(TFloatTemplate); break;
|
||||
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 eCharacterProperty: pOut = CREATE_PROP_TEMP(TCharacterTemplate); break;
|
||||
case eMayaSplineProperty: pOut = CREATE_PROP_TEMP(TMayaSplineTemplate); break;
|
||||
case eEnumProperty: pOut = CREATE_PROP_TEMP(CEnumTemplate); break;
|
||||
case eBitfieldProperty: pOut = CREATE_PROP_TEMP(CBitfieldTemplate); break;
|
||||
case eArrayProperty: pOut = CREATE_PROP_TEMP(CArrayTemplate); break;
|
||||
case eStructProperty: pOut = CREATE_PROP_TEMP(CStructTemplate); break;
|
||||
}
|
||||
|
||||
if (pOut)
|
||||
|
||||
@@ -19,13 +19,14 @@ enum EPropertyType
|
||||
eStructProperty,
|
||||
eArrayProperty,
|
||||
eCharacterProperty,
|
||||
eMayaSplineProperty,
|
||||
eUnknownProperty,
|
||||
eInvalidProperty
|
||||
};
|
||||
|
||||
// functions defined in CScriptTemplate.cpp
|
||||
EPropertyType PropStringToPropEnum(const TString& prop);
|
||||
TString PropEnumToPropString(EPropertyType prop);
|
||||
// functions defined in IPropertyTemplate.cpp
|
||||
EPropertyType PropStringToPropEnum(TString Prop);
|
||||
TString PropEnumToPropString(EPropertyType Prop);
|
||||
|
||||
#endif // EPROPERTYTYPE
|
||||
|
||||
|
||||
@@ -151,6 +151,18 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class TMayaSplineProperty : public TTypedProperty<std::vector<u8>, eMayaSplineProperty, CMayaSplineValue>
|
||||
{
|
||||
public:
|
||||
TMayaSplineProperty(IPropertyTemplate *pTemp, CPropertyStruct *pParent)
|
||||
: TTypedProperty(pTemp, pParent) {}
|
||||
|
||||
TMayaSplineProperty(IPropertyTemplate *pTemp, CPropertyStruct *pParent, const std::vector<u8>& v)
|
||||
: TTypedProperty(pTemp, pParent, v) {}
|
||||
|
||||
virtual bool MatchesDefault() { return true; }
|
||||
};
|
||||
|
||||
/*
|
||||
* CPropertyStruct is for defining structs of properties.
|
||||
*/
|
||||
|
||||
@@ -215,9 +215,9 @@ void CStructTemplate::DetermineVersionPropertyCounts()
|
||||
}
|
||||
|
||||
// ************ GLOBAL FUNCTIONS ************
|
||||
TString PropEnumToPropString(EPropertyType prop)
|
||||
TString PropEnumToPropString(EPropertyType Prop)
|
||||
{
|
||||
switch (prop)
|
||||
switch (Prop)
|
||||
{
|
||||
case eBoolProperty: return "bool";
|
||||
case eByteProperty: return "byte";
|
||||
@@ -233,6 +233,7 @@ TString PropEnumToPropString(EPropertyType prop)
|
||||
case eStructProperty: return "struct";
|
||||
case eArrayProperty: return "array";
|
||||
case eCharacterProperty: return "character";
|
||||
case eMayaSplineProperty: return "MayaSpline";
|
||||
case eUnknownProperty: return "unknown";
|
||||
|
||||
case eInvalidProperty:
|
||||
@@ -241,23 +242,25 @@ TString PropEnumToPropString(EPropertyType prop)
|
||||
}
|
||||
}
|
||||
|
||||
EPropertyType PropStringToPropEnum(const TString& rkProp)
|
||||
EPropertyType PropStringToPropEnum(TString Prop)
|
||||
{
|
||||
if (rkProp == "bool") return eBoolProperty;
|
||||
if (rkProp == "byte") return eByteProperty;
|
||||
if (rkProp == "short") return eShortProperty;
|
||||
if (rkProp == "long") return eLongProperty;
|
||||
if (rkProp == "enum") return eEnumProperty;
|
||||
if (rkProp == "bitfield") return eBitfieldProperty;
|
||||
if (rkProp == "float") return eFloatProperty;
|
||||
if (rkProp == "string") return eStringProperty;
|
||||
if (rkProp == "color") return eColorProperty;
|
||||
if (rkProp == "vector3f") return eVector3Property;
|
||||
if (rkProp == "file") return eFileProperty;
|
||||
if (rkProp == "struct") return eStructProperty;
|
||||
if (rkProp == "array") return eArrayProperty;
|
||||
if (rkProp == "character") return eCharacterProperty;
|
||||
if (rkProp == "unknown") return eUnknownProperty;
|
||||
Prop = Prop.ToLower();
|
||||
if (Prop == "bool") return eBoolProperty;
|
||||
if (Prop == "byte") return eByteProperty;
|
||||
if (Prop == "short") return eShortProperty;
|
||||
if (Prop == "long") return eLongProperty;
|
||||
if (Prop == "enum") return eEnumProperty;
|
||||
if (Prop == "bitfield") return eBitfieldProperty;
|
||||
if (Prop == "float") return eFloatProperty;
|
||||
if (Prop == "string") return eStringProperty;
|
||||
if (Prop == "color") return eColorProperty;
|
||||
if (Prop == "vector3f") return eVector3Property;
|
||||
if (Prop == "file") return eFileProperty;
|
||||
if (Prop == "struct") return eStructProperty;
|
||||
if (Prop == "array") return eArrayProperty;
|
||||
if (Prop == "character") return eCharacterProperty;
|
||||
if (Prop == "mayaspline") return eMayaSplineProperty;
|
||||
if (Prop == "unknown") return eUnknownProperty;
|
||||
return eInvalidProperty;
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +310,43 @@ typedef TNumericalPropertyTemplate<float, eFloatProperty, CFloatValue>
|
||||
typedef TTypedPropertyTemplate<TString, eStringProperty, CStringValue, false> TStringTemplate;
|
||||
typedef TTypedPropertyTemplate<CVector3f, eVector3Property, CVector3Value, true> TVector3Template;
|
||||
typedef TTypedPropertyTemplate<CColor, eColorProperty, CColorValue, true> TColorTemplate;
|
||||
typedef TTypedPropertyTemplate<CAnimationParameters, eCharacterProperty, CCharacterValue, false> TCharacterTemplate;
|
||||
|
||||
// TCharacterTemplate and TMayaSplineTemplate - quick subclasses in order to reimplement InstantiateProperty
|
||||
class TCharacterTemplate : public TTypedPropertyTemplate<CAnimationParameters, eCharacterProperty, CCharacterValue, false>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
public:
|
||||
TCharacterTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, pScript, pMaster, pParent) {}
|
||||
|
||||
TCharacterTemplate(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 TCharacterProperty(this, pParent);
|
||||
}
|
||||
};
|
||||
|
||||
class TMayaSplineTemplate : public TTypedPropertyTemplate<std::vector<u8>, eMayaSplineProperty, CMayaSplineValue, false>
|
||||
{
|
||||
friend class CTemplateLoader;
|
||||
friend class CTemplateWriter;
|
||||
|
||||
public:
|
||||
TMayaSplineTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, pScript, pMaster, pParent) {}
|
||||
|
||||
TMayaSplineTemplate(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 TMayaSplineProperty(this, pParent);
|
||||
}
|
||||
};
|
||||
|
||||
// CFileTemplate - Property template for files. Tracks a list of file types that
|
||||
// the property is allowed to accept.
|
||||
|
||||
@@ -327,6 +327,21 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CMayaSplineValue : public TTypedPropertyValue<std::vector<u8>>
|
||||
{
|
||||
public:
|
||||
CMayaSplineValue() {}
|
||||
CMayaSplineValue(const std::vector<u8>& rkData) { mValue = rkData; }
|
||||
|
||||
TString ToString() const { return "[MayaSpline]"; }
|
||||
void FromString(const TString&) {}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
return new CMayaSplineValue(mValue);
|
||||
}
|
||||
};
|
||||
|
||||
class CFileValue : public TTypedPropertyValue<CResourceInfo>
|
||||
{
|
||||
public:
|
||||
@@ -334,7 +349,7 @@ public:
|
||||
CFileValue(const CResourceInfo& rkInfo) { mValue = rkInfo; }
|
||||
|
||||
TString ToString() const { return ""; }
|
||||
void FromString(const TString&) { }
|
||||
void FromString(const TString&) {}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
{
|
||||
|
||||
@@ -309,6 +309,10 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
|
||||
return QString("%1 element%2").arg(Count).arg(Count != 1 ? "s" : "");
|
||||
}
|
||||
|
||||
// Display "[MayaSpline]" for MayaSplines (todo: proper support)
|
||||
case eMayaSplineProperty:
|
||||
return "[MayaSpline]";
|
||||
|
||||
// No display text on properties with persistent editors
|
||||
case eBoolProperty:
|
||||
case eFileProperty:
|
||||
@@ -342,6 +346,11 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
|
||||
// Add description
|
||||
TString Desc = pProp->Template()->Description();
|
||||
if (!Desc.IsEmpty()) Text += "<br/>" + TO_QSTRING(Desc);
|
||||
|
||||
// MayaSpline notification
|
||||
if (pProp->Type() == eMayaSplineProperty)
|
||||
Text += "<br/><i>(NOTE: MayaSpline properties are currently unsupported for editing)</i>";
|
||||
|
||||
return Text;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user