Handle default locations

This commit is contained in:
loki-47-6F-64 2022-08-08 14:20:52 +02:00
parent f8852e9ad5
commit aba2c3c9c5

View File

@ -4635,8 +4635,10 @@ std::map<std::string, std::string> Downloader::cloudSaveLocations(const std::str
std::cout << "Cloud saves for Linux builds not yet supported" << std::endl; std::cout << "Cloud saves for Linux builds not yet supported" << std::endl;
return {}; return {};
} }
else if (iPlatform == GlobalConstants::PLATFORM_MAC) else if (iPlatform == GlobalConstants::PLATFORM_MAC) {
sPlatform = "osx"; std::cout << "Cloud saves for Mac builds not yet supported" << std::endl;
return {};
}
else else
sPlatform = "windows"; sPlatform = "windows";
@ -4672,11 +4674,12 @@ std::map<std::string, std::string> Downloader::cloudSaveLocations(const std::str
std::string platform; std::string platform;
switch(iPlatform) { switch(iPlatform) {
case GlobalConstants::PLATFORM_MAC: case GlobalConstants::PLATFORM_WINDOWS:
platform = "MacOS"; platform = "Windows";
break; break;
default: default:
platform = "Windows"; std::cout << "Only Windows supported for now for cloud support" << std::endl;
return {};
} }
std::string install_path = Globals::globalConfig.dirConf.sDirectory + install_directory; std::string install_path = Globals::globalConfig.dirConf.sDirectory + install_directory;
@ -4686,7 +4689,12 @@ std::map<std::string, std::string> Downloader::cloudSaveLocations(const std::str
std::string appdata_local_low_path = Globals::globalConfig.dirConf.sWinePrefix + "drive_c/users/" + username() + "/AppData/LocalLow/"; std::string appdata_local_low_path = Globals::globalConfig.dirConf.sWinePrefix + "drive_c/users/" + username() + "/AppData/LocalLow/";
std::string saved_games = Globals::globalConfig.dirConf.sWinePrefix + "drive_c/users/" + username() + "/Save Games/"; std::string saved_games = Globals::globalConfig.dirConf.sWinePrefix + "drive_c/users/" + username() + "/Save Games/";
auto cloud_saves_json = gogGalaxy->getCloudPathAsJson(manifest["clientId"].asString())["content"][platform]["cloudStorage"]["locations"]; auto cloud_saves_json = gogGalaxy->getCloudPathAsJson(manifest["clientId"].asString())["content"][platform]["cloudStorage"];
auto enabled = cloud_saves_json["enabled"].asBool();
if(!enabled) {
return {};
}
std::map<std::string, std::string> vars { std::map<std::string, std::string> vars {
{ "INSTALL", std::move(install_path) }, { "INSTALL", std::move(install_path) },
@ -4698,12 +4706,26 @@ std::map<std::string, std::string> Downloader::cloudSaveLocations(const std::str
}; };
std::map<std::string, std::string> name_to_location; std::map<std::string, std::string> name_to_location;
for(auto &cloud_save : cloud_saves_json) { for(auto &cloud_save : cloud_saves_json["locations"]) {
std::string location = parseLocation(cloud_save["location"].asString(), vars); std::string location = parseLocation(cloud_save["location"].asString(), vars);
name_to_location.insert({cloud_save["name"].asString(), std::move(location)}); name_to_location.insert({cloud_save["name"].asString(), std::move(location)});
} }
if(name_to_location.empty()) {
std::string location;
switch(iPlatform) {
case GlobalConstants::PLATFORM_WINDOWS:
location = vars["APPLICATION_DATA_LOCAL"] + "/GOG.com/Galaxy/Applications/" + Globals::galaxyConf.getClientId() + "/Storage";
break;
default:
std::cout << "Only Windows supported for now for cloud support" << std::endl;
return {};
}
name_to_location.insert({"__default", std::move(location)});
}
return name_to_location; return name_to_location;
} }