mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Convert Game::savecustomlevelstats() to TinyXML2
This commit is contained in:
parent
142241fd74
commit
683dc1f97d
1 changed files with 13 additions and 14 deletions
|
@ -641,24 +641,23 @@ void Game::loadcustomlevelstats()
|
||||||
|
|
||||||
void Game::savecustomlevelstats()
|
void Game::savecustomlevelstats()
|
||||||
{
|
{
|
||||||
TiXmlDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
TiXmlElement* msg;
|
tinyxml2::XMLElement* msg;
|
||||||
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
|
tinyxml2::XMLDeclaration* decl = doc.NewDeclaration();
|
||||||
doc.LinkEndChild( decl );
|
doc.LinkEndChild( decl );
|
||||||
|
|
||||||
TiXmlElement * root = new TiXmlElement( "Levelstats" );
|
tinyxml2::XMLElement * root = doc.NewElement( "Levelstats" );
|
||||||
doc.LinkEndChild( root );
|
doc.LinkEndChild( root );
|
||||||
|
|
||||||
TiXmlComment * comment = new TiXmlComment();
|
tinyxml2::XMLComment * comment = doc.NewComment(" Levelstats Save file " );
|
||||||
comment->SetValue(" Levelstats Save file " );
|
|
||||||
root->LinkEndChild( comment );
|
root->LinkEndChild( comment );
|
||||||
|
|
||||||
TiXmlElement * msgs = new TiXmlElement( "Data" );
|
tinyxml2::XMLElement * msgs = doc.NewElement( "Data" );
|
||||||
root->LinkEndChild( msgs );
|
root->LinkEndChild( msgs );
|
||||||
|
|
||||||
if(numcustomlevelstats>=200)numcustomlevelstats=199;
|
if(numcustomlevelstats>=200)numcustomlevelstats=199;
|
||||||
msg = new TiXmlElement( "numcustomlevelstats" );
|
msg = doc.NewElement( "numcustomlevelstats" );
|
||||||
msg->LinkEndChild( new TiXmlText( help.String(numcustomlevelstats).c_str() ));
|
msg->LinkEndChild( doc.NewText( help.String(numcustomlevelstats).c_str() ));
|
||||||
msgs->LinkEndChild( msg );
|
msgs->LinkEndChild( msg );
|
||||||
|
|
||||||
std::string customlevelscorestr;
|
std::string customlevelscorestr;
|
||||||
|
@ -666,8 +665,8 @@ void Game::savecustomlevelstats()
|
||||||
{
|
{
|
||||||
customlevelscorestr += help.String(customlevelscore[i]) + ",";
|
customlevelscorestr += help.String(customlevelscore[i]) + ",";
|
||||||
}
|
}
|
||||||
msg = new TiXmlElement( "customlevelscore" );
|
msg = doc.NewElement( "customlevelscore" );
|
||||||
msg->LinkEndChild( new TiXmlText( customlevelscorestr.c_str() ));
|
msg->LinkEndChild( doc.NewText( customlevelscorestr.c_str() ));
|
||||||
msgs->LinkEndChild( msg );
|
msgs->LinkEndChild( msg );
|
||||||
|
|
||||||
std::string customlevelstatsstr;
|
std::string customlevelstatsstr;
|
||||||
|
@ -675,11 +674,11 @@ void Game::savecustomlevelstats()
|
||||||
{
|
{
|
||||||
customlevelstatsstr += customlevelstats[i] + "|";
|
customlevelstatsstr += customlevelstats[i] + "|";
|
||||||
}
|
}
|
||||||
msg = new TiXmlElement( "customlevelstats" );
|
msg = doc.NewElement( "customlevelstats" );
|
||||||
msg->LinkEndChild( new TiXmlText( customlevelstatsstr.c_str() ));
|
msg->LinkEndChild( doc.NewText( customlevelstatsstr.c_str() ));
|
||||||
msgs->LinkEndChild( msg );
|
msgs->LinkEndChild( msg );
|
||||||
|
|
||||||
if(FILESYSTEM_saveTiXmlDocument("saves/levelstats.vvv", &doc))
|
if(FILESYSTEM_saveTiXml2Document("saves/levelstats.vvv", doc))
|
||||||
{
|
{
|
||||||
printf("Level stats saved\n");
|
printf("Level stats saved\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue