mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-24 17:54:59 +01:00
Add XML forwards compatibility to levelstats.vvv
Not that hard to do for the smallest XML file in the game.
This commit is contained in:
parent
cb2f72fd8e
commit
43e57f5483
1 changed files with 15 additions and 20 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include "Script.h"
|
#include "Script.h"
|
||||||
#include "UtilityClass.h"
|
#include "UtilityClass.h"
|
||||||
|
#include "XMLUtils.h"
|
||||||
|
|
||||||
// lol, Win32 -flibit
|
// lol, Win32 -flibit
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -577,45 +578,40 @@ void Game::loadcustomlevelstats()
|
||||||
void Game::savecustomlevelstats()
|
void Game::savecustomlevelstats()
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
tinyxml2::XMLElement* msg;
|
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/levelstats.vvv", doc);
|
||||||
tinyxml2::XMLDeclaration* decl = doc.NewDeclaration();
|
if (!already_exists)
|
||||||
doc.LinkEndChild( decl );
|
{
|
||||||
|
puts("No levelstats.vvv found. Creating new file");
|
||||||
|
}
|
||||||
|
|
||||||
tinyxml2::XMLElement * root = doc.NewElement( "Levelstats" );
|
xml::update_declaration(doc);
|
||||||
doc.LinkEndChild( root );
|
|
||||||
|
|
||||||
tinyxml2::XMLComment * comment = doc.NewComment(" Levelstats Save file " );
|
tinyxml2::XMLElement * root = xml::update_element(doc, "Levelstats");
|
||||||
root->LinkEndChild( comment );
|
|
||||||
|
|
||||||
tinyxml2::XMLElement * msgs = doc.NewElement( "Data" );
|
xml::update_comment(root, " Levelstats Save file ");
|
||||||
root->LinkEndChild( msgs );
|
|
||||||
|
tinyxml2::XMLElement * msgs = xml::update_element(root, "Data");
|
||||||
|
|
||||||
int numcustomlevelstats = customlevelstats.size();
|
int numcustomlevelstats = customlevelstats.size();
|
||||||
if(numcustomlevelstats>=200)numcustomlevelstats=199;
|
if(numcustomlevelstats>=200)numcustomlevelstats=199;
|
||||||
msg = doc.NewElement( "numcustomlevelstats" );
|
xml::update_tag(msgs, "numcustomlevelstats", numcustomlevelstats);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(numcustomlevelstats).c_str() ));
|
|
||||||
msgs->LinkEndChild( msg );
|
|
||||||
|
|
||||||
std::string customlevelscorestr;
|
std::string customlevelscorestr;
|
||||||
for(int i = 0; i < numcustomlevelstats; i++ )
|
for(int i = 0; i < numcustomlevelstats; i++ )
|
||||||
{
|
{
|
||||||
customlevelscorestr += help.String(customlevelstats[i].score) + ",";
|
customlevelscorestr += help.String(customlevelstats[i].score) + ",";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "customlevelscore" );
|
xml::update_tag(msgs, "customlevelscore", customlevelscorestr.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( customlevelscorestr.c_str() ));
|
|
||||||
msgs->LinkEndChild( msg );
|
|
||||||
|
|
||||||
std::string customlevelstatsstr;
|
std::string customlevelstatsstr;
|
||||||
for(int i = 0; i < numcustomlevelstats; i++ )
|
for(int i = 0; i < numcustomlevelstats; i++ )
|
||||||
{
|
{
|
||||||
customlevelstatsstr += customlevelstats[i].name + "|";
|
customlevelstatsstr += customlevelstats[i].name + "|";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "customlevelstats" );
|
xml::update_tag(msgs, "customlevelstats", customlevelstatsstr.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( customlevelstatsstr.c_str() ));
|
|
||||||
msgs->LinkEndChild( msg );
|
|
||||||
|
|
||||||
// New system
|
// New system
|
||||||
msg = doc.NewElement("stats");
|
tinyxml2::XMLElement* msg = xml::update_element_delete_contents(msgs, "stats");
|
||||||
tinyxml2::XMLElement* stat_el;
|
tinyxml2::XMLElement* stat_el;
|
||||||
for (size_t i = 0; i < customlevelstats.size(); i++)
|
for (size_t i = 0; i < customlevelstats.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -627,7 +623,6 @@ void Game::savecustomlevelstats()
|
||||||
|
|
||||||
msg->LinkEndChild(stat_el);
|
msg->LinkEndChild(stat_el);
|
||||||
}
|
}
|
||||||
msgs->LinkEndChild(msg);
|
|
||||||
|
|
||||||
if(FILESYSTEM_saveTiXml2Document("saves/levelstats.vvv", doc))
|
if(FILESYSTEM_saveTiXml2Document("saves/levelstats.vvv", doc))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue