Fixed doors not rendering correctly, fixed array properties not displaying correctly, fixed crashes when accessing certain property types

This commit is contained in:
Aruki 2018-09-22 12:18:39 -06:00
parent 2118bbd0cd
commit e68b961a8c
7 changed files with 33 additions and 13 deletions

View File

@ -340,21 +340,33 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
}
else
{
pArray->mpItemArchetype = IPropertyNew::Create(EPropertyTypeNew::Struct, mGame);
pStruct = TPropCast<CStructPropertyNew>(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<CStructPropertyNew>(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);
}

View File

@ -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();

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -27,7 +27,7 @@ public:
{
if (Index.isValid())
{
ASSERT(mpModel != nullptr);
ASSERT(pModel != nullptr);
mpModel = pModel;
}
}

View File

@ -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 ************