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);
|
||||
|
||||
// Write property list
|
||||
if (!pMaster->mPropertyNames.empty())
|
||||
if (!pMaster->smPropertyNames.empty())
|
||||
{
|
||||
SavePropertyList(pMaster, OutDir);
|
||||
SavePropertyList(OutDir);
|
||||
|
||||
XMLElement *pPropList = Master.NewElement("properties");
|
||||
pPropList->SetText("Properties.xml");
|
||||
|
@ -147,7 +147,7 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster, const TString&
|
|||
Master.SaveFile(*OutFile);
|
||||
}
|
||||
|
||||
void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const TString& rkDir)
|
||||
void CTemplateWriter::SavePropertyList(const TString& rkDir)
|
||||
{
|
||||
// Create XML
|
||||
XMLDocument List;
|
||||
|
@ -160,7 +160,7 @@ void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const TString&
|
|||
List.LinkEndChild(pBase);
|
||||
|
||||
// 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;
|
||||
TString Name = it->second;
|
||||
|
@ -442,9 +442,9 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
|||
// 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)
|
||||
pElem->SetAttribute("name", *Name);
|
||||
|
|
|
@ -12,7 +12,7 @@ class CTemplateWriter
|
|||
public:
|
||||
static void SaveAllTemplates();
|
||||
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 SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster, const TString& rkDir);
|
||||
static void SaveEnumTemplate(CEnumTemplate *pTemp, const TString& rkDir);
|
||||
|
|
|
@ -29,8 +29,8 @@ IPropertyTemplate* CTemplateLoader::LoadProperty(XMLElement *pElem, CStructTempl
|
|||
|
||||
if (!NameAttr.IsEmpty())
|
||||
Name = NameAttr;
|
||||
else if (mpMaster->HasPropertyList())
|
||||
Name = mpMaster->PropertyName(ID);
|
||||
else if (mGame >= eEchoesDemo)
|
||||
Name = CMasterTemplate::GetPropertyName(ID);
|
||||
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");
|
||||
|
@ -636,17 +636,6 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
|
|||
{
|
||||
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
|
||||
if (NodeName == "versions")
|
||||
{
|
||||
|
@ -744,32 +733,6 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
|
|||
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 *pMaster = new CMasterTemplate();
|
||||
|
@ -855,29 +818,38 @@ void CTemplateLoader::LoadGameList()
|
|||
return;
|
||||
|
||||
// Parse
|
||||
XMLNode *pNode = GameListXML.FirstChild()->NextSibling()->FirstChild();
|
||||
XMLElement *pRoot = GameListXML.FirstChildElement("GameList");
|
||||
const char *pkGameListVersion = pRoot->Attribute("version");
|
||||
|
||||
while (pNode)
|
||||
{
|
||||
XMLElement *pElement = pNode->ToElement();
|
||||
TString NodeName = TString(pElement->Name()).ToLower();
|
||||
if (pkGameListVersion)
|
||||
CMasterTemplate::smGameListVersion = TString(pkGameListVersion).ToInt32(10);
|
||||
|
||||
// Game List version number
|
||||
if (NodeName == "version")
|
||||
XMLElement *pElem = pRoot->FirstChildElement();
|
||||
|
||||
while (pElem)
|
||||
{
|
||||
u32 VersionNum = std::stoul(pElement->GetText());
|
||||
CMasterTemplate::smGameListVersion = VersionNum;
|
||||
TString NodeName = TString(pElem->Name()).ToLower();
|
||||
|
||||
// Properties
|
||||
if (NodeName == "properties")
|
||||
{
|
||||
TString PropListPath = pElem->GetText();
|
||||
XMLDocument PropListXML;
|
||||
OpenXML(mskTemplatesDir + PropListPath, PropListXML);
|
||||
|
||||
if (!PropListXML.Error())
|
||||
LoadPropertyList(&PropListXML, PropListPath);
|
||||
}
|
||||
|
||||
// Games
|
||||
else if (NodeName == "game")
|
||||
{
|
||||
CTemplateLoader Loader(mskTemplatesDir);
|
||||
CMasterTemplate *pMaster = Loader.LoadGameInfo(pNode);
|
||||
CMasterTemplate *pMaster = Loader.LoadGameInfo(pElem);
|
||||
CMasterTemplate::smMasterMap[pMaster->mGame] = pMaster;
|
||||
}
|
||||
|
||||
pNode = pNode->NextSibling();
|
||||
pElem = pElem->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -897,6 +869,7 @@ void CTemplateLoader::LoadGameTemplates(EGame Game)
|
|||
if (!MasterXML.Error())
|
||||
{
|
||||
CTemplateLoader Loader(mskTemplatesDir);
|
||||
Loader.mGame = Game;
|
||||
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;
|
||||
|
||||
CMasterTemplate *mpMaster;
|
||||
EGame mGame;
|
||||
TString mTemplatesDir;
|
||||
TString mMasterDir;
|
||||
|
||||
|
@ -36,7 +37,6 @@ class CTemplateLoader
|
|||
// Load Master
|
||||
CMasterTemplate* LoadGameInfo(tinyxml2::XMLNode *pNode);
|
||||
void LoadMasterTemplate(tinyxml2::XMLDocument *pDoc, CMasterTemplate *pMaster);
|
||||
void LoadPropertyList(tinyxml2::XMLDocument *pDoc, const TString& rkListName);
|
||||
|
||||
// Utility
|
||||
static void OpenXML(const TString& rkPath, tinyxml2::XMLDocument& rDoc);
|
||||
|
@ -45,6 +45,7 @@ class CTemplateLoader
|
|||
public:
|
||||
static void LoadGameList();
|
||||
static void LoadGameTemplates(EGame Game);
|
||||
static void LoadPropertyList(tinyxml2::XMLDocument *pDoc, const TString& rkListName);
|
||||
};
|
||||
|
||||
#endif // CTEMPLATELOADER_H
|
||||
|
|
|
@ -6,7 +6,6 @@ CMasterTemplate::CMasterTemplate()
|
|||
{
|
||||
mVersion = 0;
|
||||
mFullyLoaded = false;
|
||||
mHasPropList = false;
|
||||
}
|
||||
|
||||
CMasterTemplate::~CMasterTemplate()
|
||||
|
@ -100,21 +99,6 @@ TString CMasterTemplate::MessageByIndex(u32 Index)
|
|||
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()
|
||||
{
|
||||
return mFullyLoaded;
|
||||
|
@ -141,5 +125,16 @@ std::list<CMasterTemplate*> CMasterTemplate::GetMasterList()
|
|||
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<u32, TString> CMasterTemplate::smPropertyNames;
|
||||
u32 CMasterTemplate::smGameListVersion;
|
||||
|
|
|
@ -22,10 +22,9 @@ class CMasterTemplate
|
|||
std::map<u32, TString> mStates;
|
||||
std::map<u32, TString> mMessages;
|
||||
|
||||
bool mHasPropList;
|
||||
std::map<u32, TString> mPropertyNames;
|
||||
|
||||
static std::map<EGame, CMasterTemplate*> smMasterMap;
|
||||
static std::map<u32, TString> smPropertyNames;
|
||||
static u32 smGameListVersion;
|
||||
|
||||
public:
|
||||
|
@ -46,12 +45,11 @@ public:
|
|||
TString MessageByID(u32 MessageID);
|
||||
TString MessageByID(const CFourCC& MessageID);
|
||||
TString MessageByIndex(u32 Index);
|
||||
TString PropertyName(u32 PropertyID);
|
||||
bool HasPropertyList();
|
||||
bool IsLoadedSuccessfully();
|
||||
|
||||
static CMasterTemplate* GetMasterForGame(EGame Game);
|
||||
static std::list<CMasterTemplate*> GetMasterList();
|
||||
static TString GetPropertyName(u32 PropertyID);
|
||||
};
|
||||
|
||||
// ************ INLINE ************
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GameList version="4">
|
||||
<properties>Properties.xml</properties>
|
||||
<game>
|
||||
<name>Metroid Prime</name>
|
||||
<mrea>0x0F</mrea>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MasterTemplate version="4">
|
||||
<properties>Properties.xml</properties>
|
||||
<objects>
|
||||
<object ID="AIHT" template="Script/AIHint.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"?>
|
||||
<MasterTemplate version="4">
|
||||
<properties>Properties.xml</properties>
|
||||
<versions>
|
||||
<version>GameCube NTSC</version>
|
||||
<version>Trilogy</version>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MasterTemplate version="4">
|
||||
<properties>Properties.xml</properties>
|
||||
<objects>
|
||||
<object ID="ACTR" template="Script/Actor.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"?>
|
||||
<MasterTemplate version="4">
|
||||
<properties>Properties.xml</properties>
|
||||
<objects>
|
||||
<object ID="AIFZ" template="Script/AIFuse.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"?>
|
||||
<MasterTemplate version="4">
|
||||
<properties>Properties.xml</properties>
|
||||
<objects>
|
||||
<object ID="ACTR" template="Script/Actor.xml"/>
|
||||
<object ID="ACKF" template="Script/ActorKeyframe.xml"/>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue