diff --git a/src/Core/CAreaAttributes.cpp b/src/Core/CAreaAttributes.cpp index d6aa2b02..ed8c1bd9 100644 --- a/src/Core/CAreaAttributes.cpp +++ b/src/Core/CAreaAttributes.cpp @@ -14,7 +14,7 @@ CAreaAttributes::~CAreaAttributes() void CAreaAttributes::SetObject(CScriptObject *pObj) { CScriptTemplate* pTemplate = pObj->Template(); - CStructPropertyNew* pProperties = pTemplate->Properties(); + CStructProperty* pProperties = pTemplate->Properties(); mpObject = pObj; mGame = pTemplate->MasterTemplate()->Game(); diff --git a/src/Core/Core.pro b/src/Core/Core.pro index 5254997f..10ceb07f 100644 --- a/src/Core/Core.pro +++ b/src/Core/Core.pro @@ -91,7 +91,6 @@ HEADERS += \ Resource/Cooker/CMaterialCooker.h \ Resource/Cooker/CModelCooker.h \ Resource/Cooker/CSectionMgrOut.h \ - Resource/Cooker/CTemplateWriter.h \ Resource/Cooker/CTextureEncoder.h \ Resource/Cooker/CWorldCooker.h \ Resource/Factory/CAnimSetLoader.h \ @@ -115,7 +114,6 @@ HEADERS += \ Resource/Script/CScriptLayer.h \ Resource/Script/CScriptObject.h \ Resource/Script/CScriptTemplate.h \ - Resource/Script/EPropertyType.h \ Resource/Script/EVolumeShape.h \ Resource/CCollisionMesh.h \ Resource/CCollisionMeshGroup.h \ @@ -163,9 +161,6 @@ HEADERS += \ OpenGL/GLCommon.h \ ScriptExtra/CRadiusSphereExtra.h \ Resource/Cooker/CAreaCooker.h \ - Resource/Script/IPropertyValue.h \ - Resource/Script/IPropertyTemplate.h \ - Resource/Script/IProperty.h \ Resource/Model/EVertexAttribute.h \ Render/FRenderOptions.h \ Scene/FShowFlags.h \ @@ -231,9 +226,8 @@ HEADERS += \ IUIRelay.h \ Resource/CResTypeFilter.h \ GameProject/COpeningBanner.h \ - Resource/Script/CPropertyNameGenerator.h \ - Resource/Script/IPropertyNew.h \ - Resource/Script/TPropertyProxy.h \ + Resource/Script/Property/CPropertyNameGenerator.h \ + Resource/Script/Property/IProperty.h \ Resource/Script/Property/CEnumProperty.h \ Resource/Script/Property/CFlagsProperty.h \ Resource/Script/Property/CAssetProperty.h \ @@ -267,7 +261,6 @@ SOURCES += \ Resource/Area/CGameArea.cpp \ Resource/Cooker/CMaterialCooker.cpp \ Resource/Cooker/CModelCooker.cpp \ - Resource/Cooker/CTemplateWriter.cpp \ Resource/Cooker/CTextureEncoder.cpp \ Resource/Cooker/CWorldCooker.cpp \ Resource/Factory/CAnimSetLoader.cpp \ @@ -320,8 +313,6 @@ SOURCES += \ OpenGL/GLCommon.cpp \ ScriptExtra/CRadiusSphereExtra.cpp \ Resource/Cooker/CAreaCooker.cpp \ - Resource/Script/IPropertyTemplate.cpp \ - Resource/Script/IProperty.cpp \ Scene/FShowFlags.cpp \ Scene/CScene.cpp \ Scene/CSceneIterator.cpp \ @@ -365,8 +356,8 @@ SOURCES += \ IUIRelay.cpp \ GameProject\COpeningBanner.cpp \ IProgressNotifier.cpp \ - Resource/Script/CPropertyNameGenerator.cpp \ - Resource/Script/IPropertyNew.cpp \ + Resource/Script/Property/CPropertyNameGenerator.cpp \ + Resource/Script/Property/IProperty.cpp \ Resource/Script/Property/CStructProperty.cpp \ Resource/Script/Property/CFlagsProperty.cpp diff --git a/src/Core/GameProject/AssetNameGeneration.cpp b/src/Core/GameProject/AssetNameGeneration.cpp index 7a044200..6524e729 100644 --- a/src/Core/GameProject/AssetNameGeneration.cpp +++ b/src/Core/GameProject/AssetNameGeneration.cpp @@ -284,7 +284,7 @@ void GenerateAssetNames(CGameProject *pProj) for (u32 iInst = 0; iInst < pLayer->NumInstances(); iInst++) { CScriptObject* pInst = pLayer->InstanceByIndex(iInst); - CStructPropertyNew* pProperties = pInst->Template()->Properties(); + CStructProperty* pProperties = pInst->Template()->Properties(); if (pInst->ObjectTypeID() == 0x42 || pInst->ObjectTypeID() == FOURCC('POIN')) { diff --git a/src/Core/GameProject/CDependencyTree.cpp b/src/Core/GameProject/CDependencyTree.cpp index 48098183..567dd396 100644 --- a/src/Core/GameProject/CDependencyTree.cpp +++ b/src/Core/GameProject/CDependencyTree.cpp @@ -152,22 +152,22 @@ CScriptInstanceDependency* CScriptInstanceDependency::BuildTree(CScriptObject *p return pInst; } -void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependency* pInst, CScriptObject* pInstance, CStructPropertyNew *pStruct) +void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependency* pInst, CScriptObject* pInstance, CStructProperty *pStruct) { // Recursive function for parsing script dependencies and loading them into the script instance dependency void* pPropertyData = pInstance->PropertyData(); for (u32 PropertyIdx = 0; PropertyIdx < pStruct->NumChildren(); PropertyIdx++) { - IPropertyNew *pProp = pStruct->ChildByIndex(PropertyIdx); - EPropertyTypeNew Type = pProp->Type(); + IProperty *pProp = pStruct->ChildByIndex(PropertyIdx); + EPropertyType Type = pProp->Type(); // Technically we aren't parsing array children, but it's not really worth refactoring this function // to support it when there aren't any array properties that contain any asset references anyway... - if (Type == EPropertyTypeNew::Struct) - ParseStructDependencies(pInst, pInstance, TPropCast(pProp)); + if (Type == EPropertyType::Struct) + ParseStructDependencies(pInst, pInstance, TPropCast(pProp)); - else if (Type == EPropertyTypeNew::Sound) + else if (Type == EPropertyType::Sound) { u32 SoundID = TPropCast(pProp)->Value(pPropertyData); @@ -184,7 +184,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc } } - else if (Type == EPropertyTypeNew::Asset) + else if (Type == EPropertyType::Asset) { CAssetID ID = TPropCast(pProp)->Value(pPropertyData); @@ -195,7 +195,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc } } - else if (Type == EPropertyTypeNew::AnimationSet) + else if (Type == EPropertyType::AnimationSet) { CAnimationParameters Params = TPropCast(pProp)->Value(pPropertyData); CAssetID ID = Params.ID(); diff --git a/src/Core/GameProject/CDependencyTree.h b/src/Core/GameProject/CDependencyTree.h index 1d688121..bbab2248 100644 --- a/src/Core/GameProject/CDependencyTree.h +++ b/src/Core/GameProject/CDependencyTree.h @@ -8,7 +8,7 @@ class CScriptLayer; class CScriptObject; -class CStructPropertyNew; +class CStructProperty; class CAnimSet; class CAnimationParameters; struct SSetCharacter; @@ -145,7 +145,7 @@ public: // Static static CScriptInstanceDependency* BuildTree(CScriptObject *pInstance); protected: - static void ParseStructDependencies(CScriptInstanceDependency *pTree, CScriptObject* pInstance, CStructPropertyNew *pStruct); + static void ParseStructDependencies(CScriptInstanceDependency *pTree, CScriptObject* pInstance, CStructProperty *pStruct); }; // Node representing an animset character. Indicates what index the character is within the animset. diff --git a/src/Core/Resource/CLight.cpp b/src/Core/Resource/CLight.cpp index 53b93976..9ab16939 100644 --- a/src/Core/Resource/CLight.cpp +++ b/src/Core/Resource/CLight.cpp @@ -128,20 +128,20 @@ void CLight::SetAngleAtten(float AngleCoefA, float AngleCoefB, float AngleCoefC) mAngleAttenCoefficients.Z = AngleCoefC; } -CStructPropertyNew* CLight::GetProperties() const +CStructProperty* CLight::GetProperties() const { //@todo MP1 properties only //@todo we cannot display full properties because a lot of them are discarded on load - static CStructPropertyNew* pProperties = nullptr; + static CStructProperty* pProperties = nullptr; if (!pProperties) { - pProperties = (CStructPropertyNew*) IPropertyNew::CreateIntrinsic(EPropertyTypeNew::Struct, + pProperties = (CStructProperty*) IProperty::CreateIntrinsic(EPropertyType::Struct, ePrime, 0, "Light"); - CChoiceProperty* pLightType = (CChoiceProperty*) IPropertyNew::CreateIntrinsic(EPropertyTypeNew::Choice, + CChoiceProperty* pLightType = (CChoiceProperty*) IProperty::CreateIntrinsic(EPropertyType::Choice, pProperties, MEMBER_OFFSET(CLight, mType), "LightType"); @@ -150,22 +150,22 @@ CStructPropertyNew* CLight::GetProperties() const pLightType->AddValue("Spot", eSpot); pLightType->AddValue("Custom", eCustom); - IPropertyNew::CreateIntrinsic(EPropertyTypeNew::Color, + IProperty::CreateIntrinsic(EPropertyType::Color, pProperties, MEMBER_OFFSET(CLight, mColor), "Color"); - IPropertyNew::CreateIntrinsic(EPropertyTypeNew::Vector, + IProperty::CreateIntrinsic(EPropertyType::Vector, pProperties, MEMBER_OFFSET(CLight, mPosition), "Position"); - IPropertyNew::CreateIntrinsic(EPropertyTypeNew::Vector, + IProperty::CreateIntrinsic(EPropertyType::Vector, pProperties, MEMBER_OFFSET(CLight, mDirection), "Direction"); - IPropertyNew::CreateIntrinsic(EPropertyTypeNew::Float, + IProperty::CreateIntrinsic(EPropertyType::Float, pProperties, MEMBER_OFFSET(CLight, mSpotCutoff), "SpotCutoff"); diff --git a/src/Core/Resource/CLight.h b/src/Core/Resource/CLight.h index 25335443..83b1877c 100644 --- a/src/Core/Resource/CLight.h +++ b/src/Core/Resource/CLight.h @@ -63,7 +63,7 @@ public: void SetDistAtten(float DistCoefA, float DistCoefB, float DistCoefC); void SetAngleAtten(float AngleCoefA, float AngleCoefB, float AngleCoefC); - CStructPropertyNew* GetProperties() const; + CStructProperty* GetProperties() const; // Other void Load() const; diff --git a/src/Core/Resource/Cooker/CScriptCooker.cpp b/src/Core/Resource/Cooker/CScriptCooker.cpp index 9ee00e8e..f8821e83 100644 --- a/src/Core/Resource/Cooker/CScriptCooker.cpp +++ b/src/Core/Resource/Cooker/CScriptCooker.cpp @@ -5,7 +5,7 @@ #include #include -void CScriptCooker::WriteProperty(IOutputStream& rOut, IPropertyNew* pProperty, bool InAtomicStruct) +void CScriptCooker::WriteProperty(IOutputStream& rOut, IProperty* pProperty, bool InAtomicStruct) { u32 SizeOffset = 0, PropStart = 0; void* pData = (mpArrayItemData ? mpArrayItemData : mpObject->PropertyData()); @@ -21,118 +21,118 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IPropertyNew* pProperty, switch (pProperty->Type()) { - case EPropertyTypeNew::Bool: + case EPropertyType::Bool: { CBoolProperty* pBool = TPropCast(pProperty); rOut.WriteBool( pBool->Value(pData) ); break; } - case EPropertyTypeNew::Byte: + case EPropertyType::Byte: { CByteProperty* pByte = TPropCast(pProperty); rOut.WriteByte( pByte->Value(pData) ); break; } - case EPropertyTypeNew::Short: + case EPropertyType::Short: { CShortProperty* pShort = TPropCast(pProperty); rOut.WriteShort( pShort->Value(pData) ); break; } - case EPropertyTypeNew::Int: + case EPropertyType::Int: { CIntProperty* pInt = TPropCast(pProperty); rOut.WriteLong( pInt->Value(pData) ); break; } - case EPropertyTypeNew::Float: + case EPropertyType::Float: { CFloatProperty* pFloat = TPropCast(pProperty); rOut.WriteFloat( pFloat->Value(pData) ); break; } - case EPropertyTypeNew::Choice: + case EPropertyType::Choice: { CChoiceProperty* pChoice = TPropCast(pProperty); rOut.WriteLong( pChoice->Value(pData) ); break; } - case EPropertyTypeNew::Enum: + case EPropertyType::Enum: { CEnumProperty* pEnum = TPropCast(pProperty); rOut.WriteLong( pEnum->Value(pData) ); break; } - case EPropertyTypeNew::Flags: + case EPropertyType::Flags: { CFlagsProperty* pFlags = TPropCast(pProperty); rOut.WriteLong( pFlags->Value(pData) ); break; } - case EPropertyTypeNew::String: + case EPropertyType::String: { CStringProperty* pString = TPropCast(pProperty); rOut.WriteString( pString->Value(pData) ); break; } - case EPropertyTypeNew::Vector: + case EPropertyType::Vector: { CVectorProperty* pVector = TPropCast(pProperty); pVector->ValueRef(pData).Write(rOut); break; } - case EPropertyTypeNew::Color: + case EPropertyType::Color: { CColorProperty* pColor = TPropCast(pProperty); pColor->ValueRef(pData).Write(rOut); break; } - case EPropertyTypeNew::Asset: + case EPropertyType::Asset: { CAssetProperty* pAsset = TPropCast(pProperty); pAsset->ValueRef(pData).Write(rOut); break; } - case EPropertyTypeNew::Sound: + case EPropertyType::Sound: { CSoundProperty* pSound = TPropCast(pProperty); rOut.WriteLong( pSound->Value(pData) ); break; } - case EPropertyTypeNew::Animation: + case EPropertyType::Animation: { CAnimationProperty* pAnim = TPropCast(pProperty); rOut.WriteLong( pAnim->Value(pData) ); break; } - case EPropertyTypeNew::AnimationSet: + case EPropertyType::AnimationSet: { CAnimationSetProperty* pAnimSet = TPropCast(pProperty); pAnimSet->ValueRef(pData).Write(rOut); break; } - case EPropertyTypeNew::Sequence: + case EPropertyType::Sequence: { // TODO break; } - case EPropertyTypeNew::Spline: + case EPropertyType::Spline: { CSplineProperty* pSpline = TPropCast(pProperty); std::vector& rBuffer = pSpline->ValueRef(pData); @@ -163,7 +163,7 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IPropertyNew* pProperty, break; } - case EPropertyTypeNew::Guid: + case EPropertyType::Guid: { CGuidProperty* pGuid = TPropCast(pProperty); std::vector& rBuffer = pGuid->ValueRef(pData); @@ -175,14 +175,14 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IPropertyNew* pProperty, break; } - case EPropertyTypeNew::Struct: + case EPropertyType::Struct: { - CStructPropertyNew* pStruct = TPropCast(pProperty); - std::vector PropertiesToWrite; + CStructProperty* pStruct = TPropCast(pProperty); + std::vector PropertiesToWrite; for (u32 ChildIdx = 0; ChildIdx < pStruct->NumChildren(); ChildIdx++) { - IPropertyNew *pChild = pStruct->ChildByIndex(ChildIdx); + IProperty *pChild = pStruct->ChildByIndex(ChildIdx); if (pStruct->IsAtomic() || pChild->ShouldCook(pData)) PropertiesToWrite.push_back(pChild); @@ -202,7 +202,7 @@ void CScriptCooker::WriteProperty(IOutputStream& rOut, IPropertyNew* pProperty, break; } - case EPropertyTypeNew::Array: + case EPropertyType::Array: { CArrayProperty* pArray = TPropCast(pProperty); u32 Count = pArray->ArrayCount(pData); diff --git a/src/Core/Resource/Cooker/CScriptCooker.h b/src/Core/Resource/Cooker/CScriptCooker.h index a43c11f6..6ace8c89 100644 --- a/src/Core/Resource/Cooker/CScriptCooker.h +++ b/src/Core/Resource/Cooker/CScriptCooker.h @@ -15,7 +15,7 @@ class CScriptCooker std::vector mGeneratedObjects; bool mWriteGeneratedSeparately; - void WriteProperty(IOutputStream& rOut, IPropertyNew* pProperty, bool InAtomicStruct); + void WriteProperty(IOutputStream& rOut, IProperty* pProperty, bool InAtomicStruct); public: CScriptCooker(EGame Game, bool WriteGeneratedObjectsSeparately = true) diff --git a/src/Core/Resource/Cooker/CTemplateWriter.cpp b/src/Core/Resource/Cooker/CTemplateWriter.cpp deleted file mode 100644 index 83f35888..00000000 --- a/src/Core/Resource/Cooker/CTemplateWriter.cpp +++ /dev/null @@ -1,844 +0,0 @@ -#include "CTemplateWriter.h" -#include "CAreaCooker.h" -#include -#include - -#include - -#if 0 -using namespace tinyxml2; -TString CTemplateWriter::smTemplatesDir = "../templates/"; - -CTemplateWriter::CTemplateWriter() -{ -} - -void CTemplateWriter::SavePropertyTemplate(IPropertyTemplate *pTemp) -{ - // Check for a source file in the template's hierarchy; that indicates it's part of a struct template, not a script template - TString SourceFile = pTemp->FindStructSource(); - - // Struct - if (!SourceFile.IsEmpty()) - { - CMasterTemplate *pMaster = pTemp->MasterTemplate(); - auto StructIt = pMaster->mStructTemplates.find(SourceFile); - - if (StructIt != pMaster->mStructTemplates.end()) - { - CStructTemplate *pStruct = StructIt->second; - CTemplateWriter::SaveStructTemplate(pStruct); - } - } - - // Script - else if (pTemp->ScriptTemplate()) - CTemplateWriter::SaveScriptTemplate(pTemp->ScriptTemplate()); - - // Error - else - Log::Error("Couldn't save property template " + pTemp->IDString(true) + "; no struct template source path or script template found"); -} - -void CTemplateWriter::SaveAllTemplates() -{ - // Create directory - std::list MasterList = CMasterTemplate::MasterList(); - FileUtil::MakeDirectory(smTemplatesDir); - - // Resave property list - SavePropertyList(); - - // Resave master templates - for (auto it = MasterList.begin(); it != MasterList.end(); it++) - SaveGameTemplates(*it); - - // Resave game list - XMLDocument GameList; - - XMLDeclaration *pDecl = GameList.NewDeclaration(); - GameList.LinkEndChild(pDecl); - - XMLElement *pBase = GameList.NewElement("GameList"); - pBase->SetAttribute("version", 4); - GameList.LinkEndChild(pBase); - - XMLElement *pProperties = GameList.NewElement("properties"); - pProperties->SetText("Properties.xml"); - pBase->LinkEndChild(pProperties); - - for (auto it = MasterList.begin(); it != MasterList.end(); it++) - { - CMasterTemplate *pMaster = *it; - - XMLElement *pGame = GameList.NewElement("game"); - pBase->LinkEndChild(pGame); - - XMLElement *pGameName = GameList.NewElement("name"); - pGameName->SetText(*pMaster->mGameName); - pGame->LinkEndChild(pGameName); - - XMLElement *pAreaVersion = GameList.NewElement("mrea"); - u32 VersionNumber = CAreaCooker::GetMREAVersion(pMaster->Game()); - pAreaVersion->SetText(*TString::HexString(VersionNumber, 2)); - pGame->LinkEndChild(pAreaVersion); - - XMLElement *pTempPath = GameList.NewElement("master"); - pTempPath->SetText(*pMaster->mSourceFile); - pGame->LinkEndChild(pTempPath); - } - - TString GameListName = smTemplatesDir + "GameList.xml"; - GameList.SaveFile(*GameListName); -} - -void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster) -{ - // Create directory - TString OutFile = smTemplatesDir + pMaster->mSourceFile; - TString OutDir = OutFile.GetFileDirectory(); - FileUtil::MakeDirectory(OutDir); - - // Resave script templates - for (auto it = pMaster->mTemplates.begin(); it != pMaster->mTemplates.end(); it++) - SaveScriptTemplate(it->second); - - // Resave struct templates - for (auto it = pMaster->mStructTemplates.begin(); it != pMaster->mStructTemplates.end(); it++) - SaveStructTemplate(it->second); - - // Resave master template - XMLDocument Master; - - XMLDeclaration *pDecl = Master.NewDeclaration(); - Master.LinkEndChild(pDecl); - - XMLElement *pBase = Master.NewElement("MasterTemplate"); - pBase->SetAttribute("version", 4); - Master.LinkEndChild(pBase); - - // Write versions - if (!pMaster->mGameVersions.empty()) - { - XMLElement *pVersionsBlock = Master.NewElement("versions"); - pBase->LinkEndChild(pVersionsBlock); - - for (auto it = pMaster->mGameVersions.begin(); it != pMaster->mGameVersions.end(); it++) - { - XMLElement *pVersion = Master.NewElement("version"); - pVersion->SetText(*(*it)); - pVersionsBlock->LinkEndChild(pVersion); - } - } - - // Write script objects - XMLElement *pObjects = Master.NewElement("objects"); - pBase->LinkEndChild(pObjects); - - for (auto it = pMaster->mTemplates.begin(); it != pMaster->mTemplates.end(); it++) - { - u32 ObjID = (it->second)->ObjectID(); - - TString StrID; - if (ObjID <= 0xFF) - StrID = TString::HexString(ObjID, 2); - else - StrID = CFourCC(ObjID).ToString(); - - XMLElement *pObj = Master.NewElement("object"); - pObj->SetAttribute("ID", *StrID); - pObj->SetAttribute("template", *(it->second)->mSourceFile); - pObjects->LinkEndChild(pObj); - } - - // Write script states/messages - for (u32 iType = 0; iType < 2; iType++) - { - TString Type = (iType == 0 ? "state" : "message"); - XMLElement *pElem = Master.NewElement(*(Type + "s")); - pBase->LinkEndChild(pElem); - - u32 Num = (iType == 0 ? pMaster->NumStates() : pMaster->NumMessages()); - - for (u32 iScr = 0; iScr < Num; iScr++) - { - u32 ID; - TString Name; - - if (iType == 0) - { - SState State = pMaster->StateByIndex(iScr); - ID = State.ID; - Name = State.Name; - } - else - { - SMessage Message = pMaster->MessageByIndex(iScr); - ID = Message.ID; - Name = Message.Name; - } - - TString StrID; - if (ID <= 0xFF) StrID = TString::HexString(ID, 2); - else StrID = CFourCC(ID).ToString(); - - XMLElement *pSubElem = Master.NewElement(*Type); - pSubElem->SetAttribute("ID", *StrID); - pSubElem->SetAttribute("name", *Name); - pElem->LinkEndChild(pSubElem); - } - } - - // Save file - Master.SaveFile(*OutFile); -} - -void CTemplateWriter::SavePropertyList() -{ - // Create XML - XMLDocument List; - - XMLDeclaration *pDecl = List.NewDeclaration(); - List.LinkEndChild(pDecl); - - XMLElement *pBase = List.NewElement("Properties"); - pBase->SetAttribute("version", 4); - List.LinkEndChild(pBase); - - // Write properties - for (auto it = CMasterTemplate::smPropertyNames.begin(); it != CMasterTemplate::smPropertyNames.end(); it++) - { - u32 ID = it->first; - TString Name = it->second; - - XMLElement *pElem = List.NewElement("property"); - pElem->SetAttribute("ID", *TString::HexString(ID)); - pElem->SetAttribute("name", *Name); - pBase->LinkEndChild(pElem); - } - - TString OutFile = smTemplatesDir + "Properties.xml"; - List.SaveFile(*OutFile); -} - -void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp) -{ - CMasterTemplate *pMaster = pTemp->MasterTemplate(); - - // Create directory - TString OutFile = smTemplatesDir + pMaster->GetDirectory() + pTemp->mSourceFile; - TString OutDir = OutFile.GetFileDirectory(); - FileUtil::MakeDirectory(*OutDir); - - // Create new document - XMLDocument ScriptXML; - - XMLDeclaration *pDecl = ScriptXML.NewDeclaration(); - ScriptXML.LinkEndChild(pDecl); - - // Base element - XMLElement *pRoot = ScriptXML.NewElement("ScriptTemplate"); - pRoot->SetAttribute("version", 4); - ScriptXML.LinkEndChild(pRoot); - - // Write object name - XMLElement *pName = ScriptXML.NewElement("name"); - pName->SetText(*pTemp->Name()); - pRoot->LinkEndChild(pName); - - // Write modules - if (!pTemp->mModules.empty()) - { - XMLElement *pModules = ScriptXML.NewElement("modules"); - pRoot->LinkEndChild(pModules); - - for (u32 iMod = 0; iMod < pTemp->mModules.size(); iMod++) - { - XMLElement *pModule = ScriptXML.NewElement("module"); - pModule->SetText(*pTemp->mModules[iMod]); - pModules->LinkEndChild(pModule); - } - } - - // Write properties - SaveProperties(&ScriptXML, pRoot, pTemp->mpBaseStruct); - - // States/Messages [todo] - XMLElement *pStates = ScriptXML.NewElement("states"); - pRoot->LinkEndChild(pStates); - - XMLElement *pMessages = ScriptXML.NewElement("messages"); - pRoot->LinkEndChild(pMessages); - - // Write editor properties - XMLElement *pEditor = ScriptXML.NewElement("editor"); - pRoot->LinkEndChild(pEditor); - - // Editor Properties - XMLElement *pEditorProperties = ScriptXML.NewElement("properties"); - pEditor->LinkEndChild(pEditorProperties); - - TString PropNames[6] = { - "InstanceName", "Position", "Rotation", - "Scale", "Active", "LightParameters" - }; - - TIDString *pPropStrings[6] = { - &pTemp->mNameIDString, &pTemp->mPositionIDString, &pTemp->mRotationIDString, - &pTemp->mScaleIDString, &pTemp->mActiveIDString, &pTemp->mLightParametersIDString - }; - - for (u32 iProp = 0; iProp < 6; iProp++) - { - if (!pPropStrings[iProp]->IsEmpty()) - { - XMLElement *pProperty = ScriptXML.NewElement("property"); - pProperty->SetAttribute("name", *PropNames[iProp]); - pProperty->SetAttribute("ID", **pPropStrings[iProp]); - pEditorProperties->LinkEndChild(pProperty); - } - } - - // Editor Assets - XMLElement *pAssets = ScriptXML.NewElement("assets"); - pEditor->LinkEndChild(pAssets); - - for (auto it = pTemp->mAssets.begin(); it != pTemp->mAssets.end(); it++) - { - TString Source = (it->AssetSource == CScriptTemplate::SEditorAsset::eFile ? "file" : "property"); - TString Type; - - switch (it->AssetType) - { - case CScriptTemplate::SEditorAsset::eModel: Type = "model"; break; - case CScriptTemplate::SEditorAsset::eAnimParams: Type = "animparams"; break; - case CScriptTemplate::SEditorAsset::eBillboard: Type = "billboard"; break; - case CScriptTemplate::SEditorAsset::eCollision: Type = "collision"; break; - } - - s32 Force = -1; - if (it->AssetType == CScriptTemplate::SEditorAsset::eAnimParams) - Force = it->ForceNodeIndex; - - XMLElement *pAsset = ScriptXML.NewElement(*Type); - pAsset->SetAttribute("source", *Source); - if (Force >= 0) pAsset->SetAttribute("force", *TString::FromInt32(Force, 0, 10)); - pAsset->SetText(*it->AssetLocation); - pAssets->LinkEndChild(pAsset); - } - - // Attachments - if (!pTemp->mAttachments.empty()) - { - XMLElement *pAttachments = ScriptXML.NewElement("attachments"); - pEditor->LinkEndChild(pAttachments); - - for (auto it = pTemp->mAttachments.begin(); it != pTemp->mAttachments.end(); it++) - { - XMLElement *pAttachment = ScriptXML.NewElement("attachment"); - pAttachment->SetAttribute("propertyID", *it->AttachProperty); - pAttachment->SetAttribute("locator", *it->LocatorName); - pAttachments->LinkEndChild(pAttachment); - - // Sub-properties - if (it->AttachType != eAttach) - { - XMLElement *pAttachType = ScriptXML.NewElement("attach_type"); - pAttachType->SetText("follow"); - pAttachment->LinkEndChild(pAttachType); - } - } - } - - // Preview Scale - if (pTemp->mPreviewScale != 1.f) - { - XMLElement *pPreviewScale = ScriptXML.NewElement("preview_scale"); - pPreviewScale->SetText(*TString::FromFloat(pTemp->mPreviewScale)); - pEditor->LinkEndChild(pPreviewScale); - } - - // Rot/Scale Type - XMLElement *pRotType = ScriptXML.NewElement("rotation_type"); - pEditor->LinkEndChild(pRotType); - pRotType->SetText(pTemp->mRotationType == CScriptTemplate::eRotationEnabled ? "enabled" : "disabled"); - - XMLElement *pScaleType = ScriptXML.NewElement("scale_type"); - pEditor->LinkEndChild(pScaleType); - - if (pTemp->mScaleType != CScriptTemplate::eScaleVolume) - pScaleType->SetText(pTemp->mScaleType == CScriptTemplate::eScaleEnabled ? "enabled" : "disabled"); - - else - { - pScaleType->SetText("volume"); - - // Volume Preview - XMLElement *pVolume = ScriptXML.NewElement("preview_volume"); - pEditor->LinkEndChild(pVolume); - - // Enum -> String conversion lambda to avoid redundant code - auto GetVolumeString = [](EVolumeShape shape) -> TString - { - switch (shape) - { - case eBoxShape: return "Box"; - case eAxisAlignedBoxShape: return "AxisAlignedBox"; - case eEllipsoidShape: return "Ellipsoid"; - case eCylinderShape: return "Cylinder"; - case eConditionalShape: return "Conditional"; - default: return "INVALID"; - } - }; - - pVolume->SetAttribute("shape", *GetVolumeString(pTemp->mVolumeShape)); - - if (pTemp->mVolumeScale != 1.f) - pVolume->SetAttribute("scale", pTemp->mVolumeScale); - - if (pTemp->mVolumeShape == eConditionalShape) - { - pVolume->SetAttribute("propertyID", *pTemp->mVolumeConditionIDString); - - // Find conditional test property - IPropertyTemplate *pProp = pTemp->mpBaseStruct->PropertyByIDString(pTemp->mVolumeConditionIDString); - - // Write conditions - for (auto it = pTemp->mVolumeConditions.begin(); it != pTemp->mVolumeConditions.end(); it++) - { - // Value should be an integer, or a boolean condition - TString StrVal; - - if (pProp->Type() == eBoolProperty) - StrVal = (it->Value == 1 ? "true" : "false"); - else - StrVal = TString::HexString((u32) it->Value, (it->Value > 0xFF ? 8 : 2)); - - XMLElement *pCondition = ScriptXML.NewElement("condition"); - pCondition->SetAttribute("value", *StrVal); - pCondition->SetAttribute("shape", *GetVolumeString(it->Shape)); - if (it->Scale != 1.f) pCondition->SetAttribute("scale", it->Scale); - pVolume->LinkEndChild(pCondition); - } - } - } - - // Write to file - ScriptXML.SaveFile(*OutFile); -} - -void CTemplateWriter::SaveStructTemplate(CStructTemplate *pTemp) -{ - // Create directory - CMasterTemplate *pMaster = pTemp->MasterTemplate(); - TString OutFile = smTemplatesDir + pMaster->GetDirectory() + pTemp->mSourceFile; - TString OutDir = OutFile.GetFileDirectory(); - TString Name = OutFile.GetFileName(false); - FileUtil::MakeDirectory(OutDir); - - // Create new document and write struct properties to it - XMLDocument StructXML; - - XMLDeclaration *pDecl = StructXML.NewDeclaration(); - StructXML.LinkEndChild(pDecl); - - XMLElement *pRoot = StructXML.NewElement("struct"); - pRoot->SetAttribute("name", *Name); - pRoot->SetAttribute("type", (pTemp->IsSingleProperty() ? "single" : "multi")); - StructXML.LinkEndChild(pRoot); - - SaveProperties(&StructXML, pRoot, pTemp); - StructXML.SaveFile(*OutFile); -} - -void CTemplateWriter::SaveEnumTemplate(CEnumTemplate *pTemp) -{ - // Create directory - CMasterTemplate *pMaster = pTemp->MasterTemplate(); - TString OutFile = smTemplatesDir + pMaster->GetDirectory() + pTemp->mSourceFile; - TString OutDir = OutFile.GetFileDirectory(); - TString Name = OutFile.GetFileName(false); - FileUtil::MakeDirectory(OutDir); - - // Create new document and write enumerators to it - XMLDocument EnumXML; - - XMLDeclaration *pDecl = EnumXML.NewDeclaration(); - EnumXML.LinkEndChild(pDecl); - - XMLElement *pRoot = EnumXML.NewElement("enum"); - pRoot->SetAttribute("name", *Name); - EnumXML.LinkEndChild(pRoot); - - SaveEnumerators(&EnumXML, pRoot, pTemp); - EnumXML.SaveFile(*OutFile); -} - -void CTemplateWriter::SaveBitfieldTemplate(CBitfieldTemplate *pTemp) -{ - // Create directory - CMasterTemplate *pMaster = pTemp->MasterTemplate(); - TString OutFile = smTemplatesDir + pMaster->GetDirectory() + pTemp->mSourceFile; - TString OutDir = OutFile.GetFileDirectory(); - TString Name = pTemp->mSourceFile.GetFileName(false); - FileUtil::MakeDirectory(OutDir); - - // Create new document and write enumerators to it - XMLDocument BitfieldXML; - - XMLDeclaration *pDecl = BitfieldXML.NewDeclaration(); - BitfieldXML.LinkEndChild(pDecl); - - XMLElement *pRoot = BitfieldXML.NewElement("bitfield"); - pRoot->SetAttribute("name", *Name); - BitfieldXML.LinkEndChild(pRoot); - - SaveBitFlags(&BitfieldXML, pRoot, pTemp); - BitfieldXML.SaveFile(*OutFile); -} - -void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CStructTemplate *pTemp) -{ - // Create base element - XMLElement *pPropsBlock = pDoc->NewElement("properties"); - pParent->LinkEndChild(pPropsBlock); - - for (u32 iProp = 0; iProp < pTemp->Count(); iProp++) - { - // Get ID - IPropertyTemplate *pProp = pTemp->PropertyByIndex(iProp); - u32 ID = pProp->PropertyID(); - TString StrID = TString::HexString(ID, (ID > 0xFF ? 8 : 2)); - - // Create element - XMLElement *pElem; - - if (pProp->Type() == eStructProperty) - pElem = pDoc->NewElement("struct"); - else if (pProp->Type() == eEnumProperty) - pElem = pDoc->NewElement("enum"); - else if (pProp->Type() == eBitfieldProperty) - pElem = pDoc->NewElement("bitfield"); - else if (pProp->Type() == eArrayProperty) - pElem = pDoc->NewElement("array"); - else - pElem = pDoc->NewElement("property"); - - pPropsBlock->LinkEndChild(pElem); - - // Set common property parameters, starting with ID - pElem->SetAttribute("ID", *StrID); - - // Name - TString Name = pProp->Name(); - - if (pProp->Game() >= eEchoesDemo && ID > 0xFF) - { - TString MasterName = CMasterTemplate::PropertyName(ID); - - if (Name != MasterName) - pElem->SetAttribute("name", *Name); - } - - else - pElem->SetAttribute("name", *Name); - - // Type - if (pProp->Type() == eStructProperty) - { - CStructTemplate *pStruct = static_cast(pProp); - - if (pStruct->mSourceFile.IsEmpty()) - pElem->SetAttribute("type", (pStruct->mIsSingleProperty ? "single" : "multi")); - } - - else if (TString(pElem->Name()) == "property") - pElem->SetAttribute("type", *PropEnumToPropString(pProp->Type())); - - // Versions - CMasterTemplate *pMaster = pProp->MasterTemplate(); - u32 NumVersions = pProp->mAllowedVersions.size(); - - if (NumVersions > 0 && NumVersions != pMaster->mGameVersions.size()) - { - XMLElement *pVersions = pDoc->NewElement("versions"); - pElem->LinkEndChild(pVersions); - - for (u32 iVer = 0; iVer < pMaster->mGameVersions.size(); iVer++) - { - if (pProp->IsInVersion(iVer)) - { - XMLElement *pVersion = pDoc->NewElement("version"); - pVersion->SetText(*pMaster->mGameVersions[iVer]); - pVersions->LinkEndChild(pVersion); - } - } - } - - // Default - if (pProp->CanHaveDefault() && pProp->Game() >= eEchoesDemo) - { - XMLElement *pDefault = pDoc->NewElement("default"); - pDefault->SetText(*pProp->DefaultToString()); - pElem->LinkEndChild(pDefault); - } - - // Description - if (!pProp->Description().IsEmpty()) - { - XMLElement *pDesc = pDoc->NewElement("description"); - pDesc->SetText(*pProp->Description()); - pElem->LinkEndChild(pDesc); - } - - // Range - if (pProp->IsNumerical() && pProp->HasValidRange()) - { - XMLElement *pRange = pDoc->NewElement("range"); - pRange->SetText(*pProp->RangeToString()); - pElem->LinkEndChild(pRange); - } - - // Suffix - if (pProp->IsNumerical()) - { - TString Suffix = pProp->Suffix(); - - if (!Suffix.IsEmpty()) - { - XMLElement *pSuffix = pDoc->NewElement("suffix"); - pSuffix->SetText(*Suffix); - pElem->LinkEndChild(pSuffix); - } - } - - // Cook Pref - ECookPreference CookPref = pProp->CookPreference(); - - if (CookPref != eNoCookPreference) - { - XMLElement *pCookPref = pDoc->NewElement("cook_pref"); - pCookPref->SetText(CookPref == eAlwaysCook ? "always" : "never"); - pElem->LinkEndChild(pCookPref); - } - - // Asset-specific parameters - if (pProp->Type() == eAssetProperty) - { - CAssetTemplate *pAsset = static_cast(pProp); - const CResTypeFilter& rkFilter = pAsset->TypeFilter(); - TString ExtensionsString = rkFilter.ToString(); - if (ExtensionsString.IsEmpty()) ExtensionsString = "UNKN"; - pElem->SetAttribute("extensions", *ExtensionsString); - } - - // Enum-specific parameters - else if (pProp->Type() == eEnumProperty) - { - CEnumTemplate *pEnum = static_cast(pProp); - - if (pEnum->mSourceFile.IsEmpty()) - SaveEnumerators(pDoc, pElem, pEnum); - - else - { - SaveEnumTemplate(pEnum); - pElem->SetAttribute("template", *pEnum->mSourceFile); - } - } - - // Bitfield-specific parameters - else if (pProp->Type() == eBitfieldProperty) - { - CBitfieldTemplate *pBitfield = static_cast(pProp); - - if (pBitfield->mSourceFile.IsEmpty()) - SaveBitFlags(pDoc, pElem, pBitfield); - - else - { - SaveBitfieldTemplate(pBitfield); - pElem->SetAttribute("template", *pBitfield->mSourceFile); - } - } - - // Struct/array-specific parameters - else if (pProp->Type() == eStructProperty || pProp->Type() == eArrayProperty) - { - // Element Name - if (pProp->Type() == eArrayProperty) - { - CArrayTemplate *pArray = static_cast(pProp); - - if (!pArray->ElementName().IsEmpty()) - { - XMLElement *pElement = pDoc->NewElement("element_name"); - pElement->SetText(*static_cast(pProp)->ElementName()); - pElem->LinkEndChild(pElement); - } - } - - // Sub-properties - CStructTemplate *pStruct = static_cast(pProp); - - if (pStruct->mSourceFile.IsEmpty()) - SaveProperties(pDoc, pElem, pStruct); - - else - { - CStructTemplate *pOriginal = pMaster->StructAtSource(pStruct->mSourceFile); - - if (pOriginal) - SavePropertyOverrides(pDoc, pElem, pStruct, pOriginal); - - pElem->SetAttribute("template", *pStruct->mSourceFile); - } - } - } -} - -void CTemplateWriter::SavePropertyOverrides(XMLDocument *pDoc, XMLElement *pParent, CStructTemplate *pStruct, CStructTemplate *pOriginal) -{ - if (!pStruct->StructDataMatches(pOriginal)) - { - // Create base element - XMLElement *pPropsBlock = pDoc->NewElement("properties"); - pParent->LinkEndChild(pPropsBlock); - - for (u32 iProp = 0; iProp < pStruct->Count(); iProp++) - { - IPropertyTemplate *pProp = pStruct->PropertyByIndex(iProp); - IPropertyTemplate *pSource = pOriginal->PropertyByIndex(iProp); - - if (!pProp->Matches(pSource)) - { - // Create element - XMLElement *pElem; - - if (pProp->Type() == eStructProperty) - pElem = pDoc->NewElement("struct"); - else if (pProp->Type() == eEnumProperty) - pElem = pDoc->NewElement("enum"); - else if (pProp->Type() == eBitfieldProperty) - pElem = pDoc->NewElement("bitfield"); - else if (pProp->Type() == eArrayProperty) - pElem = pDoc->NewElement("array"); - else - pElem = pDoc->NewElement("property"); - - pPropsBlock->LinkEndChild(pElem); - - // ID - u32 ID = pProp->PropertyID(); - pElem->SetAttribute("ID", *TString::HexString(pProp->PropertyID(), (ID > 0xFF ? 8 : 2))); - - // Name - if (pProp->Name() != pSource->Name()) - pElem->SetAttribute("name", *pProp->Name()); - - // Default - if (pProp->CanHaveDefault() && !pProp->RawDefaultValue()->Matches(pSource->RawDefaultValue())) - { - XMLElement *pDefault = pDoc->NewElement("default"); - pDefault->SetText(*pProp->DefaultToString()); - pElem->LinkEndChild(pDefault); - } - - // Description - if (pProp->Description() != pSource->Description()) - { - XMLElement *pDesc = pDoc->NewElement("description"); - pDesc->SetText(*pProp->Description()); - pElem->LinkEndChild(pDesc); - } - - // Range - if (pProp->IsNumerical()) - { - TString Range = pProp->RangeToString(); - - if (Range != pSource->RangeToString()) - { - XMLElement *pRange = pDoc->NewElement("range"); - pRange->SetText(*Range); - pElem->LinkEndChild(pRange); - } - } - - // Suffix - if (pProp->Suffix() != pSource->Suffix()) - { - XMLElement *pSuffix = pDoc->NewElement("suffix"); - pSuffix->SetText(*pProp->Suffix()); - pElem->LinkEndChild(pSuffix); - } - - // Cook Pref - if (pProp->CookPreference() != pSource->CookPreference()) - { - XMLElement *pCookPref = pDoc->NewElement("cook_pref"); - - TString PrefStr; - if (pProp->CookPreference() == eAlwaysCook) PrefStr = "always"; - else if (pProp->CookPreference() == eNeverCook) PrefStr = "never"; - else PrefStr = "none"; - - pCookPref->SetText(*PrefStr); - pElem->LinkEndChild(pCookPref); - } - - // Asset-specific parameters - if (pProp->Type() == eAssetProperty) - { - CAssetTemplate *pAsset = static_cast(pProp); - CAssetTemplate *pSourceAsset = static_cast(pSource); - - if (pAsset->TypeFilter() != pSourceAsset->TypeFilter()) - { - TString ExtensionsString = pAsset->TypeFilter().ToString(); - if (ExtensionsString.IsEmpty()) ExtensionsString = "UNKN"; - pElem->SetAttribute("extensions", *ExtensionsString); - } - } - - // Struct/array-specific parameters - else if (pProp->Type() == eStructProperty || pProp->Type() == eArrayProperty) - { - CStructTemplate *pChildStruct = static_cast(pProp); - CStructTemplate *pSourceStruct = static_cast(pSource); - SavePropertyOverrides(pDoc, pElem, pChildStruct, pSourceStruct); - } - } - } - } -} - -void CTemplateWriter::SaveEnumerators(XMLDocument *pDoc, XMLElement *pParent, CEnumTemplate *pTemp) -{ - XMLElement *pEnumerators = pDoc->NewElement("enumerators"); - pParent->LinkEndChild(pEnumerators); - - for (u32 iEnum = 0; iEnum < pTemp->NumEnumerators(); iEnum++) - { - XMLElement *pElem = pDoc->NewElement("enumerator"); - u32 EnumerID = pTemp->EnumeratorID(iEnum); - pElem->SetAttribute("ID", *TString::HexString(EnumerID, (EnumerID > 0xFF ? 8 : 2))); - pElem->SetAttribute("name", *pTemp->EnumeratorName(iEnum)); - pEnumerators->LinkEndChild(pElem); - } -} - -void CTemplateWriter::SaveBitFlags(XMLDocument *pDoc, XMLElement *pParent, CBitfieldTemplate *pTemp) -{ - XMLElement *pFlags = pDoc->NewElement("flags"); - pParent->LinkEndChild(pFlags); - - for (u32 iFlag = 0; iFlag < pTemp->NumFlags(); iFlag++) - { - XMLElement *pElem = pDoc->NewElement("flag"); - pElem->SetAttribute("mask", *TString::HexString(pTemp->FlagMask(iFlag))); - pElem->SetAttribute("name", *pTemp->FlagName(iFlag)); - pFlags->LinkEndChild(pElem); - } -} -#endif diff --git a/src/Core/Resource/Cooker/CTemplateWriter.h b/src/Core/Resource/Cooker/CTemplateWriter.h deleted file mode 100644 index 4af5da30..00000000 --- a/src/Core/Resource/Cooker/CTemplateWriter.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CTEMPLATEWRITER_H -#define CTEMPLATEWRITER_H - -#include "Core/Resource/Script/CMasterTemplate.h" -#include "Core/Resource/Script/CScriptTemplate.h" -#include - -#if 0 -class CTemplateWriter -{ - CTemplateWriter(); - static TString smTemplatesDir; - -public: - static void SavePropertyTemplate(IPropertyTemplate *pTemp); - static void SaveAllTemplates(); - static void SaveGameTemplates(CMasterTemplate *pMaster); - static void SavePropertyList(); - static void SaveScriptTemplate(CScriptTemplate *pTemp); - static void SaveStructTemplate(CStructTemplate *pTemp); - static void SaveEnumTemplate(CEnumTemplate *pTemp); - static void SaveBitfieldTemplate(CBitfieldTemplate *pTemp); - static void SaveProperties(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CStructTemplate *pTemp); - static void SavePropertyOverrides(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CStructTemplate *pStruct, CStructTemplate *pOriginal); - static void SaveEnumerators(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CEnumTemplate *pTemp); - static void SaveBitFlags(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CBitfieldTemplate *pTemp); -}; -#endif - -#endif // CTEMPLATEWRITER_H diff --git a/src/Core/Resource/Factory/CScriptLoader.cpp b/src/Core/Resource/Factory/CScriptLoader.cpp index 7324a20c..f0bab080 100644 --- a/src/Core/Resource/Factory/CScriptLoader.cpp +++ b/src/Core/Resource/Factory/CScriptLoader.cpp @@ -19,49 +19,49 @@ CScriptLoader::CScriptLoader() { } -void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rSCLY) +void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY) { void* pData = (mpArrayItemData ? mpArrayItemData : mpObj->mPropertyData.data()); switch (pProp->Type()) { - case EPropertyTypeNew::Bool: + case EPropertyType::Bool: { CBoolProperty* pBool = TPropCast(pProp); pBool->ValueRef(pData) = rSCLY.ReadBool(); break; } - case EPropertyTypeNew::Byte: + case EPropertyType::Byte: { CByteProperty* pByte = TPropCast(pProp); pByte->ValueRef(pData) = rSCLY.ReadByte(); break; } - case EPropertyTypeNew::Short: + case EPropertyType::Short: { CShortProperty* pShort = TPropCast(pProp); pShort->ValueRef(pData) = rSCLY.ReadShort(); break; } - case EPropertyTypeNew::Int: + case EPropertyType::Int: { CIntProperty* pInt = TPropCast(pProp); pInt->ValueRef(pData) = rSCLY.ReadLong(); break; } - case EPropertyTypeNew::Float: + case EPropertyType::Float: { CFloatProperty* pFloat = TPropCast(pProp); pFloat->ValueRef(pData) = rSCLY.ReadFloat(); break; } - case EPropertyTypeNew::Choice: + case EPropertyType::Choice: { CChoiceProperty* pChoice = TPropCast(pProp); pChoice->ValueRef(pData) = rSCLY.ReadLong(); @@ -76,7 +76,7 @@ void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rS break; } - case EPropertyTypeNew::Enum: + case EPropertyType::Enum: { CEnumProperty* pEnum = TPropCast(pProp); pEnum->ValueRef(pData) = rSCLY.ReadLong(); @@ -91,7 +91,7 @@ void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rS break; } - case EPropertyTypeNew::Flags: + case EPropertyType::Flags: { CFlagsProperty* pFlags = TPropCast(pProp); pFlags->ValueRef(pData) = rSCLY.ReadLong(); @@ -107,28 +107,28 @@ void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rS break; } - case EPropertyTypeNew::String: + case EPropertyType::String: { CStringProperty* pString = TPropCast(pProp); pString->ValueRef(pData) = rSCLY.ReadString(); break; } - case EPropertyTypeNew::Vector: + case EPropertyType::Vector: { CVectorProperty* pVector = TPropCast(pProp); pVector->ValueRef(pData) = CVector3f(rSCLY); break; } - case EPropertyTypeNew::Color: + case EPropertyType::Color: { CColorProperty* pColor = TPropCast(pProp); pColor->ValueRef(pData) = CColor(rSCLY); break; } - case EPropertyTypeNew::Asset: + case EPropertyType::Asset: { CAssetProperty* pAsset = TPropCast(pProp); pAsset->ValueRef(pData) = CAssetID(rSCLY, mpMaster->Game()); @@ -153,34 +153,34 @@ void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rS break; } - case EPropertyTypeNew::Sound: + case EPropertyType::Sound: { CSoundProperty* pSound = TPropCast(pProp); pSound->ValueRef(pData) = rSCLY.ReadLong(); break; } - case EPropertyTypeNew::Animation: + case EPropertyType::Animation: { CAnimationProperty* pAnim = TPropCast(pProp); pAnim->ValueRef(pData) = rSCLY.ReadLong(); break; } - case EPropertyTypeNew::AnimationSet: + case EPropertyType::AnimationSet: { CAnimationSetProperty* pAnimSet = TPropCast(pProp); pAnimSet->ValueRef(pData) = CAnimationParameters(rSCLY, mpMaster->Game()); break; } - case EPropertyTypeNew::Sequence: + case EPropertyType::Sequence: { // TODO break; } - case EPropertyTypeNew::Spline: + case EPropertyType::Spline: { CSplineProperty* pSpline = TPropCast(pProp); std::vector& Buffer = pSpline->ValueRef(pData); @@ -189,7 +189,7 @@ void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rS break; } - case EPropertyTypeNew::Guid: + case EPropertyType::Guid: { ASSERT(Size == 16); CGuidProperty* pGuid = TPropCast(pProp); @@ -198,9 +198,9 @@ void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rS break; } - case EPropertyTypeNew::Struct: + case EPropertyType::Struct: { - CStructPropertyNew* pStruct = TPropCast(pProp); + CStructProperty* pStruct = TPropCast(pProp); if (mVersion < eEchoesDemo) LoadStructMP1(rSCLY, pStruct); @@ -209,7 +209,7 @@ void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rS break; } - case EPropertyTypeNew::Array: + case EPropertyType::Array: { CArrayProperty *pArray = TPropCast(pProp); int Count = rSCLY.ReadLong(); @@ -246,7 +246,7 @@ void CScriptLoader::ReadProperty(IPropertyNew *pProp, u32 Size, IInputStream& rS } } -void CScriptLoader::LoadStructMP1(IInputStream& rSCLY, CStructPropertyNew* pStruct) +void CScriptLoader::LoadStructMP1(IInputStream& rSCLY, CStructProperty* pStruct) { u32 StructStart = rSCLY.Tell(); @@ -263,10 +263,10 @@ void CScriptLoader::LoadStructMP1(IInputStream& rSCLY, CStructPropertyNew* pStru // Parse properties for (u32 ChildIndex = 0; ChildIndex < PropertyCount; ChildIndex++) { - IPropertyNew *pProperty = pStruct->ChildByIndex(ChildIndex); + IProperty *pProperty = pStruct->ChildByIndex(ChildIndex); //@todo version check - if (pProperty->CookPreference() != ECookPreferenceNew::Never) + if (pProperty->CookPreference() != ECookPreference::Never) ReadProperty(pProperty, 0, rSCLY); } } @@ -306,7 +306,7 @@ CScriptObject* CScriptLoader::LoadObjectMP1(IInputStream& rSCLY) } // Load object... - CStructPropertyNew* pProperties = pTemplate->Properties(); + CStructProperty* pProperties = pTemplate->Properties(); LoadStructMP1(rSCLY, pProperties); // Cleanup and return @@ -339,7 +339,7 @@ CScriptLayer* CScriptLoader::LoadLayerMP1(IInputStream& rSCLY) return mpLayer; } -void CScriptLoader::LoadStructMP2(IInputStream& rSCLY, CStructPropertyNew* pStruct) +void CScriptLoader::LoadStructMP2(IInputStream& rSCLY, CStructProperty* pStruct) { // Verify property count u32 ChildCount = pStruct->NumChildren(); @@ -350,7 +350,7 @@ void CScriptLoader::LoadStructMP2(IInputStream& rSCLY, CStructPropertyNew* pStru // Parse properties for (u32 ChildIdx = 0; ChildIdx < ChildCount; ChildIdx++) { - IPropertyNew* pProperty = nullptr; + IProperty* pProperty = nullptr; u32 PropertyStart = rSCLY.Tell(); u32 PropertyID = -1; u16 PropertySize = 0; diff --git a/src/Core/Resource/Factory/CScriptLoader.h b/src/Core/Resource/Factory/CScriptLoader.h index 6af0a33d..6512701d 100644 --- a/src/Core/Resource/Factory/CScriptLoader.h +++ b/src/Core/Resource/Factory/CScriptLoader.h @@ -19,13 +19,13 @@ class CScriptLoader void* mpArrayItemData; CScriptLoader(); - void ReadProperty(IPropertyNew* pProp, u32 Size, IInputStream& rSCLY); + void ReadProperty(IProperty* pProp, u32 Size, IInputStream& rSCLY); - void LoadStructMP1(IInputStream& rSCLY, CStructPropertyNew* pStruct); + void LoadStructMP1(IInputStream& rSCLY, CStructProperty* pStruct); CScriptObject* LoadObjectMP1(IInputStream& rSCLY); CScriptLayer* LoadLayerMP1(IInputStream& rSCLY); - void LoadStructMP2(IInputStream& rSCLY, CStructPropertyNew* pStruct); + void LoadStructMP2(IInputStream& rSCLY, CStructProperty* pStruct); CScriptObject* LoadObjectMP2(IInputStream& rSCLY); CScriptLayer* LoadLayerMP2(IInputStream& rSCLY); diff --git a/src/Core/Resource/Factory/CTemplateLoader.cpp b/src/Core/Resource/Factory/CTemplateLoader.cpp index 0453fb48..a8c116b5 100644 --- a/src/Core/Resource/Factory/CTemplateLoader.cpp +++ b/src/Core/Resource/Factory/CTemplateLoader.cpp @@ -1,6 +1,5 @@ #include "CTemplateLoader.h" #include "CAreaLoader.h" -#include "Core/Resource/Script/IPropertyTemplate.h" #include "Core/Resource/Script/Property/Properties.h" #include #include @@ -108,6 +107,28 @@ using namespace tinyxml2; break;\ }\ +EPropertyTypeNew PropStringToPropEnum(TString Prop) +{ + Prop = Prop.ToLower(); + if (Prop == "bool") return EPropertyTypeNew::Bool; + if (Prop == "byte") return EPropertyTypeNew::Byte; + if (Prop == "short") return EPropertyTypeNew::Short; + if (Prop == "long") return EPropertyTypeNew::Int; + if (Prop == "enum") return EPropertyTypeNew::Enum; + if (Prop == "bitfield") return EPropertyTypeNew::Flags; + if (Prop == "float") return EPropertyTypeNew::Float; + if (Prop == "string") return EPropertyTypeNew::String; + if (Prop == "color") return EPropertyTypeNew::Color; + if (Prop == "vector3f") return EPropertyTypeNew::Vector; + if (Prop == "sound") return EPropertyTypeNew::Sound; + if (Prop == "asset") return EPropertyTypeNew::Asset; + if (Prop == "struct") return EPropertyTypeNew::Struct; + if (Prop == "array") return EPropertyTypeNew::Array; + if (Prop == "character") return EPropertyTypeNew::AnimationSet; + if (Prop == "mayaspline") return EPropertyTypeNew::Spline; + return EPropertyTypeNew::Invalid; +} + IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate* pScript, CStructPropertyNew* pParent, const TString& rkTemplateName) { TString NodeType = TString(pElem->Name()).ToLower(); diff --git a/src/Core/Resource/Factory/CTemplateLoader.h b/src/Core/Resource/Factory/CTemplateLoader.h index 352119ad..c15fd637 100644 --- a/src/Core/Resource/Factory/CTemplateLoader.h +++ b/src/Core/Resource/Factory/CTemplateLoader.h @@ -3,7 +3,7 @@ #include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CScriptTemplate.h" -#include "Core/Resource/Script/IPropertyNew.h" +#include "Core/Resource/Script/Property/IProperty.h" #include "Core/Resource/Script/Property/CEnumProperty.h" #include "Core/Resource/Script/Property/CFlagsProperty.h" #include diff --git a/src/Core/Resource/Script/CMasterTemplate.cpp b/src/Core/Resource/Script/CMasterTemplate.cpp index 7e4cacd3..ba3f36f4 100644 --- a/src/Core/Resource/Script/CMasterTemplate.cpp +++ b/src/Core/Resource/Script/CMasterTemplate.cpp @@ -150,7 +150,7 @@ SMessage CMasterTemplate::MessageByIndex(u32 Index) return SMessage(Iter->first, Iter->second); } -IPropertyNew* CMasterTemplate::FindPropertyArchetype(const TString& kTypeName) +IProperty* CMasterTemplate::FindPropertyArchetype(const TString& kTypeName) { auto Iter = mPropertyTemplates.find(kTypeName); @@ -232,7 +232,7 @@ TString CMasterTemplate::PropertyName(u32 PropertyID) } // Removing these functions for now. I'm not sure of the best way to go about implementing them under the new system yet. -u32 CMasterTemplate::CreatePropertyID(IPropertyNew* pProp) +u32 CMasterTemplate::CreatePropertyID(IProperty* pProp) { // MP1 properties don't have IDs so we can use this function to create one to track instances of a particular property. // To ensure the IDs are unique we'll create a hash using two things: the struct source file and the ID string (relative to the struct). @@ -250,7 +250,7 @@ u32 CMasterTemplate::CreatePropertyID(IPropertyNew* pProp) return Hash.Digest(); } -void CMasterTemplate::AddProperty(IPropertyNew* pProp, const TString& rkTemplateName /*= ""*/) +void CMasterTemplate::AddProperty(IProperty* pProp, const TString& rkTemplateName /*= ""*/) { u32 ID; @@ -261,11 +261,11 @@ void CMasterTemplate::AddProperty(IPropertyNew* pProp, const TString& rkTemplate else { // For MP1 we only really need to track properties that come from struct templates. - IPropertyNew* pArchetype = pProp->Archetype(); + IProperty* pArchetype = pProp->Archetype(); if (!pArchetype || pArchetype->ScriptTemplate() != nullptr || - pArchetype->RootParent()->Type() != EPropertyTypeNew::Struct) + pArchetype->RootParent()->Type() != EPropertyType::Struct) return; ID = CreatePropertyID(pProp); @@ -307,7 +307,7 @@ void CMasterTemplate::AddProperty(IPropertyNew* pProp, const TString& rkTemplate } } -void CMasterTemplate::RenameProperty(IPropertyNew* pProp, const TString& rkNewName) +void CMasterTemplate::RenameProperty(IProperty* pProp, const TString& rkNewName) { u32 ID = pProp->ID(); if (ID <= 0xFF) ID = CreatePropertyID(pProp); @@ -352,7 +352,7 @@ void CMasterTemplate::XMLsUsingID(u32 ID, std::vector& rOutList) } } -const std::vector* CMasterTemplate::TemplatesWithMatchingID(IPropertyNew* pProp) +const std::vector* CMasterTemplate::TemplatesWithMatchingID(IProperty* pProp) { u32 ID = pProp->ID(); if (ID <= 0xFF) ID = CreatePropertyID(pProp); diff --git a/src/Core/Resource/Script/CMasterTemplate.h b/src/Core/Resource/Script/CMasterTemplate.h index 24e83295..c947fae3 100644 --- a/src/Core/Resource/Script/CMasterTemplate.h +++ b/src/Core/Resource/Script/CMasterTemplate.h @@ -84,15 +84,15 @@ class CMasterTemplate TString Path; /** Template in memory */ - std::shared_ptr pTemplate; + std::shared_ptr pTemplate; /** Constructor */ SPropertyTemplatePath() {} - SPropertyTemplatePath(const TString& kInPath, IPropertyNew* pInTemplate) + SPropertyTemplatePath(const TString& kInPath, IProperty* pInTemplate) : Path(kInPath) - , pTemplate( std::shared_ptr(pInTemplate) ) + , pTemplate( std::shared_ptr(pInTemplate) ) {} /** Serializer */ @@ -117,7 +117,7 @@ class CMasterTemplate struct SPropIDInfo { std::vector XMLList; // List of script/struct templates that use this ID - std::vector PropertyList; // List of all properties that use this ID + std::vector PropertyList; // List of all properties that use this ID }; static std::map smIDMap; static std::map smMasterMap; @@ -142,7 +142,7 @@ public: SMessage MessageByID(u32 MessageID); SMessage MessageByID(const CFourCC& MessageID); SMessage MessageByIndex(u32 Index); - IPropertyNew* FindPropertyArchetype(const TString& kTypeName); + IProperty* FindPropertyArchetype(const TString& kTypeName); TString GetGameDirectory(bool Absolute = false) const; // Inline Accessors @@ -159,12 +159,12 @@ public: static TString FindGameName(EGame Game); static EGame FindGameForName(const TString& rkName); static TString PropertyName(u32 PropertyID); - static u32 CreatePropertyID(IPropertyNew *pTemp); - static void AddProperty(IPropertyNew *pTemp, const TString& rkTemplateName = ""); - static void RenameProperty(IPropertyNew *pTemp, const TString& rkNewName); + static u32 CreatePropertyID(IProperty *pTemp); + static void AddProperty(IProperty *pTemp, const TString& rkTemplateName = ""); + static void RenameProperty(IProperty *pTemp, const TString& rkNewName); static void RenameProperty(u32 ID, const TString& rkNewName); static void XMLsUsingID(u32 ID, std::vector& rOutList); - static const std::vector* TemplatesWithMatchingID(IPropertyNew *pTemp); + static const std::vector* TemplatesWithMatchingID(IProperty *pTemp); }; #endif // CMASTERTEMPLATE_H diff --git a/src/Core/Resource/Script/CScriptObject.cpp b/src/Core/Resource/Script/CScriptObject.cpp index e80c3588..9daa217f 100644 --- a/src/Core/Resource/Script/CScriptObject.cpp +++ b/src/Core/Resource/Script/CScriptObject.cpp @@ -15,7 +15,7 @@ CScriptObject::CScriptObject(u32 InstanceID, CGameArea *pArea, CScriptLayer *pLa mpTemplate->AddObject(this); // Init properties - CStructPropertyNew* pProperties = pTemplate->Properties(); + CStructProperty* pProperties = pTemplate->Properties(); u32 PropertiesSize = pProperties->DataSize(); mPropertyData.resize( PropertiesSize ); @@ -82,7 +82,7 @@ void CScriptObject::EvaluateVolume() mVolumeScale = mpTemplate->VolumeScale(this); } -bool CScriptObject::IsEditorProperty(IPropertyNew *pProp) +bool CScriptObject::IsEditorProperty(IProperty *pProp) { return ( (pProp == mInstanceName.Property()) || (pProp == mPosition.Property()) || diff --git a/src/Core/Resource/Script/CScriptObject.h b/src/Core/Resource/Script/CScriptObject.h index 58dec217..d508b4d5 100644 --- a/src/Core/Resource/Script/CScriptObject.h +++ b/src/Core/Resource/Script/CScriptObject.h @@ -59,7 +59,7 @@ public: void EvaluateDisplayAsset(); void EvaluateCollisionModel(); void EvaluateVolume(); - bool IsEditorProperty(IPropertyNew *pProp); + bool IsEditorProperty(IProperty *pProp); void SetLayer(CScriptLayer *pLayer, u32 NewLayerIndex = -1); u32 LayerIndex() const; bool HasNearVisibleActivation() const; diff --git a/src/Core/Resource/Script/CScriptTemplate.cpp b/src/Core/Resource/Script/CScriptTemplate.cpp index 590f9ffa..3f14a9ec 100644 --- a/src/Core/Resource/Script/CScriptTemplate.cpp +++ b/src/Core/Resource/Script/CScriptTemplate.cpp @@ -86,7 +86,7 @@ void CScriptTemplate::PostLoad() if (!mRotationIDString.IsEmpty()) mpRotationProperty = TPropCast( mpProperties->ChildByIDString(mRotationIDString) ); if (!mScaleIDString.IsEmpty()) mpScaleProperty = TPropCast( mpProperties->ChildByIDString(mScaleIDString) ); if (!mActiveIDString.IsEmpty()) mpActiveProperty = TPropCast( mpProperties->ChildByIDString(mActiveIDString) ); - if (!mLightParametersIDString.IsEmpty()) mpLightParametersProperty = TPropCast( mpProperties->ChildByIDString(mLightParametersIDString) ); + if (!mLightParametersIDString.IsEmpty()) mpLightParametersProperty = TPropCast( mpProperties->ChildByIDString(mLightParametersIDString) ); } EGame CScriptTemplate::Game() const @@ -96,10 +96,10 @@ EGame CScriptTemplate::Game() const // ************ PROPERTY FETCHING ************ template -PropType* TFetchProperty(CStructPropertyNew* pProperties, const TIDString& rkID) +PropType* TFetchProperty(CStructProperty* pProperties, const TIDString& rkID) { if (rkID.IsEmpty()) return nullptr; - IPropertyNew *pProp = pProperties->ChildByIDString(rkID); + IProperty *pProp = pProperties->ChildByIDString(rkID); if (pProp && (pProp->Type() == PropEnum)) return static_cast(pProp)->ValuePtr(); @@ -147,7 +147,7 @@ s32 CScriptTemplate::CheckVolumeConditions(CScriptObject *pObj, bool LogErrors) if (mVolumeShape == eConditionalShape) { TIDString PropID = mVolumeConditionIDString; - IPropertyNew* pProp = pObj->Template()->Properties()->ChildByIDString( PropID ); + IProperty* pProp = pObj->Template()->Properties()->ChildByIDString( PropID ); // Get value of the condition test property (only boolean, integral, and enum types supported) void* pData = pObj->PropertyData(); @@ -155,24 +155,24 @@ s32 CScriptTemplate::CheckVolumeConditions(CScriptObject *pObj, bool LogErrors) switch (pProp->Type()) { - case EPropertyTypeNew::Bool: + case EPropertyType::Bool: Val = TPropCast(pProp)->Value(pData) ? 1 : 0; break; - case EPropertyTypeNew::Byte: + case EPropertyType::Byte: Val = (int) TPropCast(pProp)->Value(pData); break; - case EPropertyTypeNew::Short: + case EPropertyType::Short: Val = (int) TPropCast(pProp)->Value(pData); break; - case EPropertyTypeNew::Int: + case EPropertyType::Int: Val = TPropCast(pProp)->Value(pData); break; - case EPropertyTypeNew::Enum: - case EPropertyTypeNew::Choice: + case EPropertyType::Enum: + case EPropertyType::Choice: Val = TPropCast(pProp)->Value(pData); break; } @@ -209,9 +209,9 @@ CResource* CScriptTemplate::FindDisplayAsset(void* pPropertyData, u32& rOutCharI // Property else { - IPropertyNew* pProp = mpProperties->ChildByIDString(it->AssetLocation); + IProperty* pProp = mpProperties->ChildByIDString(it->AssetLocation); - if (it->AssetType == SEditorAsset::eAnimParams && pProp->Type() == EPropertyTypeNew::AnimationSet) + if (it->AssetType == SEditorAsset::eAnimParams && pProp->Type() == EPropertyType::AnimationSet) { CAnimationSetProperty* pAnimSet = TPropCast(pProp); CAnimationParameters Params = pAnimSet->Value(pPropertyData); @@ -227,7 +227,7 @@ CResource* CScriptTemplate::FindDisplayAsset(void* pPropertyData, u32& rOutCharI else { - ASSERT(pProp->Type() == EPropertyTypeNew::Asset); + ASSERT(pProp->Type() == EPropertyType::Asset); CAssetProperty* pAsset = TPropCast(pProp); CAssetID ID = pAsset->Value(pPropertyData); CResourceEntry *pEntry = gpResourceStore->FindEntry( ID ); @@ -261,9 +261,9 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(void* pPropertyData) // Property else { - IPropertyNew* pProp = mpProperties->ChildByIDString(it->AssetLocation); + IProperty* pProp = mpProperties->ChildByIDString(it->AssetLocation); - if (pProp->Type() == EPropertyTypeNew::Asset) + if (pProp->Type() == EPropertyType::Asset) { CAssetProperty* pAsset = TPropCast(pProp); pRes = gpResourceStore->LoadResource( pAsset->Value(pPropertyData), eDynamicCollision ); diff --git a/src/Core/Resource/Script/CScriptTemplate.h b/src/Core/Resource/Script/CScriptTemplate.h index ae041198..2291d153 100644 --- a/src/Core/Resource/Script/CScriptTemplate.h +++ b/src/Core/Resource/Script/CScriptTemplate.h @@ -2,7 +2,6 @@ #define CSCRIPTTEMPLATE_H #include "Core/Resource/Script/Property/Properties.h" -#include "EPropertyType.h" #include "EVolumeShape.h" #include "Core/Resource/Model/CModel.h" #include "Core/Resource/CCollisionMeshGroup.h" diff --git a/src/Core/Resource/Script/EPropertyType.h b/src/Core/Resource/Script/EPropertyType.h deleted file mode 100644 index 0f86d1f9..00000000 --- a/src/Core/Resource/Script/EPropertyType.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef EPROPERTYTYPE -#define EPROPERTYTYPE - -#include "IPropertyNew.h" - -#if 0 -#include - -enum EPropertyType -{ - eBoolProperty, - eByteProperty, - eShortProperty, - eLongProperty, - eEnumProperty, - eBitfieldProperty, - eFloatProperty, - eStringProperty, - eVector3Property, - eColorProperty, - eSoundProperty, - eAssetProperty, - eStructProperty, - eArrayProperty, - eCharacterProperty, - eMayaSplineProperty, - eUnknownProperty, - eInvalidProperty -}; -#endif - -// functions defined in IPropertyTemplate.cpp -EPropertyTypeNew PropStringToPropEnum(TString Prop); -TString PropEnumToPropString(EPropertyTypeNew Prop); -const char* HashablePropTypeName(EPropertyTypeNew Prop); - -#endif // EPROPERTYTYPE - diff --git a/src/Core/Resource/Script/IProperty.cpp b/src/Core/Resource/Script/IProperty.cpp deleted file mode 100644 index ba015407..00000000 --- a/src/Core/Resource/Script/IProperty.cpp +++ /dev/null @@ -1,245 +0,0 @@ -#include "IProperty.h" -#include "IPropertyTemplate.h" - -#if 0 -// ************ IProperty ************ -bool IProperty::IsInArray() const -{ - CPropertyStruct *pParent = mpParent; - - while (pParent) - { - if (pParent->Type() == eArrayProperty) return true; - pParent = pParent->Parent(); - } - - return false; -} - -CPropertyStruct* IProperty::RootStruct() -{ - return (mpParent ? mpParent->RootStruct() : Type() == eStructProperty ? static_cast(this) : nullptr); -} - -IPropertyTemplate* IProperty::Template() const -{ - return mpTemplate; -} - -TString IProperty::Name() const -{ - return mpTemplate->Name(); -} - -u32 IProperty::ID() const -{ - if (mpParent && mpParent->Type() == eArrayProperty) - return ArrayIndex(); - else - return mpTemplate->PropertyID(); -} - -TIDString IProperty::IDString(bool FullPath) const -{ - TIDString Out; - - if (ID() != 0xFFFFFFFF) - { - if (mpParent && FullPath) - { - Out = mpParent->IDString(true); - if (!Out.IsEmpty()) Out += ":"; - } - - Out += TString::HexString(ID()); - } - - return Out; -} - -u32 IProperty::ArrayIndex() const -{ - CArrayProperty *pArray = TPropCast(mpParent); - - if (pArray) - { - for (u32 iSub = 0; iSub < pArray->Count(); iSub++) - { - if (pArray->PropertyByIndex(iSub) == this) - return iSub; - } - } - - return -1; -} - -bool IProperty::ShouldCook() -{ - if (mpTemplate->CookPreference() == eNeverCook) return false; - else if (mpTemplate->CookPreference() == eAlwaysCook) return true; - - else - { - if (mpTemplate->Game() == eReturns) - return !MatchesDefault(); - else - return true; - } -} - -bool IProperty::MatchesDefault() -{ - const IPropertyValue *pkValue = RawValue(); - const IPropertyValue *pkDefault = mpTemplate->RawDefaultValue(); - if (!pkValue || !pkDefault) return false; - else return pkValue->Matches(pkDefault); -} - -// ************ TAssetProperty ************ -TAssetProperty::TAssetProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent) - : TTypedProperty(pTemp, pInstance, pParent, CAssetID::InvalidID( pTemp->Game() )) -{ -} - -// ************ CPropertyStruct ************ -void CPropertyStruct::Copy(const IProperty *pkProp) -{ - const CPropertyStruct *pkSource = static_cast(pkProp); - - for (u32 iSub = 0; iSub < mProperties.size(); iSub++) - mProperties[iSub]->Copy(pkSource->mProperties[iSub]); -} - -bool CPropertyStruct::ShouldCook() -{ - if (mpTemplate->CookPreference() == eNeverCook) return false; - - for (u32 iProp = 0; iProp < mProperties.size(); iProp++) - { - if (mProperties[iProp]->ShouldCook()) - return true; - } - - return false; -} - -IProperty* CPropertyStruct::PropertyByIndex(u32 index) const -{ - return mProperties[index]; -} - -IProperty* CPropertyStruct::PropertyByID(u32 ID) const -{ - for (auto it = mProperties.begin(); it != mProperties.end(); it++) - { - if ((*it)->ID() == ID) - return *it; - } - return nullptr; -} - -IProperty* CPropertyStruct::PropertyByIDString(const TIDString& rkStr) const -{ - // Resolve namespace - u32 NSStart = rkStr.IndexOf(":"); - - // String has namespace; the requested property is within a struct - if (NSStart != -1) - { - TString StrStructID = rkStr.Truncate(NSStart); - if (!StrStructID.IsHexString()) return nullptr; - - u32 StructID = StrStructID.ToInt32(); - TString PropName = rkStr.ChopFront(NSStart + 1); - - CPropertyStruct *pStruct = StructByID(StructID); - if (!pStruct) return nullptr; - else return pStruct->PropertyByIDString(PropName); - } - - // No namespace; fetch the property from this struct - else - { - if (rkStr.IsHexString()) - return PropertyByID(rkStr.ToInt32()); - else - return nullptr; - } -} - -CPropertyStruct* CPropertyStruct::StructByIndex(u32 index) const -{ - IProperty *pProp = PropertyByIndex(index); - - if (pProp->Type() == eStructProperty || pProp->Type() == eArrayProperty) - return static_cast(pProp); - else - return nullptr; -} - -CPropertyStruct* CPropertyStruct::StructByID(u32 ID) const -{ - IProperty *pProp = PropertyByID(ID); - - if (pProp->Type() == eStructProperty || pProp->Type() == eArrayProperty) - return static_cast(pProp); - else - return nullptr; -} - -CPropertyStruct* CPropertyStruct::StructByIDString(const TIDString& rkStr) const -{ - IProperty *pProp = PropertyByIDString(rkStr); - - if (pProp->Type() == eStructProperty || pProp->Type() == eArrayProperty) - return static_cast(pProp); - else - return nullptr; -} - -// ************ CArrayProperty ************ -void CArrayProperty::Copy(const IProperty *pkProp) -{ - const CArrayProperty *pkSource = static_cast(pkProp); - Resize(pkSource->Count()); - - for (u32 iSub = 0; iSub < mProperties.size(); iSub++) - mProperties[iSub]->Copy(pkSource->mProperties[iSub]); -} - -bool CArrayProperty::ShouldCook() -{ - return (mpTemplate->CookPreference() == eNeverCook ? false : true); -} - -void CArrayProperty::Resize(int Size) -{ - int OldSize = mProperties.size(); - if (OldSize == Size) return; - - if (Size < OldSize) - { - for (int iProp = mProperties.size() - 1; iProp >= Size; iProp--) - delete mProperties[iProp]; - } - - mProperties.resize(Size); - - if (Size > OldSize) - { - for (int iProp = OldSize; iProp < Size; iProp++) - mProperties[iProp] = static_cast(mpTemplate)->CreateSubStruct(Instance(), this); - } -} - -CStructTemplate* CArrayProperty::SubStructTemplate() const -{ - // CArrayTemplate inherits from CStructTemplate. The template defines the substruct structure. - return static_cast(Template()); -} - -TString CArrayProperty::ElementName() const -{ - return static_cast(Template())->ElementName(); -} -#endif diff --git a/src/Core/Resource/Script/IProperty.h b/src/Core/Resource/Script/IProperty.h deleted file mode 100644 index 18dc3988..00000000 --- a/src/Core/Resource/Script/IProperty.h +++ /dev/null @@ -1,303 +0,0 @@ -#ifndef IPROPERTY -#define IPROPERTY - -#if 0 -#include "EPropertyType.h" -#include "IPropertyValue.h" -#include "Core/Resource/CResource.h" -#include "Core/Resource/TResPtr.h" -#include "Core/Resource/Animation/CAnimationParameters.h" -#include -#include -#include -#include - -class CScriptObject; -class CScriptTemplate; -class CStructTemplate; -class IPropertyTemplate; -typedef TString TIDString; - -/* - * IProperty is the base class, containing just some virtual function definitions - */ -class IProperty -{ -protected: - class CPropertyStruct *mpParent; - CScriptObject *mpInstance; - IPropertyTemplate *mpTemplate; - -public: - IProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent) - : mpParent(pParent) - , mpInstance(pInstance) - , mpTemplate(pTemp) - { - } - - virtual ~IProperty() {} - virtual EPropertyType Type() const = 0; - virtual TString ToString() const { return ""; } - virtual IPropertyValue* RawValue() { return nullptr; } - virtual void Copy(const IProperty *pkProp) = 0; - virtual IProperty* Clone(CScriptObject *pInstance, CPropertyStruct *pParent = 0) const = 0; - virtual bool Matches(const IProperty *pkProp) const = 0; - - virtual bool ShouldCook(); // Can't be const because it calls MatchesDefault() - virtual bool MatchesDefault(); // Can't be const because RawValue() isn't const - - inline CScriptObject* Instance() const { return mpInstance; } - inline CPropertyStruct* Parent() const { return mpParent; } - inline void SetParent(CPropertyStruct *pParent) { mpParent = pParent; } - - bool IsInArray() const; - CPropertyStruct* RootStruct(); - - // These functions can't be in the header to avoid circular includes with IPropertyTemplate.h - IPropertyTemplate* Template() const; - TString Name() const; - u32 ID() const; - TIDString IDString(bool FullPath) const; - u32 ArrayIndex() const; -}; - -/* - * TTypedProperty is a template subclass for actual properties. - */ -#define IMPLEMENT_PROPERTY_CLONE(ClassName) \ - virtual IProperty* Clone(CScriptObject *pInstance, CPropertyStruct *pParent) const \ - { \ - if (!pParent) pParent = mpParent; \ - ClassName *pOut = new ClassName(mpTemplate, pInstance, pParent); \ - pOut->Copy(this); \ - return pOut; \ - } - -template -class TTypedProperty : public IProperty -{ - ValueClass mValue; -public: - TTypedProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent) - : IProperty(pTemp, pInstance, pParent) {} - - TTypedProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent, ValueType v) - : IProperty(pTemp, pInstance, pParent), mValue(v) {} - - ~TTypedProperty() {} - virtual EPropertyType Type() const { return TypeEnum; } - static inline EPropertyType StaticType() { return TypeEnum; } - - virtual TString ToString() const { return mValue.ToString(); } - virtual IPropertyValue* RawValue() { return &mValue; } - - virtual void Copy(const IProperty *pkProp) - { - const TTypedProperty *pkCast = static_cast(pkProp); - mValue.Set(pkCast->mValue.Get()); - } - - IMPLEMENT_PROPERTY_CLONE(TTypedProperty) - - virtual bool Matches(const IProperty *pkProp) const - { - const TTypedProperty *pkTyped = static_cast(pkProp); - return ( (Type() == pkTyped->Type()) && - mValue.Matches(&pkTyped->mValue) ); - } - - inline ValueType Get() const { return mValue.Get(); } - inline void Set(ValueType v) { mValue.Set(v); } -}; -typedef TTypedProperty TBoolProperty; -typedef TTypedProperty TByteProperty; -typedef TTypedProperty TShortProperty; -typedef TTypedProperty TLongProperty; -typedef TTypedProperty TEnumProperty; -typedef TTypedProperty TBitfieldProperty; -typedef TTypedProperty TFloatProperty; -typedef TTypedProperty TVector3Property; -typedef TTypedProperty TColorProperty; -typedef TTypedProperty, eUnknownProperty, CUnknownValue> TUnknownProperty; - -/* - * TStringProperty, TSoundProperty, TAssetProperty, and TCharacterProperty get little subclasses in order to override some virtual functions. - */ -#define IMPLEMENT_PROPERTY_CTORS(ClassName, ValueType) \ - ClassName(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent) \ - : TTypedProperty(pTemp, pInstance, pParent) {} \ - \ - ClassName(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent, ValueType v) \ - : TTypedProperty(pTemp, pInstance, pParent, v) {} - -class TStringProperty : public TTypedProperty -{ -public: - IMPLEMENT_PROPERTY_CTORS(TStringProperty, TString) - IMPLEMENT_PROPERTY_CLONE(TStringProperty) - virtual bool MatchesDefault() { return Get().IsEmpty(); } - virtual bool ShouldCook() { return true; } -}; - -class TSoundProperty : public TTypedProperty -{ -public: - IMPLEMENT_PROPERTY_CTORS(TSoundProperty, u32) - IMPLEMENT_PROPERTY_CLONE(TSoundProperty) - virtual bool MatchesDefault() { return Get() == 0xFFFFFFFF; } -}; - -class TAssetProperty : public TTypedProperty -{ -public: - TAssetProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent); // Can't be in the header because needs to check the template to set the correct ID length - TAssetProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent, CAssetID v) - : TTypedProperty(pTemp, pInstance, pParent, v) {} - - IMPLEMENT_PROPERTY_CLONE(TAssetProperty) - virtual bool MatchesDefault() { return !Get().IsValid(); } - virtual bool ShouldCook() { return true; } -}; - -class TCharacterProperty : public TTypedProperty -{ -public: - IMPLEMENT_PROPERTY_CTORS(TCharacterProperty, CAnimationParameters) - IMPLEMENT_PROPERTY_CLONE(TCharacterProperty) - virtual bool MatchesDefault() { return Get().AnimSet() == nullptr; } - virtual bool ShouldCook() { return true; } -}; - -class TMayaSplineProperty : public TTypedProperty, eMayaSplineProperty, CMayaSplineValue> -{ -public: - IMPLEMENT_PROPERTY_CTORS(TMayaSplineProperty, std::vector) - IMPLEMENT_PROPERTY_CLONE(TMayaSplineProperty) - virtual bool MatchesDefault() { return Get().empty(); } -}; - -/* - * CPropertyStruct is for defining structs of properties. - */ -class CPropertyStruct : public IProperty -{ - friend class CScriptLoader; -protected: - std::vector mProperties; -public: - CPropertyStruct(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent) - : IProperty(pTemp, pInstance, pParent) {} - - ~CPropertyStruct() - { - for (auto it = mProperties.begin(); it != mProperties.end(); it++) - delete *it; - } - - EPropertyType Type() const { return eStructProperty; } - static inline EPropertyType StaticType() { return eStructProperty; } - - virtual void Copy(const IProperty *pkProp); - - virtual IProperty* Clone(CScriptObject *pInstance, CPropertyStruct *pParent) const - { - if (!pParent) pParent = mpParent; - CPropertyStruct *pOut = new CPropertyStruct(mpTemplate, pInstance, pParent); - pOut->Copy(this); - return pOut; - } - - virtual bool Matches(const IProperty *pkProp) const - { - const CPropertyStruct *pkStruct = static_cast(pkProp); - - if ( (Type() == pkStruct->Type()) && - (mProperties.size() == pkStruct->mProperties.size()) ) - { - for (u32 iProp = 0; iProp < mProperties.size(); iProp++) - { - if (!mProperties[iProp]->Matches(pkStruct->mProperties[iProp])) - return false; - } - - return true; - } - - return false; - } - - virtual bool MatchesDefault() - { - for (u32 iProp = 0; iProp < mProperties.size(); iProp++) - { - if (!mProperties[iProp]->MatchesDefault()) - return false; - } - - return true; - } - - virtual bool ShouldCook(); - - // Inline - inline u32 Count() const { return mProperties.size(); } - inline void AddSubProperty(IProperty *pProp) { mProperties.push_back(pProp); } - inline IProperty* operator[](u32 index) { return mProperties[index]; } - - // Functions - IProperty* PropertyByIndex(u32 index) const; - IProperty* PropertyByID(u32 ID) const; - IProperty* PropertyByIDString(const TIDString& rkStr) const; - CPropertyStruct* StructByIndex(u32 index) const; - CPropertyStruct* StructByID(u32 ID) const; - CPropertyStruct* StructByIDString(const TIDString& rkStr) const; -}; - -/* - * CArrayProperty stores a repeated property struct. - */ -class CArrayProperty : public CPropertyStruct -{ - friend class CScriptLoader; - -public: - CArrayProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent) - : CPropertyStruct(pTemp, pInstance, pParent) {} - - EPropertyType Type() const { return eArrayProperty; } - static inline EPropertyType StaticType() { return eArrayProperty; } - - virtual void Copy(const IProperty *pkProp); - - virtual IProperty* Clone(CScriptObject *pInstance, CPropertyStruct *pParent) const - { - if (!pParent) pParent = mpParent; - CArrayProperty *pOut = new CArrayProperty(mpTemplate, pInstance, pParent); - pOut->Copy(this); - return pOut; - } - - virtual bool MatchesDefault() { return mProperties.empty(); } - virtual bool ShouldCook(); - - // Inline - inline void Reserve(u32 amount) { mProperties.reserve(amount); } - - // Functions - void Resize(int Size); - CStructTemplate* SubStructTemplate() const; - TString ElementName() const; -}; - -/* - * Function for casting properties. Returns null if the property is not actually the requested type. - */ -template -PropertyClass* TPropCast(IProperty *pProp) -{ - return (pProp && pProp->Type() == PropertyClass::StaticType() ? static_cast(pProp) : nullptr); -} -#endif -#endif // IPROPERTY - diff --git a/src/Core/Resource/Script/IPropertyTemplate.cpp b/src/Core/Resource/Script/IPropertyTemplate.cpp deleted file mode 100644 index c890afea..00000000 --- a/src/Core/Resource/Script/IPropertyTemplate.cpp +++ /dev/null @@ -1,346 +0,0 @@ -#include "IPropertyTemplate.h" -#include "CMasterTemplate.h" -#include -#include - -#if 0 -// ************ IPropertyTemplate ************ -EGame IPropertyTemplate::Game() const -{ - return (mpMasterTemplate ? mpMasterTemplate->Game() : eUnknownGame); -} - -bool IPropertyTemplate::IsInVersion(u32 Version) const -{ - if (mAllowedVersions.empty()) - return true; - - for (u32 iVer = 0; iVer < mAllowedVersions.size(); iVer++) - if (mAllowedVersions[iVer] == Version) - return true; - - return false; -} - -TString IPropertyTemplate::FullName() const -{ - return mpParent ? mpParent->FullName() + "::" + Name() : Name(); -} - -TIDString IPropertyTemplate::IDString(bool FullPath) const -{ - if (mID != 0xFFFFFFFF) - { - TIDString Out; - - if (mpParent && FullPath) - { - Out = mpParent->IDString(true); - if (!Out.IsEmpty()) Out += ":"; - } - - Out += TIDString::HexString(mID); - return Out; - } - else return ""; -} - -bool IPropertyTemplate::IsDescendantOf(const CStructTemplate *pStruct) const -{ - CStructTemplate *pParent = mpParent; - - while (pParent) - { - if (pParent == pStruct) return true; - pParent = pParent->Parent(); - } - - return false; -} - -bool IPropertyTemplate::IsFromStructTemplate() const -{ - const CStructTemplate *pParent = Parent(); - - while (pParent) - { - if (!pParent->SourceFile().IsEmpty()) return true; - pParent = pParent->Parent(); - } - - return false; -} - -bool IPropertyTemplate::IsNameCorrect() const -{ - // Check whether the property name is correct... i.e., if we hash it, does it match the property ID? - // Only valid for Prime 2 and up, since Prime 1 doesn't have real property IDs, so we can't validate names - if (Game() >= eEchoesDemo) - { - // Don't hash for single-property structs - if ( (!Parent() || !Parent()->IsSingleProperty()) && - // Don't hash for the three properties in EditorProperties that have fourCC property IDs - mID != FOURCC('INAM') && - mID != FOURCC('XFRM') && - mID != FOURCC('ACTV') ) - { - // Only re-hash if we need to. Save the result (output won't change if function is called multiple times) - if (!mHasCachedNameCheck) - { - // The property ID is just a CRC32 of the property name + the type - CCRC32 Hash; - Hash.Hash(*mName); - Hash.Hash(GetTypeNameString()); - mCachedNameIsCorrect = Hash.Digest() == mID; - mHasCachedNameCheck = true; - } - return mCachedNameIsCorrect; - } - } - - return true; -} - -TString IPropertyTemplate::FindStructSource() const -{ - const CStructTemplate *pkStruct = mpParent; - - while (pkStruct) - { - if (!pkStruct->SourceFile().IsEmpty()) return pkStruct->SourceFile(); - pkStruct = pkStruct->Parent(); - } - - return ""; -} - -CStructTemplate* IPropertyTemplate::RootStruct() -{ - if (mpParent) return mpParent->RootStruct(); - else if (Type() == eStructProperty) return static_cast(this); - else return nullptr; -} - -// ************ CStructTemplate ************ -void CStructTemplate::CopyStructData(const CStructTemplate *pkStruct) -{ - mVersionPropertyCounts = pkStruct->mVersionPropertyCounts; - mIsSingleProperty = pkStruct->mIsSingleProperty; - mSourceFile = pkStruct->mSourceFile; - mTypeName = pkStruct->mTypeName; - - mSubProperties.resize(pkStruct->mSubProperties.size()); - - for (u32 iSub = 0; iSub < pkStruct->mSubProperties.size(); iSub++) - { - mSubProperties[iSub] = pkStruct->mSubProperties[iSub]->Clone(mpScriptTemplate, this); - CMasterTemplate::AddProperty(mSubProperties[iSub]); - } -} - -u32 CStructTemplate::PropertyCountForVersion(u32 Version) -{ - if (Version == -1) Version = 0; - return mVersionPropertyCounts[Version]; -} - -u32 CStructTemplate::VersionForPropertyCount(u32 PropCount) -{ - for (u32 iVer = 0; iVer < NumVersions(); iVer++) - if (mVersionPropertyCounts[iVer] == PropCount) - return iVer; - - return -1; -} - -IPropertyTemplate* CStructTemplate::PropertyByIndex(u32 index) -{ - if (mSubProperties.size() > index) - return mSubProperties[index]; - else - return nullptr; -} - -IPropertyTemplate* CStructTemplate::PropertyByID(u32 ID) -{ - for (auto it = mSubProperties.begin(); it != mSubProperties.end(); it++) - { - if ((*it)->PropertyID() == ID) - return *it; - } - return nullptr; -} - -IPropertyTemplate* CStructTemplate::PropertyByIDString(const TIDString& str) -{ - // Resolve namespace - u32 nsStart = str.IndexOf(":"); - u32 propStart = nsStart + 1; - - // String has namespace; the requested property is within a struct - if (nsStart != -1) - { - TString strStructID = str.SubString(0, nsStart); - if (!strStructID.IsHexString()) return nullptr; - - u32 structID = strStructID.ToInt32(); - TString propName = str.SubString(propStart, str.Length() - propStart); - - CStructTemplate *pStruct = StructByID(structID); - if (!pStruct) return nullptr; - else return pStruct->PropertyByIDString(propName); - } - - // No namespace; fetch the property from this struct - else - { - // ID string lookup - if (str.IsHexString()) - return PropertyByID(str.ToInt32()); - else - return nullptr; - } -} - -CStructTemplate* CStructTemplate::StructByIndex(u32 index) -{ - IPropertyTemplate *pProp = PropertyByIndex(index); - - if (pProp->Type() == eStructProperty) - return static_cast(pProp); - else - return nullptr; -} - -CStructTemplate* CStructTemplate::StructByID(u32 ID) -{ - IPropertyTemplate *pProp = PropertyByID(ID); - - if (pProp && pProp->Type() == eStructProperty) - return static_cast(pProp); - else - return nullptr; -} - -CStructTemplate* CStructTemplate::StructByIDString(const TString& str) -{ - IPropertyTemplate *pProp = PropertyByIDString(str); - - if (pProp && pProp->Type() == eStructProperty) - return static_cast(pProp); - else - return nullptr; -} - -bool CStructTemplate::HasProperty(const TIDString& rkIdString) -{ - IPropertyTemplate *pProperty = PropertyByIDString(rkIdString); - return (pProperty != nullptr); -} - -void CStructTemplate::DetermineVersionPropertyCounts() -{ - for (u32 iVer = 0; iVer < mVersionPropertyCounts.size(); iVer++) - { - mVersionPropertyCounts[iVer] = 0; - - for (u32 iProp = 0; iProp < mSubProperties.size(); iProp++) - { - if (mSubProperties[iProp]->IsInVersion(iVer) && mSubProperties[iProp]->CookPreference() != eNeverCook) - mVersionPropertyCounts[iVer]++; - } - } -} -#endif - -// ************ GLOBAL FUNCTIONS ************ -TString PropEnumToPropString(EPropertyTypeNew Prop) -{ - switch (Prop) - { - case EPropertyTypeNew::Bool: return "bool"; - case EPropertyTypeNew::Byte: return "byte"; - case EPropertyTypeNew::Short: return "short"; - case EPropertyTypeNew::Int: return "long"; - case EPropertyTypeNew::Enum: return "enum"; - case EPropertyTypeNew::Flags: return "bitfield"; - case EPropertyTypeNew::Float: return "float"; - case EPropertyTypeNew::String: return "string"; - case EPropertyTypeNew::Color: return "color"; - case EPropertyTypeNew::Vector: return "vector3f"; - case EPropertyTypeNew::Sound: return "sound"; - case EPropertyTypeNew::Asset: return "asset"; - case EPropertyTypeNew::Struct: return "struct"; - case EPropertyTypeNew::Array: return "array"; - case EPropertyTypeNew::AnimationSet: return "character"; - case EPropertyTypeNew::Spline: return "MayaSpline"; - - default: - return "invalid"; - } -} - -EPropertyTypeNew PropStringToPropEnum(TString Prop) -{ - Prop = Prop.ToLower(); - if (Prop == "bool") return EPropertyTypeNew::Bool; - if (Prop == "byte") return EPropertyTypeNew::Byte; - if (Prop == "short") return EPropertyTypeNew::Short; - if (Prop == "long") return EPropertyTypeNew::Int; - if (Prop == "enum") return EPropertyTypeNew::Enum; - if (Prop == "bitfield") return EPropertyTypeNew::Flags; - if (Prop == "float") return EPropertyTypeNew::Float; - if (Prop == "string") return EPropertyTypeNew::String; - if (Prop == "color") return EPropertyTypeNew::Color; - if (Prop == "vector3f") return EPropertyTypeNew::Vector; - if (Prop == "sound") return EPropertyTypeNew::Sound; - if (Prop == "asset") return EPropertyTypeNew::Asset; - if (Prop == "struct") return EPropertyTypeNew::Struct; - if (Prop == "array") return EPropertyTypeNew::Array; - if (Prop == "character") return EPropertyTypeNew::AnimationSet; - if (Prop == "mayaspline") return EPropertyTypeNew::Spline; - return EPropertyTypeNew::Invalid; -} - -const char* HashablePropTypeName(EPropertyTypeNew Prop) -{ - // Variants that match Retro's internal type names for generating property IDs. case sensitive - switch (Prop) - { - case EPropertyTypeNew::Bool: return "bool"; - case EPropertyTypeNew::Int: return "int"; - case EPropertyTypeNew::Enum: return "enum"; - case EPropertyTypeNew::Flags: return "Flags"; - case EPropertyTypeNew::Float: return "float"; - case EPropertyTypeNew::String: return "string"; - case EPropertyTypeNew::Color: return "Color"; - case EPropertyTypeNew::Vector: return "Vector"; - case EPropertyTypeNew::Sound: return "sound"; - case EPropertyTypeNew::Asset: return "asset"; - case EPropertyTypeNew::Spline: return "spline"; - - // All other types are either invalid or need a custom reimplementation because they can return multiple strings (like struct) - default: - ASSERT(false); - return nullptr; - } -} - -#if 0 -// ************ DEBUG ************ -void CStructTemplate::DebugPrintProperties(TString base) -{ - base = base + Name() + "::"; - for (auto it = mSubProperties.begin(); it != mSubProperties.end(); it++) - { - IPropertyTemplate *tmp = *it; - if (tmp->Type() == eStructProperty) - { - CStructTemplate *tmp2 = static_cast(tmp); - tmp2->DebugPrintProperties(base); - } - else - Log::Write(base + tmp->Name()); - } -} -#endif diff --git a/src/Core/Resource/Script/IPropertyTemplate.h b/src/Core/Resource/Script/IPropertyTemplate.h deleted file mode 100644 index 08a58cbb..00000000 --- a/src/Core/Resource/Script/IPropertyTemplate.h +++ /dev/null @@ -1,804 +0,0 @@ -#ifndef IPROPERTYTEMPLATE -#define IPROPERTYTEMPLATE - -#if 0 -#include "EPropertyType.h" -#include "IProperty.h" -#include "IPropertyValue.h" -#include "Core/Resource/CResTypeFilter.h" -#include "Core/Resource/Animation/CAnimationParameters.h" -#include -#include -#include -#include -#include - -typedef TString TIDString; -class CMasterTemplate; -class CStructTemplate; -class IProperty; - -enum ECookPreference -{ - eNoCookPreference, - eAlwaysCook, - eNeverCook -}; - -// IPropertyTemplate - Base class. Contains basic info that every property has, -// plus virtual functions for determining more specific property type. -class IPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - -protected: - CStructTemplate *mpParent; - CScriptTemplate *mpScriptTemplate; - CMasterTemplate *mpMasterTemplate; - TString mName; - TString mDescription; - u32 mID; - ECookPreference mCookPreference; - std::vector mAllowedVersions; - mutable bool mHasCachedNameCheck; - mutable bool mCachedNameIsCorrect; - -public: - IPropertyTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : mID(ID) - , mpParent(pParent) - , mpScriptTemplate(pScript) - , mpMasterTemplate(pMaster) - , mName("UNSET PROPERTY NAME") - , mCookPreference(eNoCookPreference) - , mHasCachedNameCheck(false) - , mCachedNameIsCorrect(false) - { - } - - IPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : mID(ID) - , mpParent(pParent) - , mpScriptTemplate(pScript) - , mpMasterTemplate(pMaster) - , mName(rkName) - , mCookPreference(CookPreference) - , mHasCachedNameCheck(false) - , mCachedNameIsCorrect(false) - { - } - - virtual EPropertyType Type() const = 0; - virtual bool CanHaveDefault() const = 0; - virtual bool IsNumerical() const = 0; - virtual IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) = 0; - virtual IPropertyTemplate* Clone(CScriptTemplate *pScript, CStructTemplate *pParent = 0) const = 0; - - virtual void Copy(const IPropertyTemplate *pkTemp) - { - mName = pkTemp->mName; - mDescription = pkTemp->mDescription; - mID = pkTemp->mID; - mCookPreference = pkTemp->mCookPreference; - mAllowedVersions = pkTemp->mAllowedVersions; - } - - virtual bool Matches(const IPropertyTemplate *pkTemp) const - { - return ( (pkTemp != nullptr) && - (mName == pkTemp->mName) && - (mDescription == pkTemp->mDescription) && - (mID == pkTemp->mID) && - (mCookPreference == pkTemp->mCookPreference) && - (mAllowedVersions == pkTemp->mAllowedVersions) && - (Type() == pkTemp->Type()) ); - } - - virtual TString DefaultToString() const { return ""; } - virtual const IPropertyValue* RawDefaultValue() const { return nullptr; } - virtual bool HasValidRange() const { return false; } - virtual TString RangeToString() const { return ""; } - virtual TString Suffix() const { return ""; } - virtual const char* GetTypeNameString() const { return HashablePropTypeName(Type()); } - - virtual void SetParam(const TString& rkParamName, const TString& rkValue) - { - if (rkParamName == "cook_pref") - { - TString lValue = rkValue.ToLower(); - - if (lValue == "always") - mCookPreference = eAlwaysCook; - else if (lValue == "never") - mCookPreference = eNeverCook; - else - mCookPreference = eNoCookPreference; - } - - else if (rkParamName == "description") - mDescription = rkValue; - } - - EGame Game() const; - bool IsInVersion(u32 Version) const; - TString FullName() const; - TIDString IDString(bool FullPath) const; - bool IsDescendantOf(const CStructTemplate *pStruct) const; - bool IsFromStructTemplate() const; - bool IsNameCorrect() const; - TString FindStructSource() const; - CStructTemplate* RootStruct(); - - // Inline Accessors - inline TString Name() const { return mName; } - inline TString Description() const { return mDescription; } - inline u32 PropertyID() const { return mID; } - inline ECookPreference CookPreference() const { return mCookPreference; } - inline CStructTemplate* Parent() const { return mpParent; } - inline CScriptTemplate* ScriptTemplate() const { return mpScriptTemplate; } - inline CMasterTemplate* MasterTemplate() const { return mpMasterTemplate; } - inline void SetName(const TString& rkName) { mName = rkName; mHasCachedNameCheck = false; } - inline void SetDescription(const TString& rkDesc) { mDescription = rkDesc; } -}; - -// Macro for defining reimplementations of IPropertyTemplate::Clone(), which are usually identical to each other aside from the class being instantiated -#define IMPLEMENT_TEMPLATE_CLONE(ClassName) \ - virtual IPropertyTemplate* Clone(CScriptTemplate *pScript, CStructTemplate *pParent = 0) const \ - { \ - if (!pParent) pParent = mpParent; \ - if (!pScript) pScript = mpScriptTemplate; \ - ClassName *pTemp = new ClassName(mID, pScript, mpMasterTemplate, pParent); \ - pTemp->Copy(this); \ - return pTemp; \ - } - -// TTypedPropertyTemplate - Template property class that allows for tracking -// a default value. Typedefs are set up for a bunch of property types. -template -class TTypedPropertyTemplate : public IPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - -protected: - ValueClass mDefaultValue; - -public: - TTypedPropertyTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : IPropertyTemplate(ID, pScript, pMaster, pParent) {} - - TTypedPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : IPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {} - - virtual EPropertyType Type() const { return PropTypeEnum; } - virtual bool CanHaveDefault() const { return CanHaveDefaultValue; } - virtual bool IsNumerical() const { return false; } - - virtual IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - typedef TTypedProperty TPropertyType; - TPropertyType *pOut = new TPropertyType(this, pInstance, pParent, GetDefaultValue()); - return pOut; - } - - IMPLEMENT_TEMPLATE_CLONE(TTypedPropertyTemplate) - - virtual void Copy(const IPropertyTemplate *pkTemp) - { - IPropertyTemplate::Copy(pkTemp); - mDefaultValue.Copy(&static_cast(pkTemp)->mDefaultValue); - } - - virtual bool Matches(const IPropertyTemplate *pkTemp) const - { - const TTypedPropertyTemplate *pkTyped = static_cast(pkTemp); - - return ( (IPropertyTemplate::Matches(pkTemp)) && - (mDefaultValue.Matches(&pkTyped->mDefaultValue)) ); - } - - virtual TString DefaultToString() const - { - return mDefaultValue.ToString(); - } - - virtual const IPropertyValue* RawDefaultValue() const - { - return &mDefaultValue; - } - - virtual void SetParam(const TString& rkParamName, const TString& rkValue) - { - IPropertyTemplate::SetParam(rkParamName, rkValue); - - if (rkParamName == "default") - mDefaultValue.FromString(rkValue.ToLower()); - } - - inline PropType GetDefaultValue() const { return mDefaultValue.Get(); } - inline void SetDefaultValue(const PropType& rkIn) { mDefaultValue.Set(rkIn); } -}; - -// TNumericalPropertyTemplate - Subclass of TTypedPropertyTemplate for numerical -// property types, and allows a min/max value and a suffix to be tracked. -template -class TNumericalPropertyTemplate : public TTypedPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - - ValueClass mMin; - ValueClass mMax; - TString mSuffix; - -public: - TNumericalPropertyTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, pScript, pMaster, pParent) - {} - - TNumericalPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) - , mMin(0) - , mMax(0) - {} - - virtual bool IsNumerical() const { return true; } - virtual bool HasValidRange() const { return (mMin != 0 || mMax != 0); } - - IMPLEMENT_TEMPLATE_CLONE(TNumericalPropertyTemplate) - - virtual void Copy(const IPropertyTemplate *pkTemp) - { - TTypedPropertyTemplate::Copy(pkTemp); - - const TNumericalPropertyTemplate *pkNumerical = static_cast(pkTemp); - mMin.Copy(&pkNumerical->mMin); - mMax.Copy(&pkNumerical->mMax); - mSuffix = pkNumerical->mSuffix; - } - - virtual bool Matches(const IPropertyTemplate *pkTemp) const - { - const TNumericalPropertyTemplate *pkNumerical = static_cast(pkTemp); - - return ( (TTypedPropertyTemplate::Matches(pkTemp)) && - (mMin.Matches(&pkNumerical->mMin)) && - (mMax.Matches(&pkNumerical->mMax)) && - (mSuffix == pkNumerical->mSuffix) ); - } - - virtual TString RangeToString() const - { - return mMin.ToString() + "," + mMax.ToString(); - } - - virtual void SetParam(const TString& rkParamName, const TString& rkValue) - { - TTypedPropertyTemplate::SetParam(rkParamName, rkValue); - - if (rkParamName == "range") - { - TStringList Components = rkValue.ToLower().Split(", "); - - if (Components.size() == 2) - { - mMin.FromString(Components.front()); - mMax.FromString(Components.back()); - } - } - - else if (rkParamName == "suffix") - { - mSuffix = rkValue; - } - } - - virtual TString Suffix() const { return mSuffix; } - inline PropType GetMin() const { return mMin.Get(); } - inline PropType GetMax() const { return mMax.Get(); } - - inline void SetRange(const PropType& rkMin, const PropType& rkMax) - { - mMin.Set(rkMin); - mMax.Set(rkMax); - } - - inline void SetSuffix(const TString& rkSuffix) - { - mSuffix = rkSuffix; - } -}; - -// Typedefs for all property types that don't need further functionality. -typedef TTypedPropertyTemplate TBoolTemplate; -typedef TNumericalPropertyTemplate TByteTemplate; -typedef TNumericalPropertyTemplate TShortTemplate; -typedef TNumericalPropertyTemplate TLongTemplate; -typedef TNumericalPropertyTemplate TFloatTemplate; -typedef TTypedPropertyTemplate TVector3Template; -typedef TTypedPropertyTemplate TColorTemplate; - -// TCharacterTemplate, TSoundTemplate, TStringTemplate, and TMayaSplineTemplate get their own subclasses so they can reimplement a couple functions -class TCharacterTemplate : public TTypedPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - -public: - TCharacterTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, pScript, pMaster, pParent) {} - - TCharacterTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {} - - IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - return new TCharacterProperty(this, pInstance, pParent, CAnimationParameters(Game())); - } - - const char* GetTypeNameString() const - { - return (Game() < eCorruptionProto ? "AnimationSet" : "CharacterAnimationSet"); - } - - IMPLEMENT_TEMPLATE_CLONE(TCharacterTemplate) -}; - -class TSoundTemplate : public TTypedPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - -public: - TSoundTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, pScript, pMaster, pParent) {} - - TSoundTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {} - - IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - return new TSoundProperty(this, pInstance, pParent, -1); - } - - IMPLEMENT_TEMPLATE_CLONE(TSoundTemplate) -}; - -class TStringTemplate : public TTypedPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - -public: - TStringTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, pScript, pMaster, pParent) {} - - TStringTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {} - - IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - return new TStringProperty(this, pInstance, pParent); - } - - IMPLEMENT_TEMPLATE_CLONE(TStringTemplate) -}; - -class TMayaSplineTemplate : public TTypedPropertyTemplate, eMayaSplineProperty, CMayaSplineValue, false> -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - -public: - TMayaSplineTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, pScript, pMaster, pParent) {} - - TMayaSplineTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {} - - IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - return new TMayaSplineProperty(this, pInstance, pParent); - } - - IMPLEMENT_TEMPLATE_CLONE(TMayaSplineTemplate) -}; - -// CAssetTemplate - Property template for assets. Tracks a list of resource types that -// the property is allowed to accept. -class CAssetTemplate : public IPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - - CResTypeFilter mTypeFilter; -public: - CAssetTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : IPropertyTemplate(ID, pScript, pMaster, pParent) {} - - CAssetTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : IPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {} - - virtual EPropertyType Type() const { return eAssetProperty; } - virtual bool CanHaveDefault() const { return false; } - virtual bool IsNumerical() const { return false; } - - IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - return new TAssetProperty(this, pInstance, pParent); - } - - IMPLEMENT_TEMPLATE_CLONE(CAssetTemplate) - - virtual void Copy(const IPropertyTemplate *pkTemp) - { - IPropertyTemplate::Copy(pkTemp); - mTypeFilter = static_cast(pkTemp)->mTypeFilter; - } - - virtual bool Matches(const IPropertyTemplate *pkTemp) const - { - const CAssetTemplate *pkAsset = static_cast(pkTemp); - - return ( (IPropertyTemplate::Matches(pkTemp)) && - (mTypeFilter == pkAsset->mTypeFilter) ); - } - - void SetTypeFilter(const TStringList& rkExtensions) { mTypeFilter.SetAcceptedTypes(Game(), rkExtensions); } - const CResTypeFilter& TypeFilter() const { return mTypeFilter; } -}; - -// CEnumTemplate - Property template for enums. Tracks a list of possible values (enumerators). -class CEnumTemplate : public TTypedPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - - struct SEnumerator - { - TString Name; - u32 ID; - - SEnumerator(const TString& rkName, u32 _ID) - : Name(rkName), ID(_ID) {} - - bool operator==(const SEnumerator& rkOther) const - { - return ( (Name == rkOther.Name) && (ID == rkOther.ID) ); - } - }; - std::vector mEnumerators; - TString mSourceFile; - bool mUsesHashes; - -public: - CEnumTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, pScript, pMaster, pParent) - , mUsesHashes(false) - { - } - - CEnumTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) - , mUsesHashes(false) - { - } - - virtual EPropertyType Type() const { return eEnumProperty; } - virtual bool CanHaveDefault() const { return true; } - virtual bool IsNumerical() const { return false; } - - virtual IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - TEnumProperty *pEnum = new TEnumProperty(this, pInstance, pParent); - pEnum->Set(GetDefaultValue()); - return pEnum; - } - - IMPLEMENT_TEMPLATE_CLONE(CEnumTemplate) - - virtual void Copy(const IPropertyTemplate *pkTemp) - { - TTypedPropertyTemplate::Copy(pkTemp); - - const CEnumTemplate *pkEnum = static_cast(pkTemp); - mEnumerators = pkEnum->mEnumerators; - mSourceFile = pkEnum->mSourceFile; - mUsesHashes = pkEnum->mUsesHashes; - } - - virtual bool Matches(const IPropertyTemplate *pkTemp) const - { - const CEnumTemplate *pkEnum = static_cast(pkTemp); - - return ( (TTypedPropertyTemplate::Matches(pkTemp)) && - (mEnumerators == pkEnum->mEnumerators) && - (mSourceFile == pkEnum->mSourceFile) && - (mUsesHashes == pkEnum->mUsesHashes) ); - } - - virtual const char* GetTypeNameString() const - { - return (mUsesHashes ? "enum" : "choice"); - } - - inline TString SourceFile() const { return mSourceFile; } - inline u32 NumEnumerators() const { return mEnumerators.size(); } - - u32 EnumeratorIndex(u32 enumID) const - { - for (u32 iEnum = 0; iEnum < mEnumerators.size(); iEnum++) - { - if (mEnumerators[iEnum].ID == enumID) - return iEnum; - } - return -1; - } - - u32 EnumeratorID(u32 enumIndex) const - { - if (mEnumerators.size() > enumIndex) - return mEnumerators[enumIndex].ID; - - else return -1; - } - - TString EnumeratorName(u32 enumIndex) const - { - if (mEnumerators.size() > enumIndex) - return mEnumerators[enumIndex].Name; - - else return "INVALID ENUM INDEX"; - } -}; - -// CBitfieldTemplate - Property template for bitfields, which can have multiple -// distinct boolean parameters packed into one property. -class CBitfieldTemplate : public TTypedPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - - struct SBitFlag - { - TString Name; - u32 Mask; - - SBitFlag(const TString& _name, u32 _mask) - : Name(_name), Mask(_mask) {} - - bool operator==(const SBitFlag& rkOther) const - { - return ( (Name == rkOther.Name) && (Mask == rkOther.Mask) ); - } - }; - std::vector mBitFlags; - TString mSourceFile; - -public: - CBitfieldTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, pScript, pMaster, pParent) - { - } - - CBitfieldTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) - { - } - - virtual EPropertyType Type() const { return eBitfieldProperty; } - virtual bool CanHaveDefault() const { return true; } - virtual bool IsNumerical() const { return false; } - - virtual IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - TBitfieldProperty *pBitfield = new TBitfieldProperty(this, pInstance, pParent); - pBitfield->Set(GetDefaultValue()); - return pBitfield; - } - - IMPLEMENT_TEMPLATE_CLONE(CBitfieldTemplate) - - virtual void Copy(const IPropertyTemplate *pkTemp) - { - TTypedPropertyTemplate::Copy(pkTemp); - - const CBitfieldTemplate *pkBitfield = static_cast(pkTemp); - mBitFlags = pkBitfield->mBitFlags; - mSourceFile = pkBitfield->mSourceFile; - } - - virtual bool Matches(const IPropertyTemplate *pkTemp) const - { - const CBitfieldTemplate *pkBitfield = static_cast(pkTemp); - - return ( (TTypedPropertyTemplate::Matches(pkTemp)) && - (mBitFlags == pkBitfield->mBitFlags) && - (mSourceFile == pkBitfield->mSourceFile) ); - } - - inline TString SourceFile() const { return mSourceFile; } - inline u32 NumFlags() const { return mBitFlags.size(); } - inline TString FlagName(u32 index) const { return mBitFlags[index].Name; } - inline u32 FlagMask(u32 index) const { return mBitFlags[index].Mask; } -}; - -// CStructTemplate - Defines structs composed of multiple sub-properties. -class CStructTemplate : public IPropertyTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - -protected: - std::vector mSubProperties; - std::vector mVersionPropertyCounts; - bool mIsSingleProperty; - TString mSourceFile; - TString mTypeName; - - void DetermineVersionPropertyCounts(); -public: - CStructTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : IPropertyTemplate(ID, pScript, pMaster, pParent) - , mIsSingleProperty(false) {} - - CStructTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : IPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) - , mIsSingleProperty(false) {} - - ~CStructTemplate() - { - for (auto it = mSubProperties.begin(); it != mSubProperties.end(); it++) - delete *it; - } - - EPropertyType Type() const { return eStructProperty; } - bool CanHaveDefault() const { return false; } - bool IsNumerical() const { return false; } - - IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - CPropertyStruct *pStruct = new CPropertyStruct(this, pInstance, pParent); - - for (u32 iSub = 0; iSub < mSubProperties.size(); iSub++) - { - IProperty *pSubProp = mSubProperties[iSub]->InstantiateProperty(pInstance, pStruct); - pStruct->AddSubProperty(pSubProp); - } - - return pStruct; - } - - IMPLEMENT_TEMPLATE_CLONE(CStructTemplate) - - virtual void Copy(const IPropertyTemplate *pkTemp) - { - IPropertyTemplate::Copy(pkTemp); - - const CStructTemplate *pkStruct = static_cast(pkTemp); - CopyStructData(pkStruct); - } - - void CopyStructData(const CStructTemplate *pkStruct); - - virtual bool Matches(const IPropertyTemplate *pkTemp) const - { - const CStructTemplate *pkStruct = static_cast(pkTemp); - - if ( (IPropertyTemplate::Matches(pkTemp)) && - (mVersionPropertyCounts == pkStruct->mVersionPropertyCounts) && - (mIsSingleProperty == pkStruct->mIsSingleProperty) && - (mSourceFile == pkStruct->mSourceFile) && - (mTypeName == pkStruct->mTypeName) ) - { - return StructDataMatches(pkStruct); - } - - return false; - } - - const char* GetTypeNameString() const - { - // hack - currently templates embedded within another XML can't have a type name - return mTypeName.IsEmpty() ? *mName : *mTypeName; - } - - bool StructDataMatches(const CStructTemplate *pkStruct) const - { - if ( (mIsSingleProperty == pkStruct->mIsSingleProperty) && - (mSubProperties.size() == pkStruct->mSubProperties.size()) ) - { - for (u32 iSub = 0; iSub < mSubProperties.size(); iSub++) - { - if (!mSubProperties[iSub]->Matches(pkStruct->mSubProperties[iSub])) - return false; - } - - return true; - } - - return false; - } - - inline TString SourceFile() const { return mSourceFile; } - inline bool IsSingleProperty() const { return mIsSingleProperty; } - inline u32 Count() const { return mSubProperties.size(); } - inline u32 NumVersions() const { return mVersionPropertyCounts.size(); } - - u32 PropertyCountForVersion(u32 Version); - u32 VersionForPropertyCount(u32 PropCount); - IPropertyTemplate* PropertyByIndex(u32 index); - IPropertyTemplate* PropertyByID(u32 ID); - IPropertyTemplate* PropertyByIDString(const TIDString& str); - CStructTemplate* StructByIndex(u32 index); - CStructTemplate* StructByID(u32 ID); - CStructTemplate* StructByIDString(const TIDString& str); - bool HasProperty(const TIDString& rkIdString); - void DebugPrintProperties(TString base); -}; - -// CArrayTemplate - Defines a repeating struct composed of multiple sub-properties. -// Similar to CStructTemplate, but with new implementations of Type() and InstantiateProperty(). -class CArrayTemplate : public CStructTemplate -{ - friend class CTemplateLoader; - friend class CTemplateWriter; - TString mElementName; - -public: - CArrayTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : CStructTemplate(ID, pScript, pMaster, pParent) - { - mIsSingleProperty = true; - } - - CArrayTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0) - : CStructTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) - { - mIsSingleProperty = true; - } - - EPropertyType Type() const { return eArrayProperty; } - - IProperty* InstantiateProperty(CScriptObject *pInstance, CPropertyStruct *pParent) - { - return new CArrayProperty(this, pInstance, pParent); - } - - IMPLEMENT_TEMPLATE_CLONE(CArrayTemplate) - - virtual void Copy(const IPropertyTemplate *pkTemp) - { - CStructTemplate::Copy(pkTemp); - mElementName = static_cast(pkTemp)->mElementName; - } - - virtual bool Matches(const IPropertyTemplate *pkTemp) const - { - const CArrayTemplate *pkArray = static_cast(pkTemp); - - return ( (mElementName == pkArray->mElementName) & - (CStructTemplate::Matches(pkTemp)) ); - } - - void SetParam(const TString& rkParamName, const TString& rkValue) - { - if (rkParamName == "element_name") - mElementName = rkValue; - else - CStructTemplate::SetParam(rkParamName, rkValue); - } - - TString ElementName() const { return mElementName; } - void SetElementName(const TString& rkName) { mElementName = rkName; } - - CPropertyStruct* CreateSubStruct(CScriptObject *pInstance, CArrayProperty *pArray) - { - return (CPropertyStruct*) CStructTemplate::InstantiateProperty(pInstance, pArray); - } -}; -#endif - -#endif // IPROPERTYTEMPLATE - diff --git a/src/Core/Resource/Script/IPropertyValue.h b/src/Core/Resource/Script/IPropertyValue.h deleted file mode 100644 index d9c83ecb..00000000 --- a/src/Core/Resource/Script/IPropertyValue.h +++ /dev/null @@ -1,392 +0,0 @@ -#ifndef IPROPERTYVALUE_H -#define IPROPERTYVALUE_H - -#if 0 -#include "EPropertyType.h" -#include -#include -#include "Core/Resource/Animation/CAnimationParameters.h" -#include "Core/Resource/CResource.h" -#include "Core/Resource/TResPtr.h" - -#include -#include -#include - -class IPropertyValue -{ -public: - virtual TString ToString() const = 0; - virtual void FromString(const TString& rkString) = 0; - virtual IPropertyValue* Clone() const = 0; - virtual void Copy(const IPropertyValue *pkValue) = 0; - virtual bool Matches(const IPropertyValue *pkValue) const = 0; -}; - -template -class TTypedPropertyValue : public IPropertyValue -{ -protected: - PropType mValue; - -public: - TTypedPropertyValue() {} - - TTypedPropertyValue(PropType rkVal) - : mValue(rkVal) {} - - virtual void Copy(const IPropertyValue *pkValue) - { - const TTypedPropertyValue *pkOther = static_cast(pkValue); - mValue = pkOther->mValue; - } - - virtual bool Matches(const IPropertyValue *pkValue) const - { - const TTypedPropertyValue *pkOther = static_cast(pkValue); - return ((pkValue != nullptr) && (mValue == pkOther->mValue)); - } - - PropType Get() const - { - return mValue; - } - - void Set(const PropType& rkIn) - { - mValue = rkIn; - } - - bool operator==(const TTypedPropertyValue& rkOther) const - { - return (mValue == rkOther.mValue); - } - - bool operator==(const PropType& rkOther) const { return (mValue == rkOther); } - bool operator!=(const PropType& rkOther) const { return (mValue != rkOther); } - bool operator< (const PropType& rkOther) const { return (mValue < rkOther); } - bool operator<=(const PropType& rkOther) const { return (mValue <= rkOther); } - bool operator> (const PropType& rkOther) const { return (mValue > rkOther); } - bool operator>=(const PropType& rkOther) const { return (mValue >= rkOther); } -}; - -class CBoolValue : public TTypedPropertyValue -{ -public: - CBoolValue() { mValue = false; } - CBoolValue(bool Val) { mValue = Val; } - - TString ToString() const - { - return (!mValue ? "false" : "true"); - } - - void FromString(const TString& rkString) - { - mValue = (rkString == "true"); - } - - IPropertyValue* Clone() const - { - return new CBoolValue(mValue); - } -}; - -class CByteValue : public TTypedPropertyValue -{ -public: - CByteValue() { mValue = 0; } - CByteValue(s8 Val) { mValue = Val; } - - TString ToString() const - { - return TString::FromInt32(mValue, 0, 10); - } - - void FromString(const TString& rkString) - { - u32 base = (rkString.StartsWith("0x") ? 16 : 10); - mValue = (s8) rkString.ToInt32(base); - } - - IPropertyValue* Clone() const - { - return new CByteValue(mValue); - } -}; - -class CShortValue : public TTypedPropertyValue -{ -public: - CShortValue() { mValue = 0; } - CShortValue(s16 Val) { mValue = Val; } - - TString ToString() const - { - return TString::FromInt32((s32) mValue, 0, 10); - } - - void FromString(const TString& rkString) - { - u32 base = (rkString.StartsWith("0x") ? 16 : 10); - mValue = (s16) rkString.ToInt32(base); - } - - IPropertyValue* Clone() const - { - return new CShortValue(mValue); - } -}; - -class CLongValue : public TTypedPropertyValue -{ -public: - CLongValue() { mValue = 0; } - CLongValue(s32 Val) { mValue = Val; } - - TString ToString() const - { - return TString::FromInt32(mValue, 0, 10); - } - - void FromString(const TString& rkString) - { - u32 base = (rkString.StartsWith("0x") ? 16 : 10); - mValue = (s32) rkString.ToInt32(base); - } - - IPropertyValue* Clone() const - { - return new CLongValue(mValue); - } -}; - -class CHexLongValue : public TTypedPropertyValue -{ -public: - CHexLongValue() { mValue = 0; } - CHexLongValue(u32 Val) { mValue = Val; } - - TString ToString() const - { - return TString::HexString(mValue, 8); - } - - void FromString(const TString& rkString) - { - u32 Base = (rkString.StartsWith("0x") ? 16 : 10); - mValue = (s32) rkString.ToInt32(Base); - } - - IPropertyValue* Clone() const - { - return new CHexLongValue(mValue); - } -}; - -class CFloatValue : public TTypedPropertyValue -{ -public: - CFloatValue() { mValue = 0.0f; } - CFloatValue(float Val) { mValue = Val; } - - TString ToString() const - { - return TString::FromFloat(mValue); - } - - void FromString(const TString& rkString) - { - mValue = rkString.ToFloat(); - } - - IPropertyValue* Clone() const - { - return new CFloatValue(mValue); - } -}; - -class CStringValue : public TTypedPropertyValue -{ -public: - CStringValue() {} - CStringValue(const TString& rkVal) { mValue = rkVal; } - - // These functions are extremely complicated, but try to follow along - TString ToString() const - { - return mValue; - } - - void FromString(const TString& rkString) - { - mValue = rkString; - } - - IPropertyValue* Clone() const - { - return new CStringValue(mValue); - } -}; - -class CColorValue : public TTypedPropertyValue -{ -public: - CColorValue() {} - CColorValue(const CColor& rkVal) { mValue = rkVal; } - - 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); - return out; - } - - void FromString(const TString& rkString) - { - TStringList Components = rkString.Split(", "); - - if (Components.size() < 3 || Components.size() > 4) - { - Log::Error("CColorValue::FromString was passed a string with an invalid number of components"); - mValue = CColor::skTransparentBlack; - return; - } - - float *pPtr = &mValue.R; - mValue.A = 1.0f; - - for (auto it = Components.begin(); it != Components.end(); it++) - { - *pPtr = it->ToFloat(); - pPtr++; - } - } - - IPropertyValue* Clone() const - { - return new CColorValue(mValue); - } -}; - -class CVector3Value : public TTypedPropertyValue -{ -public: - CVector3Value() {} - CVector3Value(const CVector3f& rkVal) { mValue = rkVal; } - - TString ToString() const - { - TString out; - out += TString::FromFloat(mValue.X) + ", "; - out += TString::FromFloat(mValue.Y) + ", "; - out += TString::FromFloat(mValue.Z); - return out; - } - - void FromString(const TString& rkString) - { - TStringList Components = rkString.Split(", "); - - if (Components.size() != 3) - { - Log::Error("CVector3Value::FromString was passed a string with an invalid number of components"); - mValue = CVector3f::skInfinite; - return; - } - - float *pPtr = &mValue.X; - - for (auto it = Components.begin(); it != Components.end(); it++) - { - *pPtr = it->ToFloat(); - pPtr++; - } - } - - IPropertyValue* Clone() const - { - return new CVector3Value(mValue); - } -}; - -class CCharacterValue : public TTypedPropertyValue -{ -public: - CCharacterValue() {} - CCharacterValue(const CAnimationParameters& rkParams) { mValue = rkParams; } - - TString ToString() const { return ""; } - void FromString(const TString&) { } - - IPropertyValue* Clone() const - { - return new CCharacterValue(mValue); - } -}; - -class CMayaSplineValue : public TTypedPropertyValue> -{ -public: - CMayaSplineValue() {} - CMayaSplineValue(const std::vector& rkData) { mValue = rkData; } - - TString ToString() const { return "[MayaSpline]"; } - void FromString(const TString&) {} - - IPropertyValue* Clone() const - { - return new CMayaSplineValue(mValue); - } -}; - -class CSoundValue : public TTypedPropertyValue -{ -public: - CSoundValue() {} - CSoundValue(u32 SoundID) { mValue = SoundID; } - - TString ToString() const { return TString::FromInt32(mValue, 0, 10); } - void FromString(const TString& rkString) { mValue = rkString.ToInt32(10); } - - IPropertyValue* Clone() const - { - return new CSoundValue(mValue); - } -}; - -class CAssetValue : public TTypedPropertyValue -{ -public: - CAssetValue() {} - CAssetValue(const CAssetID& rkID) { mValue = rkID; } - - TString ToString() const { return ""; } - void FromString(const TString&) {} - - IPropertyValue* Clone() const - { - return new CAssetValue(mValue); - } -}; - -class CUnknownValue : public TTypedPropertyValue> -{ -public: - CUnknownValue(); - CUnknownValue(const std::vector& rkVec) { mValue = rkVec; } - - TString ToString() const { return ""; } - void FromString(const TString&) {} - - IPropertyValue* Clone() const - { - return new CUnknownValue(mValue); - } -}; -#endif - -#endif // IPROPERTYVALUE_H diff --git a/src/Core/Resource/Script/Property/CAnimationProperty.h b/src/Core/Resource/Script/Property/CAnimationProperty.h index c7b73bbd..0014b522 100644 --- a/src/Core/Resource/Script/Property/CAnimationProperty.h +++ b/src/Core/Resource/Script/Property/CAnimationProperty.h @@ -1,11 +1,11 @@ #ifndef CANIMATIONPROPERTY_H #define CANIMATIONPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" -class CAnimationProperty : public TSerializeableTypedProperty< u32, EPropertyTypeNew::Animation > +class CAnimationProperty : public TSerializeableTypedProperty< u32, EPropertyType::Animation > { - friend class IPropertyNew; + friend class IProperty; protected: CAnimationProperty(EGame Game) diff --git a/src/Core/Resource/Script/Property/CAnimationSetProperty.h b/src/Core/Resource/Script/Property/CAnimationSetProperty.h index 039c8647..aefa1431 100644 --- a/src/Core/Resource/Script/Property/CAnimationSetProperty.h +++ b/src/Core/Resource/Script/Property/CAnimationSetProperty.h @@ -1,11 +1,11 @@ #ifndef CANIMATIONSETPROPERTY_H #define CANIMATIONSETPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" -class CAnimationSetProperty : public TSerializeableTypedProperty< CAnimationParameters, EPropertyTypeNew::AnimationSet > +class CAnimationSetProperty : public TSerializeableTypedProperty< CAnimationParameters, EPropertyType::AnimationSet > { - friend class IPropertyNew; + friend class IProperty; protected: CAnimationSetProperty(EGame Game) diff --git a/src/Core/Resource/Script/Property/CArrayProperty.h b/src/Core/Resource/Script/Property/CArrayProperty.h index 85dfa28f..ad4f62ec 100644 --- a/src/Core/Resource/Script/Property/CArrayProperty.h +++ b/src/Core/Resource/Script/Property/CArrayProperty.h @@ -1,7 +1,7 @@ #ifndef CARRAYPROPERTY_H #define CARRAYPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" struct SScriptArray { @@ -20,9 +20,9 @@ struct SScriptArray /** You probably shouldn't use this on intrinsic classes; script only */ /** @todo proper support of default values for arrays (this would be used for prefabs) */ -class CArrayProperty : public TTypedPropertyNew +class CArrayProperty : public TTypedProperty { - friend class IPropertyNew; + friend class IProperty; friend class CTemplateLoader; /** This class inherits from TTypedPropertyNew in order to expose the array @@ -30,7 +30,7 @@ class CArrayProperty : public TTypedPropertyNew * value and we respond by updating the allocated space, handling item destruction * and construction, etc. */ - IPropertyNew* mpItemArchetype; + IProperty* mpItemArchetype; /** Internal functions */ SScriptArray& _GetInternalArray(void* pData) const @@ -46,7 +46,7 @@ class CArrayProperty : public TTypedPropertyNew protected: CArrayProperty(EGame Game) - : TTypedPropertyNew(Game) + : TTypedProperty(Game) , mpItemArchetype(nullptr) {} @@ -69,7 +69,7 @@ public: virtual void Destruct(void* pData) const { RevertToDefault(pData); - TTypedPropertyNew::Destruct(pData); + TTypedProperty::Destruct(pData); } virtual bool MatchesDefault(void* pData) const @@ -107,7 +107,7 @@ public: virtual void Serialize(IArchive& rArc) { - TTypedPropertyNew::Serialize(rArc); + TTypedProperty::Serialize(rArc); rArc << SerialParameter("ItemArchetype", mpItemArchetype); if (rArc.IsReader()) @@ -135,16 +135,16 @@ public: } } - virtual void InitFromArchetype(IPropertyNew* pOther) + virtual void InitFromArchetype(IProperty* pOther) { - TTypedPropertyNew::InitFromArchetype(pOther); + TTypedProperty::InitFromArchetype(pOther); CArrayProperty* pOtherArray = static_cast(pOther); - mpItemArchetype = IPropertyNew::CreateCopy(pOtherArray->mpItemArchetype); + mpItemArchetype = IProperty::CreateCopy(pOtherArray->mpItemArchetype); } virtual void PostInitialize() { - TTypedPropertyNew::PostInitialize(); + TTypedProperty::PostInitialize(); mpItemArchetype->Initialize(this, mpScriptTemplate, 0); } @@ -204,7 +204,7 @@ public: } /** Accessors */ - IPropertyNew* ItemArchetype() const { return mpItemArchetype; } + IProperty* ItemArchetype() const { return mpItemArchetype; } }; #endif // CARRAYPROPERTY_H diff --git a/src/Core/Resource/Script/Property/CAssetProperty.h b/src/Core/Resource/Script/Property/CAssetProperty.h index 07bab214..fc2390cc 100644 --- a/src/Core/Resource/Script/Property/CAssetProperty.h +++ b/src/Core/Resource/Script/Property/CAssetProperty.h @@ -1,13 +1,13 @@ #ifndef CASSETPROPERTY_H #define CASSETPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" #include "Core/Resource/CResTypeFilter.h" -class CAssetProperty : public TSerializeableTypedProperty +class CAssetProperty : public TSerializeableTypedProperty { friend class CTemplateLoader; - friend class IPropertyNew; + friend class IProperty; CResTypeFilter mTypeFilter; @@ -33,9 +33,9 @@ public: mTypeFilter != pArchetype->mTypeFilter; } - virtual void InitFromArchetype(IPropertyNew* pOther) + virtual void InitFromArchetype(IProperty* pOther) { - TTypedPropertyNew::InitFromArchetype(pOther); + TTypedProperty::InitFromArchetype(pOther); mTypeFilter = static_cast(pOther)->mTypeFilter; } diff --git a/src/Core/Resource/Script/Property/CBoolProperty.h b/src/Core/Resource/Script/Property/CBoolProperty.h index f02247c5..994807cb 100644 --- a/src/Core/Resource/Script/Property/CBoolProperty.h +++ b/src/Core/Resource/Script/Property/CBoolProperty.h @@ -1,11 +1,11 @@ #ifndef CBOOLPROPERTY_H #define CBOOLPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" -class CBoolProperty : public TSerializeableTypedProperty< bool, EPropertyTypeNew::Bool > +class CBoolProperty : public TSerializeableTypedProperty< bool, EPropertyType::Bool > { - friend class IPropertyNew; + friend class IProperty; protected: CBoolProperty(EGame Game) diff --git a/src/Core/Resource/Script/Property/CByteProperty.h b/src/Core/Resource/Script/Property/CByteProperty.h index 52c2bac9..be102e74 100644 --- a/src/Core/Resource/Script/Property/CByteProperty.h +++ b/src/Core/Resource/Script/Property/CByteProperty.h @@ -1,7 +1,7 @@ #ifndef CBYTEPROPERTY_H #define CBYTEPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CByteProperty : public TNumericalPropertyNew< s8, EPropertyTypeNew::Byte > { diff --git a/src/Core/Resource/Script/Property/CColorProperty.h b/src/Core/Resource/Script/Property/CColorProperty.h index 746ae7ce..c5c8c207 100644 --- a/src/Core/Resource/Script/Property/CColorProperty.h +++ b/src/Core/Resource/Script/Property/CColorProperty.h @@ -1,7 +1,7 @@ #ifndef CCOLORPROPERTY_H #define CCOLORPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" #include "CFloatProperty.h" class CColorProperty : public TSerializeableTypedProperty< CColor, EPropertyTypeNew::Color > diff --git a/src/Core/Resource/Script/Property/CEnumProperty.h b/src/Core/Resource/Script/Property/CEnumProperty.h index 3c8d4d4d..7d313ba7 100644 --- a/src/Core/Resource/Script/Property/CEnumProperty.h +++ b/src/Core/Resource/Script/Property/CEnumProperty.h @@ -1,7 +1,7 @@ #ifndef CENUMPROPERTY_H #define CENUMPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" /** There are two types of enum properties in the game data: enum and choice. * diff --git a/src/Core/Resource/Script/Property/CFlagsProperty.cpp b/src/Core/Resource/Script/Property/CFlagsProperty.cpp index 8061b51e..dd75cc97 100644 --- a/src/Core/Resource/Script/Property/CFlagsProperty.cpp +++ b/src/Core/Resource/Script/Property/CFlagsProperty.cpp @@ -29,7 +29,7 @@ void CFlagsProperty::SerializeValue(void* pData, IArchive& rArc) const rArc.SerializePrimitive( (u32&) ValueRef(pData), SH_HexDisplay ); } -void CFlagsProperty::InitFromArchetype(IPropertyNew* pOther) +void CFlagsProperty::InitFromArchetype(IProperty* pOther) { TSerializeableTypedProperty::InitFromArchetype(pOther); CFlagsProperty* pOtherFlags = static_cast(pOther); diff --git a/src/Core/Resource/Script/Property/CFlagsProperty.h b/src/Core/Resource/Script/Property/CFlagsProperty.h index 4a369010..635df308 100644 --- a/src/Core/Resource/Script/Property/CFlagsProperty.h +++ b/src/Core/Resource/Script/Property/CFlagsProperty.h @@ -1,7 +1,7 @@ #ifndef CFLAGSPROPERTY_H #define CFLAGSPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CFlagsProperty : public TSerializeableTypedProperty { diff --git a/src/Core/Resource/Script/Property/CFloatProperty.h b/src/Core/Resource/Script/Property/CFloatProperty.h index ba26eeb8..14d94542 100644 --- a/src/Core/Resource/Script/Property/CFloatProperty.h +++ b/src/Core/Resource/Script/Property/CFloatProperty.h @@ -1,7 +1,7 @@ #ifndef CFLOATPROPERTY_H #define CFLOATPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CFloatProperty : public TNumericalPropertyNew< float, EPropertyTypeNew::Float > { diff --git a/src/Core/Resource/Script/Property/CGuidProperty.h b/src/Core/Resource/Script/Property/CGuidProperty.h index 3093ecce..47ad90c4 100644 --- a/src/Core/Resource/Script/Property/CGuidProperty.h +++ b/src/Core/Resource/Script/Property/CGuidProperty.h @@ -1,7 +1,7 @@ #ifndef CGUIDPROPERTY_H #define CGUIDPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CGuidProperty : public TTypedPropertyNew< std::vector, EPropertyTypeNew::Guid > { diff --git a/src/Core/Resource/Script/Property/CIntProperty.h b/src/Core/Resource/Script/Property/CIntProperty.h index ecb4856a..f26a4ce4 100644 --- a/src/Core/Resource/Script/Property/CIntProperty.h +++ b/src/Core/Resource/Script/Property/CIntProperty.h @@ -1,7 +1,7 @@ #ifndef CINTPROPERTY_H #define CINTPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CIntProperty : public TNumericalPropertyNew< s32, EPropertyTypeNew::Int > { diff --git a/src/Core/Resource/Script/Property/CPointerProperty.h b/src/Core/Resource/Script/Property/CPointerProperty.h index 913b2b61..7717fc33 100644 --- a/src/Core/Resource/Script/Property/CPointerProperty.h +++ b/src/Core/Resource/Script/Property/CPointerProperty.h @@ -1,7 +1,7 @@ #ifndef CPOINTERPROPERTY_H #define CPOINTERPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CPointerProperty : public TTypedPropertyNew { diff --git a/src/Core/Resource/Script/CPropertyNameGenerator.cpp b/src/Core/Resource/Script/Property/CPropertyNameGenerator.cpp similarity index 100% rename from src/Core/Resource/Script/CPropertyNameGenerator.cpp rename to src/Core/Resource/Script/Property/CPropertyNameGenerator.cpp diff --git a/src/Core/Resource/Script/CPropertyNameGenerator.h b/src/Core/Resource/Script/Property/CPropertyNameGenerator.h similarity index 100% rename from src/Core/Resource/Script/CPropertyNameGenerator.h rename to src/Core/Resource/Script/Property/CPropertyNameGenerator.h diff --git a/src/Core/Resource/Script/Property/CSequenceProperty.h b/src/Core/Resource/Script/Property/CSequenceProperty.h index ca9f9589..f4a04ae6 100644 --- a/src/Core/Resource/Script/Property/CSequenceProperty.h +++ b/src/Core/Resource/Script/Property/CSequenceProperty.h @@ -1,7 +1,7 @@ #ifndef CSEQUENCEPROPERTY_H #define CSEQUENCEPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CSequenceProperty : public TTypedPropertyNew< s32, EPropertyTypeNew::Sequence > { diff --git a/src/Core/Resource/Script/Property/CShortProperty.h b/src/Core/Resource/Script/Property/CShortProperty.h index 17ed9471..d2185a4e 100644 --- a/src/Core/Resource/Script/Property/CShortProperty.h +++ b/src/Core/Resource/Script/Property/CShortProperty.h @@ -1,7 +1,7 @@ #ifndef CSHORTPROPERTY_H #define CSHORTPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CShortProperty : public TNumericalPropertyNew< s16, EPropertyTypeNew::Short > { diff --git a/src/Core/Resource/Script/Property/CSoundProperty.h b/src/Core/Resource/Script/Property/CSoundProperty.h index 3622ff5a..31f0f1f9 100644 --- a/src/Core/Resource/Script/Property/CSoundProperty.h +++ b/src/Core/Resource/Script/Property/CSoundProperty.h @@ -1,7 +1,7 @@ #ifndef CSOUNDPROPERTY_H #define CSOUNDPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CSoundProperty : public TSerializeableTypedProperty< s32, EPropertyTypeNew::Sound > { diff --git a/src/Core/Resource/Script/Property/CSplineProperty.h b/src/Core/Resource/Script/Property/CSplineProperty.h index 06a83d21..20d04553 100644 --- a/src/Core/Resource/Script/Property/CSplineProperty.h +++ b/src/Core/Resource/Script/Property/CSplineProperty.h @@ -1,7 +1,7 @@ #ifndef CSPLINEPROPERTY_H #define CSPLINEPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CSplineProperty : public TTypedPropertyNew< std::vector, EPropertyTypeNew::Spline > { diff --git a/src/Core/Resource/Script/Property/CStringProperty.h b/src/Core/Resource/Script/Property/CStringProperty.h index 7e318c95..1d35b9ff 100644 --- a/src/Core/Resource/Script/Property/CStringProperty.h +++ b/src/Core/Resource/Script/Property/CStringProperty.h @@ -1,7 +1,7 @@ #ifndef CSTRINGPROPERTY_H #define CSTRINGPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CStringProperty : public TSerializeableTypedProperty< TString, EPropertyTypeNew::String > { diff --git a/src/Core/Resource/Script/Property/CStructProperty.cpp b/src/Core/Resource/Script/Property/CStructProperty.cpp index da51bb49..1581780f 100644 --- a/src/Core/Resource/Script/Property/CStructProperty.cpp +++ b/src/Core/Resource/Script/Property/CStructProperty.cpp @@ -1,16 +1,16 @@ #include "CStructProperty.h" #include "Core/Resource/Script/CMasterTemplate.h" -EPropertyTypeNew CStructPropertyNew::Type() const +EPropertyType CStructProperty::Type() const { - return EPropertyTypeNew::Struct; + return EPropertyType::Struct; } -u32 CStructPropertyNew::DataSize() const +u32 CStructProperty::DataSize() const { if (!mChildren.empty()) { - IPropertyNew* pLastChild = mChildren.back(); + IProperty* pLastChild = mChildren.back(); return (pLastChild->Offset() - Offset()) + pLastChild->DataSize(); } else @@ -19,13 +19,13 @@ u32 CStructPropertyNew::DataSize() const } } -u32 CStructPropertyNew::DataAlignment() const +u32 CStructProperty::DataAlignment() const { // Structs are aligned to the first child property. return (mChildren.empty() ? 1 : mChildren[0]->DataAlignment()); } -void CStructPropertyNew::Construct(void* pData) const +void CStructProperty::Construct(void* pData) const { for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { @@ -33,7 +33,7 @@ void CStructPropertyNew::Construct(void* pData) const } } -void CStructPropertyNew::Destruct(void* pData) const +void CStructProperty::Destruct(void* pData) const { for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { @@ -41,7 +41,7 @@ void CStructPropertyNew::Destruct(void* pData) const } } -bool CStructPropertyNew::MatchesDefault(void* pData) const +bool CStructProperty::MatchesDefault(void* pData) const { for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { @@ -53,7 +53,7 @@ bool CStructPropertyNew::MatchesDefault(void* pData) const return true; } -void CStructPropertyNew::RevertToDefault(void* pData) const +void CStructProperty::RevertToDefault(void* pData) const { for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { @@ -61,14 +61,14 @@ void CStructPropertyNew::RevertToDefault(void* pData) const } } -const char* CStructPropertyNew::HashableTypeName() const +const char* CStructProperty::HashableTypeName() const { return mpArchetype ? mpArchetype->HashableTypeName() : *mName; } -void CStructPropertyNew::Serialize(IArchive& rArc) +void CStructProperty::Serialize(IArchive& rArc) { - IPropertyNew::Serialize(rArc); + IProperty::Serialize(rArc); // Serialize atomic flag bool Atomic = IsAtomic(); @@ -85,7 +85,7 @@ void CStructPropertyNew::Serialize(IArchive& rArc) // Serialize archetype if (mpArchetype) { - CStructPropertyNew* pArchetype = static_cast(mpArchetype); + CStructProperty* pArchetype = static_cast(mpArchetype); ASSERT(pArchetype != nullptr); if (rArc.IsReader()) @@ -103,13 +103,13 @@ void CStructPropertyNew::Serialize(IArchive& rArc) // Serialize type and ID, then look up the matching property and serialize it. // We don't really need the type, but it's a good sanity check, and it's also good practice // to guarantee that parameters are read in order, as some serializers are order-dependent. - EPropertyTypeNew ChildType; + EPropertyType ChildType; u32 ChildID; rArc << SerialParameter("Type", ChildType, SH_Attribute) << SerialParameter("ID", ChildID, SH_Attribute | SH_HexDisplay ); - IPropertyNew* pChild = ChildByID(ChildID); + IProperty* pChild = ChildByID(ChildID); ASSERT(pChild != nullptr && pChild->Type() == ChildType); pChild->Serialize(rArc); @@ -123,7 +123,7 @@ void CStructPropertyNew::Serialize(IArchive& rArc) else { // Check if any properties need to override parameters from their archetype. - std::vector PropertiesToSerialize; + std::vector PropertiesToSerialize; for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { @@ -147,7 +147,7 @@ void CStructPropertyNew::Serialize(IArchive& rArc) } } -void CStructPropertyNew::SerializeValue(void* pData, IArchive& Arc) const +void CStructProperty::SerializeValue(void* pData, IArchive& Arc) const { for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) { @@ -159,9 +159,9 @@ void CStructPropertyNew::SerializeValue(void* pData, IArchive& Arc) const } } -void CStructPropertyNew::InitFromArchetype(IPropertyNew* pOther) +void CStructProperty::InitFromArchetype(IProperty* pOther) { - IPropertyNew::InitFromArchetype(pOther); + IProperty::InitFromArchetype(pOther); // Copy children _ClearChildren(); @@ -169,14 +169,14 @@ void CStructPropertyNew::InitFromArchetype(IPropertyNew* pOther) for (u32 ChildIdx = 0; ChildIdx < pOther->NumChildren(); ChildIdx++) { - IPropertyNew* pChild = CreateCopy( pOther->ChildByIndex(ChildIdx) ); + IProperty* pChild = CreateCopy( pOther->ChildByIndex(ChildIdx) ); mChildren.push_back( pChild ); } } -bool CStructPropertyNew::ShouldSerialize() const +bool CStructProperty::ShouldSerialize() const { - if (IPropertyNew::ShouldSerialize()) + if (IProperty::ShouldSerialize()) return true; for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) @@ -188,7 +188,7 @@ bool CStructPropertyNew::ShouldSerialize() const return false; } -TString CStructPropertyNew::GetTemplateFileName() +TString CStructProperty::GetTemplateFileName() { ASSERT(IsArchetype() || mpArchetype); return IsArchetype() ? mTemplateFileName : mpArchetype->GetTemplateFileName(); diff --git a/src/Core/Resource/Script/Property/CStructProperty.h b/src/Core/Resource/Script/Property/CStructProperty.h index 44374eb8..87681eb4 100644 --- a/src/Core/Resource/Script/Property/CStructProperty.h +++ b/src/Core/Resource/Script/Property/CStructProperty.h @@ -1,7 +1,7 @@ #ifndef CSTRUCTPROPERTY_H #define CSTRUCTPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CStructPropertyNew : public IPropertyNew { diff --git a/src/Core/Resource/Script/Property/CVectorProperty.h b/src/Core/Resource/Script/Property/CVectorProperty.h index 0d9a368a..3b0fad84 100644 --- a/src/Core/Resource/Script/Property/CVectorProperty.h +++ b/src/Core/Resource/Script/Property/CVectorProperty.h @@ -1,7 +1,7 @@ #ifndef CVECTORPROPERTY_H #define CVECTORPROPERTY_H -#include "../IPropertyNew.h" +#include "IProperty.h" class CVectorProperty : public TSerializeableTypedProperty< CVector3f, EPropertyTypeNew::Vector > { diff --git a/src/Core/Resource/Script/IPropertyNew.cpp b/src/Core/Resource/Script/Property/IProperty.cpp similarity index 98% rename from src/Core/Resource/Script/IPropertyNew.cpp rename to src/Core/Resource/Script/Property/IProperty.cpp index 022dcb5e..c71980bc 100644 --- a/src/Core/Resource/Script/IPropertyNew.cpp +++ b/src/Core/Resource/Script/Property/IProperty.cpp @@ -1,9 +1,9 @@ -#include "IPropertyNew.h" -#include "Property/CAssetProperty.h" -#include "Property/CArrayProperty.h" -#include "Property/CEnumProperty.h" -#include "Property/CFlagsProperty.h" -#include "Property/CPointerProperty.h" +#include "IProperty.h" +#include "CAssetProperty.h" +#include "CArrayProperty.h" +#include "CEnumProperty.h" +#include "CFlagsProperty.h" +#include "CPointerProperty.h" #include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CScriptTemplate.h" diff --git a/src/Core/Resource/Script/IPropertyNew.h b/src/Core/Resource/Script/Property/IProperty.h similarity index 99% rename from src/Core/Resource/Script/IPropertyNew.h rename to src/Core/Resource/Script/Property/IProperty.h index 7a949afd..e503fea9 100644 --- a/src/Core/Resource/Script/IPropertyNew.h +++ b/src/Core/Resource/Script/Property/IProperty.h @@ -87,7 +87,7 @@ inline const char* PropEnumToHashableTypeName(EPropertyTypeNew Type) 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::Animation: return "animation"; case EPropertyTypeNew::Sequence: return "sequence"; // non hashable types - not used in ID hashes but still displayed on the UI case EPropertyTypeNew::Byte: return "byte"; diff --git a/src/Core/Resource/Script/Property/Properties.h b/src/Core/Resource/Script/Property/Properties.h index c7d770b2..4363f25c 100644 --- a/src/Core/Resource/Script/Property/Properties.h +++ b/src/Core/Resource/Script/Property/Properties.h @@ -1,7 +1,7 @@ #ifndef PROPERTIES_H #define PROPERTIES_H -#include "../IPropertyNew.h" +#include "IProperty.h" #include "CAnimationProperty.h" #include "CAnimationSetProperty.h" #include "CArrayProperty.h" diff --git a/src/Core/Resource/Script/TPropertyProxy.h b/src/Core/Resource/Script/TPropertyProxy.h deleted file mode 100644 index b7d83b7f..00000000 --- a/src/Core/Resource/Script/TPropertyProxy.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef TPROPERTYPROXY_H -#define TPROPERTYPROXY_H - -#include - -/** - * Lightweight proxy class representing a property instance. Easy to read/modify - * specific properties and efficient to pass around. - */ -template -class TPropertyProxy -{ - typedef PropertyClass::ValueType ValueType; - - /** Property data buffer */ - void* mpDataPtr; - - /** Source property */ - PropertyClass* mpProperty; - -public: - TPropertyProxy() - : mpDataPtr(nullptr) - , mpProperty(nullptr) - {} - - TPropertyProxy(void* pDataPtr, PropertyClass* pProperty) - : mpDataPtr(pDataPtr) - , mpProperty(pProperty) - {} - - /** Returns whether this proxy points to a valid property instance */ - bool IsValid() const - { - return mpDataPtr != nullptr && mpProperty != nullptr; - } -}; - -#endif // TPROPERTYPROXY_H diff --git a/src/Core/Scene/CLightNode.cpp b/src/Core/Scene/CLightNode.cpp index ff6af3e0..6b418b62 100644 --- a/src/Core/Scene/CLightNode.cpp +++ b/src/Core/Scene/CLightNode.cpp @@ -130,7 +130,7 @@ CStructRef CLightNode::GetProperties() const return CStructRef(mpLight, mpLight->GetProperties()); } -void CLightNode::PropertyModified(IPropertyNew* pProperty) +void CLightNode::PropertyModified(IProperty* pProperty) { CSceneNode::PropertyModified(pProperty); diff --git a/src/Core/Scene/CLightNode.h b/src/Core/Scene/CLightNode.h index bcaee790..7734bf83 100644 --- a/src/Core/Scene/CLightNode.h +++ b/src/Core/Scene/CLightNode.h @@ -16,7 +16,7 @@ public: void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); CStructRef GetProperties() const; - void PropertyModified(IPropertyNew* pProperty); + void PropertyModified(IProperty* pProperty); bool AllowsRotate() const { return false; } CLight* Light(); CVector2f BillboardScale(); diff --git a/src/Core/Scene/CSceneNode.h b/src/Core/Scene/CSceneNode.h index 20bd3f93..1a0f45a2 100644 --- a/src/Core/Scene/CSceneNode.h +++ b/src/Core/Scene/CSceneNode.h @@ -70,7 +70,7 @@ public: virtual CColor TintColor(const SViewInfo& rkViewInfo) const; virtual CColor WireframeColor() const; virtual CStructRef GetProperties() const { return CStructRef(); } - virtual void PropertyModified(IPropertyNew* pProperty) {} + virtual void PropertyModified(IProperty* pProperty) {} void OnLoadFinished(); void Unparent(); diff --git a/src/Core/Scene/CScriptAttachNode.cpp b/src/Core/Scene/CScriptAttachNode.cpp index 552cb19f..a5a9054a 100644 --- a/src/Core/Scene/CScriptAttachNode.cpp +++ b/src/Core/Scene/CScriptAttachNode.cpp @@ -1,7 +1,7 @@ #include "CScriptAttachNode.h" #include "CScriptNode.h" #include "Core/Render/CRenderer.h" -#include "Core/Resource/Script/IProperty.h" +#include "Core/Resource/Script/Property/IProperty.h" #include CScriptAttachNode::CScriptAttachNode(CScene *pScene, const SAttachment& rkAttachment, CScriptNode *pParent) diff --git a/src/Core/Scene/CScriptAttachNode.h b/src/Core/Scene/CScriptAttachNode.h index 0b053c20..67145017 100644 --- a/src/Core/Scene/CScriptAttachNode.h +++ b/src/Core/Scene/CScriptAttachNode.h @@ -12,7 +12,7 @@ class CScriptAttachNode : public CSceneNode CScriptNode* mpScriptNode; TResPtr mpAttachAsset; - IPropertyNew* mpAttachAssetProp; + IProperty* mpAttachAssetProp; CAssetRef mAttachAssetRef; CAnimationSetRef mAttachAnimSetRef; @@ -33,7 +33,7 @@ public: void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); - inline IPropertyNew* AttachProperty() const { return mpAttachAssetProp; } + inline IProperty* AttachProperty() const { return mpAttachAssetProp; } inline TString LocatorName() const { return mLocatorName; } protected: diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index 02c28650..4f3d8b4e 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -459,26 +459,26 @@ CStructRef CScriptNode::GetProperties() const return CStructRef(mpInstance->PropertyData(), mpInstance->Template()->Properties()); } -void CScriptNode::PropertyModified(IPropertyNew* pProp) +void CScriptNode::PropertyModified(IProperty* pProp) { // Update volume - EPropertyTypeNew Type = pProp->Type(); + EPropertyType Type = pProp->Type(); - if ( Type == EPropertyTypeNew::Bool || Type == EPropertyTypeNew::Byte || Type == EPropertyTypeNew::Short || - Type == EPropertyTypeNew::Int || Type == EPropertyTypeNew::Choice || Type == EPropertyTypeNew::Enum ) + if ( Type == EPropertyType::Bool || Type == EPropertyType::Byte || Type == EPropertyType::Short || + Type == EPropertyType::Int || Type == EPropertyType::Choice || Type == EPropertyType::Enum ) { mpInstance->EvaluateVolume(); UpdatePreviewVolume(); } // Update resources - else if (Type == EPropertyTypeNew::AnimationSet) + else if (Type == EPropertyType::AnimationSet) { mpInstance->EvaluateDisplayAsset(); SetDisplayAsset(mpInstance->DisplayAsset()); } - else if (Type == EPropertyTypeNew::Asset) + else if (Type == EPropertyType::Asset) { CAssetProperty* pAssetProperty = TPropCast(pProp); const CResTypeFilter& rkFilter = pAssetProperty->GetTypeFilter(); diff --git a/src/Core/Scene/CScriptNode.h b/src/Core/Scene/CScriptNode.h index 64e973c3..af358cad 100644 --- a/src/Core/Scene/CScriptNode.h +++ b/src/Core/Scene/CScriptNode.h @@ -48,7 +48,7 @@ public: CColor TintColor(const SViewInfo& rkViewInfo) const; CColor WireframeColor() const; CStructRef GetProperties() const; - void PropertyModified(IPropertyNew* pProp); + void PropertyModified(IProperty* pProp); void LinksModified(); void UpdatePreviewVolume(); diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp index 26f0798b..f05b108a 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp @@ -14,7 +14,7 @@ CDamageableTriggerExtra::CDamageableTriggerExtra(CScriptObject *pInstance, CScen SetInheritance(true, false, false); CreateMaterial(); - CStructPropertyNew* pProperties = pInstance->Template()->Properties(); + CStructProperty* pProperties = pInstance->Template()->Properties(); // Fetch render side mRenderSide = TEnumRef(pInstance->PropertyData(), pProperties->ChildByIndex(5)); @@ -178,7 +178,7 @@ void CDamageableTriggerExtra::OnTransformed() UpdatePlaneTransform(); } -void CDamageableTriggerExtra::PropertyModified(IPropertyNew* pProperty) +void CDamageableTriggerExtra::PropertyModified(IProperty* pProperty) { if (pProperty == mRenderSide || pProperty == mPlaneSize) { diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.h b/src/Core/ScriptExtra/CDamageableTriggerExtra.h index e86b44b1..a0a9bb6a 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.h +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.h @@ -35,7 +35,7 @@ public: ERenderSide RenderSideForDirection(const CVector3f& rkDir); ERenderSide TransformRenderSide(ERenderSide Side); void OnTransformed(); - void PropertyModified(IPropertyNew* pProperty); + void PropertyModified(IProperty* pProperty); bool ShouldDrawNormalAssets(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); diff --git a/src/Core/ScriptExtra/CDoorExtra.cpp b/src/Core/ScriptExtra/CDoorExtra.cpp index 919a4b23..819d902e 100644 --- a/src/Core/ScriptExtra/CDoorExtra.cpp +++ b/src/Core/ScriptExtra/CDoorExtra.cpp @@ -4,7 +4,7 @@ CDoorExtra::CDoorExtra(CScriptObject* pInstance, CScene* pScene, CScriptNode* pParent) : CScriptExtra(pInstance, pScene, pParent) { - CStructPropertyNew* pProperties = pInstance->Template()->Properties(); + CStructProperty* pProperties = pInstance->Template()->Properties(); mShieldModelProp = CAssetRef(pInstance->PropertyData(), pProperties->ChildByID(0xB20CC271)); if (mShieldModelProp.IsValid()) PropertyModified(mShieldModelProp.Property()); @@ -22,7 +22,7 @@ CDoorExtra::CDoorExtra(CScriptObject* pInstance, CScene* pScene, CScriptNode* pP } } -void CDoorExtra::PropertyModified(IPropertyNew* pProperty) +void CDoorExtra::PropertyModified(IProperty* pProperty) { if (pProperty == mShieldModelProp) { diff --git a/src/Core/ScriptExtra/CDoorExtra.h b/src/Core/ScriptExtra/CDoorExtra.h index 5bfe223d..4667e56f 100644 --- a/src/Core/ScriptExtra/CDoorExtra.h +++ b/src/Core/ScriptExtra/CDoorExtra.h @@ -15,7 +15,7 @@ class CDoorExtra : public CScriptExtra public: explicit CDoorExtra(CScriptObject* pInstance, CScene* pScene, CScriptNode* pParent = 0); - void PropertyModified(IPropertyNew* pProperty); + void PropertyModified(IProperty* pProperty); void AddToRenderer(CRenderer* pRenderer, const SViewInfo& rkViewInfo); void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); diff --git a/src/Core/ScriptExtra/CPointOfInterestExtra.cpp b/src/Core/ScriptExtra/CPointOfInterestExtra.cpp index bfbc39d0..ef8c0b11 100644 --- a/src/Core/ScriptExtra/CPointOfInterestExtra.cpp +++ b/src/Core/ScriptExtra/CPointOfInterestExtra.cpp @@ -8,7 +8,7 @@ CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CScene *p , mpScanData(nullptr) { // Fetch scan data property - CStructPropertyNew* pProperties = pInstance->Template()->Properties(); + CStructProperty* pProperties = pInstance->Template()->Properties(); if (mGame <= ePrime) mScanProperty = CAssetRef(pInstance->PropertyData(), pProperties->ChildByIDString("0x04:0x00")); else mScanProperty = CAssetRef(pInstance->PropertyData(), pProperties->ChildByIDString("0xBDBEC295:0xB94E9BE7")); @@ -16,7 +16,7 @@ CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CScene *p PropertyModified(mScanProperty.Property()); } -void CPointOfInterestExtra::PropertyModified(IPropertyNew* pProperty) +void CPointOfInterestExtra::PropertyModified(IProperty* pProperty) { if (mScanProperty.Property() == pProperty) mpScanData = gpResourceStore->LoadResource( mScanProperty.Get() ); diff --git a/src/Core/ScriptExtra/CPointOfInterestExtra.h b/src/Core/ScriptExtra/CPointOfInterestExtra.h index eb6ac554..ae699718 100644 --- a/src/Core/ScriptExtra/CPointOfInterestExtra.h +++ b/src/Core/ScriptExtra/CPointOfInterestExtra.h @@ -13,7 +13,7 @@ class CPointOfInterestExtra : public CScriptExtra public: explicit CPointOfInterestExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0); - void PropertyModified(IPropertyNew* pProperty); + void PropertyModified(IProperty* pProperty); void ModifyTintColor(CColor& Color); CScan* GetScan() const { return mpScanData; } diff --git a/src/Core/ScriptExtra/CRadiusSphereExtra.cpp b/src/Core/ScriptExtra/CRadiusSphereExtra.cpp index 0ee85a9e..7a55d4a4 100644 --- a/src/Core/ScriptExtra/CRadiusSphereExtra.cpp +++ b/src/Core/ScriptExtra/CRadiusSphereExtra.cpp @@ -6,7 +6,7 @@ CRadiusSphereExtra::CRadiusSphereExtra(CScriptObject* pInstance, CScene* pScene, : CScriptExtra(pInstance, pScene, pParent) { mObjectType = pInstance->ObjectTypeID(); - CStructPropertyNew* pProperties = pInstance->Template()->Properties(); + CStructProperty* pProperties = pInstance->Template()->Properties(); switch (mObjectType) { diff --git a/src/Core/ScriptExtra/CSandwormExtra.cpp b/src/Core/ScriptExtra/CSandwormExtra.cpp index fa6f3364..705cc6a1 100644 --- a/src/Core/ScriptExtra/CSandwormExtra.cpp +++ b/src/Core/ScriptExtra/CSandwormExtra.cpp @@ -17,7 +17,7 @@ CSandwormExtra::CSandwormExtra(CScriptObject* pInstance, CScene* pScene, CScript if (mPincersScale.IsValid()) PropertyModified(mPincersScale.Property()); } -void CSandwormExtra::PropertyModified(IPropertyNew* pProp) +void CSandwormExtra::PropertyModified(IProperty* pProp) { if (pProp == mPincersScale) { diff --git a/src/Core/ScriptExtra/CSandwormExtra.h b/src/Core/ScriptExtra/CSandwormExtra.h index d2643666..ca6e1776 100644 --- a/src/Core/ScriptExtra/CSandwormExtra.h +++ b/src/Core/ScriptExtra/CSandwormExtra.h @@ -10,7 +10,7 @@ class CSandwormExtra : public CScriptExtra public: explicit CSandwormExtra(CScriptObject* pInstance, CScene* pScene, CScriptNode* pParent); - void PropertyModified(IPropertyNew* pProp); + void PropertyModified(IProperty* pProp); }; #endif // CSANDWORMEXTRA_H diff --git a/src/Core/ScriptExtra/CScriptExtra.h b/src/Core/ScriptExtra/CScriptExtra.h index 0bdd812b..ec5812e0 100644 --- a/src/Core/ScriptExtra/CScriptExtra.h +++ b/src/Core/ScriptExtra/CScriptExtra.h @@ -46,7 +46,7 @@ public: // Virtual CScriptExtra functions virtual void InstanceTransformed() {} - virtual void PropertyModified(IPropertyNew* /*pProperty*/) {} + virtual void PropertyModified(IProperty* /*pProperty*/) {} virtual void DisplayAssetChanged(CResource* /*pNewDisplayAsset*/) {} virtual void LinksModified() {} virtual bool ShouldDrawNormalAssets() { return true; } diff --git a/src/Core/ScriptExtra/CSpacePirateExtra.cpp b/src/Core/ScriptExtra/CSpacePirateExtra.cpp index 1a498824..dce89815 100644 --- a/src/Core/ScriptExtra/CSpacePirateExtra.cpp +++ b/src/Core/ScriptExtra/CSpacePirateExtra.cpp @@ -3,8 +3,8 @@ CSpacePirateExtra::CSpacePirateExtra(CScriptObject* pInstance, CScene* pScene, CScriptNode* pParent) : CScriptExtra(pInstance, pScene ,pParent) { - CStructPropertyNew* pBaseStruct = pInstance->Template()->Properties(); - CStructPropertyNew* pVulnerabilities = TPropCast(pBaseStruct->ChildByIDString("0x04:0x10")); + CStructProperty* pBaseStruct = pInstance->Template()->Properties(); + CStructProperty* pVulnerabilities = TPropCast(pBaseStruct->ChildByIDString("0x04:0x10")); if (pVulnerabilities) { diff --git a/src/Core/ScriptExtra/CSpacePirateExtra.h b/src/Core/ScriptExtra/CSpacePirateExtra.h index 2e9c31e5..06c116fd 100644 --- a/src/Core/ScriptExtra/CSpacePirateExtra.h +++ b/src/Core/ScriptExtra/CSpacePirateExtra.h @@ -2,7 +2,7 @@ #define CSPACEPIRATEEXTRA_H #include "CScriptExtra.h" -#include "Core/Resource/Script/IProperty.h" +#include "Core/Resource/Script/Property/IProperty.h" enum class EVulnerabilityTypeMP1 { diff --git a/src/Core/ScriptExtra/CSplinePathExtra.cpp b/src/Core/ScriptExtra/CSplinePathExtra.cpp index ec043fa9..bc93ec5e 100644 --- a/src/Core/ScriptExtra/CSplinePathExtra.cpp +++ b/src/Core/ScriptExtra/CSplinePathExtra.cpp @@ -9,7 +9,7 @@ CSplinePathExtra::CSplinePathExtra(CScriptObject* pInstance, CScene* pScene, CSc mPathColor = CColorRef(pInstance->PropertyData(), pInstance->Template()->Properties()->ChildByID(0x00DD86E2)); } -void CSplinePathExtra::PropertyModified(IPropertyNew* pProperty) +void CSplinePathExtra::PropertyModified(IProperty* pProperty) { if (pProperty == mPathColor.Property()) { diff --git a/src/Core/ScriptExtra/CSplinePathExtra.h b/src/Core/ScriptExtra/CSplinePathExtra.h index 58194af9..58172d56 100644 --- a/src/Core/ScriptExtra/CSplinePathExtra.h +++ b/src/Core/ScriptExtra/CSplinePathExtra.h @@ -20,7 +20,7 @@ public: inline CColor PathColor() const { return (mPathColor.IsValid() ? mPathColor.Get() : CColor::skBlack); } void PostLoad(); - void PropertyModified(IPropertyNew* pProperty); + void PropertyModified(IProperty* pProperty); void FindAttachedWaypoints(std::set& rChecked, CWaypointExtra* pWaypoint); void AddWaypoints(); diff --git a/src/Editor/CGeneratePropertyNamesDialog.h b/src/Editor/CGeneratePropertyNamesDialog.h index f0ca1200..df2fc95a 100644 --- a/src/Editor/CGeneratePropertyNamesDialog.h +++ b/src/Editor/CGeneratePropertyNamesDialog.h @@ -2,7 +2,7 @@ #define CGENERATEPROPERTYNAMESDIALOG_H #include "CProgressBarNotifier.h" -#include +#include #include #include diff --git a/src/Editor/CPropertyNameValidator.cpp b/src/Editor/CPropertyNameValidator.cpp index 269b60b9..32faf16e 100644 --- a/src/Editor/CPropertyNameValidator.cpp +++ b/src/Editor/CPropertyNameValidator.cpp @@ -6,7 +6,7 @@ CPropertyNameValidator::CPropertyNameValidator(QObject* pParent) {} /** Set the property to validate against */ -void CPropertyNameValidator::SetProperty(IPropertyNew* pProp) +void CPropertyNameValidator::SetProperty(IProperty* pProp) { mpProperty = pProp; emit changed(); diff --git a/src/Editor/CPropertyNameValidator.h b/src/Editor/CPropertyNameValidator.h index e6a72bb2..bb924ead 100644 --- a/src/Editor/CPropertyNameValidator.h +++ b/src/Editor/CPropertyNameValidator.h @@ -10,13 +10,13 @@ class CPropertyNameValidator : public QValidator Q_OBJECT /** The property being validated against */ - IPropertyNew* mpProperty; + IProperty* mpProperty; public: CPropertyNameValidator(QObject* pParent = 0); /** Set the property to validate against */ - void SetProperty(IPropertyNew* pProp); + void SetProperty(IProperty* pProp); /** Perform validation */ QValidator::State validate(QString& rInput, int& rPos) const; diff --git a/src/Editor/PropertyEdit/CPropertyDelegate.cpp b/src/Editor/PropertyEdit/CPropertyDelegate.cpp index fe052e43..15f12191 100644 --- a/src/Editor/PropertyEdit/CPropertyDelegate.cpp +++ b/src/Editor/PropertyEdit/CPropertyDelegate.cpp @@ -10,8 +10,7 @@ #include "Editor/Widgets/WIntegralSpinBox.h" #include -#include -#include +#include #include #include diff --git a/src/Editor/PropertyEdit/CPropertyDelegate.h b/src/Editor/PropertyEdit/CPropertyDelegate.h index 5fbae896..95948a81 100644 --- a/src/Editor/PropertyEdit/CPropertyDelegate.h +++ b/src/Editor/PropertyEdit/CPropertyDelegate.h @@ -28,7 +28,7 @@ public: QWidget* CreateCharacterEditor(QWidget *pParent, const QModelIndex& rkIndex) const; void SetCharacterEditorData(QWidget *pEditor, const QModelIndex& rkIndex) const; void SetCharacterModelData(QWidget *pEditor, const QModelIndex& rkIndex) const; - EPropertyTypeNew DetermineCharacterPropType(EGame Game, const QModelIndex& rkIndex) const; + EPropertyType DetermineCharacterPropType(EGame Game, const QModelIndex& rkIndex) const; public slots: void WidgetEdited(QWidget *pWidget, const QModelIndex& rkIndex); diff --git a/src/Editor/PropertyEdit/CPropertyModel.cpp b/src/Editor/PropertyEdit/CPropertyModel.cpp index fba7a103..27a813bc 100644 --- a/src/Editor/PropertyEdit/CPropertyModel.cpp +++ b/src/Editor/PropertyEdit/CPropertyModel.cpp @@ -1,8 +1,7 @@ #include "CPropertyModel.h" #include "Editor/UICommon.h" #include -#include -#include +#include #include #include diff --git a/src/Editor/PropertyEdit/CPropertyModel.h b/src/Editor/PropertyEdit/CPropertyModel.h index dbd63a62..24e57331 100644 --- a/src/Editor/PropertyEdit/CPropertyModel.h +++ b/src/Editor/PropertyEdit/CPropertyModel.h @@ -11,32 +11,32 @@ class CPropertyModel : public QAbstractItemModel struct SProperty { - IPropertyNew* pProperty; + IProperty* pProperty; QModelIndex Index; int ParentID; std::vector ChildIDs; }; QVector mProperties; - QMap mPropertyToIDMap; + QMap mPropertyToIDMap; int mFirstUnusedID; CGameProject* mpProject; CScriptObject* mpObject; // may be null - IPropertyNew* mpRootProperty; + IProperty* mpRootProperty; void* mpPropertyData; bool mBoldModifiedProperties; bool mShowNameValidity; QFont mFont; - int RecursiveBuildArrays(IPropertyNew* pProperty, int ParentID); + int RecursiveBuildArrays(IProperty* pProperty, int ParentID); public: CPropertyModel(QObject *pParent = 0); - void ConfigureIntrinsic(CGameProject* pProject, IPropertyNew* pRootProperty, void* pPropertyData); - void ConfigureScript(CGameProject* pProject, IPropertyNew* pRootProperty, CScriptObject* pObject); - IPropertyNew* PropertyForIndex(const QModelIndex& rkIndex, bool HandleFlaggedIndices) const; - QModelIndex IndexForProperty(IPropertyNew *pProp) const; + void ConfigureIntrinsic(CGameProject* pProject, IProperty* pRootProperty, void* pPropertyData); + void ConfigureScript(CGameProject* pProject, IProperty* pRootProperty, CScriptObject* pObject); + IProperty* PropertyForIndex(const QModelIndex& rkIndex, bool HandleFlaggedIndices) const; + QModelIndex IndexForProperty(IProperty *pProp) const; void* DataPointerForIndex(const QModelIndex& rkIndex) const; int columnCount(const QModelIndex& rkParent) const; @@ -59,7 +59,7 @@ public: inline CScriptObject* GetScriptObject() const { return mpObject; } public slots: - void NotifyPropertyModified(class CScriptObject *pInst, IPropertyNew *pProp); + void NotifyPropertyModified(class CScriptObject *pInst, IProperty *pProp); void NotifyPropertyModified(const QModelIndex& rkIndex); signals: diff --git a/src/Editor/PropertyEdit/CPropertyView.cpp b/src/Editor/PropertyEdit/CPropertyView.cpp index 98143d46..5bec05da 100644 --- a/src/Editor/PropertyEdit/CPropertyView.cpp +++ b/src/Editor/PropertyEdit/CPropertyView.cpp @@ -1,7 +1,7 @@ #include "CPropertyView.h" #include "CPropertyDelegate.h" #include "Editor/WorldEditor/CTemplateEditDialog.h" -#include +#include #include #include diff --git a/src/Editor/PropertyEdit/CPropertyView.h b/src/Editor/PropertyEdit/CPropertyView.h index c8585d41..e5ba50ea 100644 --- a/src/Editor/PropertyEdit/CPropertyView.h +++ b/src/Editor/PropertyEdit/CPropertyView.h @@ -15,7 +15,7 @@ class CPropertyView : public QTreeView CPropertyDelegate *mpDelegate; CScriptObject *mpObject; - IPropertyNew *mpMenuProperty; + IProperty *mpMenuProperty; QAction *mpShowNameValidityAction; QAction *mpEditTemplateAction; diff --git a/src/Editor/Undo/CEditScriptPropertyCommand.h b/src/Editor/Undo/CEditScriptPropertyCommand.h index 8388f138..e4c9f8ad 100644 --- a/src/Editor/Undo/CEditScriptPropertyCommand.h +++ b/src/Editor/Undo/CEditScriptPropertyCommand.h @@ -13,7 +13,7 @@ protected: QModelIndex mIndex; public: - CEditScriptPropertyCommand(IPropertyNew* pProperty, + CEditScriptPropertyCommand(IProperty* pProperty, CWorldEditor* pEditor, const QVector& rkInstances, QModelIndex Index = QModelIndex(), diff --git a/src/Editor/Undo/CResizeScriptArrayCommand.h b/src/Editor/Undo/CResizeScriptArrayCommand.h index 4352b6b9..b219d15a 100644 --- a/src/Editor/Undo/CResizeScriptArrayCommand.h +++ b/src/Editor/Undo/CResizeScriptArrayCommand.h @@ -13,7 +13,7 @@ class CResizeScriptArrayCommand : public CEditScriptPropertyCommand int mNewRowCount; public: - CResizeScriptArrayCommand(IPropertyNew* pProperty, + CResizeScriptArrayCommand(IProperty* pProperty, CWorldEditor* pEditor, const QVector& rkInstances, CPropertyModel* pModel = nullptr, diff --git a/src/Editor/Undo/IEditPropertyCommand.cpp b/src/Editor/Undo/IEditPropertyCommand.cpp index 18758eac..a1266d27 100644 --- a/src/Editor/Undo/IEditPropertyCommand.cpp +++ b/src/Editor/Undo/IEditPropertyCommand.cpp @@ -30,7 +30,7 @@ void IEditPropertyCommand::RestoreObjectStateFromArray(std::vector& rArray } IEditPropertyCommand::IEditPropertyCommand( - IPropertyNew* pProperty, + IProperty* pProperty, const QString& rkCommandName /*= "Edit Property"*/ ) : IUndoCommand(rkCommandName) diff --git a/src/Editor/Undo/IEditPropertyCommand.h b/src/Editor/Undo/IEditPropertyCommand.h index 4cf41701..59222ed5 100644 --- a/src/Editor/Undo/IEditPropertyCommand.h +++ b/src/Editor/Undo/IEditPropertyCommand.h @@ -12,7 +12,7 @@ protected: std::vector mOldData; std::vector mNewData; - IPropertyNew* mpProperty; + IProperty* mpProperty; bool mCommandEnded; bool mSavedOldData; bool mSavedNewData; @@ -25,7 +25,7 @@ protected: public: IEditPropertyCommand( - IPropertyNew* pProperty, + IProperty* pProperty, const QString& rkCommandName = "Edit Property" ); diff --git a/src/Editor/WorldEditor/CInstancesModel.cpp b/src/Editor/WorldEditor/CInstancesModel.cpp index 4f3a5867..d4b4e8a4 100644 --- a/src/Editor/WorldEditor/CInstancesModel.cpp +++ b/src/Editor/WorldEditor/CInstancesModel.cpp @@ -44,7 +44,7 @@ CInstancesModel::CInstancesModel(CWorldEditor *pEditor, QObject *pParent) connect(mpEditor, SIGNAL(NodeSpawned(CSceneNode*)), this, SLOT(NodeCreated(CSceneNode*))); connect(mpEditor, SIGNAL(NodeAboutToBeDeleted(CSceneNode*)), this, SLOT(NodeAboutToBeDeleted(CSceneNode*))); connect(mpEditor, SIGNAL(NodeDeleted()), this, SLOT(NodeDeleted())); - connect(mpEditor, SIGNAL(PropertyModified(CScriptObject*,IPropertyNew*)), this, SLOT(PropertyModified(CScriptObject*,IPropertyNew*))); + connect(mpEditor, SIGNAL(PropertyModified(CScriptObject*,IProperty*)), this, SLOT(PropertyModified(CScriptObject*,IProperty*))); connect(mpEditor, SIGNAL(InstancesLayerAboutToChange()), this, SLOT(InstancesLayerPreChange())); connect(mpEditor, SIGNAL(InstancesLayerChanged(QList)), this, SLOT(InstancesLayerPostChange(QList))); } @@ -474,7 +474,7 @@ void CInstancesModel::NodeDeleted() } } -void CInstancesModel::PropertyModified(CScriptObject *pInst, IPropertyNew *pProp) +void CInstancesModel::PropertyModified(CScriptObject *pInst, IProperty *pProp) { if (pProp->Name() == "Name") { diff --git a/src/Editor/WorldEditor/CInstancesModel.h b/src/Editor/WorldEditor/CInstancesModel.h index 8e2a9346..270143cf 100644 --- a/src/Editor/WorldEditor/CInstancesModel.h +++ b/src/Editor/WorldEditor/CInstancesModel.h @@ -67,7 +67,7 @@ public slots: void NodeAboutToBeDeleted(CSceneNode *pNode); void NodeDeleted(); - void PropertyModified(CScriptObject *pInst, IPropertyNew *pProp); + void PropertyModified(CScriptObject *pInst, IProperty *pProp); void InstancesLayerPreChange(); void InstancesLayerPostChange(const QList& rkInstanceList); diff --git a/src/Editor/WorldEditor/CTemplateEditDialog.cpp b/src/Editor/WorldEditor/CTemplateEditDialog.cpp index cbf170d2..d2faee61 100644 --- a/src/Editor/WorldEditor/CTemplateEditDialog.cpp +++ b/src/Editor/WorldEditor/CTemplateEditDialog.cpp @@ -6,7 +6,7 @@ #include #include -CTemplateEditDialog::CTemplateEditDialog(IPropertyNew *pProperty, QWidget *pParent) +CTemplateEditDialog::CTemplateEditDialog(IProperty *pProperty, QWidget *pParent) : QDialog(pParent) , mpUI(new Ui::CTemplateEditDialog) , mpValidator(new CPropertyNameValidator(this)) @@ -93,7 +93,7 @@ void CTemplateEditDialog::ApplyChanges() CMasterTemplate::RenameProperty(mpProperty, NewName); // Add modified templates to pending resave list - const std::vector *pList = CMasterTemplate::TemplatesWithMatchingID(mpProperty); + const std::vector *pList = CMasterTemplate::TemplatesWithMatchingID(mpProperty); if (pList) { @@ -126,9 +126,9 @@ void CTemplateEditDialog::ApplyChanges() } // ************ PROTECTED ************ -void CTemplateEditDialog::AddTemplate(IPropertyNew* pProp) +void CTemplateEditDialog::AddTemplate(IProperty* pProp) { - IPropertyNew* pArchetype = pProp->Archetype(); + IProperty* pArchetype = pProp->Archetype(); if (pArchetype) { @@ -137,9 +137,9 @@ void CTemplateEditDialog::AddTemplate(IPropertyNew* pProp) switch (pArchetype->Type()) { - case EPropertyTypeNew::Struct: + case EPropertyType::Struct: { - CStructPropertyNew* pStruct = TPropCast(pArchetype); + CStructProperty* pStruct = TPropCast(pArchetype); if (!mStructTemplatesToResave.contains(pStruct)) { mStructTemplatesToResave << pStruct; @@ -179,13 +179,13 @@ void CTemplateEditDialog::UpdateDescription(const TString& rkNewDesc) if (!SourceFile.IsEmpty()) { - const std::vector* pkTemplates = CMasterTemplate::TemplatesWithMatchingID(mpProperty); + const std::vector* pkTemplates = CMasterTemplate::TemplatesWithMatchingID(mpProperty); if (pkTemplates) { for (u32 TemplateIdx = 0; TemplateIdx < pkTemplates->size(); TemplateIdx++) { - IPropertyNew* pProp = pkTemplates->at(TemplateIdx); + IProperty* pProp = pkTemplates->at(TemplateIdx); if (pProp->GetTemplateFileName() == SourceFile && pProp->Description() == mOriginalDescription) pProp->SetDescription(rkNewDesc); @@ -194,14 +194,14 @@ void CTemplateEditDialog::UpdateDescription(const TString& rkNewDesc) } // Update equivalent properties with new description - foreach (IPropertyNew* pProperty, mEquivalentProperties) + foreach (IProperty* pProperty, mEquivalentProperties) { pProperty->SetDescription(rkNewDesc); AddTemplate(pProperty); } } -void CTemplateEditDialog::FindEquivalentProperties(IPropertyNew *pTemp) +void CTemplateEditDialog::FindEquivalentProperties(IProperty *pTemp) { //FIXME /* diff --git a/src/Editor/WorldEditor/CTemplateEditDialog.h b/src/Editor/WorldEditor/CTemplateEditDialog.h index a46ce71c..99b10af1 100644 --- a/src/Editor/WorldEditor/CTemplateEditDialog.h +++ b/src/Editor/WorldEditor/CTemplateEditDialog.h @@ -2,7 +2,7 @@ #define CTEMPLATEEDITDIALOG_H #include "Editor/CPropertyNameValidator.h" -#include +#include #include #include diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 1615e006..13439ab7 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -569,7 +569,7 @@ void CWorldEditor::OnLinksModified(const QList& rkInstances) emit InstanceLinksModified(rkInstances); } -void CWorldEditor::OnPropertyModified(CScriptObject* pObject, IPropertyNew *pProp) +void CWorldEditor::OnPropertyModified(CScriptObject* pObject, IProperty *pProp) { CScriptNode *pScript = mScene.NodeForInstance(pObject); @@ -592,7 +592,7 @@ void CWorldEditor::OnPropertyModified(CScriptObject* pObject, IPropertyNew *pPro } // If this is a model/character, then we'll treat this as a modified selection. This is to make sure the selection bounds updates. - if (pProp->Type() == EPropertyTypeNew::Asset) + if (pProp->Type() == EPropertyType::Asset) { CAssetProperty *pAsset = TPropCast(pProp); const CResTypeFilter& rkFilter = pAsset->GetTypeFilter(); @@ -600,7 +600,7 @@ void CWorldEditor::OnPropertyModified(CScriptObject* pObject, IPropertyNew *pPro if (rkFilter.Accepts(eModel) || rkFilter.Accepts(eAnimSet) || rkFilter.Accepts(eCharacter)) SelectionModified(); } - else if (pProp->Type() == EPropertyTypeNew::AnimationSet) + else if (pProp->Type() == EPropertyType::AnimationSet) SelectionModified(); // Emit signal so other widgets can react to the property change diff --git a/src/Editor/WorldEditor/CWorldEditor.h b/src/Editor/WorldEditor/CWorldEditor.h index 201e4970..bb7b221d 100644 --- a/src/Editor/WorldEditor/CWorldEditor.h +++ b/src/Editor/WorldEditor/CWorldEditor.h @@ -122,7 +122,7 @@ public slots: void OnActiveProjectChanged(CGameProject *pProj); void OnLinksModified(const QList& rkInstances); - void OnPropertyModified(CScriptObject* pObject, IPropertyNew *pProp); + void OnPropertyModified(CScriptObject* pObject, IProperty *pProp); void SetSelectionActive(bool Active); void SetSelectionInstanceNames(const QString& rkNewName, bool IsDone); void SetSelectionLayer(CScriptLayer *pLayer); @@ -187,7 +187,7 @@ signals: void InstancesLayerAboutToChange(); void InstancesLayerChanged(const QList& rkInstanceList); void InstanceLinksModified(const QList& rkInstances); - void PropertyModified(CScriptObject *pInst, IPropertyNew *pProp); + void PropertyModified(CScriptObject *pInst, IProperty *pProp); }; #endif // CWORLDEDITOR_H diff --git a/src/Editor/WorldEditor/WEditorProperties.cpp b/src/Editor/WorldEditor/WEditorProperties.cpp index e3c2e3bc..e032c193 100644 --- a/src/Editor/WorldEditor/WEditorProperties.cpp +++ b/src/Editor/WorldEditor/WEditorProperties.cpp @@ -65,7 +65,7 @@ void WEditorProperties::SyncToEditor(CWorldEditor *pEditor) connect(mpEditor, SIGNAL(SelectionModified()), this, SLOT(OnSelectionModified())); connect(mpEditor, SIGNAL(LayersModified()), this, SLOT(OnLayersModified())); connect(mpEditor, SIGNAL(InstancesLayerChanged(QList)), this, SLOT(OnInstancesLayerChanged(QList))); - connect(mpEditor, SIGNAL(PropertyModified(CScriptObject*,IPropertyNew*)), this, SLOT(OnPropertyModified(CScriptObject*,IPropertyNew*))); + connect(mpEditor, SIGNAL(PropertyModified(CScriptObject*,IProperty*)), this, SLOT(OnPropertyModified(CScriptObject*,IProperty*))); OnLayersModified(); } @@ -139,7 +139,7 @@ void WEditorProperties::OnSelectionModified() SetLayerComboBox(); } -void WEditorProperties::OnPropertyModified(CScriptObject *pInstance, IPropertyNew *pProp) +void WEditorProperties::OnPropertyModified(CScriptObject *pInstance, IProperty *pProp) { if (!mpInstanceNameLineEdit->hasFocus()) { diff --git a/src/Editor/WorldEditor/WEditorProperties.h b/src/Editor/WorldEditor/WEditorProperties.h index a6f56184..e21ba9b2 100644 --- a/src/Editor/WorldEditor/WEditorProperties.h +++ b/src/Editor/WorldEditor/WEditorProperties.h @@ -39,7 +39,7 @@ public: public slots: void OnSelectionModified(); - void OnPropertyModified(CScriptObject *pInst, IPropertyNew *pProp); + void OnPropertyModified(CScriptObject *pInst, IProperty *pProp); void OnInstancesLayerChanged(const QList& rkNodeList); void OnLayersModified(); void UpdatePropertyValues();