Galaxy: Add option to select platform

This commit is contained in:
Sude 2017-03-05 22:47:44 +02:00
parent d4294b6d12
commit f9981c1be0
3 changed files with 48 additions and 2 deletions

View File

@ -34,6 +34,7 @@ struct DownloadConfig
std::vector<unsigned int> vPlatformPriority;
std::vector<unsigned int> vLanguagePriority;
unsigned int iInclude;
unsigned int iGalaxyPlatform;
bool bRemoteXML;
bool bCover;

View File

@ -74,6 +74,13 @@ int main(int argc, char *argv[])
platform_text += "\n\n" + priority_help_text;
platform_text += "\nExample: Linux if available otherwise Windows and Mac: l,w+m";
// Create help text for --galaxy-platform option
std::string galaxy_platform_text = "Select platform\n";
for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i)
{
galaxy_platform_text += GlobalConstants::PLATFORMS[i].str + " = " + GlobalConstants::PLATFORMS[i].regexp + "|" + std::to_string(GlobalConstants::PLATFORMS[i].id) + "\n";
}
// Create help text for --language option
std::string language_text = "Select which language installers are downloaded\n";
unsigned int language_all = Util::getOptionValue("all", GlobalConstants::LANGUAGES);
@ -129,6 +136,7 @@ int main(int argc, char *argv[])
std::string sInstallerLanguage;
std::string sIncludeOptions;
std::string sExcludeOptions;
std::string sGalaxyPlatform;
Globals::globalConfig.bReport = false;
// Commandline options (no config file)
options_cli_no_cfg.add_options()
@ -202,6 +210,7 @@ int main(int argc, char *argv[])
options_cli_no_cfg_hidden.add_options()
("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-platform", bpo::value<std::string>(&sGalaxyPlatform)->default_value("w"), galaxy_platform_text.c_str())
;
options_cli_all.add(options_cli_no_cfg).add(options_cli_cfg);
@ -402,6 +411,8 @@ int main(int argc, char *argv[])
Util::parseOptionString(sInstallerLanguage, Globals::globalConfig.dlConf.vLanguagePriority, Globals::globalConfig.dlConf.iInstallerLanguage, GlobalConstants::LANGUAGES);
Util::parseOptionString(sInstallerPlatform, Globals::globalConfig.dlConf.vPlatformPriority, Globals::globalConfig.dlConf.iInstallerPlatform, GlobalConstants::PLATFORMS);
Globals::globalConfig.dlConf.iGalaxyPlatform = Util::getOptionValue(sGalaxyPlatform, GlobalConstants::PLATFORMS);
unsigned int include_value = 0;
unsigned int exclude_value = 0;
std::vector<std::string> vInclude = Util::tokenize(sIncludeOptions, ",");

View File

@ -3498,7 +3498,24 @@ void Downloader::galaxyInstallGame(const std::string& product_id, int build_inde
if (build_index < 0)
build_index = 0;
Json::Value json = gogGalaxy->getProductBuilds(product_id);
std::string sPlatform;
unsigned int iPlatform = Globals::globalConfig.dlConf.iGalaxyPlatform;
if (iPlatform == GlobalConstants::PLATFORM_LINUX)
sPlatform = "linux";
else if (iPlatform == GlobalConstants::PLATFORM_MAC)
sPlatform = "osx";
else
sPlatform = "windows";
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
if (json.empty() && iPlatform == GlobalConstants::PLATFORM_LINUX)
{
std::cout << "Galaxy API doesn't have Linux support" << std::endl;
return;
}
if (json["items"][build_index]["generation"].asInt() != 2)
{
std::cout << "Only generation 2 builds are supported currently" << std::endl;
@ -3775,7 +3792,24 @@ void Downloader::galaxyInstallGame(const std::string& product_id, int build_inde
void Downloader::galaxyShowBuilds(const std::string& product_id, int build_index)
{
Json::Value json = gogGalaxy->getProductBuilds(product_id);
std::string sPlatform;
unsigned int iPlatform = Globals::globalConfig.dlConf.iGalaxyPlatform;
if (iPlatform == GlobalConstants::PLATFORM_LINUX)
sPlatform = "linux";
else if (iPlatform == GlobalConstants::PLATFORM_MAC)
sPlatform = "osx";
else
sPlatform = "windows";
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
if (json.empty() && iPlatform == GlobalConstants::PLATFORM_LINUX)
{
std::cout << "Galaxy API doesn't have Linux support" << std::endl;
return;
}
if (build_index < 0)
{
for (unsigned int i = 0; i < json["items"].size(); ++i)