mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-16 08:27:01 +00:00
Mass code cleanup
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
#include <Common/Log.h>
|
||||
|
||||
CMasterTemplate::CMasterTemplate()
|
||||
: mVersion(0)
|
||||
, mFullyLoaded(false)
|
||||
{
|
||||
mVersion = 0;
|
||||
mFullyLoaded = false;
|
||||
}
|
||||
|
||||
CMasterTemplate::~CMasterTemplate()
|
||||
@@ -14,18 +14,7 @@ CMasterTemplate::~CMasterTemplate()
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
EGame CMasterTemplate::GetGame()
|
||||
{
|
||||
return mGame;
|
||||
}
|
||||
|
||||
u32 CMasterTemplate::NumGameVersions()
|
||||
{
|
||||
if (mGameVersions.empty()) return 1;
|
||||
else return mGameVersions.size();
|
||||
}
|
||||
|
||||
u32 CMasterTemplate::GetGameVersion(TString VersionName)
|
||||
u32 CMasterTemplate::GameVersion(TString VersionName)
|
||||
{
|
||||
VersionName = VersionName.ToLower();
|
||||
|
||||
@@ -99,12 +88,7 @@ SMessage CMasterTemplate::MessageByIndex(u32 Index)
|
||||
return (std::next(it, Index))->second;
|
||||
}
|
||||
|
||||
TString CMasterTemplate::GetDirectory() const
|
||||
{
|
||||
return mSourceFile.GetFileDirectory();
|
||||
}
|
||||
|
||||
CStructTemplate* CMasterTemplate::GetStructAtSource(const TString& rkSource)
|
||||
CStructTemplate* CMasterTemplate::StructAtSource(const TString& rkSource)
|
||||
{
|
||||
auto InfoIt = mStructTemplates.find(rkSource);
|
||||
|
||||
@@ -114,13 +98,8 @@ CStructTemplate* CMasterTemplate::GetStructAtSource(const TString& rkSource)
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
bool CMasterTemplate::IsLoadedSuccessfully()
|
||||
{
|
||||
return mFullyLoaded;
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
CMasterTemplate* CMasterTemplate::GetMasterForGame(EGame Game)
|
||||
CMasterTemplate* CMasterTemplate::MasterForGame(EGame Game)
|
||||
{
|
||||
auto it = smMasterMap.find(Game);
|
||||
|
||||
@@ -130,7 +109,7 @@ CMasterTemplate* CMasterTemplate::GetMasterForGame(EGame Game)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::list<CMasterTemplate*> CMasterTemplate::GetMasterList()
|
||||
std::list<CMasterTemplate*> CMasterTemplate::MasterList()
|
||||
{
|
||||
std::list<CMasterTemplate*> list;
|
||||
|
||||
@@ -140,7 +119,7 @@ std::list<CMasterTemplate*> CMasterTemplate::GetMasterList()
|
||||
return list;
|
||||
}
|
||||
|
||||
TString CMasterTemplate::GetPropertyName(u32 PropertyID)
|
||||
TString CMasterTemplate::PropertyName(u32 PropertyID)
|
||||
{
|
||||
auto it = smPropertyNames.find(PropertyID);
|
||||
|
||||
@@ -250,7 +229,7 @@ void CMasterTemplate::RenameProperty(IPropertyTemplate *pTemp, const TString& rk
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<TString> CMasterTemplate::GetXMLsUsingID(u32 ID)
|
||||
std::vector<TString> CMasterTemplate::XMLsUsingID(u32 ID)
|
||||
{
|
||||
auto InfoIt = smIDMap.find(ID);
|
||||
|
||||
@@ -263,7 +242,7 @@ std::vector<TString> CMasterTemplate::GetXMLsUsingID(u32 ID)
|
||||
return std::vector<TString>();
|
||||
}
|
||||
|
||||
const std::vector<IPropertyTemplate*>* CMasterTemplate::GetTemplatesWithMatchingID(IPropertyTemplate *pTemp)
|
||||
const std::vector<IPropertyTemplate*>* CMasterTemplate::TemplatesWithMatchingID(IPropertyTemplate *pTemp)
|
||||
{
|
||||
u32 ID = pTemp->PropertyID();
|
||||
if (ID <= 0xFF) ID = CreatePropertyID(pTemp);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef CMASTERTEMPLATE_H
|
||||
#define CMASTERTEMPLATE_H
|
||||
|
||||
#include "CScriptTemplate.h"
|
||||
#include "CLink.h"
|
||||
#include "CScriptTemplate.h"
|
||||
#include "Core/Resource/EGame.h"
|
||||
#include <Common/types.h>
|
||||
#include <map>
|
||||
@@ -38,12 +38,7 @@ class CMasterTemplate
|
||||
public:
|
||||
CMasterTemplate();
|
||||
~CMasterTemplate();
|
||||
EGame GetGame();
|
||||
u32 NumGameVersions();
|
||||
u32 GetGameVersion(TString VersionName);
|
||||
u32 NumScriptTemplates();
|
||||
u32 NumStates();
|
||||
u32 NumMessages();
|
||||
u32 GameVersion(TString VersionName);
|
||||
CScriptTemplate* TemplateByID(u32 ObjectID);
|
||||
CScriptTemplate* TemplateByID(const CFourCC& ObjectID);
|
||||
CScriptTemplate* TemplateByIndex(u32 Index);
|
||||
@@ -53,31 +48,26 @@ public:
|
||||
SMessage MessageByID(u32 MessageID);
|
||||
SMessage MessageByID(const CFourCC& MessageID);
|
||||
SMessage MessageByIndex(u32 Index);
|
||||
TString GetDirectory() const;
|
||||
CStructTemplate* GetStructAtSource(const TString& rkSource);
|
||||
bool IsLoadedSuccessfully();
|
||||
CStructTemplate* StructAtSource(const TString& rkSource);
|
||||
|
||||
static CMasterTemplate* GetMasterForGame(EGame Game);
|
||||
static std::list<CMasterTemplate*> GetMasterList();
|
||||
static TString GetPropertyName(u32 PropertyID);
|
||||
// Inline Accessors
|
||||
EGame Game() const { return mGame; }
|
||||
u32 NumGameVersions() const { return mGameVersions.empty() ? 1 : mGameVersions.size(); }
|
||||
u32 NumScriptTemplates() const { return mTemplates.size(); }
|
||||
u32 NumStates() const { return mStates.size(); }
|
||||
u32 NumMessages() const { return mMessages.size(); }
|
||||
bool IsLoadedSuccessfully() { return mFullyLoaded; }
|
||||
TString GetDirectory() const { return mSourceFile.GetFileDirectory(); }
|
||||
|
||||
// Static
|
||||
static CMasterTemplate* MasterForGame(EGame Game);
|
||||
static std::list<CMasterTemplate*> MasterList();
|
||||
static TString PropertyName(u32 PropertyID);
|
||||
static u32 CreatePropertyID(IPropertyTemplate *pTemp);
|
||||
static void AddProperty(IPropertyTemplate *pTemp, const TString& rkTemplateName = "");
|
||||
static void RenameProperty(IPropertyTemplate *pTemp, const TString& rkNewName);
|
||||
static std::vector<TString> GetXMLsUsingID(u32 ID);
|
||||
static const std::vector<IPropertyTemplate*>* GetTemplatesWithMatchingID(IPropertyTemplate *pTemp);
|
||||
static std::vector<TString> XMLsUsingID(u32 ID);
|
||||
static const std::vector<IPropertyTemplate*>* TemplatesWithMatchingID(IPropertyTemplate *pTemp);
|
||||
};
|
||||
|
||||
// ************ INLINE ************
|
||||
inline u32 CMasterTemplate::NumScriptTemplates() {
|
||||
return mTemplates.size();
|
||||
}
|
||||
|
||||
inline u32 CMasterTemplate::NumStates() {
|
||||
return mStates.size();
|
||||
}
|
||||
|
||||
inline u32 CMasterTemplate::NumMessages() {
|
||||
return mMessages.size();
|
||||
}
|
||||
|
||||
#endif // CMASTERTEMPLATE_H
|
||||
|
||||
@@ -101,14 +101,14 @@ public:
|
||||
|
||||
inline u32 AreaIndex() const
|
||||
{
|
||||
for (u32 iLyr = 0; iLyr < mpArea->GetScriptLayerCount(); iLyr++)
|
||||
for (u32 iLyr = 0; iLyr < mpArea->NumScriptLayers(); iLyr++)
|
||||
{
|
||||
if (mpArea->GetScriptLayer(iLyr) == this)
|
||||
if (mpArea->ScriptLayer(iLyr) == this)
|
||||
return iLyr;
|
||||
}
|
||||
|
||||
if (mpArea->GetGeneratorLayer() == this)
|
||||
return mpArea->GetScriptLayerCount();
|
||||
if (mpArea->GeneratedObjectsLayer() == this)
|
||||
return mpArea->NumScriptLayers();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -160,72 +160,6 @@ bool CScriptObject::HasNearVisibleActivation() const
|
||||
return false;
|
||||
}
|
||||
|
||||
// ************ GETTERS ************
|
||||
IProperty* CScriptObject::PropertyByIndex(u32 index) const
|
||||
{
|
||||
return mpProperties->PropertyByIndex(index);
|
||||
}
|
||||
|
||||
IProperty* CScriptObject::PropertyByIDString(const TString& str) const
|
||||
{
|
||||
return mpProperties->PropertyByIDString(str);
|
||||
}
|
||||
|
||||
CScriptTemplate* CScriptObject::Template() const
|
||||
{
|
||||
return mpTemplate;
|
||||
}
|
||||
|
||||
CMasterTemplate* CScriptObject::MasterTemplate() const
|
||||
{
|
||||
return mpTemplate->MasterTemplate();
|
||||
}
|
||||
|
||||
CGameArea* CScriptObject::Area() const
|
||||
{
|
||||
return mpArea;
|
||||
}
|
||||
|
||||
CScriptLayer* CScriptObject::Layer() const
|
||||
{
|
||||
return mpLayer;
|
||||
}
|
||||
|
||||
u32 CScriptObject::Version() const
|
||||
{
|
||||
return mVersion;
|
||||
}
|
||||
|
||||
CPropertyStruct* CScriptObject::Properties() const
|
||||
{
|
||||
return mpProperties;
|
||||
}
|
||||
|
||||
u32 CScriptObject::NumProperties() const
|
||||
{
|
||||
return mpProperties->Count();
|
||||
}
|
||||
|
||||
u32 CScriptObject::ObjectTypeID() const
|
||||
{
|
||||
return mpTemplate->ObjectID();
|
||||
}
|
||||
|
||||
u32 CScriptObject::InstanceID() const
|
||||
{
|
||||
return mInstanceID;
|
||||
}
|
||||
|
||||
u32 CScriptObject::NumLinks(ELinkType Type) const
|
||||
{
|
||||
return (Type == eIncoming ? mInLinks.size() : mOutLinks.size());
|
||||
}
|
||||
|
||||
CLink* CScriptObject::Link(ELinkType Type, u32 Index) const
|
||||
{
|
||||
return (Type == eIncoming ? mInLinks[Index] : mOutLinks[Index]);
|
||||
}
|
||||
|
||||
void CScriptObject::AddLink(ELinkType Type, CLink *pLink, u32 Index /*= -1*/)
|
||||
{
|
||||
std::vector<CLink*> *pLinkVec = (Type == eIncoming ? &mInLinks : &mOutLinks);
|
||||
@@ -273,103 +207,3 @@ void CScriptObject::BreakAllLinks()
|
||||
mInLinks.clear();
|
||||
mOutLinks.clear();
|
||||
}
|
||||
|
||||
TString CScriptObject::InstanceName() const
|
||||
{
|
||||
if (mpInstanceName)
|
||||
return mpInstanceName->Get();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
CVector3f CScriptObject::Position() const
|
||||
{
|
||||
if (mpPosition)
|
||||
return mpPosition->Get();
|
||||
else
|
||||
return CVector3f::skZero;
|
||||
}
|
||||
|
||||
CVector3f CScriptObject::Rotation() const
|
||||
{
|
||||
if (mpRotation)
|
||||
return mpRotation->Get();
|
||||
else
|
||||
return CVector3f::skZero;
|
||||
}
|
||||
|
||||
CVector3f CScriptObject::Scale() const
|
||||
{
|
||||
if (mpScale)
|
||||
return mpScale->Get();
|
||||
else
|
||||
return CVector3f::skOne;
|
||||
}
|
||||
|
||||
bool CScriptObject::IsActive() const
|
||||
{
|
||||
if (mpActive)
|
||||
return mpActive->Get();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CScriptObject::HasInGameModel() const
|
||||
{
|
||||
return mHasInGameModel;
|
||||
}
|
||||
|
||||
void CScriptObject::SetPosition(const CVector3f& newPos)
|
||||
{
|
||||
if (mpPosition) mpPosition->Set(newPos);
|
||||
}
|
||||
|
||||
void CScriptObject::SetRotation(const CVector3f& newRot)
|
||||
{
|
||||
if (mpRotation) mpRotation->Set(newRot);
|
||||
}
|
||||
|
||||
void CScriptObject::SetScale(const CVector3f& newScale)
|
||||
{
|
||||
if (mpScale) mpScale->Set(newScale);
|
||||
}
|
||||
|
||||
void CScriptObject::SetName(const TString& newName)
|
||||
{
|
||||
if (mpInstanceName) mpInstanceName->Set(newName);
|
||||
}
|
||||
|
||||
void CScriptObject::SetActive(bool isActive)
|
||||
{
|
||||
if (mpActive) mpActive->Set(isActive);
|
||||
}
|
||||
|
||||
CPropertyStruct* CScriptObject::LightParameters() const
|
||||
{
|
||||
return mpLightParameters;
|
||||
}
|
||||
|
||||
CModel* CScriptObject::GetDisplayModel() const
|
||||
{
|
||||
return mpDisplayModel;
|
||||
}
|
||||
|
||||
CTexture* CScriptObject::GetBillboard() const
|
||||
{
|
||||
return mpBillboard;
|
||||
}
|
||||
|
||||
CCollisionMeshGroup* CScriptObject::GetCollision() const
|
||||
{
|
||||
return mpCollision;
|
||||
}
|
||||
|
||||
EVolumeShape CScriptObject::VolumeShape() const
|
||||
{
|
||||
return mVolumeShape;
|
||||
}
|
||||
|
||||
float CScriptObject::VolumeScale() const
|
||||
{
|
||||
return mVolumeScale;
|
||||
}
|
||||
|
||||
@@ -63,41 +63,42 @@ public:
|
||||
u32 LayerIndex() const;
|
||||
bool HasNearVisibleActivation() const;
|
||||
|
||||
CScriptTemplate* Template() const;
|
||||
CMasterTemplate* MasterTemplate() const;
|
||||
CGameArea* Area() const;
|
||||
CScriptLayer* Layer() const;
|
||||
u32 Version() const;
|
||||
CPropertyStruct* Properties() const;
|
||||
u32 NumProperties() const;
|
||||
IProperty* PropertyByIndex(u32 index) const;
|
||||
IProperty* PropertyByIDString(const TIDString& str) const;
|
||||
u32 ObjectTypeID() const;
|
||||
u32 InstanceID() const;
|
||||
|
||||
u32 NumLinks(ELinkType Type) const;
|
||||
CLink* Link(ELinkType Type, u32 Index) const;
|
||||
void AddLink(ELinkType Type, CLink *pLink, u32 Index = -1);
|
||||
void RemoveLink(ELinkType Type, CLink *pLink);
|
||||
void BreakAllLinks();
|
||||
|
||||
CVector3f Position() const;
|
||||
CVector3f Rotation() const;
|
||||
CVector3f Scale() const;
|
||||
TString InstanceName() const;
|
||||
bool IsActive() const;
|
||||
bool HasInGameModel() const;
|
||||
void SetPosition(const CVector3f& newPos);
|
||||
void SetRotation(const CVector3f& newRot);
|
||||
void SetScale(const CVector3f& newScale);
|
||||
void SetName(const TString& newName);
|
||||
void SetActive(bool isActive);
|
||||
CPropertyStruct* LightParameters() const;
|
||||
CModel* GetDisplayModel() const;
|
||||
CTexture* GetBillboard() const;
|
||||
CCollisionMeshGroup* GetCollision() const;
|
||||
EVolumeShape VolumeShape() const;
|
||||
float VolumeScale() const;
|
||||
// Accessors
|
||||
CScriptTemplate* Template() const { return mpTemplate; }
|
||||
CMasterTemplate* MasterTemplate() const { return mpTemplate->MasterTemplate(); }
|
||||
CGameArea* Area() const { return mpArea; }
|
||||
CScriptLayer* Layer() const { return mpLayer; }
|
||||
u32 Version() const { return mVersion; }
|
||||
CPropertyStruct* Properties() const { return mpProperties; }
|
||||
u32 NumProperties() const { return mpProperties->Count(); }
|
||||
IProperty* PropertyByIndex(u32 Index) const { return mpProperties->PropertyByIndex(Index); }
|
||||
IProperty* PropertyByIDString(const TIDString& rkStr) const { return mpProperties->PropertyByIDString(rkStr); }
|
||||
u32 ObjectTypeID() const { return mpTemplate->ObjectID(); }
|
||||
u32 InstanceID() const { return mInstanceID; }
|
||||
u32 NumLinks(ELinkType Type) const { return (Type == eIncoming ? mInLinks.size() : mOutLinks.size()); }
|
||||
CLink* Link(ELinkType Type, u32 Index) const { return (Type == eIncoming ? mInLinks[Index] : mOutLinks[Index]); }
|
||||
|
||||
CVector3f Position() const { return mpPosition ? mpPosition->Get() : CVector3f::skZero; }
|
||||
CVector3f Rotation() const { return mpRotation ? mpRotation->Get() : CVector3f::skZero; }
|
||||
CVector3f Scale() const { return mpScale ? mpScale->Get() : CVector3f::skZero; }
|
||||
TString InstanceName() const { return mpInstanceName ? mpInstanceName->Get() : ""; }
|
||||
bool IsActive() const { return mpActive ? mpActive->Get() : false; }
|
||||
bool HasInGameModel() const { return mHasInGameModel; }
|
||||
void SetPosition(const CVector3f& rkNewPos) { if (mpPosition) mpPosition->Set(rkNewPos); }
|
||||
void SetRotation(const CVector3f& rkNewRot) { if (mpRotation) mpRotation->Set(rkNewRot); }
|
||||
void SetScale(const CVector3f& rkNewScale) { if (mpScale) mpScale->Set(rkNewScale); }
|
||||
void SetName(const TString& rkNewName) { if (mpInstanceName) mpInstanceName->Set(rkNewName); }
|
||||
void SetActive(bool Active) { if (mpActive) mpActive->Set(Active); }
|
||||
CPropertyStruct* LightParameters() const { return mpLightParameters; }
|
||||
CModel* GetDisplayModel() const { return mpDisplayModel; }
|
||||
CTexture* GetBillboard() const { return mpBillboard; }
|
||||
CCollisionMeshGroup* GetCollision() const { return mpCollision; }
|
||||
EVolumeShape VolumeShape() const { return mVolumeShape; }
|
||||
float VolumeScale() const { return mVolumeScale; }
|
||||
|
||||
TStringProperty* InstanceNameProperty() const { return mpInstanceName; }
|
||||
TVector3Property* PositionProperty() const { return mpPosition; }
|
||||
|
||||
@@ -23,74 +23,24 @@ CScriptTemplate::~CScriptTemplate()
|
||||
delete mpBaseStruct;
|
||||
}
|
||||
|
||||
CMasterTemplate* CScriptTemplate::MasterTemplate()
|
||||
EGame CScriptTemplate::Game() const
|
||||
{
|
||||
return mpMaster;
|
||||
}
|
||||
|
||||
EGame CScriptTemplate::Game()
|
||||
{
|
||||
return mpMaster->GetGame();
|
||||
}
|
||||
|
||||
TString CScriptTemplate::Name() const
|
||||
{
|
||||
return mTemplateName;
|
||||
}
|
||||
|
||||
CScriptTemplate::ERotationType CScriptTemplate::RotationType() const
|
||||
{
|
||||
return mRotationType;
|
||||
}
|
||||
|
||||
CScriptTemplate::EScaleType CScriptTemplate::ScaleType() const
|
||||
{
|
||||
return mScaleType;
|
||||
}
|
||||
|
||||
float CScriptTemplate::PreviewScale() const
|
||||
{
|
||||
return mPreviewScale;
|
||||
}
|
||||
|
||||
u32 CScriptTemplate::ObjectID() const
|
||||
{
|
||||
return mObjectID;
|
||||
}
|
||||
|
||||
void CScriptTemplate::SetVisible(bool visible)
|
||||
{
|
||||
mVisible = visible;
|
||||
}
|
||||
|
||||
bool CScriptTemplate::IsVisible() const
|
||||
{
|
||||
return mVisible;
|
||||
}
|
||||
|
||||
void CScriptTemplate::DebugPrintProperties()
|
||||
{
|
||||
mpBaseStruct->DebugPrintProperties("");
|
||||
return mpMaster->Game();
|
||||
}
|
||||
|
||||
// ************ PROPERTY FETCHING ************
|
||||
template<typename t, EPropertyType propType>
|
||||
t TFetchProperty(CPropertyStruct *pProperties, const TIDString& ID)
|
||||
template<typename PropType, EPropertyType PropEnum>
|
||||
PropType TFetchProperty(CPropertyStruct *pProperties, const TIDString& rkID)
|
||||
{
|
||||
if (ID.IsEmpty()) return nullptr;
|
||||
IProperty *pProp = pProperties->PropertyByIDString(ID);
|
||||
if (rkID.IsEmpty()) return nullptr;
|
||||
IProperty *pProp = pProperties->PropertyByIDString(rkID);
|
||||
|
||||
if (pProp && (pProp->Type() == propType))
|
||||
return static_cast<t>(pProp);
|
||||
if (pProp && (pProp->Type() == PropEnum))
|
||||
return static_cast<PropType>(pProp);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CStructTemplate* CScriptTemplate::BaseStruct()
|
||||
{
|
||||
return mpBaseStruct;
|
||||
}
|
||||
|
||||
EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
|
||||
{
|
||||
if (pObj->Template() != this)
|
||||
@@ -101,9 +51,9 @@ EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
|
||||
|
||||
if (mVolumeShape == eConditionalShape)
|
||||
{
|
||||
s32 index = CheckVolumeConditions(pObj, true);
|
||||
if (index == -1) return eInvalidShape;
|
||||
else return mVolumeConditions[index].Shape;
|
||||
s32 Index = CheckVolumeConditions(pObj, true);
|
||||
if (Index == -1) return eInvalidShape;
|
||||
else return mVolumeConditions[Index].Shape;
|
||||
}
|
||||
else return mVolumeShape;
|
||||
}
|
||||
@@ -118,9 +68,9 @@ float CScriptTemplate::VolumeScale(CScriptObject *pObj)
|
||||
|
||||
if (mVolumeShape == eConditionalShape)
|
||||
{
|
||||
s32 index = CheckVolumeConditions(pObj, false);
|
||||
if (index == -1) return mVolumeScale;
|
||||
else return mVolumeConditions[index].Scale;
|
||||
s32 Index = CheckVolumeConditions(pObj, false);
|
||||
if (Index == -1) return mVolumeScale;
|
||||
else return mVolumeConditions[Index].Scale;
|
||||
}
|
||||
else return mVolumeScale;
|
||||
}
|
||||
@@ -133,40 +83,40 @@ s32 CScriptTemplate::CheckVolumeConditions(CScriptObject *pObj, bool LogErrors)
|
||||
IProperty *pProp = pObj->Properties()->PropertyByIDString(mVolumeConditionIDString);
|
||||
|
||||
// Get value of the condition test property (only boolean, integral, and enum types supported)
|
||||
int v;
|
||||
int Val;
|
||||
|
||||
switch (pProp->Type())
|
||||
{
|
||||
case eBoolProperty:
|
||||
v = (static_cast<TBoolProperty*>(pProp)->Get() ? 1 : 0);
|
||||
Val = (static_cast<TBoolProperty*>(pProp)->Get() ? 1 : 0);
|
||||
break;
|
||||
|
||||
case eByteProperty:
|
||||
v = (int) static_cast<TByteProperty*>(pProp)->Get();
|
||||
Val = (int) static_cast<TByteProperty*>(pProp)->Get();
|
||||
break;
|
||||
|
||||
case eShortProperty:
|
||||
v = (int) static_cast<TShortProperty*>(pProp)->Get();
|
||||
Val = (int) static_cast<TShortProperty*>(pProp)->Get();
|
||||
break;
|
||||
|
||||
case eLongProperty:
|
||||
v = (int) static_cast<TLongProperty*>(pProp)->Get();
|
||||
Val = (int) static_cast<TLongProperty*>(pProp)->Get();
|
||||
break;
|
||||
|
||||
case eEnumProperty: {
|
||||
v = (int) static_cast<TEnumProperty*>(pProp)->Get();
|
||||
case eEnumProperty:
|
||||
Val = (int) static_cast<TEnumProperty*>(pProp)->Get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Test and check whether any of the conditions are true
|
||||
for (u32 iCon = 0; iCon < mVolumeConditions.size(); iCon++)
|
||||
{
|
||||
if (mVolumeConditions[iCon].Value == v)
|
||||
if (mVolumeConditions[iCon].Value == Val)
|
||||
return iCon;
|
||||
}
|
||||
|
||||
if (LogErrors)
|
||||
Log::Error(pObj->Template()->Name() + " instance " + TString::HexString(pObj->InstanceID(), true, true, 8) + " has unexpected volume shape value of " + TString::HexString((u32) v, true, true));
|
||||
Log::Error(pObj->Template()->Name() + " instance " + TString::HexString(pObj->InstanceID()) + " has unexpected volume shape value of " + TString::HexString((u32) Val, 0));
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -213,8 +163,8 @@ CModel* CScriptTemplate::FindDisplayModel(CPropertyStruct *pProperties)
|
||||
// File
|
||||
if (it->AssetSource == SEditorAsset::eFile)
|
||||
{
|
||||
TString path = "../resources/" + it->AssetLocation;
|
||||
pRes = gResCache.GetResource(path);
|
||||
TString Path = "../resources/" + it->AssetLocation;
|
||||
pRes = gResCache.GetResource(Path);
|
||||
}
|
||||
|
||||
// Property
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
class CMasterTemplate;
|
||||
class CScriptObject;
|
||||
|
||||
typedef TString TIDString;
|
||||
@@ -89,21 +88,9 @@ private:
|
||||
public:
|
||||
CScriptTemplate(CMasterTemplate *pMaster);
|
||||
~CScriptTemplate();
|
||||
|
||||
CMasterTemplate* MasterTemplate();
|
||||
EGame Game();
|
||||
TString Name() const;
|
||||
u32 NumPropertySets() const;
|
||||
ERotationType RotationType() const;
|
||||
EScaleType ScaleType() const;
|
||||
float PreviewScale() const;
|
||||
u32 ObjectID() const;
|
||||
void SetVisible(bool visible);
|
||||
bool IsVisible() const;
|
||||
void DebugPrintProperties();
|
||||
EGame Game() const;
|
||||
|
||||
// Property Fetching
|
||||
CStructTemplate* BaseStruct();
|
||||
EVolumeShape VolumeShape(CScriptObject *pObj);
|
||||
float VolumeScale(CScriptObject *pObj);
|
||||
TStringProperty* FindInstanceName(CPropertyStruct *pProperties);
|
||||
@@ -117,12 +104,26 @@ public:
|
||||
CCollisionMeshGroup* FindCollision(CPropertyStruct *pProperties);
|
||||
bool HasInGameModel(CPropertyStruct *pProperties);
|
||||
|
||||
inline TString SourceFile() const { return mSourceFile; }
|
||||
inline bool HasName() const { return !mNameIDString.IsEmpty(); }
|
||||
inline bool HasPosition() const { return !mPositionIDString.IsEmpty(); }
|
||||
inline bool HasRotation() const { return !mRotationIDString.IsEmpty(); }
|
||||
inline bool HasScale() const { return !mScaleIDString.IsEmpty(); }
|
||||
inline bool HasActive() const { return !mActiveIDString.IsEmpty(); }
|
||||
// Accessors
|
||||
inline CMasterTemplate* MasterTemplate() const { return mpMaster; }
|
||||
inline TString Name() const { return mTemplateName; }
|
||||
inline ERotationType RotationType() const { return mRotationType; }
|
||||
inline EScaleType ScaleType() const { return mScaleType; }
|
||||
inline float PreviewScale() const { return mPreviewScale; }
|
||||
inline u32 ObjectID() const { return mObjectID; }
|
||||
inline bool IsVisible() const { return mVisible; }
|
||||
inline TString SourceFile() const { return mSourceFile; }
|
||||
inline CStructTemplate* BaseStruct() const { return mpBaseStruct; }
|
||||
|
||||
inline bool HasName() const { return !mNameIDString.IsEmpty(); }
|
||||
inline bool HasPosition() const { return !mPositionIDString.IsEmpty(); }
|
||||
inline bool HasRotation() const { return !mRotationIDString.IsEmpty(); }
|
||||
inline bool HasScale() const { return !mScaleIDString.IsEmpty(); }
|
||||
inline bool HasActive() const { return !mActiveIDString.IsEmpty(); }
|
||||
|
||||
inline void SetVisible(bool Visible) { mVisible = Visible; }
|
||||
|
||||
inline void DebugPrintProperties() { mpBaseStruct->DebugPrintProperties(""); }
|
||||
|
||||
// Object Tracking
|
||||
u32 NumObjects() const;
|
||||
|
||||
@@ -50,7 +50,7 @@ TIDString IProperty::IDString(bool FullPath) const
|
||||
if (!Out.IsEmpty()) Out += ":";
|
||||
}
|
||||
|
||||
Out += TString::HexString(ID(), true, true, 8);
|
||||
Out += TString::HexString(ID());
|
||||
}
|
||||
|
||||
return Out;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// ************ IPropertyTemplate ************
|
||||
EGame IPropertyTemplate::Game() const
|
||||
{
|
||||
return (mpMasterTemplate ? mpMasterTemplate->GetGame() : eUnknownVersion);
|
||||
return (mpMasterTemplate ? mpMasterTemplate->Game() : eUnknownVersion);
|
||||
}
|
||||
|
||||
bool IPropertyTemplate::IsInVersion(u32 Version) const
|
||||
@@ -32,7 +32,7 @@ TIDString IPropertyTemplate::IDString(bool FullPath) const
|
||||
if (!out.IsEmpty()) out += ":";
|
||||
}
|
||||
|
||||
out += TIDString::HexString(mID, true, true, 8);
|
||||
out += TIDString::HexString(mID);
|
||||
return out;
|
||||
}
|
||||
else return "";
|
||||
|
||||
@@ -168,13 +168,13 @@ public:
|
||||
|
||||
TString ToString() const
|
||||
{
|
||||
return TString::HexString(mValue, true, true, mValue > 0xFF ? 8 : 2);
|
||||
return TString::HexString(mValue, 8);
|
||||
}
|
||||
|
||||
void FromString(const TString& rkString)
|
||||
{
|
||||
u32 base = (rkString.StartsWith("0x") ? 16 : 10);
|
||||
mValue = (s32) rkString.ToInt32(base);
|
||||
u32 Base = (rkString.StartsWith("0x") ? 16 : 10);
|
||||
mValue = (s32) rkString.ToInt32(Base);
|
||||
}
|
||||
|
||||
IPropertyValue* Clone() const
|
||||
@@ -237,10 +237,10 @@ public:
|
||||
TString ToString() const
|
||||
{
|
||||
TString out;
|
||||
out += TString::FromFloat(mValue.r) + ", ";
|
||||
out += TString::FromFloat(mValue.g) + ", ";
|
||||
out += TString::FromFloat(mValue.b) + ", ";
|
||||
out += TString::FromFloat(mValue.a);
|
||||
out += TString::FromFloat(mValue.R) + ", ";
|
||||
out += TString::FromFloat(mValue.G) + ", ";
|
||||
out += TString::FromFloat(mValue.B) + ", ";
|
||||
out += TString::FromFloat(mValue.A);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -255,8 +255,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
float *pPtr = &mValue.r;
|
||||
mValue.a = 1.0f;
|
||||
float *pPtr = &mValue.R;
|
||||
mValue.A = 1.0f;
|
||||
|
||||
for (auto it = Components.begin(); it != Components.end(); it++)
|
||||
{
|
||||
@@ -280,9 +280,9 @@ public:
|
||||
TString ToString() const
|
||||
{
|
||||
TString out;
|
||||
out += TString::FromFloat(mValue.x) + ", ";
|
||||
out += TString::FromFloat(mValue.y) + ", ";
|
||||
out += TString::FromFloat(mValue.z);
|
||||
out += TString::FromFloat(mValue.X) + ", ";
|
||||
out += TString::FromFloat(mValue.Y) + ", ";
|
||||
out += TString::FromFloat(mValue.Z);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
float *pPtr = &mValue.x;
|
||||
float *pPtr = &mValue.X;
|
||||
|
||||
for (auto it = Components.begin(); it != Components.end(); it++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user