From ea597945e88056acf3c43b0d2d7e707987bd9c36 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 16 Jun 2013 20:59:36 +0100 Subject: [PATCH] Lowercased all global constants' names to avoid #define conflicts. --- src/backend/game.cpp | 56 ++++++++++++++++++++-------------------- src/backend/game.h | 2 +- src/backend/generators.h | 54 +++++++++++++++++++------------------- src/backend/globals.cpp | 50 ++++++++++++++++++----------------- src/backend/globals.h | 50 ++++++++++++++++++----------------- src/backend/metadata.cpp | 10 +++---- src/backend/metadata.h | 2 +- src/backend/network.cpp | 10 +++---- src/backend/parsers.h | 36 +++++++++++++------------- src/gui/editor.cpp | 22 ++++++++-------- src/gui/main.cpp | 56 ++++++++++++++++++++-------------------- src/gui/settings.cpp | 50 +++++++++++++++++------------------ 12 files changed, 201 insertions(+), 197 deletions(-) diff --git a/src/backend/game.cpp b/src/backend/game.cpp index 754c8397..ad7c9ac7 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -42,49 +42,49 @@ namespace boss { if (settings["Games"]) games = settings["Games"].as< vector >(); - if (find(games.begin(), games.end(), Game(GAME_TES4)) == games.end()) - games.push_back(Game(GAME_TES4)); + if (find(games.begin(), games.end(), Game(g_game_tes4)) == games.end()) + games.push_back(Game(g_game_tes4)); - if (find(games.begin(), games.end(), Game(GAME_TES5)) == games.end()) - games.push_back(Game(GAME_TES5)); + if (find(games.begin(), games.end(), Game(g_game_tes5)) == games.end()) + games.push_back(Game(g_game_tes5)); - if (find(games.begin(), games.end(), Game(GAME_FO3)) == games.end()) - games.push_back(Game(GAME_FO3)); + if (find(games.begin(), games.end(), Game(g_game_fo3)) == games.end()) + games.push_back(Game(g_game_fo3)); - if (find(games.begin(), games.end(), Game(GAME_FONV)) == games.end()) - games.push_back(Game(GAME_FONV)); + if (find(games.begin(), games.end(), Game(g_game_fonv)) == games.end()) + games.push_back(Game(g_game_fonv)); return games; } - Game::Game() : id(GAME_AUTODETECT) {} + Game::Game() : id(g_game_autodetect) {} Game::Game(const std::string& folder) : bossFolderName(folder) {} Game::Game(const unsigned int gameCode, const std::string& folder) : id(gameCode) { string libespmGame; - if (Id() == GAME_TES4) { + if (Id() == g_game_tes4) { _name = "TES IV: Oblivion"; registryKey = "Software\\Bethesda Softworks\\Oblivion\\Installed Path"; bossFolderName = "Oblivion"; _masterFile = "Oblivion.esm"; libespmGame = "Oblivion"; _masterlistURL = "http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-oblivion/masterlist.yaml"; - } else if (Id() == GAME_TES5) { + } else if (Id() == g_game_tes5) { _name = "TES V: Skyrim"; registryKey = "Software\\Bethesda Softworks\\Skyrim\\Installed Path"; bossFolderName = "Skyrim"; _masterFile = "Skyrim.esm"; libespmGame = "Skyrim"; _masterlistURL = "http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-skyrim/masterlist.yaml"; - } else if (Id() == GAME_FO3) { + } else if (Id() == g_game_fo3) { _name = "Fallout 3"; registryKey = "Software\\Bethesda Softworks\\Fallout3\\Installed Path"; bossFolderName = "Fallout3"; _masterFile = "Fallout3.esm"; libespmGame = "Fallout3"; _masterlistURL = "http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-fallout/masterlist.yaml"; - } else if (Id() == GAME_FONV) { + } else if (Id() == g_game_fonv) { _name = "Fallout: New Vegas"; registryKey = "Software\\Bethesda Softworks\\FalloutNV\\Installed Path"; bossFolderName = "FalloutNV"; @@ -97,8 +97,8 @@ namespace boss { if (!folder.empty()) bossFolderName = folder; - if (fs::exists(libespm_options_path)) - espm_settings = espm::Settings(libespm_options_path.string(), libespmGame); + if (fs::exists(g_path_libespm_settings)) + espm_settings = espm::Settings(g_path_libespm_settings.string(), libespmGame); else throw error(ERROR_PATH_NOT_FOUND, "Libespm settings file could not be found."); } @@ -206,15 +206,15 @@ namespace boss { } fs::path Game::MasterlistPath() const { - return local_path / bossFolderName / "masterlist.yaml"; + return g_path_local / bossFolderName / "masterlist.yaml"; } fs::path Game::UserlistPath() const { - return local_path / bossFolderName / "userlist.yaml"; + return g_path_local / bossFolderName / "userlist.yaml"; } fs::path Game::ReportPath() const { - return local_path / bossFolderName / "report.html"; + return g_path_local / bossFolderName / "report.html"; } void Game::RefreshActivePluginsList() { @@ -222,13 +222,13 @@ namespace boss { char ** pluginArr; size_t pluginArrSize; int ret; - if (Id() == GAME_TES4) + if (Id() == g_game_tes4) ret = lo_create_handle(&gh, LIBLO_GAME_TES4, gamePath.string().c_str()); - else if (Id() == GAME_TES5) + else if (Id() == g_game_tes5) ret = lo_create_handle(&gh, LIBLO_GAME_TES5, gamePath.string().c_str()); - else if (Id() == GAME_FO3) + else if (Id() == g_game_fo3) ret = lo_create_handle(&gh, LIBLO_GAME_FO3, gamePath.string().c_str()); - else if (Id() == GAME_FONV) + else if (Id() == g_game_fonv) ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str()); if (ret != LIBLO_OK) { @@ -273,13 +273,13 @@ namespace boss { size_t pluginArrSize; int ret; - if (Id() == GAME_TES4) + if (Id() == g_game_tes4) ret = lo_create_handle(&gh, LIBLO_GAME_TES4, gamePath.string().c_str()); - else if (Id() == GAME_TES5) + else if (Id() == g_game_tes5) ret = lo_create_handle(&gh, LIBLO_GAME_TES5, gamePath.string().c_str()); - else if (Id() == GAME_FO3) + else if (Id() == g_game_fo3) ret = lo_create_handle(&gh, LIBLO_GAME_FO3, gamePath.string().c_str()); - else if (Id() == GAME_FONV) + else if (Id() == g_game_fonv) ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str()); if (ret != LIBLO_OK) { @@ -329,8 +329,8 @@ namespace boss { void Game::CreateBOSSGameFolder() { //Make sure that the BOSS game path exists. try { - if (!fs::exists(local_path / bossFolderName)) - fs::create_directory(local_path / bossFolderName); + if (!fs::exists(g_path_local / bossFolderName)) + fs::create_directory(g_path_local / bossFolderName); } catch (fs::filesystem_error& e) { throw error(ERROR_PATH_WRITE_FAIL, "Could not create BOSS folder for game."); } diff --git a/src/backend/game.h b/src/backend/game.h index 3198a1c0..174fbd2c 100644 --- a/src/backend/game.h +++ b/src/backend/game.h @@ -42,7 +42,7 @@ namespace boss { class Game { public: - Game(); //Sets game to BOSS_GAME_AUTODETECT, with all other vars being empty. + Game(); //Sets game to BOSS_g_game_autodetect, with all other vars being empty. Game(const std::string& folder); Game(const unsigned int baseGameCode, const std::string& folder = ""); diff --git a/src/backend/generators.h b/src/backend/generators.h index 6aa75b9c..c0975501 100644 --- a/src/backend/generators.h +++ b/src/backend/generators.h @@ -49,11 +49,11 @@ namespace boss { inline void WriteMessage(pugi::xml_node& listItem, unsigned int type, std::string content) { - if (type == MESSAGE_SAY) + if (type == g_message_say) content = "Note: " + content; - else if (type == MESSAGE_TAG) { + else if (type == g_message_tag) { content = "Bash Tag Suggestion(s): " + content; - } else if (type == MESSAGE_WARN) + } else if (type == g_message_warn) content = "Warning: " + content; else content = "Error: " + content; @@ -129,11 +129,11 @@ namespace boss { node = head.append_child(); node.set_name("link"); node.append_attribute("rel").set_value("stylesheet"); - node.append_attribute("href").set_value(ToFileURL(css_path).c_str()); + node.append_attribute("href").set_value(ToFileURL(g_path_css).c_str()); node = head.append_child(); node.set_name("script"); - node.append_attribute("src").set_value(ToFileURL(polyfill_path).c_str()); + node.append_attribute("src").set_value(ToFileURL(g_path_polyfill).c_str()); node.text().set(" "); } @@ -173,11 +173,11 @@ namespace boss { pugi::xml_node li = list.append_child(); li.set_name("li"); - if (it->Type() == MESSAGE_SAY) + if (it->Type() == g_message_say) li.append_attribute("class").set_value("say"); - if (it->Type() == MESSAGE_TAG) + if (it->Type() == g_message_tag) li.append_attribute("class").set_value("tag"); - else if (it->Type() == MESSAGE_WARN) { + else if (it->Type() == g_message_warn) { li.append_attribute("class").set_value("warn"); ++warnNo; } else { @@ -218,7 +218,7 @@ namespace boss { cell.text().set("BOSS Version"); cell = row.append_child(); cell.set_name("td"); - cell.text().set((IntToString(VERSION_MAJOR)+"."+IntToString(VERSION_MINOR)+"."+IntToString(VERSION_PATCH)).c_str()); + cell.text().set((IntToString(g_version_major)+"."+IntToString(g_version_minor)+"."+IntToString(g_version_patch)).c_str()); row = table.append_child(); row.set_name("tr"); @@ -323,7 +323,7 @@ namespace boss { content += "Add " + add.substr(2) + ". "; if (!remove.empty()) content += "Remove " + remove.substr(2) + ". "; - messages.push_back(Message(MESSAGE_TAG, content)); //Special type just for tag suggestions. + messages.push_back(Message(g_message_tag, content)); //Special type just for tag suggestions. } AppendMessages(plugin, messages, warnNo, errorNo); @@ -448,7 +448,7 @@ namespace boss { node = body.append_child(); node.set_name("script"); - node.append_attribute("src").set_value(ToFileURL(js_path).c_str()); + node.append_attribute("src").set_value(ToFileURL(g_path_js).c_str()); node.text().set(" "); } @@ -495,11 +495,11 @@ namespace boss { root["Update Masterlist"] = true; root["View Report Externally"] = false; - games.push_back(Game(GAME_TES4)); - games.push_back(Game(GAME_TES5)); - games.push_back(Game(GAME_FO3)); - games.push_back(Game(GAME_FONV)); - games.push_back(Game(GAME_TES4, "Nehrim").SetDetails("Nehrim - At Fate's Edge", "Nehrim.esm", "http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-nehrim/masterlist.yaml", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1")); + games.push_back(Game(g_game_tes4)); + games.push_back(Game(g_game_tes5)); + games.push_back(Game(g_game_fo3)); + games.push_back(Game(g_game_fonv)); + games.push_back(Game(g_game_tes4, "Nehrim").SetDetails("Nehrim - At Fate's Edge", "Nehrim.esm", "http://better-oblivion-sorting-software.googlecode.com/svn/data/boss-nehrim/masterlist.yaml", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1")); root["Games"] = games; @@ -535,14 +535,14 @@ namespace YAML { << Key << "path" << Value << rhs.GamePath().string() << Key << "registry" << Value << rhs.RegistryKey(); - if (rhs.Id() == boss::GAME_TES4) - out << Key << Value << boss::Game(boss::GAME_TES4).FolderName(); - else if (rhs.Id() == boss::GAME_TES5) - out << Key << Value << boss::Game(boss::GAME_TES5).FolderName(); - else if (rhs.Id() == boss::GAME_FO3) - out << Key << Value << boss::Game(boss::GAME_FO3).FolderName(); - else if (rhs.Id() == boss::GAME_FONV) - out << Key << Value << boss::Game(boss::GAME_FONV).FolderName(); + if (rhs.Id() == boss::g_game_tes4) + out << Key << Value << boss::Game(boss::g_game_tes4).FolderName(); + else if (rhs.Id() == boss::g_game_tes5) + out << Key << Value << boss::Game(boss::g_game_tes5).FolderName(); + else if (rhs.Id() == boss::g_game_fo3) + out << Key << Value << boss::Game(boss::g_game_fo3).FolderName(); + else if (rhs.Id() == boss::g_game_fonv) + out << Key << Value << boss::Game(boss::g_game_fonv).FolderName(); out << EndMap; } @@ -550,7 +550,7 @@ namespace YAML { inline Emitter& operator << (Emitter& out, const boss::MessageContent& rhs) { out << BeginMap; - if (rhs.Language() == boss::LANG_ENG) + if (rhs.Language() == boss::g_lang_english) out << Key << "lang" << Value << "eng"; out << Key << "str" << Value << rhs.Str(); @@ -561,9 +561,9 @@ namespace YAML { inline Emitter& operator << (Emitter& out, const boss::Message& rhs) { out << BeginMap; - if (rhs.Type() == boss::MESSAGE_SAY) + if (rhs.Type() == boss::g_message_say) out << Key << "type" << Value << "say"; - else if (rhs.Type() == boss::MESSAGE_WARN) + else if (rhs.Type() == boss::g_message_warn) out << Key << "type" << Value << "warn"; else out << Key << "type" << Value << "error"; diff --git a/src/backend/globals.cpp b/src/backend/globals.cpp index bb5a1a0e..7b6a2098 100644 --- a/src/backend/globals.cpp +++ b/src/backend/globals.cpp @@ -27,36 +27,38 @@ namespace boss { //Game values. - const unsigned int GAME_AUTODETECT = 0; - const unsigned int GAME_TES4 = 1; - const unsigned int GAME_TES5 = 2; - const unsigned int GAME_FO3 = 3; - const unsigned int GAME_FONV = 4; + const unsigned int g_game_autodetect = 0; + const unsigned int g_game_tes4 = 1; + const unsigned int g_game_tes5 = 2; + const unsigned int g_game_fo3 = 3; + const unsigned int g_game_fonv = 4; //Message types. - const unsigned int MESSAGE_SAY = 0; - const unsigned int MESSAGE_WARN = 1; - const unsigned int MESSAGE_ERROR = 2; - const unsigned int MESSAGE_TAG = 3; + const unsigned int g_message_say = 0; + const unsigned int g_message_warn = 1; + const unsigned int g_message_error = 2; + const unsigned int g_message_tag = 3; //Languages - const unsigned int LANG_AUTO = 0; - const unsigned int LANG_ENG = 1; + const unsigned int g_lang_any = 0; + const unsigned int g_lang_english = 1; + const unsigned int g_lang_spanish = 2; + const unsigned int g_lang_russian = 3; //Version numbers. - const unsigned int VERSION_MAJOR = 3; - const unsigned int VERSION_MINOR = 0; - const unsigned int VERSION_PATCH = 0; + const unsigned int g_version_major = 3; + const unsigned int g_version_minor = 0; + const unsigned int g_version_patch = 0; //Common paths. - const boost::filesystem::path readme_path = "docs/BOSS Readme.html"; - const boost::filesystem::path libespm_options_path = "resources/libespm.yaml"; - const boost::filesystem::path svn_path = "resources/svn/svn.exe"; - const boost::filesystem::path local_path = GetLocalAppDataPath() / "BOSS"; - const boost::filesystem::path css_path = boost::filesystem::current_path() / "resources" / "style.css"; - const boost::filesystem::path js_path = boost::filesystem::current_path() / "resources" / "script.js"; - const boost::filesystem::path polyfill_path = boost::filesystem::current_path() / "resources" / "polyfill.js"; - const boost::filesystem::path settings_path = local_path / "settings.yaml"; - const boost::filesystem::path log_path = local_path / "BOSSDebugLog.txt"; - const boost::filesystem::path l10n_path = "resources/l10n"; + const boost::filesystem::path g_path_readme = "docs/BOSS Readme.html"; + const boost::filesystem::path g_path_libespm_settings = "resources/libespm.yaml"; + const boost::filesystem::path g_path_svn = "resources/svn/svn.exe"; + const boost::filesystem::path g_path_local = GetLocalAppDataPath() / "BOSS"; + const boost::filesystem::path g_path_css = boost::filesystem::current_path() / "resources" / "style.css"; + const boost::filesystem::path g_path_js = boost::filesystem::current_path() / "resources" / "script.js"; + const boost::filesystem::path g_path_polyfill = boost::filesystem::current_path() / "resources" / "polyfill.js"; + const boost::filesystem::path g_path_settings = g_path_local / "settings.yaml"; + const boost::filesystem::path g_path_log = g_path_local / "BOSSDebugLog.txt"; + const boost::filesystem::path g_path_l10n = "resources/l10n"; } diff --git a/src/backend/globals.h b/src/backend/globals.h index 0e6aea32..8f8637e0 100644 --- a/src/backend/globals.h +++ b/src/backend/globals.h @@ -28,38 +28,40 @@ namespace boss { //Game values. - extern const unsigned int GAME_AUTODETECT; - extern const unsigned int GAME_TES4; - extern const unsigned int GAME_TES5; - extern const unsigned int GAME_FO3; - extern const unsigned int GAME_FONV; + extern const unsigned int g_game_autodetect; + extern const unsigned int g_game_tes4; + extern const unsigned int g_game_tes5; + extern const unsigned int g_game_fo3; + extern const unsigned int g_game_fonv; //Message types. - extern const unsigned int MESSAGE_SAY; - extern const unsigned int MESSAGE_WARN; - extern const unsigned int MESSAGE_ERROR; - extern const unsigned int MESSAGE_TAG; + extern const unsigned int g_message_say; + extern const unsigned int g_message_warn; + extern const unsigned int g_message_error; + extern const unsigned int g_message_tag; //Languages - extern const unsigned int LANG_AUTO; - extern const unsigned int LANG_ENG; + extern const unsigned int g_lang_any; + extern const unsigned int g_lang_english; + extern const unsigned int g_lang_spanish; + extern const unsigned int g_lang_russian; //Version numbers. - extern const unsigned int VERSION_MAJOR; - extern const unsigned int VERSION_MINOR; - extern const unsigned int VERSION_PATCH; + extern const unsigned int g_version_major; + extern const unsigned int g_version_minor; + extern const unsigned int g_version_patch; //Common paths. - extern const boost::filesystem::path local_path; - extern const boost::filesystem::path readme_path; - extern const boost::filesystem::path settings_path; - extern const boost::filesystem::path libespm_options_path; - extern const boost::filesystem::path css_path; - extern const boost::filesystem::path js_path; - extern const boost::filesystem::path polyfill_path; - extern const boost::filesystem::path svn_path; - extern const boost::filesystem::path log_path; - extern const boost::filesystem::path l10n_path; + extern const boost::filesystem::path g_path_local; + extern const boost::filesystem::path g_path_readme; + extern const boost::filesystem::path g_path_settings; + extern const boost::filesystem::path g_path_libespm_settings; + extern const boost::filesystem::path g_path_css; + extern const boost::filesystem::path g_path_js; + extern const boost::filesystem::path g_path_polyfill; + extern const boost::filesystem::path g_path_svn; + extern const boost::filesystem::path g_path_log; + extern const boost::filesystem::path g_path_l10n; } #endif diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index 90864ca5..c0e7ed73 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -114,7 +114,7 @@ namespace boss { return eval; } - MessageContent::MessageContent() : _language(LANG_AUTO) {} + MessageContent::MessageContent() : _language(g_lang_any) {} MessageContent::MessageContent(const std::string& str, const unsigned int language) : _str(str), _language(language) {} @@ -154,7 +154,7 @@ namespace boss { bool Message::EvalCondition(boss::Game& game, const unsigned int language) { if (_content.size() > 1) { - if (language == LANG_AUTO) //Can use a message of any language, so use the first string. + if (language == g_lang_any) //Can use a message of any language, so use the first string. _content.resize(1); else { MessageContent english, match; @@ -162,7 +162,7 @@ namespace boss { if (it->Language() == language) { match = *it; break; - } else if (it->Language() == LANG_ENG) + } else if (it->Language() == g_lang_english) english = *it; } _content.resize(1); @@ -176,7 +176,7 @@ namespace boss { } MessageContent Message::ChooseContent(const unsigned int language) const { - if (_content.size() == 1 || language == LANG_AUTO) + if (_content.size() == 1 || language == g_lang_any) return _content[0]; else { MessageContent english, match; @@ -184,7 +184,7 @@ namespace boss { if (it->Language() == language) { match = *it; break; - } else if (it->Language() == LANG_ENG) + } else if (it->Language() == g_lang_english) english = *it; } if (!match.Str().empty()) diff --git a/src/backend/metadata.h b/src/backend/metadata.h index b1dccd14..d514495a 100644 --- a/src/backend/metadata.h +++ b/src/backend/metadata.h @@ -68,7 +68,7 @@ namespace boss { class MessageContent { public: MessageContent(); - MessageContent(const std::string& str, const unsigned int language = LANG_AUTO); + MessageContent(const std::string& str, const unsigned int language = g_lang_any); std::string Str() const; unsigned int Language() const; diff --git a/src/backend/network.cpp b/src/backend/network.cpp index 898dc342..e3f52210 100644 --- a/src/backend/network.cpp +++ b/src/backend/network.cpp @@ -134,7 +134,7 @@ namespace boss { string command, output, revision; //First check if the working copy is set up or not. - command = svn_path.string() + " info \"" + game.MasterlistPath().string() + "\""; + command = g_path_svn.string() + " info \"" + game.MasterlistPath().string() + "\""; revision = GetRevision(output); @@ -147,13 +147,13 @@ namespace boss { if (!RunCommand(command, output)) { //Working copy not set up, perform a checkout. - command = svn_path.string() + " co --depth empty " + game.URL().substr(0, game.URL().rfind('/')) + " \"" + game.MasterlistPath().parent_path().string() + "\\.\""; + command = g_path_svn.string() + " co --depth empty " + game.URL().substr(0, game.URL().rfind('/')) + " \"" + game.MasterlistPath().parent_path().string() + "\\.\""; if (!RunCommand(command, output)) throw error(ERROR_SUBVERSION_ERROR, "Subversion could not perform a checkout. Details: " + output); } //Now update masterlist. - command = svn_path.string() + " update \"" + game.MasterlistPath().string() + "\""; + command = g_path_svn.string() + " update \"" + game.MasterlistPath().string() + "\""; if (!RunCommand(command, output)) throw error(ERROR_SUBVERSION_ERROR, "Subversion could not update the masterlist. Details: " + output); @@ -161,7 +161,7 @@ namespace boss { try { //Now get the masterlist revision. - command = svn_path.string() + " info \"" + game.MasterlistPath().string() + "\""; + command = g_path_svn.string() + " info \"" + game.MasterlistPath().string() + "\""; if (!RunCommand(command, output)) throw error(ERROR_SUBVERSION_ERROR, "Subversion could not read the masterlist revision number. Details: " + output); @@ -174,7 +174,7 @@ namespace boss { } catch (YAML::Exception& e) { //Roll back one revision if there's an error. parsingErrors.push_back("Masterlist revision " + revision + ": " + e.what()); - command = svn_path.string() + " update --revision PREV \"" + game.MasterlistPath().string() + "\""; + command = g_path_svn.string() + " update --revision PREV \"" + game.MasterlistPath().string() + "\""; if (!RunCommand(command, output)) throw error(ERROR_SUBVERSION_ERROR, "Subversion could not update the masterlist. Details: " + output); } diff --git a/src/backend/parsers.h b/src/backend/parsers.h index 743996bd..e991feba 100644 --- a/src/backend/parsers.h +++ b/src/backend/parsers.h @@ -74,14 +74,14 @@ namespace YAML { boss::Game game(node["folder"].as()); - if (node["type"].as() == boss::Game(boss::GAME_TES4).FolderName()) - rhs = boss::Game(boss::GAME_TES4, game.FolderName()); - else if (node["type"].as() == boss::Game(boss::GAME_TES5).FolderName()) - rhs = boss::Game(boss::GAME_TES5, game.FolderName()); - else if (node["type"].as() == boss::Game(boss::GAME_FO3).FolderName()) - rhs = boss::Game(boss::GAME_FO3, game.FolderName()); - else if (node["type"].as() == boss::Game(boss::GAME_FONV).FolderName()) - rhs = boss::Game(boss::GAME_FONV, game.FolderName()); + if (node["type"].as() == boss::Game(boss::g_game_tes4).FolderName()) + rhs = boss::Game(boss::g_game_tes4, game.FolderName()); + else if (node["type"].as() == boss::Game(boss::g_game_tes5).FolderName()) + rhs = boss::Game(boss::g_game_tes5, game.FolderName()); + else if (node["type"].as() == boss::Game(boss::g_game_fo3).FolderName()) + rhs = boss::Game(boss::g_game_fo3, game.FolderName()); + else if (node["type"].as() == boss::Game(boss::g_game_fonv).FolderName()) + rhs = boss::Game(boss::g_game_fonv, game.FolderName()); else return false; @@ -109,9 +109,9 @@ namespace YAML { Node node; node["str"] = rhs.Str(); - if (rhs.Language() == boss::LANG_AUTO) + if (rhs.Language() == boss::g_lang_any) node["lang"] = ""; - else + else if (rhs.Language() == boss::g_lang_english) node["lang"] = "eng"; return node; @@ -126,9 +126,9 @@ namespace YAML { unsigned int langNo; if (boost::iequals(lang, "eng")) - langNo = boss::LANG_ENG; + langNo = boss::g_lang_english; else - langNo = boss::LANG_AUTO; + langNo = boss::g_lang_any; rhs = boss::MessageContent(str, langNo); @@ -143,9 +143,9 @@ namespace YAML { node["condition"] = rhs.Condition(); node["content"] = rhs.Content(); - if (rhs.Type() == boss::MESSAGE_SAY) + if (rhs.Type() == boss::g_message_say) node["type"] = "say"; - else if (rhs.Type() == boss::MESSAGE_WARN) + else if (rhs.Type() == boss::g_message_warn) node["type"] = "warn"; else node["type"] = "error"; @@ -163,11 +163,11 @@ namespace YAML { type = node["type"].as(); if (boost::iequals(type, "say")) - typeNo = boss::MESSAGE_SAY; + typeNo = boss::g_message_say; else if (boost::iequals(type, "warn")) - typeNo = boss::MESSAGE_WARN; + typeNo = boss::g_message_warn; else - typeNo = boss::MESSAGE_ERROR; + typeNo = boss::g_message_error; } std::vector content; @@ -180,7 +180,7 @@ namespace YAML { if (content.size() > 1) { bool found = false; for (std::vector::const_iterator it=content.begin(), endit=content.end(); it != endit; ++it) { - if (it->Language() == boss::LANG_ENG) + if (it->Language() == boss::g_lang_english) found = true; } if (!found) diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index 370bc5e8..523e1f38 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -96,9 +96,9 @@ wxString MessageList::OnGetItemText(long item, long column) const { return wxString(); if (column == 0) { - if (_messages[item].Type() == boss::MESSAGE_SAY) + if (_messages[item].Type() == boss::g_message_say) return Type[0]; - else if (_messages[item].Type() == boss::MESSAGE_WARN) + else if (_messages[item].Type() == boss::g_message_warn) return Type[1]; else return Type[2]; @@ -107,7 +107,7 @@ wxString MessageList::OnGetItemText(long item, long column) const { } else if (column == 2) { return FromUTF8(_messages[item].Condition()); } else { - if (_messages[item].ChooseContent(_language).Language() == boss::LANG_AUTO) + if (_messages[item].ChooseContent(_language).Language() == boss::g_lang_any) return Language[0]; else return Language[1]; @@ -911,9 +911,9 @@ MessageEditDialog::MessageEditDialog(wxWindow *parent, const wxString& title) : void MessageEditDialog::SetMessage(const boss::Message& message) { - if (message.Type() == boss::MESSAGE_SAY) + if (message.Type() == boss::g_message_say) _type->SetSelection(0); - else if (message.Type() == boss::MESSAGE_WARN) + else if (message.Type() == boss::g_message_warn) _type->SetSelection(1); else _type->SetSelection(2); @@ -922,7 +922,7 @@ void MessageEditDialog::SetMessage(const boss::Message& message) { vector contents = message.Content(); for (size_t i=0, max=contents.size(); i < max; ++i) { - if (contents[i].Language() == boss::LANG_AUTO) + if (contents[i].Language() == boss::g_lang_any) _content->InsertItem(i, Language[0]); else _content->InsertItem(i, Language[1]); @@ -936,11 +936,11 @@ boss::Message MessageEditDialog::GetMessage() const { unsigned int type; string condition; if (_type->GetSelection() == 0) - type = boss::MESSAGE_SAY; + type = boss::g_message_say; else if (_type->GetSelection() == 1) - type = boss::MESSAGE_WARN; + type = boss::g_message_warn; else - type = boss::MESSAGE_ERROR; + type = boss::g_message_error; condition = string(_condition->GetValue().ToUTF8()); @@ -950,9 +950,9 @@ boss::Message MessageEditDialog::GetMessage() const { string str = string(_content->GetItemText(i, 1).ToUTF8()); unsigned int lang; if (_content->GetItemText(i, 0) == Language[0]) - lang = boss::LANG_AUTO; + lang = boss::g_lang_any; else - lang = boss::LANG_ENG; + lang = boss::g_lang_english; contents.push_back(boss::MessageContent(str, lang)); } diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 27605279..fbea8d10 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -79,10 +79,10 @@ bool BossGUI::OnInit() { } //Load settings. - if (!fs::exists(settings_path)) { + if (!fs::exists(g_path_settings)) { try { - if (!fs::exists(settings_path.parent_path())) - fs::create_directory(settings_path.parent_path()); + if (!fs::exists(g_path_settings.parent_path())) + fs::create_directory(g_path_settings.parent_path()); } catch (fs::filesystem_error& e) { wxMessageBox( translate("Error: Could not create local app data BOSS folder."), @@ -91,11 +91,11 @@ bool BossGUI::OnInit() { NULL); return false; } - GenerateDefaultSettingsFile(settings_path.string()); + GenerateDefaultSettingsFile(g_path_settings.string()); } - if (fs::exists(settings_path)) { + if (fs::exists(g_path_settings)) { try { - _settings = YAML::LoadFile(settings_path.string()); + _settings = YAML::LoadFile(g_path_settings.string()); } catch (YAML::ParserException& e) { //LOG_ERROR("Error: %s", e.getString().c_str()); wxMessageBox( @@ -109,7 +109,7 @@ bool BossGUI::OnInit() { //Skip logging initialisation for tester. /* if (gl_log_debug_output) - g_logger.setStream(debug_log_path.string().c_str()); + g_logger.setStream(debug_g_path_log.string().c_str()); g_logger.setOriginTracking(gl_debug_with_source); // it's ok if this number is too high. setVerbosity will handle it g_logger.setVerbosity(static_cast(LV_WARN + gl_debug_verbosity)); @@ -135,7 +135,7 @@ bool BossGUI::OnInit() { wxLoc = new wxLocale(); if (!wxLoc->Init(lang, wxLOCALE_LOAD_DEFAULT)) throw runtime_error("System GUI text could not be set."); - wxLocale::AddCatalogLookupPathPrefix(l10n_path.string().c_str()); + wxLocale::AddCatalogLookupPathPrefix(g_path_l10n.string().c_str()); wxLoc->AddCatalog("wxstd"); } catch(runtime_error &e) { // LOG_ERROR("could not implement translation: %s", e.what()); @@ -319,7 +319,7 @@ void Launcher::OnClose(wxCloseEvent& event) { yout.SetIndent(2); yout << _settings; - ofstream out(boss::settings_path.string().c_str()); + ofstream out(boss::g_path_settings.string().c_str()); out << yout.c_str(); out.close(); @@ -337,7 +337,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { time_t t0 = time(NULL); - ofstream out((local_path / "out.txt").string().c_str()); + ofstream out((g_path_local / "out.txt").string().c_str()); out << "Updating masterlist..." << endl; start = time(NULL); @@ -347,10 +347,10 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { try { revision = UpdateMasterlist(_game, parsingErrors); } catch (boss::error& e) { - messages.push_back(boss::Message(boss::MESSAGE_ERROR, string("Masterlist update failed. Details: ") + e.what())); + messages.push_back(boss::Message(boss::g_message_error, string("Masterlist update failed. Details: ") + e.what())); } for (vector::const_iterator it=parsingErrors.begin(), endit=parsingErrors.end(); it != endit; ++it) { - messages.push_back(boss::Message(boss::MESSAGE_ERROR, *it)); + messages.push_back(boss::Message(boss::g_message_error, *it)); } end = time(NULL); @@ -384,7 +384,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { try { mlist = YAML::LoadFile(_game.MasterlistPath().string()); } catch (YAML::ParserException& e) { - messages.push_back(boss::Message(boss::MESSAGE_ERROR, string("Masterlist parsing failed. Details: ") + e.what())); + messages.push_back(boss::Message(boss::g_message_error, string("Masterlist parsing failed. Details: ") + e.what())); } if (mlist["globals"]) mlist_messages = mlist["globals"].as< list >(); @@ -402,7 +402,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { try { ulist = YAML::LoadFile(_game.UserlistPath().string()); } catch (YAML::ParserException& e) { - messages.push_back(boss::Message(boss::MESSAGE_ERROR, string("Userlist parsing failed. Details: ") + e.what())); + messages.push_back(boss::Message(boss::g_message_error, string("Userlist parsing failed. Details: ") + e.what())); } if (ulist["plugins"]) ulist_plugins = ulist["plugins"].as< list >(); @@ -423,9 +423,9 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { messages.insert(messages.end(), ulist_messages.begin(), ulist_messages.end()); //Set language. - unsigned int lang = boss::LANG_AUTO; + unsigned int lang = boss::g_lang_any; if (_settings["Language"].as() == "eng") - lang = boss::LANG_ENG; + lang = boss::g_lang_english; //Merge plugin list, masterlist and userlist plugin data. map consistencyIssues; @@ -447,7 +447,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { try { it->EvalAllConditions(_game, lang); } catch (boss::error& e) { - messages.push_back(boss::Message(boss::MESSAGE_ERROR, "\"" + it->Name() + "\" contains a condition that could not be evaluated. Details: " + e.what())); + messages.push_back(boss::Message(boss::g_message_error, "\"" + it->Name() + "\" contains a condition that could not be evaluated. Details: " + e.what())); } progDia->Pulse(); @@ -463,9 +463,9 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { list pluginMessages = it->Messages(); for (map::const_iterator jt=issues.begin(), endJt=issues.end(); jt != endJt; ++jt) { if (jt->second) - pluginMessages.push_back(boss::Message(boss::MESSAGE_ERROR, "\"" + jt->first + "\" is incompatible with \"" + it->Name() + "\" and is present.")); + pluginMessages.push_back(boss::Message(boss::g_message_error, "\"" + jt->first + "\" is incompatible with \"" + it->Name() + "\" and is present.")); else - pluginMessages.push_back(boss::Message(boss::MESSAGE_ERROR, "\"" + jt->first + "\" is required by \"" + it->Name() + "\" but is missing.")); + pluginMessages.push_back(boss::Message(boss::g_message_error, "\"" + jt->first + "\" is required by \"" + it->Name() + "\" but is missing.")); } if (!issues.empty()) it->Messages(pluginMessages); @@ -475,10 +475,10 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { for (map::const_iterator jt=consistencyIssues.begin(), endJt=consistencyIssues.end(); jt != endJt; ++jt) { if (jt->second) { - messages.push_back(boss::Message(boss::MESSAGE_ERROR, "\"" + jt->first + "\" is a circular dependency. Plugins will not be sorted.")); + messages.push_back(boss::Message(boss::g_message_error, "\"" + jt->first + "\" is a circular dependency. Plugins will not be sorted.")); cyclicDependenciesExist = true; } else - messages.push_back(boss::Message(boss::MESSAGE_ERROR, "\"" + jt->first + "\" is given as a dependency and an incompatibility.")); + messages.push_back(boss::Message(boss::g_message_error, "\"" + jt->first + "\" is given as a dependency and an incompatibility.")); } end = time(NULL); @@ -588,7 +588,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { //Now set load order. _game.SetLoadOrder(plugins); } else - messages.push_back(boss::Message(boss::MESSAGE_WARN, "The load order displayed in the Details tab was not applied as sorting was canceled.")); + messages.push_back(boss::Message(boss::g_message_warn, "The load order displayed in the Details tab was not applied as sorting was canceled.")); cyclicDependenciesExist = true; out << "Set load order:" << endl; @@ -736,9 +736,9 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { progDia->Pulse(); - unsigned int lang = boss::LANG_AUTO; + unsigned int lang = boss::g_lang_any; if (_settings["Language"].as() == "eng") - lang = boss::LANG_ENG; + lang = boss::g_lang_english; //Create editor window. Editor *editor = new Editor(this, translate("BOSS: Metadata Editor"), _game.UserlistPath().string(), installed, ulist_plugins, lang); @@ -780,11 +780,11 @@ void Launcher::OnGameChange(wxCommandEvent& event) { void Launcher::OnHelp(wxCommandEvent& event) { //Look for file. - if (fs::exists(readme_path.string())) { - wxLaunchDefaultApplication(readme_path.string()); + if (fs::exists(g_path_readme.string())) { + wxLaunchDefaultApplication(g_path_readme.string()); } else //No ReadMe exists, show a pop-up message saying so. wxMessageBox( - FromUTF8(format(loc::translate("Error: \"%1%\" cannot be found.")) % readme_path.string()), + FromUTF8(format(loc::translate("Error: \"%1%\" cannot be found.")) % g_path_readme.string()), translate("BOSS: Error"), wxOK | wxICON_ERROR, this); @@ -793,7 +793,7 @@ void Launcher::OnHelp(wxCommandEvent& event) { void Launcher::OnAbout(wxCommandEvent& event) { wxAboutDialogInfo aboutInfo; aboutInfo.SetName("BOSS"); - aboutInfo.SetVersion(IntToString(VERSION_MAJOR)+"."+IntToString(VERSION_MINOR)+"."+IntToString(VERSION_PATCH)); + aboutInfo.SetVersion(IntToString(g_version_major)+"."+IntToString(g_version_minor)+"."+IntToString(g_version_patch)); aboutInfo.SetDescription(translate( "A utility that optimises TES IV: Oblivion, Nehrim - At Fate's Edge,\nTES V: Skyrim, Fallout 3 and Fallout: New Vegas mod load orders.")); aboutInfo.SetCopyright("Copyright (C) 2009-2013 BOSS Development Team."); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 809927d8..5a7dbed5 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -225,14 +225,14 @@ void SettingsFrame::OnQuit(wxCommandEvent& event) { path = gamesList->GetItemText(i, 5).ToUTF8(); registry = gamesList->GetItemText(i, 6).ToUTF8(); - if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::GAME_TES4).FolderName()) - id = boss::GAME_TES4; - else if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::GAME_TES5).FolderName()) - id = boss::GAME_TES5; - else if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::GAME_FO3).FolderName()) - id = boss::GAME_FO3; + if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::g_game_tes4).FolderName()) + id = boss::g_game_tes4; + else if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::g_game_tes5).FolderName()) + id = boss::g_game_tes5; + else if (gamesList->GetItemText(i, 1).ToUTF8() == boss::Game(boss::g_game_fo3).FolderName()) + id = boss::g_game_fo3; else - id = boss::GAME_FONV; + id = boss::g_game_fonv; _games[i] = boss::Game(id, folder).SetDetails(name, master, url, path, registry); } @@ -243,10 +243,10 @@ void SettingsFrame::OnQuit(wxCommandEvent& event) { void SettingsFrame::OnGameSelect(wxListEvent& event) { wxString name = gamesList->GetItemText(event.GetIndex()); - if (name == boss::Game(boss::GAME_TES4).Name() - || name == boss::Game(boss::GAME_TES5).Name() - || name == boss::Game(boss::GAME_FO3).Name() - || name == boss::Game(boss::GAME_FONV).Name()) { + if (name == boss::Game(boss::g_game_tes4).Name() + || name == boss::Game(boss::g_game_tes5).Name() + || name == boss::Game(boss::g_game_fo3).Name() + || name == boss::Game(boss::g_game_fonv).Name()) { removeBtn->Enable(false); } else { removeBtn->Enable(true); @@ -311,14 +311,14 @@ void SettingsFrame::OnEditGame(wxCommandEvent& event) { long i = gamesList->GetFirstSelected(); int stateNo; - if (gamesList->GetItemText(i, 1) == boss::Game(boss::GAME_TES4).FolderName()) - stateNo = boss::GAME_TES4; - else if (gamesList->GetItemText(i, 1) == boss::Game(boss::GAME_TES5).FolderName()) - stateNo = boss::GAME_TES5; - else if (gamesList->GetItemText(i, 1) == boss::Game(boss::GAME_FO3).FolderName()) - stateNo = boss::GAME_FO3; + if (gamesList->GetItemText(i, 1) == boss::Game(boss::g_game_tes4).FolderName()) + stateNo = boss::g_game_tes4; + else if (gamesList->GetItemText(i, 1) == boss::Game(boss::g_game_tes5).FolderName()) + stateNo = boss::g_game_tes5; + else if (gamesList->GetItemText(i, 1) == boss::Game(boss::g_game_fo3).FolderName()) + stateNo = boss::g_game_fo3; else - stateNo = boss::GAME_FONV; + stateNo = boss::g_game_fonv; rowDialog->SetValues(stateNo, gamesList->GetItemText(i, 0), gamesList->GetItemText(i, 2), gamesList->GetItemText(i, 3), gamesList->GetItemText(i, 4), gamesList->GetItemText(i, 5), gamesList->GetItemText(i, 6)); @@ -360,10 +360,10 @@ void SettingsFrame::OnRemoveGame(wxCommandEvent& event) { GameEditDialog::GameEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) { wxString Types[] = { - FromUTF8(boss::Game(boss::GAME_TES4).FolderName()), - FromUTF8(boss::Game(boss::GAME_TES5).FolderName()), - FromUTF8(boss::Game(boss::GAME_FO3).FolderName()), - FromUTF8(boss::Game(boss::GAME_FONV).FolderName()) + FromUTF8(boss::Game(boss::g_game_tes4).FolderName()), + FromUTF8(boss::Game(boss::g_game_tes5).FolderName()), + FromUTF8(boss::Game(boss::g_game_fo3).FolderName()), + FromUTF8(boss::Game(boss::g_game_fonv).FolderName()) }; //Initialise controls. @@ -429,11 +429,11 @@ GameEditDialog::GameEditDialog(wxWindow *parent, const wxString& title) : wxDial void GameEditDialog::SetValues(unsigned int type, const wxString& name, const wxString& folderName, const wxString& master, const wxString& url, const wxString& path, const wxString& registry) { - if (type == boss::GAME_TES4) + if (type == boss::g_game_tes4) _type->SetSelection(0); - else if (type == boss::GAME_TES5) + else if (type == boss::g_game_tes5) _type->SetSelection(1); - else if (type == boss::GAME_FO3) + else if (type == boss::g_game_fo3) _type->SetSelection(2); else _type->SetSelection(3);