2020-09-25 18:08:20 +02:00
|
|
|
// Forward decl, avoid including tinyxml2.h
|
|
|
|
namespace tinyxml2
|
|
|
|
{
|
|
|
|
class XMLComment;
|
|
|
|
class XMLDocument;
|
|
|
|
class XMLDeclaration;
|
|
|
|
class XMLElement;
|
|
|
|
class XMLNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace xml
|
|
|
|
{
|
|
|
|
|
Move all settings to settings.vvv
The game previously did this dumb thing where it lumped in all its
settings with its file that tracked your records and unlocks,
`unlock.vvv`. It wasn't really an issue, until 2.3 came along and added
a few settings, suddenly making a problem where 2.3 settings would be
reset by chance if you decided to touch 2.2.
The solution to this is to move all settings to a new file,
`settings.vvv`. However, for compatibility with 2.2, settings will still
be written to `unlock.vvv`.
The game will prioritize reading from `settings.vvv` instead of
`unlock.vvv`, so if there's a setting that's missing from `unlock.vvv`,
no worries there. But if `settings.vvv` is missing, then it'll read
settings from `unlock.vvv`. As well, if `unlock.vvv` is missing, then
`settings.vvv` will be read from instead (I explicitly tested for this,
and found that I had to write special code to handle this case,
otherwise the game would overwrite the existing `settings.vvv` before
reading from it; kids, make sure to always test your code!).
Closes #373 fully.
2020-11-04 08:11:21 +01:00
|
|
|
tinyxml2::XMLDocument& get_document(tinyxml2::XMLNode* parent);
|
|
|
|
|
2020-09-25 18:08:20 +02:00
|
|
|
tinyxml2::XMLElement* update_element(tinyxml2::XMLNode* parent, const char* name);
|
|
|
|
// Same thing as above, but takes &parent instead of *parent
|
|
|
|
tinyxml2::XMLElement* update_element(tinyxml2::XMLNode& parent, const char* name);
|
|
|
|
|
|
|
|
tinyxml2::XMLElement* update_element_delete_contents(tinyxml2::XMLNode* parent, const char* name);
|
|
|
|
|
|
|
|
tinyxml2::XMLElement* update_tag(tinyxml2::XMLNode* parent, const char* name, const char* value);
|
|
|
|
tinyxml2::XMLElement* update_tag(tinyxml2::XMLNode* parent, const char* name, const int value);
|
|
|
|
|
|
|
|
tinyxml2::XMLDeclaration* update_declaration(tinyxml2::XMLDocument& doc);
|
|
|
|
|
|
|
|
tinyxml2::XMLComment* update_comment(tinyxml2::XMLNode* parent, const char* text);
|
|
|
|
|
|
|
|
} // namespace xml
|
2022-12-30 22:57:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
// XMLHandle doc, XMLElement* elem
|
|
|
|
#define FOR_EACH_XML_ELEMENT(doc, elem) \
|
|
|
|
for ( \
|
|
|
|
elem = doc \
|
|
|
|
.FirstChildElement() \
|
|
|
|
.FirstChildElement() \
|
|
|
|
.ToElement(); \
|
|
|
|
elem != NULL; \
|
|
|
|
elem = elem->NextSiblingElement() \
|
|
|
|
)
|
|
|
|
|
|
|
|
// XMLElement* elem, XMLElement* subelem
|
|
|
|
#define FOR_EACH_XML_SUB_ELEMENT(elem, subelem) \
|
|
|
|
for ( \
|
|
|
|
subelem = elem->FirstChildElement(); \
|
|
|
|
subelem != NULL; \
|
|
|
|
subelem = subelem->NextSiblingElement() \
|
|
|
|
)
|
|
|
|
|
|
|
|
// XMLElement* elem, const char* expect
|
|
|
|
#define EXPECT_ELEM(elem, expect) \
|
|
|
|
if (SDL_strcmp(elem->Value(), expect) != 0) \
|
|
|
|
{ \
|
|
|
|
continue; \
|
|
|
|
} \
|
|
|
|
do { } while (false)
|