mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-14 23:56:23 +00:00
Fixed array property display on UI (they still can't be resized)
This commit is contained in:
@@ -152,10 +152,8 @@ TString IPropertyNew::GetTemplateFileName()
|
||||
void* IPropertyNew::RawValuePtr(void* pData) const
|
||||
{
|
||||
// For array archetypes, the caller needs to provide the pointer to the correct array item
|
||||
if (IsArrayArchetype())
|
||||
return pData;
|
||||
|
||||
void* pBasePtr = (mpPointerParent ? mpPointerParent->GetChildDataPointer(pData) : pData);
|
||||
// Array archetypes can't store their index in the array so it's impossible to determine the correct pointer.
|
||||
void* pBasePtr = (mpPointerParent && !IsArrayArchetype() ? mpPointerParent->GetChildDataPointer(pData) : pData);
|
||||
void* pValuePtr = ((char*)pBasePtr + mOffset);
|
||||
return pValuePtr;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ inline const char* PropEnumToHashableTypeName(EPropertyTypeNew Type)
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
// these names are required to generate accurate property ID hashes
|
||||
case EPropertyTypeNew::Bool: return "bool";
|
||||
case EPropertyTypeNew::Int: return "int";
|
||||
case EPropertyTypeNew::Float: return "float";
|
||||
@@ -85,6 +86,14 @@ inline const char* PropEnumToHashableTypeName(EPropertyTypeNew Type)
|
||||
case EPropertyTypeNew::Sound: return "sound";
|
||||
case EPropertyTypeNew::Spline: return "spline";
|
||||
case EPropertyTypeNew::Guid: return "guid";
|
||||
// unknown hashable types - used in hashes but these names are inaccurate
|
||||
case EPropertyTypeNew::Animation: return "animation"; // hashable but real name unknown
|
||||
case EPropertyTypeNew::Sequence: return "sequence";
|
||||
// non hashable types - not used in ID hashes but still displayed on the UI
|
||||
case EPropertyTypeNew::Byte: return "byte";
|
||||
case EPropertyTypeNew::Short: return "short";
|
||||
case EPropertyTypeNew::Array: return "array";
|
||||
// fallback
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ public:
|
||||
{
|
||||
Value(pData).Serialize(Arc);
|
||||
}
|
||||
|
||||
virtual const char* HashableTypeName() const
|
||||
{
|
||||
return (Game() <= eEchoes ? "AnimationSet" : "CharacterAnimationSet");
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CANIMATIONSETPROPERTY_H
|
||||
|
||||
@@ -22,7 +22,9 @@ struct SScriptArray
|
||||
/** @todo proper support of default values for arrays (this would be used for prefabs) */
|
||||
class CArrayProperty : public TTypedPropertyNew<int, EPropertyTypeNew::Array>
|
||||
{
|
||||
friend class IPropertyNew;
|
||||
friend class CTemplateLoader;
|
||||
|
||||
/** This class inherits from TTypedPropertyNew<int> in order to expose the array
|
||||
* count value (the first member of SScriptArray). Outside users can edit this
|
||||
* value and we respond by updating the allocated space, handling item destruction
|
||||
@@ -42,6 +44,12 @@ class CArrayProperty : public TTypedPropertyNew<int, EPropertyTypeNew::Array>
|
||||
return rArray.size() / ItemSize();
|
||||
}
|
||||
|
||||
protected:
|
||||
CArrayProperty()
|
||||
: TTypedPropertyNew()
|
||||
, mpItemArchetype(nullptr)
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual u32 DataSize() const
|
||||
{
|
||||
@@ -110,7 +118,7 @@ public:
|
||||
if (Arc.ParamBegin("ArrayElement"))
|
||||
{
|
||||
void* pItemData = ItemPointer(pData, ItemIdx);
|
||||
mpArchetype->SerializeValue(pItemData, Arc);
|
||||
mpItemArchetype->SerializeValue(pItemData, Arc);
|
||||
Arc.ParamEnd();
|
||||
}
|
||||
}
|
||||
@@ -148,6 +156,7 @@ public:
|
||||
|
||||
u32 NewSize = NewCount * ItemSize();
|
||||
rArray.Array.resize(NewSize);
|
||||
rArray.Count = NewCount;
|
||||
|
||||
// Handle construction of new elements
|
||||
if (NewCount > OldCount)
|
||||
@@ -163,7 +172,7 @@ public:
|
||||
|
||||
void* ItemPointer(void* pPropertyData, u32 ItemIndex) const
|
||||
{
|
||||
ASSERT(ArrayCount(pPropertyData) > ItemIndex);
|
||||
ASSERT(_InternalArrayCount(pPropertyData) > ItemIndex);
|
||||
std::vector<char>& rArray = _GetInternalArray(pPropertyData).Array;
|
||||
u32 MyItemSize = ItemSize();
|
||||
ASSERT(rArray.size() >= (MyItemSize * (ItemIndex+1)));
|
||||
@@ -178,7 +187,7 @@ public:
|
||||
}
|
||||
|
||||
/** Accessors */
|
||||
IPropertyNew* ArchetypeProperty() const { return mpArchetype; }
|
||||
IPropertyNew* ItemArchetype() const { return mpItemArchetype; }
|
||||
};
|
||||
|
||||
#endif // CARRAYPROPERTY_H
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
Arc.SerializePrimitive( (u8&) ValueRef(pData) );
|
||||
}
|
||||
|
||||
virtual TString ValueAsString(void* pData)
|
||||
virtual TString ValueAsString(void* pData) const
|
||||
{
|
||||
return TString::FromInt32( (s32) Value(pData), 0, 10 );
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
Arc.SerializePrimitive( (u16&) ValueRef(pData) );
|
||||
}
|
||||
|
||||
virtual TString ValueAsString(void* pData)
|
||||
virtual TString ValueAsString(void* pData) const
|
||||
{
|
||||
return TString::FromInt32( (s32) Value(pData), 0, 10 );
|
||||
}
|
||||
|
||||
@@ -81,12 +81,10 @@ public:
|
||||
|
||||
virtual const char* HashableTypeName() const
|
||||
{
|
||||
ASSERT(IsArchetype() || mpArchetype != nullptr);
|
||||
|
||||
if (IsArchetype())
|
||||
if (IsArchetype() || !mpArchetype)
|
||||
return *mName;
|
||||
else
|
||||
return *mpArchetype->Name();
|
||||
return mpArchetype->HashableTypeName();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
Reference in New Issue
Block a user