mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-05 02:55:07 +01:00
Change TinyXML to pugixml
Thanks to Oddx.
This commit is contained in:
parent
8ab03c4bf9
commit
fbfcba4200
@ -7,17 +7,15 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "xml/tinyxml2.h"
|
||||
#include "xml/pugixml.hpp"
|
||||
#include "gecko.h"
|
||||
|
||||
#include "HomebrewXML.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
|
||||
#define ENTRIE_SIZE 8192
|
||||
#define ENTRIE_SIZE 8192
|
||||
|
||||
/* qparam filename Filepath of the XML file */
|
||||
int HomebrewXML::LoadHomebrewXMLData(const char* filename)
|
||||
int HomebrewXML::LoadHomebrewXMLData(const char *filename)
|
||||
{
|
||||
Name.clear();
|
||||
Coder.clear();
|
||||
@ -26,121 +24,109 @@ int HomebrewXML::LoadHomebrewXMLData(const char* filename)
|
||||
LongDescription.clear();
|
||||
Releasedate.clear();
|
||||
|
||||
XMLDocument xmlDoc;
|
||||
if(xmlDoc.LoadFile(filename) != 0)
|
||||
return false;
|
||||
pugi::xml_document xmlDoc;
|
||||
pugi::xml_parse_result result = xmlDoc.load_file(filename);
|
||||
if (!result)
|
||||
return 0;
|
||||
|
||||
XMLElement *appNode = xmlDoc.FirstChildElement("app");
|
||||
if(!appNode)
|
||||
return false;
|
||||
Name = xmlDoc.child("app").child_value("name");
|
||||
Coder = xmlDoc.child("app").child_value("coder");
|
||||
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;
|
||||
|
||||
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)
|
||||
std::string ReleaseText = xmlDoc.child("app").child_value("release_date");
|
||||
if (ReleaseText.length() >= 6)
|
||||
{
|
||||
if(argNode->FirstChild() && argNode->FirstChild()->Value())
|
||||
Arguments.push_back(std::string(argNode->FirstChild()->Value()));
|
||||
|
||||
argNode = argNode->NextSiblingElement();
|
||||
if (ReleaseText.find("/") == std::string::npos)
|
||||
{
|
||||
Releasedate = ReleaseText.substr(4, 2);
|
||||
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;
|
||||
}
|
||||
|
||||
int HomebrewXML::SaveHomebrewXMLData(const char* filename)
|
||||
int HomebrewXML::SaveHomebrewXMLData(const char *filename)
|
||||
{
|
||||
const int max_line_size = 4096;
|
||||
char *line = new (std::nothrow) char[max_line_size];
|
||||
if(!line) return 0;
|
||||
if (!line)
|
||||
return 0;
|
||||
|
||||
FILE *fp = fopen(filename, "wb");
|
||||
if(!fp)
|
||||
if (!fp)
|
||||
{
|
||||
delete [] line;
|
||||
delete[] line;
|
||||
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,"<app version=\"1\">\n"); fputs(line, fp);
|
||||
snprintf(line, max_line_size," <name>%s</name>\n", GetName()); 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);
|
||||
snprintf(line, max_line_size, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
|
||||
fputs(line, fp);
|
||||
snprintf(line, max_line_size, "<app version=\"1\">\n");
|
||||
fputs(line, fp);
|
||||
snprintf(line, max_line_size, " <name>%s</name>\n", GetName());
|
||||
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)
|
||||
{
|
||||
snprintf(line, max_line_size," <arguments>\n"); fputs(line, fp);
|
||||
for(u8 i = 0; i < Arguments.size(); i++)
|
||||
snprintf(line, max_line_size, " <arguments>\n");
|
||||
fputs(line, fp);
|
||||
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," <short_description>%s</short_description>\n", GetShortDescription()); 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);
|
||||
snprintf(line, max_line_size, " <ahb_access/>\n");
|
||||
fputs(line, fp);
|
||||
snprintf(line, max_line_size, " <short_description>%s</short_description>\n", GetShortDescription());
|
||||
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);
|
||||
delete [] line;
|
||||
delete[] line;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Set argument */
|
||||
void HomebrewXML::SetArgument(const char* argument)
|
||||
void HomebrewXML::SetArgument(const char *argument)
|
||||
{
|
||||
// Crop value from argument, if present
|
||||
char argName[strlen(argument)+1];
|
||||
char argName[strlen(argument) + 1];
|
||||
strcpy(argName, argument);
|
||||
char *ptr = strrchr(argName, '=');
|
||||
if(ptr) *(ptr+1) = 0;
|
||||
if (ptr)
|
||||
*(ptr + 1) = 0;
|
||||
|
||||
// Check if argument already exists and edit it
|
||||
bool found = false;
|
||||
for(u8 i=0; i < Arguments.size(); i++)
|
||||
for (u8 i = 0; i < Arguments.size(); i++)
|
||||
{
|
||||
size_t pos = Arguments[i].find(argName);
|
||||
if(pos != std::string::npos)
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
Arguments[i] = argument;
|
||||
found = true;
|
||||
@ -149,54 +135,54 @@ void HomebrewXML::SetArgument(const char* argument)
|
||||
}
|
||||
|
||||
// if it doesn't exist, add the new argument.
|
||||
if(!found)
|
||||
if (!found)
|
||||
Arguments.push_back(argument);
|
||||
}
|
||||
|
||||
/* Get name */
|
||||
const char * HomebrewXML::GetName() const
|
||||
const char *HomebrewXML::GetName() const
|
||||
{
|
||||
return Name.c_str();
|
||||
}
|
||||
|
||||
/* Set Name */
|
||||
void HomebrewXML::SetName(char * newName)
|
||||
void HomebrewXML::SetName(char *newName)
|
||||
{
|
||||
Name = newName;
|
||||
}
|
||||
|
||||
/* Get coder */
|
||||
const char * HomebrewXML::GetCoder() const
|
||||
const char *HomebrewXML::GetCoder() const
|
||||
{
|
||||
return Coder.c_str();
|
||||
}
|
||||
|
||||
/* Get version */
|
||||
const char * HomebrewXML::GetVersion() const
|
||||
const char *HomebrewXML::GetVersion() const
|
||||
{
|
||||
return Version.c_str();
|
||||
}
|
||||
|
||||
/* Set version */
|
||||
void HomebrewXML::SetVersion(const char * newVer)
|
||||
void HomebrewXML::SetVersion(const char *newVer)
|
||||
{
|
||||
Version = newVer;
|
||||
}
|
||||
|
||||
/* Get releasedate */
|
||||
const char * HomebrewXML::GetReleasedate() const
|
||||
const char *HomebrewXML::GetReleasedate() const
|
||||
{
|
||||
return Releasedate.c_str();
|
||||
}
|
||||
|
||||
/* Get shortdescription */
|
||||
const char * HomebrewXML::GetShortDescription() const
|
||||
const char *HomebrewXML::GetShortDescription() const
|
||||
{
|
||||
return ShortDescription.c_str();
|
||||
}
|
||||
|
||||
/* Get longdescription */
|
||||
const char * HomebrewXML::GetLongDescription() const
|
||||
const char *HomebrewXML::GetLongDescription() const
|
||||
{
|
||||
return LongDescription.c_str();
|
||||
}
|
||||
|
@ -27,11 +27,9 @@
|
||||
#include "network/networkops.h"
|
||||
#include "network/https.h"
|
||||
#include "utils/StringTools.h"
|
||||
#include "xml/tinyxml2.h"
|
||||
#include "xml/pugixml.hpp"
|
||||
#include "gecko.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
|
||||
Wiinnertag::Wiinnertag(const std::string &filepath)
|
||||
{
|
||||
ReadXML(filepath);
|
||||
@ -39,26 +37,27 @@ Wiinnertag::Wiinnertag(const std::string &filepath)
|
||||
|
||||
bool Wiinnertag::ReadXML(const std::string &filepath)
|
||||
{
|
||||
XMLDocument xmlDoc;
|
||||
if(xmlDoc.LoadFile(filepath.c_str()) != 0)
|
||||
pugi::xml_document xmlDoc;
|
||||
pugi::xml_parse_result result = xmlDoc.load_file(filepath.c_str());
|
||||
if (!result)
|
||||
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 * Key = node->Attribute("Key");
|
||||
const char *URL = node.attribute("URL").value();
|
||||
const char *Key = node.attribute("Key").value();
|
||||
|
||||
if(URL && Key)
|
||||
if (URL && Key)
|
||||
{
|
||||
int size = tagList.size();
|
||||
tagList.resize(size+1);
|
||||
tagList.resize(size + 1);
|
||||
tagList[size].first = URL;
|
||||
tagList[size].second = Key;
|
||||
}
|
||||
|
||||
node = node->NextSiblingElement();
|
||||
node = node.next_sibling();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -66,12 +65,12 @@ bool Wiinnertag::ReadXML(const std::string &filepath)
|
||||
|
||||
bool Wiinnertag::Send(const char *gameID)
|
||||
{
|
||||
if(!IsNetworkInit())
|
||||
if (!IsNetworkInit())
|
||||
return false;
|
||||
|
||||
char sendURL[1024];
|
||||
|
||||
for(u32 i = 0; i < tagList.size(); ++i)
|
||||
for (u32 i = 0; i < tagList.size(); ++i)
|
||||
{
|
||||
strcpy(sendURL, tagList[i].first.c_str());
|
||||
|
||||
@ -88,11 +87,11 @@ bool Wiinnertag::Send(const char *gameID)
|
||||
|
||||
bool Wiinnertag::TagGame(const char *gameID)
|
||||
{
|
||||
std::string fullpath = Settings.WiinnertagPath;
|
||||
if(fullpath.size() == 0)
|
||||
std::string fullpath(Settings.WiinnertagPath);
|
||||
if (fullpath.length() == 0)
|
||||
return false;
|
||||
|
||||
if(fullpath[fullpath.size()-1] != '/')
|
||||
if (fullpath.back() != '/')
|
||||
fullpath += '/';
|
||||
fullpath += "Wiinnertag.xml";
|
||||
|
||||
@ -102,27 +101,26 @@ bool Wiinnertag::TagGame(const char *gameID)
|
||||
|
||||
bool Wiinnertag::CreateExample(const std::string &filepath)
|
||||
{
|
||||
if(filepath.size() == 0)
|
||||
if (filepath.length() == 0)
|
||||
return false;
|
||||
|
||||
CreateSubfolder(filepath.c_str());
|
||||
|
||||
std::string fullpath = filepath;
|
||||
if(fullpath[fullpath.size()-1] != '/')
|
||||
if (fullpath.back() != '/')
|
||||
fullpath += '/';
|
||||
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();
|
||||
xmlDoc.InsertEndChild(declaration);
|
||||
pugi::xml_node Tag = xmlDoc.append_child("Tag");
|
||||
Tag.append_attribute("URL") = "https://tag.rc24.xyz/wii?game={ID6}&key={KEY}";
|
||||
Tag.append_attribute("Key") = "1234567890";
|
||||
|
||||
XMLElement *Tag = xmlDoc.NewElement("Tag");
|
||||
Tag->SetAttribute("URL", "https://tag.rc24.xyz/wii?game={ID6}&key={KEY}");
|
||||
Tag->SetAttribute("Key", "1234567890");
|
||||
xmlDoc.InsertEndChild(Tag);
|
||||
|
||||
xmlDoc.SaveFile(fullpath.c_str());
|
||||
xmlDoc.save_file(fullpath.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -90,18 +90,18 @@ static bool CheckNewGameTDBVersion(const char *url)
|
||||
if (file.gametdbcheck <= 0)
|
||||
return false;
|
||||
|
||||
std::string Title;
|
||||
std::string Filepath = Settings.titlestxt_path;
|
||||
if (Settings.titlestxt_path[Filepath.size() - 1] != '/')
|
||||
std::string Filepath(Settings.titlestxt_path);
|
||||
if (Filepath.back() != '/')
|
||||
Filepath += '/';
|
||||
Filepath += "wiitdb.xml";
|
||||
|
||||
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
|
||||
|
||||
u64 ExistingVersion = XML_DB.GetGameTDBVersion();
|
||||
XML_DB.CloseFile();
|
||||
|
||||
gprintf("Existing GameTDB Version: %llu Online GameTDB Version: %llu\n", ExistingVersion, file.gametdbcheck);
|
||||
|
||||
@ -118,10 +118,9 @@ int UpdateGameTDB()
|
||||
|
||||
gprintf("Updating GameTDB...\n");
|
||||
|
||||
std::string ZipPath = Settings.titlestxt_path;
|
||||
if (Settings.titlestxt_path[ZipPath.size() - 1] != '/')
|
||||
std::string ZipPath(Settings.titlestxt_path);
|
||||
if (ZipPath.back() != '/')
|
||||
ZipPath += '/';
|
||||
|
||||
ZipPath += "wiitdb.zip";
|
||||
|
||||
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))
|
||||
{
|
||||
XML_DB.CloseFile();
|
||||
ShowError(tr("Could not find info for this game in the wiitdb.xml."));
|
||||
return -1;
|
||||
}
|
||||
@ -255,26 +256,26 @@ static int InternalShowGameInfo(struct discHdr *header)
|
||||
char linebuf2[100] = "";
|
||||
|
||||
// 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;
|
||||
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "classiccontroller") == 0) classiccontroller = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "guitar") == 0) guitar = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "drums") == 0) drums = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wheel") == 0) wheel = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "microphone") == 0) microphone = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "zapper") == 0) zapper = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[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(), "classiccontroller") == 0) classiccontroller = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "guitar") == 0) guitar = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "drums") == 0) drums = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "wheel") == 0) wheel = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "microphone") == 0) microphone = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "zapper") == 0) zapper = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "wiispeak") == 0) wiispeak = 1;
|
||||
//if (strcmp(GameInfo.AccessoryList[i].Name.c_str(),"vitalitysensor")==0)
|
||||
// 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
|
||||
@ -331,26 +332,26 @@ static int InternalShowGameInfo(struct discHdr *header)
|
||||
else dancepadImgData = Resources::GetImageData("dancepad.png");
|
||||
|
||||
// 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;
|
||||
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "classiccontroller") == 0) classiccontroller = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "guitar") == 0) guitar = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "drums") == 0) drums = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "wheel") == 0) wheel = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "microphone") == 0) microphone = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "zapper") == 0) zapper = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
|
||||
if (strcmp(GameInfo.AccessoirList[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(), "classiccontroller") == 0) classiccontroller = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "nunchuk") == 0) nunchuk = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "guitar") == 0) guitar = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "drums") == 0) drums = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "dancepad") == 0) dancepad = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "motionplus") == 0) motionplus = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "wheel") == 0) wheel = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "balanceboard") == 0) balanceboard = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "microphone") == 0) microphone = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "zapper") == 0) zapper = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "nintendods") == 0) nintendods = 1;
|
||||
if (strcmp(GameInfo.AccessoryList[i].Name.c_str(), "wiispeak") == 0) wiispeak = 1;
|
||||
//if (strcmp(GameInfo.AccessoryList[i].Name.c_str(),"vitalitysensor")==0)
|
||||
// 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);
|
||||
|
@ -35,9 +35,7 @@
|
||||
#include "utils/StringTools.h"
|
||||
#include "svnrev.h"
|
||||
|
||||
using namespace tinyxml2;
|
||||
|
||||
#define VALID_CONFIG_REV 1084
|
||||
#define VALID_CONFIG_REV 1084
|
||||
|
||||
CGameCategories GameCategories;
|
||||
|
||||
@ -48,11 +46,12 @@ CGameCategories::CGameCategories()
|
||||
|
||||
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++)
|
||||
{
|
||||
if(strncasecmp(itr->first.c_str(), id, 6) == 0)
|
||||
if (strncasecmp(itr->first.c_str(), id, 6) == 0)
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
@ -61,63 +60,55 @@ const std::vector<unsigned int> &CGameCategories::operator[](const char *id) con
|
||||
|
||||
bool CGameCategories::Load(std::string filepath)
|
||||
{
|
||||
if(filepath.size() == 0)
|
||||
if (filepath.length() == 0)
|
||||
return false;
|
||||
|
||||
if(filepath[filepath.size()-1] != '/')
|
||||
if (filepath.back() != '/')
|
||||
filepath += '/';
|
||||
|
||||
filepath += "GXGameCategories.xml";
|
||||
configPath = filepath;
|
||||
|
||||
clear();
|
||||
|
||||
XMLDocument xmlDoc;
|
||||
if(xmlDoc.LoadFile(filepath.c_str()) != 0)
|
||||
pugi::xml_document xmlDoc;
|
||||
pugi::xml_parse_result result = xmlDoc.load_file(filepath.c_str());
|
||||
if (!result)
|
||||
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;
|
||||
|
||||
XMLElement * node = xmlDoc.FirstChildElement("Categories");
|
||||
if(!node)
|
||||
pugi::xml_node categories = root.child("Categories");
|
||||
if (!categories)
|
||||
return false;
|
||||
|
||||
node = node->FirstChildElement("Category");
|
||||
|
||||
while(node != NULL)
|
||||
for (pugi::xml_node category : categories.children("Category"))
|
||||
{
|
||||
const char * ID = node->Attribute("ID");
|
||||
const char * Name = node->Attribute("Name");
|
||||
const char *ID = category.attribute("ID").value();
|
||||
const char *Name = category.attribute("Name").value();
|
||||
|
||||
if(ID && Name)
|
||||
if (ID && Name)
|
||||
CategoryList.SetCategory(atoi(ID), Name);
|
||||
|
||||
node = node->NextSiblingElement();
|
||||
}
|
||||
|
||||
node = xmlDoc.FirstChildElement("GameCategories");
|
||||
if(!node)
|
||||
pugi::xml_node gamecategories = root.child("GameCategories");
|
||||
if (!gamecategories)
|
||||
return false;
|
||||
|
||||
node = node->FirstChildElement("Game");
|
||||
|
||||
while(node != NULL)
|
||||
for (pugi::xml_node game : gamecategories.children("Game"))
|
||||
{
|
||||
const char * gameID = node->Attribute("ID");
|
||||
const char *gameID = game.attribute("ID").value();
|
||||
|
||||
XMLElement * category = node->FirstChildElement("Category");
|
||||
|
||||
while(category != NULL)
|
||||
for (pugi::xml_node category : game.children("Category"))
|
||||
{
|
||||
const char * categoryID = category->Attribute("ID");
|
||||
if(gameID && categoryID)
|
||||
const char *categoryID = category.attribute("ID").value();
|
||||
if (gameID && categoryID)
|
||||
SetCategory(gameID, atoi(categoryID));
|
||||
|
||||
category = category->NextSiblingElement();
|
||||
}
|
||||
|
||||
node = node->NextSiblingElement();
|
||||
}
|
||||
|
||||
CategoryList.goToFirst();
|
||||
@ -130,104 +121,87 @@ bool CGameCategories::Save()
|
||||
char filepath[300];
|
||||
snprintf(filepath, sizeof(filepath), configPath.c_str());
|
||||
|
||||
char * ptr = strrchr(filepath, '/');
|
||||
if(ptr)
|
||||
char *ptr = strrchr(filepath, '/');
|
||||
if (ptr)
|
||||
ptr[0] = 0;
|
||||
|
||||
CreateSubfolder(filepath);
|
||||
|
||||
StartProgress(tr("Generating GXGameCategories.xml"), tr("Please wait..."), 0, false, true);
|
||||
XMLDocument xmlDoc;
|
||||
|
||||
XMLDeclaration *declaration = xmlDoc.NewDeclaration();
|
||||
xmlDoc.InsertEndChild(declaration);
|
||||
XMLElement *Revision = xmlDoc.NewElement("Revision");
|
||||
XMLText *revText = xmlDoc.NewText(GetRev());
|
||||
Revision->InsertEndChild(revText);
|
||||
xmlDoc.InsertEndChild(Revision);
|
||||
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";
|
||||
|
||||
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 progress = 0;
|
||||
|
||||
//! Add all categories as an ID map
|
||||
pugi::xml_node categories = root.append_child("Categories");
|
||||
|
||||
CategoryList.goToFirst();
|
||||
do
|
||||
{
|
||||
//! 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");
|
||||
ShowProgress(progress, progressSize);
|
||||
|
||||
CategoryList.goToFirst();
|
||||
do
|
||||
{
|
||||
ShowProgress(progress, progressSize);
|
||||
pugi::xml_node category = categories.append_child("Category");
|
||||
category.append_attribute("ID") = fmt("%02i", CategoryList.getCurrentID());
|
||||
category.append_attribute("Name") = CategoryList.getCurrentName().c_str();
|
||||
|
||||
XMLElement *Category = xmlDoc.NewElement("Category");
|
||||
Category->SetAttribute("ID", fmt("%02i", CategoryList.getCurrentID()));
|
||||
Category->SetAttribute("Name", CategoryList.getCurrentName().c_str());
|
||||
|
||||
Categories->LinkEndChild(Category);
|
||||
|
||||
++progress;
|
||||
}
|
||||
while(CategoryList.goToNext());
|
||||
|
||||
xmlDoc.LinkEndChild(Categories);
|
||||
}
|
||||
++progress;
|
||||
} while (CategoryList.goToNext());
|
||||
|
||||
//! Add game specific categories now
|
||||
pugi::xml_node gamecategories = root.append_child("GameCategories");
|
||||
|
||||
for (std::map<std::string, std::vector<unsigned int>>::iterator itr = List.begin(); itr != List.end(); itr++)
|
||||
{
|
||||
//! 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");
|
||||
ShowProgress(progress, progressSize);
|
||||
|
||||
for(std::map<std::string, std::vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
|
||||
pugi::xml_node game = gamecategories.append_child("Game");
|
||||
game.append_attribute("ID") = itr->first.c_str();
|
||||
game.append_attribute("Title") = GameTitles.GetTitle(itr->first.c_str());
|
||||
|
||||
for (u32 i = 0; i < itr->second.size(); ++i)
|
||||
{
|
||||
ShowProgress(progress, progressSize);
|
||||
const char *CatName = CategoryList[itr->second[i]];
|
||||
if (!CatName)
|
||||
CatName = "";
|
||||
|
||||
XMLElement *Game = xmlDoc.NewElement("Game");
|
||||
Game->SetAttribute("ID", itr->first.c_str());
|
||||
Game->SetAttribute("Title", GameTitles.GetTitle(itr->first.c_str()));
|
||||
|
||||
for(u32 i = 0; i < itr->second.size(); ++i)
|
||||
{
|
||||
const char *CatName = CategoryList[itr->second[i]];
|
||||
if(!CatName)
|
||||
CatName = "";
|
||||
|
||||
XMLElement *Category = xmlDoc.NewElement("Category");
|
||||
Category->SetAttribute("ID", fmt("%02i", itr->second[i]));
|
||||
Category->SetAttribute("Name", CatName);
|
||||
|
||||
Game->LinkEndChild(Category);
|
||||
}
|
||||
|
||||
GameCategories->LinkEndChild(Game);
|
||||
++progress;
|
||||
pugi::xml_node category = game.append_child("Category");
|
||||
category.append_attribute("ID") = fmt("%02i", itr->second[i]);
|
||||
category.append_attribute("Name") = CatName;
|
||||
}
|
||||
|
||||
xmlDoc.LinkEndChild(GameCategories);
|
||||
++progress;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameCategories::ValidVersion(XMLElement *revisionNode)
|
||||
bool CGameCategories::ValidVersion(pugi::xml_node revisionNode)
|
||||
{
|
||||
if(!revisionNode) return false;
|
||||
|
||||
if(!revisionNode->FirstChild() || !revisionNode->FirstChild()->Value())
|
||||
if (!revisionNode)
|
||||
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)
|
||||
{
|
||||
if(!gameID) return false;
|
||||
if (!gameID)
|
||||
return false;
|
||||
|
||||
char gameID6[7];
|
||||
snprintf(gameID6, sizeof(gameID6), gameID);
|
||||
@ -239,14 +213,14 @@ bool CGameCategories::SetCategory(const char *gameID, unsigned int id)
|
||||
|
||||
bool CGameCategories::SetCategory(const std::string &gameID, unsigned int id)
|
||||
{
|
||||
if(List[gameID].empty())
|
||||
if (List[gameID].empty())
|
||||
List[gameID] = defaultCategory;
|
||||
|
||||
std::vector<unsigned int> tmpVect(List[gameID]);
|
||||
|
||||
for(u32 i = 0; i < tmpVect.size(); ++i)
|
||||
for (u32 i = 0; i < tmpVect.size(); ++i)
|
||||
{
|
||||
if(tmpVect[i] == id)
|
||||
if (tmpVect[i] == id)
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -256,7 +230,8 @@ bool CGameCategories::SetCategory(const std::string &gameID, unsigned int id)
|
||||
|
||||
bool CGameCategories::ReplaceCategory(const char *gameID, unsigned int id)
|
||||
{
|
||||
if(!gameID) return false;
|
||||
if (!gameID)
|
||||
return false;
|
||||
|
||||
char gameID6[7];
|
||||
snprintf(gameID6, sizeof(gameID6), gameID);
|
||||
@ -266,7 +241,6 @@ bool CGameCategories::ReplaceCategory(const char *gameID, unsigned int id)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CGameCategories::ReplaceCategory(const std::string &gameID, unsigned int id)
|
||||
{
|
||||
List[gameID] = defaultCategory;
|
||||
@ -276,13 +250,13 @@ bool CGameCategories::ReplaceCategory(const std::string &gameID, unsigned int id
|
||||
|
||||
void CGameCategories::RemoveCategory(unsigned int id)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
for(u32 i = 0; i < itr->second.size(); ++i)
|
||||
for (u32 i = 0; i < itr->second.size(); ++i)
|
||||
{
|
||||
if(itr->second[i] == id)
|
||||
if (itr->second[i] == id)
|
||||
{
|
||||
itr->second.erase(itr->second.begin()+ i);
|
||||
itr->second.erase(itr->second.begin() + i);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
@ -291,21 +265,20 @@ void CGameCategories::RemoveCategory(unsigned int id)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameCategories::RemoveCategory(const char *gameID, unsigned int id)
|
||||
{
|
||||
if(!gameID) return;
|
||||
if (!gameID)
|
||||
return;
|
||||
|
||||
std::string gameID6;
|
||||
for(int i = 0; i < 6 && gameID[i] != 0; ++i)
|
||||
for (int i = 0; i < 6 && gameID[i] != 0; ++i)
|
||||
gameID6.push_back(gameID[i]);
|
||||
|
||||
RemoveCategory(gameID6, id);
|
||||
@ -313,15 +286,15 @@ void CGameCategories::RemoveCategory(const char *gameID, unsigned int id)
|
||||
|
||||
void CGameCategories::RemoveCategory(const std::string &gameID, unsigned int id)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for(u32 i = 0; i < itr->second.size(); ++i)
|
||||
for (u32 i = 0; i < itr->second.size(); ++i)
|
||||
{
|
||||
if(itr->second[i] == id)
|
||||
if (itr->second[i] == id)
|
||||
{
|
||||
itr->second.erase(itr->second.begin()+ i);
|
||||
itr->second.erase(itr->second.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -332,22 +305,23 @@ void CGameCategories::RemoveCategory(const std::string &gameID, unsigned int id)
|
||||
|
||||
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;
|
||||
|
||||
if(!gameID) return false;
|
||||
if (!gameID)
|
||||
return false;
|
||||
|
||||
std::string gameID6;
|
||||
for(int i = 0; i < 6 && gameID[i] != 0; ++i)
|
||||
for (int i = 0; i < 6 && gameID[i] != 0; ++i)
|
||||
gameID6.push_back(gameID[i]);
|
||||
|
||||
for (std::map<std::string, std::vector<unsigned int> >::iterator itr = GameCategories.List.begin(); itr != GameCategories.List.end(); itr++)
|
||||
for (std::map<std::string, std::vector<unsigned int>>::iterator itr = GameCategories.List.begin(); itr != GameCategories.List.end(); itr++)
|
||||
{
|
||||
if(itr->first == gameID6)
|
||||
if (itr->first == gameID6)
|
||||
{
|
||||
for(u32 i = 0; i < itr->second.size(); ++i)
|
||||
for (u32 i = 0; i < itr->second.size(); ++i)
|
||||
{
|
||||
if(itr->second[i] == id)
|
||||
if (itr->second[i] == id)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -361,45 +335,45 @@ bool CGameCategories::ImportFromGameTDB(const std::string &xmlpath)
|
||||
{
|
||||
GameTDB XML_DB;
|
||||
|
||||
if(!XML_DB.OpenFile(xmlpath.c_str()))
|
||||
if (!XML_DB.OpenFile(xmlpath.c_str()))
|
||||
return false;
|
||||
|
||||
StartProgress(tr("Importing categories"), tr("Please wait..."), 0, false, true);
|
||||
|
||||
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::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);
|
||||
|
||||
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;
|
||||
|
||||
for(u32 n = 0; n < genreList.size(); ++n)
|
||||
for (u32 n = 0; n < genreList.size(); ++n)
|
||||
{
|
||||
if(!CategoryList.findCategory(genreList[n]))
|
||||
if (!CategoryList.findCategory(genreList[n]))
|
||||
CategoryList.AddCategory(genreList[n]);
|
||||
|
||||
this->SetCategory(gameList[i]->id, CategoryList.getCurrentID());
|
||||
this->SetCategory(headerlist[i]->id, CategoryList.getCurrentID());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
XML_DB.CloseFile();
|
||||
gameList.FilterList(filter.c_str());
|
||||
|
||||
ProgressStop();
|
||||
|
||||
|
@ -28,11 +28,9 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "xml/tinyxml2.h"
|
||||
#include "xml/pugixml.hpp"
|
||||
#include "CCategoryList.hpp"
|
||||
|
||||
using namespace tinyxml2;
|
||||
|
||||
class CGameCategories
|
||||
{
|
||||
public:
|
||||
@ -58,7 +56,7 @@ class CGameCategories
|
||||
|
||||
CCategoryList CategoryList;
|
||||
protected:
|
||||
bool ValidVersion(XMLElement *xmlfile);
|
||||
bool ValidVersion(pugi::xml_node xmlfile);
|
||||
|
||||
std::string configPath;
|
||||
const std::vector<unsigned int> defaultCategory;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,12 +26,13 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "pugixml.hpp"
|
||||
|
||||
typedef struct _Accessoir
|
||||
typedef struct _Accessory
|
||||
{
|
||||
std::string Name;
|
||||
bool Required;
|
||||
} Accessoir;
|
||||
} Accessory;
|
||||
|
||||
typedef struct _GameXMLInfo
|
||||
{
|
||||
@ -49,7 +50,7 @@ typedef struct _GameXMLInfo
|
||||
int WifiPlayers;
|
||||
std::vector<std::string> WifiFeatureList;
|
||||
int Players;
|
||||
std::vector<Accessoir> AccessoirList;
|
||||
std::vector<Accessory> AccessoryList;
|
||||
long CaseColor;
|
||||
|
||||
} GameXMLInfo;
|
||||
@ -63,96 +64,97 @@ typedef struct _GameOffsets
|
||||
|
||||
class GameTDB
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
GameTDB();
|
||||
//! Constructor
|
||||
//! If filepath is passed the xml file is opened and the node offsets are loaded
|
||||
GameTDB(const char * filepath);
|
||||
//! Destructor
|
||||
~GameTDB();
|
||||
//! If filepath is passed the xml file is opened and the node offsets are loaded
|
||||
bool OpenFile(const char * filepath);
|
||||
//! Closes the GameTDB xml file
|
||||
void CloseFile();
|
||||
//! Set the language code which should be use to find the appropriate language
|
||||
//! If the language code is not found, the language code defaults to EN
|
||||
void SetLanguageCode(const char * code) { if(code) LangCode = code; };
|
||||
//! Get the current set language code
|
||||
const char * GetLanguageCode() { return LangCode.c_str(); };
|
||||
//! Get the title of a specific game id in the language defined in LangCode
|
||||
bool GetTitle(const char * id, std::string & title);
|
||||
//! Get the synopsis of a specific game id in the language defined in LangCode
|
||||
bool GetSynopsis(const char * id, std::string & synopsis);
|
||||
//! Get the region of a game for a specific game id
|
||||
bool GetRegion(const char * id, std::string & region);
|
||||
//! Get the developer of a game for a specific game id
|
||||
bool GetDeveloper(const char * id, std::string & dev);
|
||||
//! Get the publisher of a game for a specific game id
|
||||
bool GetPublisher(const char * id, std::string & pub);
|
||||
//! Get the publish date of a game for a specific game id
|
||||
//! First 1 byte is the day, than 1 byte month and last 2 bytes is the year
|
||||
//! year = (return >> 16), month = (return >> 8) & 0xFF, day = return & 0xFF
|
||||
unsigned int GetPublishDate(const char * id);
|
||||
//! Get the genre list of a game for a specific game id
|
||||
bool GetGenreList(const char * id, std::vector<std::string> & genre);
|
||||
//! Get the rating type for a specific game id
|
||||
//! The rating type can be converted to a std::string with GameTDB::RatingTostd::string(rating)
|
||||
int GetRating(const char * id);
|
||||
//! Get the rating value for a specific game id
|
||||
bool GetRatingValue(const char * id, std::string & rating_value);
|
||||
//! Get the rating descriptor list inside a std::vector for a specific game id
|
||||
//! Returns the amount of descriptors found or -1 if failed
|
||||
int GetRatingDescriptorList(const char * id, std::vector<std::string> & desc_list);
|
||||
//! Get the wifi player count for a specific game id
|
||||
//! Returns the amount of wifi players or -1 if failed
|
||||
int GetWifiPlayers(const char * id);
|
||||
//! Get the wifi feature list inside a std::vector for a specific game id
|
||||
//! Returns the amount of wifi features found or -1 if failed
|
||||
int GetWifiFeatureList(const char * id, std::vector<std::string> & feat_list);
|
||||
//! Get the player count for a specific game id
|
||||
//! Returns the amount of players or -1 if failed
|
||||
int GetPlayers(const char * id);
|
||||
//! Returns the amount of accessoirs found or -1 if failed
|
||||
//! Get the accessoir (inputs) list inside a std::vector for a specific game id
|
||||
int GetAccessoirList(const char * id, std::vector<Accessoir> & acc_list);
|
||||
//! Get the box (case) color for a specific game id
|
||||
//! Returns the color in RGB (first 3 bytes)
|
||||
int GetCaseColor(const char * id);
|
||||
//! Get the complete game info in the GameXMLInfo struct
|
||||
bool GetGameXMLInfo(const char * id, GameXMLInfo * gameInfo);
|
||||
//! Get the type of the game. If blank the game is a Wii game.
|
||||
bool GetGameType(const char * id, std::string &GameType);
|
||||
//! Translate genre list to configure language code
|
||||
void TranslateGenres(std::vector<std::string> &GenreList);
|
||||
//! Translate descriptors list to configure language code
|
||||
void TranslateDescriptors(std::vector<std::string> &DescList);
|
||||
//! Convert a specific game rating to a std::string
|
||||
static const char * RatingToString(int rating);
|
||||
//! Convert a rating std::string to a rating number
|
||||
static int StringToRating(const char *rate_string);
|
||||
//! Convert a rating to another rating
|
||||
static int ConvertRating(const char *value, const char *from, const char *to);
|
||||
//! Get the version of the gametdb xml database
|
||||
unsigned long long GetGameTDBVersion();
|
||||
//! Get the entry count in the xml database
|
||||
inline size_t GetEntryCount() { return OffsetMap.size(); };
|
||||
private:
|
||||
bool ParseFile();
|
||||
bool LoadGameOffsets(const char * path);
|
||||
bool SaveGameOffsets(const char * path);
|
||||
inline int GetData(char * data, int offset, int size);
|
||||
inline char * LoadGameNode(const char * id);
|
||||
inline char * GetGameNode(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);
|
||||
public:
|
||||
//! Constructor
|
||||
GameTDB();
|
||||
//! Constructor
|
||||
//! If filepath is passed the xml file is opened and the node offsets are loaded
|
||||
GameTDB(const char *filepath);
|
||||
//! Destructor
|
||||
~GameTDB();
|
||||
//! If filepath is passed the xml file is opened and the node offsets are loaded
|
||||
bool OpenFile(const char *filepath);
|
||||
//! Closes the GameTDB xml file
|
||||
void CloseFile();
|
||||
//! Set the language code which should be use to find the appropriate language
|
||||
//! If the language code is not found, the language code defaults to EN
|
||||
void SetLanguageCode(const char *code) { if(code) LangCode = code; };
|
||||
//! Get the current set language code
|
||||
const char *GetLanguageCode() { return LangCode.c_str(); };
|
||||
//! Get the title of a specific game id in the language defined in LangCode
|
||||
bool GetTitle(const char *id, std::string &title);
|
||||
//! Get the synopsis of a specific game id in the language defined in LangCode
|
||||
bool GetSynopsis(const char *id, std::string &synopsis);
|
||||
//! Get the region of a game for a specific game id
|
||||
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
|
||||
bool GetDeveloper(const char *id, std::string &dev);
|
||||
//! Get the publisher of a game for a specific game id
|
||||
bool GetPublisher(const char *id, std::string &pub);
|
||||
//! Get the publish date of a game for a specific game id
|
||||
//! First 1 byte is the day, than 1 byte month and last 2 bytes is the year
|
||||
//! year = (return >> 16), month = (return >> 8) & 0xFF, day = return & 0xFF
|
||||
unsigned int GetPublishDate(const char *id);
|
||||
//! Get the genre list of a game for a specific game id
|
||||
bool GetGenreList(const char *id, std::vector<std::string> &genre);
|
||||
//! Get the rating type for a specific game id
|
||||
//! The rating type can be converted to a std::string with GameTDB::RatingTostd::string(rating)
|
||||
int GetRating(const char *id);
|
||||
//! Get the rating value for a specific game id
|
||||
bool GetRatingValue(const char *id, std::string &rating_value);
|
||||
//! Get the rating descriptor list inside a std::vector for a specific game id
|
||||
//! Returns the amount of descriptors found or -1 if failed
|
||||
int GetRatingDescriptorList(const char *id, std::vector<std::string> &desc_list);
|
||||
//! Get the wifi player count for a specific game id
|
||||
//! Returns the amount of wifi players or -1 if failed
|
||||
int GetWifiPlayers(const char *id);
|
||||
//! Get the wifi feature list inside a std::vector for a specific game id
|
||||
//! Returns the amount of wifi features found or -1 if failed
|
||||
int GetWifiFeatureList(const char *id, std::vector<std::string> &feat_list);
|
||||
//! Get the player count for a specific game id
|
||||
//! Returns the amount of players or -1 if failed
|
||||
int GetPlayers(const char *id);
|
||||
//! Returns the amount of accessories found or -1 if failed
|
||||
//! Get the accessory (inputs) list inside a std::vector for a specific game id
|
||||
int GetAccessoryList(const char *id, std::vector<Accessory> &acc_list);
|
||||
//! Get the box (case) color for a specific game id
|
||||
//! Returns the color in RGB (first 3 bytes)
|
||||
int GetCaseColor(const char *id);
|
||||
//! Get the complete game info in the GameXMLInfo struct
|
||||
bool GetGameXMLInfo(const char *id, GameXMLInfo *gameInfo);
|
||||
//! Get the type of the game. If blank the game is a Wii game.
|
||||
bool GetGameType(const char *id, std::string &GameType);
|
||||
//! Translate genre list to configure language code
|
||||
void TranslateGenres(std::vector<std::string> &GenreList);
|
||||
//! Translate descriptors list to configure language code
|
||||
//! void TranslateDescriptors(std::vector<std::string> &DescList);
|
||||
//! Convert a specific game rating to a std::string
|
||||
static const char *RatingToString(int rating);
|
||||
//! Convert a rating std::string to a rating number
|
||||
static int StringToRating(const char *rate_string);
|
||||
//! Convert a rating to another rating
|
||||
static int ConvertRating(const char *value, const char *from, const char *to);
|
||||
//! Get the version of the gametdb xml database
|
||||
unsigned long long GetGameTDBVersion();
|
||||
//! Get the entry count in the xml database
|
||||
inline size_t GetEntryCount() { return OffsetMap.size(); };
|
||||
|
||||
std::vector<GameOffsets> OffsetMap;
|
||||
FILE * file;
|
||||
std::string LangCode;
|
||||
char * GameNodeCache;
|
||||
char GameIDCache[7];
|
||||
private:
|
||||
bool ParseFile();
|
||||
bool LoadGameOffsets(const char *path);
|
||||
bool SaveGameOffsets(const char *path);
|
||||
bool ParseGameNode(const char *id);
|
||||
inline int GetData(char *data, int offset, int size);
|
||||
inline char *LoadGameNode(const char *id);
|
||||
inline GameOffsets *GetGameOffset(const char *id);
|
||||
|
||||
std::vector<GameOffsets> OffsetMap;
|
||||
FILE *file;
|
||||
std::string LangCode;
|
||||
char GameIDCache[7];
|
||||
pugi::xml_document xmlDoc;
|
||||
};
|
||||
|
||||
#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