diff --git a/include/config.h b/include/config.h index 85c5e67..9385b9e 100644 --- a/include/config.h +++ b/include/config.h @@ -46,6 +46,7 @@ struct DownloadConfig bool bRemoteXML; bool bSaveChangelogs; bool bSaveSerials; + bool bSaveLogo; bool bAutomaticXMLCreation; bool bFreeSpaceCheck; diff --git a/include/gamedetails.h b/include/gamedetails.h index 7637933..555735a 100644 --- a/include/gamedetails.h +++ b/include/gamedetails.h @@ -32,9 +32,11 @@ class gameDetails std::string icon; std::string serials; std::string changelog; + std::string logo; void filterWithPriorities(const gameSpecificConfig& config); void makeFilepaths(const DirectoryConfig& config); std::string getSerialsFilepath(); + std::string getLogoFilepath(); std::string getChangelogFilepath(); Json::Value getDetailsAsJson(); std::vector getGameFileVector(); @@ -46,6 +48,7 @@ class gameDetails void filterListWithType(std::vector& list, const unsigned int& iType); private: std::string serialsFilepath; + std::string logoFilepath; std::string changelogFilepath; }; diff --git a/main.cpp b/main.cpp index d83ad09..c946f50 100644 --- a/main.cpp +++ b/main.cpp @@ -258,6 +258,7 @@ int main(int argc, char *argv[]) ("use-cache", bpo::value(&Globals::globalConfig.bUseCache)->zero_tokens()->default_value(false), ("Use game details cache")) ("cache-valid", bpo::value(&Globals::globalConfig.iCacheValid)->default_value(2880), ("Set how long cached game details are valid (in minutes)\nDefault: 2880 minutes (48 hours)")) ("save-serials", bpo::value(&Globals::globalConfig.dlConf.bSaveSerials)->zero_tokens()->default_value(false), "Save serial numbers when downloading") + ("save-logo", bpo::value(&Globals::globalConfig.dlConf.bSaveLogo)->zero_tokens()->default_value(false), "Save logo when downloading") ("ignore-dlc-count", bpo::value(&Globals::globalConfig.sIgnoreDLCCountRegex)->implicit_value(".*"), "Set regular expression filter for games to ignore DLC count information\nIgnoring DLC count information helps in situations where the account page doesn't provide accurate information about DLCs") ("include", bpo::value(&sIncludeOptions)->default_value("all"), ("Select what to download/list/repair\n" + include_options_text).c_str()) ("exclude", bpo::value(&sExcludeOptions)->default_value(""), ("Select what not to download/list/repair\n" + include_options_text).c_str()) diff --git a/src/downloader.cpp b/src/downloader.cpp index cd02bd0..18ef339 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -683,6 +683,12 @@ void Downloader::download() this->saveSerials(games[i].serials, filepath); } + if (conf.dlConf.bSaveLogo && !games[i].logo.empty()) + { + std::string filepath = games[i].getLogoFilepath(); + this->downloadFile(games[i].logo, filepath, "", games[i].gamename); + } + if (conf.dlConf.bSaveChangelogs && !games[i].changelog.empty()) { std::string filepath = games[i].getChangelogFilepath(); @@ -698,6 +704,11 @@ void Downloader::download() std::string filepath = games[i].dlcs[j].getSerialsFilepath(); this->saveSerials(games[i].dlcs[j].serials, filepath); } + if (conf.dlConf.bSaveLogo && !games[i].dlcs[j].logo.empty()) + { + std::string filepath = games[i].dlcs[j].getLogoFilepath(); + this->downloadFile(games[i].dlcs[j].logo, filepath, "", games[i].dlcs[j].gamename); + } if (conf.dlConf.bSaveChangelogs && !games[i].dlcs[j].changelog.empty()) { std::string filepath = games[i].dlcs[j].getChangelogFilepath(); diff --git a/src/galaxyapi.cpp b/src/galaxyapi.cpp index be83b12..50f9820 100644 --- a/src/galaxyapi.cpp +++ b/src/galaxyapi.cpp @@ -312,6 +312,7 @@ gameDetails galaxyAPI::productInfoJsonToGameDetails(const Json::Value& json, con gamedetails.product_id = json["id"].asString(); gamedetails.title = json["title"].asString(); gamedetails.icon = "https:" + json["images"]["icon"].asString(); + gamedetails.logo = "https:" + json["images"]["logo2x"].asString(); if (json.isMember("changelog")) gamedetails.changelog = json["changelog"].asString(); diff --git a/src/gamedetails.cpp b/src/gamedetails.cpp index 1a16c27..6757fae 100644 --- a/src/gamedetails.cpp +++ b/src/gamedetails.cpp @@ -83,6 +83,7 @@ void gameDetails::makeFilepaths(const DirectoryConfig& config) std::string directory = config.sDirectory + "/" + config.sGameSubdir + "/"; std::string subdir; this->serialsFilepath = Util::makeFilepath(directory, "serials.txt", this->gamename, subdir, 0); + this->logoFilepath = Util::makeFilepath(directory, "logo" + this->logo.substr(this->logo.rfind(".")), this->gamename, subdir, 0); this->changelogFilepath = Util::makeFilepath(directory, "changelog_" + gamename + ".html", this->gamename, subdir, 0); for (unsigned int i = 0; i < this->installers.size(); ++i) @@ -117,6 +118,7 @@ void gameDetails::makeFilepaths(const DirectoryConfig& config) { subdir = config.bSubDirectories ? config.sDLCSubdir + "/" + config.sInstallersSubdir : ""; this->dlcs[i].serialsFilepath = Util::makeFilepath(directory, "serials.txt", this->gamename, subdir, 0); + this->dlcs[i].logoFilepath = Util::makeFilepath(directory, "logo" + this->logo.substr(this->logo.rfind(".")), this->gamename, subdir, 0); this->dlcs[i].changelogFilepath = Util::makeFilepath(directory, "changelog_" + this->dlcs[i].gamename + ".html", this->gamename, subdir, 0); for (unsigned int j = 0; j < this->dlcs[i].installers.size(); ++j) { @@ -184,6 +186,11 @@ std::string gameDetails::getSerialsFilepath() return this->serialsFilepath; } +std::string gameDetails::getLogoFilepath() +{ + return this->logoFilepath; +} + std::string gameDetails::getChangelogFilepath() { return this->changelogFilepath;