From e68b961a8c09a00500b9978abf6ae78906c2694d Mon Sep 17 00:00:00 2001 From: Aruki Date: Sat, 22 Sep 2018 12:18:39 -0600 Subject: [PATCH] Fixed doors not rendering correctly, fixed array properties not displaying correctly, fixed crashes when accessing certain property types --- src/Core/Resource/Factory/CTemplateLoader.cpp | 22 ++++++++++++++----- src/Core/Resource/Script/IPropertyNew.cpp | 8 +++---- src/Core/ScriptExtra/CDoorExtra.cpp | 5 +++++ src/Editor/PropertyEdit/CPropertyDelegate.cpp | 2 +- src/Editor/PropertyEdit/CPropertyModel.cpp | 2 +- src/Editor/Undo/CResizeScriptArrayCommand.h | 2 +- src/Math/CVector3f.cpp | 5 ++++- 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/Core/Resource/Factory/CTemplateLoader.cpp b/src/Core/Resource/Factory/CTemplateLoader.cpp index e29d79c9..0453fb48 100644 --- a/src/Core/Resource/Factory/CTemplateLoader.cpp +++ b/src/Core/Resource/Factory/CTemplateLoader.cpp @@ -340,21 +340,33 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate* } else { - pArray->mpItemArchetype = IPropertyNew::Create(EPropertyTypeNew::Struct, mGame); - pStruct = TPropCast(pArray->mpItemArchetype); - pStruct->mFlags = EPropertyFlag::IsAtomic | EPropertyFlag::IsArrayArchetype; + if (Name == "Activation Times") + { + CFloatProperty* pFloatItem = (CFloatProperty*) IPropertyNew::Create(EPropertyTypeNew::Float, mGame); + pFloatItem->mName = "Time"; + pFloatItem->mID = 0; + pFloatItem->mDefaultValue = 0.0f; + pFloatItem->mFlags = EPropertyFlag::IsArrayArchetype; + pArray->mpItemArchetype = pFloatItem; + } + else + { + pArray->mpItemArchetype = IPropertyNew::Create(EPropertyTypeNew::Struct, mGame); + pStruct = TPropCast(pArray->mpItemArchetype); + pStruct->mFlags = EPropertyFlag::IsAtomic | EPropertyFlag::IsArrayArchetype; + } } XMLElement* pItemNameElem = pElem->FirstChildElement("element_name"); - if (pItemNameElem) + if (pStruct && pItemNameElem) pStruct->mName = pItemNameElem->GetText(); } // Load parameter overrides XMLElement *pProperties = pElem->FirstChildElement("properties"); - if (pProperties) + if (pStruct && pProperties) { LoadProperties(pProperties, pScript, pStruct, rkTemplateName); } diff --git a/src/Core/Resource/Script/IPropertyNew.cpp b/src/Core/Resource/Script/IPropertyNew.cpp index df9bc29e..022dcb5e 100644 --- a/src/Core/Resource/Script/IPropertyNew.cpp +++ b/src/Core/Resource/Script/IPropertyNew.cpp @@ -89,7 +89,7 @@ void IPropertyNew::Serialize(IArchive& rArc) // // We can't currently tell if this property is atomic, as the flag hasn't been serialized and the parent // hasn't been set, but atomic sub-properties don't use hash IDs, so we can do a pseudo-check against the ID. - if (rArc.Game() <= ePrime || IsRootParent() || mID <= 0xFF) + if (rArc.Game() <= ePrime || IsRootParent() || IsArrayArchetype() || mID <= 0xFF) { rArc << SerialParameter("Name", mName, mpArchetype ? SH_Optional : 0, mpArchetype ? mpArchetype->mName : ""); } @@ -162,7 +162,7 @@ void IPropertyNew::Initialize(IPropertyNew* pInParent, CScriptTemplate* pInTempl mpScriptTemplate = pInTemplate; // Look up property name if needed. - if (Game() >= eEchoesDemo && !IsRootParent() && !IsIntrinsic() && !mpParent->IsAtomic()) + if (Game() >= eEchoesDemo && !IsRootParent() && !IsIntrinsic() && !mpParent->IsAtomic() && !IsArrayArchetype()) { mName = CMasterTemplate::PropertyName(mID); } @@ -301,8 +301,8 @@ bool IPropertyNew::HasAccurateName() if (mID == FOURCC('XFRM') || mID == FOURCC('INAM') || mID == FOURCC('ACTV')) return true; - // Children of atomic properties defer to parents. Intrinsic properties also defer to parents. - if ( (mpParent && mpParent->IsAtomic()) || IsIntrinsic() ) + // Children of atomic properties defer to parents. Intrinsic properties and array archetypes also defer to parents. + if ( (mpParent && mpParent->IsAtomic()) || IsIntrinsic() || IsArrayArchetype() ) { if (mpParent) return mpParent->HasAccurateName(); diff --git a/src/Core/ScriptExtra/CDoorExtra.cpp b/src/Core/ScriptExtra/CDoorExtra.cpp index 82ab8214..919a4b23 100644 --- a/src/Core/ScriptExtra/CDoorExtra.cpp +++ b/src/Core/ScriptExtra/CDoorExtra.cpp @@ -37,6 +37,11 @@ void CDoorExtra::PropertyModified(IPropertyNew* pProperty) MarkTransformChanged(); } + else if (pProperty == mShieldColorProp) + { + mShieldColor = mShieldColorProp.Get(); + } + else if (pProperty == mDisabledProp) { // The Echoes demo doesn't have the shield color property. The color is diff --git a/src/Editor/PropertyEdit/CPropertyDelegate.cpp b/src/Editor/PropertyEdit/CPropertyDelegate.cpp index 1e78e3ec..fe052e43 100644 --- a/src/Editor/PropertyEdit/CPropertyDelegate.cpp +++ b/src/Editor/PropertyEdit/CPropertyDelegate.cpp @@ -163,7 +163,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie } } - // Check for sub-property of flgs/animation set + // Check for sub-property of flags/animation set else if (rkIndex.internalId() & 0x80000000) { pProp = mpModel->PropertyForIndex(rkIndex, true); diff --git a/src/Editor/PropertyEdit/CPropertyModel.cpp b/src/Editor/PropertyEdit/CPropertyModel.cpp index 8999d717..fba7a103 100644 --- a/src/Editor/PropertyEdit/CPropertyModel.cpp +++ b/src/Editor/PropertyEdit/CPropertyModel.cpp @@ -136,7 +136,7 @@ QModelIndex CPropertyModel::IndexForProperty(IPropertyNew *pProp) const void* CPropertyModel::DataPointerForIndex(const QModelIndex& rkIndex) const { // Going to be the base pointer in 99% of cases, but we need to account for arrays in some cases - int ID = rkIndex.internalId(); + int ID = rkIndex.internalId() & ~0x80000000; if (!mProperties[ID].pProperty->IsArrayArchetype()) return mpPropertyData; diff --git a/src/Editor/Undo/CResizeScriptArrayCommand.h b/src/Editor/Undo/CResizeScriptArrayCommand.h index 375ce649..4352b6b9 100644 --- a/src/Editor/Undo/CResizeScriptArrayCommand.h +++ b/src/Editor/Undo/CResizeScriptArrayCommand.h @@ -27,7 +27,7 @@ public: { if (Index.isValid()) { - ASSERT(mpModel != nullptr); + ASSERT(pModel != nullptr); mpModel = pModel; } } diff --git a/src/Math/CVector3f.cpp b/src/Math/CVector3f.cpp index 19ac0bbc..6130daa4 100644 --- a/src/Math/CVector3f.cpp +++ b/src/Math/CVector3f.cpp @@ -45,7 +45,10 @@ void CVector3f::Serialize(IArchive& rArc) TString CVector3f::ToString() const { - return TString::Format("%.1f, %.1f, %.1f", X, Y, Z); + return TString::Format("%s, %s, %s", + *TString::FromFloat(X), + *TString::FromFloat(Y), + *TString::FromFloat(Z)); } // ************ SWIZZLE ************