More cleanup, renamed CMasterTemplate to CGameTemplate

This commit is contained in:
Aruki 2018-09-22 23:54:34 -06:00
parent 31dac74a64
commit 42d021e757
58 changed files with 724 additions and 715 deletions

View File

@ -1,5 +1,5 @@
#include "CAreaAttributes.h" #include "CAreaAttributes.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include "Core/Resource/Script/CScriptLayer.h" #include "Core/Resource/Script/CScriptLayer.h"
CAreaAttributes::CAreaAttributes(CScriptObject *pObj) CAreaAttributes::CAreaAttributes(CScriptObject *pObj)
@ -17,7 +17,7 @@ void CAreaAttributes::SetObject(CScriptObject *pObj)
CStructProperty* pProperties = pTemplate->Properties(); CStructProperty* pProperties = pTemplate->Properties();
mpObject = pObj; mpObject = pObj;
mGame = pTemplate->MasterTemplate()->Game(); mGame = pTemplate->GameTemplate()->Game();
mNeedSky = CBoolRef(pObj->PropertyData(), pProperties->ChildByIndex(1)); mNeedSky = CBoolRef(pObj->PropertyData(), pProperties->ChildByIndex(1));
if (mGame == ePrime) if (mGame == ePrime)

View File

@ -110,7 +110,6 @@ HEADERS += \
Resource/Model/CStaticModel.h \ Resource/Model/CStaticModel.h \
Resource/Model/CVertex.h \ Resource/Model/CVertex.h \
Resource/Model/SSurface.h \ Resource/Model/SSurface.h \
Resource/Script/CMasterTemplate.h \
Resource/Script/CScriptLayer.h \ Resource/Script/CScriptLayer.h \
Resource/Script/CScriptObject.h \ Resource/Script/CScriptObject.h \
Resource/Script/CScriptTemplate.h \ Resource/Script/CScriptTemplate.h \
@ -249,7 +248,8 @@ HEADERS += \
Resource/Script/Property/CVectorProperty.h \ Resource/Script/Property/CVectorProperty.h \
Resource/Script/Property/CColorProperty.h \ Resource/Script/Property/CColorProperty.h \
Resource/Script/Property/CStructProperty.h \ Resource/Script/Property/CStructProperty.h \
Resource/Script/Property/CGuidProperty.h Resource/Script/Property/CGuidProperty.h \
Resource/Script/CGameTemplate.h
# Source Files # Source Files
SOURCES += \ SOURCES += \
@ -279,7 +279,6 @@ SOURCES += \
Resource/Model/CModel.cpp \ Resource/Model/CModel.cpp \
Resource/Model/CStaticModel.cpp \ Resource/Model/CStaticModel.cpp \
Resource/Model/SSurface.cpp \ Resource/Model/SSurface.cpp \
Resource/Script/CMasterTemplate.cpp \
Resource/Script/CScriptObject.cpp \ Resource/Script/CScriptObject.cpp \
Resource/Script/CScriptTemplate.cpp \ Resource/Script/CScriptTemplate.cpp \
Resource/CCollisionMesh.cpp \ Resource/CCollisionMesh.cpp \
@ -359,7 +358,8 @@ SOURCES += \
Resource/Script/Property/CPropertyNameGenerator.cpp \ Resource/Script/Property/CPropertyNameGenerator.cpp \
Resource/Script/Property/IProperty.cpp \ Resource/Script/Property/IProperty.cpp \
Resource/Script/Property/CStructProperty.cpp \ Resource/Script/Property/CStructProperty.cpp \
Resource/Script/Property/CFlagsProperty.cpp Resource/Script/Property/CFlagsProperty.cpp \
Resource/Script/CGameTemplate.cpp
# Codegen # Codegen
CODEGEN_DIR = $$EXTERNALS_DIR/CodeGen CODEGEN_DIR = $$EXTERNALS_DIR/CodeGen

View File

@ -1,7 +1,7 @@
#include "CDependencyTree.h" #include "CDependencyTree.h"
#include "Core/GameProject/CGameProject.h" #include "Core/GameProject/CGameProject.h"
#include "Core/Resource/Animation/CAnimSet.h" #include "Core/Resource/Animation/CAnimSet.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include "Core/Resource/Script/CScriptLayer.h" #include "Core/Resource/Script/CScriptLayer.h"
#include "Core/Resource/Script/CScriptObject.h" #include "Core/Resource/Script/CScriptObject.h"
@ -360,7 +360,7 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector
void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<u32>& rModuleLayerOffsetsOut) const void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<u32>& rModuleLayerOffsetsOut) const
{ {
CMasterTemplate *pMaster = CMasterTemplate::MasterForGame(Game); CGameTemplate *pGame = CGameTemplate::GetGameTemplate(Game);
// Output module list will be split per-script layer // Output module list will be split per-script layer
// The output offset list contains two offsets per layer - start index and end index // The output offset list contains two offsets per layer - start index and end index
@ -386,7 +386,7 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>
if (UsedObjectTypes.find(ObjType) == UsedObjectTypes.end()) if (UsedObjectTypes.find(ObjType) == UsedObjectTypes.end())
{ {
// Get the module list for this object type and check whether any of them are new before adding them to the output list // Get the module list for this object type and check whether any of them are new before adding them to the output list
CScriptTemplate *pTemplate = pMaster->TemplateByID(ObjType); CScriptTemplate *pTemplate = pGame->TemplateByID(ObjType);
const std::vector<TString>& rkModules = pTemplate->RequiredModules(); const std::vector<TString>& rkModules = pTemplate->RequiredModules();
for (u32 iMod = 0; iMod < rkModules.size(); iMod++) for (u32 iMod = 0; iMod < rkModules.size(); iMod++)

View File

@ -4,7 +4,7 @@
#include "CResourceStore.h" #include "CResourceStore.h"
#include "Core/CompressionUtil.h" #include "Core/CompressionUtil.h"
#include "Core/Resource/CWorld.h" #include "Core/Resource/CWorld.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include <Common/AssertMacro.h> #include <Common/AssertMacro.h>
#include <Common/CScopedTimer.h> #include <Common/CScopedTimer.h>
#include <Common/FileIO.h> #include <Common/FileIO.h>

View File

@ -1,7 +1,7 @@
#include "CGameProject.h" #include "CGameProject.h"
#include "IUIRelay.h" #include "IUIRelay.h"
#include "Core/Resource/Factory/CTemplateLoader.h" #include "Core/Resource/Factory/CTemplateLoader.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include <Common/Serialization/XML.h> #include <Common/Serialization/XML.h>
#include <nod/nod.hpp> #include <nod/nod.hpp>

View File

@ -6,7 +6,7 @@
#include "CResourceStore.h" #include "CResourceStore.h"
#include "Core/CAudioManager.h" #include "Core/CAudioManager.h"
#include "Core/IProgressNotifier.h" #include "Core/IProgressNotifier.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include <Common/CAssetID.h> #include <Common/CAssetID.h>
#include <Common/EGame.h> #include <Common/EGame.h>
#include <Common/FileUtil.h> #include <Common/FileUtil.h>

View File

@ -1,7 +1,7 @@
#include "CScriptLoader.h" #include "CScriptLoader.h"
#include "CTemplateLoader.h" #include "CTemplateLoader.h"
#include "Core/GameProject/CResourceStore.h" #include "Core/GameProject/CResourceStore.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include "Core/Resource/Script/Property/CArrayProperty.h" #include "Core/Resource/Script/Property/CArrayProperty.h"
#include "Core/Resource/Script/Property/CAssetProperty.h" #include "Core/Resource/Script/Property/CAssetProperty.h"
#include "Core/Resource/Script/Property/CEnumProperty.h" #include "Core/Resource/Script/Property/CEnumProperty.h"
@ -131,7 +131,7 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
case EPropertyType::Asset: case EPropertyType::Asset:
{ {
CAssetProperty* pAsset = TPropCast<CAssetProperty>(pProp); CAssetProperty* pAsset = TPropCast<CAssetProperty>(pProp);
pAsset->ValueRef(pData) = CAssetID(rSCLY, mpMaster->Game()); pAsset->ValueRef(pData) = CAssetID(rSCLY, mpGameTemplate->Game());
#if VALIDATE_PROPERTY_VALUES #if VALIDATE_PROPERTY_VALUES
CAssetID ID = pAsset->ValueRef(pData); CAssetID ID = pAsset->ValueRef(pData);
@ -170,7 +170,7 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
case EPropertyType::AnimationSet: case EPropertyType::AnimationSet:
{ {
CAnimationSetProperty* pAnimSet = TPropCast<CAnimationSetProperty>(pProp); CAnimationSetProperty* pAnimSet = TPropCast<CAnimationSetProperty>(pProp);
pAnimSet->ValueRef(pData) = CAnimationParameters(rSCLY, mpMaster->Game()); pAnimSet->ValueRef(pData) = CAnimationParameters(rSCLY, mpGameTemplate->Game());
break; break;
} }
@ -278,7 +278,7 @@ CScriptObject* CScriptLoader::LoadObjectMP1(IInputStream& rSCLY)
u32 Size = rSCLY.ReadLong(); u32 Size = rSCLY.ReadLong();
u32 End = rSCLY.Tell() + Size; u32 End = rSCLY.Tell() + Size;
CScriptTemplate *pTemplate = mpMaster->TemplateByID((u32) Type); CScriptTemplate *pTemplate = mpGameTemplate->TemplateByID((u32) Type);
if (!pTemplate) if (!pTemplate)
{ {
// No valid template for this object; can't load // No valid template for this object; can't load
@ -385,7 +385,7 @@ CScriptObject* CScriptLoader::LoadObjectMP2(IInputStream& rSCLY)
u16 ObjectSize = rSCLY.ReadShort(); u16 ObjectSize = rSCLY.ReadShort();
u32 ObjEnd = rSCLY.Tell() + ObjectSize; u32 ObjEnd = rSCLY.Tell() + ObjectSize;
CScriptTemplate* pTemplate = mpMaster->TemplateByID(ObjectID); CScriptTemplate* pTemplate = mpGameTemplate->TemplateByID(ObjectID);
if (!pTemplate) if (!pTemplate)
{ {
@ -447,16 +447,16 @@ CScriptLayer* CScriptLoader::LoadLayer(IInputStream& rSCLY, CGameArea *pArea, EG
CScriptLoader Loader; CScriptLoader Loader;
Loader.mVersion = Version; Loader.mVersion = Version;
Loader.mpMaster = CMasterTemplate::MasterForGame(Version); Loader.mpGameTemplate = CGameTemplate::GetGameTemplate(Version);
Loader.mpArea = pArea; Loader.mpArea = pArea;
if (!Loader.mpMaster) if (!Loader.mpGameTemplate)
{ {
Log::Write("This game doesn't have a master template; couldn't load script layer"); Log::Write("This game doesn't have a game template; couldn't load script layer");
return nullptr; return nullptr;
} }
if (!Loader.mpMaster->IsLoadedSuccessfully()) if (!Loader.mpGameTemplate->IsLoadedSuccessfully())
CTemplateLoader::LoadGameTemplates(Version); CTemplateLoader::LoadGameTemplates(Version);
if (Version <= ePrime) if (Version <= ePrime)
@ -471,17 +471,17 @@ CScriptObject* CScriptLoader::LoadInstance(IInputStream& rSCLY, CGameArea *pArea
CScriptLoader Loader; CScriptLoader Loader;
Loader.mVersion = (ForceReturnsFormat ? eReturns : Version); Loader.mVersion = (ForceReturnsFormat ? eReturns : Version);
Loader.mpMaster = CMasterTemplate::MasterForGame(Version); Loader.mpGameTemplate = CGameTemplate::GetGameTemplate(Version);
Loader.mpArea = pArea; Loader.mpArea = pArea;
Loader.mpLayer = pLayer; Loader.mpLayer = pLayer;
if (!Loader.mpMaster) if (!Loader.mpGameTemplate)
{ {
Log::Write("This game doesn't have a master template; couldn't load script instance"); Log::Write("This game doesn't have a game template; couldn't load script instance");
return nullptr; return nullptr;
} }
if (!Loader.mpMaster->IsLoadedSuccessfully()) if (!Loader.mpGameTemplate->IsLoadedSuccessfully())
CTemplateLoader::LoadGameTemplates(Version); CTemplateLoader::LoadGameTemplates(Version);
if (Loader.mVersion <= ePrime) if (Loader.mVersion <= ePrime)

View File

@ -5,7 +5,7 @@
#include "Core/Resource/Area/CGameArea.h" #include "Core/Resource/Area/CGameArea.h"
#include "Core/Resource/Script/CScriptObject.h" #include "Core/Resource/Script/CScriptObject.h"
#include "Core/Resource/Script/CScriptLayer.h" #include "Core/Resource/Script/CScriptLayer.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
class CScriptLoader class CScriptLoader
{ {
@ -13,7 +13,7 @@ class CScriptLoader
CScriptObject* mpObj; CScriptObject* mpObj;
CScriptLayer* mpLayer; CScriptLayer* mpLayer;
CGameArea* mpArea; CGameArea* mpArea;
CMasterTemplate *mpMaster; CGameTemplate *mpGameTemplate;
// Current array item pointer // Current array item pointer
void* mpArrayItemData; void* mpArrayItemData;

View File

@ -11,45 +11,45 @@ using namespace tinyxml2;
// ugly macro because this is all temp code anyway so whatever // ugly macro because this is all temp code anyway so whatever
#define SET_MEMBER_CASES_NUMERICAL(MemberName, Param, LParam) \ #define SET_MEMBER_CASES_NUMERICAL(MemberName, Param, LParam) \
case EPropertyTypeNew::Byte:\ case EPropertyType::Byte:\
TPropCast<CByteProperty>(pProp)->MemberName = (s8) LParam.ToInt32(10);\ TPropCast<CByteProperty>(pProp)->MemberName = (s8) LParam.ToInt32(10);\
break;\ break;\
\ \
case EPropertyTypeNew::Short:\ case EPropertyType::Short:\
TPropCast<CShortProperty>(pProp)->MemberName = (s16) LParam.ToInt32(10);\ TPropCast<CShortProperty>(pProp)->MemberName = (s16) LParam.ToInt32(10);\
break;\ break;\
\ \
case EPropertyTypeNew::Int:\ case EPropertyType::Int:\
TPropCast<CIntProperty>(pProp)->MemberName = (s32) LParam.ToInt32(10);\ TPropCast<CIntProperty>(pProp)->MemberName = (s32) LParam.ToInt32(10);\
break;\ break;\
\ \
case EPropertyTypeNew::Float:\ case EPropertyType::Float:\
TPropCast<CFloatProperty>(pProp)->MemberName = LParam.ToFloat();\ TPropCast<CFloatProperty>(pProp)->MemberName = LParam.ToFloat();\
break;\ break;\
\ \
#define SET_MEMBER_CASES_NON_NUMERICAL(MemberName, Param, LParam) \ #define SET_MEMBER_CASES_NON_NUMERICAL(MemberName, Param, LParam) \
case EPropertyTypeNew::Bool:\ case EPropertyType::Bool:\
TPropCast<CBoolProperty>(pProp)->MemberName = (LParam == "true");\ TPropCast<CBoolProperty>(pProp)->MemberName = (LParam == "true");\
break;\ break;\
\ \
case EPropertyTypeNew::Choice:\ case EPropertyType::Choice:\
TPropCast<CChoiceProperty>(pProp)->MemberName = LParam.ToInt32( LParam.StartsWith("0x") ? 16 : 10 );\ TPropCast<CChoiceProperty>(pProp)->MemberName = LParam.ToInt32( LParam.StartsWith("0x") ? 16 : 10 );\
break;\ break;\
\ \
case EPropertyTypeNew::Enum:\ case EPropertyType::Enum:\
TPropCast<CEnumProperty>(pProp)->MemberName = LParam.ToInt32( LParam.StartsWith("0x") ? 16 : 10 );\ TPropCast<CEnumProperty>(pProp)->MemberName = LParam.ToInt32( LParam.StartsWith("0x") ? 16 : 10 );\
break;\ break;\
\ \
case EPropertyTypeNew::Flags:\ case EPropertyType::Flags:\
TPropCast<CFlagsProperty>(pProp)->MemberName = LParam.ToInt32( LParam.StartsWith("0x") ? 16 : 10 );\ TPropCast<CFlagsProperty>(pProp)->MemberName = LParam.ToInt32( LParam.StartsWith("0x") ? 16 : 10 );\
break;\ break;\
\ \
case EPropertyTypeNew::String:\ case EPropertyType::String:\
TPropCast<CStringProperty>(pProp)->MemberName = Param;\ TPropCast<CStringProperty>(pProp)->MemberName = Param;\
break;\ break;\
\ \
case EPropertyTypeNew::Vector:\ case EPropertyType::Vector:\
{\ {\
TStringList Components = Param.Split(", ");\ TStringList Components = Param.Split(", ");\
if (Components.size() != 3) {\ if (Components.size() != 3) {\
@ -64,7 +64,7 @@ using namespace tinyxml2;
}\ }\
break;\ break;\
}\ }\
case EPropertyTypeNew::Color:\ case EPropertyType::Color:\
{\ {\
TStringList Components = Param.Split(", ");\ TStringList Components = Param.Split(", ");\
if (Components.size() < 3 || Components.size() > 4) {\ if (Components.size() < 3 || Components.size() > 4) {\
@ -79,11 +79,11 @@ using namespace tinyxml2;
}\ }\
break;\ break;\
}\ }\
case EPropertyTypeNew::Asset:\ case EPropertyType::Asset:\
TPropCast<CAssetProperty>(pProp)->MemberName = CAssetID::FromString(Param);\ TPropCast<CAssetProperty>(pProp)->MemberName = CAssetID::FromString(Param);\
break;\ break;\
\ \
case EPropertyTypeNew::Sound:\ case EPropertyType::Sound:\
TPropCast<CSoundProperty>(pProp)->MemberName = LParam.ToInt32(10);\ TPropCast<CSoundProperty>(pProp)->MemberName = LParam.ToInt32(10);\
break;\ break;\
\ \
@ -107,29 +107,29 @@ using namespace tinyxml2;
break;\ break;\
}\ }\
EPropertyTypeNew PropStringToPropEnum(TString Prop) EPropertyType PropStringToPropEnum(TString Prop)
{ {
Prop = Prop.ToLower(); Prop = Prop.ToLower();
if (Prop == "bool") return EPropertyTypeNew::Bool; if (Prop == "bool") return EPropertyType::Bool;
if (Prop == "byte") return EPropertyTypeNew::Byte; if (Prop == "byte") return EPropertyType::Byte;
if (Prop == "short") return EPropertyTypeNew::Short; if (Prop == "short") return EPropertyType::Short;
if (Prop == "long") return EPropertyTypeNew::Int; if (Prop == "long") return EPropertyType::Int;
if (Prop == "enum") return EPropertyTypeNew::Enum; if (Prop == "enum") return EPropertyType::Enum;
if (Prop == "bitfield") return EPropertyTypeNew::Flags; if (Prop == "bitfield") return EPropertyType::Flags;
if (Prop == "float") return EPropertyTypeNew::Float; if (Prop == "float") return EPropertyType::Float;
if (Prop == "string") return EPropertyTypeNew::String; if (Prop == "string") return EPropertyType::String;
if (Prop == "color") return EPropertyTypeNew::Color; if (Prop == "color") return EPropertyType::Color;
if (Prop == "vector3f") return EPropertyTypeNew::Vector; if (Prop == "vector3f") return EPropertyType::Vector;
if (Prop == "sound") return EPropertyTypeNew::Sound; if (Prop == "sound") return EPropertyType::Sound;
if (Prop == "asset") return EPropertyTypeNew::Asset; if (Prop == "asset") return EPropertyType::Asset;
if (Prop == "struct") return EPropertyTypeNew::Struct; if (Prop == "struct") return EPropertyType::Struct;
if (Prop == "array") return EPropertyTypeNew::Array; if (Prop == "array") return EPropertyType::Array;
if (Prop == "character") return EPropertyTypeNew::AnimationSet; if (Prop == "character") return EPropertyType::AnimationSet;
if (Prop == "mayaspline") return EPropertyTypeNew::Spline; if (Prop == "mayaspline") return EPropertyType::Spline;
return EPropertyTypeNew::Invalid; return EPropertyType::Invalid;
} }
IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate* pScript, CStructPropertyNew* pParent, const TString& rkTemplateName) IProperty* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate* pScript, CStructProperty* pParent, const TString& rkTemplateName)
{ {
TString NodeType = TString(pElem->Name()).ToLower(); TString NodeType = TString(pElem->Name()).ToLower();
TString IDAttr = TString(pElem->Attribute("ID")).ToLower(); TString IDAttr = TString(pElem->Attribute("ID")).ToLower();
@ -150,16 +150,16 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
if (!NameAttr.IsEmpty()) if (!NameAttr.IsEmpty())
Name = NameAttr; Name = NameAttr;
else if (mGame >= eEchoesDemo) else if (mGame >= eEchoesDemo)
Name = CMasterTemplate::PropertyName(ID); Name = CGameTemplate::PropertyName(ID);
else else
{ {
Log::Error(rkTemplateName + ": Property " + TString::HexString(ID) + " doesn't have a name either in the template itself nor in the master list"); Log::Error(rkTemplateName + ": Property " + TString::HexString(ID) + " doesn't have a name either in the template itself nor in the game list");
return nullptr; return nullptr;
} }
// Does the property already exist (eg is this an override)? // Does the property already exist (eg is this an override)?
IPropertyNew* pProp = pParent->ChildByID(ID); IProperty* pProp = pParent->ChildByID(ID);
EPropertyTypeNew Type; EPropertyType Type;
bool IsNewProperty = false; bool IsNewProperty = false;
// If it doesn't, then we'll need to create it. // If it doesn't, then we'll need to create it.
@ -170,7 +170,7 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
Type = PropStringToPropEnum(TypeStr); Type = PropStringToPropEnum(TypeStr);
IsNewProperty = true; IsNewProperty = true;
if (Type == EPropertyTypeNew::Invalid) if (Type == EPropertyType::Invalid)
{ {
if (TypeStr.IsEmpty()) if (TypeStr.IsEmpty())
Log::Error(rkTemplateName + ": Property " + TString::HexString(ID) + " doesn't have a type set"); Log::Error(rkTemplateName + ": Property " + TString::HexString(ID) + " doesn't have a type set");
@ -181,27 +181,27 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
} }
// Load archetype if required // Load archetype if required
bool bNeedsArchetype = ( Type == EPropertyTypeNew::Struct || bool bNeedsArchetype = ( Type == EPropertyType::Struct ||
Type == EPropertyTypeNew::Enum || Type == EPropertyType::Enum ||
Type == EPropertyTypeNew::Choice || Type == EPropertyType::Choice ||
Type == EPropertyTypeNew::Flags ); Type == EPropertyType::Flags );
if (bNeedsArchetype) if (bNeedsArchetype)
{ {
IPropertyNew* pArchetype = nullptr; IProperty* pArchetype = nullptr;
//todo: struct archetypes are not supposed to be optional but apparently some still don't have them //todo: struct archetypes are not supposed to be optional but apparently some still don't have them
if (!TemplateAttr.IsEmpty()) if (!TemplateAttr.IsEmpty())
{ {
if (Type == EPropertyTypeNew::Struct) if (Type == EPropertyType::Struct)
{ {
pArchetype = LoadStructArchetype(TemplateAttr); pArchetype = LoadStructArchetype(TemplateAttr);
} }
else if (Type == EPropertyTypeNew::Enum || Type == EPropertyTypeNew::Choice) else if (Type == EPropertyType::Enum || Type == EPropertyType::Choice)
{ {
pArchetype = LoadEnumArchetype(TemplateAttr, Type == EPropertyTypeNew::Choice); pArchetype = LoadEnumArchetype(TemplateAttr, Type == EPropertyType::Choice);
} }
else if (Type == EPropertyTypeNew::Flags) else if (Type == EPropertyType::Flags)
{ {
pArchetype = LoadFlagsArchetype(TemplateAttr); pArchetype = LoadFlagsArchetype(TemplateAttr);
} }
@ -210,14 +210,14 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
// create property as a copy of the archetype // create property as a copy of the archetype
if (pArchetype != nullptr) if (pArchetype != nullptr)
{ {
pProp = IPropertyNew::CreateCopy(pArchetype); pProp = IProperty::CreateCopy(pArchetype);
} }
} }
// no archetype, so do normal create // no archetype, so do normal create
if (!pProp) if (!pProp)
{ {
pProp = IPropertyNew::Create(Type, mGame); pProp = IProperty::Create(Type, mGame);
} }
// we need to have a valid property by this point // we need to have a valid property by this point
@ -251,7 +251,7 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
while (pVersion) while (pVersion)
{ {
TString VerName = pVersion->GetText(); TString VerName = pVersion->GetText();
u32 VerIdx = mpMaster->GameVersion(VerName); u32 VerIdx = mpGameTemplate->GameVersion(VerName);
if (VerIdx == -1) if (VerIdx == -1)
Log::Error(rkTemplateName + ": Property " + TString::HexString(ID) + " has invalid version \"" + VerName + "\""); Log::Error(rkTemplateName + ": Property " + TString::HexString(ID) + " has invalid version \"" + VerName + "\"");
@ -272,11 +272,11 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
TString lValue = ParamVal.ToLower(); TString lValue = ParamVal.ToLower();
if (lValue == "always") if (lValue == "always")
pProp->mCookPreference = ECookPreferenceNew::Always; pProp->mCookPreference = ECookPreference::Always;
else if (lValue == "never") else if (lValue == "never")
pProp->mCookPreference = ECookPreferenceNew::Never; pProp->mCookPreference = ECookPreference::Never;
else else
pProp->mCookPreference = ECookPreferenceNew::Default; pProp->mCookPreference = ECookPreference::Default;
} }
else if (ParamName == "description") else if (ParamName == "description")
{ {
@ -304,7 +304,7 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
} }
// Asset-specific parameters // Asset-specific parameters
if (Type == EPropertyTypeNew::Asset) if (Type == EPropertyType::Asset)
{ {
TString ExtensionsAttr = pElem->Attribute("extensions"); TString ExtensionsAttr = pElem->Attribute("extensions");
@ -317,7 +317,7 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
} }
// Enum-specific parameters // Enum-specific parameters
else if (Type == EPropertyTypeNew::Enum || Type == EPropertyTypeNew::Choice) else if (Type == EPropertyType::Enum || Type == EPropertyType::Choice)
{ {
// use static_cast so we can do both enum and choice with this code // use static_cast so we can do both enum and choice with this code
CEnumProperty* pEnum = static_cast<CEnumProperty*>(pProp); CEnumProperty* pEnum = static_cast<CEnumProperty*>(pProp);
@ -330,7 +330,7 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
} }
// Bitfield-specific parameters // Bitfield-specific parameters
else if (Type == EPropertyTypeNew::Flags) else if (Type == EPropertyType::Flags)
{ {
CFlagsProperty* pFlags = TPropCast<CFlagsProperty>(pProp); CFlagsProperty* pFlags = TPropCast<CFlagsProperty>(pProp);
@ -342,13 +342,13 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
} }
// Struct-specific parameters // Struct-specific parameters
else if ( (Type == EPropertyTypeNew::Struct) || (Type == EPropertyTypeNew::Array) ) else if ( (Type == EPropertyType::Struct) || (Type == EPropertyType::Array) )
{ {
CStructPropertyNew* pStruct = nullptr; CStructProperty* pStruct = nullptr;
if (Type == EPropertyTypeNew::Struct) if (Type == EPropertyType::Struct)
{ {
pStruct = TPropCast<CStructPropertyNew>(pProp); pStruct = TPropCast<CStructProperty>(pProp);
} }
else else
{ {
@ -356,14 +356,14 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
if (pArray->mpItemArchetype != nullptr) if (pArray->mpItemArchetype != nullptr)
{ {
ASSERT(pArray->mpItemArchetype->Type() == EPropertyTypeNew::Struct); ASSERT(pArray->mpItemArchetype->Type() == EPropertyType::Struct);
pStruct = TPropCast<CStructPropertyNew>(pArray->mpItemArchetype); pStruct = TPropCast<CStructProperty>(pArray->mpItemArchetype);
} }
else else
{ {
if (Name == "Activation Times") if (Name == "Activation Times")
{ {
CFloatProperty* pFloatItem = (CFloatProperty*) IPropertyNew::Create(EPropertyTypeNew::Float, mGame); CFloatProperty* pFloatItem = (CFloatProperty*) IProperty::Create(EPropertyType::Float, mGame);
pFloatItem->mName = "Time"; pFloatItem->mName = "Time";
pFloatItem->mID = 0; pFloatItem->mID = 0;
pFloatItem->mDefaultValue = 0.0f; pFloatItem->mDefaultValue = 0.0f;
@ -372,8 +372,8 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
} }
else else
{ {
pArray->mpItemArchetype = IPropertyNew::Create(EPropertyTypeNew::Struct, mGame); pArray->mpItemArchetype = IProperty::Create(EPropertyType::Struct, mGame);
pStruct = TPropCast<CStructPropertyNew>(pArray->mpItemArchetype); pStruct = TPropCast<CStructProperty>(pArray->mpItemArchetype);
pStruct->mFlags = EPropertyFlag::IsAtomic | EPropertyFlag::IsArrayArchetype; pStruct->mFlags = EPropertyFlag::IsAtomic | EPropertyFlag::IsArrayArchetype;
} }
} }
@ -395,7 +395,7 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
if (IsNewProperty) if (IsNewProperty)
{ {
CMasterTemplate::AddProperty(pProp, mMasterDir + rkTemplateName); CGameTemplate::AddProperty(pProp, mGameDir + rkTemplateName);
if (pParent) if (pParent)
pParent->mChildren.push_back(pProp); pParent->mChildren.push_back(pProp);
@ -404,28 +404,28 @@ IPropertyNew* CTemplateLoader::LoadProperty(XMLElement* pElem, CScriptTemplate*
return pProp; return pProp;
} }
CStructPropertyNew* CTemplateLoader::LoadStructArchetype(const TString& rkTemplateFileName) CStructProperty* CTemplateLoader::LoadStructArchetype(const TString& rkTemplateFileName)
{ {
// Check whether this struct has already been read // Check whether this struct has already been read
TString StructName = rkTemplateFileName.GetFileName(false); TString StructName = rkTemplateFileName.GetFileName(false);
CStructPropertyNew* pArchetype = static_cast<CStructPropertyNew*>( mpMaster->FindPropertyArchetype(StructName) ); CStructProperty* pArchetype = static_cast<CStructProperty*>( mpGameTemplate->FindPropertyArchetype(StructName) );
// Names cannot be shared between multiple property archetypes // Names cannot be shared between multiple property archetypes
if (pArchetype != nullptr) if (pArchetype != nullptr)
{ {
ASSERT(pArchetype->Type() == EPropertyTypeNew::Struct); ASSERT(pArchetype->Type() == EPropertyType::Struct);
} }
// If the struct template hasn't been read yet, then we read it and add it to master's list // If the struct template hasn't been read yet, then we read it and add it to game's list
if (!pArchetype) if (!pArchetype)
{ {
XMLDocument Doc; XMLDocument Doc;
OpenXML(mskTemplatesDir + mMasterDir + rkTemplateFileName, Doc); OpenXML(mskTemplatesDir + mGameDir + rkTemplateFileName, Doc);
if (!Doc.Error()) if (!Doc.Error())
{ {
pArchetype = TPropCast<CStructPropertyNew>( pArchetype = TPropCast<CStructProperty>(
IPropertyNew::Create(EPropertyTypeNew::Struct, mGame) IProperty::Create(EPropertyType::Struct, mGame)
); );
ASSERT(pArchetype != nullptr); ASSERT(pArchetype != nullptr);
@ -468,10 +468,10 @@ CStructPropertyNew* CTemplateLoader::LoadStructArchetype(const TString& rkTempla
LoadProperties(pSubPropsElem, nullptr, pArchetype, rkTemplateFileName); LoadProperties(pSubPropsElem, nullptr, pArchetype, rkTemplateFileName);
pArchetype->Initialize(nullptr, nullptr, 0); pArchetype->Initialize(nullptr, nullptr, 0);
mpMaster->mPropertyTemplates.emplace( mpGameTemplate->mPropertyTemplates.emplace(
std::make_pair( std::make_pair(
StructName, StructName,
CMasterTemplate::SPropertyTemplatePath(rkTemplateFileName, pArchetype) CGameTemplate::SPropertyTemplatePath(rkTemplateFileName, pArchetype)
)); ));
} }
} }
@ -484,25 +484,25 @@ CEnumProperty* CTemplateLoader::LoadEnumArchetype(const TString& rkTemplateFileN
{ {
// Check whether this struct has already been read // Check whether this struct has already been read
TString EnumName = rkTemplateFileName.GetFileName(false); TString EnumName = rkTemplateFileName.GetFileName(false);
CEnumProperty* pArchetype = static_cast<CEnumProperty*>( mpMaster->FindPropertyArchetype(EnumName) ); CEnumProperty* pArchetype = static_cast<CEnumProperty*>( mpGameTemplate->FindPropertyArchetype(EnumName) );
// Names cannot be shared between multiple property archetypes // Names cannot be shared between multiple property archetypes
if (pArchetype != nullptr) if (pArchetype != nullptr)
{ {
ASSERT(pArchetype->Type() == EPropertyTypeNew::Enum || pArchetype->Type() == EPropertyTypeNew::Choice); ASSERT(pArchetype->Type() == EPropertyType::Enum || pArchetype->Type() == EPropertyType::Choice);
} }
// If the enum template hasn't been read yet, then we read it and add it to master's list // If the enum template hasn't been read yet, then we read it and add it to game's list
if (!pArchetype) if (!pArchetype)
{ {
XMLDocument Doc; XMLDocument Doc;
OpenXML(mskTemplatesDir + mMasterDir + rkTemplateFileName, Doc); OpenXML(mskTemplatesDir + mGameDir + rkTemplateFileName, Doc);
if (!Doc.Error()) if (!Doc.Error())
{ {
// use static_cast so this code works for both enum and choice // use static_cast so this code works for both enum and choice
pArchetype = static_cast<CEnumProperty*>( pArchetype = static_cast<CEnumProperty*>(
IPropertyNew::Create(bIsChoice ? EPropertyTypeNew::Choice : EPropertyTypeNew::Enum, mGame) IProperty::Create(bIsChoice ? EPropertyType::Choice : EPropertyType::Enum, mGame)
); );
ASSERT(pArchetype != nullptr); ASSERT(pArchetype != nullptr);
@ -519,10 +519,10 @@ CEnumProperty* CTemplateLoader::LoadEnumArchetype(const TString& rkTemplateFileN
LoadEnumerators(pEnumers, pArchetype, rkTemplateFileName); LoadEnumerators(pEnumers, pArchetype, rkTemplateFileName);
pArchetype->Initialize(nullptr, nullptr, 0); pArchetype->Initialize(nullptr, nullptr, 0);
mpMaster->mPropertyTemplates.emplace( mpGameTemplate->mPropertyTemplates.emplace(
std::make_pair( std::make_pair(
EnumName, EnumName,
CMasterTemplate::SPropertyTemplatePath(rkTemplateFileName, pArchetype) CGameTemplate::SPropertyTemplatePath(rkTemplateFileName, pArchetype)
)); ));
} }
} }
@ -535,24 +535,24 @@ CFlagsProperty* CTemplateLoader::LoadFlagsArchetype(const TString& rkTemplateFil
{ {
// Check whether this struct has already been read // Check whether this struct has already been read
TString FlagsName = rkTemplateFileName.GetFileName(false); TString FlagsName = rkTemplateFileName.GetFileName(false);
CFlagsProperty* pArchetype = static_cast<CFlagsProperty*>( mpMaster->FindPropertyArchetype(FlagsName) ); CFlagsProperty* pArchetype = static_cast<CFlagsProperty*>( mpGameTemplate->FindPropertyArchetype(FlagsName) );
// Names cannot be shared between multiple property archetypes // Names cannot be shared between multiple property archetypes
if (pArchetype != nullptr) if (pArchetype != nullptr)
{ {
ASSERT(pArchetype->Type() == EPropertyTypeNew::Flags); ASSERT(pArchetype->Type() == EPropertyType::Flags);
} }
// If the enum template hasn't been read yet, then we read it and add it to master's list // If the enum template hasn't been read yet, then we read it and add it to game's list
if (!pArchetype) if (!pArchetype)
{ {
XMLDocument Doc; XMLDocument Doc;
OpenXML(mskTemplatesDir + mMasterDir + rkTemplateFileName, Doc); OpenXML(mskTemplatesDir + mGameDir + rkTemplateFileName, Doc);
if (!Doc.Error()) if (!Doc.Error())
{ {
pArchetype = TPropCast<CFlagsProperty>( pArchetype = TPropCast<CFlagsProperty>(
IPropertyNew::Create(EPropertyTypeNew::Flags, mGame) IProperty::Create(EPropertyType::Flags, mGame)
); );
ASSERT(pArchetype != nullptr); ASSERT(pArchetype != nullptr);
@ -569,10 +569,10 @@ CFlagsProperty* CTemplateLoader::LoadFlagsArchetype(const TString& rkTemplateFil
LoadBitFlags(pFlags, pArchetype, rkTemplateFileName); LoadBitFlags(pFlags, pArchetype, rkTemplateFileName);
pArchetype->Initialize(nullptr, nullptr, 0); pArchetype->Initialize(nullptr, nullptr, 0);
mpMaster->mPropertyTemplates.emplace( mpGameTemplate->mPropertyTemplates.emplace(
std::make_pair( std::make_pair(
FlagsName, FlagsName,
CMasterTemplate::SPropertyTemplatePath(rkTemplateFileName, pArchetype) CGameTemplate::SPropertyTemplatePath(rkTemplateFileName, pArchetype)
)); ));
} }
@ -582,7 +582,7 @@ CFlagsProperty* CTemplateLoader::LoadFlagsArchetype(const TString& rkTemplateFil
return pArchetype; return pArchetype;
} }
void CTemplateLoader::LoadProperties(XMLElement *pPropertiesElem, CScriptTemplate *pScript, CStructPropertyNew* pStruct, const TString& rkTemplateName) void CTemplateLoader::LoadProperties(XMLElement *pPropertiesElem, CScriptTemplate *pScript, CStructProperty* pStruct, const TString& rkTemplateName)
{ {
XMLElement *pChild = pPropertiesElem->FirstChildElement(); XMLElement *pChild = pPropertiesElem->FirstChildElement();
@ -661,12 +661,12 @@ void CTemplateLoader::LoadBitFlags(XMLElement *pFlagsElem, CFlagsProperty* pFlag
// ************ SCRIPT OBJECT ************ // ************ SCRIPT OBJECT ************
CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TString& rkTemplateName, u32 ObjectID) CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TString& rkTemplateName, u32 ObjectID)
{ {
CScriptTemplate *pScript = new CScriptTemplate(mpMaster); CScriptTemplate *pScript = new CScriptTemplate(mpGameTemplate);
pScript->mObjectID = ObjectID; pScript->mObjectID = ObjectID;
pScript->mSourceFile = rkTemplateName; pScript->mSourceFile = rkTemplateName;
IPropertyNew* pBaseStruct = IPropertyNew::Create(EPropertyTypeNew::Struct, mGame); IProperty* pBaseStruct = IProperty::Create(EPropertyType::Struct, mGame);
pScript->mpProperties = std::make_unique<CStructPropertyNew>( *TPropCast<CStructPropertyNew>(pBaseStruct) ); pScript->mpProperties = std::make_unique<CStructProperty>( *TPropCast<CStructProperty>(pBaseStruct) );
XMLElement *pRoot = pDoc->FirstChildElement("ScriptTemplate"); XMLElement *pRoot = pDoc->FirstChildElement("ScriptTemplate");
@ -845,11 +845,11 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TS
Attachment.AttachType = eAttach; Attachment.AttachType = eAttach;
// Validate property // Validate property
IPropertyNew* pProp = pScript->mpProperties->ChildByIDString(Attachment.AttachProperty); IProperty* pProp = pScript->mpProperties->ChildByIDString(Attachment.AttachProperty);
if (!pProp) if (!pProp)
Log::Error(rkTemplateName + ": Invalid property for attachment " + TString::FromInt32(AttachIdx) + ": " + Attachment.AttachProperty); Log::Error(rkTemplateName + ": Invalid property for attachment " + TString::FromInt32(AttachIdx) + ": " + Attachment.AttachProperty);
else if (pProp->Type() != EPropertyTypeNew::AnimationSet && (pProp->Type() != EPropertyTypeNew::Asset || !TPropCast<CAssetProperty>(pProp)->GetTypeFilter().Accepts(eModel))) else if (pProp->Type() != EPropertyType::AnimationSet && (pProp->Type() != EPropertyType::Asset || !TPropCast<CAssetProperty>(pProp)->GetTypeFilter().Accepts(eModel)))
Log::Error(rkTemplateName + ": Property referred to by attachment " + TString::FromInt32(AttachIdx) + " is not an attachable asset! Must be a file property that accepts CMDLs, or an animation set property."); Log::Error(rkTemplateName + ": Property referred to by attachment " + TString::FromInt32(AttachIdx) + " is not an attachable asset! Must be a file property that accepts CMDLs, or an animation set property.");
else else
@ -986,11 +986,11 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TS
return pScript; return pScript;
} }
// ************ MASTER ************ // ************ GAME ************
void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMaster) void CTemplateLoader::LoadGameTemplate(XMLDocument *pDoc, CGameTemplate *pGame)
{ {
mpMaster = pMaster; mpGameTemplate = pGame;
mMasterDir = pMaster->mSourceFile.GetFileDirectory(); mGameDir = pGame->mSourceFile.GetFileDirectory();
XMLElement *pRoot = pDoc->FirstChildElement("MasterTemplate"); XMLElement *pRoot = pDoc->FirstChildElement("MasterTemplate");
XMLElement *pElem = pRoot->FirstChildElement(); XMLElement *pElem = pRoot->FirstChildElement();
@ -1019,7 +1019,7 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
TString TemplateName = pObj->Attribute("template"); TString TemplateName = pObj->Attribute("template");
XMLDocument ScriptXML; XMLDocument ScriptXML;
OpenXML(mskTemplatesDir + mMasterDir + TemplateName, ScriptXML); OpenXML(mskTemplatesDir + mGameDir + TemplateName, ScriptXML);
if (!ScriptXML.Error()) if (!ScriptXML.Error())
{ {
@ -1027,10 +1027,10 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
if (pTemp) if (pTemp)
{ {
mpMaster->mScriptTemplates.emplace( mpGameTemplate->mScriptTemplates.emplace(
std::make_pair( std::make_pair(
ID, ID,
CMasterTemplate::SScriptTemplatePath(ID, TemplateName, pTemp) CGameTemplate::SScriptTemplatePath(ID, TemplateName, pTemp)
)); ));
} }
} }
@ -1055,7 +1055,7 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
StateID = CFourCC(StrID).ToLong(); StateID = CFourCC(StrID).ToLong();
TString StateName = pState->Attribute("name"); TString StateName = pState->Attribute("name");
mpMaster->mStates[StateID] = StateName; mpGameTemplate->mStates[StateID] = StateName;
pState = pState->NextSiblingElement("state"); pState = pState->NextSiblingElement("state");
} }
} }
@ -1076,7 +1076,7 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
MessageID = CFourCC(StrID).ToLong(); MessageID = CFourCC(StrID).ToLong();
TString MessageName = pMessage->Attribute("name"); TString MessageName = pMessage->Attribute("name");
mpMaster->mMessages[MessageID] = MessageName; mpGameTemplate->mMessages[MessageID] = MessageName;
pMessage = pMessage->NextSiblingElement("message"); pMessage = pMessage->NextSiblingElement("message");
} }
} }
@ -1084,12 +1084,12 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
pElem = pElem->NextSiblingElement(); pElem = pElem->NextSiblingElement();
} }
pMaster->mFullyLoaded = true; pGame->mFullyLoaded = true;
} }
CMasterTemplate* CTemplateLoader::LoadGameInfo(XMLNode *pNode) CGameTemplate* CTemplateLoader::LoadGameInfo(XMLNode *pNode)
{ {
CMasterTemplate *pMaster = new CMasterTemplate(); CGameTemplate *pGame = new CGameTemplate();
XMLElement *pGameElem = pNode->FirstChildElement(); XMLElement *pGameElem = pNode->FirstChildElement();
// Parse game parameters // Parse game parameters
@ -1098,24 +1098,24 @@ CMasterTemplate* CTemplateLoader::LoadGameInfo(XMLNode *pNode)
TString NodeName = TString(pGameElem->Name()).ToLower(); TString NodeName = TString(pGameElem->Name()).ToLower();
if (NodeName == "name") if (NodeName == "name")
pMaster->mGameName = pGameElem->GetText(); pGame->mGameName = pGameElem->GetText();
else if (NodeName == "mrea") else if (NodeName == "mrea")
{ {
u32 VersionNum = std::stoul(pGameElem->GetText(), 0, 16); u32 VersionNum = std::stoul(pGameElem->GetText(), 0, 16);
pMaster->mGame = CAreaLoader::GetFormatVersion(VersionNum); pGame->mGame = CAreaLoader::GetFormatVersion(VersionNum);
} }
else if (NodeName == "master") else if (NodeName == "master")
{ {
TString MasterPath = pGameElem->GetText(); TString MasterPath = pGameElem->GetText();
pMaster->mSourceFile = MasterPath; pGame->mSourceFile = MasterPath;
} }
pGameElem = pGameElem->NextSiblingElement(); pGameElem = pGameElem->NextSiblingElement();
} }
return pMaster; return pGame;
} }
// ************ UTILITY ************ // ************ UTILITY ************
@ -1182,17 +1182,17 @@ void CTemplateLoader::LoadGameList()
if (Reader.ParamBegin("Game", 0)) if (Reader.ParamBegin("Game", 0))
{ {
EGame Game; EGame Game;
TString Name, MasterPath; TString Name, GamePath;
Reader << SerialParameter("ID", Game, SH_Attribute) Reader << SerialParameter("ID", Game, SH_Attribute)
<< SerialParameter("Name", Name) << SerialParameter("Name", Name)
<< SerialParameter("MasterTemplate", MasterPath); << SerialParameter("GameTemplate", GamePath);
CMasterTemplate* pMaster = new CMasterTemplate(); CGameTemplate* pGame = new CGameTemplate();
pMaster->mGame = Game; pGame->mGame = Game;
pMaster->mGameName = Name; pGame->mGameName = Name;
pMaster->mSourceFile = MasterPath; pGame->mSourceFile = GamePath;
CMasterTemplate::smMasterMap[Game] = pMaster; CGameTemplate::smGameMap[Game] = pGame;
Reader.ParamEnd(); Reader.ParamEnd();
} }
} }
@ -1204,21 +1204,21 @@ void CTemplateLoader::LoadGameList()
const TString kPropertyMapPath = kTemplatesDir + "PropertyMap.xml"; const TString kPropertyMapPath = kTemplatesDir + "PropertyMap.xml";
CXMLReader Reader(kPropertyMapPath); CXMLReader Reader(kPropertyMapPath);
ASSERT(Reader.IsValid()); ASSERT(Reader.IsValid());
Reader << SerialParameter("PropertyMap", CMasterTemplate::smPropertyNames, SH_HexDisplay); Reader << SerialParameter("PropertyMap", CGameTemplate::smPropertyNames, SH_HexDisplay);
} }
{ {
// Read master templates // Read game templates
std::list<CMasterTemplate*> MasterList = CMasterTemplate::MasterList(); std::list<CGameTemplate*> GameList = CGameTemplate::GameTemplateList();
for (auto Iter = MasterList.begin(); Iter != MasterList.end(); Iter++) for (auto Iter = GameList.begin(); Iter != GameList.end(); Iter++)
{ {
CMasterTemplate* pMaster = *Iter; CGameTemplate* pGame = *Iter;
const TString kMasterPath = pMaster->GetGameDirectory(true) + "Game.xml"; const TString kGamePath = pGame->GetGameDirectory(true) + "Game.xml";
CXMLReader Reader(kMasterPath); CXMLReader Reader(kGamePath);
ASSERT(Reader.IsValid()); ASSERT(Reader.IsValid());
pMaster->Serialize(Reader); pGame->Serialize(Reader);
pMaster->LoadSubTemplates(); pGame->LoadSubTemplates();
} }
} }
#else #else
@ -1236,7 +1236,7 @@ void CTemplateLoader::LoadGameList()
const char *pkGameListVersion = pRoot->Attribute("version"); const char *pkGameListVersion = pRoot->Attribute("version");
if (pkGameListVersion) if (pkGameListVersion)
CMasterTemplate::smGameListVersion = TString(pkGameListVersion).ToInt32(10); CGameTemplate::smGameListVersion = TString(pkGameListVersion).ToInt32(10);
XMLElement *pElem = pRoot->FirstChildElement(); XMLElement *pElem = pRoot->FirstChildElement();
@ -1259,8 +1259,8 @@ void CTemplateLoader::LoadGameList()
else if (NodeName == "game") else if (NodeName == "game")
{ {
CTemplateLoader Loader(mskTemplatesDir); CTemplateLoader Loader(mskTemplatesDir);
CMasterTemplate *pMaster = Loader.LoadGameInfo(pElem); CGameTemplate *pGame = Loader.LoadGameInfo(pElem);
CMasterTemplate::smMasterMap[pMaster->mGame] = pMaster; CGameTemplate::smGameMap[pGame->mGame] = pGame;
} }
pElem = pElem->NextSiblingElement(); pElem = pElem->NextSiblingElement();
@ -1270,22 +1270,22 @@ void CTemplateLoader::LoadGameList()
void CTemplateLoader::LoadGameTemplates(EGame Game) void CTemplateLoader::LoadGameTemplates(EGame Game)
{ {
std::list<CMasterTemplate*> MasterList = CMasterTemplate::MasterList(); std::list<CGameTemplate*> GameList = CGameTemplate::GameTemplateList();
for (auto it = MasterList.begin(); it != MasterList.end(); it++) for (auto it = GameList.begin(); it != GameList.end(); it++)
{ {
CMasterTemplate *pMaster = *it; CGameTemplate *pGame = *it;
if (pMaster->Game() == Game && !pMaster->IsLoadedSuccessfully()) if (pGame->Game() == Game && !pGame->IsLoadedSuccessfully())
{ {
XMLDocument MasterXML; XMLDocument GameXML;
OpenXML(mskTemplatesDir + pMaster->mSourceFile, MasterXML); OpenXML(mskTemplatesDir + pGame->mSourceFile, GameXML);
if (!MasterXML.Error()) if (!GameXML.Error())
{ {
CTemplateLoader Loader(mskTemplatesDir); CTemplateLoader Loader(mskTemplatesDir);
Loader.mGame = Game; Loader.mGame = Game;
Loader.LoadMasterTemplate(&MasterXML, pMaster); Loader.LoadGameTemplate(&GameXML, pGame);
} }
break; break;
@ -1295,22 +1295,22 @@ void CTemplateLoader::LoadGameTemplates(EGame Game)
void CTemplateLoader::LoadAllGames() void CTemplateLoader::LoadAllGames()
{ {
std::list<CMasterTemplate*> MasterList = CMasterTemplate::MasterList(); std::list<CGameTemplate*> GameList = CGameTemplate::GameTemplateList();
for (auto it = MasterList.begin(); it != MasterList.end(); it++) for (auto it = GameList.begin(); it != GameList.end(); it++)
{ {
CMasterTemplate *pMaster = *it; CGameTemplate *pGame = *it;
if (!pMaster->IsLoadedSuccessfully()) if (!pGame->IsLoadedSuccessfully())
{ {
XMLDocument MasterXML; XMLDocument GameXML;
OpenXML(mskTemplatesDir + pMaster->mSourceFile, MasterXML); OpenXML(mskTemplatesDir + pGame->mSourceFile, GameXML);
if (!MasterXML.Error()) if (!GameXML.Error())
{ {
CTemplateLoader Loader(mskTemplatesDir); CTemplateLoader Loader(mskTemplatesDir);
Loader.mGame = pMaster->Game(); Loader.mGame = pGame->Game();
Loader.LoadMasterTemplate(&MasterXML, pMaster); Loader.LoadGameTemplate(&GameXML, pGame);
} }
} }
} }
@ -1333,7 +1333,7 @@ void CTemplateLoader::LoadPropertyList(XMLDocument *pDoc, const TString& ListNam
TString Name = pElem->Attribute("name"); TString Name = pElem->Attribute("name");
if (!ID.IsEmpty() && !Name.IsEmpty()) if (!ID.IsEmpty() && !Name.IsEmpty())
CMasterTemplate::smPropertyNames[ID.ToInt32()] = Name; CGameTemplate::smPropertyNames[ID.ToInt32()] = Name;
pElem = pElem->NextSiblingElement(); pElem = pElem->NextSiblingElement();
} }
@ -1350,31 +1350,31 @@ void CTemplateLoader::SaveGameList()
const TString kGameListPath = kTemplatesDir + "GameList.xml"; const TString kGameListPath = kTemplatesDir + "GameList.xml";
CXMLWriter Writer(kGameListPath, "GameList"); CXMLWriter Writer(kGameListPath, "GameList");
u32 NumGames = CMasterTemplate::smMasterMap.size(); u32 NumGames = CGameTemplate::smGameMap.size();
Writer.ParamBegin("Games", 0); Writer.ParamBegin("Games", 0);
Writer.SerializeArraySize(NumGames); Writer.SerializeArraySize(NumGames);
for (auto Iter = CMasterTemplate::smMasterMap.begin(); Iter != CMasterTemplate::smMasterMap.end(); Iter++) for (auto Iter = CGameTemplate::smGameMap.begin(); Iter != CGameTemplate::smGameMap.end(); Iter++)
{ {
struct SGameInfo struct SGameInfo
{ {
EGame Game; EGame Game;
TString Name; TString Name;
TString MasterPath; TString GamePath;
void Serialize(IArchive& Arc) void Serialize(IArchive& Arc)
{ {
Arc << SerialParameter("ID", Game, SH_Attribute) Arc << SerialParameter("ID", Game, SH_Attribute)
<< SerialParameter("Name", Name) << SerialParameter("Name", Name)
<< SerialParameter("MasterTemplate", MasterPath); << SerialParameter("GameTemplate", GamePath);
} }
}; };
CMasterTemplate* pMaster = Iter->second; CGameTemplate* pGame = Iter->second;
SGameInfo Info; SGameInfo Info;
Info.Game = pMaster->Game(); Info.Game = pGame->Game();
Info.Name = pMaster->GameName(); Info.Name = pGame->GameName();
Info.MasterPath = pMaster->GetGameDirectory() + "Game.xml"; Info.GamePath = pGame->GetGameDirectory() + "Game.xml";
Writer << SerialParameter("Game", Info); Writer << SerialParameter("Game", Info);
} }
Writer.ParamEnd(); Writer.ParamEnd();
@ -1383,22 +1383,22 @@ void CTemplateLoader::SaveGameList()
// Write property list // Write property list
{ {
CXMLWriter Writer(kTemplatesDir + "PropertyMap.xml", "PropertyMap"); CXMLWriter Writer(kTemplatesDir + "PropertyMap.xml", "PropertyMap");
Writer << SerialParameter("PropertyMap", CMasterTemplate::smPropertyNames, SH_HexDisplay); Writer << SerialParameter("PropertyMap", CGameTemplate::smPropertyNames, SH_HexDisplay);
} }
// Write master templates // Write game templates
{ {
std::list<CMasterTemplate*> MasterList = CMasterTemplate::MasterList(); std::list<CGameTemplate*> GameList = CGameTemplate::GameTemplateList();
for (auto Iter = MasterList.begin(); Iter != MasterList.end(); Iter++) for (auto Iter = GameList.begin(); Iter != GameList.end(); Iter++)
{ {
CMasterTemplate* pMasterTemplate = *Iter; CGameTemplate* pGameTemplate = *Iter;
TString MasterFilePath = pMasterTemplate->GetGameDirectory(true) + "Game.xml"; TString GameFilePath = pGameTemplate->GetGameDirectory(true) + "Game.xml";
FileUtil::MakeDirectory( MasterFilePath.GetFileDirectory() ); FileUtil::MakeDirectory( GameFilePath.GetFileDirectory() );
CXMLWriter Writer(MasterFilePath, "Game", 0, pMasterTemplate->Game()); CXMLWriter Writer(GameFilePath, "Game", 0, pGameTemplate->Game());
pMasterTemplate->Serialize(Writer); pGameTemplate->Serialize(Writer);
pMasterTemplate->SaveSubTemplates(); pGameTemplate->SaveSubTemplates();
} }
} }
} }

View File

@ -1,7 +1,7 @@
#ifndef CTEMPLATELOADER_H #ifndef CTEMPLATELOADER_H
#define CTEMPLATELOADER_H #define CTEMPLATELOADER_H
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include "Core/Resource/Script/CScriptTemplate.h" #include "Core/Resource/Script/CScriptTemplate.h"
#include "Core/Resource/Script/Property/IProperty.h" #include "Core/Resource/Script/Property/IProperty.h"
#include "Core/Resource/Script/Property/CEnumProperty.h" #include "Core/Resource/Script/Property/CEnumProperty.h"
@ -13,33 +13,33 @@ class CTemplateLoader
static const TString mskTemplatesDir; static const TString mskTemplatesDir;
static const TString mskGameListPath; static const TString mskGameListPath;
CMasterTemplate *mpMaster; CGameTemplate *mpGameTemplate;
EGame mGame; EGame mGame;
TString mTemplatesDir; TString mTemplatesDir;
TString mMasterDir; TString mGameDir;
// Constructor // Constructor
CTemplateLoader(const TString& rkTemplatesDir) CTemplateLoader(const TString& rkTemplatesDir)
: mTemplatesDir(rkTemplatesDir) {} : mTemplatesDir(rkTemplatesDir) {}
// Load Property // Load Property
IPropertyNew* LoadProperty(tinyxml2::XMLElement* pElem, CScriptTemplate* pScript, CStructPropertyNew* pParentStruct, const TString& rkTemplateName); IProperty* LoadProperty(tinyxml2::XMLElement* pElem, CScriptTemplate* pScript, CStructProperty* pParentStruct, const TString& rkTemplateName);
IPropertyNew* CreateProperty(u32 ID, EPropertyTypeNew Type, const TString& rkName, CScriptTemplate* pScript, CStructPropertyNew* pStruct); IProperty* CreateProperty(u32 ID, EPropertyType Type, const TString& rkName, CScriptTemplate* pScript, CStructProperty* pStruct);
CStructPropertyNew* LoadStructArchetype(const TString& rkTemplateFileName); CStructProperty* LoadStructArchetype(const TString& rkTemplateFileName);
CEnumProperty* LoadEnumArchetype(const TString& rkTemplateFileName, bool bIsChoice); CEnumProperty* LoadEnumArchetype(const TString& rkTemplateFileName, bool bIsChoice);
CFlagsProperty* LoadFlagsArchetype(const TString& rkTemplateFileName); CFlagsProperty* LoadFlagsArchetype(const TString& rkTemplateFileName);
void LoadProperties(tinyxml2::XMLElement* pPropertiesElem, CScriptTemplate* pScript, CStructPropertyNew* pStruct, const TString& rkTemplateName); void LoadProperties(tinyxml2::XMLElement* pPropertiesElem, CScriptTemplate* pScript, CStructProperty* pStruct, const TString& rkTemplateName);
void LoadEnumerators(tinyxml2::XMLElement* pEnumeratorsElem, CEnumProperty* pEnum, const TString& rkTemplateName); void LoadEnumerators(tinyxml2::XMLElement* pEnumeratorsElem, CEnumProperty* pEnum, const TString& rkTemplateName);
void LoadBitFlags(tinyxml2::XMLElement* pFlagsElem, CFlagsProperty* pFlags, const TString& rkTemplateName); void LoadBitFlags(tinyxml2::XMLElement* pFlagsElem, CFlagsProperty* pFlags, const TString& rkTemplateName);
// Load Script Object // Load Script Object
CScriptTemplate* LoadScriptTemplate(tinyxml2::XMLDocument* pDoc, const TString& rkTemplateName, u32 ObjectID); CScriptTemplate* LoadScriptTemplate(tinyxml2::XMLDocument* pDoc, const TString& rkTemplateName, u32 ObjectID);
// Load Master // Load Game
CMasterTemplate* LoadGameInfo(tinyxml2::XMLNode* pNode); CGameTemplate* LoadGameInfo(tinyxml2::XMLNode* pNode);
void LoadMasterTemplate(tinyxml2::XMLDocument* pDoc, CMasterTemplate* pMaster); void LoadGameTemplate(tinyxml2::XMLDocument* pDoc, CGameTemplate* pGame);
// Utility // Utility
static void OpenXML(const TString& rkPath, tinyxml2::XMLDocument& rDoc); static void OpenXML(const TString& rkPath, tinyxml2::XMLDocument& rDoc);

View File

@ -1,13 +1,13 @@
#include "CMasterTemplate.h" #include "CGameTemplate.h"
#include "Core/Resource/Factory/CWorldLoader.h" #include "Core/Resource/Factory/CWorldLoader.h"
#include <Common/Log.h> #include <Common/Log.h>
CMasterTemplate::CMasterTemplate() CGameTemplate::CGameTemplate()
: mFullyLoaded(false) : mFullyLoaded(false)
{ {
} }
void CMasterTemplate::Serialize(IArchive& Arc) void CGameTemplate::Serialize(IArchive& Arc)
{ {
Arc << SerialParameter("ScriptObjects", mScriptTemplates) Arc << SerialParameter("ScriptObjects", mScriptTemplates)
<< SerialParameter("PropertyArchetypes", mPropertyTemplates) << SerialParameter("PropertyArchetypes", mPropertyTemplates)
@ -15,7 +15,7 @@ void CMasterTemplate::Serialize(IArchive& Arc)
<< SerialParameter("Messages", mMessages); << SerialParameter("Messages", mMessages);
} }
void CMasterTemplate::LoadSubTemplates() void CGameTemplate::LoadSubTemplates()
{ {
for (auto Iter = mScriptTemplates.begin(); Iter != mScriptTemplates.end(); Iter++) for (auto Iter = mScriptTemplates.begin(); Iter != mScriptTemplates.end(); Iter++)
Internal_LoadScriptTemplate( Iter->second ); Internal_LoadScriptTemplate( Iter->second );
@ -24,7 +24,7 @@ void CMasterTemplate::LoadSubTemplates()
Internal_LoadPropertyTemplate( Iter->second ); Internal_LoadPropertyTemplate( Iter->second );
} }
void CMasterTemplate::Internal_LoadScriptTemplate(SScriptTemplatePath& Path) void CGameTemplate::Internal_LoadScriptTemplate(SScriptTemplatePath& Path)
{ {
ASSERT(Path.pTemplate == nullptr); // make sure it hasn't been loaded yet ASSERT(Path.pTemplate == nullptr); // make sure it hasn't been loaded yet
@ -38,7 +38,7 @@ void CMasterTemplate::Internal_LoadScriptTemplate(SScriptTemplatePath& Path)
Path.pTemplate->PostLoad(); Path.pTemplate->PostLoad();
} }
void CMasterTemplate::Internal_LoadPropertyTemplate(SPropertyTemplatePath& Path) void CGameTemplate::Internal_LoadPropertyTemplate(SPropertyTemplatePath& Path)
{ {
if (Path.pTemplate != nullptr) // don't load twice if (Path.pTemplate != nullptr) // don't load twice
return; return;
@ -55,7 +55,7 @@ void CMasterTemplate::Internal_LoadPropertyTemplate(SPropertyTemplatePath& Path)
Path.pTemplate->Initialize(nullptr, nullptr, 0); Path.pTemplate->Initialize(nullptr, nullptr, 0);
} }
void CMasterTemplate::SaveSubTemplates() void CGameTemplate::SaveSubTemplates()
{ {
const TString kGameDir = GetGameDirectory(true); const TString kGameDir = GetGameDirectory(true);
@ -80,12 +80,21 @@ void CMasterTemplate::SaveSubTemplates()
} }
} }
u32 CMasterTemplate::GameVersion(TString VersionName) void CGameTemplate::SaveScriptTemplate(CScriptTemplate* pTemplate)
{
ASSERT( pTemplate->GameTemplate() == this );
}
void CGameTemplate::SavePropertyTemplate(IProperty* pProperty)
{
}
u32 CGameTemplate::GameVersion(TString VersionName)
{ {
return -1; return -1;
} }
CScriptTemplate* CMasterTemplate::TemplateByID(u32 ObjectID) CScriptTemplate* CGameTemplate::TemplateByID(u32 ObjectID)
{ {
auto it = mScriptTemplates.find(ObjectID); auto it = mScriptTemplates.find(ObjectID);
@ -95,18 +104,18 @@ CScriptTemplate* CMasterTemplate::TemplateByID(u32 ObjectID)
return nullptr; return nullptr;
} }
CScriptTemplate* CMasterTemplate::TemplateByID(const CFourCC& ObjectID) CScriptTemplate* CGameTemplate::TemplateByID(const CFourCC& ObjectID)
{ {
return TemplateByID(ObjectID.ToLong()); return TemplateByID(ObjectID.ToLong());
} }
CScriptTemplate* CMasterTemplate::TemplateByIndex(u32 Index) CScriptTemplate* CGameTemplate::TemplateByIndex(u32 Index)
{ {
auto it = mScriptTemplates.begin(); auto it = mScriptTemplates.begin();
return (std::next(it, Index))->second.pTemplate.get(); return (std::next(it, Index))->second.pTemplate.get();
} }
SState CMasterTemplate::StateByID(u32 StateID) SState CGameTemplate::StateByID(u32 StateID)
{ {
auto Iter = mStates.find(StateID); auto Iter = mStates.find(StateID);
@ -116,19 +125,19 @@ SState CMasterTemplate::StateByID(u32 StateID)
return SState(-1, "Invalid"); return SState(-1, "Invalid");
} }
SState CMasterTemplate::StateByID(const CFourCC& State) SState CGameTemplate::StateByID(const CFourCC& State)
{ {
return StateByID(State.ToLong()); return StateByID(State.ToLong());
} }
SState CMasterTemplate::StateByIndex(u32 Index) SState CGameTemplate::StateByIndex(u32 Index)
{ {
auto Iter = mStates.begin(); auto Iter = mStates.begin();
Iter = std::next(Iter, Index); Iter = std::next(Iter, Index);
return SState(Iter->first, Iter->second); return SState(Iter->first, Iter->second);
} }
SMessage CMasterTemplate::MessageByID(u32 MessageID) SMessage CGameTemplate::MessageByID(u32 MessageID)
{ {
auto Iter = mMessages.find(MessageID); auto Iter = mMessages.find(MessageID);
@ -138,19 +147,19 @@ SMessage CMasterTemplate::MessageByID(u32 MessageID)
return SMessage(-1, "Invalid"); return SMessage(-1, "Invalid");
} }
SMessage CMasterTemplate::MessageByID(const CFourCC& MessageID) SMessage CGameTemplate::MessageByID(const CFourCC& MessageID)
{ {
return MessageByID(MessageID.ToLong()); return MessageByID(MessageID.ToLong());
} }
SMessage CMasterTemplate::MessageByIndex(u32 Index) SMessage CGameTemplate::MessageByIndex(u32 Index)
{ {
auto Iter = mMessages.begin(); auto Iter = mMessages.begin();
Iter = std::next(Iter, Index); Iter = std::next(Iter, Index);
return SMessage(Iter->first, Iter->second); return SMessage(Iter->first, Iter->second);
} }
IProperty* CMasterTemplate::FindPropertyArchetype(const TString& kTypeName) IProperty* CGameTemplate::FindPropertyArchetype(const TString& kTypeName)
{ {
auto Iter = mPropertyTemplates.find(kTypeName); auto Iter = mPropertyTemplates.find(kTypeName);
@ -174,54 +183,54 @@ IProperty* CMasterTemplate::FindPropertyArchetype(const TString& kTypeName)
return Path.pTemplate.get(); return Path.pTemplate.get();
} }
TString CMasterTemplate::GetGameDirectory(bool Absolute) const TString CGameTemplate::GetGameDirectory(bool Absolute) const
{ {
TString Out = mSourceFile.GetFileDirectory(); TString Out = mSourceFile.GetFileDirectory();
return Absolute ? "../templates_new/" + Out : Out; return Absolute ? "../templates_new/" + Out : Out;
} }
// ************ STATIC ************ // ************ STATIC ************
CMasterTemplate* CMasterTemplate::MasterForGame(EGame Game) CGameTemplate* CGameTemplate::GetGameTemplate(EGame Game)
{ {
auto it = smMasterMap.find(Game); auto it = smGameMap.find(Game);
if (it != smMasterMap.end()) if (it != smGameMap.end())
return it->second; return it->second;
else else
return nullptr; return nullptr;
} }
std::list<CMasterTemplate*> CMasterTemplate::MasterList() std::list<CGameTemplate*> CGameTemplate::GameTemplateList()
{ {
std::list<CMasterTemplate*> list; std::list<CGameTemplate*> list;
for (auto it = smMasterMap.begin(); it != smMasterMap.end(); it++) for (auto it = smGameMap.begin(); it != smGameMap.end(); it++)
list.push_back(it->second); list.push_back(it->second);
return list; return list;
} }
TString CMasterTemplate::FindGameName(EGame Game) TString CGameTemplate::FindGameName(EGame Game)
{ {
CMasterTemplate *pMaster = MasterForGame(Game); CGameTemplate *pGame = GetGameTemplate(Game);
return pMaster ? pMaster->GameName() : "Unknown Game"; return pGame ? pGame->GameName() : "Unknown Game";
} }
EGame CMasterTemplate::FindGameForName(const TString& rkName) EGame CGameTemplate::FindGameForName(const TString& rkName)
{ {
std::list<CMasterTemplate*> Masters = MasterList(); std::list<CGameTemplate*> Games = GameTemplateList();
for (auto It = Masters.begin(); It != Masters.end(); It++) for (auto It = Games.begin(); It != Games.end(); It++)
{ {
CMasterTemplate *pMaster = *It; CGameTemplate *pGame = *It;
if (pMaster->GameName() == rkName) if (pGame->GameName() == rkName)
return pMaster->Game(); return pGame->Game();
} }
return eUnknownGame; return eUnknownGame;
} }
TString CMasterTemplate::PropertyName(u32 PropertyID) TString CGameTemplate::PropertyName(u32 PropertyID)
{ {
auto it = smPropertyNames.find(PropertyID); auto it = smPropertyNames.find(PropertyID);
@ -232,7 +241,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. // 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(IProperty* pProp) u32 CGameTemplate::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. // 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). // 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 +259,7 @@ u32 CMasterTemplate::CreatePropertyID(IProperty* pProp)
return Hash.Digest(); return Hash.Digest();
} }
void CMasterTemplate::AddProperty(IProperty* pProp, const TString& rkTemplateName /*= ""*/) void CGameTemplate::AddProperty(IProperty* pProp, const TString& rkTemplateName /*= ""*/)
{ {
u32 ID; u32 ID;
@ -307,16 +316,16 @@ void CMasterTemplate::AddProperty(IProperty* pProp, const TString& rkTemplateNam
} }
} }
void CMasterTemplate::RenameProperty(IProperty* pProp, const TString& rkNewName) void CGameTemplate::RenameProperty(IProperty* pProp, const TString& rkNewName)
{ {
u32 ID = pProp->ID(); u32 ID = pProp->ID();
if (ID <= 0xFF) ID = CreatePropertyID(pProp); if (ID <= 0xFF) ID = CreatePropertyID(pProp);
RenameProperty(ID, rkNewName); RenameProperty(ID, rkNewName);
} }
void CMasterTemplate::RenameProperty(u32 ID, const TString& rkNewName) void CGameTemplate::RenameProperty(u32 ID, const TString& rkNewName)
{ {
// Master name list // Game name list
auto NameIt = smPropertyNames.find(ID); auto NameIt = smPropertyNames.find(ID);
TString Original; TString Original;
@ -341,7 +350,7 @@ void CMasterTemplate::RenameProperty(u32 ID, const TString& rkNewName)
} }
} }
void CMasterTemplate::XMLsUsingID(u32 ID, std::vector<TString>& rOutList) void CGameTemplate::XMLsUsingID(u32 ID, std::vector<TString>& rOutList)
{ {
auto InfoIt = smIDMap.find(ID); auto InfoIt = smIDMap.find(ID);
@ -352,7 +361,7 @@ void CMasterTemplate::XMLsUsingID(u32 ID, std::vector<TString>& rOutList)
} }
} }
const std::vector<IProperty*>* CMasterTemplate::TemplatesWithMatchingID(IProperty* pProp) const std::vector<IProperty*>* CGameTemplate::TemplatesWithMatchingID(IProperty* pProp)
{ {
u32 ID = pProp->ID(); u32 ID = pProp->ID();
if (ID <= 0xFF) ID = CreatePropertyID(pProp); if (ID <= 0xFF) ID = CreatePropertyID(pProp);
@ -367,7 +376,7 @@ const std::vector<IProperty*>* CMasterTemplate::TemplatesWithMatchingID(IPropert
return nullptr; return nullptr;
} }
std::map<u32, CMasterTemplate::SPropIDInfo> CMasterTemplate::smIDMap; std::map<u32, CGameTemplate::SPropIDInfo> CGameTemplate::smIDMap;
std::map<EGame, CMasterTemplate*> CMasterTemplate::smMasterMap; std::map<EGame, CGameTemplate*> CGameTemplate::smGameMap;
std::map<u32, TString> CMasterTemplate::smPropertyNames; std::map<u32, TString> CGameTemplate::smPropertyNames;
u32 CMasterTemplate::smGameListVersion; u32 CGameTemplate::smGameListVersion;

View File

@ -1,5 +1,5 @@
#ifndef CMASTERTEMPLATE_H #ifndef CGAMETEMPLATE_H
#define CMASTERTEMPLATE_H #define CGAMETEMPLATE_H
#include "CLink.h" #include "CLink.h"
#include "CScriptTemplate.h" #include "CScriptTemplate.h"
@ -35,7 +35,7 @@ struct SObjId
} }
}; };
class CMasterTemplate class CGameTemplate
{ {
friend class CTemplateLoader; friend class CTemplateLoader;
friend class CTemplateWriter; friend class CTemplateWriter;
@ -120,7 +120,7 @@ class CMasterTemplate
std::vector<IProperty*> PropertyList; // List of all properties that use this ID std::vector<IProperty*> PropertyList; // List of all properties that use this ID
}; };
static std::map<u32, SPropIDInfo> smIDMap; static std::map<u32, SPropIDInfo> smIDMap;
static std::map<EGame, CMasterTemplate*> smMasterMap; static std::map<EGame, CGameTemplate*> smGameMap;
static std::map<u32, TString> smPropertyNames; static std::map<u32, TString> smPropertyNames;
static u32 smGameListVersion; static u32 smGameListVersion;
@ -128,10 +128,12 @@ class CMasterTemplate
void Internal_LoadPropertyTemplate(SPropertyTemplatePath& Path); void Internal_LoadPropertyTemplate(SPropertyTemplatePath& Path);
public: public:
CMasterTemplate(); CGameTemplate();
void Serialize(IArchive& Arc); void Serialize(IArchive& Arc);
void LoadSubTemplates(); void LoadSubTemplates();
void SaveSubTemplates(); void SaveSubTemplates();
void SaveScriptTemplate(CScriptTemplate* pTemplate);
void SavePropertyTemplate(IProperty* pProperty);
u32 GameVersion(TString VersionName); u32 GameVersion(TString VersionName);
CScriptTemplate* TemplateByID(u32 ObjectID); CScriptTemplate* TemplateByID(u32 ObjectID);
CScriptTemplate* TemplateByID(const CFourCC& ObjectID); CScriptTemplate* TemplateByID(const CFourCC& ObjectID);
@ -154,8 +156,8 @@ public:
inline bool IsLoadedSuccessfully() { return mFullyLoaded; } inline bool IsLoadedSuccessfully() { return mFullyLoaded; }
// Static // Static
static CMasterTemplate* MasterForGame(EGame Game); static CGameTemplate* GetGameTemplate(EGame Game);
static std::list<CMasterTemplate*> MasterList(); static std::list<CGameTemplate*> GameTemplateList();
static TString FindGameName(EGame Game); static TString FindGameName(EGame Game);
static EGame FindGameForName(const TString& rkName); static EGame FindGameForName(const TString& rkName);
static TString PropertyName(u32 PropertyID); static TString PropertyName(u32 PropertyID);
@ -167,4 +169,4 @@ public:
static const std::vector<IProperty*>* TemplatesWithMatchingID(IProperty *pTemp); static const std::vector<IProperty*>* TemplatesWithMatchingID(IProperty *pTemp);
}; };
#endif // CMASTERTEMPLATE_H #endif // CGAMETEMPLATE_H

View File

@ -1,6 +1,6 @@
#include "CScriptObject.h" #include "CScriptObject.h"
#include "CScriptLayer.h" #include "CScriptLayer.h"
#include "CMasterTemplate.h" #include "CGameTemplate.h"
#include "Core/Resource/Animation/CAnimSet.h" #include "Core/Resource/Animation/CAnimSet.h"
CScriptObject::CScriptObject(u32 InstanceID, CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate) CScriptObject::CScriptObject(u32 InstanceID, CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate)

View File

@ -70,7 +70,7 @@ public:
// Accessors // Accessors
CScriptTemplate* Template() const { return mpTemplate; } CScriptTemplate* Template() const { return mpTemplate; }
CMasterTemplate* MasterTemplate() const { return mpTemplate->MasterTemplate(); } CGameTemplate* GameTemplate() const { return mpTemplate->GameTemplate(); }
CGameArea* Area() const { return mpArea; } CGameArea* Area() const { return mpArea; }
CScriptLayer* Layer() const { return mpLayer; } CScriptLayer* Layer() const { return mpLayer; }
u32 Version() const { return mVersion; } u32 Version() const { return mVersion; }

View File

@ -1,6 +1,6 @@
#include "CScriptTemplate.h" #include "CScriptTemplate.h"
#include "CScriptObject.h" #include "CScriptObject.h"
#include "CMasterTemplate.h" #include "CGameTemplate.h"
#include "Core/GameProject/CResourceStore.h" #include "Core/GameProject/CResourceStore.h"
#include "Core/Resource/Animation/CAnimSet.h" #include "Core/Resource/Animation/CAnimSet.h"
#include <Common/Log.h> #include <Common/Log.h>
@ -9,8 +9,8 @@
#include <string> #include <string>
// Old constructor // Old constructor
CScriptTemplate::CScriptTemplate(CMasterTemplate *pMaster) CScriptTemplate::CScriptTemplate(CGameTemplate *pGame)
: mpMaster(pMaster) : mpGame(pGame)
, mpProperties(nullptr) , mpProperties(nullptr)
, mVisible(true) , mVisible(true)
, mpNameProperty(nullptr) , mpNameProperty(nullptr)
@ -26,7 +26,7 @@ CScriptTemplate::CScriptTemplate(CMasterTemplate *pMaster)
} }
// New constructor // New constructor
CScriptTemplate::CScriptTemplate(CMasterTemplate* pInMaster, u32 InObjectID, const TString& kInFilePath) CScriptTemplate::CScriptTemplate(CGameTemplate* pInGame, u32 InObjectID, const TString& kInFilePath)
: mRotationType(eRotationEnabled) : mRotationType(eRotationEnabled)
, mScaleType(eScaleEnabled) , mScaleType(eScaleEnabled)
, mPreviewScale(1.f) , mPreviewScale(1.f)
@ -34,7 +34,7 @@ CScriptTemplate::CScriptTemplate(CMasterTemplate* pInMaster, u32 InObjectID, con
, mVolumeScale(1.f) , mVolumeScale(1.f)
, mSourceFile(kInFilePath) , mSourceFile(kInFilePath)
, mObjectID(InObjectID) , mObjectID(InObjectID)
, mpMaster(pInMaster) , mpGame(pInGame)
, mpNameProperty(nullptr) , mpNameProperty(nullptr)
, mpPositionProperty(nullptr) , mpPositionProperty(nullptr)
, mpRotationProperty(nullptr) , mpRotationProperty(nullptr)
@ -91,7 +91,7 @@ void CScriptTemplate::PostLoad()
EGame CScriptTemplate::Game() const EGame CScriptTemplate::Game() const
{ {
return mpMaster->Game(); return mpGame->Game();
} }
// ************ PROPERTY FETCHING ************ // ************ PROPERTY FETCHING ************

View File

@ -10,7 +10,7 @@
#include <list> #include <list>
#include <vector> #include <vector>
class CMasterTemplate; class CGameTemplate;
class CScriptObject; class CScriptObject;
typedef TString TIDString; typedef TString TIDString;
@ -79,7 +79,7 @@ private:
}; };
std::vector<TString> mModules; std::vector<TString> mModules;
std::unique_ptr<CStructPropertyNew> mpProperties; std::unique_ptr<CStructProperty> mpProperties;
std::vector<SEditorAsset> mAssets; std::vector<SEditorAsset> mAssets;
std::vector<SAttachment> mAttachments; std::vector<SAttachment> mAttachments;
@ -103,7 +103,7 @@ private:
TIDString mActiveIDString; TIDString mActiveIDString;
TIDString mLightParametersIDString; TIDString mLightParametersIDString;
CMasterTemplate* mpMaster; CGameTemplate* mpGame;
std::list<CScriptObject*> mObjectList; std::list<CScriptObject*> mObjectList;
CStringProperty* mpNameProperty; CStringProperty* mpNameProperty;
@ -111,7 +111,7 @@ private:
CVectorProperty* mpRotationProperty; CVectorProperty* mpRotationProperty;
CVectorProperty* mpScaleProperty; CVectorProperty* mpScaleProperty;
CBoolProperty* mpActiveProperty; CBoolProperty* mpActiveProperty;
CStructPropertyNew* mpLightParametersProperty; CStructProperty* mpLightParametersProperty;
struct SVolumeCondition { struct SVolumeCondition {
u32 Value; u32 Value;
@ -132,9 +132,9 @@ public:
// Default constructor. Don't use. This is only here so the serializer doesn't complain // Default constructor. Don't use. This is only here so the serializer doesn't complain
CScriptTemplate() { ASSERT(false); } CScriptTemplate() { ASSERT(false); }
// Old constructor // Old constructor
CScriptTemplate(CMasterTemplate *pMaster); CScriptTemplate(CGameTemplate *pGame);
// New constructor // New constructor
CScriptTemplate(CMasterTemplate* pMaster, u32 ObjectID, const TString& kFilePath); CScriptTemplate(CGameTemplate* pGame, u32 ObjectID, const TString& kFilePath);
~CScriptTemplate(); ~CScriptTemplate();
void Serialize(IArchive& rArc); void Serialize(IArchive& rArc);
void PostLoad(); void PostLoad();
@ -147,7 +147,7 @@ public:
CCollisionMeshGroup* FindCollision(void* pPropertyData); CCollisionMeshGroup* FindCollision(void* pPropertyData);
// Accessors // Accessors
inline CMasterTemplate* MasterTemplate() const { return mpMaster; } inline CGameTemplate* GameTemplate() const { return mpGame; }
inline TString Name() const { return mpProperties->Name(); } inline TString Name() const { return mpProperties->Name(); }
inline ERotationType RotationType() const { return mRotationType; } inline ERotationType RotationType() const { return mRotationType; }
inline EScaleType ScaleType() const { return mScaleType; } inline EScaleType ScaleType() const { return mScaleType; }
@ -155,7 +155,7 @@ public:
inline u32 ObjectID() const { return mObjectID; } inline u32 ObjectID() const { return mObjectID; }
inline bool IsVisible() const { return mVisible; } inline bool IsVisible() const { return mVisible; }
inline TString SourceFile() const { return mSourceFile; } inline TString SourceFile() const { return mSourceFile; }
inline CStructPropertyNew* Properties() const { return mpProperties.get(); } inline CStructProperty* Properties() const { return mpProperties.get(); }
inline u32 NumAttachments() const { return mAttachments.size(); } inline u32 NumAttachments() const { return mAttachments.size(); }
const SAttachment& Attachment(u32 Index) const { return mAttachments[Index]; } const SAttachment& Attachment(u32 Index) const { return mAttachments[Index]; }
const std::vector<TString>& RequiredModules() const { return mModules; } const std::vector<TString>& RequiredModules() const { return mModules; }
@ -165,7 +165,7 @@ public:
inline CVectorProperty* RotationProperty() const { return mpRotationProperty; } inline CVectorProperty* RotationProperty() const { return mpRotationProperty; }
inline CVectorProperty* ScaleProperty() const { return mpScaleProperty; } inline CVectorProperty* ScaleProperty() const { return mpScaleProperty; }
inline CBoolProperty* ActiveProperty() const { return mpActiveProperty; } inline CBoolProperty* ActiveProperty() const { return mpActiveProperty; }
inline CStructPropertyNew* LightParametersProperty() const { return mpLightParametersProperty; } inline CStructProperty* LightParametersProperty() const { return mpLightParametersProperty; }
inline void SetVisible(bool Visible) { mVisible = Visible; } inline void SetVisible(bool Visible) { mVisible = Visible; }

View File

@ -3,13 +3,13 @@
#include "IProperty.h" #include "IProperty.h"
class CByteProperty : public TNumericalPropertyNew< s8, EPropertyTypeNew::Byte > class CByteProperty : public TNumericalProperty< s8, EPropertyType::Byte >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CByteProperty(EGame Game) CByteProperty(EGame Game)
: TNumericalPropertyNew(Game) : TNumericalProperty(Game)
{} {}
public: public:

View File

@ -4,9 +4,9 @@
#include "IProperty.h" #include "IProperty.h"
#include "CFloatProperty.h" #include "CFloatProperty.h"
class CColorProperty : public TSerializeableTypedProperty< CColor, EPropertyTypeNew::Color > class CColorProperty : public TSerializeableTypedProperty< CColor, EPropertyType::Color >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CColorProperty(EGame Game) CColorProperty(EGame Game)
@ -16,10 +16,10 @@ protected:
public: public:
virtual void PostInitialize() virtual void PostInitialize()
{ {
CreateIntrinsic(EPropertyTypeNew::Float, this, mOffset + 0, "R"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 0, "R");
CreateIntrinsic(EPropertyTypeNew::Float, this, mOffset + 4, "G"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 4, "G");
CreateIntrinsic(EPropertyTypeNew::Float, this, mOffset + 8, "B"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 8, "B");
CreateIntrinsic(EPropertyTypeNew::Float, this, mOffset + 12, "A"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 12, "A");
TPropCast<CFloatProperty>( mChildren.back() )->SetDefaultValue(1.0f); TPropCast<CFloatProperty>( mChildren.back() )->SetDefaultValue(1.0f);
} }

View File

@ -10,11 +10,11 @@
* *
* In PWE, however, they are both implemented the same way under the hood. * In PWE, however, they are both implemented the same way under the hood.
*/ */
template<EPropertyTypeNew TypeEnum> template<EPropertyType TypeEnum>
class TEnumPropertyBase : public TSerializeableTypedProperty<s32, TypeEnum> class TEnumPropertyBase : public TSerializeableTypedProperty<s32, TypeEnum>
{ {
friend class CTemplateLoader; friend class CTemplateLoader;
friend class IPropertyNew; friend class IProperty;
struct SEnumValue struct SEnumValue
{ {
@ -54,7 +54,7 @@ protected:
public: public:
virtual const char* GetHashableTypeName() const virtual const char* GetHashableTypeName() const
{ {
if (TypeEnum == EPropertyTypeNew::Enum) if (TypeEnum == EPropertyType::Enum)
return "enum"; return "enum";
else else
return "choice"; return "choice";
@ -63,7 +63,7 @@ public:
virtual void Serialize(IArchive& rArc) virtual void Serialize(IArchive& rArc)
{ {
// Skip TSerializeableTypedProperty, serialize default value ourselves so we can set SH_HexDisplay // Skip TSerializeableTypedProperty, serialize default value ourselves so we can set SH_HexDisplay
TTypedPropertyNew::Serialize(rArc); TTypedProperty::Serialize(rArc);
TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(mpArchetype); TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(mpArchetype);
u32 DefaultValueFlags = SH_HexDisplay | (pArchetype || Game() <= ePrime ? SH_Optional : 0); u32 DefaultValueFlags = SH_HexDisplay | (pArchetype || Game() <= ePrime ? SH_Optional : 0);
@ -80,9 +80,9 @@ public:
Arc.SerializePrimitive( (u32&) ValueRef(pData), 0 ); Arc.SerializePrimitive( (u32&) ValueRef(pData), 0 );
} }
virtual void InitFromArchetype(IPropertyNew* pOther) virtual void InitFromArchetype(IProperty* pOther)
{ {
TTypedPropertyNew::InitFromArchetype(pOther); TTypedProperty::InitFromArchetype(pOther);
TEnumPropertyBase* pOtherEnum = static_cast<TEnumPropertyBase*>(pOther); TEnumPropertyBase* pOtherEnum = static_cast<TEnumPropertyBase*>(pOther);
mValues = pOtherEnum->mValues; mValues = pOtherEnum->mValues;
} }
@ -132,18 +132,18 @@ public:
} }
}; };
typedef TEnumPropertyBase<EPropertyTypeNew::Choice> CChoiceProperty; typedef TEnumPropertyBase<EPropertyType::Choice> CChoiceProperty;
typedef TEnumPropertyBase<EPropertyTypeNew::Enum> CEnumProperty; typedef TEnumPropertyBase<EPropertyType::Enum> CEnumProperty;
// Specialization of TPropCast to allow interchangeable casting, as both types are the same thing // Specialization of TPropCast to allow interchangeable casting, as both types are the same thing
template<> template<>
inline CEnumProperty* TPropCast(IPropertyNew* pProperty) inline CEnumProperty* TPropCast(IProperty* pProperty)
{ {
if (pProperty) if (pProperty)
{ {
EPropertyTypeNew InType = pProperty->Type(); EPropertyType InType = pProperty->Type();
if (InType == EPropertyTypeNew::Enum || InType == EPropertyTypeNew::Choice) if (InType == EPropertyType::Enum || InType == EPropertyType::Choice)
{ {
return static_cast<CEnumProperty*>(pProperty); return static_cast<CEnumProperty*>(pProperty);
} }
@ -153,13 +153,13 @@ inline CEnumProperty* TPropCast(IPropertyNew* pProperty)
} }
template<> template<>
inline CChoiceProperty* TPropCast(IPropertyNew* pProperty) inline CChoiceProperty* TPropCast(IProperty* pProperty)
{ {
if (pProperty) if (pProperty)
{ {
EPropertyTypeNew InType = pProperty->Type(); EPropertyType InType = pProperty->Type();
if (InType == EPropertyTypeNew::Enum || InType == EPropertyTypeNew::Choice) if (InType == EPropertyType::Enum || InType == EPropertyType::Choice)
{ {
return static_cast<CChoiceProperty*>(pProperty); return static_cast<CChoiceProperty*>(pProperty);
} }

View File

@ -1,5 +1,5 @@
#include "CFlagsProperty.h" #include "CFlagsProperty.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
void CFlagsProperty::Serialize(IArchive& rArc) void CFlagsProperty::Serialize(IArchive& rArc)
{ {

View File

@ -3,10 +3,10 @@
#include "IProperty.h" #include "IProperty.h"
class CFlagsProperty : public TSerializeableTypedProperty<u32, EPropertyTypeNew::Flags> class CFlagsProperty : public TSerializeableTypedProperty<u32, EPropertyType::Flags>
{ {
friend class CTemplateLoader; friend class CTemplateLoader;
friend class IPropertyNew; friend class IProperty;
struct SBitFlag struct SBitFlag
{ {
@ -64,7 +64,7 @@ public:
virtual void Serialize(IArchive& rArc); virtual void Serialize(IArchive& rArc);
virtual void PostInitialize(); virtual void PostInitialize();
virtual void SerializeValue(void* pData, IArchive& rArc) const; virtual void SerializeValue(void* pData, IArchive& rArc) const;
virtual void InitFromArchetype(IPropertyNew* pOther); virtual void InitFromArchetype(IProperty* pOther);
virtual TString GetTemplateFileName(); virtual TString GetTemplateFileName();
/** /**

View File

@ -3,13 +3,13 @@
#include "IProperty.h" #include "IProperty.h"
class CFloatProperty : public TNumericalPropertyNew< float, EPropertyTypeNew::Float > class CFloatProperty : public TNumericalProperty< float, EPropertyType::Float >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CFloatProperty(EGame Game) CFloatProperty(EGame Game)
: TNumericalPropertyNew(Game) : TNumericalProperty(Game)
{} {}
public: public:

View File

@ -3,13 +3,13 @@
#include "IProperty.h" #include "IProperty.h"
class CGuidProperty : public TTypedPropertyNew< std::vector<char>, EPropertyTypeNew::Guid > class CGuidProperty : public TTypedProperty< std::vector<char>, EPropertyType::Guid >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CGuidProperty(EGame Game) CGuidProperty(EGame Game)
: TTypedPropertyNew(Game) : TTypedProperty(Game)
{} {}
public: public:

View File

@ -3,13 +3,13 @@
#include "IProperty.h" #include "IProperty.h"
class CIntProperty : public TNumericalPropertyNew< s32, EPropertyTypeNew::Int > class CIntProperty : public TNumericalProperty< s32, EPropertyType::Int >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CIntProperty(EGame Game) CIntProperty(EGame Game)
: TNumericalPropertyNew(Game) : TNumericalProperty(Game)
{} {}
public: public:

View File

@ -3,13 +3,13 @@
#include "IProperty.h" #include "IProperty.h"
class CPointerProperty : public TTypedPropertyNew<void*, EPropertyTypeNew::Pointer> class CPointerProperty : public TTypedProperty<void*, EPropertyType::Pointer>
{ {
friend class CTemplateLoader; friend class CTemplateLoader;
friend class IPropertyNew; friend class IProperty;
CPointerProperty(EGame Game) CPointerProperty(EGame Game)
: TTypedPropertyNew(Game) : TTypedProperty(Game)
{} {}
public: public:

View File

@ -1,7 +1,7 @@
#include "CPropertyNameGenerator.h" #include "CPropertyNameGenerator.h"
#include "IUIRelay.h" #include "IUIRelay.h"
#include "Core/Resource/Factory/CTemplateLoader.h" #include "Core/Resource/Factory/CTemplateLoader.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include <Common/Hash/CCRC32.h> #include <Common/Hash/CCRC32.h>
/** Default constructor */ /** Default constructor */
@ -151,7 +151,7 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
// Check if this hash is a property ID - it's valid if there are any XMLs using this ID // Check if this hash is a property ID - it's valid if there are any XMLs using this ID
SGeneratedPropertyName PropertyName; SGeneratedPropertyName PropertyName;
CMasterTemplate::XMLsUsingID(PropertyID, PropertyName.XmlList); CGameTemplate::XMLsUsingID(PropertyID, PropertyName.XmlList);
if (PropertyName.XmlList.size() > 0) if (PropertyName.XmlList.size() > 0)
{ {

View File

@ -3,13 +3,13 @@
#include "IProperty.h" #include "IProperty.h"
class CSequenceProperty : public TTypedPropertyNew< s32, EPropertyTypeNew::Sequence > class CSequenceProperty : public TTypedProperty< s32, EPropertyType::Sequence >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CSequenceProperty(EGame Game) CSequenceProperty(EGame Game)
: TTypedPropertyNew(Game) : TTypedProperty(Game)
{} {}
virtual void SerializeValue(void* pData, IArchive& rArc) const virtual void SerializeValue(void* pData, IArchive& rArc) const

View File

@ -3,13 +3,13 @@
#include "IProperty.h" #include "IProperty.h"
class CShortProperty : public TNumericalPropertyNew< s16, EPropertyTypeNew::Short > class CShortProperty : public TNumericalProperty< s16, EPropertyType::Short >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CShortProperty(EGame Game) CShortProperty(EGame Game)
: TNumericalPropertyNew(Game) : TNumericalProperty(Game)
{} {}
public: public:

View File

@ -3,9 +3,9 @@
#include "IProperty.h" #include "IProperty.h"
class CSoundProperty : public TSerializeableTypedProperty< s32, EPropertyTypeNew::Sound > class CSoundProperty : public TSerializeableTypedProperty< s32, EPropertyType::Sound >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CSoundProperty(EGame Game) CSoundProperty(EGame Game)

View File

@ -3,13 +3,13 @@
#include "IProperty.h" #include "IProperty.h"
class CSplineProperty : public TTypedPropertyNew< std::vector<char>, EPropertyTypeNew::Spline > class CSplineProperty : public TTypedProperty< std::vector<char>, EPropertyType::Spline >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CSplineProperty(EGame Game) CSplineProperty(EGame Game)
: TTypedPropertyNew(Game) : TTypedProperty(Game)
{} {}
public: public:

View File

@ -3,9 +3,9 @@
#include "IProperty.h" #include "IProperty.h"
class CStringProperty : public TSerializeableTypedProperty< TString, EPropertyTypeNew::String > class CStringProperty : public TSerializeableTypedProperty< TString, EPropertyType::String >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CStringProperty(EGame Game) CStringProperty(EGame Game)

View File

@ -1,5 +1,5 @@
#include "CStructProperty.h" #include "CStructProperty.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
EPropertyType CStructProperty::Type() const EPropertyType CStructProperty::Type() const
{ {

View File

@ -3,10 +3,10 @@
#include "IProperty.h" #include "IProperty.h"
class CStructPropertyNew : public IPropertyNew class CStructProperty : public IProperty
{ {
friend class CTemplateLoader; friend class CTemplateLoader;
friend class IPropertyNew; friend class IProperty;
public: public:
// Must be a valid type for TPropertyRef // Must be a valid type for TPropertyRef
@ -16,12 +16,12 @@ protected:
/** For archetypes, the filename of the template XML file. */ /** For archetypes, the filename of the template XML file. */
TString mTemplateFileName; TString mTemplateFileName;
CStructPropertyNew(EGame Game) CStructProperty(EGame Game)
: IPropertyNew(Game) : IProperty(Game)
{} {}
public: public:
virtual EPropertyTypeNew Type() const; virtual EPropertyType Type() const;
virtual u32 DataSize() const; virtual u32 DataSize() const;
virtual u32 DataAlignment() const; virtual u32 DataAlignment() const;
virtual void Construct(void* pData) const; virtual void Construct(void* pData) const;
@ -31,11 +31,11 @@ public:
virtual const char* HashableTypeName() const; virtual const char* HashableTypeName() const;
virtual void Serialize(IArchive& rArc); virtual void Serialize(IArchive& rArc);
virtual void SerializeValue(void* pData, IArchive& Arc) const; virtual void SerializeValue(void* pData, IArchive& Arc) const;
virtual void InitFromArchetype(IPropertyNew* pOther); virtual void InitFromArchetype(IProperty* pOther);
virtual bool ShouldSerialize() const; virtual bool ShouldSerialize() const;
virtual TString GetTemplateFileName(); virtual TString GetTemplateFileName();
inline static EPropertyTypeNew StaticType() { return EPropertyTypeNew::Struct; } inline static EPropertyType StaticType() { return EPropertyType::Struct; }
}; };
#endif #endif

View File

@ -3,9 +3,9 @@
#include "IProperty.h" #include "IProperty.h"
class CVectorProperty : public TSerializeableTypedProperty< CVector3f, EPropertyTypeNew::Vector > class CVectorProperty : public TSerializeableTypedProperty< CVector3f, EPropertyType::Vector >
{ {
friend class IPropertyNew; friend class IProperty;
protected: protected:
CVectorProperty(EGame Game) CVectorProperty(EGame Game)
@ -15,9 +15,9 @@ protected:
public: public:
virtual void PostInitialize() override virtual void PostInitialize() override
{ {
CreateIntrinsic(EPropertyTypeNew::Float, this, mOffset + 0, "X"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 0, "X");
CreateIntrinsic(EPropertyTypeNew::Float, this, mOffset + 4, "Y"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 4, "Y");
CreateIntrinsic(EPropertyTypeNew::Float, this, mOffset + 8, "Z"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 8, "Z");
} }
virtual void SerializeValue(void* pData, IArchive& Arc) const virtual void SerializeValue(void* pData, IArchive& Arc) const

View File

@ -5,11 +5,11 @@
#include "CFlagsProperty.h" #include "CFlagsProperty.h"
#include "CPointerProperty.h" #include "CPointerProperty.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include "Core/Resource/Script/CScriptTemplate.h" #include "Core/Resource/Script/CScriptTemplate.h"
/** IPropertyNew */ /** IProperty */
IPropertyNew::IPropertyNew(EGame Game) IProperty::IProperty(EGame Game)
: mpParent( nullptr ) : mpParent( nullptr )
, mpPointerParent( nullptr ) , mpPointerParent( nullptr )
, mpArchetype( nullptr ) , mpArchetype( nullptr )
@ -17,12 +17,12 @@ IPropertyNew::IPropertyNew(EGame Game)
, mpScriptTemplate( nullptr ) , mpScriptTemplate( nullptr )
, mOffset( -1 ) , mOffset( -1 )
, mID( -1 ) , mID( -1 )
, mCookPreference( ECookPreferenceNew::Default ) , mCookPreference( ECookPreference::Default )
, mMinVersion( 0.0f ) , mMinVersion( 0.0f )
, mMaxVersion( FLT_MAX ) , mMaxVersion( FLT_MAX )
{} {}
void IPropertyNew::_ClearChildren() void IProperty::_ClearChildren()
{ {
for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
delete mChildren[ChildIdx]; delete mChildren[ChildIdx];
@ -30,7 +30,7 @@ void IPropertyNew::_ClearChildren()
mChildren.clear(); mChildren.clear();
} }
IPropertyNew::~IPropertyNew() IProperty::~IProperty()
{ {
// Remove from archetype // Remove from archetype
if( mpArchetype != nullptr ) if( mpArchetype != nullptr )
@ -48,17 +48,17 @@ IPropertyNew::~IPropertyNew()
_ClearChildren(); _ClearChildren();
} }
const char* IPropertyNew::HashableTypeName() const const char* IProperty::HashableTypeName() const
{ {
return PropEnumToHashableTypeName( Type() ); return PropEnumToHashableTypeName( Type() );
} }
void* IPropertyNew::GetChildDataPointer(void* pPropertyData) const void* IProperty::GetChildDataPointer(void* pPropertyData) const
{ {
return pPropertyData; return pPropertyData;
} }
void IPropertyNew::Serialize(IArchive& rArc) void IProperty::Serialize(IArchive& rArc)
{ {
// Always serialize ID first! ID is always required (except for root properties, which have an ID of 0xFFFFFFFF) // Always serialize ID first! ID is always required (except for root properties, which have an ID of 0xFFFFFFFF)
// because they are needed to look up the correct property to apply parameter overrides to. // because they are needed to look up the correct property to apply parameter overrides to.
@ -72,8 +72,8 @@ void IPropertyNew::Serialize(IArchive& rArc)
if (rArc.IsReader() && !ArchetypeName.IsEmpty()) if (rArc.IsReader() && !ArchetypeName.IsEmpty())
{ {
CMasterTemplate* pMaster = CMasterTemplate::MasterForGame( Game() ); CGameTemplate* pGame = CGameTemplate::GetGameTemplate( Game() );
IPropertyNew* pArchetype = pMaster->FindPropertyArchetype(ArchetypeName); IProperty* pArchetype = pGame->FindPropertyArchetype(ArchetypeName);
// The archetype must exist, or else the template file is malformed. // The archetype must exist, or else the template file is malformed.
ASSERT(pArchetype != nullptr); ASSERT(pArchetype != nullptr);
@ -95,7 +95,7 @@ void IPropertyNew::Serialize(IArchive& rArc)
} }
rArc << SerialParameter("Description", mDescription, SH_Optional, mpArchetype ? mpArchetype->mDescription : "") rArc << SerialParameter("Description", mDescription, SH_Optional, mpArchetype ? mpArchetype->mDescription : "")
<< SerialParameter("CookPreference", mCookPreference, SH_Optional, mpArchetype ? mpArchetype->mCookPreference : ECookPreferenceNew::Default) << SerialParameter("CookPreference", mCookPreference, SH_Optional, mpArchetype ? mpArchetype->mCookPreference : ECookPreference::Default)
<< SerialParameter("MinVersion", mMinVersion, SH_Optional, mpArchetype ? mpArchetype->mMinVersion : 0.f) << SerialParameter("MinVersion", mMinVersion, SH_Optional, mpArchetype ? mpArchetype->mMinVersion : 0.f)
<< SerialParameter("MaxVersion", mMaxVersion, SH_Optional, mpArchetype ? mpArchetype->mMaxVersion : FLT_MAX) << SerialParameter("MaxVersion", mMaxVersion, SH_Optional, mpArchetype ? mpArchetype->mMaxVersion : FLT_MAX)
<< SerialParameter("Suffix", mSuffix, SH_Optional, mpArchetype ? mpArchetype->mSuffix : ""); << SerialParameter("Suffix", mSuffix, SH_Optional, mpArchetype ? mpArchetype->mSuffix : "");
@ -103,7 +103,7 @@ void IPropertyNew::Serialize(IArchive& rArc)
// Children don't get serialized for most property types // Children don't get serialized for most property types
} }
void IPropertyNew::InitFromArchetype(IPropertyNew* pOther) void IProperty::InitFromArchetype(IProperty* pOther)
{ {
//@todo maybe somehow use Serialize for this instead? //@todo maybe somehow use Serialize for this instead?
mpArchetype = pOther; mpArchetype = pOther;
@ -122,7 +122,7 @@ void IPropertyNew::InitFromArchetype(IPropertyNew* pOther)
} }
} }
bool IPropertyNew::ShouldSerialize() const bool IProperty::ShouldSerialize() const
{ {
return mpArchetype == nullptr || return mpArchetype == nullptr ||
mName != mpArchetype->mName || mName != mpArchetype->mName ||
@ -133,7 +133,7 @@ bool IPropertyNew::ShouldSerialize() const
mMaxVersion != mpArchetype->mMaxVersion; mMaxVersion != mpArchetype->mMaxVersion;
} }
TString IPropertyNew::GetTemplateFileName() TString IProperty::GetTemplateFileName()
{ {
if (mpScriptTemplate) if (mpScriptTemplate)
{ {
@ -141,7 +141,7 @@ TString IPropertyNew::GetTemplateFileName()
} }
else if (IsArchetype()) else if (IsArchetype())
{ {
IPropertyNew* pRootParent = RootParent(); IProperty* pRootParent = RootParent();
ASSERT(pRootParent != this); ASSERT(pRootParent != this);
return pRootParent->GetTemplateFileName(); return pRootParent->GetTemplateFileName();
} }
@ -151,7 +151,7 @@ TString IPropertyNew::GetTemplateFileName()
} }
} }
void IPropertyNew::Initialize(IPropertyNew* pInParent, CScriptTemplate* pInTemplate, u32 InOffset) void IProperty::Initialize(IProperty* pInParent, CScriptTemplate* pInTemplate, u32 InOffset)
{ {
// Make sure we only get initialized once. // Make sure we only get initialized once.
ASSERT( (mFlags & EPropertyFlag::IsInitialized) == 0 ); ASSERT( (mFlags & EPropertyFlag::IsInitialized) == 0 );
@ -164,7 +164,7 @@ void IPropertyNew::Initialize(IPropertyNew* pInParent, CScriptTemplate* pInTempl
// Look up property name if needed. // Look up property name if needed.
if (Game() >= eEchoesDemo && !IsRootParent() && !IsIntrinsic() && !mpParent->IsAtomic() && !IsArrayArchetype()) if (Game() >= eEchoesDemo && !IsRootParent() && !IsIntrinsic() && !mpParent->IsAtomic() && !IsArrayArchetype())
{ {
mName = CMasterTemplate::PropertyName(mID); mName = CGameTemplate::PropertyName(mID);
} }
// Set any fields dependent on the parent... // Set any fields dependent on the parent...
@ -190,7 +190,7 @@ void IPropertyNew::Initialize(IPropertyNew* pInParent, CScriptTemplate* pInTempl
for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
{ {
IPropertyNew* pChild = mChildren[ChildIdx]; IProperty* pChild = mChildren[ChildIdx];
// update offset and round up to the child's alignment // update offset and round up to the child's alignment
if (ChildIdx > 0) if (ChildIdx > 0)
@ -207,7 +207,7 @@ void IPropertyNew::Initialize(IPropertyNew* pInParent, CScriptTemplate* pInTempl
} }
} }
void* IPropertyNew::RawValuePtr(void* pData) const void* IProperty::RawValuePtr(void* pData) const
{ {
// For array archetypes, the caller needs to provide the pointer to the correct array item // For array archetypes, the caller needs to provide the pointer to the correct array item
// Array archetypes can't store their index in the array so it's impossible to determine the correct pointer. // Array archetypes can't store their index in the array so it's impossible to determine the correct pointer.
@ -216,7 +216,7 @@ void* IPropertyNew::RawValuePtr(void* pData) const
return pValuePtr; return pValuePtr;
} }
IPropertyNew* IPropertyNew::ChildByID(u32 ID) const IProperty* IProperty::ChildByID(u32 ID) const
{ {
for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++) for (u32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
{ {
@ -227,7 +227,7 @@ IPropertyNew* IPropertyNew::ChildByID(u32 ID) const
return nullptr; return nullptr;
} }
IPropertyNew* IPropertyNew::ChildByIDString(const TIDString& rkIdString) IProperty* IProperty::ChildByIDString(const TIDString& rkIdString)
{ {
// String must contain at least one ID! // String must contain at least one ID!
// some ID strings are formatted with 8 characters and some with 2 (plus the beginning "0x") // some ID strings are formatted with 8 characters and some with 2 (plus the beginning "0x")
@ -246,7 +246,7 @@ IPropertyNew* IPropertyNew::ChildByIDString(const TIDString& rkIdString)
return nullptr; return nullptr;
} }
IPropertyNew* pNextChild = ChildByID(NextChildID); IProperty* pNextChild = ChildByID(NextChildID);
// Check if we need to recurse // Check if we need to recurse
if (IDEndPos != -1) if (IDEndPos != -1)
@ -259,14 +259,14 @@ IPropertyNew* IPropertyNew::ChildByIDString(const TIDString& rkIdString)
} }
} }
bool IPropertyNew::ShouldCook(void*pPropertyData) const bool IProperty::ShouldCook(void*pPropertyData) const
{ {
switch (mCookPreference) switch (mCookPreference)
{ {
case ECookPreferenceNew::Always: case ECookPreference::Always:
return true; return true;
case ECookPreferenceNew::Never: case ECookPreference::Never:
return false; return false;
default: default:
@ -274,28 +274,28 @@ bool IPropertyNew::ShouldCook(void*pPropertyData) const
} }
} }
void IPropertyNew::SetName(const TString& rkNewName) void IProperty::SetName(const TString& rkNewName)
{ {
mName = rkNewName; mName = rkNewName;
mFlags.ClearFlag(EPropertyFlag::HasCachedNameCheck); mFlags.ClearFlag(EPropertyFlag::HasCachedNameCheck);
} }
void IPropertyNew::SetDescription(const TString& rkNewDescription) void IProperty::SetDescription(const TString& rkNewDescription)
{ {
mDescription = rkNewDescription; mDescription = rkNewDescription;
} }
void IPropertyNew::SetSuffix(const TString& rkNewSuffix) void IProperty::SetSuffix(const TString& rkNewSuffix)
{ {
mSuffix = rkNewSuffix; mSuffix = rkNewSuffix;
} }
void IPropertyNew::SetPropertyFlags(FPropertyFlags FlagsToSet) void IProperty::SetPropertyFlags(FPropertyFlags FlagsToSet)
{ {
mFlags |= FlagsToSet; mFlags |= FlagsToSet;
} }
bool IPropertyNew::HasAccurateName() bool IProperty::HasAccurateName()
{ {
// Exceptions for the three hardcoded 4CC property IDs // Exceptions for the three hardcoded 4CC property IDs
if (mID == FOURCC('XFRM') || mID == FOURCC('INAM') || mID == FOURCC('ACTV')) if (mID == FOURCC('XFRM') || mID == FOURCC('INAM') || mID == FOURCC('ACTV'))
@ -330,39 +330,39 @@ bool IPropertyNew::HasAccurateName()
} }
/** IPropertyNew Accessors */ /** IPropertyNew Accessors */
EGame IPropertyNew::Game() const EGame IProperty::Game() const
{ {
return mGame; return mGame;
} }
IPropertyNew* IPropertyNew::Create(EPropertyTypeNew Type, IProperty* IProperty::Create(EPropertyType Type,
EGame Game) EGame Game)
{ {
IPropertyNew* pOut = nullptr; IProperty* pOut = nullptr;
switch (Type) switch (Type)
{ {
case EPropertyTypeNew::Bool: pOut = new CBoolProperty(Game); break; case EPropertyType::Bool: pOut = new CBoolProperty(Game); break;
case EPropertyTypeNew::Byte: pOut = new CByteProperty(Game); break; case EPropertyType::Byte: pOut = new CByteProperty(Game); break;
case EPropertyTypeNew::Short: pOut = new CShortProperty(Game); break; case EPropertyType::Short: pOut = new CShortProperty(Game); break;
case EPropertyTypeNew::Int: pOut = new CIntProperty(Game); break; case EPropertyType::Int: pOut = new CIntProperty(Game); break;
case EPropertyTypeNew::Float: pOut = new CFloatProperty(Game); break; case EPropertyType::Float: pOut = new CFloatProperty(Game); break;
case EPropertyTypeNew::Choice: pOut = new CChoiceProperty(Game); break; case EPropertyType::Choice: pOut = new CChoiceProperty(Game); break;
case EPropertyTypeNew::Enum: pOut = new CEnumProperty(Game); break; case EPropertyType::Enum: pOut = new CEnumProperty(Game); break;
case EPropertyTypeNew::Flags: pOut = new CFlagsProperty(Game); break; case EPropertyType::Flags: pOut = new CFlagsProperty(Game); break;
case EPropertyTypeNew::String: pOut = new CStringProperty(Game); break; case EPropertyType::String: pOut = new CStringProperty(Game); break;
case EPropertyTypeNew::Vector: pOut = new CVectorProperty(Game); break; case EPropertyType::Vector: pOut = new CVectorProperty(Game); break;
case EPropertyTypeNew::Color: pOut = new CColorProperty(Game); break; case EPropertyType::Color: pOut = new CColorProperty(Game); break;
case EPropertyTypeNew::Asset: pOut = new CAssetProperty(Game); break; case EPropertyType::Asset: pOut = new CAssetProperty(Game); break;
case EPropertyTypeNew::Sound: pOut = new CSoundProperty(Game); break; case EPropertyType::Sound: pOut = new CSoundProperty(Game); break;
case EPropertyTypeNew::Animation: pOut = new CAnimationProperty(Game); break; case EPropertyType::Animation: pOut = new CAnimationProperty(Game); break;
case EPropertyTypeNew::AnimationSet: pOut = new CAnimationSetProperty(Game); break; case EPropertyType::AnimationSet: pOut = new CAnimationSetProperty(Game); break;
case EPropertyTypeNew::Sequence: pOut = new CSequenceProperty(Game); break; case EPropertyType::Sequence: pOut = new CSequenceProperty(Game); break;
case EPropertyTypeNew::Spline: pOut = new CSplineProperty(Game); break; case EPropertyType::Spline: pOut = new CSplineProperty(Game); break;
case EPropertyTypeNew::Guid: pOut = new CGuidProperty(Game); break; case EPropertyType::Guid: pOut = new CGuidProperty(Game); break;
case EPropertyTypeNew::Pointer: pOut = new CPointerProperty(Game); break; case EPropertyType::Pointer: pOut = new CPointerProperty(Game); break;
case EPropertyTypeNew::Struct: pOut = new CStructPropertyNew(Game); break; case EPropertyType::Struct: pOut = new CStructProperty(Game); break;
case EPropertyTypeNew::Array: pOut = new CArrayProperty(Game); break; case EPropertyType::Array: pOut = new CArrayProperty(Game); break;
} }
// If this assertion fails, then there is an unhandled type! // If this assertion fails, then there is an unhandled type!
@ -370,28 +370,28 @@ IPropertyNew* IPropertyNew::Create(EPropertyTypeNew Type,
return pOut; return pOut;
} }
IPropertyNew* IPropertyNew::CreateCopy(IPropertyNew* pArchetype) IProperty* IProperty::CreateCopy(IProperty* pArchetype)
{ {
IPropertyNew* pOut = Create(pArchetype->Type(), pArchetype->mGame); IProperty* pOut = Create(pArchetype->Type(), pArchetype->mGame);
pOut->InitFromArchetype(pArchetype); pOut->InitFromArchetype(pArchetype);
pArchetype->mSubInstances.push_back(pOut); pArchetype->mSubInstances.push_back(pOut);
return pOut; return pOut;
} }
IPropertyNew* IPropertyNew::CreateIntrinsic(EPropertyTypeNew Type, IProperty* IProperty::CreateIntrinsic(EPropertyType Type,
EGame Game, EGame Game,
u32 Offset, u32 Offset,
const TString& rkName) const TString& rkName)
{ {
IPropertyNew* pOut = Create(Type, Game); IProperty* pOut = Create(Type, Game);
pOut->mFlags |= EPropertyFlag::IsIntrinsic; pOut->mFlags |= EPropertyFlag::IsIntrinsic;
pOut->SetName(rkName); pOut->SetName(rkName);
pOut->Initialize(nullptr, nullptr, Offset); pOut->Initialize(nullptr, nullptr, Offset);
return pOut; return pOut;
} }
IPropertyNew* IPropertyNew::CreateIntrinsic(EPropertyTypeNew Type, IProperty* IProperty::CreateIntrinsic(EPropertyType Type,
IPropertyNew* pParent, IProperty* pParent,
u32 Offset, u32 Offset,
const TString& rkName) const TString& rkName)
{ {
@ -399,7 +399,7 @@ IPropertyNew* IPropertyNew::CreateIntrinsic(EPropertyTypeNew Type,
// If you are creating a root property, call the other overload takes an EGame instead of a parent. // If you are creating a root property, call the other overload takes an EGame instead of a parent.
ASSERT(pParent != nullptr); ASSERT(pParent != nullptr);
IPropertyNew* pOut = Create(Type, pParent->mGame); IProperty* pOut = Create(Type, pParent->mGame);
pOut->mFlags |= EPropertyFlag::IsIntrinsic; pOut->mFlags |= EPropertyFlag::IsIntrinsic;
pOut->SetName(rkName); pOut->SetName(rkName);
pOut->Initialize(pParent, nullptr, Offset); pOut->Initialize(pParent, nullptr, Offset);
@ -407,7 +407,7 @@ IPropertyNew* IPropertyNew::CreateIntrinsic(EPropertyTypeNew Type,
return pOut; return pOut;
} }
IPropertyNew* IPropertyNew::ArchiveConstructor(EPropertyTypeNew Type, IProperty* IProperty::ArchiveConstructor(EPropertyType Type,
const IArchive& Arc) const IArchive& Arc)
{ {
return Create(Type, Arc.Game()); return Create(Type, Arc.Game());

View File

@ -1,5 +1,5 @@
#ifndef IPROPERTYNEW_H #ifndef IPROPERTY_H
#define IPROPERTYNEW_H #define IPROPERTY_H
#include "Core/Resource/Animation/CAnimationParameters.h" #include "Core/Resource/Animation/CAnimationParameters.h"
#include <Common/Common.h> #include <Common/Common.h>
@ -9,9 +9,9 @@
#include <memory> #include <memory>
/** Forward declares */ /** Forward declares */
class CMasterTemplate; class CGameTemplate;
class CScriptTemplate; class CScriptTemplate;
class CStructPropertyNew; class CStructProperty;
/** Typedefs */ /** Typedefs */
typedef TString TIDString; typedef TString TIDString;
@ -42,7 +42,7 @@ enum class EPropertyFlag : u32
DECLARE_FLAGS_ENUMCLASS(EPropertyFlag, FPropertyFlags) DECLARE_FLAGS_ENUMCLASS(EPropertyFlag, FPropertyFlags)
/** Property type */ /** Property type */
enum class EPropertyTypeNew enum class EPropertyType
{ {
Bool = FOURCC('BOOL'), Bool = FOURCC('BOOL'),
Byte = FOURCC('BYTE'), Byte = FOURCC('BYTE'),
@ -68,38 +68,38 @@ enum class EPropertyTypeNew
Invalid = FOURCC('INVD') Invalid = FOURCC('INVD')
}; };
inline const char* PropEnumToHashableTypeName(EPropertyTypeNew Type) inline const char* PropEnumToHashableTypeName(EPropertyType Type)
{ {
switch (Type) switch (Type)
{ {
// these names are required to generate accurate property ID hashes // these names are required to generate accurate property ID hashes
case EPropertyTypeNew::Bool: return "bool"; case EPropertyType::Bool: return "bool";
case EPropertyTypeNew::Int: return "int"; case EPropertyType::Int: return "int";
case EPropertyTypeNew::Float: return "float"; case EPropertyType::Float: return "float";
case EPropertyTypeNew::Choice: return "choice"; case EPropertyType::Choice: return "choice";
case EPropertyTypeNew::Enum: return "enum"; case EPropertyType::Enum: return "enum";
case EPropertyTypeNew::Flags: return "Flags"; case EPropertyType::Flags: return "Flags";
case EPropertyTypeNew::String: return "string"; case EPropertyType::String: return "string";
case EPropertyTypeNew::Vector: return "Vector"; case EPropertyType::Vector: return "Vector";
case EPropertyTypeNew::Color: return "Color"; case EPropertyType::Color: return "Color";
case EPropertyTypeNew::Asset: return "asset"; case EPropertyType::Asset: return "asset";
case EPropertyTypeNew::Sound: return "sound"; case EPropertyType::Sound: return "sound";
case EPropertyTypeNew::Spline: return "spline"; case EPropertyType::Spline: return "spline";
case EPropertyTypeNew::Guid: return "guid"; case EPropertyType::Guid: return "guid";
// unknown hashable types - used in hashes but these names are inaccurate // unknown hashable types - used in hashes but these names are inaccurate
case EPropertyTypeNew::Animation: return "animation"; case EPropertyType::Animation: return "animation";
case EPropertyTypeNew::Sequence: return "sequence"; case EPropertyType::Sequence: return "sequence";
// non hashable types - not used in ID hashes but still displayed on the UI // non hashable types - not used in ID hashes but still displayed on the UI
case EPropertyTypeNew::Byte: return "byte"; case EPropertyType::Byte: return "byte";
case EPropertyTypeNew::Short: return "short"; case EPropertyType::Short: return "short";
case EPropertyTypeNew::Array: return "array"; case EPropertyType::Array: return "array";
// fallback // fallback
default: return ""; default: return "";
} }
} }
/** Enum that describes when/how properties should be cooked out */ /** Enum that describes when/how properties should be cooked out */
enum class ECookPreferenceNew enum class ECookPreference
{ {
Default, Default,
Always, Always,
@ -107,7 +107,7 @@ enum class ECookPreferenceNew
}; };
/** New property class */ /** New property class */
class IPropertyNew class IProperty
{ {
friend class CTemplateLoader; friend class CTemplateLoader;
friend class CPropertyFactory; friend class CPropertyFactory;
@ -117,21 +117,21 @@ protected:
FPropertyFlags mFlags; FPropertyFlags mFlags;
/** Parent property */ /** Parent property */
IPropertyNew* mpParent; IProperty* mpParent;
/** Pointer parent; if non-null, this parent needs to be dereferenced to access the correct /** Pointer parent; if non-null, this parent needs to be dereferenced to access the correct
* memory region that our property data is stored in */ * memory region that our property data is stored in */
IPropertyNew* mpPointerParent; IProperty* mpPointerParent;
/** Archetype property; source property that we copied metadata from */ /** Archetype property; source property that we copied metadata from */
IPropertyNew* mpArchetype; IProperty* mpArchetype;
/** Sub-instances of archetype properties. For non-archetypes, will be empty. /** Sub-instances of archetype properties. For non-archetypes, will be empty.
* @todo this really oughta be a linked list */ * @todo this really oughta be a linked list */
std::vector<IPropertyNew*> mSubInstances; std::vector<IProperty*> mSubInstances;
/** Child properties; these appear underneath this property on the UI */ /** Child properties; these appear underneath this property on the UI */
std::vector<IPropertyNew*> mChildren; std::vector<IProperty*> mChildren;
/** Game this property belongs to */ /** Game this property belongs to */
EGame mGame; EGame mGame;
@ -149,7 +149,7 @@ protected:
TString mName; TString mName;
TString mDescription; TString mDescription;
TString mSuffix; TString mSuffix;
ECookPreferenceNew mCookPreference; ECookPreference mCookPreference;
/** Min/max allowed version number. These numbers correspond to the game's internal build number. /** Min/max allowed version number. These numbers correspond to the game's internal build number.
* This is not used yet but in the future it can be used to configure certain properties to only * This is not used yet but in the future it can be used to configure certain properties to only
@ -159,14 +159,14 @@ protected:
float mMaxVersion; float mMaxVersion;
/** Private constructor - use static methods to instantiate */ /** Private constructor - use static methods to instantiate */
IPropertyNew(EGame Game); IProperty(EGame Game);
void _ClearChildren(); void _ClearChildren();
public: public:
virtual ~IPropertyNew(); virtual ~IProperty();
/** Interface */ /** Interface */
virtual EPropertyTypeNew Type() const = 0; virtual EPropertyType Type() const = 0;
virtual u32 DataSize() const = 0; virtual u32 DataSize() const = 0;
virtual u32 DataAlignment() const = 0; virtual u32 DataAlignment() const = 0;
virtual void Construct(void* pData) const = 0; virtual void Construct(void* pData) const = 0;
@ -183,15 +183,15 @@ public:
virtual const char* HashableTypeName() const; virtual const char* HashableTypeName() const;
virtual void* GetChildDataPointer(void* pPropertyData) const; virtual void* GetChildDataPointer(void* pPropertyData) const;
virtual void Serialize(IArchive& rArc); virtual void Serialize(IArchive& rArc);
virtual void InitFromArchetype(IPropertyNew* pOther); virtual void InitFromArchetype(IProperty* pOther);
virtual bool ShouldSerialize() const; virtual bool ShouldSerialize() const;
virtual TString GetTemplateFileName(); virtual TString GetTemplateFileName();
/** Utility methods */ /** Utility methods */
void Initialize(IPropertyNew* pInParent, CScriptTemplate* pInTemplate, u32 InOffset); void Initialize(IProperty* pInParent, CScriptTemplate* pInTemplate, u32 InOffset);
void* RawValuePtr(void* pData) const; void* RawValuePtr(void* pData) const;
IPropertyNew* ChildByID(u32 ID) const; IProperty* ChildByID(u32 ID) const;
IPropertyNew* ChildByIDString(const TIDString& rkIdString); IProperty* ChildByIDString(const TIDString& rkIdString);
bool ShouldCook(void* pPropertyData) const; bool ShouldCook(void* pPropertyData) const;
void SetName(const TString& rkNewName); void SetName(const TString& rkNewName);
void SetDescription(const TString& rkNewDescription); void SetDescription(const TString& rkNewDescription);
@ -201,12 +201,12 @@ public:
/** Accessors */ /** Accessors */
EGame Game() const; EGame Game() const;
inline ECookPreferenceNew CookPreference() const; inline ECookPreference CookPreference() const;
inline u32 NumChildren() const; inline u32 NumChildren() const;
inline IPropertyNew* ChildByIndex(u32 ChildIndex) const; inline IProperty* ChildByIndex(u32 ChildIndex) const;
inline IPropertyNew* Parent() const; inline IProperty* Parent() const;
inline IPropertyNew* RootParent(); inline IProperty* RootParent();
inline IPropertyNew* Archetype() const; inline IProperty* Archetype() const;
inline CScriptTemplate* ScriptTemplate() const; inline CScriptTemplate* ScriptTemplate() const;
inline TString Name() const; inline TString Name() const;
inline TString Description() const; inline TString Description() const;
@ -222,50 +222,50 @@ public:
inline bool IsRootParent() const { return mpParent == nullptr; } inline bool IsRootParent() const { return mpParent == nullptr; }
/** Create */ /** Create */
static IPropertyNew* Create(EPropertyTypeNew Type, static IProperty* Create(EPropertyType Type,
EGame Game); EGame Game);
static IPropertyNew* CreateCopy(IPropertyNew* pArchetype); static IProperty* CreateCopy(IProperty* pArchetype);
static IPropertyNew* CreateIntrinsic(EPropertyTypeNew Type, static IProperty* CreateIntrinsic(EPropertyType Type,
EGame Game, EGame Game,
u32 Offset, u32 Offset,
const TString& rkName); const TString& rkName);
static IPropertyNew* CreateIntrinsic(EPropertyTypeNew Type, static IProperty* CreateIntrinsic(EPropertyType Type,
IPropertyNew* pParent, IProperty* pParent,
u32 Offset, u32 Offset,
const TString& rkName); const TString& rkName);
static IPropertyNew* ArchiveConstructor(EPropertyTypeNew Type, static IProperty* ArchiveConstructor(EPropertyType Type,
const IArchive& Arc); const IArchive& Arc);
}; };
inline ECookPreferenceNew IPropertyNew::CookPreference() const inline ECookPreference IProperty::CookPreference() const
{ {
return mCookPreference; return mCookPreference;
} }
inline u32 IPropertyNew::NumChildren() const inline u32 IProperty::NumChildren() const
{ {
return mChildren.size(); return mChildren.size();
} }
inline IPropertyNew* IPropertyNew::ChildByIndex(u32 ChildIndex) const inline IProperty* IProperty::ChildByIndex(u32 ChildIndex) const
{ {
ASSERT(ChildIndex >= 0 && ChildIndex < mChildren.size()); ASSERT(ChildIndex >= 0 && ChildIndex < mChildren.size());
return mChildren[ChildIndex]; return mChildren[ChildIndex];
} }
inline IPropertyNew* IPropertyNew::Parent() const inline IProperty* IProperty::Parent() const
{ {
return mpParent; return mpParent;
} }
inline IPropertyNew* IPropertyNew::RootParent() inline IProperty* IProperty::RootParent()
{ {
IPropertyNew* pParent = Parent(); IProperty* pParent = Parent();
IPropertyNew* pOut = this; IProperty* pOut = this;
while (pParent) while (pParent)
{ {
@ -276,32 +276,32 @@ inline IPropertyNew* IPropertyNew::RootParent()
return pOut; return pOut;
} }
inline IPropertyNew* IPropertyNew::Archetype() const inline IProperty* IProperty::Archetype() const
{ {
return mpArchetype; return mpArchetype;
} }
inline CScriptTemplate* IPropertyNew::ScriptTemplate() const inline CScriptTemplate* IProperty::ScriptTemplate() const
{ {
return mpScriptTemplate; return mpScriptTemplate;
} }
inline TString IPropertyNew::Name() const inline TString IProperty::Name() const
{ {
return mName; return mName;
} }
inline TString IPropertyNew::Description() const inline TString IProperty::Description() const
{ {
return mDescription; return mDescription;
} }
inline TString IPropertyNew::Suffix() const inline TString IProperty::Suffix() const
{ {
return mSuffix; return mSuffix;
} }
inline TString IPropertyNew::IDString(bool FullyQualified) const inline TString IProperty::IDString(bool FullyQualified) const
{ {
if (FullyQualified && mpParent != nullptr && mpParent->Parent() != nullptr) if (FullyQualified && mpParent != nullptr && mpParent->Parent() != nullptr)
return mpParent->IDString(FullyQualified) + ":" + TString::HexString(mID); return mpParent->IDString(FullyQualified) + ":" + TString::HexString(mID);
@ -309,20 +309,20 @@ inline TString IPropertyNew::IDString(bool FullyQualified) const
return TString::HexString(mID); return TString::HexString(mID);
} }
inline u32 IPropertyNew::Offset() const inline u32 IProperty::Offset() const
{ {
return mOffset; return mOffset;
} }
inline u32 IPropertyNew::ID() const inline u32 IProperty::ID() const
{ {
return mID; return mID;
} }
template<typename PropType, EPropertyTypeNew PropEnum> template<typename PropType, EPropertyType PropEnum>
class TTypedPropertyNew : public IPropertyNew class TTypedProperty : public IProperty
{ {
friend class IPropertyNew; friend class IProperty;
friend class CTemplateLoader; friend class CTemplateLoader;
public: public:
typedef PropType ValueType; typedef PropType ValueType;
@ -330,14 +330,14 @@ public:
protected: protected:
PropType mDefaultValue; PropType mDefaultValue;
TTypedPropertyNew(EGame Game) TTypedProperty(EGame Game)
: IPropertyNew(Game) : IProperty(Game)
{ {
memset(&mDefaultValue, 0, sizeof(PropType)); memset(&mDefaultValue, 0, sizeof(PropType));
} }
public: public:
virtual EPropertyTypeNew Type() const { return PropEnum; } virtual EPropertyType Type() const { return PropEnum; }
virtual u32 DataSize() const { return sizeof(PropType); } virtual u32 DataSize() const { return sizeof(PropType); }
virtual u32 DataAlignment() const { return alignof(PropType); } virtual u32 DataAlignment() const { return alignof(PropType); }
virtual void Construct(void* pData) const { new(ValuePtr(pData)) PropType(mDefaultValue); } virtual void Construct(void* pData) const { new(ValuePtr(pData)) PropType(mDefaultValue); }
@ -347,10 +347,10 @@ public:
virtual bool CanHaveDefault() const { return true; } virtual bool CanHaveDefault() const { return true; }
virtual void InitFromArchetype(IPropertyNew* pOther) virtual void InitFromArchetype(IProperty* pOther)
{ {
IPropertyNew::InitFromArchetype(pOther); IProperty::InitFromArchetype(pOther);
mDefaultValue = static_cast<TTypedPropertyNew*>(pOther)->mDefaultValue; mDefaultValue = static_cast<TTypedProperty*>(pOther)->mDefaultValue;
} }
inline PropType* ValuePtr(void* pData) const inline PropType* ValuePtr(void* pData) const
@ -378,21 +378,21 @@ public:
mDefaultValue = kInDefaultValue; mDefaultValue = kInDefaultValue;
} }
inline static EPropertyTypeNew StaticType() { return PropEnum; } inline static EPropertyType StaticType() { return PropEnum; }
}; };
template<typename PropType, EPropertyTypeNew PropEnum> template<typename PropType, EPropertyType PropEnum>
class TSerializeableTypedProperty : public TTypedPropertyNew<PropType, PropEnum> class TSerializeableTypedProperty : public TTypedProperty<PropType, PropEnum>
{ {
protected: protected:
TSerializeableTypedProperty(EGame Game) TSerializeableTypedProperty(EGame Game)
: TTypedPropertyNew(Game) : TTypedProperty(Game)
{} {}
public: public:
virtual void Serialize(IArchive& rArc) virtual void Serialize(IArchive& rArc)
{ {
TTypedPropertyNew::Serialize(rArc); TTypedProperty::Serialize(rArc);
TSerializeableTypedProperty* pArchetype = static_cast<TSerializeableTypedProperty*>(mpArchetype); TSerializeableTypedProperty* pArchetype = static_cast<TSerializeableTypedProperty*>(mpArchetype);
// Determine if default value should be serialized as optional. // Determine if default value should be serialized as optional.
@ -408,13 +408,13 @@ public:
{ {
switch (Type()) switch (Type())
{ {
case EPropertyTypeNew::String: case EPropertyType::String:
case EPropertyTypeNew::Asset: case EPropertyType::Asset:
case EPropertyTypeNew::Animation: case EPropertyType::Animation:
case EPropertyTypeNew::AnimationSet: case EPropertyType::AnimationSet:
case EPropertyTypeNew::Sequence: case EPropertyType::Sequence:
case EPropertyTypeNew::Spline: case EPropertyType::Spline:
case EPropertyTypeNew::Guid: case EPropertyType::Guid:
MakeOptional = true; MakeOptional = true;
break; break;
} }
@ -429,9 +429,9 @@ public:
virtual bool ShouldSerialize() const virtual bool ShouldSerialize() const
{ {
TTypedPropertyNew* pArchetype = static_cast<TTypedPropertyNew*>(mpArchetype); TTypedProperty* pArchetype = static_cast<TTypedProperty*>(mpArchetype);
return TTypedPropertyNew::ShouldSerialize() || return TTypedProperty::ShouldSerialize() ||
!(mDefaultValue == pArchetype->DefaultValue()); !(mDefaultValue == pArchetype->DefaultValue());
} }
@ -442,17 +442,17 @@ public:
} }
}; };
template<typename PropType, EPropertyTypeNew PropEnum> template<typename PropType, EPropertyType PropEnum>
class TNumericalPropertyNew : public TSerializeableTypedProperty<PropType, PropEnum> class TNumericalProperty : public TSerializeableTypedProperty<PropType, PropEnum>
{ {
friend class IPropertyNew; friend class IProperty;
friend class CTemplateLoader; friend class CTemplateLoader;
protected: protected:
PropType mMinValue; PropType mMinValue;
PropType mMaxValue; PropType mMaxValue;
TNumericalPropertyNew(EGame Game) TNumericalProperty(EGame Game)
: TSerializeableTypedProperty(Game) : TSerializeableTypedProperty(Game)
, mMinValue( -1 ) , mMinValue( -1 )
, mMaxValue( -1 ) , mMaxValue( -1 )
@ -462,7 +462,7 @@ public:
virtual void Serialize(IArchive& rArc) virtual void Serialize(IArchive& rArc)
{ {
TSerializeableTypedProperty::Serialize(rArc); TSerializeableTypedProperty::Serialize(rArc);
TNumericalPropertyNew* pArchetype = static_cast<TNumericalPropertyNew*>(mpArchetype); TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(mpArchetype);
rArc << SerialParameter("Min", mMinValue, SH_Optional, pArchetype ? pArchetype->mMinValue : (PropType) -1) rArc << SerialParameter("Min", mMinValue, SH_Optional, pArchetype ? pArchetype->mMinValue : (PropType) -1)
<< SerialParameter("Max", mMaxValue, SH_Optional, pArchetype ? pArchetype->mMaxValue : (PropType) -1); << SerialParameter("Max", mMaxValue, SH_Optional, pArchetype ? pArchetype->mMaxValue : (PropType) -1);
@ -470,16 +470,16 @@ public:
virtual bool ShouldSerialize() const virtual bool ShouldSerialize() const
{ {
TNumericalPropertyNew* pArchetype = static_cast<TNumericalPropertyNew*>(mpArchetype); TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(mpArchetype);
return TSerializeableTypedProperty::ShouldSerialize() || return TSerializeableTypedProperty::ShouldSerialize() ||
mMinValue != pArchetype->mMinValue || mMinValue != pArchetype->mMinValue ||
mMaxValue != pArchetype->mMaxValue; mMaxValue != pArchetype->mMaxValue;
} }
virtual void InitFromArchetype(IPropertyNew* pOther) virtual void InitFromArchetype(IProperty* pOther)
{ {
TSerializeableTypedProperty::InitFromArchetype(pOther); TSerializeableTypedProperty::InitFromArchetype(pOther);
TNumericalPropertyNew* pCastOther = static_cast<TNumericalPropertyNew*>(pOther); TNumericalProperty* pCastOther = static_cast<TNumericalProperty*>(pOther);
mMinValue = pCastOther->mMinValue; mMinValue = pCastOther->mMinValue;
mMaxValue = pCastOther->mMaxValue; mMaxValue = pCastOther->mMaxValue;
} }
@ -498,7 +498,7 @@ public:
/** Property casting with dynamic type checking */ /** Property casting with dynamic type checking */
template<class PropertyClass> template<class PropertyClass>
inline PropertyClass* TPropCast(IPropertyNew* pProperty) inline PropertyClass* TPropCast(IProperty* pProperty)
{ {
if (pProperty && pProperty->Type() == PropertyClass::StaticType()) if (pProperty && pProperty->Type() == PropertyClass::StaticType())
{ {
@ -510,4 +510,4 @@ inline PropertyClass* TPropCast(IPropertyNew* pProperty)
} }
} }
#endif // IPROPERTYNEW_H #endif // IPROPERTY_H

View File

@ -37,7 +37,7 @@ public:
: mpPropertyData(nullptr), mpProperty(nullptr) : mpPropertyData(nullptr), mpProperty(nullptr)
{} {}
explicit TPropertyRef(void* pInData, IPropertyNew* pInProperty) explicit TPropertyRef(void* pInData, IProperty* pInProperty)
: mpPropertyData(pInData), mpProperty( TPropCast<PropertyClass>(pInProperty) ) : mpPropertyData(pInData), mpProperty( TPropCast<PropertyClass>(pInProperty) )
{ {
} }
@ -60,12 +60,12 @@ public:
return Get(); return Get();
} }
inline bool operator==(IPropertyNew* pProperty) const inline bool operator==(IProperty* pProperty) const
{ {
return mpProperty == pProperty; return mpProperty == pProperty;
} }
friend bool operator==(IPropertyNew* pLeft, const TPropertyRef& kRight) friend bool operator==(IProperty* pLeft, const TPropertyRef& kRight)
{ {
return pLeft == kRight.Property(); return pLeft == kRight.Property();
} }
@ -89,7 +89,7 @@ typedef TPropertyRef<CSequenceProperty> CSequenceRef;
typedef TPropertyRef<CSplineProperty> CSplineRef; typedef TPropertyRef<CSplineProperty> CSplineRef;
typedef TPropertyRef<CGuidProperty> CGuidRef; typedef TPropertyRef<CGuidProperty> CGuidRef;
typedef TPropertyRef<CPointerProperty> CPointerRef; typedef TPropertyRef<CPointerProperty> CPointerRef;
typedef TPropertyRef<CStructPropertyNew> CStructRef; typedef TPropertyRef<CStructProperty> CStructRef;
typedef TPropertyRef<CArrayProperty> CArrayRef; typedef TPropertyRef<CArrayProperty> CArrayRef;
/** Special version for enums */ /** Special version for enums */
@ -101,7 +101,7 @@ public:
: TPropertyRef() : TPropertyRef()
{} {}
TEnumRef(void* pInData, IPropertyNew* pInProperty) TEnumRef(void* pInData, IProperty* pInProperty)
: TPropertyRef(pInData, pInProperty) : TPropertyRef(pInData, pInProperty)
{} {}

View File

@ -10,7 +10,7 @@ CScriptAttachNode::CScriptAttachNode(CScene *pScene, const SAttachment& rkAttach
, mAttachType(rkAttachment.AttachType) , mAttachType(rkAttachment.AttachType)
, mLocatorName(rkAttachment.LocatorName) , mLocatorName(rkAttachment.LocatorName)
{ {
CStructPropertyNew* pBaseStruct = pParent->Template()->Properties(); CStructProperty* pBaseStruct = pParent->Template()->Properties();
mpAttachAssetProp = pBaseStruct->ChildByIDString(rkAttachment.AttachProperty); mpAttachAssetProp = pBaseStruct->ChildByIDString(rkAttachment.AttachProperty);
mAttachAssetRef = CAssetRef(pParent->Instance()->PropertyData(), mpAttachAssetProp); mAttachAssetRef = CAssetRef(pParent->Instance()->PropertyData(), mpAttachAssetProp);

View File

@ -5,7 +5,7 @@
#include "Core/Render/CGraphics.h" #include "Core/Render/CGraphics.h"
#include "Core/Render/CRenderer.h" #include "Core/Render/CRenderer.h"
#include "Core/Resource/Animation/CAnimSet.h" #include "Core/Resource/Animation/CAnimSet.h"
#include "Core/Resource/Script/CMasterTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include "Core/Resource/Script/CScriptLayer.h" #include "Core/Resource/Script/CScriptLayer.h"
#include "Core/ScriptExtra/CScriptExtra.h" #include "Core/ScriptExtra/CScriptExtra.h"
#include <Common/AssertMacro.h> #include <Common/AssertMacro.h>
@ -66,7 +66,7 @@ CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScrip
} }
// Fetch LightParameters // Fetch LightParameters
mpLightParameters = new CLightParameters(mpInstance->LightParameters(), mpInstance->MasterTemplate()->Game()); mpLightParameters = new CLightParameters(mpInstance->LightParameters(), mpInstance->GameTemplate()->Game());
SetLightLayerIndex(mpLightParameters->LightLayerIndex()); SetLightLayerIndex(mpLightParameters->LightLayerIndex());
} }

View File

@ -7,7 +7,7 @@
#include <Core/GameProject/CAssetNameMap.h> #include <Core/GameProject/CAssetNameMap.h>
#include <Core/GameProject/CGameExporter.h> #include <Core/GameProject/CGameExporter.h>
#include <Core/GameProject/CGameInfo.h> #include <Core/GameProject/CGameInfo.h>
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
#include <QComboBox> #include <QComboBox>
#include <QDialogButtonBox> #include <QDialogButtonBox>

View File

@ -3,7 +3,6 @@
#include "Editor/Widgets/CCheckableTreeWidgetItem.h" #include "Editor/Widgets/CCheckableTreeWidgetItem.h"
#include "UICommon.h" #include "UICommon.h"
#include <Core/Resource/Cooker/CTemplateWriter.h>
#include <Core/Resource/Factory/CTemplateLoader.h> #include <Core/Resource/Factory/CTemplateLoader.h>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <iterator> #include <iterator>
@ -227,7 +226,7 @@ void CGeneratePropertyNamesDialog::ApplyChanges()
u32 ID = TO_TSTRING( pItem->text(2) ).ToInt32(); u32 ID = TO_TSTRING( pItem->text(2) ).ToInt32();
QString NewName = pItem->text(0); QString NewName = pItem->text(0);
CMasterTemplate::RenameProperty( ID, TO_TSTRING(NewName) ); CGameTemplate::RenameProperty( ID, TO_TSTRING(NewName) );
pItem->setText(3, NewName); pItem->setText(3, NewName);
} }
@ -259,7 +258,7 @@ void CGeneratePropertyNamesDialog::CheckForNewResults()
ColumnText << TO_QSTRING( rkName.Name ) ColumnText << TO_QSTRING( rkName.Name )
<< TO_QSTRING( rkName.Type ) << TO_QSTRING( rkName.Type )
<< TO_QSTRING( TString::HexString(rkName.ID) ) << TO_QSTRING( TString::HexString(rkName.ID) )
<< TO_QSTRING( CMasterTemplate::PropertyName(rkName.ID) ); << TO_QSTRING( CGameTemplate::PropertyName(rkName.ID) );
QTreeWidgetItem* pItem = new CCheckableTreeWidgetItem(pTreeWidget, ColumnText); QTreeWidgetItem* pItem = new CCheckableTreeWidgetItem(pTreeWidget, ColumnText);
pItem->setFlags(Qt::ItemIsEnabled | pItem->setFlags(Qt::ItemIsEnabled |

View File

@ -48,7 +48,7 @@ void CPropertyDelegate::SetEditor(CWorldEditor *pEditor)
QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionViewItem& /*rkOption*/, const QModelIndex& rkIndex) const QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionViewItem& /*rkOption*/, const QModelIndex& rkIndex) const
{ {
if (!mpModel) return nullptr; if (!mpModel) return nullptr;
IPropertyNew *pProp = mpModel->PropertyForIndex(rkIndex, false); IProperty *pProp = mpModel->PropertyForIndex(rkIndex, false);
QWidget *pOut = nullptr; QWidget *pOut = nullptr;
if (pProp) if (pProp)
@ -56,7 +56,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
switch (pProp->Type()) switch (pProp->Type())
{ {
case EPropertyTypeNew::Bool: case EPropertyType::Bool:
{ {
QCheckBox *pCheckBox = new QCheckBox(pParent); QCheckBox *pCheckBox = new QCheckBox(pParent);
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool)) CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool))
@ -64,7 +64,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::Short: case EPropertyType::Short:
{ {
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent); WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
pSpinBox->setMinimum(INT16_MIN); pSpinBox->setMinimum(INT16_MIN);
@ -75,7 +75,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::Int: case EPropertyType::Int:
{ {
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent); WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
pSpinBox->setMinimum(INT32_MIN); pSpinBox->setMinimum(INT32_MIN);
@ -86,7 +86,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::Float: case EPropertyType::Float:
{ {
WDraggableSpinBox *pSpinBox = new WDraggableSpinBox(pParent); WDraggableSpinBox *pSpinBox = new WDraggableSpinBox(pParent);
pSpinBox->setSingleStep(0.1); pSpinBox->setSingleStep(0.1);
@ -96,7 +96,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::Color: case EPropertyType::Color:
{ {
WColorPicker *pColorPicker = new WColorPicker(pParent); WColorPicker *pColorPicker = new WColorPicker(pParent);
CONNECT_RELAY(pColorPicker, rkIndex, ColorChanged(QColor)) CONNECT_RELAY(pColorPicker, rkIndex, ColorChanged(QColor))
@ -104,7 +104,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::Sound: case EPropertyType::Sound:
{ {
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent); WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
pSpinBox->setMinimum(-1); pSpinBox->setMinimum(-1);
@ -114,7 +114,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::String: case EPropertyType::String:
{ {
QLineEdit *pLineEdit = new QLineEdit(pParent); QLineEdit *pLineEdit = new QLineEdit(pParent);
CONNECT_RELAY(pLineEdit, rkIndex, textEdited(QString)) CONNECT_RELAY(pLineEdit, rkIndex, textEdited(QString))
@ -122,8 +122,8 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::Enum: case EPropertyType::Enum:
case EPropertyTypeNew::Choice: case EPropertyType::Choice:
{ {
QComboBox *pComboBox = new QComboBox(pParent); QComboBox *pComboBox = new QComboBox(pParent);
CEnumProperty* pEnum = TPropCast<CEnumProperty>(pProp); CEnumProperty* pEnum = TPropCast<CEnumProperty>(pProp);
@ -136,7 +136,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::Asset: case EPropertyType::Asset:
{ {
CResourceSelector *pSelector = new CResourceSelector(pParent); CResourceSelector *pSelector = new CResourceSelector(pParent);
pSelector->SetFrameVisible(false); pSelector->SetFrameVisible(false);
@ -149,7 +149,7 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
break; break;
} }
case EPropertyTypeNew::Array: case EPropertyType::Array:
{ {
// No relay here, would prefer user to be sure of their change before it's reflected on the UI // No relay here, would prefer user to be sure of their change before it's reflected on the UI
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent); WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
@ -166,14 +166,14 @@ QWidget* CPropertyDelegate::createEditor(QWidget *pParent, const QStyleOptionVie
else if (rkIndex.internalId() & 0x80000000) else if (rkIndex.internalId() & 0x80000000)
{ {
pProp = mpModel->PropertyForIndex(rkIndex, true); pProp = mpModel->PropertyForIndex(rkIndex, true);
EPropertyTypeNew Type = pProp->Type(); EPropertyType Type = pProp->Type();
// Handle character // Handle character
if (Type == EPropertyTypeNew::AnimationSet) if (Type == EPropertyType::AnimationSet)
pOut = CreateCharacterEditor(pParent, rkIndex); pOut = CreateCharacterEditor(pParent, rkIndex);
// Handle flags // Handle flags
else if (Type == EPropertyTypeNew::Flags) else if (Type == EPropertyType::Flags)
{ {
QCheckBox *pCheckBox = new QCheckBox(pParent); QCheckBox *pCheckBox = new QCheckBox(pParent);
CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool)) CONNECT_RELAY(pCheckBox, rkIndex, toggled(bool))
@ -199,7 +199,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
if (pEditor) if (pEditor)
{ {
// Set editor data for regular property // Set editor data for regular property
IPropertyNew *pProp = mpModel->PropertyForIndex(rkIndex, false); IProperty *pProp = mpModel->PropertyForIndex(rkIndex, false);
void* pData = mpModel->DataPointerForIndex(rkIndex); void* pData = mpModel->DataPointerForIndex(rkIndex);
if (pProp) if (pProp)
@ -209,7 +209,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
switch (pProp->Type()) switch (pProp->Type())
{ {
case EPropertyTypeNew::Bool: case EPropertyType::Bool:
{ {
QCheckBox *pCheckBox = static_cast<QCheckBox*>(pEditor); QCheckBox *pCheckBox = static_cast<QCheckBox*>(pEditor);
CBoolProperty *pBool = TPropCast<CBoolProperty>(pProp); CBoolProperty *pBool = TPropCast<CBoolProperty>(pProp);
@ -217,7 +217,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::Short: case EPropertyType::Short:
{ {
WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor); WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
@ -230,7 +230,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::Int: case EPropertyType::Int:
{ {
WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor); WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
@ -243,7 +243,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::Sound: case EPropertyType::Sound:
{ {
WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor); WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
@ -256,7 +256,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::Float: case EPropertyType::Float:
{ {
WDraggableSpinBox *pSpinBox = static_cast<WDraggableSpinBox*>(pEditor); WDraggableSpinBox *pSpinBox = static_cast<WDraggableSpinBox*>(pEditor);
@ -269,7 +269,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::Color: case EPropertyType::Color:
{ {
WColorPicker *pColorPicker = static_cast<WColorPicker*>(pEditor); WColorPicker *pColorPicker = static_cast<WColorPicker*>(pEditor);
CColorProperty *pColor = TPropCast<CColorProperty>(pProp); CColorProperty *pColor = TPropCast<CColorProperty>(pProp);
@ -279,7 +279,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::String: case EPropertyType::String:
{ {
QLineEdit *pLineEdit = static_cast<QLineEdit*>(pEditor); QLineEdit *pLineEdit = static_cast<QLineEdit*>(pEditor);
@ -292,8 +292,8 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::Enum: case EPropertyType::Enum:
case EPropertyTypeNew::Choice: case EPropertyType::Choice:
{ {
QComboBox *pComboBox = static_cast<QComboBox*>(pEditor); QComboBox *pComboBox = static_cast<QComboBox*>(pEditor);
CEnumProperty* pEnum = TPropCast<CEnumProperty>(pProp); CEnumProperty* pEnum = TPropCast<CEnumProperty>(pProp);
@ -301,7 +301,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::Asset: case EPropertyType::Asset:
{ {
CResourceSelector *pSelector = static_cast<CResourceSelector*>(pEditor); CResourceSelector *pSelector = static_cast<CResourceSelector*>(pEditor);
CAssetProperty *pAsset = TPropCast<CAssetProperty>(pProp); CAssetProperty *pAsset = TPropCast<CAssetProperty>(pProp);
@ -309,7 +309,7 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
break; break;
} }
case EPropertyTypeNew::Array: case EPropertyType::Array:
{ {
WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor); WIntegralSpinBox *pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
@ -331,10 +331,10 @@ void CPropertyDelegate::setEditorData(QWidget *pEditor, const QModelIndex &rkInd
{ {
pProp = mpModel->PropertyForIndex(rkIndex, true); pProp = mpModel->PropertyForIndex(rkIndex, true);
if (pProp->Type() == EPropertyTypeNew::AnimationSet) if (pProp->Type() == EPropertyType::AnimationSet)
SetCharacterEditorData(pEditor, rkIndex); SetCharacterEditorData(pEditor, rkIndex);
else if (pProp->Type() == EPropertyTypeNew::Flags) else if (pProp->Type() == EPropertyType::Flags)
{ {
QCheckBox *pCheckBox = static_cast<QCheckBox*>(pEditor); QCheckBox *pCheckBox = static_cast<QCheckBox*>(pEditor);
CFlagsProperty* pFlags = TPropCast<CFlagsProperty>(pProp); CFlagsProperty* pFlags = TPropCast<CFlagsProperty>(pProp);
@ -354,17 +354,17 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
if (!pEditor) return; if (!pEditor) return;
IEditPropertyCommand* pCommand = nullptr; IEditPropertyCommand* pCommand = nullptr;
IPropertyNew *pProp = mpModel->PropertyForIndex(rkIndex, true); IProperty *pProp = mpModel->PropertyForIndex(rkIndex, true);
void* pData = mpModel->DataPointerForIndex(rkIndex); void* pData = mpModel->DataPointerForIndex(rkIndex);
if (pProp) if (pProp)
{ {
EPropertyTypeNew Type = pProp->Type(); EPropertyType Type = pProp->Type();
QVector<CScriptObject*> Objects; QVector<CScriptObject*> Objects;
Objects << mpModel->GetScriptObject(); Objects << mpModel->GetScriptObject();
if (Type != EPropertyTypeNew::Array) if (Type != EPropertyType::Array)
{ {
// TODO: support this for non script object properties // TODO: support this for non script object properties
pCommand = new CEditScriptPropertyCommand(pProp, mpEditor, Objects, rkIndex); pCommand = new CEditScriptPropertyCommand(pProp, mpEditor, Objects, rkIndex);
@ -373,10 +373,10 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
// Handle sub-properties of flags and animation sets // Handle sub-properties of flags and animation sets
if (rkIndex.internalId() & 0x80000000) if (rkIndex.internalId() & 0x80000000)
{ {
if (pProp->Type() == EPropertyTypeNew::AnimationSet) if (pProp->Type() == EPropertyType::AnimationSet)
SetCharacterModelData(pEditor, rkIndex); SetCharacterModelData(pEditor, rkIndex);
else if (pProp->Type() == EPropertyTypeNew::Flags) else if (pProp->Type() == EPropertyType::Flags)
{ {
QCheckBox* pCheckBox = static_cast<QCheckBox*>(pEditor); QCheckBox* pCheckBox = static_cast<QCheckBox*>(pEditor);
CFlagsProperty* pFlags = static_cast<CFlagsProperty*>(pProp); CFlagsProperty* pFlags = static_cast<CFlagsProperty*>(pProp);
@ -394,7 +394,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
switch (pProp->Type()) switch (pProp->Type())
{ {
case EPropertyTypeNew::Bool: case EPropertyType::Bool:
{ {
QCheckBox *pCheckBox = static_cast<QCheckBox*>(pEditor); QCheckBox *pCheckBox = static_cast<QCheckBox*>(pEditor);
CBoolProperty* pBool = static_cast<CBoolProperty*>(pProp); CBoolProperty* pBool = static_cast<CBoolProperty*>(pProp);
@ -402,7 +402,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
break; break;
} }
case EPropertyTypeNew::Short: case EPropertyType::Short:
{ {
WIntegralSpinBox* pSpinBox = static_cast<WIntegralSpinBox*>(pEditor); WIntegralSpinBox* pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
CShortProperty* pShort = static_cast<CShortProperty*>(pProp); CShortProperty* pShort = static_cast<CShortProperty*>(pProp);
@ -410,7 +410,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
break; break;
} }
case EPropertyTypeNew::Int: case EPropertyType::Int:
{ {
WIntegralSpinBox* pSpinBox = static_cast<WIntegralSpinBox*>(pEditor); WIntegralSpinBox* pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
CIntProperty* pInt = static_cast<CIntProperty*>(pProp); CIntProperty* pInt = static_cast<CIntProperty*>(pProp);
@ -418,7 +418,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
break; break;
} }
case EPropertyTypeNew::Sound: case EPropertyType::Sound:
{ {
WIntegralSpinBox* pSpinBox = static_cast<WIntegralSpinBox*>(pEditor); WIntegralSpinBox* pSpinBox = static_cast<WIntegralSpinBox*>(pEditor);
CSoundProperty* pSound = static_cast<CSoundProperty*>(pProp); CSoundProperty* pSound = static_cast<CSoundProperty*>(pProp);
@ -426,7 +426,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
break; break;
} }
case EPropertyTypeNew::Float: case EPropertyType::Float:
{ {
WDraggableSpinBox* pSpinBox = static_cast<WDraggableSpinBox*>(pEditor); WDraggableSpinBox* pSpinBox = static_cast<WDraggableSpinBox*>(pEditor);
CFloatProperty* pFloat = static_cast<CFloatProperty*>(pProp); CFloatProperty* pFloat = static_cast<CFloatProperty*>(pProp);
@ -434,7 +434,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
break; break;
} }
case EPropertyTypeNew::Color: case EPropertyType::Color:
{ {
WColorPicker* pColorPicker = static_cast<WColorPicker*>(pEditor); WColorPicker* pColorPicker = static_cast<WColorPicker*>(pEditor);
CColorProperty* pColor = static_cast<CColorProperty*>(pProp); CColorProperty* pColor = static_cast<CColorProperty*>(pProp);
@ -444,7 +444,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
break; break;
} }
case EPropertyTypeNew::String: case EPropertyType::String:
{ {
QLineEdit* pLineEdit = static_cast<QLineEdit*>(pEditor); QLineEdit* pLineEdit = static_cast<QLineEdit*>(pEditor);
CStringProperty* pString = static_cast<CStringProperty*>(pProp); CStringProperty* pString = static_cast<CStringProperty*>(pProp);
@ -452,8 +452,8 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
break; break;
} }
case EPropertyTypeNew::Enum: case EPropertyType::Enum:
case EPropertyTypeNew::Choice: case EPropertyType::Choice:
{ {
QComboBox* pComboBox = static_cast<QComboBox*>(pEditor); QComboBox* pComboBox = static_cast<QComboBox*>(pEditor);
CEnumProperty* pEnum = static_cast<CEnumProperty*>(pProp); CEnumProperty* pEnum = static_cast<CEnumProperty*>(pProp);
@ -461,7 +461,7 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
break; break;
} }
case EPropertyTypeNew::Asset: case EPropertyType::Asset:
{ {
CResourceSelector* pSelector = static_cast<CResourceSelector*>(pEditor); CResourceSelector* pSelector = static_cast<CResourceSelector*>(pEditor);
CResourceEntry* pEntry = pSelector->Entry(); CResourceEntry* pEntry = pSelector->Entry();
@ -504,20 +504,20 @@ void CPropertyDelegate::setModelData(QWidget *pEditor, QAbstractItemModel* /*pMo
// Check for edit in progress // Check for edit in progress
bool DataChanged = pCommand->IsNewDataDifferent(); bool DataChanged = pCommand->IsNewDataDifferent();
if (DataChanged && mInRelayWidgetEdit && (pEditor->hasFocus() || pProp->Type() == EPropertyTypeNew::Color)) if (DataChanged && mInRelayWidgetEdit && (pEditor->hasFocus() || pProp->Type() == EPropertyType::Color))
mEditInProgress = true; mEditInProgress = true;
bool EditWasInProgress = mEditInProgress; bool EditWasInProgress = mEditInProgress;
// Check for edit finished // Check for edit finished
if (!mInRelayWidgetEdit || (!pEditor->hasFocus() && pProp->Type() != EPropertyTypeNew::Color)) if (!mInRelayWidgetEdit || (!pEditor->hasFocus() && pProp->Type() != EPropertyType::Color))
mEditInProgress = false; mEditInProgress = false;
// Push undo command // Push undo command
if (DataChanged || EditWasInProgress) if (DataChanged || EditWasInProgress)
{ {
// Always consider the edit done for bool properties // Always consider the edit done for bool properties
pCommand->SetEditComplete(!mEditInProgress || pProp->Type() == EPropertyTypeNew::Bool); pCommand->SetEditComplete(!mEditInProgress || pProp->Type() == EPropertyType::Bool);
mpEditor->UndoStack()->push(pCommand); mpEditor->UndoStack()->push(pCommand);
} }
@ -549,10 +549,10 @@ QWidget* CPropertyDelegate::CreateCharacterEditor(QWidget *pParent, const QModel
CAnimationParameters Params = pAnimSetProp->Value(mpModel->DataPointerForIndex(rkIndex)); CAnimationParameters Params = pAnimSetProp->Value(mpModel->DataPointerForIndex(rkIndex));
// Determine property type // Determine property type
EPropertyTypeNew Type = DetermineCharacterPropType(Params.Version(), rkIndex); EPropertyType Type = DetermineCharacterPropType(Params.Version(), rkIndex);
// Create widget // Create widget
if (Type == EPropertyTypeNew::Asset) if (Type == EPropertyType::Asset)
{ {
CResourceSelector* pSelector = new CResourceSelector(pParent); CResourceSelector* pSelector = new CResourceSelector(pParent);
pSelector->SetFrameVisible(false); pSelector->SetFrameVisible(false);
@ -566,7 +566,7 @@ QWidget* CPropertyDelegate::CreateCharacterEditor(QWidget *pParent, const QModel
return pSelector; return pSelector;
} }
else if (Type == EPropertyTypeNew::Enum || Type == EPropertyTypeNew::Choice) else if (Type == EPropertyType::Enum || Type == EPropertyType::Choice)
{ {
QComboBox* pComboBox = new QComboBox(pParent); QComboBox* pComboBox = new QComboBox(pParent);
CAnimSet* pAnimSet = Params.AnimSet(); CAnimSet* pAnimSet = Params.AnimSet();
@ -581,7 +581,7 @@ QWidget* CPropertyDelegate::CreateCharacterEditor(QWidget *pParent, const QModel
return pComboBox; return pComboBox;
} }
else if (Type == EPropertyTypeNew::Int) else if (Type == EPropertyType::Int)
{ {
WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent); WIntegralSpinBox *pSpinBox = new WIntegralSpinBox(pParent);
CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int)); CONNECT_RELAY(pSpinBox, rkIndex, valueChanged(int));
@ -595,19 +595,19 @@ void CPropertyDelegate::SetCharacterEditorData(QWidget *pEditor, const QModelInd
{ {
CAnimationSetProperty* pAnimSetProp = TPropCast<CAnimationSetProperty>(mpModel->PropertyForIndex(rkIndex, true)); CAnimationSetProperty* pAnimSetProp = TPropCast<CAnimationSetProperty>(mpModel->PropertyForIndex(rkIndex, true));
CAnimationParameters Params = pAnimSetProp->Value(mpModel->DataPointerForIndex(rkIndex)); CAnimationParameters Params = pAnimSetProp->Value(mpModel->DataPointerForIndex(rkIndex));
EPropertyTypeNew Type = DetermineCharacterPropType(Params.Version(), rkIndex); EPropertyType Type = DetermineCharacterPropType(Params.Version(), rkIndex);
if (Type == EPropertyTypeNew::Asset) if (Type == EPropertyType::Asset)
{ {
static_cast<CResourceSelector*>(pEditor)->SetResource(Params.AnimSet()); static_cast<CResourceSelector*>(pEditor)->SetResource(Params.AnimSet());
} }
else if (Type == EPropertyTypeNew::Enum || Type == EPropertyTypeNew::Choice) else if (Type == EPropertyType::Enum || Type == EPropertyType::Choice)
{ {
static_cast<QComboBox*>(pEditor)->setCurrentIndex(Params.CharacterIndex()); static_cast<QComboBox*>(pEditor)->setCurrentIndex(Params.CharacterIndex());
} }
else if (Type == EPropertyTypeNew::Int && !pEditor->hasFocus()) else if (Type == EPropertyType::Int && !pEditor->hasFocus())
{ {
int UnkIndex = (Params.Version() <= eEchoes ? rkIndex.row() - 2 : rkIndex.row() - 1); int UnkIndex = (Params.Version() <= eEchoes ? rkIndex.row() - 2 : rkIndex.row() - 1);
u32 Value = Params.Unknown(UnkIndex); u32 Value = Params.Unknown(UnkIndex);
@ -619,20 +619,20 @@ void CPropertyDelegate::SetCharacterModelData(QWidget *pEditor, const QModelInde
{ {
CAnimationSetProperty* pAnimSetProp = TPropCast<CAnimationSetProperty>(mpModel->PropertyForIndex(rkIndex, true)); CAnimationSetProperty* pAnimSetProp = TPropCast<CAnimationSetProperty>(mpModel->PropertyForIndex(rkIndex, true));
CAnimationParameters Params = pAnimSetProp->Value(mpModel->DataPointerForIndex(rkIndex)); CAnimationParameters Params = pAnimSetProp->Value(mpModel->DataPointerForIndex(rkIndex));
EPropertyTypeNew Type = DetermineCharacterPropType(Params.Version(), rkIndex); EPropertyType Type = DetermineCharacterPropType(Params.Version(), rkIndex);
if (Type == EPropertyTypeNew::Asset) if (Type == EPropertyType::Asset)
{ {
CResourceEntry *pEntry = static_cast<CResourceSelector*>(pEditor)->Entry(); CResourceEntry *pEntry = static_cast<CResourceSelector*>(pEditor)->Entry();
Params.SetResource( pEntry ? pEntry->ID() : CAssetID::InvalidID(mpEditor->CurrentGame()) ); Params.SetResource( pEntry ? pEntry->ID() : CAssetID::InvalidID(mpEditor->CurrentGame()) );
} }
else if (Type == EPropertyTypeNew::Enum || Type == EPropertyTypeNew::Choice) else if (Type == EPropertyType::Enum || Type == EPropertyType::Choice)
{ {
Params.SetCharIndex( static_cast<QComboBox*>(pEditor)->currentIndex() ); Params.SetCharIndex( static_cast<QComboBox*>(pEditor)->currentIndex() );
} }
else if (Type == EPropertyTypeNew::Int) else if (Type == EPropertyType::Int)
{ {
int UnkIndex = (Params.Version() <= eEchoes ? rkIndex.row() - 2 : rkIndex.row() - 1); int UnkIndex = (Params.Version() <= eEchoes ? rkIndex.row() - 2 : rkIndex.row() - 1);
Params.SetUnknown(UnkIndex, static_cast<WIntegralSpinBox*>(pEditor)->value() ); Params.SetUnknown(UnkIndex, static_cast<WIntegralSpinBox*>(pEditor)->value() );
@ -642,32 +642,32 @@ void CPropertyDelegate::SetCharacterModelData(QWidget *pEditor, const QModelInde
// If we just updated the resource, make sure all the sub-properties of the character are flagged as changed. // If we just updated the resource, make sure all the sub-properties of the character are flagged as changed.
// We want to do this -after- updating the anim params on the property, which is why we have a second type check. // We want to do this -after- updating the anim params on the property, which is why we have a second type check.
if (Type == EPropertyTypeNew::Asset) if (Type == EPropertyType::Asset)
{ {
QModelIndex ParentIndex = rkIndex.parent(); QModelIndex ParentIndex = rkIndex.parent();
mpModel->dataChanged(mpModel->index(1, 1, ParentIndex), mpModel->index(mpModel->rowCount(ParentIndex) - 1, 1, ParentIndex)); mpModel->dataChanged(mpModel->index(1, 1, ParentIndex), mpModel->index(mpModel->rowCount(ParentIndex) - 1, 1, ParentIndex));
} }
} }
EPropertyTypeNew CPropertyDelegate::DetermineCharacterPropType(EGame Game, const QModelIndex& rkIndex) const EPropertyType CPropertyDelegate::DetermineCharacterPropType(EGame Game, const QModelIndex& rkIndex) const
{ {
if (Game <= eEchoes) if (Game <= eEchoes)
{ {
if (rkIndex.row() == 0) return EPropertyTypeNew::Asset; if (rkIndex.row() == 0) return EPropertyType::Asset;
else if (rkIndex.row() == 1) return EPropertyTypeNew::Choice; else if (rkIndex.row() == 1) return EPropertyType::Choice;
else if (rkIndex.row() == 2) return EPropertyTypeNew::Int; else if (rkIndex.row() == 2) return EPropertyType::Int;
} }
else if (Game <= eCorruption) else if (Game <= eCorruption)
{ {
if (rkIndex.row() == 0) return EPropertyTypeNew::Asset; if (rkIndex.row() == 0) return EPropertyType::Asset;
else if (rkIndex.row() == 1) return EPropertyTypeNew::Int; else if (rkIndex.row() == 1) return EPropertyType::Int;
} }
else else
{ {
if (rkIndex.row() == 0) return EPropertyTypeNew::Asset; if (rkIndex.row() == 0) return EPropertyType::Asset;
else if (rkIndex.row() <= 2) return EPropertyTypeNew::Int; else if (rkIndex.row() <= 2) return EPropertyType::Int;
} }
return EPropertyTypeNew::Invalid; return EPropertyType::Invalid;
} }
// ************ PUBLIC SLOTS ************ // ************ PUBLIC SLOTS ************

View File

@ -16,7 +16,7 @@ CPropertyModel::CPropertyModel(QObject *pParent /*= 0*/)
{ {
} }
int CPropertyModel::RecursiveBuildArrays(IPropertyNew* pProperty, int ParentID) int CPropertyModel::RecursiveBuildArrays(IProperty* pProperty, int ParentID)
{ {
// Insert into an unused slot if one exists. Otherwise, append to the end of the array. // Insert into an unused slot if one exists. Otherwise, append to the end of the array.
int MyID = -1; int MyID = -1;
@ -38,7 +38,7 @@ int CPropertyModel::RecursiveBuildArrays(IPropertyNew* pProperty, int ParentID)
int RowNumber = (ParentID >= 0 ? mProperties[ParentID].ChildIDs.size() : 0); int RowNumber = (ParentID >= 0 ? mProperties[ParentID].ChildIDs.size() : 0);
mProperties[MyID].Index = createIndex(RowNumber, 0, MyID); mProperties[MyID].Index = createIndex(RowNumber, 0, MyID);
if (pProperty->Type() == EPropertyTypeNew::Array) if (pProperty->Type() == EPropertyType::Array)
{ {
CArrayProperty* pArray = TPropCast<CArrayProperty>(pProperty); CArrayProperty* pArray = TPropCast<CArrayProperty>(pProperty);
u32 ArrayCount = pArray->ArrayCount(mpPropertyData); u32 ArrayCount = pArray->ArrayCount(mpPropertyData);
@ -70,7 +70,7 @@ int CPropertyModel::RecursiveBuildArrays(IPropertyNew* pProperty, int ParentID)
return MyID; return MyID;
} }
void CPropertyModel::ConfigureIntrinsic(CGameProject* pProject, IPropertyNew* pRootProperty, void* pPropertyData) void CPropertyModel::ConfigureIntrinsic(CGameProject* pProject, IProperty* pRootProperty, void* pPropertyData)
{ {
beginResetModel(); beginResetModel();
@ -89,13 +89,13 @@ void CPropertyModel::ConfigureIntrinsic(CGameProject* pProject, IPropertyNew* pR
endResetModel(); endResetModel();
} }
void CPropertyModel::ConfigureScript(CGameProject* pProject, IPropertyNew* pRootProperty, CScriptObject* pObject) void CPropertyModel::ConfigureScript(CGameProject* pProject, IProperty* pRootProperty, CScriptObject* pObject)
{ {
ConfigureIntrinsic(pProject, pRootProperty, pObject ? pObject->PropertyData() : nullptr); ConfigureIntrinsic(pProject, pRootProperty, pObject ? pObject->PropertyData() : nullptr);
mpObject = pObject; mpObject = pObject;
} }
IPropertyNew* CPropertyModel::PropertyForIndex(const QModelIndex& rkIndex, bool HandleFlaggedIndices) const IProperty* CPropertyModel::PropertyForIndex(const QModelIndex& rkIndex, bool HandleFlaggedIndices) const
{ {
if (!rkIndex.isValid()) return mpRootProperty; if (!rkIndex.isValid()) return mpRootProperty;
@ -112,7 +112,7 @@ IPropertyNew* CPropertyModel::PropertyForIndex(const QModelIndex& rkIndex, bool
return mProperties[Index].pProperty; return mProperties[Index].pProperty;
} }
QModelIndex CPropertyModel::IndexForProperty(IPropertyNew *pProp) const QModelIndex CPropertyModel::IndexForProperty(IProperty *pProp) const
{ {
// Array archetype properties cannot be associated with a single index because the same IProperty // Array archetype properties cannot be associated with a single index because the same IProperty
// is used for every element of the array. So instead fetch the index for the array itself. // is used for every element of the array. So instead fetch the index for the array itself.
@ -121,7 +121,7 @@ QModelIndex CPropertyModel::IndexForProperty(IPropertyNew *pProp) const
while (pProp && pProp->IsArrayArchetype()) while (pProp && pProp->IsArrayArchetype())
pProp = pProp->Parent(); pProp = pProp->Parent();
ASSERT(pProp != nullptr && pProp->Type() == EPropertyTypeNew::Array); ASSERT(pProp != nullptr && pProp->Type() == EPropertyType::Array);
} }
if (pProp == mpRootProperty) return QModelIndex(); if (pProp == mpRootProperty) return QModelIndex();
@ -146,7 +146,7 @@ void* CPropertyModel::DataPointerForIndex(const QModelIndex& rkIndex) const
int ArrayIndices[2]; int ArrayIndices[2];
int MaxIndex = -1; int MaxIndex = -1;
IPropertyNew* pProperty = mProperties[ID].pProperty; IProperty* pProperty = mProperties[ID].pProperty;
while (pProperty->IsArrayArchetype()) while (pProperty->IsArrayArchetype())
{ {
@ -188,15 +188,15 @@ int CPropertyModel::rowCount(const QModelIndex& rkParent) const
if (rkParent.column() != 0) return 0; if (rkParent.column() != 0) return 0;
if (rkParent.internalId() & 0x80000000) return 0; if (rkParent.internalId() & 0x80000000) return 0;
IPropertyNew *pProp = PropertyForIndex(rkParent, false); IProperty *pProp = PropertyForIndex(rkParent, false);
int ID = rkParent.internalId(); int ID = rkParent.internalId();
switch (pProp->Type()) switch (pProp->Type())
{ {
case EPropertyTypeNew::Flags: case EPropertyType::Flags:
return TPropCast<CFlagsProperty>(pProp)->NumFlags(); return TPropCast<CFlagsProperty>(pProp)->NumFlags();
case EPropertyTypeNew::AnimationSet: case EPropertyType::AnimationSet:
{ {
void* pData = DataPointerForIndex(rkParent); void* pData = DataPointerForIndex(rkParent);
CAnimationParameters Params = TPropCast<CAnimationSetProperty>(pProp)->Value(pData); CAnimationParameters Params = TPropCast<CAnimationSetProperty>(pProp)->Value(pData);
@ -230,10 +230,10 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
{ {
if (rkIndex.internalId() & 0x80000000) if (rkIndex.internalId() & 0x80000000)
{ {
IPropertyNew *pProp = PropertyForIndex(rkIndex, true); IProperty *pProp = PropertyForIndex(rkIndex, true);
EPropertyTypeNew Type = pProp->Type(); EPropertyType Type = pProp->Type();
if (Type == EPropertyTypeNew::Flags) if (Type == EPropertyType::Flags)
{ {
CFlagsProperty* pFlags = TPropCast<CFlagsProperty>(pProp); CFlagsProperty* pFlags = TPropCast<CFlagsProperty>(pProp);
@ -249,7 +249,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
} }
} }
else if (Type == EPropertyTypeNew::AnimationSet) else if (Type == EPropertyType::AnimationSet)
{ {
void* pData = DataPointerForIndex(rkIndex); void* pData = DataPointerForIndex(rkIndex);
CAnimationSetProperty* pAnimSet = TPropCast<CAnimationSetProperty>(pProp); CAnimationSetProperty* pAnimSet = TPropCast<CAnimationSetProperty>(pProp);
@ -300,14 +300,14 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
else else
{ {
IPropertyNew *pProp = PropertyForIndex(rkIndex, false); IProperty *pProp = PropertyForIndex(rkIndex, false);
if (rkIndex.column() == 0) if (rkIndex.column() == 0)
{ {
// Check for arrays // Check for arrays
IPropertyNew *pParent = pProp->Parent(); IProperty *pParent = pProp->Parent();
if (pParent && pParent->Type() == EPropertyTypeNew::Array) if (pParent && pParent->Type() == EPropertyType::Array)
{ {
// For direct array sub-properties, display the element index after the name // For direct array sub-properties, display the element index after the name
TString ElementName = pProp->Name(); TString ElementName = pProp->Name();
@ -325,14 +325,14 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
switch (pProp->Type()) switch (pProp->Type())
{ {
// Enclose vector property text in parentheses // Enclose vector property text in parentheses
case EPropertyTypeNew::Vector: case EPropertyType::Vector:
{ {
CVector3f Value = TPropCast<CVectorProperty>(pProp)->Value(pData); CVector3f Value = TPropCast<CVectorProperty>(pProp)->Value(pData);
return TO_QSTRING("(" + Value.ToString() + ")"); return TO_QSTRING("(" + Value.ToString() + ")");
} }
// Display the AGSC/sound name for sounds // Display the AGSC/sound name for sounds
case EPropertyTypeNew::Sound: case EPropertyType::Sound:
{ {
CSoundProperty* pSound = TPropCast<CSoundProperty>(pProp); CSoundProperty* pSound = TPropCast<CSoundProperty>(pProp);
u32 SoundID = pSound->Value(pData); u32 SoundID = pSound->Value(pData);
@ -358,12 +358,12 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
} }
// Display character name for characters // Display character name for characters
case EPropertyTypeNew::AnimationSet: case EPropertyType::AnimationSet:
return TO_QSTRING(TPropCast<CAnimationSetProperty>(pProp)->Value(pData).GetCurrentCharacterName()); return TO_QSTRING(TPropCast<CAnimationSetProperty>(pProp)->Value(pData).GetCurrentCharacterName());
// Display enumerator name for enums (but only on ToolTipRole) // Display enumerator name for enums (but only on ToolTipRole)
case EPropertyTypeNew::Choice: case EPropertyType::Choice:
case EPropertyTypeNew::Enum: case EPropertyType::Enum:
if (Role == Qt::ToolTipRole) if (Role == Qt::ToolTipRole)
{ {
CEnumProperty *pEnum = TPropCast<CEnumProperty>(pProp); CEnumProperty *pEnum = TPropCast<CEnumProperty>(pProp);
@ -374,20 +374,20 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
else return ""; else return "";
// Display the element count for arrays // Display the element count for arrays
case EPropertyTypeNew::Array: case EPropertyType::Array:
{ {
u32 Count = TPropCast<CArrayProperty>(pProp)->Value(pData); u32 Count = TPropCast<CArrayProperty>(pProp)->Value(pData);
return QString("%1 element%2").arg(Count).arg(Count != 1 ? "s" : ""); return QString("%1 element%2").arg(Count).arg(Count != 1 ? "s" : "");
} }
// Display "[spline]" for splines (todo: proper support) // Display "[spline]" for splines (todo: proper support)
case EPropertyTypeNew::Spline: case EPropertyType::Spline:
return "[spline]"; return "[spline]";
// No display text on properties with persistent editors // No display text on properties with persistent editors
case EPropertyTypeNew::Bool: case EPropertyType::Bool:
case EPropertyTypeNew::Asset: case EPropertyType::Asset:
case EPropertyTypeNew::Color: case EPropertyType::Color:
if (Role == Qt::DisplayRole) if (Role == Qt::DisplayRole)
return ""; return "";
// fall through // fall through
@ -404,13 +404,13 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
if (!(rkIndex.internalId() & 0x80000000)) if (!(rkIndex.internalId() & 0x80000000))
{ {
// Add name // Add name
IPropertyNew *pProp = PropertyForIndex(rkIndex, false); IProperty *pProp = PropertyForIndex(rkIndex, false);
QString DisplayText = data(rkIndex, Qt::DisplayRole).toString(); QString DisplayText = data(rkIndex, Qt::DisplayRole).toString();
QString TypeName = pProp->HashableTypeName(); QString TypeName = pProp->HashableTypeName();
QString Text = QString("<b>%1</b> <i>(%2)</i>").arg(DisplayText).arg(TypeName); QString Text = QString("<b>%1</b> <i>(%2)</i>").arg(DisplayText).arg(TypeName);
// Add uncooked notification // Add uncooked notification
if (pProp->CookPreference() == ECookPreferenceNew::Never) if (pProp->CookPreference() == ECookPreference::Never)
{ {
Text.prepend("<i>[uncooked]</i>"); Text.prepend("<i>[uncooked]</i>");
} }
@ -420,7 +420,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
if (!Desc.IsEmpty()) Text += "<br/>" + TO_QSTRING(Desc); if (!Desc.IsEmpty()) Text += "<br/>" + TO_QSTRING(Desc);
// Spline notification // Spline notification
if (pProp->Type() == EPropertyTypeNew::Spline) if (pProp->Type() == EPropertyType::Spline)
Text += "<br/><i>(NOTE: Spline properties are currently unsupported for editing)</i>"; Text += "<br/><i>(NOTE: Spline properties are currently unsupported for editing)</i>";
return Text; return Text;
@ -434,7 +434,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
if (mBoldModifiedProperties) if (mBoldModifiedProperties)
{ {
IPropertyNew *pProp = PropertyForIndex(rkIndex, true); IProperty *pProp = PropertyForIndex(rkIndex, true);
if (!pProp->IsArrayArchetype()) if (!pProp->IsArrayArchetype())
{ {
@ -455,7 +455,7 @@ QVariant CPropertyModel::data(const QModelIndex& rkIndex, int Role) const
{ {
if (mShowNameValidity && mpRootProperty->ScriptTemplate()->Game() >= eEchoesDemo) if (mShowNameValidity && mpRootProperty->ScriptTemplate()->Game() >= eEchoesDemo)
{ {
IPropertyNew *pProp = PropertyForIndex(rkIndex, true); IProperty *pProp = PropertyForIndex(rkIndex, true);
// Don't highlight the name of the root property // Don't highlight the name of the root property
if (pProp && pProp->Parent() != nullptr) if (pProp && pProp->Parent() != nullptr)
@ -477,11 +477,11 @@ QModelIndex CPropertyModel::index(int Row, int Column, const QModelIndex& rkPare
return QModelIndex(); return QModelIndex();
// Check property for children // Check property for children
IPropertyNew* pParent = (rkParent.isValid() ? PropertyForIndex(rkParent, false) : mpRootProperty); IProperty* pParent = (rkParent.isValid() ? PropertyForIndex(rkParent, false) : mpRootProperty);
EPropertyTypeNew ParentType = pParent->Type(); EPropertyType ParentType = pParent->Type();
int ParentID = rkParent.internalId(); int ParentID = rkParent.internalId();
if (ParentType == EPropertyTypeNew::Flags || ParentType == EPropertyTypeNew::AnimationSet) if (ParentType == EPropertyType::Flags || ParentType == EPropertyType::AnimationSet)
{ {
return createIndex(Row, Column, ParentID | 0x80000000); return createIndex(Row, Column, ParentID | 0x80000000);
} }
@ -517,7 +517,7 @@ Qt::ItemFlags CPropertyModel::flags(const QModelIndex& rkIndex) const
else return (Qt::ItemIsEnabled | Qt::ItemIsEditable); else return (Qt::ItemIsEnabled | Qt::ItemIsEditable);
} }
void CPropertyModel::NotifyPropertyModified(class CScriptObject*, IPropertyNew* pProp) void CPropertyModel::NotifyPropertyModified(class CScriptObject*, IProperty* pProp)
{ {
NotifyPropertyModified(IndexForProperty(pProp)); NotifyPropertyModified(IndexForProperty(pProp));
} }
@ -545,7 +545,7 @@ void CPropertyModel::NotifyPropertyModified(const QModelIndex& rkIndex)
void CPropertyModel::ArrayAboutToBeResized(const QModelIndex& rkIndex, u32 NewSize) void CPropertyModel::ArrayAboutToBeResized(const QModelIndex& rkIndex, u32 NewSize)
{ {
QModelIndex Index = rkIndex.sibling(rkIndex.row(), 0); QModelIndex Index = rkIndex.sibling(rkIndex.row(), 0);
IPropertyNew* pProperty = PropertyForIndex(Index, false); IProperty* pProperty = PropertyForIndex(Index, false);
CArrayProperty* pArray = TPropCast<CArrayProperty>(pProperty); CArrayProperty* pArray = TPropCast<CArrayProperty>(pProperty);
ASSERT(pArray); ASSERT(pArray);
@ -564,7 +564,7 @@ void CPropertyModel::ArrayAboutToBeResized(const QModelIndex& rkIndex, u32 NewSi
void CPropertyModel::ArrayResized(const QModelIndex& rkIndex, u32 OldSize) void CPropertyModel::ArrayResized(const QModelIndex& rkIndex, u32 OldSize)
{ {
QModelIndex Index = rkIndex.sibling(rkIndex.row(), 0); QModelIndex Index = rkIndex.sibling(rkIndex.row(), 0);
IPropertyNew* pProperty = PropertyForIndex(Index, false); IProperty* pProperty = PropertyForIndex(Index, false);
CArrayProperty* pArray = TPropCast<CArrayProperty>(pProperty); CArrayProperty* pArray = TPropCast<CArrayProperty>(pProperty);
ASSERT(pArray); ASSERT(pArray);

View File

@ -81,7 +81,7 @@ void CPropertyView::SetEditor(CWorldEditor *pEditor)
{ {
mpEditor = pEditor; mpEditor = pEditor;
mpDelegate->SetEditor(pEditor); mpDelegate->SetEditor(pEditor);
connect(mpEditor, SIGNAL(PropertyModified(CScriptObject*,IPropertyNew*)), mpModel, SLOT(NotifyPropertyModified(CScriptObject*,IPropertyNew*))); connect(mpEditor, SIGNAL(PropertyModified(CScriptObject*,IProperty*)), mpModel, SLOT(NotifyPropertyModified(CScriptObject*,IProperty*)));
} }
void CPropertyView::SetProperties(CStructRef InProperties) void CPropertyView::SetProperties(CStructRef InProperties)
@ -106,7 +106,7 @@ void CPropertyView::SetInstance(CScriptObject *pObj)
// Auto-expand EditorProperties // Auto-expand EditorProperties
QModelIndex Index = mpModel->index(0, 0, QModelIndex()); QModelIndex Index = mpModel->index(0, 0, QModelIndex());
IPropertyNew *pProp = mpModel->PropertyForIndex(Index, false); IProperty *pProp = mpModel->PropertyForIndex(Index, false);
if (pProp && pProp->ID() == 0x255A4580) if (pProp && pProp->ID() == 0x255A4580)
expand(Index); expand(Index);
} }
@ -121,14 +121,14 @@ void CPropertyView::UpdateEditorProperties(const QModelIndex& rkParent)
{ {
QModelIndex Index0 = mpModel->index(iRow, 0, rkParent); QModelIndex Index0 = mpModel->index(iRow, 0, rkParent);
QModelIndex Index1 = mpModel->index(iRow, 1, rkParent); QModelIndex Index1 = mpModel->index(iRow, 1, rkParent);
IPropertyNew *pProp = mpModel->PropertyForIndex(Index0, false); IProperty *pProp = mpModel->PropertyForIndex(Index0, false);
if (pProp) if (pProp)
{ {
// For structs, update sub-properties. // For structs, update sub-properties.
if (pProp->Type() == EPropertyTypeNew::Struct) if (pProp->Type() == EPropertyType::Struct)
{ {
CStructPropertyNew *pStruct = TPropCast<CStructPropertyNew>(pProp); CStructProperty *pStruct = TPropCast<CStructProperty>(pProp);
// As an optimization, in MP2+, we don't need to update unless this is an atomic struct or if // As an optimization, in MP2+, we don't need to update unless this is an atomic struct or if
// it's EditorProperties, because other structs never have editor properties in them. // it's EditorProperties, because other structs never have editor properties in them.
@ -161,35 +161,35 @@ void CPropertyView::SetPersistentEditors(const QModelIndex& rkParent)
for (u32 iChild = 0; iChild < NumChildren; iChild++) for (u32 iChild = 0; iChild < NumChildren; iChild++)
{ {
QModelIndex ChildIndex = mpModel->index(iChild, 1, rkParent); QModelIndex ChildIndex = mpModel->index(iChild, 1, rkParent);
IPropertyNew *pProp = mpModel->PropertyForIndex(ChildIndex, false); IProperty *pProp = mpModel->PropertyForIndex(ChildIndex, false);
EPropertyTypeNew Type = (pProp ? pProp->Type() : EPropertyTypeNew::Invalid); EPropertyType Type = (pProp ? pProp->Type() : EPropertyType::Invalid);
// Handle persistent editors under character properties // Handle persistent editors under character properties
if (!pProp && ChildIndex.internalId() & 0x80000000) if (!pProp && ChildIndex.internalId() & 0x80000000)
{ {
pProp = mpModel->PropertyForIndex(ChildIndex, true); pProp = mpModel->PropertyForIndex(ChildIndex, true);
if (pProp->Type() == EPropertyTypeNew::AnimationSet) if (pProp->Type() == EPropertyType::AnimationSet)
{ {
EGame Game = mpObject->Area()->Game(); EGame Game = mpObject->Area()->Game();
Type = mpDelegate->DetermineCharacterPropType(Game, ChildIndex); Type = mpDelegate->DetermineCharacterPropType(Game, ChildIndex);
} }
if (pProp->Type() == EPropertyTypeNew::Flags) if (pProp->Type() == EPropertyType::Flags)
Type = EPropertyTypeNew::Bool; Type = EPropertyType::Bool;
} }
switch (Type) switch (Type)
{ {
case EPropertyTypeNew::Bool: case EPropertyType::Bool:
case EPropertyTypeNew::Enum: case EPropertyType::Enum:
case EPropertyTypeNew::Choice: case EPropertyType::Choice:
case EPropertyTypeNew::Color: case EPropertyType::Color:
case EPropertyTypeNew::Asset: case EPropertyType::Asset:
openPersistentEditor(ChildIndex); openPersistentEditor(ChildIndex);
break; break;
case EPropertyTypeNew::Struct: case EPropertyType::Struct:
setFirstColumnSpanned(iChild, rkParent, true); setFirstColumnSpanned(iChild, rkParent, true);
break; break;
} }
@ -216,9 +216,9 @@ void CPropertyView::ClosePersistentEditors(const QModelIndex& rkIndex)
void CPropertyView::OnPropertyModified(const QModelIndex& rkIndex) void CPropertyView::OnPropertyModified(const QModelIndex& rkIndex)
{ {
// Check for a character resource being changed. If that's the case we need to remake the persistent editors. // Check for a character resource being changed. If that's the case we need to remake the persistent editors.
IPropertyNew *pProp = mpModel->PropertyForIndex(rkIndex, true); IProperty *pProp = mpModel->PropertyForIndex(rkIndex, true);
if (pProp->Type() == EPropertyTypeNew::AnimationSet /*&& rkIndex.internalId() & 0x1*/) if (pProp->Type() == EPropertyType::AnimationSet /*&& rkIndex.internalId() & 0x1*/)
{ {
ClosePersistentEditors(rkIndex); ClosePersistentEditors(rkIndex);
SetPersistentEditors(rkIndex); SetPersistentEditors(rkIndex);
@ -231,7 +231,7 @@ void CPropertyView::CreateContextMenu(const QPoint& rkPos)
if (Index.isValid() && Index.column() == 0) if (Index.isValid() && Index.column() == 0)
{ {
IPropertyNew *pProp = mpModel->PropertyForIndex(Index, true); IProperty *pProp = mpModel->PropertyForIndex(Index, true);
mpMenuProperty = pProp; mpMenuProperty = pProp;
QMenu Menu; QMenu Menu;

View File

@ -31,7 +31,7 @@ CInstancesModel::CInstancesModel(CWorldEditor *pEditor, QObject *pParent)
, mpEditor(pEditor) , mpEditor(pEditor)
, mpScene(pEditor->Scene()) , mpScene(pEditor->Scene())
, mpArea(nullptr) , mpArea(nullptr)
, mpCurrentMaster(nullptr) , mpCurrentGame(nullptr)
, mModelType(eLayers) , mModelType(eLayers)
, mShowColumnEnabled(true) , mShowColumnEnabled(true)
, mChangingLayout(false) , mChangingLayout(false)
@ -366,10 +366,10 @@ void CInstancesModel::OnActiveProjectChanged(CGameProject *pProj)
if (pProj) if (pProj)
{ {
EGame ProjGame = pProj->Game(); EGame ProjGame = pProj->Game();
mpCurrentMaster = CMasterTemplate::MasterForGame(ProjGame); mpCurrentGame = CGameTemplate::GetGameTemplate(ProjGame);
} }
else else
mpCurrentMaster = nullptr; mpCurrentGame = nullptr;
GenerateList(); GenerateList();
} }
@ -570,13 +570,13 @@ void CInstancesModel::GenerateList()
mTemplateList.clear(); mTemplateList.clear();
if (mpCurrentMaster) if (mpCurrentGame)
{ {
u32 NumTemplates = mpCurrentMaster->NumScriptTemplates(); u32 NumTemplates = mpCurrentGame->NumScriptTemplates();
for (u32 iTemp = 0; iTemp < NumTemplates; iTemp++) for (u32 iTemp = 0; iTemp < NumTemplates; iTemp++)
{ {
CScriptTemplate *pTemp = mpCurrentMaster->TemplateByIndex(iTemp); CScriptTemplate *pTemp = mpCurrentGame->TemplateByIndex(iTemp);
if (pTemp->NumObjects() > 0) if (pTemp->NumObjects() > 0)
mTemplateList << pTemp; mTemplateList << pTemp;

View File

@ -2,7 +2,7 @@
#define CTYPESINSTANCEMODEL_H #define CTYPESINSTANCEMODEL_H
#include "CWorldEditor.h" #include "CWorldEditor.h"
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
#include <Core/Resource/Script/CScriptTemplate.h> #include <Core/Resource/Script/CScriptTemplate.h>
#include <Core/Scene/CSceneNode.h> #include <Core/Scene/CSceneNode.h>
@ -35,7 +35,7 @@ private:
CWorldEditor *mpEditor; CWorldEditor *mpEditor;
CScene *mpScene; CScene *mpScene;
CGameArea *mpArea; CGameArea *mpArea;
CMasterTemplate *mpCurrentMaster; CGameTemplate *mpCurrentGame;
EInstanceModelType mModelType; EInstanceModelType mModelType;
QList<CScriptTemplate*> mTemplateList; QList<CScriptTemplate*> mTemplateList;
QStringList mBaseItems; QStringList mBaseItems;

View File

@ -10,7 +10,7 @@ CLinkDialog::CLinkDialog(CWorldEditor *pEditor, QWidget *pParent /*= 0*/)
: QDialog(pParent) : QDialog(pParent)
, ui(new Ui::CLinkDialog) , ui(new Ui::CLinkDialog)
, mpEditor(pEditor) , mpEditor(pEditor)
, mpMaster(nullptr) , mpGame(nullptr)
, mpSender(nullptr) , mpSender(nullptr)
, mpReceiver(nullptr) , mpReceiver(nullptr)
, mSenderStateModel(CStateMessageModel::eStates, this) , mSenderStateModel(CStateMessageModel::eStates, this)
@ -77,13 +77,13 @@ void CLinkDialog::EditLink(CLink *pLink)
ui->ReceiverMessageComboBox->setCurrentIndex(mReceiverMessageModel.MessageIndex(pLink->Message())); ui->ReceiverMessageComboBox->setCurrentIndex(mReceiverMessageModel.MessageIndex(pLink->Message()));
} }
void CLinkDialog::SetMaster(CMasterTemplate *pMaster) void CLinkDialog::SetGame(CGameTemplate *pGame)
{ {
if (mpMaster != pMaster) if (mpGame != pGame)
{ {
mpMaster = pMaster; mpGame = pGame;
mSenderStateModel.SetMasterTemplate(pMaster); mSenderStateModel.SetGameTemplate(pGame);
mReceiverMessageModel.SetMasterTemplate(pMaster); mReceiverMessageModel.SetGameTemplate(pGame);
} }
} }

View File

@ -12,7 +12,7 @@ class CLinkDialog : public QDialog
Q_OBJECT Q_OBJECT
CWorldEditor *mpEditor; CWorldEditor *mpEditor;
CMasterTemplate *mpMaster; CGameTemplate *mpGame;
CScriptObject *mpSender; CScriptObject *mpSender;
CScriptObject *mpReceiver; CScriptObject *mpReceiver;
CLink *mpEditLink; CLink *mpEditLink;
@ -34,7 +34,7 @@ public:
void NewLink(CScriptObject *pSender, CScriptObject *pReceiver); void NewLink(CScriptObject *pSender, CScriptObject *pReceiver);
void EditLink(CLink *pLink); void EditLink(CLink *pLink);
void SetMaster(CMasterTemplate *pMaster); void SetGame(CGameTemplate *pGame);
void SetSender(CScriptObject *pSender); void SetSender(CScriptObject *pSender);
void SetReceiver(CScriptObject *pReceiver); void SetReceiver(CScriptObject *pReceiver);
u32 State() const; u32 State() const;

View File

@ -1,7 +1,7 @@
#include "CLinkModel.h" #include "CLinkModel.h"
#include "Editor/UICommon.h" #include "Editor/UICommon.h"
#include <Core/Resource/Area/CGameArea.h> #include <Core/Resource/Area/CGameArea.h>
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
CLinkModel::CLinkModel(QObject *pParent) CLinkModel::CLinkModel(QObject *pParent)
: QAbstractTableModel(pParent) : QAbstractTableModel(pParent)
@ -67,13 +67,13 @@ QVariant CLinkModel::data(const QModelIndex& rkIndex, int Role) const
case 1: // Column 1 - State case 1: // Column 1 - State
{ {
TString StateName = mpObject->MasterTemplate()->StateByID(pLink->State()).Name; TString StateName = mpObject->GameTemplate()->StateByID(pLink->State()).Name;
return UICommon::ToQString(StateName); return UICommon::ToQString(StateName);
} }
case 2: // Column 2 - Message case 2: // Column 2 - Message
{ {
TString MessageName = mpObject->MasterTemplate()->MessageByID(pLink->Message()).Name; TString MessageName = mpObject->GameTemplate()->MessageByID(pLink->Message()).Name;
return UICommon::ToQString(MessageName); return UICommon::ToQString(MessageName);
} }

View File

@ -5,7 +5,7 @@
#include <Core/Resource/CScan.h> #include <Core/Resource/CScan.h>
#include <Core/Resource/Cooker/CPoiToWorldCooker.h> #include <Core/Resource/Cooker/CPoiToWorldCooker.h>
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
#include <Core/ScriptExtra/CPointOfInterestExtra.h> #include <Core/ScriptExtra/CPointOfInterestExtra.h>
#include <QMouseEvent> #include <QMouseEvent>
@ -339,7 +339,7 @@ void CPoiMapSidebar::StopPicking()
void CPoiMapSidebar::OnInstanceListButtonClicked() void CPoiMapSidebar::OnInstanceListButtonClicked()
{ {
EGame Game = Editor()->CurrentGame(); EGame Game = Editor()->CurrentGame();
CScriptTemplate *pPoiTemplate = CMasterTemplate::MasterForGame(Game)->TemplateByID("POIN"); CScriptTemplate *pPoiTemplate = CGameTemplate::GetGameTemplate(Game)->TemplateByID("POIN");
CPoiListDialog Dialog(pPoiTemplate, &mSourceModel, Editor()->Scene(), this); CPoiListDialog Dialog(pPoiTemplate, &mSourceModel, Editor()->Scene(), this);
Dialog.exec(); Dialog.exec();

View File

@ -2,11 +2,11 @@
#define CSTATEMESSAGEMODEL_H #define CSTATEMESSAGEMODEL_H
#include "Editor/UICommon.h" #include "Editor/UICommon.h"
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
#include <Core/Resource/Script/CScriptTemplate.h> #include <Core/Resource/Script/CScriptTemplate.h>
#include <QAbstractListModel> #include <QAbstractListModel>
// todo: support pulling states/messages from script templates instead of master // todo: support pulling states/messages from script templates instead of game
class CStateMessageModel : public QAbstractListModel class CStateMessageModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
@ -35,7 +35,7 @@ private:
}; };
QList<SEntry> mEntries; QList<SEntry> mEntries;
CMasterTemplate *mpMaster; CGameTemplate *mpGame;
CScriptTemplate *mpScript; CScriptTemplate *mpScript;
EType mType; EType mType;
@ -43,7 +43,7 @@ public:
explicit CStateMessageModel(EType Type, QObject *pParent = 0) explicit CStateMessageModel(EType Type, QObject *pParent = 0)
: QAbstractListModel(pParent) : QAbstractListModel(pParent)
, mType(Type) , mType(Type)
, mpMaster(nullptr) , mpGame(nullptr)
, mpScript(nullptr) , mpScript(nullptr)
{} {}
@ -62,27 +62,27 @@ public:
else return QVariant::Invalid; else return QVariant::Invalid;
} }
void SetMasterTemplate(CMasterTemplate *pMaster) void SetGameTemplate(CGameTemplate *pGame)
{ {
beginResetModel(); beginResetModel();
mpMaster = pMaster; mpGame = pGame;
mEntries.clear(); mEntries.clear();
if (mType == eStates) if (mType == eStates)
{ {
for (u32 iState = 0; iState < pMaster->NumStates(); iState++) for (u32 iState = 0; iState < pGame->NumStates(); iState++)
{ {
SState State = pMaster->StateByIndex(iState); SState State = pGame->StateByIndex(iState);
mEntries << SEntry(State.ID, TO_QSTRING(State.Name)); mEntries << SEntry(State.ID, TO_QSTRING(State.Name));
} }
} }
else else
{ {
for (u32 iMsg = 0; iMsg < pMaster->NumMessages(); iMsg++) for (u32 iMsg = 0; iMsg < pGame->NumMessages(); iMsg++)
{ {
SMessage Message = pMaster->MessageByIndex(iMsg); SMessage Message = pGame->MessageByIndex(iMsg);
mEntries << SEntry(Message.ID, TO_QSTRING(Message.Name)); mEntries << SEntry(Message.ID, TO_QSTRING(Message.Name));
} }
} }

View File

@ -2,9 +2,8 @@
#include "ui_CTemplateEditDialog.h" #include "ui_CTemplateEditDialog.h"
#include "Editor/UICommon.h" #include "Editor/UICommon.h"
#include <Core/Resource/Cooker/CTemplateWriter.h>
#include <Core/Resource/Factory/CTemplateLoader.h> #include <Core/Resource/Factory/CTemplateLoader.h>
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
CTemplateEditDialog::CTemplateEditDialog(IProperty *pProperty, QWidget *pParent) CTemplateEditDialog::CTemplateEditDialog(IProperty *pProperty, QWidget *pParent)
: QDialog(pParent) : QDialog(pParent)
@ -35,7 +34,7 @@ CTemplateEditDialog::CTemplateEditDialog(IProperty *pProperty, QWidget *pParent)
{ {
CTemplateLoader::LoadAllGames(); CTemplateLoader::LoadAllGames();
std::vector<TString> TemplateList; std::vector<TString> TemplateList;
CMasterTemplate::XMLsUsingID(pProperty->ID(), TemplateList); CGameTemplate::XMLsUsingID(pProperty->ID(), TemplateList);
for (u32 iTemp = 0; iTemp < TemplateList.size(); iTemp++) for (u32 iTemp = 0; iTemp < TemplateList.size(); iTemp++)
mpUI->TemplatesListWidget->addItem(TO_QSTRING(TemplateList[iTemp])); mpUI->TemplatesListWidget->addItem(TO_QSTRING(TemplateList[iTemp]));
@ -90,10 +89,10 @@ void CTemplateEditDialog::ApplyChanges()
// Rename properties // Rename properties
if (RenameAll && (mGame >= eEchoesDemo || mpProperty->Archetype() != nullptr)) if (RenameAll && (mGame >= eEchoesDemo || mpProperty->Archetype() != nullptr))
{ {
CMasterTemplate::RenameProperty(mpProperty, NewName); CGameTemplate::RenameProperty(mpProperty, NewName);
// Add modified templates to pending resave list // Add modified templates to pending resave list
const std::vector<IProperty*> *pList = CMasterTemplate::TemplatesWithMatchingID(mpProperty); const std::vector<IProperty*> *pList = CGameTemplate::TemplatesWithMatchingID(mpProperty);
if (pList) if (pList)
{ {
@ -102,7 +101,7 @@ void CTemplateEditDialog::ApplyChanges()
} }
} }
mpProperty->SetName(NewName); // If mpTemplate has an overridden name then CMasterTemplate::RenameProperty won't touch it mpProperty->SetName(NewName); // If mpTemplate has an overridden name then CGameTemplate::RenameProperty won't touch it
if (RenameAll && mGame >= eEchoesDemo) if (RenameAll && mGame >= eEchoesDemo)
NeedsListResave = true; NeedsListResave = true;
@ -179,7 +178,7 @@ void CTemplateEditDialog::UpdateDescription(const TString& rkNewDesc)
if (!SourceFile.IsEmpty()) if (!SourceFile.IsEmpty())
{ {
const std::vector<IProperty*>* pkTemplates = CMasterTemplate::TemplatesWithMatchingID(mpProperty); const std::vector<IProperty*>* pkTemplates = CGameTemplate::TemplatesWithMatchingID(mpProperty);
if (pkTemplates) if (pkTemplates)
{ {
@ -230,16 +229,16 @@ void CTemplateEditDialog::FindEquivalentProperties(IProperty *pTemp)
} }
} }
QList<CMasterTemplate*> MasterList = QList<CMasterTemplate*>::fromStdList(CMasterTemplate::MasterList()); QList<CGameTemplate*> GameList = QList<CGameTemplate*>::fromStdList(CGameTemplate::GameList());
if (Source.IsEmpty()) if (Source.IsEmpty())
{ {
u32 ObjectID = pScript->ObjectID(); u32 ObjectID = pScript->ObjectID();
foreach (CMasterTemplate *pMaster, MasterList) foreach (CGameTemplate *pGame, GameList)
{ {
if (pMaster == pTemp->MasterTemplate() || pMaster->Game() <= ePrime) continue; if (pGame == pTemp->GameTemplate() || pGame->Game() <= ePrime) continue;
CScriptTemplate *pNewScript = pMaster->TemplateByID(ObjectID); CScriptTemplate *pNewScript = pGame->TemplateByID(ObjectID);
if (pNewScript) if (pNewScript)
{ {
@ -253,10 +252,10 @@ void CTemplateEditDialog::FindEquivalentProperties(IProperty *pTemp)
else else
{ {
foreach (CMasterTemplate *pMaster, MasterList) foreach (CGameTemplate *pGame, GameList)
{ {
if (pMaster == pTemp->MasterTemplate() || pMaster->Game() <= ePrime) continue; if (pGame == pTemp->GameTemplate() || pGame->Game() <= ePrime) continue;
CStructTemplate *pStruct = pMaster->StructAtSource(Source); CStructTemplate *pStruct = pGame->StructAtSource(Source);
if (pStruct) if (pStruct)
{ {

View File

@ -3,7 +3,7 @@
#include "Editor/CPropertyNameValidator.h" #include "Editor/CPropertyNameValidator.h"
#include <Core/Resource/Script/Property/Properties.h> #include <Core/Resource/Script/Property/Properties.h>
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui {
@ -16,7 +16,7 @@ class CTemplateEditDialog : public QDialog
Ui::CTemplateEditDialog* mpUI; Ui::CTemplateEditDialog* mpUI;
CPropertyNameValidator* mpValidator; CPropertyNameValidator* mpValidator;
IPropertyNew *mpProperty; IProperty *mpProperty;
EGame mGame; EGame mGame;
TString mOriginalName; TString mOriginalName;
@ -25,20 +25,20 @@ class CTemplateEditDialog : public QDialog
// These members help track what templates need to be updated and resaved after the user clicks OK // These members help track what templates need to be updated and resaved after the user clicks OK
QVector<CScriptTemplate*> mScriptTemplatesToResave; QVector<CScriptTemplate*> mScriptTemplatesToResave;
QVector<CStructPropertyNew*> mStructTemplatesToResave; QVector<CStructProperty*> mStructTemplatesToResave;
QVector<IPropertyNew*> mEquivalentProperties; QVector<IProperty*> mEquivalentProperties;
public: public:
CTemplateEditDialog(IPropertyNew* pProperty, QWidget *pParent = 0); CTemplateEditDialog(IProperty* pProperty, QWidget *pParent = 0);
~CTemplateEditDialog(); ~CTemplateEditDialog();
public slots: public slots:
void ApplyChanges(); void ApplyChanges();
protected: protected:
void AddTemplate(IPropertyNew* pProperty); void AddTemplate(IProperty* pProperty);
void UpdateDescription(const TString& rkNewDesc); void UpdateDescription(const TString& rkNewDesc);
void FindEquivalentProperties(IPropertyNew *pTemp); void FindEquivalentProperties(IProperty *pTemp);
}; };
#endif // CTEMPLATEEDITDIALOG_H #endif // CTEMPLATEEDITDIALOG_H

View File

@ -3,7 +3,7 @@
#include "CTemplateMimeData.h" #include "CTemplateMimeData.h"
#include "Editor/UICommon.h" #include "Editor/UICommon.h"
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QDrag> #include <QDrag>
#include <QListView> #include <QListView>
@ -11,7 +11,7 @@
class CTemplateListModel : public QAbstractListModel class CTemplateListModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
CMasterTemplate *mpMaster; CGameTemplate *mpGame;
QList<CScriptTemplate*> mTemplates; QList<CScriptTemplate*> mTemplates;
public: public:
@ -55,17 +55,17 @@ public:
return Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled; return Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled;
} }
void SetMaster(CMasterTemplate *pMaster) void SetGame(CGameTemplate *pGame)
{ {
beginResetModel(); beginResetModel();
mpMaster = pMaster; mpGame = pGame;
mTemplates.clear(); mTemplates.clear();
if (mpMaster) if (mpGame)
{ {
for (u32 iTemp = 0; iTemp < mpMaster->NumScriptTemplates(); iTemp++) for (u32 iTemp = 0; iTemp < mpGame->NumScriptTemplates(); iTemp++)
mTemplates << mpMaster->TemplateByIndex(iTemp); mTemplates << mpGame->TemplateByIndex(iTemp);
qSort(mTemplates.begin(), mTemplates.end(), [](CScriptTemplate *pLeft, CScriptTemplate *pRight) -> bool { qSort(mTemplates.begin(), mTemplates.end(), [](CScriptTemplate *pLeft, CScriptTemplate *pRight) -> bool {
return pLeft->Name() < pRight->Name(); return pLeft->Name() < pRight->Name();
@ -103,9 +103,9 @@ public:
QListView::setModel(mpModel); QListView::setModel(mpModel);
} }
inline void SetMaster(CMasterTemplate *pMaster) inline void SetGame(CGameTemplate *pGame)
{ {
if (mpModel) mpModel->SetMaster(pMaster); if (mpModel) mpModel->SetGame(pGame);
} }
protected: protected:

View File

@ -282,8 +282,8 @@ bool CWorldEditor::SetArea(CWorld *pWorld, int AreaIndex)
// Update UI stuff // Update UI stuff
UpdateWindowTitle(); UpdateWindowTitle();
CMasterTemplate *pMaster = CMasterTemplate::MasterForGame(mpArea->Game()); CGameTemplate *pGame = CGameTemplate::GetGameTemplate(mpArea->Game());
mpLinkDialog->SetMaster(pMaster); mpLinkDialog->SetGame(pGame);
QString AreaName = TO_QSTRING(mpWorld->AreaInGameName(AreaIndex)); QString AreaName = TO_QSTRING(mpWorld->AreaInGameName(AreaIndex));

View File

@ -61,8 +61,8 @@ bool WCreateTab::eventFilter(QObject *pObj, QEvent *pEvent)
void WCreateTab::OnActiveProjectChanged(CGameProject *pProj) void WCreateTab::OnActiveProjectChanged(CGameProject *pProj)
{ {
EGame Game = (pProj ? pProj->Game() : eUnknownGame); EGame Game = (pProj ? pProj->Game() : eUnknownGame);
CMasterTemplate *pMaster = CMasterTemplate::MasterForGame(Game); CGameTemplate *pGame = CGameTemplate::GetGameTemplate(Game);
ui->TemplateView->SetMaster(pMaster); ui->TemplateView->SetGame(pGame);
} }
void WCreateTab::OnLayersChanged() void WCreateTab::OnLayersChanged()

View File

@ -2,7 +2,7 @@
#define WCREATETAB_H #define WCREATETAB_H
#include "CWorldEditor.h" #include "CWorldEditor.h"
#include <Core/Resource/Script/CMasterTemplate.h> #include <Core/Resource/Script/CGameTemplate.h>
#include <QWidget> #include <QWidget>
namespace Ui { namespace Ui {

View File

@ -299,11 +299,11 @@ void WInstancesTab::OnHideAllExceptTypeAction()
else else
{ {
EGame Game = mpEditor->CurrentGame(); EGame Game = mpEditor->CurrentGame();
CMasterTemplate *pMaster = CMasterTemplate::MasterForGame(Game); CGameTemplate *pGame = CGameTemplate::GetGameTemplate(Game);
for (u32 iTemp = 0; iTemp < pMaster->NumScriptTemplates(); iTemp++) for (u32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++)
{ {
CScriptTemplate *pTemplate = pMaster->TemplateByIndex(iTemp); CScriptTemplate *pTemplate = pGame->TemplateByIndex(iTemp);
pTemplate->SetVisible( pTemplate == mpMenuTemplate ? true : false ); pTemplate->SetVisible( pTemplate == mpMenuTemplate ? true : false );
} }
@ -330,10 +330,10 @@ void WInstancesTab::OnUnhideAllTypes()
else else
{ {
EGame Game = mpEditor->CurrentGame(); EGame Game = mpEditor->CurrentGame();
CMasterTemplate *pMaster = CMasterTemplate::MasterForGame(Game); CGameTemplate *pGame = CGameTemplate::GetGameTemplate(Game);
for (u32 iTemp = 0; iTemp < pMaster->NumScriptTemplates(); iTemp++) for (u32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++)
pMaster->TemplateByIndex(iTemp)->SetVisible(true); pGame->TemplateByIndex(iTemp)->SetVisible(true);
mpTypesModel->dataChanged( mpTypesModel->index(0, 2, TypeParent), mpTypesModel->index(mpTypesModel->rowCount(TypeParent) - 1, 2, TypeParent) ); mpTypesModel->dataChanged( mpTypesModel->index(0, 2, TypeParent), mpTypesModel->index(mpTypesModel->rowCount(TypeParent) - 1, 2, TypeParent) );
} }
@ -364,10 +364,10 @@ void WInstancesTab::OnUnhideAll()
if (TypesRoot.isValid()) if (TypesRoot.isValid())
{ {
EGame Game = mpEditor->CurrentGame(); EGame Game = mpEditor->CurrentGame();
CMasterTemplate *pMaster = CMasterTemplate::MasterForGame(Game); CGameTemplate *pGame = CGameTemplate::GetGameTemplate(Game);
for (u32 iTemp = 0; iTemp < pMaster->NumScriptTemplates(); iTemp++) for (u32 iTemp = 0; iTemp < pGame->NumScriptTemplates(); iTemp++)
pMaster->TemplateByIndex(iTemp)->SetVisible(true); pGame->TemplateByIndex(iTemp)->SetVisible(true);
mpTypesModel->dataChanged( mpTypesModel->index(0, 2, TypesRoot), mpTypesModel->index(mpTypesModel->rowCount(TypesRoot) - 1, 2, TypesRoot) ); mpTypesModel->dataChanged( mpTypesModel->index(0, 2, TypesRoot), mpTypesModel->index(mpTypesModel->rowCount(TypesRoot) - 1, 2, TypesRoot) );
} }