Merged all the Properties.xmls together to eliminate the need to sync property name changes between games
This commit is contained in:
parent
55b2c053ab
commit
d9b5895074
|
@ -78,9 +78,9 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster, const TString&
|
||||||
Master.LinkEndChild(pBase);
|
Master.LinkEndChild(pBase);
|
||||||
|
|
||||||
// Write property list
|
// Write property list
|
||||||
if (!pMaster->mPropertyNames.empty())
|
if (!pMaster->smPropertyNames.empty())
|
||||||
{
|
{
|
||||||
SavePropertyList(pMaster, OutDir);
|
SavePropertyList(OutDir);
|
||||||
|
|
||||||
XMLElement *pPropList = Master.NewElement("properties");
|
XMLElement *pPropList = Master.NewElement("properties");
|
||||||
pPropList->SetText("Properties.xml");
|
pPropList->SetText("Properties.xml");
|
||||||
|
@ -147,7 +147,7 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster, const TString&
|
||||||
Master.SaveFile(*OutFile);
|
Master.SaveFile(*OutFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const TString& rkDir)
|
void CTemplateWriter::SavePropertyList(const TString& rkDir)
|
||||||
{
|
{
|
||||||
// Create XML
|
// Create XML
|
||||||
XMLDocument List;
|
XMLDocument List;
|
||||||
|
@ -160,7 +160,7 @@ void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const TString&
|
||||||
List.LinkEndChild(pBase);
|
List.LinkEndChild(pBase);
|
||||||
|
|
||||||
// Write properties
|
// Write properties
|
||||||
for (auto it = pMaster->mPropertyNames.begin(); it != pMaster->mPropertyNames.end(); it++)
|
for (auto it = CMasterTemplate::smPropertyNames.begin(); it != CMasterTemplate::smPropertyNames.end(); it++)
|
||||||
{
|
{
|
||||||
u32 ID = it->first;
|
u32 ID = it->first;
|
||||||
TString Name = it->second;
|
TString Name = it->second;
|
||||||
|
@ -442,9 +442,9 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||||
// Name
|
// Name
|
||||||
TString Name = pProp->Name();
|
TString Name = pProp->Name();
|
||||||
|
|
||||||
if (pMaster->HasPropertyList())
|
if (pMaster->GetGame() >= eEchoesDemo)
|
||||||
{
|
{
|
||||||
TString MasterName = pMaster->PropertyName(ID);
|
TString MasterName = CMasterTemplate::GetPropertyName(ID);
|
||||||
|
|
||||||
if (Name != MasterName)
|
if (Name != MasterName)
|
||||||
pElem->SetAttribute("name", *Name);
|
pElem->SetAttribute("name", *Name);
|
||||||
|
|
|
@ -12,7 +12,7 @@ class CTemplateWriter
|
||||||
public:
|
public:
|
||||||
static void SaveAllTemplates();
|
static void SaveAllTemplates();
|
||||||
static void SaveGameTemplates(CMasterTemplate *pMaster, const TString& rkDir);
|
static void SaveGameTemplates(CMasterTemplate *pMaster, const TString& rkDir);
|
||||||
static void SavePropertyList(CMasterTemplate *pMaster, const TString& rkDir);
|
static void SavePropertyList(const TString& rkDir);
|
||||||
static void SaveScriptTemplate(CScriptTemplate *pTemp, const TString& rkDir);
|
static void SaveScriptTemplate(CScriptTemplate *pTemp, const TString& rkDir);
|
||||||
static void SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster, const TString& rkDir);
|
static void SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster, const TString& rkDir);
|
||||||
static void SaveEnumTemplate(CEnumTemplate *pTemp, const TString& rkDir);
|
static void SaveEnumTemplate(CEnumTemplate *pTemp, const TString& rkDir);
|
||||||
|
|
|
@ -29,8 +29,8 @@ IPropertyTemplate* CTemplateLoader::LoadProperty(XMLElement *pElem, CStructTempl
|
||||||
|
|
||||||
if (!NameAttr.IsEmpty())
|
if (!NameAttr.IsEmpty())
|
||||||
Name = NameAttr;
|
Name = NameAttr;
|
||||||
else if (mpMaster->HasPropertyList())
|
else if (mGame >= eEchoesDemo)
|
||||||
Name = mpMaster->PropertyName(ID);
|
Name = CMasterTemplate::GetPropertyName(ID);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::Error("Error reading " + rkTemplateName + " property " + TString::HexString(ID, true, true, 8) + "; this property doesn't have a name either in the template itself nor in the master list");
|
Log::Error("Error reading " + rkTemplateName + " property " + TString::HexString(ID, true, true, 8) + "; this property doesn't have a name either in the template itself nor in the master list");
|
||||||
|
@ -636,17 +636,6 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
|
||||||
{
|
{
|
||||||
TString NodeName = pElem->Name();
|
TString NodeName = pElem->Name();
|
||||||
|
|
||||||
// Properties
|
|
||||||
if (NodeName == "properties")
|
|
||||||
{
|
|
||||||
TString PropListPath = pElem->GetText();
|
|
||||||
XMLDocument PropListXML;
|
|
||||||
OpenXML(mMasterDir + PropListPath, PropListXML);
|
|
||||||
|
|
||||||
if (!PropListXML.Error())
|
|
||||||
LoadPropertyList(&PropListXML, PropListPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Versions
|
// Versions
|
||||||
if (NodeName == "versions")
|
if (NodeName == "versions")
|
||||||
{
|
{
|
||||||
|
@ -744,32 +733,6 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
|
||||||
pMaster->mFullyLoaded = true;
|
pMaster->mFullyLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateLoader::LoadPropertyList(XMLDocument *pDoc, const TString& ListName)
|
|
||||||
{
|
|
||||||
XMLElement *pRootElem = pDoc->FirstChildElement("Properties");
|
|
||||||
|
|
||||||
if (!pRootElem)
|
|
||||||
Log::Error("Error reading property list at " + ListName + "; there is no root \"Properties\" block element");
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XMLElement *pElem = pRootElem->FirstChildElement("property");
|
|
||||||
|
|
||||||
while (pElem)
|
|
||||||
{
|
|
||||||
TString ID = pElem->Attribute("ID");
|
|
||||||
TString Name = pElem->Attribute("name");
|
|
||||||
|
|
||||||
if (!ID.IsEmpty() && !Name.IsEmpty())
|
|
||||||
mpMaster->mPropertyNames[ID.ToInt32()] = Name;
|
|
||||||
|
|
||||||
pElem = pElem->NextSiblingElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
mpMaster->mHasPropList = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CMasterTemplate* CTemplateLoader::LoadGameInfo(XMLNode *pNode)
|
CMasterTemplate* CTemplateLoader::LoadGameInfo(XMLNode *pNode)
|
||||||
{
|
{
|
||||||
CMasterTemplate *pMaster = new CMasterTemplate();
|
CMasterTemplate *pMaster = new CMasterTemplate();
|
||||||
|
@ -855,29 +818,38 @@ void CTemplateLoader::LoadGameList()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
XMLNode *pNode = GameListXML.FirstChild()->NextSibling()->FirstChild();
|
XMLElement *pRoot = GameListXML.FirstChildElement("GameList");
|
||||||
|
const char *pkGameListVersion = pRoot->Attribute("version");
|
||||||
|
|
||||||
while (pNode)
|
if (pkGameListVersion)
|
||||||
{
|
CMasterTemplate::smGameListVersion = TString(pkGameListVersion).ToInt32(10);
|
||||||
XMLElement *pElement = pNode->ToElement();
|
|
||||||
TString NodeName = TString(pElement->Name()).ToLower();
|
|
||||||
|
|
||||||
// Game List version number
|
XMLElement *pElem = pRoot->FirstChildElement();
|
||||||
if (NodeName == "version")
|
|
||||||
|
while (pElem)
|
||||||
{
|
{
|
||||||
u32 VersionNum = std::stoul(pElement->GetText());
|
TString NodeName = TString(pElem->Name()).ToLower();
|
||||||
CMasterTemplate::smGameListVersion = VersionNum;
|
|
||||||
|
// Properties
|
||||||
|
if (NodeName == "properties")
|
||||||
|
{
|
||||||
|
TString PropListPath = pElem->GetText();
|
||||||
|
XMLDocument PropListXML;
|
||||||
|
OpenXML(mskTemplatesDir + PropListPath, PropListXML);
|
||||||
|
|
||||||
|
if (!PropListXML.Error())
|
||||||
|
LoadPropertyList(&PropListXML, PropListPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Games
|
// Games
|
||||||
else if (NodeName == "game")
|
else if (NodeName == "game")
|
||||||
{
|
{
|
||||||
CTemplateLoader Loader(mskTemplatesDir);
|
CTemplateLoader Loader(mskTemplatesDir);
|
||||||
CMasterTemplate *pMaster = Loader.LoadGameInfo(pNode);
|
CMasterTemplate *pMaster = Loader.LoadGameInfo(pElem);
|
||||||
CMasterTemplate::smMasterMap[pMaster->mGame] = pMaster;
|
CMasterTemplate::smMasterMap[pMaster->mGame] = pMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
pNode = pNode->NextSibling();
|
pElem = pElem->NextSiblingElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,6 +869,7 @@ void CTemplateLoader::LoadGameTemplates(EGame Game)
|
||||||
if (!MasterXML.Error())
|
if (!MasterXML.Error())
|
||||||
{
|
{
|
||||||
CTemplateLoader Loader(mskTemplatesDir);
|
CTemplateLoader Loader(mskTemplatesDir);
|
||||||
|
Loader.mGame = Game;
|
||||||
Loader.LoadMasterTemplate(&MasterXML, pMaster);
|
Loader.LoadMasterTemplate(&MasterXML, pMaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,3 +877,27 @@ void CTemplateLoader::LoadGameTemplates(EGame Game)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CTemplateLoader::LoadPropertyList(XMLDocument *pDoc, const TString& ListName)
|
||||||
|
{
|
||||||
|
XMLElement *pRootElem = pDoc->FirstChildElement("Properties");
|
||||||
|
|
||||||
|
if (!pRootElem)
|
||||||
|
Log::Error("Error reading property list at " + ListName + "; there is no root \"Properties\" block element");
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XMLElement *pElem = pRootElem->FirstChildElement("property");
|
||||||
|
|
||||||
|
while (pElem)
|
||||||
|
{
|
||||||
|
TString ID = pElem->Attribute("ID");
|
||||||
|
TString Name = pElem->Attribute("name");
|
||||||
|
|
||||||
|
if (!ID.IsEmpty() && !Name.IsEmpty())
|
||||||
|
CMasterTemplate::smPropertyNames[ID.ToInt32()] = Name;
|
||||||
|
|
||||||
|
pElem = pElem->NextSiblingElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ class CTemplateLoader
|
||||||
static const TString mskGameListPath;
|
static const TString mskGameListPath;
|
||||||
|
|
||||||
CMasterTemplate *mpMaster;
|
CMasterTemplate *mpMaster;
|
||||||
|
EGame mGame;
|
||||||
TString mTemplatesDir;
|
TString mTemplatesDir;
|
||||||
TString mMasterDir;
|
TString mMasterDir;
|
||||||
|
|
||||||
|
@ -36,7 +37,6 @@ class CTemplateLoader
|
||||||
// Load Master
|
// Load Master
|
||||||
CMasterTemplate* LoadGameInfo(tinyxml2::XMLNode *pNode);
|
CMasterTemplate* LoadGameInfo(tinyxml2::XMLNode *pNode);
|
||||||
void LoadMasterTemplate(tinyxml2::XMLDocument *pDoc, CMasterTemplate *pMaster);
|
void LoadMasterTemplate(tinyxml2::XMLDocument *pDoc, CMasterTemplate *pMaster);
|
||||||
void LoadPropertyList(tinyxml2::XMLDocument *pDoc, const TString& rkListName);
|
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
static void OpenXML(const TString& rkPath, tinyxml2::XMLDocument& rDoc);
|
static void OpenXML(const TString& rkPath, tinyxml2::XMLDocument& rDoc);
|
||||||
|
@ -45,6 +45,7 @@ class CTemplateLoader
|
||||||
public:
|
public:
|
||||||
static void LoadGameList();
|
static void LoadGameList();
|
||||||
static void LoadGameTemplates(EGame Game);
|
static void LoadGameTemplates(EGame Game);
|
||||||
|
static void LoadPropertyList(tinyxml2::XMLDocument *pDoc, const TString& rkListName);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CTEMPLATELOADER_H
|
#endif // CTEMPLATELOADER_H
|
||||||
|
|
|
@ -6,7 +6,6 @@ CMasterTemplate::CMasterTemplate()
|
||||||
{
|
{
|
||||||
mVersion = 0;
|
mVersion = 0;
|
||||||
mFullyLoaded = false;
|
mFullyLoaded = false;
|
||||||
mHasPropList = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMasterTemplate::~CMasterTemplate()
|
CMasterTemplate::~CMasterTemplate()
|
||||||
|
@ -100,21 +99,6 @@ TString CMasterTemplate::MessageByIndex(u32 Index)
|
||||||
return (std::next(it, Index))->second;
|
return (std::next(it, Index))->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
TString CMasterTemplate::PropertyName(u32 PropertyID)
|
|
||||||
{
|
|
||||||
auto it = mPropertyNames.find(PropertyID);
|
|
||||||
|
|
||||||
if (it != mPropertyNames.end())
|
|
||||||
return it->second;
|
|
||||||
else
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMasterTemplate::HasPropertyList()
|
|
||||||
{
|
|
||||||
return mHasPropList;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMasterTemplate::IsLoadedSuccessfully()
|
bool CMasterTemplate::IsLoadedSuccessfully()
|
||||||
{
|
{
|
||||||
return mFullyLoaded;
|
return mFullyLoaded;
|
||||||
|
@ -141,5 +125,16 @@ std::list<CMasterTemplate*> CMasterTemplate::GetMasterList()
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TString CMasterTemplate::GetPropertyName(u32 PropertyID)
|
||||||
|
{
|
||||||
|
auto it = smPropertyNames.find(PropertyID);
|
||||||
|
|
||||||
|
if (it != smPropertyNames.end())
|
||||||
|
return it->second;
|
||||||
|
else
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
std::map<EGame, CMasterTemplate*> CMasterTemplate::smMasterMap;
|
std::map<EGame, CMasterTemplate*> CMasterTemplate::smMasterMap;
|
||||||
|
std::map<u32, TString> CMasterTemplate::smPropertyNames;
|
||||||
u32 CMasterTemplate::smGameListVersion;
|
u32 CMasterTemplate::smGameListVersion;
|
||||||
|
|
|
@ -22,10 +22,9 @@ class CMasterTemplate
|
||||||
std::map<u32, TString> mStates;
|
std::map<u32, TString> mStates;
|
||||||
std::map<u32, TString> mMessages;
|
std::map<u32, TString> mMessages;
|
||||||
|
|
||||||
bool mHasPropList;
|
|
||||||
std::map<u32, TString> mPropertyNames;
|
|
||||||
|
|
||||||
static std::map<EGame, CMasterTemplate*> smMasterMap;
|
static std::map<EGame, CMasterTemplate*> smMasterMap;
|
||||||
|
static std::map<u32, TString> smPropertyNames;
|
||||||
static u32 smGameListVersion;
|
static u32 smGameListVersion;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -46,12 +45,11 @@ public:
|
||||||
TString MessageByID(u32 MessageID);
|
TString MessageByID(u32 MessageID);
|
||||||
TString MessageByID(const CFourCC& MessageID);
|
TString MessageByID(const CFourCC& MessageID);
|
||||||
TString MessageByIndex(u32 Index);
|
TString MessageByIndex(u32 Index);
|
||||||
TString PropertyName(u32 PropertyID);
|
|
||||||
bool HasPropertyList();
|
|
||||||
bool IsLoadedSuccessfully();
|
bool IsLoadedSuccessfully();
|
||||||
|
|
||||||
static CMasterTemplate* GetMasterForGame(EGame Game);
|
static CMasterTemplate* GetMasterForGame(EGame Game);
|
||||||
static std::list<CMasterTemplate*> GetMasterList();
|
static std::list<CMasterTemplate*> GetMasterList();
|
||||||
|
static TString GetPropertyName(u32 PropertyID);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ************ INLINE ************
|
// ************ INLINE ************
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<GameList version="4">
|
<GameList version="4">
|
||||||
|
<properties>Properties.xml</properties>
|
||||||
<game>
|
<game>
|
||||||
<name>Metroid Prime</name>
|
<name>Metroid Prime</name>
|
||||||
<mrea>0x0F</mrea>
|
<mrea>0x0F</mrea>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MasterTemplate version="4">
|
<MasterTemplate version="4">
|
||||||
<properties>Properties.xml</properties>
|
|
||||||
<objects>
|
<objects>
|
||||||
<object ID="AIHT" template="Script/AIHint.xml"/>
|
<object ID="AIHT" template="Script/AIHint.xml"/>
|
||||||
<object ID="AIKF" template="Script/AIKeyframe.xml"/>
|
<object ID="AIKF" template="Script/AIKeyframe.xml"/>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MasterTemplate version="4">
|
<MasterTemplate version="4">
|
||||||
<properties>Properties.xml</properties>
|
|
||||||
<versions>
|
<versions>
|
||||||
<version>GameCube NTSC</version>
|
<version>GameCube NTSC</version>
|
||||||
<version>Trilogy</version>
|
<version>Trilogy</version>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MasterTemplate version="4">
|
<MasterTemplate version="4">
|
||||||
<properties>Properties.xml</properties>
|
|
||||||
<objects>
|
<objects>
|
||||||
<object ID="ACTR" template="Script/Actor.xml"/>
|
<object ID="ACTR" template="Script/Actor.xml"/>
|
||||||
<object ID="ACKF" template="Script/ActorKeyframe.xml"/>
|
<object ID="ACKF" template="Script/ActorKeyframe.xml"/>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MasterTemplate version="4">
|
<MasterTemplate version="4">
|
||||||
<properties>Properties.xml</properties>
|
|
||||||
<objects>
|
<objects>
|
||||||
<object ID="AIFZ" template="Script/AIFuse.xml"/>
|
<object ID="AIFZ" template="Script/AIFuse.xml"/>
|
||||||
<object ID="AIHT" template="Script/AIHint.xml"/>
|
<object ID="AIHT" template="Script/AIHint.xml"/>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MasterTemplate version="4">
|
<MasterTemplate version="4">
|
||||||
<properties>Properties.xml</properties>
|
|
||||||
<objects>
|
<objects>
|
||||||
<object ID="ACTR" template="Script/Actor.xml"/>
|
<object ID="ACTR" template="Script/Actor.xml"/>
|
||||||
<object ID="ACKF" template="Script/ActorKeyframe.xml"/>
|
<object ID="ACKF" template="Script/ActorKeyframe.xml"/>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue