mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-14 15:46:17 +00:00
Tweak templates for MP2, MP3, and DKCR
This commit is contained in:
@@ -106,7 +106,8 @@ struct SNameValue
|
||||
bool IsValid;
|
||||
|
||||
/** List of all properties using this ID */
|
||||
std::list<IProperty*> PropertyList;
|
||||
/** @todo - make this an intrusively linked list */
|
||||
std::set<IProperty*> PropertyList;
|
||||
|
||||
void Serialize(IArchive& Arc)
|
||||
{
|
||||
@@ -285,7 +286,7 @@ bool IsValidPropertyID(uint32 ID, const char* pkTypeName, bool* pOutIsValid /*=
|
||||
}
|
||||
|
||||
/** Retrieves a list of all properties that match the requested property ID. */
|
||||
void RetrievePropertiesWithID(uint32 ID, const char* pkTypeName, std::list<IProperty*>& OutList)
|
||||
void RetrievePropertiesWithID(uint32 ID, const char* pkTypeName, std::vector<IProperty*>& OutList)
|
||||
{
|
||||
SNameKey Key = CreateKey(ID, pkTypeName);
|
||||
auto MapFind = gNameMap.find(Key);
|
||||
@@ -293,7 +294,12 @@ void RetrievePropertiesWithID(uint32 ID, const char* pkTypeName, std::list<IProp
|
||||
if (MapFind != gNameMap.end())
|
||||
{
|
||||
SNameValue& Value = MapFind->second;
|
||||
OutList = Value.PropertyList;
|
||||
OutList.reserve(Value.PropertyList.size());
|
||||
|
||||
for (auto Iter = Value.PropertyList.begin(); Iter != Value.PropertyList.end(); Iter++)
|
||||
{
|
||||
OutList.push_back(*Iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +397,7 @@ void ChangeTypeName(IProperty* pProperty, const char* pkOldTypeName, const char*
|
||||
if (Find != gNameMap.end())
|
||||
{
|
||||
SNameValue& Value = Find->second;
|
||||
WasRegistered = NBasics::ListRemoveOne(Value.PropertyList, pProperty);
|
||||
WasRegistered = (Value.PropertyList.find(pProperty) != Value.PropertyList.end());
|
||||
}
|
||||
|
||||
// Create a key for the new property and add it to the list.
|
||||
@@ -409,7 +415,7 @@ void ChangeTypeName(IProperty* pProperty, const char* pkOldTypeName, const char*
|
||||
|
||||
if (WasRegistered)
|
||||
{
|
||||
Find->second.PropertyList.push_back(pProperty);
|
||||
Find->second.PropertyList.insert(pProperty);
|
||||
}
|
||||
|
||||
gMapIsDirty = true;
|
||||
@@ -527,7 +533,7 @@ void RegisterProperty(IProperty* pProperty)
|
||||
pProperty->SetName( MapFind->second.Name );
|
||||
}
|
||||
|
||||
MapFind->second.PropertyList.push_back(pProperty);
|
||||
MapFind->second.PropertyList.insert(pProperty);
|
||||
|
||||
// Update the property's Name field to match the mapped name.
|
||||
pProperty->SetName( MapFind->second.Name );
|
||||
@@ -543,7 +549,7 @@ void UnregisterProperty(IProperty* pProperty)
|
||||
{
|
||||
// Found the value, now remove the element from the list.
|
||||
SNameValue& Value = Iter->second;
|
||||
NBasics::ListRemoveOne(Value.PropertyList, pProperty);
|
||||
Value.PropertyList.erase(pProperty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ uint32 CalculatePropertyID(const char* pkName, const char* pkTypeName);
|
||||
bool IsValidPropertyID(uint32 ID, const char* pkTypeName, bool* pOutIsValid = nullptr);
|
||||
|
||||
/** Retrieves a list of all properties that match the requested property ID. */
|
||||
void RetrievePropertiesWithID(uint32 ID, const char* pkTypeName, std::list<IProperty*>& OutList);
|
||||
void RetrievePropertiesWithID(uint32 ID, const char* pkTypeName, std::vector<IProperty*>& OutList);
|
||||
|
||||
/** Retrieves a list of all XML templates that contain a given property ID. */
|
||||
void RetrieveXMLsWithProperty(uint32 ID, const char* pkTypeName, std::set<TString>& OutSet);
|
||||
|
||||
@@ -69,9 +69,9 @@ public:
|
||||
// Skip TSerializeableTypedProperty, serialize default value ourselves so we can set SH_HexDisplay
|
||||
TTypedProperty::Serialize(rArc);
|
||||
|
||||
// Serialize default value
|
||||
TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(mpArchetype);
|
||||
uint32 DefaultValueFlags = SH_HexDisplay | (pArchetype || Game() <= EGame::Prime ? SH_Optional : 0);
|
||||
|
||||
uint32 DefaultValueFlags = SH_Optional | (TypeEnum == EPropertyType::Enum ? SH_HexDisplay : 0);
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue, DefaultValueFlags, pArchetype ? pArchetype->mDefaultValue : 0);
|
||||
|
||||
// Only serialize type name override for root archetypes.
|
||||
|
||||
@@ -69,6 +69,14 @@ void CStructProperty::RevertToDefault(void* pData) const
|
||||
}
|
||||
}
|
||||
|
||||
void CStructProperty::SetDefaultFromData(void* pData)
|
||||
{
|
||||
for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
||||
{
|
||||
mChildren[ChildIdx]->SetDefaultFromData(pData);
|
||||
}
|
||||
}
|
||||
|
||||
const char* CStructProperty::HashableTypeName() const
|
||||
{
|
||||
return mpArchetype ? mpArchetype->HashableTypeName() : *mName;
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
virtual void Destruct(void* pData) const;
|
||||
virtual bool MatchesDefault(void* pData) const;
|
||||
virtual void RevertToDefault(void* pData) const;
|
||||
virtual void SetDefaultFromData(void* pData);
|
||||
virtual const char* HashableTypeName() const;
|
||||
virtual void Serialize(IArchive& rArc);
|
||||
virtual void SerializeValue(void* pData, IArchive& Arc) const;
|
||||
|
||||
@@ -177,6 +177,7 @@ public:
|
||||
virtual void PostInitialize() {}
|
||||
virtual void PropertyValueChanged(void* pPropertyData) {}
|
||||
virtual void CopyDefaultValueTo(IProperty* pOtherProperty) {}
|
||||
virtual void SetDefaultFromData(void* pData) {}
|
||||
virtual bool IsNumericalType() const { return false; }
|
||||
virtual bool IsPointerType() const { return false; }
|
||||
virtual TString ValueAsString(void* pData) const { return ""; }
|
||||
@@ -366,6 +367,7 @@ public:
|
||||
virtual void Destruct(void* pData) const { ValueRef(pData).~PropType(); }
|
||||
virtual bool MatchesDefault(void* pData) const { return ValueRef(pData) == mDefaultValue; }
|
||||
virtual void RevertToDefault(void* pData) const { ValueRef(pData) = mDefaultValue; }
|
||||
virtual void SetDefaultFromData(void* pData) { mDefaultValue = ValueRef(pData); MarkDirty(); }
|
||||
|
||||
virtual bool CanHaveDefault() const { return true; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user