mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 03:09:15 +01:00
Change TinyXML to pugixml
Thanks to Oddx.
This commit is contained in:
parent
8ab03c4bf9
commit
fbfcba4200
@ -7,13 +7,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "FileOperations/fileops.h"
|
#include "FileOperations/fileops.h"
|
||||||
#include "xml/tinyxml2.h"
|
#include "xml/pugixml.hpp"
|
||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
|
|
||||||
#include "HomebrewXML.h"
|
#include "HomebrewXML.h"
|
||||||
|
|
||||||
using namespace tinyxml2;
|
|
||||||
|
|
||||||
#define ENTRIE_SIZE 8192
|
#define ENTRIE_SIZE 8192
|
||||||
|
|
||||||
/* qparam filename Filepath of the XML file */
|
/* qparam filename Filepath of the XML file */
|
||||||
@ -26,64 +24,37 @@ int HomebrewXML::LoadHomebrewXMLData(const char* filename)
|
|||||||
LongDescription.clear();
|
LongDescription.clear();
|
||||||
Releasedate.clear();
|
Releasedate.clear();
|
||||||
|
|
||||||
XMLDocument xmlDoc;
|
pugi::xml_document xmlDoc;
|
||||||
if(xmlDoc.LoadFile(filename) != 0)
|
pugi::xml_parse_result result = xmlDoc.load_file(filename);
|
||||||
return false;
|
if (!result)
|
||||||
|
return 0;
|
||||||
|
|
||||||
XMLElement *appNode = xmlDoc.FirstChildElement("app");
|
Name = xmlDoc.child("app").child_value("name");
|
||||||
if(!appNode)
|
Coder = xmlDoc.child("app").child_value("coder");
|
||||||
return false;
|
Version = xmlDoc.child("app").child_value("version");
|
||||||
|
ShortDescription = xmlDoc.child("app").child_value("short_description");
|
||||||
|
LongDescription = xmlDoc.child("app").child_value("long_description");
|
||||||
|
|
||||||
XMLElement *node = NULL;
|
std::string ReleaseText = xmlDoc.child("app").child_value("release_date");
|
||||||
|
if (ReleaseText.length() >= 6)
|
||||||
node = appNode->FirstChildElement("name");
|
|
||||||
if(node && node->FirstChild() && node->FirstChild()->Value())
|
|
||||||
Name = node->FirstChild()->Value();
|
|
||||||
|
|
||||||
node = appNode->FirstChildElement("coder");
|
|
||||||
if(node && node->FirstChild() && node->FirstChild()->Value())
|
|
||||||
Coder = node->FirstChild()->Value();
|
|
||||||
|
|
||||||
node = appNode->FirstChildElement("version");
|
|
||||||
if(node && node->FirstChild() && node->FirstChild()->Value())
|
|
||||||
Version = node->FirstChild()->Value();
|
|
||||||
|
|
||||||
node = appNode->FirstChildElement("short_description");
|
|
||||||
if(node && node->FirstChild() && node->FirstChild()->Value())
|
|
||||||
ShortDescription = node->FirstChild()->Value();
|
|
||||||
|
|
||||||
node = appNode->FirstChildElement("long_description");
|
|
||||||
if(node && node->FirstChild() && node->FirstChild()->Value())
|
|
||||||
LongDescription = node->FirstChild()->Value();
|
|
||||||
|
|
||||||
char ReleaseText[200];
|
|
||||||
memset(ReleaseText, 0, sizeof(ReleaseText));
|
|
||||||
|
|
||||||
node = appNode->FirstChildElement("release_date");
|
|
||||||
if(node && node->FirstChild() && node->FirstChild()->Value())
|
|
||||||
snprintf(ReleaseText, sizeof(ReleaseText), node->FirstChild()->Value());
|
|
||||||
|
|
||||||
int len = (strlen(ReleaseText) - 6); //length of the date string without the 200000 at the end
|
|
||||||
if (len == 8)
|
|
||||||
snprintf(ReleaseText, sizeof(ReleaseText), "%c%c/%c%c/%c%c%c%c", ReleaseText[4], ReleaseText[5], ReleaseText[6], ReleaseText[7], ReleaseText[0], ReleaseText[1], ReleaseText[2], ReleaseText[3]);
|
|
||||||
else if (len == 6)
|
|
||||||
snprintf(ReleaseText, sizeof(ReleaseText), "%c%c/%c%c%c%c", ReleaseText[4], ReleaseText[5], ReleaseText[0], ReleaseText[1], ReleaseText[2], ReleaseText[3]);
|
|
||||||
|
|
||||||
Releasedate = ReleaseText;
|
|
||||||
|
|
||||||
node = appNode->FirstChildElement("arguments");
|
|
||||||
if(!node)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
XMLElement *argNode = node->FirstChildElement("arg");
|
|
||||||
|
|
||||||
while(argNode)
|
|
||||||
{
|
{
|
||||||
if(argNode->FirstChild() && argNode->FirstChild()->Value())
|
if (ReleaseText.find("/") == std::string::npos)
|
||||||
Arguments.push_back(std::string(argNode->FirstChild()->Value()));
|
{
|
||||||
|
Releasedate = ReleaseText.substr(4, 2);
|
||||||
argNode = argNode->NextSiblingElement();
|
if (ReleaseText.length() >= 8)
|
||||||
|
{
|
||||||
|
Releasedate.append("/");
|
||||||
|
Releasedate.append(ReleaseText.substr(6, 2));
|
||||||
}
|
}
|
||||||
|
Releasedate.append("/");
|
||||||
|
Releasedate.append(ReleaseText.substr(0, 4));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Releasedate = ReleaseText;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (pugi::xml_node arg : xmlDoc.child("app").child("arguments").children("arg"))
|
||||||
|
Arguments.push_back(arg.text().as_string());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -92,7 +63,8 @@ int HomebrewXML::SaveHomebrewXMLData(const char* filename)
|
|||||||
{
|
{
|
||||||
const int max_line_size = 4096;
|
const int max_line_size = 4096;
|
||||||
char *line = new (std::nothrow) char[max_line_size];
|
char *line = new (std::nothrow) char[max_line_size];
|
||||||
if(!line) return 0;
|
if (!line)
|
||||||
|
return 0;
|
||||||
|
|
||||||
FILE *fp = fopen(filename, "wb");
|
FILE *fp = fopen(filename, "wb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
@ -101,25 +73,38 @@ int HomebrewXML::SaveHomebrewXMLData(const char* filename)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(line, max_line_size,"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"); fputs(line, fp);
|
snprintf(line, max_line_size, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
|
||||||
snprintf(line, max_line_size,"<app version=\"1\">\n"); fputs(line, fp);
|
fputs(line, fp);
|
||||||
snprintf(line, max_line_size," <name>%s</name>\n", GetName()); fputs(line, fp);
|
snprintf(line, max_line_size, "<app version=\"1\">\n");
|
||||||
snprintf(line, max_line_size," <coder>%s</coder>\n", GetCoder()); fputs(line, fp);
|
fputs(line, fp);
|
||||||
snprintf(line, max_line_size," <version>%s</version>\n", GetVersion()); fputs(line, fp);
|
snprintf(line, max_line_size, " <name>%s</name>\n", GetName());
|
||||||
snprintf(line, max_line_size," <release_date>%s</release_date>\n", GetReleasedate()); fputs(line, fp);
|
fputs(line, fp);
|
||||||
|
snprintf(line, max_line_size, " <coder>%s</coder>\n", GetCoder());
|
||||||
|
fputs(line, fp);
|
||||||
|
snprintf(line, max_line_size, " <version>%s</version>\n", GetVersion());
|
||||||
|
fputs(line, fp);
|
||||||
|
snprintf(line, max_line_size, " <release_date>%s</release_date>\n", GetReleasedate());
|
||||||
|
fputs(line, fp);
|
||||||
if (Arguments.size() > 0)
|
if (Arguments.size() > 0)
|
||||||
{
|
{
|
||||||
snprintf(line, max_line_size," <arguments>\n"); fputs(line, fp);
|
snprintf(line, max_line_size, " <arguments>\n");
|
||||||
|
fputs(line, fp);
|
||||||
for (u8 i = 0; i < Arguments.size(); i++)
|
for (u8 i = 0; i < Arguments.size(); i++)
|
||||||
{
|
{
|
||||||
snprintf(line, max_line_size," <arg>%s</arg>\n", Arguments[i].c_str()); fputs(line, fp);
|
snprintf(line, max_line_size, " <arg>%s</arg>\n", Arguments[i].c_str());
|
||||||
|
fputs(line, fp);
|
||||||
}
|
}
|
||||||
snprintf(line, max_line_size," </arguments>\n"); fputs(line, fp);
|
snprintf(line, max_line_size, " </arguments>\n");
|
||||||
|
fputs(line, fp);
|
||||||
}
|
}
|
||||||
snprintf(line, max_line_size," <ahb_access/>\n"); fputs(line, fp);
|
snprintf(line, max_line_size, " <ahb_access/>\n");
|
||||||
snprintf(line, max_line_size," <short_description>%s</short_description>\n", GetShortDescription()); fputs(line, fp);
|
fputs(line, fp);
|
||||||
snprintf(line, max_line_size," <long_description>%s</long_description>\n", GetLongDescription()); fputs(line, fp);
|
snprintf(line, max_line_size, " <short_description>%s</short_description>\n", GetShortDescription());
|
||||||
snprintf(line, max_line_size,"</app>\n"); fputs(line, fp);
|
fputs(line, fp);
|
||||||
|
snprintf(line, max_line_size, " <long_description>%s</long_description>\n", GetLongDescription());
|
||||||
|
fputs(line, fp);
|
||||||
|
snprintf(line, max_line_size, "</app>\n");
|
||||||
|
fputs(line, fp);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
delete[] line;
|
delete[] line;
|
||||||
@ -133,7 +118,8 @@ void HomebrewXML::SetArgument(const char* argument)
|
|||||||
char argName[strlen(argument) + 1];
|
char argName[strlen(argument) + 1];
|
||||||
strcpy(argName, argument);
|
strcpy(argName, argument);
|
||||||
char *ptr = strrchr(argName, '=');
|
char *ptr = strrchr(argName, '=');
|
||||||
if(ptr) *(ptr+1) = 0;
|
if (ptr)
|
||||||
|
*(ptr + 1) = 0;
|
||||||
|
|
||||||
// Check if argument already exists and edit it
|
// Check if argument already exists and edit it
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
@ -27,11 +27,9 @@
|
|||||||
#include "network/networkops.h"
|
#include "network/networkops.h"
|
||||||
#include "network/https.h"
|
#include "network/https.h"
|
||||||
#include "utils/StringTools.h"
|
#include "utils/StringTools.h"
|
||||||
#include "xml/tinyxml2.h"
|
#include "xml/pugixml.hpp"
|
||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
|
|
||||||
using namespace tinyxml2;
|
|
||||||
|
|
||||||
Wiinnertag::Wiinnertag(const std::string &filepath)
|
Wiinnertag::Wiinnertag(const std::string &filepath)
|
||||||
{
|
{
|
||||||
ReadXML(filepath);
|
ReadXML(filepath);
|
||||||
@ -39,16 +37,17 @@ Wiinnertag::Wiinnertag(const std::string &filepath)
|
|||||||
|
|
||||||
bool Wiinnertag::ReadXML(const std::string &filepath)
|
bool Wiinnertag::ReadXML(const std::string &filepath)
|
||||||
{
|
{
|
||||||
XMLDocument xmlDoc;
|
pugi::xml_document xmlDoc;
|
||||||
if(xmlDoc.LoadFile(filepath.c_str()) != 0)
|
pugi::xml_parse_result result = xmlDoc.load_file(filepath.c_str());
|
||||||
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
XMLElement * node = xmlDoc.FirstChildElement("Tag");
|
pugi::xml_node node = xmlDoc.child("Tag");
|
||||||
|
|
||||||
while (node != NULL)
|
while (node != NULL)
|
||||||
{
|
{
|
||||||
const char * URL = node->Attribute("URL");
|
const char *URL = node.attribute("URL").value();
|
||||||
const char * Key = node->Attribute("Key");
|
const char *Key = node.attribute("Key").value();
|
||||||
|
|
||||||
if (URL && Key)
|
if (URL && Key)
|
||||||
{
|
{
|
||||||
@ -58,7 +57,7 @@ bool Wiinnertag::ReadXML(const std::string &filepath)
|
|||||||
tagList[size].second = Key;
|
tagList[size].second = Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->NextSiblingElement();
|
node = node.next_sibling();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -88,11 +87,11 @@ bool Wiinnertag::Send(const char *gameID)
|
|||||||
|
|
||||||
bool Wiinnertag::TagGame(const char *gameID)
|
bool Wiinnertag::TagGame(const char *gameID)
|
||||||
{
|
{
|
||||||
std::string fullpath = Settings.WiinnertagPath;
|
std::string fullpath(Settings.WiinnertagPath);
|
||||||
if(fullpath.size() == 0)
|
if (fullpath.length() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(fullpath[fullpath.size()-1] != '/')
|
if (fullpath.back() != '/')
|
||||||
fullpath += '/';
|
fullpath += '/';
|
||||||
fullpath += "Wiinnertag.xml";
|
fullpath += "Wiinnertag.xml";
|
||||||
|
|
||||||
@ -102,27 +101,26 @@ bool Wiinnertag::TagGame(const char *gameID)
|
|||||||
|
|
||||||
bool Wiinnertag::CreateExample(const std::string &filepath)
|
bool Wiinnertag::CreateExample(const std::string &filepath)
|
||||||
{
|
{
|
||||||
if(filepath.size() == 0)
|
if (filepath.length() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CreateSubfolder(filepath.c_str());
|
CreateSubfolder(filepath.c_str());
|
||||||
|
|
||||||
std::string fullpath = filepath;
|
std::string fullpath = filepath;
|
||||||
if(fullpath[fullpath.size()-1] != '/')
|
if (fullpath.back() != '/')
|
||||||
fullpath += '/';
|
fullpath += '/';
|
||||||
fullpath += "Wiinnertag.xml";
|
fullpath += "Wiinnertag.xml";
|
||||||
|
|
||||||
XMLDocument xmlDoc;
|
pugi::xml_document xmlDoc;
|
||||||
|
pugi::xml_node declaration = xmlDoc.append_child(pugi::node_declaration);
|
||||||
|
declaration.append_attribute("version") = "1.0";
|
||||||
|
declaration.append_attribute("encoding") = "UTF-8";
|
||||||
|
|
||||||
XMLDeclaration * declaration = xmlDoc.NewDeclaration();
|
pugi::xml_node Tag = xmlDoc.append_child("Tag");
|
||||||
xmlDoc.InsertEndChild(declaration);
|
Tag.append_attribute("URL") = "https://tag.rc24.xyz/wii?game={ID6}&key={KEY}";
|
||||||
|
Tag.append_attribute("Key") = "1234567890";
|
||||||
|
|
||||||
XMLElement *Tag = xmlDoc.NewElement("Tag");
|
xmlDoc.save_file(fullpath.c_str());
|
||||||
Tag->SetAttribute("URL", "https://tag.rc24.xyz/wii?game={ID6}&key={KEY}");
|
|
||||||
Tag->SetAttribute("Key", "1234567890");
|
|
||||||
xmlDoc.InsertEndChild(Tag);
|
|
||||||
|
|
||||||
xmlDoc.SaveFile(fullpath.c_str());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -90,18 +90,18 @@ static bool CheckNewGameTDBVersion(const char *url)
|
|||||||
if (file.gametdbcheck <= 0)
|
if (file.gametdbcheck <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string Title;
|
std::string Filepath(Settings.titlestxt_path);
|
||||||
std::string Filepath = Settings.titlestxt_path;
|
if (Filepath.back() != '/')
|
||||||
if (Settings.titlestxt_path[Filepath.size() - 1] != '/')
|
|
||||||
Filepath += '/';
|
Filepath += '/';
|
||||||
Filepath += "wiitdb.xml";
|
Filepath += "wiitdb.xml";
|
||||||
|
|
||||||
GameTDB XML_DB;
|
GameTDB XML_DB;
|
||||||
|
|
||||||
if (!XML_DB.OpenFile((Filepath.c_str())))
|
if (!XML_DB.OpenFile(Filepath.c_str()))
|
||||||
return true; //! If no file exists we need the file
|
return true; //! If no file exists we need the file
|
||||||
|
|
||||||
u64 ExistingVersion = XML_DB.GetGameTDBVersion();
|
u64 ExistingVersion = XML_DB.GetGameTDBVersion();
|
||||||
|
XML_DB.CloseFile();
|
||||||
|
|
||||||
gprintf("Existing GameTDB Version: %llu Online GameTDB Version: %llu\n", ExistingVersion, file.gametdbcheck);
|
gprintf("Existing GameTDB Version: %llu Online GameTDB Version: %llu\n", ExistingVersion, file.gametdbcheck);
|
||||||
|
|
||||||
@ -118,10 +118,9 @@ int UpdateGameTDB()
|
|||||||
|
|
||||||
gprintf("Updating GameTDB...\n");
|
gprintf("Updating GameTDB...\n");
|
||||||
|
|
||||||
std::string ZipPath = Settings.titlestxt_path;
|
std::string ZipPath(Settings.titlestxt_path);
|
||||||
if (Settings.titlestxt_path[ZipPath.size() - 1] != '/')
|
if (ZipPath.back() != '/')
|
||||||
ZipPath += '/';
|
ZipPath += '/';
|
||||||
|
|
||||||
ZipPath += "wiitdb.zip";
|
ZipPath += "wiitdb.zip";
|
||||||
|
|
||||||
int filesize = DownloadFileToPath(Settings.URL_GameTDB, ZipPath.c_str());
|
int filesize = DownloadFileToPath(Settings.URL_GameTDB, ZipPath.c_str());
|
||||||
|
@ -94,6 +94,7 @@ static int InternalShowGameInfo(struct discHdr *header)
|
|||||||
|
|
||||||
if(!XML_DB.GetGameXMLInfo(ID, &GameInfo))
|
if(!XML_DB.GetGameXMLInfo(ID, &GameInfo))
|
||||||
{
|
{
|
||||||
|
XML_DB.CloseFile();
|
||||||
ShowError(tr("Could not find info for this game in the wiitdb.xml."));
|
ShowError(tr("Could not find info for this game in the wiitdb.xml."));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -255,26 +256,26 @@ static int InternalShowGameInfo(struct discHdr *header)
|
|||||||
char linebuf2[100] = "";
|
char linebuf2[100] = "";
|
||||||
|
|
||||||
// enable icons for required accessories
|
// enable icons for required accessories
|
||||||
for (u32 i = 0; i < GameInfo.AccessoirList.size(); ++i)
|
for (u32 i = 0; i < GameInfo.AccessoryList.size(); ++i)
|
||||||
{
|
{
|
||||||
if(!GameInfo.AccessoirList[i].Required)
|
if(!GameInfo.AccessoryList[i].Required)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "classiccontroller") == 0) classiccontroller = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "classiccontroller") == 0) classiccontroller = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "guitar") == 0) guitar = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "guitar") == 0) guitar = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "drums") == 0) drums = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "drums") == 0) drums = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wheel") == 0) wheel = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "wheel") == 0) wheel = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "microphone") == 0) microphone = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "microphone") == 0) microphone = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "zapper") == 0) zapper = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "zapper") == 0) zapper = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wiispeak") == 0) wiispeak = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "wiispeak") == 0) wiispeak = 1;
|
||||||
//if (strcmp(GameInfo.AccessoirList[i].Name.c_str(),"vitalitysensor")==0)
|
//if (strcmp(GameInfo.AccessoryList[i].Name.c_str(),"vitalitysensor")==0)
|
||||||
// vitalitysensor=1;
|
// vitalitysensor=1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "gamecube") == 0) gamecube = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "gamecube") == 0) gamecube = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch icons
|
// switch icons
|
||||||
@ -331,26 +332,26 @@ static int InternalShowGameInfo(struct discHdr *header)
|
|||||||
else dancepadImgData = Resources::GetImageData("dancepad.png");
|
else dancepadImgData = Resources::GetImageData("dancepad.png");
|
||||||
|
|
||||||
// look for optional accessories
|
// look for optional accessories
|
||||||
for (u32 i = 0; i < GameInfo.AccessoirList.size(); ++i)
|
for (u32 i = 0; i < GameInfo.AccessoryList.size(); ++i)
|
||||||
{
|
{
|
||||||
if(GameInfo.AccessoirList[i].Required)
|
if(GameInfo.AccessoryList[i].Required)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "classiccontroller") == 0) classiccontroller = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "classiccontroller") == 0) classiccontroller = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "guitar") == 0) guitar = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "guitar") == 0) guitar = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "drums") == 0) drums = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "drums") == 0) drums = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wheel") == 0) wheel = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "wheel") == 0) wheel = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "microphone") == 0) microphone = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "microphone") == 0) microphone = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "zapper") == 0) zapper = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "zapper") == 0) zapper = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wiispeak") == 0) wiispeak = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "wiispeak") == 0) wiispeak = 1;
|
||||||
//if (strcmp(GameInfo.AccessoirList[i].Name.c_str(),"vitalitysensor")==0)
|
//if (strcmp(GameInfo.AccessoryList[i].Name.c_str(),"vitalitysensor")==0)
|
||||||
// vitalitysensor=1;
|
// vitalitysensor=1;
|
||||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "gamecube") == 0) gamecube = 1;
|
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "gamecube") == 0) gamecube = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogBoxImg1 = new GuiImage(&dialogBox1);
|
dialogBoxImg1 = new GuiImage(&dialogBox1);
|
||||||
|
@ -35,8 +35,6 @@
|
|||||||
#include "utils/StringTools.h"
|
#include "utils/StringTools.h"
|
||||||
#include "svnrev.h"
|
#include "svnrev.h"
|
||||||
|
|
||||||
using namespace tinyxml2;
|
|
||||||
|
|
||||||
#define VALID_CONFIG_REV 1084
|
#define VALID_CONFIG_REV 1084
|
||||||
|
|
||||||
CGameCategories GameCategories;
|
CGameCategories GameCategories;
|
||||||
@ -48,7 +46,8 @@ CGameCategories::CGameCategories()
|
|||||||
|
|
||||||
const std::vector<unsigned int> &CGameCategories::operator[](const char *id) const
|
const std::vector<unsigned int> &CGameCategories::operator[](const char *id) const
|
||||||
{
|
{
|
||||||
if(!id) return defaultCategory;
|
if (!id)
|
||||||
|
return defaultCategory;
|
||||||
|
|
||||||
for (std::map<std::string, std::vector<unsigned int>>::const_iterator itr = List.begin(); itr != List.end(); itr++)
|
for (std::map<std::string, std::vector<unsigned int>>::const_iterator itr = List.begin(); itr != List.end(); itr++)
|
||||||
{
|
{
|
||||||
@ -61,63 +60,55 @@ const std::vector<unsigned int> &CGameCategories::operator[](const char *id) con
|
|||||||
|
|
||||||
bool CGameCategories::Load(std::string filepath)
|
bool CGameCategories::Load(std::string filepath)
|
||||||
{
|
{
|
||||||
if(filepath.size() == 0)
|
if (filepath.length() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(filepath[filepath.size()-1] != '/')
|
if (filepath.back() != '/')
|
||||||
filepath += '/';
|
filepath += '/';
|
||||||
|
|
||||||
filepath += "GXGameCategories.xml";
|
filepath += "GXGameCategories.xml";
|
||||||
configPath = filepath;
|
configPath = filepath;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
XMLDocument xmlDoc;
|
pugi::xml_document xmlDoc;
|
||||||
if(xmlDoc.LoadFile(filepath.c_str()) != 0)
|
pugi::xml_parse_result result = xmlDoc.load_file(filepath.c_str());
|
||||||
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!ValidVersion(xmlDoc.FirstChildElement("Revision")))
|
pugi::xml_node root = xmlDoc.child("USBLoaderGX");
|
||||||
|
if (!root)
|
||||||
|
root = xmlDoc;
|
||||||
|
|
||||||
|
if (!ValidVersion(root.child("Revision")))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
XMLElement * node = xmlDoc.FirstChildElement("Categories");
|
pugi::xml_node categories = root.child("Categories");
|
||||||
if(!node)
|
if (!categories)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
node = node->FirstChildElement("Category");
|
for (pugi::xml_node category : categories.children("Category"))
|
||||||
|
|
||||||
while(node != NULL)
|
|
||||||
{
|
{
|
||||||
const char * ID = node->Attribute("ID");
|
const char *ID = category.attribute("ID").value();
|
||||||
const char * Name = node->Attribute("Name");
|
const char *Name = category.attribute("Name").value();
|
||||||
|
|
||||||
if (ID && Name)
|
if (ID && Name)
|
||||||
CategoryList.SetCategory(atoi(ID), Name);
|
CategoryList.SetCategory(atoi(ID), Name);
|
||||||
|
|
||||||
node = node->NextSiblingElement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node = xmlDoc.FirstChildElement("GameCategories");
|
pugi::xml_node gamecategories = root.child("GameCategories");
|
||||||
if(!node)
|
if (!gamecategories)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
node = node->FirstChildElement("Game");
|
for (pugi::xml_node game : gamecategories.children("Game"))
|
||||||
|
|
||||||
while(node != NULL)
|
|
||||||
{
|
{
|
||||||
const char * gameID = node->Attribute("ID");
|
const char *gameID = game.attribute("ID").value();
|
||||||
|
|
||||||
XMLElement * category = node->FirstChildElement("Category");
|
for (pugi::xml_node category : game.children("Category"))
|
||||||
|
|
||||||
while(category != NULL)
|
|
||||||
{
|
{
|
||||||
const char * categoryID = category->Attribute("ID");
|
const char *categoryID = category.attribute("ID").value();
|
||||||
if (gameID && categoryID)
|
if (gameID && categoryID)
|
||||||
SetCategory(gameID, atoi(categoryID));
|
SetCategory(gameID, atoi(categoryID));
|
||||||
|
|
||||||
category = category->NextSiblingElement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->NextSiblingElement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CategoryList.goToFirst();
|
CategoryList.goToFirst();
|
||||||
@ -137,55 +128,44 @@ bool CGameCategories::Save()
|
|||||||
CreateSubfolder(filepath);
|
CreateSubfolder(filepath);
|
||||||
|
|
||||||
StartProgress(tr("Generating GXGameCategories.xml"), tr("Please wait..."), 0, false, true);
|
StartProgress(tr("Generating GXGameCategories.xml"), tr("Please wait..."), 0, false, true);
|
||||||
XMLDocument xmlDoc;
|
|
||||||
|
|
||||||
XMLDeclaration *declaration = xmlDoc.NewDeclaration();
|
pugi::xml_document xmlDoc;
|
||||||
xmlDoc.InsertEndChild(declaration);
|
pugi::xml_node declaration = xmlDoc.append_child(pugi::node_declaration);
|
||||||
XMLElement *Revision = xmlDoc.NewElement("Revision");
|
declaration.append_attribute("version") = "1.0";
|
||||||
XMLText *revText = xmlDoc.NewText(GetRev());
|
declaration.append_attribute("encoding") = "UTF-8";
|
||||||
Revision->InsertEndChild(revText);
|
|
||||||
xmlDoc.InsertEndChild(Revision);
|
pugi::xml_node root = xmlDoc.append_child("USBLoaderGX");
|
||||||
|
pugi::xml_node revision = root.append_child("Revision");
|
||||||
|
revision.append_child(pugi::node_pcdata).set_value(GetRev());
|
||||||
|
|
||||||
int progressSize = CategoryList.size() + List.size();
|
int progressSize = CategoryList.size() + List.size();
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
|
|
||||||
//! Add all categories as an ID map
|
//! Add all categories as an ID map
|
||||||
{
|
pugi::xml_node categories = root.append_child("Categories");
|
||||||
//! On LinkEndChild TinyXML owns and deletes the elements allocated here.
|
|
||||||
//! This is more memory efficient than making another copy of the elements.
|
|
||||||
XMLElement *Categories = xmlDoc.NewElement("Categories");
|
|
||||||
|
|
||||||
CategoryList.goToFirst();
|
CategoryList.goToFirst();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ShowProgress(progress, progressSize);
|
ShowProgress(progress, progressSize);
|
||||||
|
|
||||||
XMLElement *Category = xmlDoc.NewElement("Category");
|
pugi::xml_node category = categories.append_child("Category");
|
||||||
Category->SetAttribute("ID", fmt("%02i", CategoryList.getCurrentID()));
|
category.append_attribute("ID") = fmt("%02i", CategoryList.getCurrentID());
|
||||||
Category->SetAttribute("Name", CategoryList.getCurrentName().c_str());
|
category.append_attribute("Name") = CategoryList.getCurrentName().c_str();
|
||||||
|
|
||||||
Categories->LinkEndChild(Category);
|
|
||||||
|
|
||||||
++progress;
|
++progress;
|
||||||
}
|
} while (CategoryList.goToNext());
|
||||||
while(CategoryList.goToNext());
|
|
||||||
|
|
||||||
xmlDoc.LinkEndChild(Categories);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Add game specific categories now
|
//! Add game specific categories now
|
||||||
{
|
pugi::xml_node gamecategories = root.append_child("GameCategories");
|
||||||
//! On LinkEndChild TinyXML owns and deletes the elements allocated here.
|
|
||||||
//! This is more memory efficient than making another copy of the elements.
|
|
||||||
XMLElement *GameCategories = xmlDoc.NewElement("GameCategories");
|
|
||||||
|
|
||||||
for (std::map<std::string, std::vector<unsigned int>>::iterator itr = List.begin(); itr != List.end(); itr++)
|
for (std::map<std::string, std::vector<unsigned int>>::iterator itr = List.begin(); itr != List.end(); itr++)
|
||||||
{
|
{
|
||||||
ShowProgress(progress, progressSize);
|
ShowProgress(progress, progressSize);
|
||||||
|
|
||||||
XMLElement *Game = xmlDoc.NewElement("Game");
|
pugi::xml_node game = gamecategories.append_child("Game");
|
||||||
Game->SetAttribute("ID", itr->first.c_str());
|
game.append_attribute("ID") = itr->first.c_str();
|
||||||
Game->SetAttribute("Title", GameTitles.GetTitle(itr->first.c_str()));
|
game.append_attribute("Title") = GameTitles.GetTitle(itr->first.c_str());
|
||||||
|
|
||||||
for (u32 i = 0; i < itr->second.size(); ++i)
|
for (u32 i = 0; i < itr->second.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -193,41 +173,35 @@ bool CGameCategories::Save()
|
|||||||
if (!CatName)
|
if (!CatName)
|
||||||
CatName = "";
|
CatName = "";
|
||||||
|
|
||||||
XMLElement *Category = xmlDoc.NewElement("Category");
|
pugi::xml_node category = game.append_child("Category");
|
||||||
Category->SetAttribute("ID", fmt("%02i", itr->second[i]));
|
category.append_attribute("ID") = fmt("%02i", itr->second[i]);
|
||||||
Category->SetAttribute("Name", CatName);
|
category.append_attribute("Name") = CatName;
|
||||||
|
|
||||||
Game->LinkEndChild(Category);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameCategories->LinkEndChild(Game);
|
|
||||||
++progress;
|
++progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlDoc.LinkEndChild(GameCategories);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowProgress(tr("Writing GXGameCategories.xml"), tr("Please wait..."), 0, progressSize, progressSize, false, true);
|
ShowProgress(tr("Writing GXGameCategories.xml"), tr("Please wait..."), 0, progressSize, progressSize, false, true);
|
||||||
|
|
||||||
xmlDoc.SaveFile(configPath.c_str());
|
xmlDoc.save_file(configPath.c_str());
|
||||||
ProgressStop();
|
ProgressStop();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameCategories::ValidVersion(XMLElement *revisionNode)
|
bool CGameCategories::ValidVersion(pugi::xml_node revisionNode)
|
||||||
{
|
{
|
||||||
if(!revisionNode) return false;
|
if (!revisionNode)
|
||||||
|
|
||||||
if(!revisionNode->FirstChild() || !revisionNode->FirstChild()->Value())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return atoi(revisionNode->FirstChild()->Value()) >= VALID_CONFIG_REV;
|
if (!revisionNode.first_child() || !revisionNode.first_child().value())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return atoi(revisionNode.first_child().value()) >= VALID_CONFIG_REV;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameCategories::SetCategory(const char *gameID, unsigned int id)
|
bool CGameCategories::SetCategory(const char *gameID, unsigned int id)
|
||||||
{
|
{
|
||||||
if(!gameID) return false;
|
if (!gameID)
|
||||||
|
return false;
|
||||||
|
|
||||||
char gameID6[7];
|
char gameID6[7];
|
||||||
snprintf(gameID6, sizeof(gameID6), gameID);
|
snprintf(gameID6, sizeof(gameID6), gameID);
|
||||||
@ -256,7 +230,8 @@ bool CGameCategories::SetCategory(const std::string &gameID, unsigned int id)
|
|||||||
|
|
||||||
bool CGameCategories::ReplaceCategory(const char *gameID, unsigned int id)
|
bool CGameCategories::ReplaceCategory(const char *gameID, unsigned int id)
|
||||||
{
|
{
|
||||||
if(!gameID) return false;
|
if (!gameID)
|
||||||
|
return false;
|
||||||
|
|
||||||
char gameID6[7];
|
char gameID6[7];
|
||||||
snprintf(gameID6, sizeof(gameID6), gameID);
|
snprintf(gameID6, sizeof(gameID6), gameID);
|
||||||
@ -266,7 +241,6 @@ bool CGameCategories::ReplaceCategory(const char *gameID, unsigned int id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CGameCategories::ReplaceCategory(const std::string &gameID, unsigned int id)
|
bool CGameCategories::ReplaceCategory(const std::string &gameID, unsigned int id)
|
||||||
{
|
{
|
||||||
List[gameID] = defaultCategory;
|
List[gameID] = defaultCategory;
|
||||||
@ -294,15 +268,14 @@ void CGameCategories::RemoveGameCategories(const std::string &gameID)
|
|||||||
for (std::map<std::string, std::vector<unsigned int>>::iterator itr = List.begin(); itr != List.end(); itr++)
|
for (std::map<std::string, std::vector<unsigned int>>::iterator itr = List.begin(); itr != List.end(); itr++)
|
||||||
{
|
{
|
||||||
if (gameID == itr->first)
|
if (gameID == itr->first)
|
||||||
{
|
|
||||||
List.erase(itr);
|
List.erase(itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CGameCategories::RemoveCategory(const char *gameID, unsigned int id)
|
void CGameCategories::RemoveCategory(const char *gameID, unsigned int id)
|
||||||
{
|
{
|
||||||
if(!gameID) return;
|
if (!gameID)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string gameID6;
|
std::string gameID6;
|
||||||
for (int i = 0; i < 6 && gameID[i] != 0; ++i)
|
for (int i = 0; i < 6 && gameID[i] != 0; ++i)
|
||||||
@ -335,7 +308,8 @@ bool CGameCategories::isInCategory(const char *gameID, unsigned int id)
|
|||||||
if (id == 0) //! ID = 0 means category 'All' so it is always true
|
if (id == 0) //! ID = 0 means category 'All' so it is always true
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(!gameID) return false;
|
if (!gameID)
|
||||||
|
return false;
|
||||||
|
|
||||||
std::string gameID6;
|
std::string gameID6;
|
||||||
for (int i = 0; i < 6 && gameID[i] != 0; ++i)
|
for (int i = 0; i < 6 && gameID[i] != 0; ++i)
|
||||||
@ -367,25 +341,27 @@ bool CGameCategories::ImportFromGameTDB(const std::string &xmlpath)
|
|||||||
StartProgress(tr("Importing categories"), tr("Please wait..."), 0, false, true);
|
StartProgress(tr("Importing categories"), tr("Please wait..."), 0, false, true);
|
||||||
|
|
||||||
XML_DB.SetLanguageCode(Settings.db_language);
|
XML_DB.SetLanguageCode(Settings.db_language);
|
||||||
wString filter(gameList.GetCurrentFilter());
|
|
||||||
gameList.LoadUnfiltered();
|
|
||||||
|
|
||||||
for(int i = 0; i < gameList.size(); ++i)
|
std::vector<struct discHdr *> headerlist;
|
||||||
|
if (!gameList.GetGameListHeaders(headerlist, MODE_ALL))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < headerlist.size(); ++i)
|
||||||
{
|
{
|
||||||
ShowProgress(i, gameList.size());
|
ShowProgress(i, headerlist.size());
|
||||||
|
|
||||||
std::vector<std::string> genreList;
|
std::vector<std::string> genreList;
|
||||||
std::string GameType;
|
std::string GameType;
|
||||||
|
|
||||||
if(XML_DB.GetGameType((const char *) gameList[i]->id, GameType))
|
if (XML_DB.GetGameType((const char *)headerlist[i]->id, GameType))
|
||||||
{
|
{
|
||||||
if (!CategoryList.findCategory(GameType))
|
if (!CategoryList.findCategory(GameType))
|
||||||
CategoryList.AddCategory(GameType);
|
CategoryList.AddCategory(GameType);
|
||||||
|
|
||||||
this->SetCategory(gameList[i]->id, CategoryList.getCurrentID());
|
this->SetCategory(headerlist[i]->id, CategoryList.getCurrentID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!XML_DB.GetGenreList((const char *) gameList[i]->id, genreList))
|
if (!XML_DB.GetGenreList((const char *)headerlist[i]->id, genreList))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (u32 n = 0; n < genreList.size(); ++n)
|
for (u32 n = 0; n < genreList.size(); ++n)
|
||||||
@ -393,13 +369,11 @@ bool CGameCategories::ImportFromGameTDB(const std::string &xmlpath)
|
|||||||
if (!CategoryList.findCategory(genreList[n]))
|
if (!CategoryList.findCategory(genreList[n]))
|
||||||
CategoryList.AddCategory(genreList[n]);
|
CategoryList.AddCategory(genreList[n]);
|
||||||
|
|
||||||
this->SetCategory(gameList[i]->id, CategoryList.getCurrentID());
|
this->SetCategory(headerlist[i]->id, CategoryList.getCurrentID());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XML_DB.CloseFile();
|
XML_DB.CloseFile();
|
||||||
gameList.FilterList(filter.c_str());
|
|
||||||
|
|
||||||
ProgressStop();
|
ProgressStop();
|
||||||
|
|
||||||
|
@ -28,11 +28,9 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "xml/tinyxml2.h"
|
#include "xml/pugixml.hpp"
|
||||||
#include "CCategoryList.hpp"
|
#include "CCategoryList.hpp"
|
||||||
|
|
||||||
using namespace tinyxml2;
|
|
||||||
|
|
||||||
class CGameCategories
|
class CGameCategories
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -58,7 +56,7 @@ class CGameCategories
|
|||||||
|
|
||||||
CCategoryList CategoryList;
|
CCategoryList CategoryList;
|
||||||
protected:
|
protected:
|
||||||
bool ValidVersion(XMLElement *xmlfile);
|
bool ValidVersion(pugi::xml_node xmlfile);
|
||||||
|
|
||||||
std::string configPath;
|
std::string configPath;
|
||||||
const std::vector<unsigned int> defaultCategory;
|
const std::vector<unsigned int> defaultCategory;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -26,12 +26,13 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "pugixml.hpp"
|
||||||
|
|
||||||
typedef struct _Accessoir
|
typedef struct _Accessory
|
||||||
{
|
{
|
||||||
std::string Name;
|
std::string Name;
|
||||||
bool Required;
|
bool Required;
|
||||||
} Accessoir;
|
} Accessory;
|
||||||
|
|
||||||
typedef struct _GameXMLInfo
|
typedef struct _GameXMLInfo
|
||||||
{
|
{
|
||||||
@ -49,7 +50,7 @@ typedef struct _GameXMLInfo
|
|||||||
int WifiPlayers;
|
int WifiPlayers;
|
||||||
std::vector<std::string> WifiFeatureList;
|
std::vector<std::string> WifiFeatureList;
|
||||||
int Players;
|
int Players;
|
||||||
std::vector<Accessoir> AccessoirList;
|
std::vector<Accessory> AccessoryList;
|
||||||
long CaseColor;
|
long CaseColor;
|
||||||
|
|
||||||
} GameXMLInfo;
|
} GameXMLInfo;
|
||||||
@ -86,6 +87,8 @@ class GameTDB
|
|||||||
bool GetSynopsis(const char *id, std::string &synopsis);
|
bool GetSynopsis(const char *id, std::string &synopsis);
|
||||||
//! Get the region of a game for a specific game id
|
//! Get the region of a game for a specific game id
|
||||||
bool GetRegion(const char *id, std::string ®ion);
|
bool GetRegion(const char *id, std::string ®ion);
|
||||||
|
//! Get the languages of a game for a specific game id
|
||||||
|
bool GetLanguages(const char *id, std::string &languages);
|
||||||
//! Get the developer of a game for a specific game id
|
//! Get the developer of a game for a specific game id
|
||||||
bool GetDeveloper(const char *id, std::string &dev);
|
bool GetDeveloper(const char *id, std::string &dev);
|
||||||
//! Get the publisher of a game for a specific game id
|
//! Get the publisher of a game for a specific game id
|
||||||
@ -113,9 +116,9 @@ class GameTDB
|
|||||||
//! Get the player count for a specific game id
|
//! Get the player count for a specific game id
|
||||||
//! Returns the amount of players or -1 if failed
|
//! Returns the amount of players or -1 if failed
|
||||||
int GetPlayers(const char *id);
|
int GetPlayers(const char *id);
|
||||||
//! Returns the amount of accessoirs found or -1 if failed
|
//! Returns the amount of accessories found or -1 if failed
|
||||||
//! Get the accessoir (inputs) list inside a std::vector for a specific game id
|
//! Get the accessory (inputs) list inside a std::vector for a specific game id
|
||||||
int GetAccessoirList(const char * id, std::vector<Accessoir> & acc_list);
|
int GetAccessoryList(const char *id, std::vector<Accessory> &acc_list);
|
||||||
//! Get the box (case) color for a specific game id
|
//! Get the box (case) color for a specific game id
|
||||||
//! Returns the color in RGB (first 3 bytes)
|
//! Returns the color in RGB (first 3 bytes)
|
||||||
int GetCaseColor(const char *id);
|
int GetCaseColor(const char *id);
|
||||||
@ -126,7 +129,7 @@ class GameTDB
|
|||||||
//! Translate genre list to configure language code
|
//! Translate genre list to configure language code
|
||||||
void TranslateGenres(std::vector<std::string> &GenreList);
|
void TranslateGenres(std::vector<std::string> &GenreList);
|
||||||
//! Translate descriptors list to configure language code
|
//! Translate descriptors list to configure language code
|
||||||
void TranslateDescriptors(std::vector<std::string> &DescList);
|
//! void TranslateDescriptors(std::vector<std::string> &DescList);
|
||||||
//! Convert a specific game rating to a std::string
|
//! Convert a specific game rating to a std::string
|
||||||
static const char *RatingToString(int rating);
|
static const char *RatingToString(int rating);
|
||||||
//! Convert a rating std::string to a rating number
|
//! Convert a rating std::string to a rating number
|
||||||
@ -137,22 +140,21 @@ class GameTDB
|
|||||||
unsigned long long GetGameTDBVersion();
|
unsigned long long GetGameTDBVersion();
|
||||||
//! Get the entry count in the xml database
|
//! Get the entry count in the xml database
|
||||||
inline size_t GetEntryCount() { return OffsetMap.size(); };
|
inline size_t GetEntryCount() { return OffsetMap.size(); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ParseFile();
|
bool ParseFile();
|
||||||
bool LoadGameOffsets(const char *path);
|
bool LoadGameOffsets(const char *path);
|
||||||
bool SaveGameOffsets(const char *path);
|
bool SaveGameOffsets(const char *path);
|
||||||
|
bool ParseGameNode(const char *id);
|
||||||
inline int GetData(char *data, int offset, int size);
|
inline int GetData(char *data, int offset, int size);
|
||||||
inline char *LoadGameNode(const char *id);
|
inline char *LoadGameNode(const char *id);
|
||||||
inline char * GetGameNode(const char * id);
|
|
||||||
inline GameOffsets *GetGameOffset(const char *id);
|
inline GameOffsets *GetGameOffset(const char *id);
|
||||||
inline char * SeekLang(char * text, const char * langcode);
|
|
||||||
inline char * GetNodeText(char * data, const char * nodestart, const char * nodeend);
|
|
||||||
|
|
||||||
std::vector<GameOffsets> OffsetMap;
|
std::vector<GameOffsets> OffsetMap;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
std::string LangCode;
|
std::string LangCode;
|
||||||
char * GameNodeCache;
|
|
||||||
char GameIDCache[7];
|
char GameIDCache[7];
|
||||||
|
pugi::xml_document xmlDoc;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
77
source/xml/pugiconfig.hpp
Normal file
77
source/xml/pugiconfig.hpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/**
|
||||||
|
* pugixml parser - version 1.13
|
||||||
|
* --------------------------------------------------------
|
||||||
|
* Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
|
||||||
|
* Report bugs and download new versions at https://pugixml.org/
|
||||||
|
*
|
||||||
|
* This library is distributed under the MIT License. See notice at the end
|
||||||
|
* of this file.
|
||||||
|
*
|
||||||
|
* This work is based on the pugxml parser, which is:
|
||||||
|
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HEADER_PUGICONFIG_HPP
|
||||||
|
#define HEADER_PUGICONFIG_HPP
|
||||||
|
|
||||||
|
// Uncomment this to enable wchar_t mode
|
||||||
|
// #define PUGIXML_WCHAR_MODE
|
||||||
|
|
||||||
|
// Uncomment this to enable compact mode
|
||||||
|
// #define PUGIXML_COMPACT
|
||||||
|
|
||||||
|
// Uncomment this to disable XPath
|
||||||
|
// #define PUGIXML_NO_XPATH
|
||||||
|
|
||||||
|
// Uncomment this to disable STL
|
||||||
|
// #define PUGIXML_NO_STL
|
||||||
|
|
||||||
|
// Uncomment this to disable exceptions
|
||||||
|
// #define PUGIXML_NO_EXCEPTIONS
|
||||||
|
|
||||||
|
// Set this to control attributes for public classes/functions, i.e.:
|
||||||
|
// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
|
||||||
|
// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
|
||||||
|
// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
|
||||||
|
// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead
|
||||||
|
|
||||||
|
// Tune these constants to adjust memory-related behavior
|
||||||
|
// #define PUGIXML_MEMORY_PAGE_SIZE 32768
|
||||||
|
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240
|
||||||
|
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
|
||||||
|
|
||||||
|
// Tune this constant to adjust max nesting for XPath queries
|
||||||
|
// #define PUGIXML_XPATH_DEPTH_LIMIT 1024
|
||||||
|
|
||||||
|
// Uncomment this to switch to header-only version
|
||||||
|
// #define PUGIXML_HEADER_ONLY
|
||||||
|
|
||||||
|
// Uncomment this to enable long long support
|
||||||
|
// #define PUGIXML_HAS_LONG_LONG
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2022 Arseny Kapoulkine
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
13158
source/xml/pugixml.cpp
Normal file
13158
source/xml/pugixml.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1506
source/xml/pugixml.hpp
Normal file
1506
source/xml/pugixml.hpp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user