mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-14 23:56:23 +00:00
Various property cleanup, fixing more broken stuff, trialing new features
This commit is contained in:
@@ -17,15 +17,17 @@ CScriptObject::CScriptObject(u32 InstanceID, CGameArea *pArea, CScriptLayer *pLa
|
||||
// Init properties
|
||||
CStructPropertyNew* pProperties = pTemplate->Properties();
|
||||
u32 PropertiesSize = pProperties->DataSize();
|
||||
mPropertyData.resize( PropertiesSize );
|
||||
pProperties->Construct( mPropertyData.data() );
|
||||
|
||||
mInstanceName = CStringRef(this, pTemplate->NameProperty());
|
||||
mPosition = CVectorRef(this, pTemplate->PositionProperty());
|
||||
mRotation = CVectorRef(this, pTemplate->RotationProperty());
|
||||
mScale = CVectorRef(this, pTemplate->ScaleProperty());
|
||||
mActive = CBoolRef(this, pTemplate->ActiveProperty());
|
||||
mLightParameters = CStructRef(this, pTemplate->LightParametersProperty());
|
||||
mPropertyData.resize( PropertiesSize );
|
||||
void* pData = mPropertyData.data();
|
||||
pProperties->Construct( pData );
|
||||
|
||||
mInstanceName = CStringRef(pData, pTemplate->NameProperty());
|
||||
mPosition = CVectorRef(pData, pTemplate->PositionProperty());
|
||||
mRotation = CVectorRef(pData, pTemplate->RotationProperty());
|
||||
mScale = CVectorRef(pData, pTemplate->ScaleProperty());
|
||||
mActive = CBoolRef(pData, pTemplate->ActiveProperty());
|
||||
mLightParameters = CStructRef(pData, pTemplate->LightParametersProperty());
|
||||
}
|
||||
|
||||
CScriptObject::~CScriptObject()
|
||||
|
||||
@@ -255,12 +255,12 @@ bool IPropertyNew::HasAccurateName()
|
||||
/** IPropertyNew Accessors */
|
||||
EGame IPropertyNew::Game() const
|
||||
{
|
||||
return mpMasterTemplate->Game();
|
||||
return mGame;
|
||||
}
|
||||
|
||||
IPropertyNew* IPropertyNew::Create(EPropertyTypeNew Type,
|
||||
IPropertyNew* pParent,
|
||||
CMasterTemplate* pMaster,
|
||||
EGame Game,
|
||||
CScriptTemplate* pScript,
|
||||
bool CallPostInit /*= true*/)
|
||||
{
|
||||
@@ -316,7 +316,7 @@ IPropertyNew* IPropertyNew::Create(EPropertyTypeNew Type,
|
||||
}
|
||||
|
||||
// Set other metadata
|
||||
pOut->mpMasterTemplate = pMaster;
|
||||
pOut->mGame = Game;
|
||||
pOut->mpScriptTemplate = pScript;
|
||||
pOut->_CalcOffset();
|
||||
|
||||
@@ -344,8 +344,20 @@ IPropertyNew* IPropertyNew::CreateCopy(IPropertyNew* pArchetype,
|
||||
// always be valid.
|
||||
ASSERT(pParent != nullptr);
|
||||
|
||||
IPropertyNew* pOut = Create(pArchetype->Type(), pParent, pParent->mpMasterTemplate, pParent->mpScriptTemplate, false);
|
||||
IPropertyNew* pOut = Create(pArchetype->Type(), pParent, pParent->mGame, pParent->mpScriptTemplate, false);
|
||||
pOut->InitFromArchetype(pArchetype);
|
||||
pArchetype->mSubInstances.push_back(pOut);
|
||||
return pOut;
|
||||
}
|
||||
|
||||
IPropertyNew* IPropertyNew::CreateIntrinsic(EPropertyTypeNew Type,
|
||||
IPropertyNew* pParent,
|
||||
u32 Offset,
|
||||
const TString& rkName)
|
||||
{
|
||||
IPropertyNew* pOut = Create(Type, pParent, pParent ? pParent->mGame : eUnknownGame, nullptr, false);
|
||||
pOut->mOffset = Offset;
|
||||
pOut->SetName(rkName);
|
||||
pOut->PostInitialize();
|
||||
return pOut;
|
||||
}
|
||||
|
||||
@@ -137,9 +137,8 @@ protected:
|
||||
/** Child properties; these appear underneath this property on the UI */
|
||||
std::vector<IPropertyNew*> mChildren;
|
||||
|
||||
/** Master template for the game this property belongs to.
|
||||
* Cannot be derived from mpScriptTemplate because mpScriptTemplate is null sometimes */
|
||||
CMasterTemplate* mpMasterTemplate;
|
||||
/** Game this property belongs to */
|
||||
EGame mGame;
|
||||
|
||||
/** Script template that this property belongs to. Null for struct/enum/flag archetypes. */
|
||||
CScriptTemplate* mpScriptTemplate;
|
||||
@@ -231,12 +230,17 @@ public:
|
||||
/** Create */
|
||||
static IPropertyNew* Create(EPropertyTypeNew Type,
|
||||
IPropertyNew* pParent,
|
||||
CMasterTemplate* pMaster,
|
||||
EGame Game,
|
||||
CScriptTemplate* pScript,
|
||||
bool CallPostInit = true);
|
||||
|
||||
static IPropertyNew* CreateCopy(IPropertyNew* pArchetype,
|
||||
IPropertyNew* pParent);
|
||||
|
||||
static IPropertyNew* CreateIntrinsic(EPropertyTypeNew Type,
|
||||
IPropertyNew* pParent,
|
||||
u32 Offset,
|
||||
const TString& rkName);
|
||||
};
|
||||
|
||||
inline ECookPreferenceNew IPropertyNew::CookPreference() const
|
||||
@@ -284,11 +288,6 @@ inline CScriptTemplate* IPropertyNew::ScriptTemplate() const
|
||||
return mpScriptTemplate;
|
||||
}
|
||||
|
||||
inline CMasterTemplate* IPropertyNew::MasterTemplate() const
|
||||
{
|
||||
return mpMasterTemplate;
|
||||
}
|
||||
|
||||
inline TString IPropertyNew::Name() const
|
||||
{
|
||||
return mName;
|
||||
|
||||
@@ -15,10 +15,10 @@ protected:
|
||||
public:
|
||||
virtual void PostInitialize()
|
||||
{
|
||||
IPropertyNew* pR = Create(EPropertyTypeNew::Float, this, mpMasterTemplate, mpScriptTemplate);
|
||||
IPropertyNew* pG = Create(EPropertyTypeNew::Float, this, mpMasterTemplate, mpScriptTemplate);
|
||||
IPropertyNew* pB = Create(EPropertyTypeNew::Float, this, mpMasterTemplate, mpScriptTemplate);
|
||||
IPropertyNew* pA = Create(EPropertyTypeNew::Float, this, mpMasterTemplate, mpScriptTemplate);
|
||||
IPropertyNew* pR = Create(EPropertyTypeNew::Float, this, mGame, mpScriptTemplate);
|
||||
IPropertyNew* pG = Create(EPropertyTypeNew::Float, this, mGame, mpScriptTemplate);
|
||||
IPropertyNew* pB = Create(EPropertyTypeNew::Float, this, mGame, mpScriptTemplate);
|
||||
IPropertyNew* pA = Create(EPropertyTypeNew::Float, this, mGame, mpScriptTemplate);
|
||||
pR->SetName("R");
|
||||
pG->SetName("G");
|
||||
pB->SetName("B");
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#include "../IPropertyNew.h"
|
||||
|
||||
/** There are two types of enum properties: in the game data enum and choice.
|
||||
/** There are two types of enum properties in the game data: enum and choice.
|
||||
*
|
||||
* In the game, the difference is that choice properties are index-based, while
|
||||
* enum properties are stored as a hash of the name of the enum.
|
||||
* enum properties are stored as a hash of the name of the enum value.
|
||||
*
|
||||
* In PWE, however, they are both implemented the same way under the hood.
|
||||
*/
|
||||
@@ -59,6 +59,11 @@ public:
|
||||
return IsArchetype() ? mSourceFile : mpArchetype->GetTemplateFileName();
|
||||
}
|
||||
|
||||
void AddValue(TString ValueName, u32 ValueID)
|
||||
{
|
||||
mValues.push_back( SEnumValue(ValueName, ValueID) );
|
||||
}
|
||||
|
||||
inline u32 NumPossibleValues() const { return mValues.size(); }
|
||||
|
||||
u32 ValueIndex(u32 ID) const
|
||||
|
||||
@@ -15,9 +15,9 @@ protected:
|
||||
public:
|
||||
virtual void PostInitialize()
|
||||
{
|
||||
IPropertyNew* pX = Create(EPropertyTypeNew::Float, this, mpMasterTemplate, mpScriptTemplate);
|
||||
IPropertyNew* pY = Create(EPropertyTypeNew::Float, this, mpMasterTemplate, mpScriptTemplate);
|
||||
IPropertyNew* pZ = Create(EPropertyTypeNew::Float, this, mpMasterTemplate, mpScriptTemplate);
|
||||
IPropertyNew* pX = Create(EPropertyTypeNew::Float, this, mGame, mpScriptTemplate);
|
||||
IPropertyNew* pY = Create(EPropertyTypeNew::Float, this, mGame, mpScriptTemplate);
|
||||
IPropertyNew* pZ = Create(EPropertyTypeNew::Float, this, mGame, mpScriptTemplate);
|
||||
pX->SetName("X");
|
||||
pY->SetName("Y");
|
||||
pZ->SetName("Z");
|
||||
|
||||
@@ -22,37 +22,37 @@
|
||||
#include "CStructProperty.h"
|
||||
#include "CVectorProperty.h"
|
||||
|
||||
/** TPropertyRef: Embeds a reference to a property on a specific script object */
|
||||
/** TPropertyRef: Embeds a reference to a property on a specific object */
|
||||
template<class PropertyClass, typename ValueType = PropertyClass::ValueType>
|
||||
class TPropertyRef
|
||||
{
|
||||
/** Script object containing the property data being referenced */
|
||||
CScriptObject* mpObject;
|
||||
/** Property data being referenced */
|
||||
void* mpPropertyData;
|
||||
|
||||
/** Property being referenced */
|
||||
PropertyClass* mpProperty;
|
||||
PropertyClass* mpProperty;
|
||||
|
||||
public:
|
||||
TPropertyRef()
|
||||
: mpObject(nullptr), mpProperty(nullptr)
|
||||
: mpPropertyData(nullptr), mpProperty(nullptr)
|
||||
{}
|
||||
|
||||
TPropertyRef(CScriptObject* pInObject, IPropertyNew* pInProperty)
|
||||
: mpObject(pInObject), mpProperty( TPropCast<PropertyClass>(pInProperty) )
|
||||
explicit TPropertyRef(void* pInData, IPropertyNew* pInProperty)
|
||||
: mpPropertyData(pInData), mpProperty( TPropCast<PropertyClass>(pInProperty) )
|
||||
{
|
||||
}
|
||||
|
||||
TPropertyRef(CScriptObject* pInObject, PropertyClass* pInProperty)
|
||||
: mpObject(pInObject), mpProperty(pInProperty)
|
||||
explicit TPropertyRef(void* pInData, PropertyClass* pInProperty)
|
||||
: mpPropertyData(pInData), mpProperty(pInProperty)
|
||||
{
|
||||
}
|
||||
|
||||
/** Accessors */
|
||||
inline CScriptObject* Object() const { return mpObject; }
|
||||
inline void* DataPointer() const { return mpPropertyData; }
|
||||
inline PropertyClass* Property() const { return mpProperty; }
|
||||
inline ValueType Get() const { return IsValid() ? *((ValueType*) mpProperty->RawValuePtr( mpObject->PropertyData() )) : ValueType(); }
|
||||
inline void Set(const ValueType& kIn) const { if (IsValid()) *((ValueType*) mpProperty->RawValuePtr( mpObject->PropertyData() )) = kIn; }
|
||||
inline bool IsValid() const { return mpObject != nullptr && mpProperty != nullptr; }
|
||||
inline ValueType Get() const { return IsValid() ? *((ValueType*) mpProperty->RawValuePtr( mpPropertyData )) : ValueType(); }
|
||||
inline void Set(const ValueType& kIn) const { if (IsValid()) *((ValueType*) mpProperty->RawValuePtr( mpPropertyData )) = kIn; }
|
||||
inline bool IsValid() const { return mpPropertyData != nullptr && mpProperty != nullptr; }
|
||||
|
||||
/** Inline operators */
|
||||
inline operator ValueType() const
|
||||
@@ -101,12 +101,12 @@ public:
|
||||
: TPropertyRef()
|
||||
{}
|
||||
|
||||
TEnumRef(CScriptObject* pInObject, IPropertyNew* pInProperty)
|
||||
: TPropertyRef(pInObject, pInProperty)
|
||||
TEnumRef(void* pInData, IPropertyNew* pInProperty)
|
||||
: TPropertyRef(pInData, pInProperty)
|
||||
{}
|
||||
|
||||
TEnumRef(CScriptObject* pInObject, CEnumProperty* pInProperty)
|
||||
: TPropertyRef(pInObject, pInProperty)
|
||||
TEnumRef(void* pInData, CEnumProperty* pInProperty)
|
||||
: TPropertyRef(pInData, pInProperty)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user