mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 10:49:23 +00:00
Added dialog for editing property templates
This commit is contained in:
@@ -11,6 +11,33 @@ CTemplateWriter::CTemplateWriter()
|
||||
{
|
||||
}
|
||||
|
||||
void CTemplateWriter::SavePropertyTemplate(IPropertyTemplate *pTemp)
|
||||
{
|
||||
// Check for a source file in the template's hierarchy; that indicates it's part of a struct template, not a script template
|
||||
TString SourceFile = pTemp->FindStructSource();
|
||||
|
||||
// Struct
|
||||
if (!SourceFile.IsEmpty())
|
||||
{
|
||||
CMasterTemplate *pMaster = pTemp->MasterTemplate();
|
||||
auto StructIt = pMaster->mStructTemplates.find(SourceFile);
|
||||
|
||||
if (StructIt != pMaster->mStructTemplates.end())
|
||||
{
|
||||
CStructTemplate *pStruct = StructIt->second;
|
||||
CTemplateWriter::SaveStructTemplate(pStruct);
|
||||
}
|
||||
}
|
||||
|
||||
// Script
|
||||
else if (pTemp->ScriptTemplate())
|
||||
CTemplateWriter::SaveScriptTemplate(pTemp->ScriptTemplate());
|
||||
|
||||
// Error
|
||||
else
|
||||
Log::Error("Couldn't save property template " + pTemp->IDString(true) + "; no struct template source path or script template found");
|
||||
}
|
||||
|
||||
void CTemplateWriter::SaveAllTemplates()
|
||||
{
|
||||
// Create directory
|
||||
@@ -76,7 +103,7 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster)
|
||||
|
||||
// Resave struct templates
|
||||
for (auto it = pMaster->mStructTemplates.begin(); it != pMaster->mStructTemplates.end(); it++)
|
||||
SaveStructTemplate(it->second, pMaster);
|
||||
SaveStructTemplate(it->second);
|
||||
|
||||
// Resave master template
|
||||
XMLDocument Master;
|
||||
@@ -202,7 +229,7 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp)
|
||||
pRoot->LinkEndChild(pName);
|
||||
|
||||
// Write properties
|
||||
SaveProperties(&ScriptXML, pRoot, pTemp->mpBaseStruct, pMaster);
|
||||
SaveProperties(&ScriptXML, pRoot, pTemp->mpBaseStruct);
|
||||
|
||||
// States/Messages [todo]
|
||||
XMLElement *pStates = ScriptXML.NewElement("states");
|
||||
@@ -345,9 +372,10 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp)
|
||||
ScriptXML.SaveFile(*OutFile);
|
||||
}
|
||||
|
||||
void CTemplateWriter::SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster)
|
||||
void CTemplateWriter::SaveStructTemplate(CStructTemplate *pTemp)
|
||||
{
|
||||
// Create directory
|
||||
CMasterTemplate *pMaster = pTemp->MasterTemplate();
|
||||
TString OutFile = smTemplatesDir + pMaster->GetDirectory() + pTemp->mSourceFile;
|
||||
TString OutDir = OutFile.GetFileDirectory();
|
||||
TString Name = OutFile.GetFileName(false);
|
||||
@@ -364,13 +392,14 @@ void CTemplateWriter::SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate
|
||||
pRoot->SetAttribute("type", (pTemp->IsSingleProperty() ? "single" : "multi"));
|
||||
StructXML.LinkEndChild(pRoot);
|
||||
|
||||
SaveProperties(&StructXML, pRoot, pTemp, pMaster);
|
||||
SaveProperties(&StructXML, pRoot, pTemp);
|
||||
StructXML.SaveFile(*OutFile);
|
||||
}
|
||||
|
||||
void CTemplateWriter::SaveEnumTemplate(CEnumTemplate *pTemp, CMasterTemplate *pMaster)
|
||||
void CTemplateWriter::SaveEnumTemplate(CEnumTemplate *pTemp)
|
||||
{
|
||||
// Create directory
|
||||
CMasterTemplate *pMaster = pTemp->MasterTemplate();
|
||||
TString OutFile = smTemplatesDir + pMaster->GetDirectory() + pTemp->mSourceFile;
|
||||
TString OutDir = OutFile.GetFileDirectory();
|
||||
TString Name = OutFile.GetFileName(false);
|
||||
@@ -390,9 +419,10 @@ void CTemplateWriter::SaveEnumTemplate(CEnumTemplate *pTemp, CMasterTemplate *pM
|
||||
EnumXML.SaveFile(*OutFile);
|
||||
}
|
||||
|
||||
void CTemplateWriter::SaveBitfieldTemplate(CBitfieldTemplate *pTemp, CMasterTemplate *pMaster)
|
||||
void CTemplateWriter::SaveBitfieldTemplate(CBitfieldTemplate *pTemp)
|
||||
{
|
||||
// Create directory
|
||||
CMasterTemplate *pMaster = pTemp->MasterTemplate();
|
||||
TString OutFile = smTemplatesDir + pMaster->GetDirectory() + pTemp->mSourceFile;
|
||||
TString OutDir = OutFile.GetFileDirectory();
|
||||
TString Name = pTemp->mSourceFile.GetFileName(false);
|
||||
@@ -412,7 +442,7 @@ void CTemplateWriter::SaveBitfieldTemplate(CBitfieldTemplate *pTemp, CMasterTemp
|
||||
BitfieldXML.SaveFile(*OutFile);
|
||||
}
|
||||
|
||||
void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CStructTemplate *pTemp, CMasterTemplate *pMaster)
|
||||
void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CStructTemplate *pTemp)
|
||||
{
|
||||
// Create base element
|
||||
XMLElement *pPropsBlock = pDoc->NewElement("properties");
|
||||
@@ -447,7 +477,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
// Name
|
||||
TString Name = pProp->Name();
|
||||
|
||||
if (pMaster->GetGame() >= eEchoesDemo && ID > 0xFF)
|
||||
if (pProp->Game() >= eEchoesDemo && ID > 0xFF)
|
||||
{
|
||||
TString MasterName = CMasterTemplate::GetPropertyName(ID);
|
||||
|
||||
@@ -471,6 +501,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
pElem->SetAttribute("type", *PropEnumToPropString(pProp->Type()));
|
||||
|
||||
// Versions
|
||||
CMasterTemplate *pMaster = pProp->MasterTemplate();
|
||||
u32 NumVersions = pProp->mAllowedVersions.size();
|
||||
|
||||
if (NumVersions > 0 && NumVersions != pMaster->mGameVersions.size())
|
||||
@@ -490,7 +521,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
}
|
||||
|
||||
// Default
|
||||
if (pProp->CanHaveDefault() && pMaster->GetGame() >= eEchoesDemo)
|
||||
if (pProp->CanHaveDefault() && pProp->Game() >= eEchoesDemo)
|
||||
{
|
||||
XMLElement *pDefault = pDoc->NewElement("default");
|
||||
pDefault->SetText(*pProp->DefaultToString());
|
||||
@@ -561,7 +592,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
|
||||
else
|
||||
{
|
||||
SaveEnumTemplate(pEnum, pMaster);
|
||||
SaveEnumTemplate(pEnum);
|
||||
pElem->SetAttribute("template", *pEnum->mSourceFile);
|
||||
}
|
||||
}
|
||||
@@ -576,7 +607,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
|
||||
else
|
||||
{
|
||||
SaveBitfieldTemplate(pBitfield, pMaster);
|
||||
SaveBitfieldTemplate(pBitfield);
|
||||
pElem->SetAttribute("template", *pBitfield->mSourceFile);
|
||||
}
|
||||
}
|
||||
@@ -601,14 +632,14 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
CStructTemplate *pStruct = static_cast<CStructTemplate*>(pProp);
|
||||
|
||||
if (pStruct->mSourceFile.IsEmpty())
|
||||
SaveProperties(pDoc, pElem, pStruct, pMaster);
|
||||
SaveProperties(pDoc, pElem, pStruct);
|
||||
|
||||
else
|
||||
{
|
||||
auto it = pMaster->mStructTemplates.find(pStruct->mSourceFile);
|
||||
CStructTemplate *pOriginal = pMaster->GetStructAtSource(pStruct->mSourceFile);
|
||||
|
||||
if (it != pMaster->mStructTemplates.end())
|
||||
SavePropertyOverrides(pDoc, pElem, pStruct, it->second);
|
||||
if (pOriginal)
|
||||
SavePropertyOverrides(pDoc, pElem, pStruct, pOriginal);
|
||||
|
||||
pElem->SetAttribute("template", *pStruct->mSourceFile);
|
||||
}
|
||||
|
||||
@@ -11,14 +11,15 @@ class CTemplateWriter
|
||||
static TString smTemplatesDir;
|
||||
|
||||
public:
|
||||
static void SavePropertyTemplate(IPropertyTemplate *pTemp);
|
||||
static void SaveAllTemplates();
|
||||
static void SaveGameTemplates(CMasterTemplate *pMaster);
|
||||
static void SavePropertyList();
|
||||
static void SaveScriptTemplate(CScriptTemplate *pTemp);
|
||||
static void SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster);
|
||||
static void SaveEnumTemplate(CEnumTemplate *pTemp, CMasterTemplate *pMaster);
|
||||
static void SaveBitfieldTemplate(CBitfieldTemplate *pTemp, CMasterTemplate *pMaster);
|
||||
static void SaveProperties(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CStructTemplate *pTemp, CMasterTemplate *pMaster);
|
||||
static void SaveStructTemplate(CStructTemplate *pTemp);
|
||||
static void SaveEnumTemplate(CEnumTemplate *pTemp);
|
||||
static void SaveBitfieldTemplate(CBitfieldTemplate *pTemp);
|
||||
static void SaveProperties(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CStructTemplate *pTemp);
|
||||
static void SavePropertyOverrides(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CStructTemplate *pStruct, CStructTemplate *pOriginal);
|
||||
static void SaveEnumerators(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CEnumTemplate *pTemp);
|
||||
static void SaveBitFlags(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CBitfieldTemplate *pTemp);
|
||||
|
||||
@@ -9,7 +9,7 @@ const TString CTemplateLoader::mskGameListPath = CTemplateLoader::mskTemplatesDi
|
||||
|
||||
using namespace tinyxml2;
|
||||
|
||||
IPropertyTemplate* CTemplateLoader::LoadProperty(XMLElement *pElem, CStructTemplate *pStruct, const TString& rkTemplateName)
|
||||
IPropertyTemplate* CTemplateLoader::LoadProperty(XMLElement *pElem, CScriptTemplate *pScript, CStructTemplate *pStruct, const TString& rkTemplateName)
|
||||
{
|
||||
TString NodeType = TString(pElem->Name()).ToLower();
|
||||
TString IDAttr = TString(pElem->Attribute("ID")).ToLower();
|
||||
@@ -60,7 +60,7 @@ IPropertyTemplate* CTemplateLoader::LoadProperty(XMLElement *pElem, CStructTempl
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pProp = CreateProperty(ID, Type, Name, pStruct);
|
||||
pProp = CreateProperty(ID, Type, Name, pScript, pStruct);
|
||||
|
||||
if (!pProp)
|
||||
{
|
||||
@@ -162,15 +162,15 @@ IPropertyTemplate* CTemplateLoader::LoadProperty(XMLElement *pElem, CStructTempl
|
||||
XMLElement *pProperties = pElem->FirstChildElement("properties");
|
||||
|
||||
if (pProperties)
|
||||
LoadProperties(pProperties, pStruct, rkTemplateName);
|
||||
LoadProperties(pProperties, pScript, pStruct, rkTemplateName);
|
||||
}
|
||||
|
||||
CMasterTemplate::AddProperty(pProp, mMasterDir + rkTemplateName);
|
||||
return pProp;
|
||||
}
|
||||
|
||||
#define CREATE_PROP_TEMP(Class) new Class(ID, rkName, eNoCookPreference, pStruct)
|
||||
IPropertyTemplate* CTemplateLoader::CreateProperty(u32 ID, EPropertyType Type, const TString& rkName, CStructTemplate *pStruct)
|
||||
#define CREATE_PROP_TEMP(Class) new Class(ID, rkName, eNoCookPreference, pScript, mpMaster, pStruct)
|
||||
IPropertyTemplate* CTemplateLoader::CreateProperty(u32 ID, EPropertyType Type, const TString& rkName, CScriptTemplate *pScript, CStructTemplate *pStruct)
|
||||
{
|
||||
IPropertyTemplate *pOut = pStruct->PropertyByID(ID);
|
||||
|
||||
@@ -216,7 +216,7 @@ void CTemplateLoader::LoadStructTemplate(const TString& rkTemplateFileName, CStr
|
||||
|
||||
if (pStruct->Type() == eStructProperty)
|
||||
{
|
||||
pSource = new CStructTemplate(-1, nullptr);
|
||||
pSource = new CStructTemplate(-1, nullptr, mpMaster);
|
||||
pRootElem = Doc.FirstChildElement("struct");
|
||||
|
||||
if (!pRootElem)
|
||||
@@ -238,6 +238,7 @@ void CTemplateLoader::LoadStructTemplate(const TString& rkTemplateFileName, CStr
|
||||
|
||||
else if (pStruct->Type() == eArrayProperty)
|
||||
{
|
||||
pSource = new CArrayTemplate(-1, nullptr, mpMaster);
|
||||
pRootElem = Doc.FirstChildElement("array");
|
||||
|
||||
if (!pRootElem)
|
||||
@@ -246,15 +247,19 @@ void CTemplateLoader::LoadStructTemplate(const TString& rkTemplateFileName, CStr
|
||||
return;
|
||||
}
|
||||
}
|
||||
pSource->mSourceFile = rkTemplateFileName;
|
||||
|
||||
TString NameAttr = TString(pRootElem->Attribute("name"));
|
||||
if (!NameAttr.IsEmpty())
|
||||
pSource->mName = NameAttr;
|
||||
|
||||
// Read sub-properties
|
||||
XMLElement *pSubPropsElem = pRootElem->FirstChildElement("properties");
|
||||
|
||||
if (pSubPropsElem)
|
||||
{
|
||||
LoadProperties(pSubPropsElem, pSource, rkTemplateFileName);
|
||||
LoadProperties(pSubPropsElem, nullptr, pSource, rkTemplateFileName);
|
||||
mpMaster->mStructTemplates[rkTemplateFileName] = pSource;
|
||||
pSource->mSourceFile = rkTemplateFileName;
|
||||
}
|
||||
|
||||
else
|
||||
@@ -278,6 +283,7 @@ void CTemplateLoader::LoadEnumTemplate(const TString& rkTemplateFileName, CEnumT
|
||||
|
||||
if (!Doc.Error())
|
||||
{
|
||||
pEnum->mSourceFile = rkTemplateFileName;
|
||||
XMLElement *pRootElem = Doc.FirstChildElement("enum");
|
||||
|
||||
if (!pRootElem)
|
||||
@@ -294,7 +300,6 @@ void CTemplateLoader::LoadEnumTemplate(const TString& rkTemplateFileName, CEnumT
|
||||
else
|
||||
Log::Error(rkTemplateFileName + ": There is no \"enumerators\" block element");
|
||||
|
||||
pEnum->mSourceFile = rkTemplateFileName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,6 +310,7 @@ void CTemplateLoader::LoadBitfieldTemplate(const TString& rkTemplateFileName, CB
|
||||
|
||||
if (!Doc.Error())
|
||||
{
|
||||
pBitfield->mSourceFile = rkTemplateFileName;
|
||||
XMLElement *pRootElem = Doc.FirstChildElement("bitfield");
|
||||
|
||||
if (!pRootElem)
|
||||
@@ -320,12 +326,10 @@ void CTemplateLoader::LoadBitfieldTemplate(const TString& rkTemplateFileName, CB
|
||||
|
||||
else
|
||||
Log::Error(rkTemplateFileName + ": There is no \"flags\" block element");
|
||||
|
||||
pBitfield->mSourceFile = rkTemplateFileName;
|
||||
}
|
||||
}
|
||||
|
||||
void CTemplateLoader::LoadProperties(XMLElement *pPropertiesElem, CStructTemplate *pStruct, const TString& rkTemplateName)
|
||||
void CTemplateLoader::LoadProperties(XMLElement *pPropertiesElem, CScriptTemplate *pScript, CStructTemplate *pStruct, const TString& rkTemplateName)
|
||||
{
|
||||
XMLElement *pChild = pPropertiesElem->FirstChildElement();
|
||||
|
||||
@@ -341,7 +345,7 @@ void CTemplateLoader::LoadProperties(XMLElement *pPropertiesElem, CStructTemplat
|
||||
// LoadProperty adds newly created properties to the struct, so we don't need to do anything other than call it for each sub-element.
|
||||
else
|
||||
{
|
||||
LoadProperty(pChild, pStruct, rkTemplateName);
|
||||
LoadProperty(pChild, pScript, pStruct, rkTemplateName);
|
||||
}
|
||||
|
||||
pChild = pChild->NextSiblingElement();
|
||||
@@ -406,7 +410,7 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TS
|
||||
{
|
||||
CScriptTemplate *pScript = new CScriptTemplate(mpMaster);
|
||||
pScript->mObjectID = ObjectID;
|
||||
pScript->mpBaseStruct = new CStructTemplate(-1, nullptr);
|
||||
pScript->mpBaseStruct = new CStructTemplate(-1, nullptr, mpMaster);
|
||||
pScript->mSourceFile = rkTemplateName;
|
||||
|
||||
XMLElement *pRoot = pDoc->FirstChildElement("ScriptTemplate");
|
||||
@@ -424,7 +428,7 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(XMLDocument *pDoc, const TS
|
||||
XMLElement *pPropsElem = pRoot->FirstChildElement("properties");
|
||||
|
||||
if (pPropsElem)
|
||||
LoadProperties(pPropsElem, pScript->mpBaseStruct, rkTemplateName);
|
||||
LoadProperties(pPropsElem, pScript, pScript->mpBaseStruct, rkTemplateName);
|
||||
else
|
||||
Log::Error(rkTemplateName + ": There is no \"properties\" block element");
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ class CTemplateLoader
|
||||
: mTemplatesDir(rkTemplatesDir) {}
|
||||
|
||||
// Load Property
|
||||
IPropertyTemplate* LoadProperty(tinyxml2::XMLElement *pElem, CStructTemplate *pParentStruct, const TString& rkTemplateName);
|
||||
IPropertyTemplate* CreateProperty(u32 ID, EPropertyType Type, const TString& rkName, CStructTemplate *pStruct);
|
||||
IPropertyTemplate* LoadProperty(tinyxml2::XMLElement *pElem, CScriptTemplate *pScript, CStructTemplate *pParentStruct, const TString& rkTemplateName);
|
||||
IPropertyTemplate* CreateProperty(u32 ID, EPropertyType Type, const TString& rkName, CScriptTemplate *pScript, CStructTemplate *pStruct);
|
||||
|
||||
void LoadStructTemplate(const TString& rkTemplateFileName, CStructTemplate *pStruct);
|
||||
void LoadEnumTemplate(const TString& rkTemplateFileName, CEnumTemplate *pEnum);
|
||||
void LoadBitfieldTemplate(const TString& rkTemplateFileName, CBitfieldTemplate *pBitfield);
|
||||
|
||||
void LoadProperties(tinyxml2::XMLElement *pPropertiesElem, CStructTemplate *pStruct, const TString& rkTemplateName);
|
||||
void LoadProperties(tinyxml2::XMLElement *pPropertiesElem, CScriptTemplate *pScript, CStructTemplate *pStruct, const TString& rkTemplateName);
|
||||
void LoadEnumerators(tinyxml2::XMLElement *pEnumeratorsElem, CEnumTemplate *pEnum, const TString& rkTemplateName);
|
||||
void LoadBitFlags(tinyxml2::XMLElement *pFlagsElem, CBitfieldTemplate *pBitfield, const TString& rkTemplateName);
|
||||
|
||||
|
||||
@@ -104,6 +104,16 @@ TString CMasterTemplate::GetDirectory() const
|
||||
return mSourceFile.GetFileDirectory();
|
||||
}
|
||||
|
||||
CStructTemplate* CMasterTemplate::GetStructAtSource(const TString& rkSource)
|
||||
{
|
||||
auto InfoIt = mStructTemplates.find(rkSource);
|
||||
|
||||
if (InfoIt != mStructTemplates.end())
|
||||
return InfoIt->second;
|
||||
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
bool CMasterTemplate::IsLoadedSuccessfully()
|
||||
{
|
||||
return mFullyLoaded;
|
||||
@@ -140,46 +150,92 @@ TString CMasterTemplate::GetPropertyName(u32 PropertyID)
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
void CMasterTemplate::AddProperty(IPropertyTemplate *pTemp, const TString& rkTemplateName)
|
||||
u32 CMasterTemplate::CreatePropertyID(IPropertyTemplate *pTemp)
|
||||
{
|
||||
auto it = smIDMap.find(pTemp->PropertyID());
|
||||
// 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).
|
||||
TString IDString = pTemp->IDString(false);
|
||||
TString Source;
|
||||
CStructTemplate *pStruct = pTemp->Parent();
|
||||
|
||||
while (pStruct)
|
||||
{
|
||||
Source = pStruct->SourceFile();
|
||||
if (!Source.IsEmpty()) break;
|
||||
IDString.Prepend(pStruct->IDString(false) + ":");
|
||||
pStruct = pStruct->Parent();
|
||||
}
|
||||
|
||||
return IDString.Hash32() * Source.Hash32();
|
||||
}
|
||||
|
||||
void CMasterTemplate::AddProperty(IPropertyTemplate *pTemp, const TString& rkTemplateName /*= ""*/)
|
||||
{
|
||||
u32 ID;
|
||||
|
||||
if (pTemp->Game() >= eEchoesDemo)
|
||||
ID = pTemp->PropertyID();
|
||||
|
||||
// Use a different ID for MP1
|
||||
else
|
||||
{
|
||||
// For MP1 we only really need to track properties that come from struct templates.
|
||||
if (!pTemp->IsFromStructTemplate()) return;
|
||||
else ID = CreatePropertyID(pTemp);
|
||||
}
|
||||
|
||||
auto it = smIDMap.find(ID);
|
||||
|
||||
// Add this property/template to existing ID info
|
||||
if (it != smIDMap.end())
|
||||
{
|
||||
SPropIDInfo& rInfo = it->second;
|
||||
bool NewTemplate = true;
|
||||
rInfo.PropertyList.push_back(pTemp);
|
||||
|
||||
for (u32 iTemp = 0; iTemp < rInfo.XMLList.size(); iTemp++)
|
||||
if (!rkTemplateName.IsEmpty())
|
||||
{
|
||||
if (rInfo.XMLList[iTemp] == rkTemplateName)
|
||||
bool NewTemplate = true;
|
||||
|
||||
for (u32 iTemp = 0; iTemp < rInfo.XMLList.size(); iTemp++)
|
||||
{
|
||||
NewTemplate = false;
|
||||
break;
|
||||
if (rInfo.XMLList[iTemp] == rkTemplateName)
|
||||
{
|
||||
NewTemplate = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NewTemplate)
|
||||
rInfo.XMLList.push_back(rkTemplateName);
|
||||
}
|
||||
|
||||
if (NewTemplate)
|
||||
rInfo.XMLList.push_back(rkTemplateName);
|
||||
|
||||
it->second.PropertyList.push_back(pTemp);
|
||||
}
|
||||
|
||||
// Create new ID info
|
||||
else
|
||||
{
|
||||
SPropIDInfo Info;
|
||||
Info.XMLList.push_back(rkTemplateName);
|
||||
if (!rkTemplateName.IsEmpty()) Info.XMLList.push_back(rkTemplateName);
|
||||
Info.PropertyList.push_back(pTemp);
|
||||
smIDMap[pTemp->PropertyID()] = Info;
|
||||
smIDMap[ID] = Info;
|
||||
}
|
||||
}
|
||||
|
||||
void CMasterTemplate::RenameProperty(u32 ID, const TString& rkNewName)
|
||||
void CMasterTemplate::RenameProperty(IPropertyTemplate *pTemp, const TString& rkNewName)
|
||||
{
|
||||
auto NameIt = smPropertyNames.find(ID);
|
||||
TString CurName = (NameIt == smPropertyNames.end() ? "" : NameIt->second);
|
||||
u32 ID = pTemp->PropertyID();
|
||||
if (ID <= 0xFF) ID = CreatePropertyID(pTemp);
|
||||
|
||||
// Master name list
|
||||
auto NameIt = smPropertyNames.find(ID);
|
||||
TString Original;
|
||||
|
||||
if (NameIt != smPropertyNames.end())
|
||||
{
|
||||
Original = NameIt->second;
|
||||
smPropertyNames[ID] = rkNewName;
|
||||
}
|
||||
|
||||
// Properties
|
||||
auto InfoIt = smIDMap.find(ID);
|
||||
|
||||
if (InfoIt != smIDMap.end())
|
||||
@@ -188,18 +244,13 @@ void CMasterTemplate::RenameProperty(u32 ID, const TString& rkNewName)
|
||||
|
||||
for (u32 iTemp = 0; iTemp < rkInfo.PropertyList.size(); iTemp++)
|
||||
{
|
||||
IPropertyTemplate *pTemp = rkInfo.PropertyList[iTemp];
|
||||
|
||||
if (pTemp->Name() == CurName)
|
||||
pTemp->SetName(rkNewName);
|
||||
if (Original.IsEmpty() || rkInfo.PropertyList[iTemp]->Name() == Original)
|
||||
rkInfo.PropertyList[iTemp]->SetName(rkNewName);
|
||||
}
|
||||
}
|
||||
|
||||
if (NameIt != smPropertyNames.end())
|
||||
smPropertyNames[ID] = rkNewName;
|
||||
}
|
||||
|
||||
std::vector<TString> CMasterTemplate::GetTemplatesUsingID(u32 ID)
|
||||
std::vector<TString> CMasterTemplate::GetXMLsUsingID(u32 ID)
|
||||
{
|
||||
auto InfoIt = smIDMap.find(ID);
|
||||
|
||||
@@ -212,6 +263,21 @@ std::vector<TString> CMasterTemplate::GetTemplatesUsingID(u32 ID)
|
||||
return std::vector<TString>();
|
||||
}
|
||||
|
||||
const std::vector<IPropertyTemplate*>* CMasterTemplate::GetTemplatesWithMatchingID(IPropertyTemplate *pTemp)
|
||||
{
|
||||
u32 ID = pTemp->PropertyID();
|
||||
if (ID <= 0xFF) ID = CreatePropertyID(pTemp);
|
||||
|
||||
auto InfoIt = smIDMap.find(ID);
|
||||
|
||||
if (InfoIt != smIDMap.end())
|
||||
{
|
||||
const SPropIDInfo& rkInfo = InfoIt->second;
|
||||
return &rkInfo.PropertyList;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::map<u32, CMasterTemplate::SPropIDInfo> CMasterTemplate::smIDMap;
|
||||
std::map<EGame, CMasterTemplate*> CMasterTemplate::smMasterMap;
|
||||
std::map<u32, TString> CMasterTemplate::smPropertyNames;
|
||||
|
||||
@@ -53,14 +53,17 @@ public:
|
||||
TString MessageByID(const CFourCC& MessageID);
|
||||
TString MessageByIndex(u32 Index);
|
||||
TString GetDirectory() const;
|
||||
CStructTemplate* GetStructAtSource(const TString& rkSource);
|
||||
bool IsLoadedSuccessfully();
|
||||
|
||||
static CMasterTemplate* GetMasterForGame(EGame Game);
|
||||
static std::list<CMasterTemplate*> GetMasterList();
|
||||
static TString GetPropertyName(u32 PropertyID);
|
||||
static void AddProperty(IPropertyTemplate *pTemp, const TString& rkTemplateName);
|
||||
static void RenameProperty(u32 ID, const TString& rkNewName);
|
||||
static std::vector<TString> GetTemplatesUsingID(u32 ID);
|
||||
static u32 CreatePropertyID(IPropertyTemplate *pTemp);
|
||||
static void AddProperty(IPropertyTemplate *pTemp, const TString& rkTemplateName = "");
|
||||
static void RenameProperty(IPropertyTemplate *pTemp, const TString& rkNewName);
|
||||
static std::vector<TString> GetXMLsUsingID(u32 ID);
|
||||
static const std::vector<IPropertyTemplate*>* GetTemplatesWithMatchingID(IPropertyTemplate *pTemp);
|
||||
};
|
||||
|
||||
// ************ INLINE ************
|
||||
|
||||
@@ -117,6 +117,7 @@ public:
|
||||
CCollisionMeshGroup* FindCollision(CPropertyStruct *pProperties);
|
||||
bool HasInGameModel(CPropertyStruct *pProperties);
|
||||
|
||||
inline TString SourceFile() const { return mSourceFile; }
|
||||
inline bool HasName() const { return !mNameIDString.IsEmpty(); }
|
||||
inline bool HasPosition() const { return !mPositionIDString.IsEmpty(); }
|
||||
inline bool HasRotation() const { return !mRotationIDString.IsEmpty(); }
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#include "IPropertyTemplate.h"
|
||||
#include "CMasterTemplate.h"
|
||||
#include <iostream>
|
||||
|
||||
// ************ IPropertyTemplate ************
|
||||
EGame IPropertyTemplate::Game() const
|
||||
{
|
||||
return (mpMasterTemplate ? mpMasterTemplate->GetGame() : eUnknownVersion);
|
||||
}
|
||||
|
||||
bool IPropertyTemplate::IsInVersion(u32 Version) const
|
||||
{
|
||||
if (mAllowedVersions.empty())
|
||||
@@ -32,6 +38,45 @@ TIDString IPropertyTemplate::IDString(bool FullPath) const
|
||||
else return "";
|
||||
}
|
||||
|
||||
bool IPropertyTemplate::IsDescendantOf(const CStructTemplate *pStruct) const
|
||||
{
|
||||
CStructTemplate *pParent = mpParent;
|
||||
|
||||
while (pParent)
|
||||
{
|
||||
if (pParent == pStruct) return true;
|
||||
pParent = pParent->Parent();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IPropertyTemplate::IsFromStructTemplate() const
|
||||
{
|
||||
const CStructTemplate *pParent = Parent();
|
||||
|
||||
while (pParent)
|
||||
{
|
||||
if (!pParent->SourceFile().IsEmpty()) return true;
|
||||
pParent = pParent->Parent();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
TString IPropertyTemplate::FindStructSource() const
|
||||
{
|
||||
const CStructTemplate *pkStruct = mpParent;
|
||||
|
||||
while (pkStruct)
|
||||
{
|
||||
if (!pkStruct->SourceFile().IsEmpty()) return pkStruct->SourceFile();
|
||||
pkStruct = pkStruct->Parent();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
CStructTemplate* IPropertyTemplate::RootStruct()
|
||||
{
|
||||
if (mpParent) return mpParent->RootStruct();
|
||||
@@ -40,19 +85,19 @@ CStructTemplate* IPropertyTemplate::RootStruct()
|
||||
}
|
||||
|
||||
// ************ CStructTemplate ************
|
||||
bool CStructTemplate::IsSingleProperty() const
|
||||
void CStructTemplate::CopyStructData(const CStructTemplate *pkStruct)
|
||||
{
|
||||
return mIsSingleProperty;
|
||||
}
|
||||
mVersionPropertyCounts = pkStruct->mVersionPropertyCounts;
|
||||
mIsSingleProperty = pkStruct->mIsSingleProperty;
|
||||
mSourceFile = pkStruct->mSourceFile;
|
||||
|
||||
u32 CStructTemplate::Count() const
|
||||
{
|
||||
return mSubProperties.size();
|
||||
}
|
||||
mSubProperties.resize(pkStruct->mSubProperties.size());
|
||||
|
||||
u32 CStructTemplate::NumVersions()
|
||||
{
|
||||
return mVersionPropertyCounts.size();
|
||||
for (u32 iSub = 0; iSub < pkStruct->mSubProperties.size(); iSub++)
|
||||
{
|
||||
mSubProperties[iSub] = pkStruct->mSubProperties[iSub]->Clone(mpScriptTemplate, this);
|
||||
CMasterTemplate::AddProperty(mSubProperties[iSub]);
|
||||
}
|
||||
}
|
||||
|
||||
u32 CStructTemplate::PropertyCountForVersion(u32 Version)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <vector>
|
||||
|
||||
typedef TString TIDString;
|
||||
class CMasterTemplate;
|
||||
class CStructTemplate;
|
||||
class IProperty;
|
||||
|
||||
@@ -31,6 +32,8 @@ class IPropertyTemplate
|
||||
|
||||
protected:
|
||||
CStructTemplate *mpParent;
|
||||
CScriptTemplate *mpScriptTemplate;
|
||||
CMasterTemplate *mpMasterTemplate;
|
||||
TString mName;
|
||||
TString mDescription;
|
||||
u32 mID;
|
||||
@@ -38,17 +41,21 @@ protected:
|
||||
std::vector<u32> mAllowedVersions;
|
||||
|
||||
public:
|
||||
IPropertyTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
IPropertyTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: mID(ID)
|
||||
, mpParent(pParent)
|
||||
, mpScriptTemplate(pScript)
|
||||
, mpMasterTemplate(pMaster)
|
||||
, mName("UNSET PROPERTY NAME")
|
||||
, mCookPreference(eNoCookPreference)
|
||||
{
|
||||
}
|
||||
|
||||
IPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
IPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: mID(ID)
|
||||
, mpParent(pParent)
|
||||
, mpScriptTemplate(pScript)
|
||||
, mpMasterTemplate(pMaster)
|
||||
, mName(rkName)
|
||||
, mCookPreference(CookPreference)
|
||||
{
|
||||
@@ -58,7 +65,7 @@ public:
|
||||
virtual bool CanHaveDefault() const = 0;
|
||||
virtual bool IsNumerical() const = 0;
|
||||
virtual IProperty* InstantiateProperty(CPropertyStruct *pParent) = 0;
|
||||
virtual IPropertyTemplate* Clone(CStructTemplate *pParent = 0) const = 0;
|
||||
virtual IPropertyTemplate* Clone(CScriptTemplate *pScript, CStructTemplate *pParent = 0) const = 0;
|
||||
|
||||
virtual void Copy(const IPropertyTemplate *pkTemp)
|
||||
{
|
||||
@@ -104,8 +111,12 @@ public:
|
||||
mDescription = rkValue;
|
||||
}
|
||||
|
||||
EGame Game() const;
|
||||
bool IsInVersion(u32 Version) const;
|
||||
TIDString IDString(bool FullPath) const;
|
||||
bool IsDescendantOf(const CStructTemplate *pStruct) const;
|
||||
bool IsFromStructTemplate() const;
|
||||
TString FindStructSource() const;
|
||||
CStructTemplate* RootStruct();
|
||||
|
||||
// Inline Accessors
|
||||
@@ -114,16 +125,19 @@ public:
|
||||
inline u32 PropertyID() const { return mID; }
|
||||
inline ECookPreference CookPreference() const { return mCookPreference; }
|
||||
inline CStructTemplate* Parent() const { return mpParent; }
|
||||
inline CScriptTemplate* ScriptTemplate() const { return mpScriptTemplate; }
|
||||
inline CMasterTemplate* MasterTemplate() const { return mpMasterTemplate; }
|
||||
inline void SetName(const TString& rkName) { mName = rkName; }
|
||||
inline void SetDescription(const TString& rkDesc) { mDescription = rkDesc; }
|
||||
};
|
||||
|
||||
// Macro for defining reimplementations of IPropertyTemplate::Clone(), which are usually identical to each other aside from the class being instantiated
|
||||
#define DEFINE_TEMPLATE_CLONE(ClassName) \
|
||||
virtual IPropertyTemplate* Clone(CStructTemplate *pParent = 0) const \
|
||||
#define IMPLEMENT_TEMPLATE_CLONE(ClassName) \
|
||||
virtual IPropertyTemplate* Clone(CScriptTemplate *pScript, CStructTemplate *pParent = 0) const \
|
||||
{ \
|
||||
if (!pParent) pParent = mpParent; \
|
||||
ClassName *pTemp = new ClassName(mID, pParent); \
|
||||
if (!pScript) pScript = mpScriptTemplate; \
|
||||
ClassName *pTemp = new ClassName(mID, pScript, mpMasterTemplate, pParent); \
|
||||
pTemp->Copy(this); \
|
||||
return pTemp; \
|
||||
}
|
||||
@@ -140,11 +154,11 @@ protected:
|
||||
ValueClass mDefaultValue;
|
||||
|
||||
public:
|
||||
TTypedPropertyTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, pParent) {}
|
||||
TTypedPropertyTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, pScript, pMaster, pParent) {}
|
||||
|
||||
TTypedPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, rkName, CookPreference, pParent) {}
|
||||
TTypedPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {}
|
||||
|
||||
virtual EPropertyType Type() const { return PropTypeEnum; }
|
||||
virtual bool CanHaveDefault() const { return CanHaveDefaultValue; }
|
||||
@@ -159,7 +173,7 @@ public:
|
||||
return pOut;
|
||||
}
|
||||
|
||||
DEFINE_TEMPLATE_CLONE(TTypedPropertyTemplate)
|
||||
IMPLEMENT_TEMPLATE_CLONE(TTypedPropertyTemplate)
|
||||
|
||||
virtual void Copy(const IPropertyTemplate *pkTemp)
|
||||
{
|
||||
@@ -210,12 +224,12 @@ class TNumericalPropertyTemplate : public TTypedPropertyTemplate<PropType,PropTy
|
||||
TString mSuffix;
|
||||
|
||||
public:
|
||||
TNumericalPropertyTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, pParent)
|
||||
TNumericalPropertyTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, pScript, pMaster, pParent)
|
||||
{}
|
||||
|
||||
TNumericalPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, rkName, CookPreference, pParent)
|
||||
TNumericalPropertyTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent)
|
||||
, mMin(0)
|
||||
, mMax(0)
|
||||
{}
|
||||
@@ -223,7 +237,7 @@ public:
|
||||
virtual bool IsNumerical() const { return true; }
|
||||
virtual bool HasValidRange() const { return (mMin != 0 || mMax != 0); }
|
||||
|
||||
DEFINE_TEMPLATE_CLONE(TNumericalPropertyTemplate)
|
||||
IMPLEMENT_TEMPLATE_CLONE(TNumericalPropertyTemplate)
|
||||
|
||||
virtual void Copy(const IPropertyTemplate *pkTemp)
|
||||
{
|
||||
@@ -307,11 +321,11 @@ class CFileTemplate : public IPropertyTemplate
|
||||
|
||||
TStringList mAcceptedExtensions;
|
||||
public:
|
||||
CFileTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, pParent) {}
|
||||
CFileTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, pScript, pMaster, pParent) {}
|
||||
|
||||
CFileTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, rkName, CookPreference, pParent) {}
|
||||
CFileTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent) {}
|
||||
|
||||
virtual EPropertyType Type() const { return eFileProperty; }
|
||||
virtual bool CanHaveDefault() const { return false; }
|
||||
@@ -322,7 +336,7 @@ public:
|
||||
return new TFileProperty(this, pParent);
|
||||
}
|
||||
|
||||
DEFINE_TEMPLATE_CLONE(CFileTemplate)
|
||||
IMPLEMENT_TEMPLATE_CLONE(CFileTemplate)
|
||||
|
||||
virtual void Copy(const IPropertyTemplate *pkTemp)
|
||||
{
|
||||
@@ -372,13 +386,13 @@ class CEnumTemplate : public TTypedPropertyTemplate<s32, eEnumProperty, CHexLong
|
||||
TString mSourceFile;
|
||||
|
||||
public:
|
||||
CEnumTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, pParent)
|
||||
CEnumTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, pScript, pMaster, pParent)
|
||||
{
|
||||
}
|
||||
|
||||
CEnumTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, rkName, CookPreference, pParent)
|
||||
CEnumTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -393,7 +407,7 @@ public:
|
||||
return pEnum;
|
||||
}
|
||||
|
||||
DEFINE_TEMPLATE_CLONE(CEnumTemplate)
|
||||
IMPLEMENT_TEMPLATE_CLONE(CEnumTemplate)
|
||||
|
||||
virtual void Copy(const IPropertyTemplate *pkTemp)
|
||||
{
|
||||
@@ -413,10 +427,8 @@ public:
|
||||
(mSourceFile == pkEnum->mSourceFile) );
|
||||
}
|
||||
|
||||
inline u32 NumEnumerators() const
|
||||
{
|
||||
return mEnumerators.size();
|
||||
}
|
||||
inline TString SourceFile() const { return mSourceFile; }
|
||||
inline u32 NumEnumerators() const { return mEnumerators.size(); }
|
||||
|
||||
u32 EnumeratorIndex(u32 enumID) const
|
||||
{
|
||||
@@ -469,13 +481,13 @@ class CBitfieldTemplate : public TTypedPropertyTemplate<u32, eBitfieldProperty,
|
||||
TString mSourceFile;
|
||||
|
||||
public:
|
||||
CBitfieldTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, pParent)
|
||||
CBitfieldTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, pScript, pMaster, pParent)
|
||||
{
|
||||
}
|
||||
|
||||
CBitfieldTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, rkName, CookPreference, pParent)
|
||||
CBitfieldTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: TTypedPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -490,7 +502,7 @@ public:
|
||||
return pBitfield;
|
||||
}
|
||||
|
||||
DEFINE_TEMPLATE_CLONE(CBitfieldTemplate)
|
||||
IMPLEMENT_TEMPLATE_CLONE(CBitfieldTemplate)
|
||||
|
||||
virtual void Copy(const IPropertyTemplate *pkTemp)
|
||||
{
|
||||
@@ -510,9 +522,10 @@ public:
|
||||
(mSourceFile == pkBitfield->mSourceFile) );
|
||||
}
|
||||
|
||||
u32 NumFlags() const { return mBitFlags.size(); }
|
||||
TString FlagName(u32 index) const { return mBitFlags[index].Name; }
|
||||
u32 FlagMask(u32 index) const { return mBitFlags[index].Mask; }
|
||||
inline TString SourceFile() const { return mSourceFile; }
|
||||
inline u32 NumFlags() const { return mBitFlags.size(); }
|
||||
inline TString FlagName(u32 index) const { return mBitFlags[index].Name; }
|
||||
inline u32 FlagMask(u32 index) const { return mBitFlags[index].Mask; }
|
||||
};
|
||||
|
||||
// CStructTemplate - Defines structs composed of multiple sub-properties.
|
||||
@@ -529,12 +542,12 @@ protected:
|
||||
|
||||
void DetermineVersionPropertyCounts();
|
||||
public:
|
||||
CStructTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, pParent)
|
||||
CStructTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, pScript, pMaster, pParent)
|
||||
, mIsSingleProperty(false) {}
|
||||
|
||||
CStructTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, rkName, CookPreference, pParent)
|
||||
CStructTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: IPropertyTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent)
|
||||
, mIsSingleProperty(false) {}
|
||||
|
||||
~CStructTemplate()
|
||||
@@ -560,7 +573,7 @@ public:
|
||||
return pStruct;
|
||||
}
|
||||
|
||||
DEFINE_TEMPLATE_CLONE(CStructTemplate)
|
||||
IMPLEMENT_TEMPLATE_CLONE(CStructTemplate)
|
||||
|
||||
virtual void Copy(const IPropertyTemplate *pkTemp)
|
||||
{
|
||||
@@ -570,17 +583,7 @@ public:
|
||||
CopyStructData(pkStruct);
|
||||
}
|
||||
|
||||
void CopyStructData(const CStructTemplate *pkStruct)
|
||||
{
|
||||
mVersionPropertyCounts = pkStruct->mVersionPropertyCounts;
|
||||
mIsSingleProperty = pkStruct->mIsSingleProperty;
|
||||
mSourceFile = pkStruct->mSourceFile;
|
||||
|
||||
mSubProperties.resize(pkStruct->mSubProperties.size());
|
||||
|
||||
for (u32 iSub = 0; iSub < pkStruct->mSubProperties.size(); iSub++)
|
||||
mSubProperties[iSub] = pkStruct->mSubProperties[iSub]->Clone(this);
|
||||
}
|
||||
void CopyStructData(const CStructTemplate *pkStruct);
|
||||
|
||||
virtual bool Matches(const IPropertyTemplate *pkTemp) const
|
||||
{
|
||||
@@ -614,9 +617,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsSingleProperty() const;
|
||||
u32 Count() const;
|
||||
u32 NumVersions();
|
||||
inline TString SourceFile() const { return mSourceFile; }
|
||||
inline bool IsSingleProperty() const { return mIsSingleProperty; }
|
||||
inline u32 Count() const { return mSubProperties.size(); }
|
||||
inline u32 NumVersions() const { return mVersionPropertyCounts.size(); }
|
||||
|
||||
u32 PropertyCountForVersion(u32 Version);
|
||||
u32 VersionForPropertyCount(u32 PropCount);
|
||||
IPropertyTemplate* PropertyByIndex(u32 index);
|
||||
@@ -638,14 +643,14 @@ class CArrayTemplate : public CStructTemplate
|
||||
TString mElementName;
|
||||
|
||||
public:
|
||||
CArrayTemplate(u32 ID, CStructTemplate *pParent = 0)
|
||||
: CStructTemplate(ID, pParent)
|
||||
CArrayTemplate(u32 ID, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: CStructTemplate(ID, pScript, pMaster, pParent)
|
||||
{
|
||||
mIsSingleProperty = true;
|
||||
}
|
||||
|
||||
CArrayTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CStructTemplate *pParent = 0)
|
||||
: CStructTemplate(ID, rkName, CookPreference, pParent)
|
||||
CArrayTemplate(u32 ID, const TString& rkName, ECookPreference CookPreference, CScriptTemplate *pScript, CMasterTemplate *pMaster, CStructTemplate *pParent = 0)
|
||||
: CStructTemplate(ID, rkName, CookPreference, pScript, pMaster, pParent)
|
||||
{
|
||||
mIsSingleProperty = true;
|
||||
}
|
||||
@@ -657,12 +662,10 @@ public:
|
||||
return new CArrayProperty(this, pParent);
|
||||
}
|
||||
|
||||
DEFINE_TEMPLATE_CLONE(CArrayTemplate)
|
||||
IMPLEMENT_TEMPLATE_CLONE(CArrayTemplate)
|
||||
|
||||
virtual void Copy(const IPropertyTemplate *pkTemp)
|
||||
{
|
||||
IPropertyTemplate::Copy(pkTemp);
|
||||
|
||||
CStructTemplate::Copy(pkTemp);
|
||||
mElementName = static_cast<const CArrayTemplate*>(pkTemp)->mElementName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user