Automatically use a compatible language for games

This commit is contained in:
wiidev 2023-01-01 17:00:33 +00:00
parent 5813ff3981
commit 83133a292b

View File

@ -56,6 +56,7 @@
#include "prompts/ProgressWindow.h" #include "prompts/ProgressWindow.h"
#include "neek.hpp" #include "neek.hpp"
#include "lstub.h" #include "lstub.h"
#include "xml/GameTDB.hpp"
/* GCC 11 false positives */ /* GCC 11 false positives */
#if __GNUC__ > 10 #if __GNUC__ > 10
@ -328,6 +329,40 @@ int GameBooter::BootGame(struct discHdr *gameHdr)
if (NandEmuMode == EMUNAND_NEEK && (gameHeader.type == TYPE_GAME_WII_IMG || gameHeader.type == TYPE_GAME_EMUNANDCHAN)) if (NandEmuMode == EMUNAND_NEEK && (gameHeader.type == TYPE_GAME_WII_IMG || gameHeader.type == TYPE_GAME_EMUNANDCHAN))
return BootNeek(&gameHeader); return BootNeek(&gameHeader);
if (languageChoice == CONSOLE_DEFAULT)
{
std::string Filepath(Settings.titlestxt_path);
if (Filepath.back() != '/')
Filepath += '/';
Filepath += "wiitdb.xml";
GameTDB XML_DB;
if (XML_DB.OpenFile(Filepath.c_str()))
{
std::string gameLangs;
if (XML_DB.GetLanguages((char *)gameHeader.id, gameLangs))
{
// Check if the game supports the system language (CONF_GetLanguage returns 0-9)
std::string sysLangs[] = {"JA", "EN", "DE", "FR", "ES", "IT", "NL", "ZHCN", "ZHTW", "KO"};
if (gameLangs.find(sysLangs[CONF_GetLanguage()]) == std::string::npos)
{
// Use whatever is the first supported language
std::string lang = gameLangs.substr(0, gameLangs.find(","));
for (u32 i = 0; i < sizeof(sysLangs) / sizeof(sysLangs[0]); i++)
{
if (sysLangs[i] == lang)
{
gprintf("Changed language to %s\n", lang.c_str());
languageChoice = i;
break;
}
}
}
}
XML_DB.CloseFile();
}
}
AppCleanUp(); AppCleanUp();
gprintf("\tSettings.partition: %d\n", Settings.partition); gprintf("\tSettings.partition: %d\n", Settings.partition);