1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Convert editorclass::load() to TinyXML2

Ok, it's a bit of a more complicated structure, but it seems to load
fine. I decided to test this one.
This commit is contained in:
Misa 2020-06-03 18:03:00 -07:00 committed by Ethan Lee
parent 2f2f04c76b
commit cfacc7a2dc

View file

@ -1643,21 +1643,21 @@ bool editorclass::load(std::string& _path)
printf("Custom asset directory does not exist\n"); printf("Custom asset directory does not exist\n");
} }
TiXmlDocument doc; tinyxml2::XMLDocument doc;
if (!FILESYSTEM_loadTiXmlDocument(_path.c_str(), &doc)) if (!FILESYSTEM_loadTiXml2Document(_path.c_str(), doc))
{ {
printf("No level %s to load :(\n", _path.c_str()); printf("No level %s to load :(\n", _path.c_str());
return false; return false;
} }
TiXmlHandle hDoc(&doc); tinyxml2::XMLHandle hDoc(&doc);
TiXmlElement* pElem; tinyxml2::XMLElement* pElem;
TiXmlHandle hRoot(0); tinyxml2::XMLHandle hRoot(NULL);
version = 0; version = 0;
{ {
pElem=hDoc.FirstChildElement().Element(); pElem=hDoc.FirstChildElement().ToElement();
// should always have a valid root but handle gracefully if it does // should always have a valid root but handle gracefully if it does
if (!pElem) if (!pElem)
{ {
@ -1666,10 +1666,10 @@ bool editorclass::load(std::string& _path)
pElem->QueryIntAttribute("version", &version); pElem->QueryIntAttribute("version", &version);
// save this for later // save this for later
hRoot=TiXmlHandle(pElem); hRoot=tinyxml2::XMLHandle(pElem);
} }
for( pElem = hRoot.FirstChild( "Data" ).FirstChild().Element(); pElem; pElem=pElem->NextSiblingElement()) for( pElem = hRoot.FirstChildElement( "Data" ).FirstChild().ToElement(); pElem; pElem=pElem->NextSiblingElement())
{ {
std::string pKey(pElem->Value()); std::string pKey(pElem->Value());
const char* pText = pElem->GetText() ; const char* pText = pElem->GetText() ;
@ -1681,7 +1681,7 @@ bool editorclass::load(std::string& _path)
if (pKey == "MetaData") if (pKey == "MetaData")
{ {
for( TiXmlElement* subElem = pElem->FirstChildElement(); subElem; subElem= subElem->NextSiblingElement()) for( tinyxml2::XMLElement* subElem = pElem->FirstChildElement(); subElem; subElem= subElem->NextSiblingElement())
{ {
std::string pKey(subElem->Value()); std::string pKey(subElem->Value());
const char* pText = subElem->GetText() ; const char* pText = subElem->GetText() ;
@ -1783,7 +1783,7 @@ bool editorclass::load(std::string& _path)
if (pKey == "edEntities") if (pKey == "edEntities")
{ {
for( TiXmlElement* edEntityEl = pElem->FirstChildElement(); edEntityEl; edEntityEl=edEntityEl->NextSiblingElement()) for( tinyxml2::XMLElement* edEntityEl = pElem->FirstChildElement(); edEntityEl; edEntityEl=edEntityEl->NextSiblingElement())
{ {
edentities entity; edentities entity;
@ -1810,7 +1810,7 @@ bool editorclass::load(std::string& _path)
if (pKey == "levelMetaData") if (pKey == "levelMetaData")
{ {
int i = 0; int i = 0;
for( TiXmlElement* edLevelClassElement = pElem->FirstChildElement(); edLevelClassElement; edLevelClassElement=edLevelClassElement->NextSiblingElement()) for( tinyxml2::XMLElement* edLevelClassElement = pElem->FirstChildElement(); edLevelClassElement; edLevelClassElement=edLevelClassElement->NextSiblingElement())
{ {
std::string pKey(edLevelClassElement->Value()); std::string pKey(edLevelClassElement->Value());
if(edLevelClassElement->GetText() != NULL) if(edLevelClassElement->GetText() != NULL)