Rename global constants to better describe what they mean

This commit is contained in:
Sude 2013-04-25 10:48:10 +03:00
parent 1593c58a01
commit 9ee5f75bfb
4 changed files with 14 additions and 14 deletions

View File

@ -81,7 +81,7 @@ class API
std::string getResponseOAuth(const std::string& url);
int getUserDetails();
int getGames();
gameDetails getGameDetails(const std::string& game_name, const unsigned int& type = GlobalConstants::INSTALLER_WINDOWS, const unsigned int& lang = GlobalConstants::LANGUAGE_EN);
gameDetails getGameDetails(const std::string& game_name, const unsigned int& type = GlobalConstants::PLATFORM_WINDOWS, const unsigned int& lang = GlobalConstants::LANGUAGE_EN);
std::string getInstallerLink(const std::string& game_name, const std::string& id);
std::string getExtraLink(const std::string& game_name, const std::string& id);
std::string getXML(const std::string& game_name, const std::string& id);

View File

@ -51,14 +51,14 @@ namespace GlobalConstants
};
// Installer constants
const unsigned int INSTALLER_WINDOWS = 1;
const unsigned int INSTALLER_MAC = 2;
const unsigned int PLATFORM_WINDOWS = 1;
const unsigned int PLATFORM_MAC = 2;
struct installerStruct {const unsigned int installerId; const std::string installerCode; const std::string installerString;};
const std::vector<installerStruct> INSTALLERS =
struct platformStruct {const unsigned int platformId; const std::string platformCode; const std::string platformString;};
const std::vector<platformStruct> PLATFORMS =
{
{ INSTALLER_WINDOWS, "win", "Windows" },
{ INSTALLER_MAC, "mac", "Mac" }
{ PLATFORM_WINDOWS, "win", "Windows" },
{ PLATFORM_MAC, "mac", "Mac" }
};
};

View File

@ -52,9 +52,9 @@ int main(int argc, char *argv[])
// Create help text for --platform option
std::string platform_text = "Select which installers are downloaded\n";
unsigned int platform_sum = 0;
for (unsigned int i = 0; i < GlobalConstants::INSTALLERS.size(); ++i)
for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i)
{
platform_text += std::to_string(GlobalConstants::INSTALLERS[i].installerId) + " = " + GlobalConstants::INSTALLERS[i].installerString + "\n";
platform_text += std::to_string(GlobalConstants::PLATFORMS[i].platformId) + " = " + GlobalConstants::PLATFORMS[i].platformString + "\n";
platform_sum += GlobalConstants::LANGUAGES[i].languageId;
}
platform_text += std::to_string(platform_sum) + " = All";
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
("xml-directory", bpo::value<std::string>(&config.sXMLDirectory), "Set directory for GOG XML files")
("chunk-size", bpo::value<size_t>(&config.iChunkSize)->default_value(10), "Chunk size (in MB) when creating XML")
("update-check", bpo::value<bool>(&config.bUpdateCheck)->zero_tokens()->default_value(false), "Check for update notifications")
("platform", bpo::value<unsigned int>(&config.iInstallerType)->default_value(GlobalConstants::INSTALLER_WINDOWS), platform_text.c_str())
("platform", bpo::value<unsigned int>(&config.iInstallerType)->default_value(GlobalConstants::PLATFORM_WINDOWS), platform_text.c_str())
("language", bpo::value<unsigned int>(&config.iInstallerLanguage)->default_value(GlobalConstants::LANGUAGE_EN), language_text.c_str())
("no-installers", bpo::value<bool>(&config.bNoInstallers)->zero_tokens()->default_value(false), "Don't download/list/repair installers")
("no-extras", bpo::value<bool>(&config.bNoExtras)->zero_tokens()->default_value(false), "Don't download/list/repair extras")
@ -151,7 +151,7 @@ int main(int argc, char *argv[])
return 1;
}
if (config.iInstallerType < GlobalConstants::INSTALLER_WINDOWS || config.iInstallerType > platform_sum)
if (config.iInstallerType < GlobalConstants::PLATFORM_WINDOWS || config.iInstallerType > platform_sum)
{
std::cout << "Invalid value for --platform" << std::endl;
return 1;

View File

@ -289,11 +289,11 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
// Installer details
std::vector<std::pair<Json::Value,unsigned int>> installers;
for (unsigned int i = 0; i < GlobalConstants::INSTALLERS.size(); ++i)
for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i)
{
if (type & GlobalConstants::INSTALLERS[i].installerId)
if (type & GlobalConstants::PLATFORMS[i].platformId)
{
std::string installer = "installer_" + GlobalConstants::INSTALLERS[i].installerCode + "_";
std::string installer = "installer_" + GlobalConstants::PLATFORMS[i].platformCode + "_";
for (unsigned int j = 0; j < GlobalConstants::LANGUAGES.size(); ++j)
{
if (lang & GlobalConstants::LANGUAGES[j].languageId)