mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-03 15:39:46 +01:00
Add XML forwards compatibility to unlock.vvv
This file is probably the biggest one, as there will be more settings added in the future and we don't want people's settings to be erased. Of course, this file will be migrated to a settings.vvv sometime later in 2.3 in order to prevent 2.2 from erasing 2.3 settings.
This commit is contained in:
parent
43e57f5483
commit
17b8d0308e
1 changed files with 79 additions and 112 deletions
|
@ -4747,100 +4747,78 @@ void Game::loadstats(int *width, int *height, bool *vsync)
|
||||||
void Game::savestats()
|
void Game::savestats()
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
tinyxml2::XMLElement * msg;
|
bool already_exists = FILESYSTEM_loadTiXml2Document("saves/unlock.vvv", doc);
|
||||||
tinyxml2::XMLDeclaration * decl = doc.NewDeclaration();
|
if (!already_exists)
|
||||||
doc.LinkEndChild( decl );
|
{
|
||||||
|
puts("No unlock.vvv found. Creating new file");
|
||||||
|
}
|
||||||
|
|
||||||
tinyxml2::XMLElement * root = doc.NewElement( "Save" );
|
xml::update_declaration(doc);
|
||||||
doc.LinkEndChild( root );
|
|
||||||
|
|
||||||
tinyxml2::XMLComment * comment = doc.NewComment(" Save file " );
|
tinyxml2::XMLElement * root = xml::update_element(doc, "Save");
|
||||||
root->LinkEndChild( comment );
|
|
||||||
|
|
||||||
tinyxml2::XMLElement * dataNode = doc.NewElement( "Data" );
|
xml::update_comment(root, " Save file " );
|
||||||
root->LinkEndChild( dataNode );
|
|
||||||
|
tinyxml2::XMLElement * dataNode = xml::update_element(root, "Data");
|
||||||
|
|
||||||
std::string s_unlock;
|
std::string s_unlock;
|
||||||
for(size_t i = 0; i < SDL_arraysize(unlock); i++ )
|
for(size_t i = 0; i < SDL_arraysize(unlock); i++ )
|
||||||
{
|
{
|
||||||
s_unlock += help.String(unlock[i]) + ",";
|
s_unlock += help.String(unlock[i]) + ",";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "unlock" );
|
xml::update_tag(dataNode, "unlock", s_unlock.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( s_unlock.c_str() ));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
std::string s_unlocknotify;
|
std::string s_unlocknotify;
|
||||||
for(size_t i = 0; i < SDL_arraysize(unlocknotify); i++ )
|
for(size_t i = 0; i < SDL_arraysize(unlocknotify); i++ )
|
||||||
{
|
{
|
||||||
s_unlocknotify += help.String(unlocknotify[i]) + ",";
|
s_unlocknotify += help.String(unlocknotify[i]) + ",";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "unlocknotify" );
|
xml::update_tag(dataNode, "unlocknotify", s_unlocknotify.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( s_unlocknotify.c_str() ));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
std::string s_besttimes;
|
std::string s_besttimes;
|
||||||
for(size_t i = 0; i < SDL_arraysize(besttimes); i++ )
|
for(size_t i = 0; i < SDL_arraysize(besttimes); i++ )
|
||||||
{
|
{
|
||||||
s_besttimes += help.String(besttimes[i]) + ",";
|
s_besttimes += help.String(besttimes[i]) + ",";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "besttimes" );
|
xml::update_tag(dataNode, "besttimes", s_besttimes.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( s_besttimes.c_str() ));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
std::string s_bestframes;
|
std::string s_bestframes;
|
||||||
for (size_t i = 0; i < SDL_arraysize(bestframes); i++)
|
for (size_t i = 0; i < SDL_arraysize(bestframes); i++)
|
||||||
{
|
{
|
||||||
s_bestframes += help.String(bestframes[i]) + ",";
|
s_bestframes += help.String(bestframes[i]) + ",";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "bestframes" );
|
xml::update_tag(dataNode, "bestframes", s_bestframes.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( s_bestframes.c_str() ) );
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
std::string s_besttrinkets;
|
std::string s_besttrinkets;
|
||||||
for(size_t i = 0; i < SDL_arraysize(besttrinkets); i++ )
|
for(size_t i = 0; i < SDL_arraysize(besttrinkets); i++ )
|
||||||
{
|
{
|
||||||
s_besttrinkets += help.String(besttrinkets[i]) + ",";
|
s_besttrinkets += help.String(besttrinkets[i]) + ",";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "besttrinkets" );
|
xml::update_tag(dataNode, "besttrinkets", s_besttrinkets.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( s_besttrinkets.c_str() ));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
std::string s_bestlives;
|
std::string s_bestlives;
|
||||||
for(size_t i = 0; i < SDL_arraysize(bestlives); i++ )
|
for(size_t i = 0; i < SDL_arraysize(bestlives); i++ )
|
||||||
{
|
{
|
||||||
s_bestlives += help.String(bestlives[i]) + ",";
|
s_bestlives += help.String(bestlives[i]) + ",";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "bestlives" );
|
xml::update_tag(dataNode, "bestlives", s_bestlives.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( s_bestlives.c_str() ));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
std::string s_bestrank;
|
std::string s_bestrank;
|
||||||
for(size_t i = 0; i < SDL_arraysize(bestrank); i++ )
|
for(size_t i = 0; i < SDL_arraysize(bestrank); i++ )
|
||||||
{
|
{
|
||||||
s_bestrank += help.String(bestrank[i]) + ",";
|
s_bestrank += help.String(bestrank[i]) + ",";
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "bestrank" );
|
xml::update_tag(dataNode, "bestrank", s_bestrank.c_str());
|
||||||
msg->LinkEndChild( doc.NewText( s_bestrank.c_str() ));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "bestgamedeaths" );
|
xml::update_tag(dataNode, "bestgamedeaths", bestgamedeaths);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(bestgamedeaths).c_str() ));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
msg = doc.NewElement( "stat_trinkets" );
|
|
||||||
msg->LinkEndChild( doc.NewText( help.String(stat_trinkets).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "fullscreen" );
|
xml::update_tag(dataNode, "stat_trinkets", stat_trinkets);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(fullscreen).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "stretch" );
|
xml::update_tag(dataNode, "fullscreen", fullscreen);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(stretchMode).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "useLinearFilter" );
|
xml::update_tag(dataNode, "stretch", stretchMode);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(useLinearFilter).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
xml::update_tag(dataNode, "useLinearFilter", useLinearFilter);
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
if (graphics.screenbuffer != NULL)
|
if (graphics.screenbuffer != NULL)
|
||||||
|
@ -4852,85 +4830,47 @@ void Game::savestats()
|
||||||
width = 320;
|
width = 320;
|
||||||
height = 240;
|
height = 240;
|
||||||
}
|
}
|
||||||
msg = doc.NewElement( "window_width" );
|
xml::update_tag(dataNode, "window_width", width);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(width).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
msg = doc.NewElement( "window_height" );
|
|
||||||
msg->LinkEndChild( doc.NewText( help.String(height).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "noflashingmode" );
|
xml::update_tag(dataNode, "window_height", height);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(noflashingmode).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "colourblindmode" );
|
xml::update_tag(dataNode, "noflashingmode", noflashingmode);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(colourblindmode).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "setflipmode" );
|
xml::update_tag(dataNode, "colourblindmode", colourblindmode);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(graphics.setflipmode).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "invincibility" );
|
xml::update_tag(dataNode, "setflipmode", graphics.setflipmode);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(map.invincibility).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "slowdown" );
|
xml::update_tag(dataNode, "invincibility", map.invincibility);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(slowdown).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "swnbestrank" );
|
xml::update_tag(dataNode, "slowdown", slowdown);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(swnbestrank).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement( "swnrecord" );
|
xml::update_tag(dataNode, "swnbestrank", swnbestrank);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(swnrecord).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
xml::update_tag(dataNode, "swnrecord", swnrecord);
|
||||||
|
|
||||||
|
|
||||||
msg = doc.NewElement( "advanced_smoothing" );
|
xml::update_tag(dataNode, "advanced_smoothing", fullScreenEffect_badSignal);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(fullScreenEffect_badSignal).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
|
|
||||||
msg = doc.NewElement( "usingmmmmmm" );
|
xml::update_tag(dataNode, "usingmmmmmm", usingmmmmmm);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(usingmmmmmm).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
msg = doc.NewElement("ghostsenabled");
|
xml::update_tag(dataNode, "ghostsenabled", (int) ghostsenabled);
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) ghostsenabled).c_str()));
|
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
msg = doc.NewElement("skipfakeload");
|
xml::update_tag(dataNode, "skipfakeload", (int) skipfakeload);
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) skipfakeload).c_str()));
|
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
msg = doc.NewElement("disablepause");
|
xml::update_tag(dataNode, "disablepause", (int) disablepause);
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) disablepause).c_str()));
|
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
msg = doc.NewElement("notextoutline");
|
xml::update_tag(dataNode, "notextoutline", (int) graphics.notextoutline);
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) graphics.notextoutline).c_str()));
|
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
msg = doc.NewElement("translucentroomname");
|
xml::update_tag(dataNode, "translucentroomname", (int) graphics.translucentroomname);
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) graphics.translucentroomname).c_str()));
|
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
msg = doc.NewElement("showmousecursor");
|
xml::update_tag(dataNode, "showmousecursor", (int) graphics.showmousecursor);
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int)graphics.showmousecursor).c_str()));
|
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
msg = doc.NewElement("over30mode");
|
xml::update_tag(dataNode, "over30mode", (int) over30mode);
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) over30mode).c_str()));
|
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
msg = doc.NewElement("glitchrunnermode");
|
xml::update_tag(dataNode, "glitchrunnermode", (int) glitchrunnermode);
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) glitchrunnermode).c_str()));
|
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
int vsyncOption;
|
int vsyncOption;
|
||||||
msg = doc.NewElement("vsync");
|
|
||||||
if (graphics.screenbuffer != NULL)
|
if (graphics.screenbuffer != NULL)
|
||||||
{
|
{
|
||||||
vsyncOption = (int) graphics.screenbuffer->vsync;
|
vsyncOption = (int) graphics.screenbuffer->vsync;
|
||||||
|
@ -4939,37 +4879,64 @@ void Game::savestats()
|
||||||
{
|
{
|
||||||
vsyncOption = 0;
|
vsyncOption = 0;
|
||||||
}
|
}
|
||||||
msg->LinkEndChild(doc.NewText(help.String(vsyncOption).c_str()));
|
xml::update_tag(dataNode, "vsync", vsyncOption);
|
||||||
dataNode->LinkEndChild(msg);
|
|
||||||
|
|
||||||
|
// Delete all controller buttons we had previously.
|
||||||
|
// dataNode->FirstChildElement() shouldn't be NULL at this point...
|
||||||
|
// we've already added a bunch of elements
|
||||||
|
for (tinyxml2::XMLElement* element = dataNode->FirstChildElement();
|
||||||
|
element != NULL;
|
||||||
|
/* Increment code handled separately */)
|
||||||
|
{
|
||||||
|
const char* name = element->Name();
|
||||||
|
|
||||||
|
if (SDL_strcmp(name, "flipButton") == 0
|
||||||
|
|| SDL_strcmp(name, "enterButton") == 0
|
||||||
|
|| SDL_strcmp(name, "escButton") == 0
|
||||||
|
|| SDL_strcmp(name, "restartButton") == 0)
|
||||||
|
{
|
||||||
|
// Can't just doc.DeleteNode(element) and then go to next,
|
||||||
|
// element->NextSiblingElement() will be NULL.
|
||||||
|
// Instead, store pointer of element we want to delete. Then
|
||||||
|
// increment `element`. And THEN delete the element.
|
||||||
|
tinyxml2::XMLElement* delete_this = element;
|
||||||
|
|
||||||
|
element = element->NextSiblingElement();
|
||||||
|
|
||||||
|
doc.DeleteNode(delete_this);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
element = element->NextSiblingElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now add them
|
||||||
for (size_t i = 0; i < controllerButton_flip.size(); i += 1)
|
for (size_t i = 0; i < controllerButton_flip.size(); i += 1)
|
||||||
{
|
{
|
||||||
msg = doc.NewElement("flipButton");
|
tinyxml2::XMLElement* msg = doc.NewElement("flipButton");
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_flip[i]).c_str()));
|
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_flip[i]).c_str()));
|
||||||
dataNode->LinkEndChild(msg);
|
dataNode->LinkEndChild(msg);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < controllerButton_map.size(); i += 1)
|
for (size_t i = 0; i < controllerButton_map.size(); i += 1)
|
||||||
{
|
{
|
||||||
msg = doc.NewElement("enterButton");
|
tinyxml2::XMLElement* msg = doc.NewElement("enterButton");
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_map[i]).c_str()));
|
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_map[i]).c_str()));
|
||||||
dataNode->LinkEndChild(msg);
|
dataNode->LinkEndChild(msg);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < controllerButton_esc.size(); i += 1)
|
for (size_t i = 0; i < controllerButton_esc.size(); i += 1)
|
||||||
{
|
{
|
||||||
msg = doc.NewElement("escButton");
|
tinyxml2::XMLElement* msg = doc.NewElement("escButton");
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_esc[i]).c_str()));
|
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_esc[i]).c_str()));
|
||||||
dataNode->LinkEndChild(msg);
|
dataNode->LinkEndChild(msg);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < controllerButton_restart.size(); i += 1)
|
for (size_t i = 0; i < controllerButton_restart.size(); i += 1)
|
||||||
{
|
{
|
||||||
msg = doc.NewElement("restartButton");
|
tinyxml2::XMLElement* msg = doc.NewElement("restartButton");
|
||||||
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_restart[i]).c_str()));
|
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_restart[i]).c_str()));
|
||||||
dataNode->LinkEndChild(msg);
|
dataNode->LinkEndChild(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = doc.NewElement( "controllerSensitivity" );
|
xml::update_tag(dataNode, "controllerSensitivity", controllerSensitivity);
|
||||||
msg->LinkEndChild( doc.NewText( help.String(controllerSensitivity).c_str()));
|
|
||||||
dataNode->LinkEndChild( msg );
|
|
||||||
|
|
||||||
FILESYSTEM_saveTiXml2Document("saves/unlock.vvv", doc);
|
FILESYSTEM_saveTiXml2Document("saves/unlock.vvv", doc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue