mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Galaxy: Add option to select language
This commit is contained in:
parent
8cbc62b8cd
commit
d4a6791e65
@ -35,6 +35,7 @@ struct DownloadConfig
|
|||||||
std::vector<unsigned int> vLanguagePriority;
|
std::vector<unsigned int> vLanguagePriority;
|
||||||
unsigned int iInclude;
|
unsigned int iInclude;
|
||||||
unsigned int iGalaxyPlatform;
|
unsigned int iGalaxyPlatform;
|
||||||
|
unsigned int iGalaxyLanguage;
|
||||||
|
|
||||||
bool bRemoteXML;
|
bool bRemoteXML;
|
||||||
bool bCover;
|
bool bCover;
|
||||||
|
10
main.cpp
10
main.cpp
@ -93,6 +93,13 @@ int main(int argc, char *argv[])
|
|||||||
language_text += "\n\n" + priority_help_text;
|
language_text += "\n\n" + priority_help_text;
|
||||||
language_text += "\nExample: German if available otherwise English and French: de,en+fr";
|
language_text += "\nExample: German if available otherwise English and French: de,en+fr";
|
||||||
|
|
||||||
|
// Create help text for --galaxy-language option
|
||||||
|
std::string galaxy_language_text = "Select language\n";
|
||||||
|
for (unsigned int i = 0; i < GlobalConstants::LANGUAGES.size(); ++i)
|
||||||
|
{
|
||||||
|
galaxy_language_text += GlobalConstants::LANGUAGES[i].str + " = " + GlobalConstants::LANGUAGES[i].regexp + "|" + std::to_string(GlobalConstants::LANGUAGES[i].id) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Create help text for --check-orphans
|
// Create help text for --check-orphans
|
||||||
std::string orphans_regex_default = ".*\\.(zip|exe|bin|dmg|old|deb|tar\\.gz|pkg|sh)$"; // Limit to files with these extensions (".old" is for renamed older version files)
|
std::string orphans_regex_default = ".*\\.(zip|exe|bin|dmg|old|deb|tar\\.gz|pkg|sh)$"; // Limit to files with these extensions (".old" is for renamed older version files)
|
||||||
std::string check_orphans_text = "Check for orphaned files (files found on local filesystem that are not found on GOG servers). Sets regular expression filter (Perl syntax) for files to check. If no argument is given then the regex defaults to '" + orphans_regex_default + "'";
|
std::string check_orphans_text = "Check for orphaned files (files found on local filesystem that are not found on GOG servers). Sets regular expression filter (Perl syntax) for files to check. If no argument is given then the regex defaults to '" + orphans_regex_default + "'";
|
||||||
@ -137,6 +144,7 @@ int main(int argc, char *argv[])
|
|||||||
std::string sIncludeOptions;
|
std::string sIncludeOptions;
|
||||||
std::string sExcludeOptions;
|
std::string sExcludeOptions;
|
||||||
std::string sGalaxyPlatform;
|
std::string sGalaxyPlatform;
|
||||||
|
std::string sGalaxyLanguage;
|
||||||
Globals::globalConfig.bReport = false;
|
Globals::globalConfig.bReport = false;
|
||||||
// Commandline options (no config file)
|
// Commandline options (no config file)
|
||||||
options_cli_no_cfg.add_options()
|
options_cli_no_cfg.add_options()
|
||||||
@ -211,6 +219,7 @@ int main(int argc, char *argv[])
|
|||||||
("galaxy-install", bpo::value<std::string>(&galaxy_product_id_install)->default_value(""), "Install game using product id")
|
("galaxy-install", bpo::value<std::string>(&galaxy_product_id_install)->default_value(""), "Install game using product id")
|
||||||
("galaxy-show-builds", bpo::value<std::string>(&galaxy_product_id_show_builds)->default_value(""), "Show game builds using product id")
|
("galaxy-show-builds", bpo::value<std::string>(&galaxy_product_id_show_builds)->default_value(""), "Show game builds using product id")
|
||||||
("galaxy-platform", bpo::value<std::string>(&sGalaxyPlatform)->default_value("w"), galaxy_platform_text.c_str())
|
("galaxy-platform", bpo::value<std::string>(&sGalaxyPlatform)->default_value("w"), galaxy_platform_text.c_str())
|
||||||
|
("galaxy-language", bpo::value<std::string>(&sGalaxyLanguage)->default_value("en"), galaxy_language_text.c_str())
|
||||||
("login-email", bpo::value<std::string>(&Globals::globalConfig.sEmail)->default_value(""), "login email")
|
("login-email", bpo::value<std::string>(&Globals::globalConfig.sEmail)->default_value(""), "login email")
|
||||||
("login-password", bpo::value<std::string>(&Globals::globalConfig.sPassword)->default_value(""), "login password")
|
("login-password", bpo::value<std::string>(&Globals::globalConfig.sPassword)->default_value(""), "login password")
|
||||||
;
|
;
|
||||||
@ -440,6 +449,7 @@ int main(int argc, char *argv[])
|
|||||||
Util::parseOptionString(sInstallerPlatform, Globals::globalConfig.dlConf.vPlatformPriority, Globals::globalConfig.dlConf.iInstallerPlatform, GlobalConstants::PLATFORMS);
|
Util::parseOptionString(sInstallerPlatform, Globals::globalConfig.dlConf.vPlatformPriority, Globals::globalConfig.dlConf.iInstallerPlatform, GlobalConstants::PLATFORMS);
|
||||||
|
|
||||||
Globals::globalConfig.dlConf.iGalaxyPlatform = Util::getOptionValue(sGalaxyPlatform, GlobalConstants::PLATFORMS);
|
Globals::globalConfig.dlConf.iGalaxyPlatform = Util::getOptionValue(sGalaxyPlatform, GlobalConstants::PLATFORMS);
|
||||||
|
Globals::globalConfig.dlConf.iGalaxyLanguage = Util::getOptionValue(sGalaxyLanguage, GlobalConstants::LANGUAGES);
|
||||||
|
|
||||||
unsigned int include_value = 0;
|
unsigned int include_value = 0;
|
||||||
unsigned int exclude_value = 0;
|
unsigned int exclude_value = 0;
|
||||||
|
@ -3516,6 +3516,17 @@ void Downloader::galaxyInstallGame(const std::string& product_id, int build_inde
|
|||||||
else
|
else
|
||||||
sPlatform = "windows";
|
sPlatform = "windows";
|
||||||
|
|
||||||
|
std::string sLanguage = "en";
|
||||||
|
unsigned int iLanguage = Globals::globalConfig.dlConf.iGalaxyLanguage;
|
||||||
|
for (unsigned int i = 0; i < GlobalConstants::LANGUAGES.size(); ++i)
|
||||||
|
{
|
||||||
|
if (GlobalConstants::LANGUAGES[i].id == iLanguage)
|
||||||
|
{
|
||||||
|
sLanguage = GlobalConstants::LANGUAGES[i].code;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value json = gogGalaxy->getProductBuilds(product_id, sPlatform);
|
Json::Value json = gogGalaxy->getProductBuilds(product_id, sPlatform);
|
||||||
|
|
||||||
// JSON is empty and platform is Linux. Most likely cause is that Galaxy API doesn't have Linux support
|
// JSON is empty and platform is Linux. Most likely cause is that Galaxy API doesn't have Linux support
|
||||||
@ -3544,15 +3555,15 @@ void Downloader::galaxyInstallGame(const std::string& product_id, int build_inde
|
|||||||
std::vector<galaxyDepotItem> items;
|
std::vector<galaxyDepotItem> items;
|
||||||
for (unsigned int i = 0; i < json["depots"].size(); ++i)
|
for (unsigned int i = 0; i < json["depots"].size(); ++i)
|
||||||
{
|
{
|
||||||
bool bSupportedLanguage = false;
|
bool bSelectedLanguage = false;
|
||||||
for (unsigned int j = 0; j < json["depots"][i]["languages"].size(); ++j)
|
for (unsigned int j = 0; j < json["depots"][i]["languages"].size(); ++j)
|
||||||
{
|
{
|
||||||
std::string language = json["depots"][i]["languages"][j].asString();
|
std::string language = json["depots"][i]["languages"][j].asString();
|
||||||
if (language == "*" || language == "en")
|
if (language == "*" || language == sLanguage)
|
||||||
bSupportedLanguage = true;
|
bSelectedLanguage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bSupportedLanguage)
|
if (!bSelectedLanguage)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string depotHash = json["depots"][i]["manifest"].asString();
|
std::string depotHash = json["depots"][i]["manifest"].asString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user