diff --git a/src/api/api.cpp b/src/api/api.cpp index b2fefe08..130cd91e 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -46,62 +46,62 @@ #include #include -const unsigned int boss_ok = boss::error::ok; -const unsigned int boss_error_liblo_error = boss::error::liblo_error; -const unsigned int boss_error_file_write_fail = boss::error::path_write_fail; -const unsigned int boss_error_parse_fail = boss::error::path_read_fail; -const unsigned int boss_error_condition_eval_fail = boss::error::condition_eval_fail; -const unsigned int boss_error_regex_eval_fail = boss::error::regex_eval_fail; -const unsigned int boss_error_no_mem = boss::error::no_mem; -const unsigned int boss_error_invalid_args = boss::error::invalid_args; -const unsigned int boss_error_no_tag_map = boss::error::no_tag_map; -const unsigned int boss_error_path_not_found = boss::error::path_not_found; -const unsigned int boss_error_no_game_detected = boss::error::no_game_detected; -const unsigned int boss_error_windows_error = boss::error::windows_error; -const unsigned int boss_error_sorting_error = boss::error::sorting_error; -const unsigned int boss_return_max = boss_error_sorting_error; +const unsigned int loot_ok = loot::error::ok; +const unsigned int loot_error_liblo_error = loot::error::liblo_error; +const unsigned int loot_error_file_write_fail = loot::error::path_write_fail; +const unsigned int loot_error_parse_fail = loot::error::path_read_fail; +const unsigned int loot_error_condition_eval_fail = loot::error::condition_eval_fail; +const unsigned int loot_error_regex_eval_fail = loot::error::regex_eval_fail; +const unsigned int loot_error_no_mem = loot::error::no_mem; +const unsigned int loot_error_invalid_args = loot::error::invalid_args; +const unsigned int loot_error_no_tag_map = loot::error::no_tag_map; +const unsigned int loot_error_path_not_found = loot::error::path_not_found; +const unsigned int loot_error_no_game_detected = loot::error::no_game_detected; +const unsigned int loot_error_windows_error = loot::error::windows_error; +const unsigned int loot_error_sorting_error = loot::error::sorting_error; +const unsigned int loot_return_max = loot_error_sorting_error; // The following are the games identifiers used by the API. -const unsigned int boss_game_tes4 = boss::g_game_tes4; -const unsigned int boss_game_tes5 = boss::g_game_tes5; -const unsigned int boss_game_fo3 = boss::g_game_fo3; -const unsigned int boss_game_fonv = boss::g_game_fonv; +const unsigned int loot_game_tes4 = loot::g_game_tes4; +const unsigned int loot_game_tes5 = loot::g_game_tes5; +const unsigned int loot_game_fo3 = loot::g_game_fo3; +const unsigned int loot_game_fonv = loot::g_game_fonv; // LOOT message types. -const unsigned int boss_message_say = boss::g_message_say; -const unsigned int boss_message_warn = boss::g_message_warn; -const unsigned int boss_message_error = boss::g_message_error; -const unsigned int boss_message_tag = boss::g_message_tag; +const unsigned int loot_message_say = loot::g_message_say; +const unsigned int loot_message_warn = loot::g_message_warn; +const unsigned int loot_message_error = loot::g_message_error; +const unsigned int loot_message_tag = loot::g_message_tag; // LOOT message languages. -const unsigned int boss_lang_any = boss::g_lang_any; -const unsigned int boss_lang_english = boss::g_lang_english; -const unsigned int boss_lang_spanish = boss::g_lang_spanish; -const unsigned int boss_lang_russian = boss::g_lang_russian; -const unsigned int boss_lang_french = boss::g_lang_french; -const unsigned int boss_lang_chinese = boss::g_lang_chinese; -const unsigned int boss_lang_polish = boss::g_lang_polish; -const unsigned int boss_lang_brazilian_portuguese = boss::g_lang_brazilian_portuguese; +const unsigned int loot_lang_any = loot::g_lang_any; +const unsigned int loot_lang_english = loot::g_lang_english; +const unsigned int loot_lang_spanish = loot::g_lang_spanish; +const unsigned int loot_lang_russian = loot::g_lang_russian; +const unsigned int loot_lang_french = loot::g_lang_french; +const unsigned int loot_lang_chinese = loot::g_lang_chinese; +const unsigned int loot_lang_polish = loot::g_lang_polish; +const unsigned int loot_lang_brazilian_portuguese = loot::g_lang_brazilian_portuguese; // LOOT cleanliness codes. -const unsigned int boss_needs_cleaning_no = 0; -const unsigned int boss_needs_cleaning_yes = 1; -const unsigned int boss_needs_cleaning_unknown = 2; +const unsigned int loot_needs_cleaning_no = 0; +const unsigned int loot_needs_cleaning_yes = 1; +const unsigned int loot_needs_cleaning_unknown = 2; -struct _boss_db_int { - _boss_db_int() +struct _loot_db_int { + _loot_db_int() : extTagMap(NULL), extAddedTagIds(NULL), extRemovedTagIds(NULL), extMessageArray(NULL), extMessageArraySize(0) { - extMessage.type = boss_message_say; + extMessage.type = loot_message_say; extMessage.message = NULL; } - ~_boss_db_int() { + ~_loot_db_int() { delete [] extAddedTagIds; delete [] extRemovedTagIds; delete [] extMessage.message; @@ -119,8 +119,8 @@ struct _boss_db_int { } } - boss::Game game; - std::list metadata, rawMetadata, userMetadata, rawUserMetadata; + loot::Game game; + std::list metadata, rawMetadata, userMetadata, rawUserMetadata; boost::unordered_map bashTagMap; @@ -129,8 +129,8 @@ struct _boss_db_int { unsigned int * extAddedTagIds; unsigned int * extRemovedTagIds; - boss_message extMessage; - boss_message * extMessageArray; + loot_message extMessage; + loot_message * extMessageArray; size_t extMessageArraySize; }; @@ -142,7 +142,7 @@ char * ToNewCString(std::string str) { return strcpy(p, str.c_str()); } -unsigned int c_error(const boss::error& e) { +unsigned int c_error(const loot::error& e) { delete[] extMessageStr; try { extMessageStr = new char[strlen(e.what()) + 1]; @@ -155,7 +155,7 @@ unsigned int c_error(const boss::error& e) { } unsigned int c_error(const unsigned int code, const std::string& what) { - return c_error(boss::error(code, what.c_str())); + return c_error(loot::error(code, what.c_str())); } @@ -166,17 +166,17 @@ unsigned int c_error(const unsigned int code, const std::string& what) { // Outputs a string giving the details of the last time an error or // warning return code was returned by a function. The string exists // until this function is called again or until CleanUpAPI is called. -LOOT_API unsigned int boss_get_error_message (const char ** const message) { +LOOT_API unsigned int loot_get_error_message (const char ** const message) { if (message == NULL) - return c_error(boss_error_invalid_args, "Null message pointer passed."); + return c_error(loot_error_invalid_args, "Null message pointer passed."); *message = extMessageStr; - return boss_ok; + return loot_ok; } // Frees memory allocated to error string. -LOOT_API void boss_cleanup () { +LOOT_API void loot_cleanup () { delete [] extMessageStr; extMessageStr = NULL; } @@ -188,22 +188,22 @@ LOOT_API void boss_cleanup () { // Returns whether this version of LOOT supports the API from the given // LOOT version. Abstracts LOOT API stability policy away from clients. -LOOT_API bool boss_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch) { - return versionMajor == boss::g_version_major && versionMinor == boss::g_version_minor; +LOOT_API bool loot_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch) { + return versionMajor == loot::g_version_major && versionMinor == loot::g_version_minor; } // Returns the version string for this version of LOOT. // The string exists until this function is called again or until // CleanUpAPI is called. -LOOT_API unsigned int boss_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch) { +LOOT_API unsigned int loot_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch) { if (versionMajor == NULL || versionMinor == NULL || versionPatch == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + return c_error(loot_error_invalid_args, "Null pointer passed."); - *versionMajor = boss::g_version_major; - *versionMinor = boss::g_version_minor; - *versionPatch = boss::g_version_patch; + *versionMajor = loot::g_version_major; + *versionMinor = loot::g_version_minor; + *versionPatch = loot::g_version_patch; - return boss_ok; + return loot_ok; } @@ -218,9 +218,9 @@ LOOT_API unsigned int boss_get_version (unsigned int * const versionMajor, unsig // plugins.txt and loadorder.txt (if they both exist) are in sync. If // dataPath == NULL then the API will attempt to detect the data path of // the specified game. -LOOT_API unsigned int boss_create_db (boss_db * const db, const unsigned int clientGame, const char * const gamePath) { - if (db == NULL || (clientGame != boss_game_tes4 && clientGame != boss_game_tes5 && clientGame != boss_game_fo3 && clientGame != boss_game_fonv)) - return c_error(boss_error_invalid_args, "Null pointer passed."); +LOOT_API unsigned int loot_create_db (loot_db * const db, const unsigned int clientGame, const char * const gamePath) { + if (db == NULL || (clientGame != loot_game_tes4 && clientGame != loot_game_tes5 && clientGame != loot_game_fo3 && clientGame != loot_game_fonv)) + return c_error(loot_error_invalid_args, "Null pointer passed."); //Set the locale to get encoding conversions working correctly. std::setlocale(LC_CTYPE, ""); @@ -235,27 +235,27 @@ LOOT_API unsigned int boss_create_db (boss_db * const db, const unsigned int cli if (gamePath != NULL) game_path = gamePath; - boss::Game game; + loot::Game game; try { - game = boss::Game(clientGame).SetPath(game_path).Init(); //This also checks to see if the game is installed if game_path is empty and throws an exception if it is not detected. It also creates a folder in %LOCALAPPDATA% and reads the active plugins list, but that shouldn't be an issue. - } catch (boss::error& e) { + game = loot::Game(clientGame).SetPath(game_path).Init(); //This also checks to see if the game is installed if game_path is empty and throws an exception if it is not detected. It also creates a folder in %LOCALAPPDATA% and reads the active plugins list, but that shouldn't be an issue. + } catch (loot::error& e) { return c_error(e); } - boss_db retVal; + loot_db retVal; try { - retVal = new _boss_db_int; + retVal = new _loot_db_int; } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } retVal->game = game; *db = retVal; - return boss_ok; + return loot_ok; } // Destroys the given DB, freeing any memory allocated as part of its use. -LOOT_API void boss_destroy_db (boss_db db) { +LOOT_API void loot_destroy_db (loot_db db) { delete db; } @@ -268,45 +268,45 @@ LOOT_API void boss_destroy_db (boss_db db) { // Can be called multiple times. On error, the database is unchanged. // Paths are case-sensitive if the underlying filesystem is case-sensitive. // masterlistPath and userlistPath are files. -LOOT_API unsigned int boss_load_lists (boss_db db, const char * const masterlistPath, +LOOT_API unsigned int loot_load_lists (loot_db db, const char * const masterlistPath, const char * const userlistPath) { if (db == NULL || masterlistPath == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + return c_error(loot_error_invalid_args, "Null pointer passed."); - std::list temp; - std::list userTemp; + std::list temp; + std::list userTemp; try { if (boost::filesystem::exists(masterlistPath)) { if (boost::algorithm::iends_with(masterlistPath, ".yaml")) { - boss::ifstream in(masterlistPath); + loot::ifstream in(masterlistPath); YAML::Node tempNode = YAML::Load(in); in.close(); - temp = tempNode["plugins"].as< std::list >(); + temp = tempNode["plugins"].as< std::list >(); } else { boost::filesystem::path p(masterlistPath); - std::list filler; + std::list filler; Loadv2Masterlist(p, temp, filler); } } } catch (std::exception& e) { - return c_error(boss_error_parse_fail, e.what()); + return c_error(loot_error_parse_fail, e.what()); } try { if (userlistPath != NULL) { if (boost::filesystem::exists(userlistPath)) { if (boost::algorithm::iends_with(userlistPath, ".yaml")) { - boss::ifstream in(userlistPath); + loot::ifstream in(userlistPath); YAML::Node tempNode = YAML::Load(in); in.close(); - userTemp = tempNode["plugins"].as< std::list >(); + userTemp = tempNode["plugins"].as< std::list >(); } } } } catch (YAML::Exception& e) { - return c_error(boss_error_parse_fail, e.what()); + return c_error(loot_error_parse_fail, e.what()); } //Also free memory. @@ -336,7 +336,7 @@ LOOT_API unsigned int boss_load_lists (boss_db db, const char * const masterlist db->userMetadata = userTemp; db->rawUserMetadata = userTemp; - return boss_ok; + return loot_ok; } // Evaluates all conditional lines and regex mods the loaded masterlist. @@ -345,27 +345,27 @@ LOOT_API unsigned int boss_load_lists (boss_db db, const char * const masterlist // is called. Repeated calls re-evaluate the masterlist from scratch each time, // ignoring the results of any previous evaluations. Paths are case-sensitive // if the underlying filesystem is case-sensitive. -LOOT_API unsigned int boss_eval_lists (boss_db db, const unsigned int language) { +LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) { if (db == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + return c_error(loot_error_invalid_args, "Null pointer passed."); - std::list temp = db->rawMetadata; + std::list temp = db->rawMetadata; try { db->game.RefreshActivePluginsList(); - for (std::list::iterator it=temp.begin(); it != temp.end();) { + for (std::list::iterator it=temp.begin(); it != temp.end();) { it->EvalAllConditions(db->game, language); if (it->IsRegexPlugin()) { boost::regex regex; try { regex = boost::regex(it->Name(), boost::regex::perl|boost::regex::icase); } catch (boost::regex_error& e) { - return c_error(boss_error_regex_eval_fail, e.what()); + return c_error(loot_error_regex_eval_fail, e.what()); } for (boost::filesystem::directory_iterator itr(db->game.DataPath()); itr != boost::filesystem::directory_iterator(); ++itr) { const std::string filename = itr->path().filename().string(); if (boost::regex_match(filename, regex)) { - boss::Plugin p = *it; + loot::Plugin p = *it; p.Name(filename); temp.push_back(p); } @@ -375,27 +375,27 @@ LOOT_API unsigned int boss_eval_lists (boss_db db, const unsigned int language) ++it; } } - } catch (boss::error& e) { + } catch (loot::error& e) { return c_error(e); } db->metadata = temp; temp = db->rawUserMetadata; try { - for (std::list::iterator it=temp.begin(); it != temp.end();) { + for (std::list::iterator it=temp.begin(); it != temp.end();) { it->EvalAllConditions(db->game, language); if (it->IsRegexPlugin()) { boost::regex regex; try { regex = boost::regex(it->Name(), boost::regex::perl|boost::regex::icase); } catch (boost::regex_error& e) { - return c_error(boss_error_regex_eval_fail, e.what()); + return c_error(loot_error_regex_eval_fail, e.what()); } for (boost::filesystem::directory_iterator itr(db->game.DataPath()); itr != boost::filesystem::directory_iterator(); ++itr) { const std::string filename = itr->path().filename().string(); if (boost::regex_match(filename, regex)) { - boss::Plugin p = *it; + loot::Plugin p = *it; p.Name(filename); temp.push_back(p); } @@ -405,12 +405,12 @@ LOOT_API unsigned int boss_eval_lists (boss_db db, const unsigned int language) ++it; } } - } catch (boss::error& e) { + } catch (loot::error& e) { return c_error(e); } db->userMetadata = temp; - return boss_ok; + return loot_ok; } @@ -421,9 +421,9 @@ LOOT_API unsigned int boss_eval_lists (boss_db db, const unsigned int language) // Returns an array of the Bash Tags encounterred when loading the masterlist // and userlist, and the number of tags in the returned array. The array and // its contents are static and should not be freed by the client. -LOOT_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_t * const numTags) { +LOOT_API unsigned int loot_get_tag_map (loot_db db, char *** const tagMap, size_t * const numTags) { if (db == NULL || tagMap == NULL || numTags == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + return c_error(loot_error_invalid_args, "Null pointer passed."); //Clear existing array allocation. if (db->extTagMap != NULL) { @@ -440,26 +440,26 @@ LOOT_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_ boost::unordered_set allTags; - for (std::list::iterator it=db->metadata.begin(), endIt=db->metadata.end(); it != endIt; ++it) { - std::set tags = it->Tags(); - for (std::set::const_iterator jt=tags.begin(), endJt=tags.end(); jt != endJt; ++jt) { + for (std::list::iterator it=db->metadata.begin(), endIt=db->metadata.end(); it != endIt; ++it) { + std::set tags = it->Tags(); + for (std::set::const_iterator jt=tags.begin(), endJt=tags.end(); jt != endJt; ++jt) { allTags.insert(jt->Name()); } } - for (std::list::iterator it=db->userMetadata.begin(), endIt=db->userMetadata.end(); it != endIt; ++it) { - std::set tags = it->Tags(); - for (std::set::const_iterator jt=tags.begin(), endJt=tags.end(); jt != endJt; ++jt) { + for (std::list::iterator it=db->userMetadata.begin(), endIt=db->userMetadata.end(); it != endIt; ++it) { + std::set tags = it->Tags(); + for (std::set::const_iterator jt=tags.begin(), endJt=tags.end(); jt != endJt; ++jt) { allTags.insert(jt->Name()); } } if (allTags.empty()) - return boss_ok; + return loot_ok; try { db->extTagMap = new char*[allTags.size()]; } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } unsigned int UID = 0; @@ -471,13 +471,13 @@ LOOT_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_ UID++; } } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } *tagMap = db->extTagMap; *numTags = allTags.size(); - return boss_ok; + return loot_ok; } // Returns arrays of Bash Tag UIDs for Bash Tags suggested for addition and removal @@ -487,14 +487,14 @@ LOOT_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_ // case-insensitive. If no Tags are found for an array, the array pointer (*tagIds) // will be NULL. The userlistModified bool is true if the userlist contains Bash Tag // suggestion message additions. -LOOT_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugin, +LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugin, unsigned int ** const tagIds_added, size_t * const numTags_added, unsigned int ** const tagIds_removed, size_t * const numTags_removed, bool * const userlistModified) { if (db == NULL || plugin == NULL || tagIds_added == NULL || numTags_added == NULL || tagIds_removed == NULL || numTags_removed == NULL || userlistModified == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + return c_error(loot_error_invalid_args, "Null pointer passed."); //Clear existing array allocations. @@ -511,10 +511,10 @@ LOOT_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi *numTags_removed = 0; boost::unordered_set tagsAdded, tagsRemoved; - std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), boss::Plugin(plugin)); + std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), loot::Plugin(plugin)); if (pluginIt != db->metadata.end()) { - std::set tags = pluginIt->Tags(); - for (std::set::const_iterator it=tags.begin(), endIt=tags.end(); it != endIt; ++it) { + std::set tags = pluginIt->Tags(); + for (std::set::const_iterator it=tags.begin(), endIt=tags.end(); it != endIt; ++it) { if (it->IsAddition()) tagsAdded.insert(it->Name()); else @@ -522,11 +522,11 @@ LOOT_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi } } - pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), boss::Plugin(plugin)); + pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), loot::Plugin(plugin)); if (pluginIt != db->userMetadata.end()) { *userlistModified = true; - std::set tags = pluginIt->Tags(); - for (std::set::const_iterator it = tags.begin(), endIt = tags.end(); it != endIt; ++it) { + std::set tags = pluginIt->Tags(); + for (std::set::const_iterator it = tags.begin(), endIt = tags.end(); it != endIt; ++it) { if (it->IsAddition()) tagsAdded.insert(it->Name()); else @@ -536,7 +536,7 @@ LOOT_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi } if ((!tagsAdded.empty() || !tagsRemoved.empty()) && db->bashTagMap.empty()) { - return c_error(boss_error_no_tag_map, "No Bash Tag map has been previously generated."); + return c_error(loot_error_no_tag_map, "No Bash Tag map has been previously generated."); } std::vector tagsAddedIDs, tagsRemovedIDs; @@ -566,7 +566,7 @@ LOOT_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi db->extRemovedTagIds[i] = tagsRemovedIDs[i]; } } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } //Set outputs. @@ -575,17 +575,17 @@ LOOT_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi *numTags_added = numAdded; *numTags_removed = numRemoved; - return boss_ok; + return loot_ok; } // Returns the messages attached to the given plugin. Messages are valid until Load, // DestroyBossDb or GetPluginMessages are next called. plugin is case-insensitive. // If no messages are attached, *messages will be NULL and numMessages will equal 0. -LOOT_API unsigned int boss_get_plugin_messages (boss_db db, const char * const plugin, - boss_message ** const messages, +LOOT_API unsigned int loot_get_plugin_messages (loot_db db, const char * const plugin, + loot_message ** const messages, size_t * const numMessages) { if (db == NULL || plugin == NULL || messages == NULL || numMessages == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + return c_error(loot_error_invalid_args, "Null pointer passed."); //Clear existing array allocation. if (db->extMessageArray != NULL) { @@ -600,59 +600,59 @@ LOOT_API unsigned int boss_get_plugin_messages (boss_db db, const char * const p *messages = NULL; *numMessages = 0; - std::list pluginMessages; - std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), boss::Plugin(plugin)); + std::list pluginMessages; + std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), loot::Plugin(plugin)); if (pluginIt != db->metadata.end()) { pluginMessages = pluginIt->Messages(); } - pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), boss::Plugin(plugin)); + pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), loot::Plugin(plugin)); if (pluginIt != db->userMetadata.end()) { - std::list temp = pluginIt->Messages(); + std::list temp = pluginIt->Messages(); pluginMessages.insert(pluginMessages.end(), temp.begin(), temp.end()); } db->extMessageArraySize = pluginMessages.size(); try { - db->extMessageArray = new boss_message[db->extMessageArraySize]; + db->extMessageArray = new loot_message[db->extMessageArraySize]; int i = 0; - for (std::list::const_iterator it=pluginMessages.begin(), endIt=pluginMessages.end(); it != endIt; ++it) { + for (std::list::const_iterator it=pluginMessages.begin(), endIt=pluginMessages.end(); it != endIt; ++it) { db->extMessageArray[i].type = it->Type(); - db->extMessageArray[i].message = ToNewCString(it->ChooseContent(boss::g_lang_any).Str()); + db->extMessageArray[i].message = ToNewCString(it->ChooseContent(loot::g_lang_any).Str()); } } catch (std::bad_alloc& e) { - return c_error(boss_error_no_mem, e.what()); + return c_error(loot_error_no_mem, e.what()); } *messages = db->extMessageArray; *numMessages = db->extMessageArraySize; - return boss_ok; + return loot_ok; } -LOOT_API unsigned int boss_get_dirty_info(boss_db db, const char * const plugin, unsigned int * const needsCleaning) { +LOOT_API unsigned int loot_get_dirty_info(loot_db db, const char * const plugin, unsigned int * const needsCleaning) { if (db == NULL || plugin == NULL || needsCleaning == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + return c_error(loot_error_invalid_args, "Null pointer passed."); - *needsCleaning = boss_needs_cleaning_unknown; + *needsCleaning = loot_needs_cleaning_unknown; //Get all dirty info. - std::set dirtyInfo; - std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), boss::Plugin(plugin)); + std::set dirtyInfo; + std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), loot::Plugin(plugin)); if (pluginIt != db->metadata.end()) { dirtyInfo = pluginIt->DirtyInfo(); } - pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), boss::Plugin(plugin)); + pluginIt = std::find(db->userMetadata.begin(), db->userMetadata.end(), loot::Plugin(plugin)); if (pluginIt != db->userMetadata.end()) { - std::set temp = pluginIt->DirtyInfo(); + std::set temp = pluginIt->DirtyInfo(); dirtyInfo.insert(temp.begin(), temp.end()); } if (!dirtyInfo.empty()) { - *needsCleaning = boss_needs_cleaning_yes; + *needsCleaning = loot_needs_cleaning_yes; } - return boss_ok; + return loot_ok; } @@ -660,16 +660,16 @@ LOOT_API unsigned int boss_get_dirty_info(boss_db db, const char * const plugin, // and/or dirty messages, plus the Tag suggestions and/or messages themselves and their // conditions, in order to create the Wrye Bash taglist. outputFile is the path to use // for output. If outputFile already exists, it will only be overwritten if overwrite is true. -LOOT_API unsigned int boss_write_minimal_list (boss_db db, const char * const outputFile, const bool overwrite) { +LOOT_API unsigned int loot_write_minimal_list (loot_db db, const char * const outputFile, const bool overwrite) { if (db == NULL || outputFile == NULL) - return c_error(boss_error_invalid_args, "Null pointer passed."); + return c_error(loot_error_invalid_args, "Null pointer passed."); if (boost::filesystem::exists(outputFile) && !overwrite) - return c_error(boss_error_invalid_args, "Output file exists but overwrite is not set to true."); + return c_error(loot_error_invalid_args, "Output file exists but overwrite is not set to true."); - std::list temp = db->metadata; - for (std::list::iterator it=temp.begin(), endIt=temp.end(); it != endIt; ++it) { - boss::Plugin p(it->Name()); + std::list temp = db->metadata; + for (std::list::iterator it=temp.begin(), endIt=temp.end(); it != endIt; ++it) { + loot::Plugin p(it->Name()); p.Tags(it->Tags()); p.DirtyInfo(it->DirtyInfo()); @@ -683,11 +683,11 @@ LOOT_API unsigned int boss_write_minimal_list (boss_db db, const char * const ou << YAML::EndMap; boost::filesystem::path p(outputFile); - boss::ofstream out(p); + loot::ofstream out(p); if (out.fail()) - return c_error(boss_error_invalid_args, "Couldn't open output file"); + return c_error(loot_error_invalid_args, "Couldn't open output file"); out << yout.c_str(); out.close(); - return boss_ok; + return loot_ok; } diff --git a/src/api/api.h b/src/api/api.h index 98b22f5f..be94c70d 100644 --- a/src/api/api.h +++ b/src/api/api.h @@ -42,7 +42,7 @@ Data returned by a function lasts until a function is called which returns data of the same type (eg. a string is stored until the client calls another function which returns a string, an integer array lasts until another integer array is returned, etc.). - All allocated memory is freed when boss_destroy_db() is called, except the string allocated by boss_get_error_message(), which must be freed by calling boss_cleanup(). + All allocated memory is freed when loot_destroy_db() is called, except the string allocated by loot_get_error_message(), which must be freed by calling loot_cleanup(). */ #ifndef __LOOT_API_H__ @@ -94,17 +94,17 @@ extern "C" @brief A structure that holds all game-specific data used by the LOOT API. @details Used to keep each game's data independent. Abstracts the definition of the API's internal state while still providing type safety across the library. Multiple handles can also be made for each game, though it should be kept in mind that the API is not thread-safe. */ -typedef struct _boss_db_int * boss_db; +typedef struct _loot_db_int * loot_db; /** @brief A structure that holds the type of a message and the message string itself. - @var boss_message::type The type of the message, specified using one of the message type codes given below. - @var boss_message::message The message string itself. + @var loot_message::type The type of the message, specified using one of the message type codes given below. + @var loot_message::message The message string itself. */ typedef struct { unsigned int type; const char * message; -} boss_message; +} loot_message; /*********************//** @@ -113,81 +113,81 @@ typedef struct { *************************/ ///@{ -LOOT_API extern const unsigned int boss_ok; ///< The function completed successfully. -LOOT_API extern const unsigned int boss_error_liblo_error; ///< There was an error in performing a load order operation. -LOOT_API extern const unsigned int boss_error_file_write_fail; ///< A file could not be written to. -LOOT_API extern const unsigned int boss_error_parse_fail; ///< There was an error parsing the file. -LOOT_API extern const unsigned int boss_error_condition_eval_fail; ///< There was an error evaluating the conditionals in a metadata file. -LOOT_API extern const unsigned int boss_error_regex_eval_fail; ///< There was an error evaluating the regular expressions in a metadata file. -LOOT_API extern const unsigned int boss_error_no_mem; ///< The API was unable to allocate the required memory. -LOOT_API extern const unsigned int boss_error_invalid_args; ///< Invalid arguments were given for the function. -LOOT_API extern const unsigned int boss_error_no_tag_map; ///< No Bash Tag map has been generated yet. -LOOT_API extern const unsigned int boss_error_path_not_found; ///< A file or folder path could not be found. -LOOT_API extern const unsigned int boss_error_no_game_detected; ///< The given game could not be found. -LOOT_API extern const unsigned int boss_error_windows_error; ///< An error occurred during a call to the Windows API. -LOOT_API extern const unsigned int boss_error_sorting_error; ///< An error occurred while sorting plugins. +LOOT_API extern const unsigned int loot_ok; ///< The function completed successfully. +LOOT_API extern const unsigned int loot_error_liblo_error; ///< There was an error in performing a load order operation. +LOOT_API extern const unsigned int loot_error_file_write_fail; ///< A file could not be written to. +LOOT_API extern const unsigned int loot_error_parse_fail; ///< There was an error parsing the file. +LOOT_API extern const unsigned int loot_error_condition_eval_fail; ///< There was an error evaluating the conditionals in a metadata file. +LOOT_API extern const unsigned int loot_error_regex_eval_fail; ///< There was an error evaluating the regular expressions in a metadata file. +LOOT_API extern const unsigned int loot_error_no_mem; ///< The API was unable to allocate the required memory. +LOOT_API extern const unsigned int loot_error_invalid_args; ///< Invalid arguments were given for the function. +LOOT_API extern const unsigned int loot_error_no_tag_map; ///< No Bash Tag map has been generated yet. +LOOT_API extern const unsigned int loot_error_path_not_found; ///< A file or folder path could not be found. +LOOT_API extern const unsigned int loot_error_no_game_detected; ///< The given game could not be found. +LOOT_API extern const unsigned int loot_error_windows_error; ///< An error occurred during a call to the Windows API. +LOOT_API extern const unsigned int loot_error_sorting_error; ///< An error occurred while sorting plugins. /** @brief Matches the value of the highest-numbered return code. @details Provided in case clients wish to incorporate additional return codes in their implementation and desire some method of avoiding value conflicts. */ -LOOT_API extern const unsigned int boss_return_max; +LOOT_API extern const unsigned int loot_return_max; ///@} /*******************//** @name Game Codes - @brief Used with boss_create_db(). + @brief Used with loot_create_db(). ***********************/ ///@{ -LOOT_API extern const unsigned int boss_game_tes4; ///< Game code for The Elder Scrolls IV: Oblivion. -LOOT_API extern const unsigned int boss_game_tes5; ///< Game code for The Elder Scrolls V: Skyrim. -LOOT_API extern const unsigned int boss_game_fo3; ///< Game code for Fallout 3. -LOOT_API extern const unsigned int boss_game_fonv; ///< Game code for Fallout: New Vegas. +LOOT_API extern const unsigned int loot_game_tes4; ///< Game code for The Elder Scrolls IV: Oblivion. +LOOT_API extern const unsigned int loot_game_tes5; ///< Game code for The Elder Scrolls V: Skyrim. +LOOT_API extern const unsigned int loot_game_fo3; ///< Game code for Fallout 3. +LOOT_API extern const unsigned int loot_game_fonv; ///< Game code for Fallout: New Vegas. ///@} /***************************//** @name Message Type Codes - @brief Used with the boss_message structure. + @brief Used with the loot_message structure. *******************************/ ///@{ -LOOT_API extern const unsigned int boss_message_say; ///< Denotes a generic note-type message. -LOOT_API extern const unsigned int boss_message_warn; ///< Denotes a warning message. -LOOT_API extern const unsigned int boss_message_error; ///< Denotes an error message. +LOOT_API extern const unsigned int loot_message_say; ///< Denotes a generic note-type message. +LOOT_API extern const unsigned int loot_message_warn; ///< Denotes a warning message. +LOOT_API extern const unsigned int loot_message_error; ///< Denotes an error message. /** @brief Denites a Bash Tag suggestion message. @details This type should never be seen client-side as it is only used during conversion between internal Bash Tag and message structures, but it is provided just in case. */ -LOOT_API extern const unsigned int boss_message_tag; +LOOT_API extern const unsigned int loot_message_tag; ///@} /*******************************//** @name Message Language Codes - @brief Used with boss_eval_lists(). + @brief Used with loot_eval_lists(). ***********************************/ ///@{ -LOOT_API extern const unsigned int boss_lang_any; ///< Tells the API to select messages of any language. -LOOT_API extern const unsigned int boss_lang_english; ///< Tells the API to preferentially select English messages. -LOOT_API extern const unsigned int boss_lang_spanish; ///< Tells the API to preferentially select Spanish messages. -LOOT_API extern const unsigned int boss_lang_russian; ///< Tells the API to preferentially select Russian messages. -LOOT_API extern const unsigned int boss_lang_french; ///< Tells the API to preferentially select French messages. -LOOT_API extern const unsigned int boss_lang_chinese; ///< Tells the API to preferentially select Chinese messages. -LOOT_API extern const unsigned int boss_lang_polish; ///< Tells the API to preferentially select Polish messages. -LOOT_API extern const unsigned int boss_lang_brazilian_portuguese; ///< Tells the API to preferentially select Polish messages. +LOOT_API extern const unsigned int loot_lang_any; ///< Tells the API to select messages of any language. +LOOT_API extern const unsigned int loot_lang_english; ///< Tells the API to preferentially select English messages. +LOOT_API extern const unsigned int loot_lang_spanish; ///< Tells the API to preferentially select Spanish messages. +LOOT_API extern const unsigned int loot_lang_russian; ///< Tells the API to preferentially select Russian messages. +LOOT_API extern const unsigned int loot_lang_french; ///< Tells the API to preferentially select French messages. +LOOT_API extern const unsigned int loot_lang_chinese; ///< Tells the API to preferentially select Chinese messages. +LOOT_API extern const unsigned int loot_lang_polish; ///< Tells the API to preferentially select Polish messages. +LOOT_API extern const unsigned int loot_lang_brazilian_portuguese; ///< Tells the API to preferentially select Polish messages. ///@} /*********************************//** @name Plugin Cleanliness Codes - @brief Used with boss_get_dirty_message(). + @brief Used with loot_get_dirty_message(). *************************************/ ///@{ -LOOT_API extern const unsigned int boss_needs_cleaning_no; ///< Denotes that the plugin queried does not need cleaning. -LOOT_API extern const unsigned int boss_needs_cleaning_yes; ///< Denotes that the plugin queried needs cleaning. -LOOT_API extern const unsigned int boss_needs_cleaning_unknown; ///< Denotes that the API is unable to determine whether or not the plugin queried needs cleaning. +LOOT_API extern const unsigned int loot_needs_cleaning_no; ///< Denotes that the plugin queried does not need cleaning. +LOOT_API extern const unsigned int loot_needs_cleaning_yes; ///< Denotes that the plugin queried needs cleaning. +LOOT_API extern const unsigned int loot_needs_cleaning_unknown; ///< Denotes that the API is unable to determine whether or not the plugin queried needs cleaning. ///@} @@ -203,12 +203,12 @@ LOOT_API extern const unsigned int boss_needs_cleaning_unknown; ///< Denotes th @param details A pointer to the error details string outputted by the function. @returns A return code. */ -LOOT_API unsigned int boss_get_error_message (const char ** const message); +LOOT_API unsigned int loot_get_error_message (const char ** const message); /** @brief Frees the memory allocated to the last error details string. */ -LOOT_API void boss_cleanup (); +LOOT_API void loot_cleanup (); ///@} @@ -226,7 +226,7 @@ LOOT_API void boss_cleanup (); @param versionPatch The patch version number to check. @returns True if the API versions are compatible, false otherwise. */ -LOOT_API bool boss_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch); +LOOT_API bool loot_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch); /** @brief Gets the API version. @@ -235,7 +235,7 @@ LOOT_API bool boss_is_compatible (const unsigned int versionMajor, const unsigne @param versionMinor A pointer to the minor version number. @param versionPatch A pointer to the patch version number. */ -LOOT_API unsigned int boss_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch); +LOOT_API unsigned int loot_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch); /***************************************//** @@ -251,14 +251,14 @@ LOOT_API unsigned int boss_get_version (unsigned int * const versionMajor, unsig @param gamePath The relative or absolute path to the game folder, ot `NULL`. If `NULL`, the API will attempt to detect the data path of the specified game. @returns A return code. */ -LOOT_API unsigned int boss_create_db (boss_db * const db, const unsigned int clientGame, const char * const gamePath); +LOOT_API unsigned int loot_create_db (loot_db * const db, const unsigned int clientGame, const char * const gamePath); /** @brief Destroy an existing database handle. @details Destroys the given database handle, freeing up memory allocated during its use, excluding any memory allocated to error messages. @param db The database handle to destroy. */ -LOOT_API void boss_destroy_db (boss_db db); +LOOT_API void loot_destroy_db (loot_db db); ///@} @@ -276,7 +276,7 @@ LOOT_API void boss_destroy_db (boss_db db); @param userlistPath A string containing the relative or absolute path to the userlist file that should be loaded, or `NULL`. If `NULL`, no userlist will be loaded. The API only upports loading v3 userlists. @returns A return code. */ -LOOT_API unsigned int boss_load_lists (boss_db db, const char * const masterlistPath, +LOOT_API unsigned int loot_load_lists (loot_db db, const char * const masterlistPath, const char * const userlistPath); /** @@ -286,7 +286,7 @@ LOOT_API unsigned int boss_load_lists (boss_db db, const char * const masterlist @param language The language code that is used for message language comparisons. @returns A return code. */ -LOOT_API unsigned int boss_eval_lists (boss_db db, const unsigned int language); +LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language); ///@} @@ -298,17 +298,17 @@ LOOT_API unsigned int boss_eval_lists (boss_db db, const unsigned int language); /** @brief Outputs an array of the Bash Tags that are suggested in the database. - @details This function must be called prior to calling boss_get_plugin_tags() to ensure that the latter can return the Tags using the correct array indicies. + @details This function must be called prior to calling loot_get_plugin_tags() to ensure that the latter can return the Tags using the correct array indicies. @param db The database the function acts on. - @param tagMap A pointer to the outputted array of Bash Tags. The array functions as a map where the indicies are the keys, allowing the API to use them as UIDs for Bash Tags instead of passing their names as strings every time boss_get_plugin_tags() is called. If no Bash Tags are suggested, this will be `NULL`. + @param tagMap A pointer to the outputted array of Bash Tags. The array functions as a map where the indicies are the keys, allowing the API to use them as UIDs for Bash Tags instead of passing their names as strings every time loot_get_plugin_tags() is called. If no Bash Tags are suggested, this will be `NULL`. @param numTags A pointer to the size of the outputted array. If no Bash Tags are suggested, this will be `0`. @returns A return code. */ -LOOT_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_t * const numTags); +LOOT_API unsigned int loot_get_tag_map (loot_db db, char *** const tagMap, size_t * const numTags); /** @brief Outputs the Bash Tags suggested for addition and removal by the database for the given plugin. - @details boss_get_tag_map() must be called before this to ensure that the Bash Tag UIDs outputted by this function can be matched up to name strings. + @details loot_get_tag_map() must be called before this to ensure that the Bash Tag UIDs outputted by this function can be matched up to name strings. @param db The database the function acts on. @param plugin The filename of the plugin to look up Bash Tag suggestions for. @param tags_added A pointer to the outputted array of UIDs of the Bash Tags suggested for addition to the specified plugin. `NULL` if no Bash Tag additions are suggested. @@ -318,7 +318,7 @@ LOOT_API unsigned int boss_get_tag_map (boss_db db, char *** const tagMap, size_ @param userlistModified `true` if the Bash Tag suggestions were modified by the data in the userlist, `false` otherwise. @returns A return code. */ -LOOT_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugin, +LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugin, unsigned int ** const tags_added, size_t * const numTags_added, unsigned int ** const tags_removed, @@ -329,12 +329,12 @@ LOOT_API unsigned int boss_get_plugin_tags (boss_db db, const char * const plugi @brief Outputs the messages associated with the given plugin in the database. @param db The database the function acts on. @param plugin The filename of the plugin to look up messages for. - @param messages A pointer to the outputted array of messages associated with the specified plugin, given as boss_message structures. `NULL` if the plugin has no messages associated with it. + @param messages A pointer to the outputted array of messages associated with the specified plugin, given as loot_message structures. `NULL` if the plugin has no messages associated with it. @param numMessages A pointer to the size of the outputted array. If no messages are outputted, this will be `0`. @returns A return code. */ -LOOT_API unsigned int boss_get_plugin_messages (boss_db db, const char * const plugin, - boss_message ** const messages, +LOOT_API unsigned int loot_get_plugin_messages (loot_db db, const char * const plugin, + loot_message ** const messages, size_t * const numMessages); /** @@ -347,7 +347,7 @@ LOOT_API unsigned int boss_get_plugin_messages (boss_db db, const char * const p @returns A return code. */ -LOOT_API unsigned int boss_get_dirty_info (boss_db db, const char * const plugin, +LOOT_API unsigned int loot_get_dirty_info (loot_db db, const char * const plugin, unsigned int * const needsCleaning); /** @@ -357,7 +357,7 @@ LOOT_API unsigned int boss_get_dirty_info (boss_db db, const char * const plugin @param overwrite If `false` and `outputFile` already exists, no data will be written. Otherwise, data will be written. @returns A return code. */ -LOOT_API unsigned int boss_write_minimal_list (boss_db db, const char * const outputFile, const bool overwrite); +LOOT_API unsigned int loot_write_minimal_list (loot_db db, const char * const outputFile, const bool overwrite); ///@} diff --git a/src/backend/error.h b/src/backend/error.h index 393f275e..5aba022f 100644 --- a/src/backend/error.h +++ b/src/backend/error.h @@ -28,7 +28,7 @@ #include #include -namespace boss { +namespace loot { class error : public std::exception { public: diff --git a/src/backend/game.cpp b/src/backend/game.cpp index ed9ada03..bb518548 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -36,7 +36,7 @@ using namespace std; namespace fs = boost::filesystem; namespace lc = boost::locale; -namespace boss { +namespace loot { std::vector GetGames(const YAML::Node& settings) { vector games; @@ -65,34 +65,34 @@ namespace boss { if (Id() == g_game_tes4) { _name = "TES IV: Oblivion"; registryKey = "Software\\Bethesda Softworks\\Oblivion\\Installed Path"; - bossFolderName = "Oblivion"; + lootFolderName = "Oblivion"; _masterFile = "Oblivion.esm"; espm_settings = espm::Settings("tes4"); - _repositoryURL = "https://github.com/boss-developers/boss-oblivion.git"; + _repositoryURL = "https://github.com/loot-developers/loot-oblivion.git"; _repositoryBranch = "gh-pages"; } else if (Id() == g_game_tes5) { _name = "TES V: Skyrim"; registryKey = "Software\\Bethesda Softworks\\Skyrim\\Installed Path"; - bossFolderName = "Skyrim"; + lootFolderName = "Skyrim"; _masterFile = "Skyrim.esm"; espm_settings = espm::Settings("tes5"); - _repositoryURL = "https://github.com/boss-developers/boss-skyrim.git"; + _repositoryURL = "https://github.com/loot-developers/loot-skyrim.git"; _repositoryBranch = "gh-pages"; } else if (Id() == g_game_fo3) { _name = "Fallout 3"; registryKey = "Software\\Bethesda Softworks\\Fallout3\\Installed Path"; - bossFolderName = "Fallout3"; + lootFolderName = "Fallout3"; _masterFile = "Fallout3.esm"; espm_settings = espm::Settings("fo3"); - _repositoryURL = "https://github.com/boss-developers/boss-fallout3.git"; + _repositoryURL = "https://github.com/loot-developers/loot-fallout3.git"; _repositoryBranch = "gh-pages"; } else if (Id() == g_game_fonv) { _name = "Fallout: New Vegas"; registryKey = "Software\\Bethesda Softworks\\FalloutNV\\Installed Path"; - bossFolderName = "FalloutNV"; + lootFolderName = "FalloutNV"; _masterFile = "FalloutNV.esm"; espm_settings = espm::Settings("fonv"); - _repositoryURL = "https://github.com/boss-developers/boss-fallout-new-vegas.git"; + _repositoryURL = "https://github.com/loot-developers/loot-fallout-new-vegas.git"; _repositoryBranch = "gh-pages"; } else { BOOST_LOG_TRIVIAL(error) << "Invalid game ID supplied."; @@ -100,7 +100,7 @@ namespace boss { } if (!folder.empty()) - bossFolderName = folder; + lootFolderName = folder; } Game& Game::SetDetails(const std::string& name, const std::string& masterFile, @@ -186,7 +186,7 @@ namespace boss { } bool Game::operator == (const Game& rhs) const { - return (boost::iequals(_name, rhs.Name()) || boost::iequals(bossFolderName, rhs.FolderName())); + return (boost::iequals(_name, rhs.Name()) || boost::iequals(lootFolderName, rhs.FolderName())); } unsigned int Game::Id() const { @@ -198,7 +198,7 @@ namespace boss { } string Game::FolderName() const { - return bossFolderName; + return lootFolderName; } std::string Game::Master() const { @@ -226,15 +226,15 @@ namespace boss { } fs::path Game::MasterlistPath() const { - return g_path_local / bossFolderName / "masterlist.yaml"; + return g_path_local / lootFolderName / "masterlist.yaml"; } fs::path Game::UserlistPath() const { - return g_path_local / bossFolderName / "userlist.yaml"; + return g_path_local / lootFolderName / "userlist.yaml"; } fs::path Game::ReportPath() const { - return g_path_local / bossFolderName / "report.html"; + return g_path_local / lootFolderName / "report.html"; } void Game::RefreshActivePluginsList() { @@ -483,8 +483,8 @@ namespace boss { void Game::CreateLOOTGameFolder() { //Make sure that the LOOT game path exists. try { - if (fs::exists(g_path_local) && !fs::exists(g_path_local / bossFolderName)) - fs::create_directory(g_path_local / bossFolderName); + if (fs::exists(g_path_local) && !fs::exists(g_path_local / lootFolderName)) + fs::create_directory(g_path_local / lootFolderName); } catch (fs::filesystem_error& e) { BOOST_LOG_TRIVIAL(error) << "Could not create LOOT folder for game. Details: " << e.what(); throw error(error::path_write_fail, lc::translate("Could not create LOOT folder for game. Details:").str() + " " + e.what()); diff --git a/src/backend/game.h b/src/backend/game.h index adfb1fd9..426a9fcf 100644 --- a/src/backend/game.h +++ b/src/backend/game.h @@ -38,14 +38,14 @@ #include #include -namespace boss { +namespace loot { class Plugin; class Game { public: Game(); //Sets game to LOOT_g_game_autodetect, with all other vars being empty. - Game(const unsigned int baseGameCode, const std::string& bossFolder = ""); + Game(const unsigned int baseGameCode, const std::string& lootFolder = ""); Game& SetDetails(const std::string& name, const std::string& masterFile, const std::string& repositoryURL, const std::string& repositoryBranch, @@ -91,7 +91,7 @@ namespace boss { std::string registryKey; - std::string bossFolderName; + std::string lootFolderName; std::string _repositoryURL; std::string _repositoryBranch; diff --git a/src/backend/generators.h b/src/backend/generators.h index bc97f3de..cedf59cc 100644 --- a/src/backend/generators.h +++ b/src/backend/generators.h @@ -39,7 +39,7 @@ #include #include -namespace boss { +namespace loot { //LOOT Report generation stuff. @@ -260,7 +260,7 @@ namespace boss { note.append_attribute("id").set_value("noChanges"); note.text().set(boost::locale::translate("No change in details since last run.").str().c_str()); */ - messages.push_front(boss::Message(boss::g_message_say, boost::locale::translate("There have been no changes in the Details tab since LOOT was last run for this game.").str())); + messages.push_front(loot::Message(loot::g_message_say, boost::locale::translate("There have been no changes in the Details tab since LOOT was last run for this game.").str())); } if (!messages.empty()) { @@ -393,7 +393,7 @@ namespace boss { else if (jt->ITMs() > 0 && jt->UDRs() > 0 && jt->DeletedNavmeshes() == 0) f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% UDR records. Clean with %3%.")) % jt->ITMs() % jt->UDRs() % jt->CleaningUtility(); - messages.push_back(boss::Message(boss::g_message_warn, f.str())); + messages.push_back(loot::Message(loot::g_message_warn, f.str())); } AppendMessages(plugin, messages, warnNo, errorNo); @@ -562,7 +562,7 @@ namespace boss { AppendScripts(body); //PugiXML's save_file doesn't handle Unicode paths right (it can't open them right), so use a stream instead. boost::filesystem::path outpath(file); - boss::ofstream out(outpath); + loot::ofstream out(outpath); doc.save(out, "\t", pugi::format_default | pugi::format_no_declaration | pugi::format_raw); out.close(); @@ -588,7 +588,7 @@ namespace boss { 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", "https://github.com/boss-developers/boss-oblivion.git", "gh-pages", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1")); + games.push_back(Game(g_game_tes4, "Nehrim").SetDetails("Nehrim - At Fate's Edge", "Nehrim.esm", "https://github.com/loot-developers/loot-oblivion.git", "gh-pages", "", "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Nehrim - At Fate's Edge_is1")); root["Games"] = games; @@ -598,7 +598,7 @@ namespace boss { yout << root; boost::filesystem::path p(file); - boss::ofstream out(p); + loot::ofstream out(p); out << yout.c_str(); out.close(); } @@ -616,7 +616,7 @@ namespace YAML { return out; } - inline Emitter& operator << (Emitter& out, const boss::PluginDirtyInfo& rhs) { + inline Emitter& operator << (Emitter& out, const loot::PluginDirtyInfo& rhs) { out << BeginMap << Key << "crc" << Value << Hex << rhs.CRC() << Dec << Key << "util" << Value << rhs.CleaningUtility(); @@ -633,7 +633,7 @@ namespace YAML { return out; } - inline Emitter& operator << (Emitter& out, const boss::Game& rhs) { + inline Emitter& operator << (Emitter& out, const loot::Game& rhs) { out << BeginMap << Key << "folder" << Value << rhs.FolderName() << Key << "name" << Value << rhs.Name() @@ -643,24 +643,24 @@ namespace YAML { << Key << "path" << Value << rhs.GamePath().string() << Key << "registry" << Value << rhs.RegistryKey(); - 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(); + if (rhs.Id() == loot::g_game_tes4) + out << Key << Value << loot::Game(loot::g_game_tes4).FolderName(); + else if (rhs.Id() == loot::g_game_tes5) + out << Key << Value << loot::Game(loot::g_game_tes5).FolderName(); + else if (rhs.Id() == loot::g_game_fo3) + out << Key << Value << loot::Game(loot::g_game_fo3).FolderName(); + else if (rhs.Id() == loot::g_game_fonv) + out << Key << Value << loot::Game(loot::g_game_fonv).FolderName(); out << EndMap; return out; } - inline Emitter& operator << (Emitter& out, const boss::MessageContent& rhs) { + inline Emitter& operator << (Emitter& out, const loot::MessageContent& rhs) { out << BeginMap; - out << Key << "lang" << Value << boss::Language(rhs.Language()).Locale(); + out << Key << "lang" << Value << loot::Language(rhs.Language()).Locale(); out << Key << "str" << Value << rhs.Str(); @@ -669,17 +669,17 @@ namespace YAML { return out; } - inline Emitter& operator << (Emitter& out, const boss::Message& rhs) { + inline Emitter& operator << (Emitter& out, const loot::Message& rhs) { out << BeginMap; - if (rhs.Type() == boss::g_message_say) + if (rhs.Type() == loot::g_message_say) out << Key << "type" << Value << "say"; - else if (rhs.Type() == boss::g_message_warn) + else if (rhs.Type() == loot::g_message_warn) out << Key << "type" << Value << "warn"; else out << Key << "type" << Value << "error"; - if (rhs.Content().size() == 1 && rhs.Content().front().Language() == boss::g_lang_any) + if (rhs.Content().size() == 1 && rhs.Content().front().Language() == loot::g_lang_any) out << Key << "content" << Value << rhs.Content().front().Str(); else out << Key << "content" << Value << rhs.Content(); @@ -692,7 +692,7 @@ namespace YAML { return out; } - inline Emitter& operator << (Emitter& out, const boss::File& rhs) { + inline Emitter& operator << (Emitter& out, const loot::File& rhs) { if (!rhs.IsConditional() && rhs.DisplayName().empty()) out << rhs.Name(); else { @@ -711,7 +711,7 @@ namespace YAML { return out; } - inline Emitter& operator << (Emitter& out, const boss::Tag& rhs) { + inline Emitter& operator << (Emitter& out, const loot::Tag& rhs) { if (!rhs.IsConditional()) { if (rhs.IsAddition()) out << rhs.Name(); @@ -731,7 +731,7 @@ namespace YAML { return out; } - inline Emitter& operator << (Emitter& out, const boss::Plugin& rhs) { + inline Emitter& operator << (Emitter& out, const loot::Plugin& rhs) { if (!rhs.HasNameOnly()) { out << BeginMap diff --git a/src/backend/globals.cpp b/src/backend/globals.cpp index 8a370409..9cbf13d7 100644 --- a/src/backend/globals.cpp +++ b/src/backend/globals.cpp @@ -25,7 +25,7 @@ #include "globals.h" #include "helpers.h" -namespace boss { +namespace loot { //Game values. const unsigned int g_game_autodetect = 0; diff --git a/src/backend/globals.h b/src/backend/globals.h index afcbb3b9..68156793 100644 --- a/src/backend/globals.h +++ b/src/backend/globals.h @@ -26,7 +26,7 @@ #include -namespace boss { +namespace loot { //Game values. extern const unsigned int g_game_autodetect; diff --git a/src/backend/graph.cpp b/src/backend/graph.cpp index 8c750bbd..87e77005 100644 --- a/src/backend/graph.cpp +++ b/src/backend/graph.cpp @@ -35,7 +35,7 @@ using namespace std; namespace lc = boost::locale; -namespace boss { +namespace loot { cycle_detector::cycle_detector() {} @@ -44,7 +44,7 @@ namespace boss { vertex_t vTarget = boost::target(e, g); BOOST_LOG_TRIVIAL(error) << "Cyclic interaction detected between plugins \"" << g[vSource].Name() << "\" and \"" << g[vTarget].Name() << "\"."; - throw boss::error(boss::error::sorting_error, (boost::format(lc::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\".")) % g[vSource].Name() % g[vTarget].Name()).str()); + throw loot::error(loot::error::sorting_error, (boost::format(lc::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\".")) % g[vSource].Name() % g[vTarget].Name()).str()); } bool GetVertexByName(const PluginGraph& graph, const std::string& name, vertex_t& vertex) { @@ -77,7 +77,7 @@ namespace boss { boost::topological_sort(graph, std::front_inserter(sortedVertices), boost::vertex_index_map(v_index_map)); BOOST_LOG_TRIVIAL(info) << "Calculated order: "; - list tempPlugins; + list tempPlugins; for (std::list::iterator it = sortedVertices.begin(), endit = sortedVertices.end(); it != endit; ++it) { BOOST_LOG_TRIVIAL(info) << '\t' << graph[*it].Name(); tempPlugins.push_back(graph[*it]); @@ -95,13 +95,13 @@ namespace boss { BGL_FORALL_VERTICES(v, graph, PluginGraph) put(v_index_map, v, i++); - boss::cycle_detector vis; + loot::cycle_detector vis; boost::depth_first_search(graph, visitor(vis).vertex_index_map(v_index_map)); } void AddSpecificEdges(PluginGraph& graph) { //Add edges for all relationships that aren't overlaps or priority differences. - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { vertex_t parentVertex; @@ -109,7 +109,7 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Adding edges for master flag differences."; - boss::vertex_it vit2 = vit; + loot::vertex_it vit2 = vit; ++vit2; while (vit2 != vitend) { @@ -139,7 +139,7 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for masters."; vector strVec(graph[*vit].Masters()); for (vector::const_iterator it=strVec.begin(), itend=strVec.end(); it != itend; ++it) { - if (boss::GetVertexByName(graph, *it, parentVertex) && + if (loot::GetVertexByName(graph, *it, parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; @@ -150,8 +150,8 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for requirements."; set fileset(graph[*vit].Reqs()); for (set::const_iterator it=fileset.begin(), itend=fileset.end(); it != itend; ++it) { - if (boss::IsPlugin(it->Name()) && - boss::GetVertexByName(graph, it->Name(), parentVertex) && + if (loot::IsPlugin(it->Name()) && + loot::GetVertexByName(graph, it->Name(), parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; @@ -163,8 +163,8 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for 'load after's."; fileset = graph[*vit].LoadAfter(); for (set::const_iterator it=fileset.begin(), itend=fileset.end(); it != itend; ++it) { - if (boss::IsPlugin(it->Name()) && - boss::GetVertexByName(graph, it->Name(), parentVertex) && + if (loot::IsPlugin(it->Name()) && + loot::GetVertexByName(graph, it->Name(), parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; @@ -176,7 +176,7 @@ namespace boss { } void AddPriorityEdges(PluginGraph& graph) { - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { BOOST_LOG_TRIVIAL(trace) << "Adding priority difference edges to vertex for \"" << graph[*vit].Name() << "\"."; @@ -185,7 +185,7 @@ namespace boss { //as they are for loading BSAs, and in Skyrim that means the resources they load can //be affected by load order. - boss::vertex_it vit2, vitend2; + loot::vertex_it vit2, vitend2; for (boost::tie(vit2, vitend2) = boost::vertices(graph); vit2 != vitend2; ++vit2) { if (graph[*vit].Priority() == graph[*vit2].Priority() || (!graph[*vit].FormIDs().empty() && !graph[*vit2].FormIDs().empty() && !graph[*vit].DoFormIDsOverlap(graph[*vit2]))) { @@ -215,7 +215,7 @@ namespace boss { } void AddOverlapEdges(PluginGraph& graph) { - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { @@ -226,7 +226,7 @@ namespace boss { continue; } - boss::vertex_it vit2, vitend2; + loot::vertex_it vit2, vitend2; for (boost::tie(vit2, vitend2) = boost::vertices(graph); vit2 != vitend2; ++vit2) { if (vit == vit2 || boost::edge(*vit, *vit2, graph).second || boost::edge(*vit2, *vit, graph).second) //Vertices are the same or are already linked. diff --git a/src/backend/graph.h b/src/backend/graph.h index 672dcf3a..f0b696fa 100644 --- a/src/backend/graph.h +++ b/src/backend/graph.h @@ -34,9 +34,9 @@ #include #include -namespace boss { +namespace loot { - typedef boost::adjacency_list PluginGraph; + typedef boost::adjacency_list PluginGraph; typedef boost::graph_traits::vertex_descriptor vertex_t; typedef boost::graph_traits::vertex_iterator vertex_it; typedef boost::graph_traits::edge_descriptor edge_t; diff --git a/src/backend/helpers.cpp b/src/backend/helpers.cpp index db09eb95..5f02ede1 100644 --- a/src/backend/helpers.cpp +++ b/src/backend/helpers.cpp @@ -56,7 +56,7 @@ #endif #define BUFSIZE 4096 -namespace boss { +namespace loot { using namespace std; using boost::algorithm::replace_all; using boost::algorithm::replace_first; @@ -127,7 +127,7 @@ namespace boss { uint32_t chksum = 0; static const size_t buffer_size = 8192; char buffer[buffer_size]; - boss::ifstream ifile(filename, ios::binary); + loot::ifstream ifile(filename, ios::binary); BOOST_LOG_TRIVIAL(trace) << "Calculating CRC for: " << filename.string(); boost::crc_32_type result; if (ifile) { diff --git a/src/backend/helpers.h b/src/backend/helpers.h index 5d98ef3d..2704631e 100644 --- a/src/backend/helpers.h +++ b/src/backend/helpers.h @@ -32,7 +32,7 @@ #include #include -namespace boss { +namespace loot { /// Array used to try each of the expressions defined using /// an iteration for each of them. diff --git a/src/backend/legacy-parser.h b/src/backend/legacy-parser.h index 70e0a663..4397e350 100644 --- a/src/backend/legacy-parser.h +++ b/src/backend/legacy-parser.h @@ -53,7 +53,7 @@ #include #include -namespace boss { +namespace loot { namespace qi = boost::spirit::qi; namespace unicode = boost::spirit::unicode; namespace phoenix = boost::phoenix; @@ -400,7 +400,7 @@ namespace boss { if (it == varConditionMap.end()) { BOOST_LOG_TRIVIAL(error) << "The variable \"" << var << "\" was not previously defined."; - throw boss::error(boss::error::condition_eval_fail, "The variable \"" + var + "\" was not previously defined."); //Isn't used by LOOT application, so don't need to translate. + throw loot::error(loot::error::condition_eval_fail, "The variable \"" + var + "\" was not previously defined."); //Isn't used by LOOT application, so don't need to translate. } if (ifIfnotStr == "if ") @@ -792,7 +792,7 @@ namespace boss { boost::trim(context); BOOST_LOG_TRIVIAL(error) << "Error parsing at \"" << context << "\", expected \"" << what.tag << "\"."; - throw boss::error(boss::error::condition_eval_fail, "Expected \"" + what.tag + "\" at \"" + context + "\"."); //Isn't used by LOOT application, so don't need to translate. + throw loot::error(loot::error::condition_eval_fail, "Expected \"" + what.tag + "\" at \"" + context + "\"."); //Isn't used by LOOT application, so don't need to translate. } }; @@ -804,7 +804,7 @@ namespace boss { grammar.SetGlobalMessageBuffer(&globalMessages); - boss::ifstream ifile(file); + loot::ifstream ifile(file); ifile.unsetf(std::ios::skipws); // No white space skipping! std::copy( @@ -820,7 +820,7 @@ namespace boss { if (!r || begin != end) { BOOST_LOG_TRIVIAL(error) << "Failed to read file: " << file.string(); - throw boss::error(boss::error::path_read_fail, file.string()); + throw loot::error(loot::error::path_read_fail, file.string()); } } } diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index 7bc66d03..1694465e 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -36,7 +36,7 @@ using namespace std; -namespace boss { +namespace loot { namespace lc = boost::locale; @@ -116,7 +116,7 @@ namespace boss { return _condition; } - bool ConditionStruct::EvalCondition(boss::Game& game) const { + bool ConditionStruct::EvalCondition(loot::Game& game) const { if (_condition.empty()) return true; @@ -138,14 +138,14 @@ namespace boss { bool r; try { r = boost::spirit::qi::phrase_parse(begin, end, grammar, skipper, eval); - } catch (boss::error& e) { + } catch (loot::error& e) { BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\": " << e.what(); - throw boss::error(boss::error::path_read_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str()); + throw loot::error(loot::error::path_read_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str()); } if (!r || begin != end) { BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\"."; - throw boss::error(boss::error::path_read_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\".")) % _condition).str()); + throw loot::error(loot::error::path_read_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\".")) % _condition).str()); } game.conditionCache.emplace(boost::to_lower_copy(_condition), eval); @@ -196,7 +196,7 @@ namespace boss { return (_type == rhs.Type() && _content == rhs.Content()); } - bool Message::EvalCondition(boss::Game& game, const unsigned int language) { + bool Message::EvalCondition(loot::Game& game, const unsigned int language) { BOOST_LOG_TRIVIAL(trace) << "Choosing message language."; @@ -303,7 +303,7 @@ namespace boss { name = name.substr(0, name.length() - 6); } - Plugin::Plugin(boss::Game& game, const std::string& n, const bool headerOnly) + Plugin::Plugin(loot::Game& game, const std::string& n, const bool headerOnly) : name(n), enabled(true), priority(0), isMaster(false), crc(0), numOverrideRecords(0), _isPriorityExplicit(false) { // Get data from file contents using libespm. Assumes libespm has already been initialised. @@ -563,7 +563,7 @@ namespace boss { _dirtyInfo = dirtyInfo; } - void Plugin::EvalAllConditions(boss::Game& game, const unsigned int language) { + void Plugin::EvalAllConditions(loot::Game& game, const unsigned int language) { for (set::iterator it = loadAfter.begin(); it != loadAfter.end();) { if (!it->EvalCondition(game)) loadAfter.erase(it++); diff --git a/src/backend/metadata.h b/src/backend/metadata.h index 38964ea7..be0896cc 100644 --- a/src/backend/metadata.h +++ b/src/backend/metadata.h @@ -33,7 +33,7 @@ #include #include -namespace boss { +namespace loot { //A FormID is a 32 bit unsigned integer of the form xxYYYYYY in hex. The xx is the position in the masters list of the plugin that the FormID is from, and the YYYYYY is the rest of the FormID. Here the xx bit is stored as the corresponding filename to allow comparison between FormIDs from different plugins. @@ -79,7 +79,7 @@ namespace boss { ConditionStruct(const std::string& condition); bool IsConditional() const; - bool EvalCondition(boss::Game& game) const; + bool EvalCondition(loot::Game& game) const; std::string Condition() const; private: @@ -112,7 +112,7 @@ namespace boss { bool operator < (const Message& rhs) const; bool operator == (const Message& rhs) const; - bool EvalCondition(boss::Game& game, const unsigned int language); + bool EvalCondition(loot::Game& game, const unsigned int language); unsigned int Type() const; std::vector Content() const; @@ -157,7 +157,7 @@ namespace boss { public: Plugin(); Plugin(const std::string& name); - Plugin(boss::Game& game, const std::string& name, const bool headerOnly); + Plugin(loot::Game& game, const std::string& name, const bool headerOnly); //Merges from the given plugin into this one, unless there is already equal metadata present. //For 'enabled' and 'priority' metadata, use the given plugin's values, but if the 'priority' user value is zero, ignore it. @@ -195,7 +195,7 @@ namespace boss { void Tags(const std::set& tags); void DirtyInfo(const std::set& info); - void EvalAllConditions(boss::Game& game, const unsigned int language); + void EvalAllConditions(loot::Game& game, const unsigned int language); bool HasNameOnly() const; bool IsRegexPlugin() const; bool LoadsBSA(const Game& game) const; diff --git a/src/backend/network.cpp b/src/backend/network.cpp index 7233ab5d..d3017f1d 100644 --- a/src/backend/network.cpp +++ b/src/backend/network.cpp @@ -39,7 +39,7 @@ using namespace std; namespace fs = boost::filesystem; namespace lc = boost::locale; -namespace boss { +namespace loot { struct pointers_struct { pointers_struct() : repo(NULL), remote(NULL), cfg(NULL), obj(NULL), commit(NULL) {} @@ -73,7 +73,7 @@ namespace boss { giterr_clear(); BOOST_LOG_TRIVIAL(error) << "Git operation failed. Error: " << error_message; - throw boss::error(boss::error::git_error, (boost::format(lc::translate("Git operation failed. Error: %1%")) % error_message).str()); + throw loot::error(loot::error::git_error, (boost::format(lc::translate("Git operation failed. Error: %1%")) % error_message).str()); } int progress_cb(const char *str, int len, void *data) { @@ -201,7 +201,7 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Adding the masterlist to the list of files to be checked out."; - boss::ofstream out(game.MasterlistPath().parent_path() / ".git/info/sparse-checkout"); + loot::ofstream out(game.MasterlistPath().parent_path() / ".git/info/sparse-checkout"); out << "masterlist.yaml"; @@ -282,23 +282,23 @@ namespace boss { BOOST_LOG_TRIVIAL(trace) << "Testing masterlist parsing."; //Now try parsing the masterlist. - list messages; - list plugins; + list messages; + list plugins; try { - boss::ifstream in(game.MasterlistPath()); + loot::ifstream in(game.MasterlistPath()); YAML::Node mlist = YAML::Load(in); in.close(); if (mlist["globals"]) - messages = mlist["globals"].as< list >(); + messages = mlist["globals"].as< list >(); if (mlist["plugins"]) - plugins = mlist["plugins"].as< list >(); + plugins = mlist["plugins"].as< list >(); - for (list::iterator it=plugins.begin(), endIt=plugins.end(); it != endIt; ++it) { + for (list::iterator it=plugins.begin(), endIt=plugins.end(); it != endIt; ++it) { it->EvalAllConditions(game, g_lang_any); } - for (list::iterator it=messages.begin(), endIt=messages.end(); it != endIt; ++it) { + for (list::iterator it=messages.begin(), endIt=messages.end(); it != endIt; ++it) { it->EvalCondition(game, g_lang_any); } @@ -311,7 +311,7 @@ namespace boss { //Roll back one revision if there's an error. BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. Masterlist revision " + string(revision) + ": " + e.what(); - parsingErrors.push_back(boss::Message(boss::g_message_error, boost::locale::translate("Masterlist revision").str() + " " + string(revision) + ": " + e.what() + " " + boost::locale::translate("Rolled back to the previous revision.").str())); + parsingErrors.push_back(loot::Message(loot::g_message_error, boost::locale::translate("Masterlist revision").str() + " " + string(revision) + ": " + e.what() + " " + boost::locale::translate("Rolled back to the previous revision.").str())); } } while (parsingFailed); diff --git a/src/backend/network.h b/src/backend/network.h index 7c2607f2..96e5504e 100644 --- a/src/backend/network.h +++ b/src/backend/network.h @@ -31,7 +31,7 @@ #include "game.h" #include "metadata.h" -namespace boss { +namespace loot { std::string UpdateMasterlist(Game& game, std::list& parsingErrors, std::list& plugins, std::list& messages); } diff --git a/src/backend/parsers.h b/src/backend/parsers.h index b5c12078..761de60c 100644 --- a/src/backend/parsers.h +++ b/src/backend/parsers.h @@ -60,11 +60,11 @@ namespace YAML { /////////////////////// template<> - struct convert { - static Node encode(const boss::Game& rhs) { + struct convert { + static Node encode(const loot::Game& rhs) { Node node; - node["type"] = boss::Game(rhs.Id()).FolderName(); + node["type"] = loot::Game(rhs.Id()).FolderName(); node["name"] = rhs.Name(); node["folder"] = rhs.FolderName(); node["master"] = rhs.Master(); @@ -76,18 +76,18 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::Game& rhs) { + static bool decode(const Node& node, loot::Game& rhs) { if (!node.IsMap() || !node["folder"] || !node["type"]) return false; - if (node["type"].as() == boss::Game(boss::g_game_tes4).FolderName()) - rhs = boss::Game(boss::g_game_tes4, node["folder"].as()); - else if (node["type"].as() == boss::Game(boss::g_game_tes5).FolderName()) - rhs = boss::Game(boss::g_game_tes5, node["folder"].as()); - else if (node["type"].as() == boss::Game(boss::g_game_fo3).FolderName()) - rhs = boss::Game(boss::g_game_fo3, node["folder"].as()); - else if (node["type"].as() == boss::Game(boss::g_game_fonv).FolderName()) - rhs = boss::Game(boss::g_game_fonv, node["folder"].as()); + if (node["type"].as() == loot::Game(loot::g_game_tes4).FolderName()) + rhs = loot::Game(loot::g_game_tes4, node["folder"].as()); + else if (node["type"].as() == loot::Game(loot::g_game_tes5).FolderName()) + rhs = loot::Game(loot::g_game_tes5, node["folder"].as()); + else if (node["type"].as() == loot::Game(loot::g_game_fo3).FolderName()) + rhs = loot::Game(loot::g_game_fo3, node["folder"].as()); + else if (node["type"].as() == loot::Game(loot::g_game_fonv).FolderName()) + rhs = loot::Game(loot::g_game_fonv, node["folder"].as()); else return false; @@ -112,8 +112,8 @@ namespace YAML { }; template<> - struct convert { - static Node encode(const boss::PluginDirtyInfo& rhs) { + struct convert { + static Node encode(const loot::PluginDirtyInfo& rhs) { Node node; node["crc"] = rhs.CRC(); node["util"] = rhs.CleaningUtility(); @@ -128,7 +128,7 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::PluginDirtyInfo& rhs) { + static bool decode(const Node& node, loot::PluginDirtyInfo& rhs) { if (!node.IsMap() || !node["crc"] || !node["util"]) return false; @@ -144,45 +144,45 @@ namespace YAML { std::string utility = node["util"].as(); - rhs = boss::PluginDirtyInfo(crc, itm, udr, nav, utility); + rhs = loot::PluginDirtyInfo(crc, itm, udr, nav, utility); return true; } }; template<> - struct convert { - static Node encode(const boss::MessageContent& rhs) { + struct convert { + static Node encode(const loot::MessageContent& rhs) { Node node; node["str"] = rhs.Str(); - node["lang"] = boss::Language(rhs.Language()).Locale(); + node["lang"] = loot::Language(rhs.Language()).Locale(); return node; } - static bool decode(const Node& node, boss::MessageContent& rhs) { + static bool decode(const Node& node, loot::MessageContent& rhs) { if (!node.IsMap() || !node["str"] || !node["lang"]) return false; std::string str = node["str"].as(); - unsigned int lang = boss::Language(node["lang"].as()).Code(); + unsigned int lang = loot::Language(node["lang"].as()).Code(); - rhs = boss::MessageContent(str, lang); + rhs = loot::MessageContent(str, lang); return true; } }; template<> - struct convert { - static Node encode(const boss::Message& rhs) { + struct convert { + static Node encode(const loot::Message& rhs) { Node node; node["condition"] = rhs.Condition(); node["content"] = rhs.Content(); - if (rhs.Type() == boss::g_message_say) + if (rhs.Type() == loot::g_message_say) node["type"] = "say"; - else if (rhs.Type() == boss::g_message_warn) + else if (rhs.Type() == loot::g_message_warn) node["type"] = "warn"; else node["type"] = "error"; @@ -190,7 +190,7 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::Message& rhs) { + static bool decode(const Node& node, loot::Message& rhs) { if(!node.IsMap() || !node["type"] || !node["content"]) return false; @@ -200,25 +200,25 @@ namespace YAML { type = node["type"].as(); if (boost::iequals(type, "say")) - typeNo = boss::g_message_say; + typeNo = loot::g_message_say; else if (boost::iequals(type, "warn")) - typeNo = boss::g_message_warn; + typeNo = loot::g_message_warn; else - typeNo = boss::g_message_error; + typeNo = loot::g_message_error; } - std::vector content; + std::vector content; if (node["content"].IsSequence()) - content = node["content"].as< std::vector >(); + content = node["content"].as< std::vector >(); else { - content.push_back(boss::MessageContent(node["content"].as())); + content.push_back(loot::MessageContent(node["content"].as())); } //Check now that at least one item in content is English if there are multiple items. 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::g_lang_english) + for (std::vector::const_iterator it=content.begin(), endit=content.end(); it != endit; ++it) { + if (it->Language() == loot::g_lang_english) found = true; } if (!found) @@ -229,14 +229,14 @@ namespace YAML { if (node["condition"]) condition = node["condition"].as(); - rhs = boss::Message(typeNo, content, condition); + rhs = loot::Message(typeNo, content, condition); return true; } }; template<> - struct convert { - static Node encode(const boss::File& rhs) { + struct convert { + static Node encode(const loot::File& rhs) { Node node; node["condition"] = rhs.Condition(); node["name"] = rhs.Name(); @@ -244,7 +244,7 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::File& rhs) { + static bool decode(const Node& node, loot::File& rhs) { if(node.IsMap()) { std::string condition, name, display; if (node["condition"]) @@ -253,16 +253,16 @@ namespace YAML { name = node["name"].as(); if (node["display"]) display = node["display"].as(); - rhs = boss::File(name, display, condition); + rhs = loot::File(name, display, condition); } else - rhs = boss::File(node.as()); + rhs = loot::File(node.as()); return true; } }; template<> - struct convert { - static Node encode(const boss::Tag& rhs) { + struct convert { + static Node encode(const loot::Tag& rhs) { Node node; node["condition"] = rhs.Condition(); if (rhs.IsAddition()) @@ -272,7 +272,7 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::Tag& rhs) { + static bool decode(const Node& node, loot::Tag& rhs) { std::string condition, tag; if(node.IsMap()) { if (node["condition"]) @@ -283,9 +283,9 @@ namespace YAML { tag = node.as(); if (tag[0] == '-') - rhs = boss::Tag(tag.substr(1), false, condition); + rhs = loot::Tag(tag.substr(1), false, condition); else - rhs = boss::Tag(tag, true, condition); + rhs = loot::Tag(tag, true, condition); return true; } @@ -315,8 +315,8 @@ namespace YAML { }; template<> - struct convert { - static Node encode(const boss::Plugin& rhs) { + struct convert { + static Node encode(const loot::Plugin& rhs) { Node node; node["name"] = rhs.Name(); node["enabled"] = rhs.Enabled(); @@ -331,12 +331,12 @@ namespace YAML { return node; } - static bool decode(const Node& node, boss::Plugin& rhs) { + static bool decode(const Node& node, loot::Plugin& rhs) { if(!node.IsMap()) return false; if (node["name"]) - rhs = boss::Plugin(node["name"].as()); + rhs = loot::Plugin(node["name"].as()); if (node["enabled"]) rhs.Enabled(node["enabled"].as()); @@ -346,24 +346,24 @@ namespace YAML { } if (node["after"]) - rhs.LoadAfter(node["after"].as< std::set >()); + rhs.LoadAfter(node["after"].as< std::set >()); if (node["req"]) - rhs.Reqs(node["req"].as< std::set >()); + rhs.Reqs(node["req"].as< std::set >()); if (node["inc"]) - rhs.Incs(node["inc"].as< std::set >()); + rhs.Incs(node["inc"].as< std::set >()); if (node["msg"]) - rhs.Messages(node["msg"].as< std::list >()); + rhs.Messages(node["msg"].as< std::list >()); if (node["tag"]) - rhs.Tags(node["tag"].as< std::set >()); + rhs.Tags(node["tag"].as< std::set >()); if (node["dirty"]) - rhs.DirtyInfo(node["dirty"].as< std::set >()); + rhs.DirtyInfo(node["dirty"].as< std::set >()); return true; } }; } -namespace boss { +namespace loot { /////////////////////////////// // Condition parser/evaluator @@ -444,7 +444,7 @@ namespace boss { qi::on_error(invalidPathChars, phoenix::bind(&condition_grammar::SyntaxError, this, qi::labels::_1, qi::labels::_2, qi::labels::_3, qi::labels::_4)); } - void SetGame(boss::Game& g) { + void SetGame(loot::Game& g) { game = &g; } @@ -453,7 +453,7 @@ namespace boss { qi::rule quotedStr, filePath, comparator; qi::rule invalidPathChars; - boss::Game * game; + loot::Game * game; //Eval's exact paths. Check for files and ghosted plugins. void CheckFile(bool& result, const std::string& file) { @@ -467,7 +467,7 @@ namespace boss { if (!IsSafePath(file)) { BOOST_LOG_TRIVIAL(error) << "Invalid file path: " << file; - throw boss::error(boss::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file); + throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file); } if (IsPlugin(file)) @@ -515,7 +515,7 @@ namespace boss { if (boost::contains(parent, "../../")){ BOOST_LOG_TRIVIAL(error) << "Invalid folder path: " << parent; - throw boss::error(boss::error::invalid_args, boost::locale::translate("Invalid folder path:").str() + " " + parent); + throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid folder path:").str() + " " + parent); } //Now we have a valid parent path and a regex filename. Check that @@ -532,7 +532,7 @@ namespace boss { regex = boost::regex(filename, boost::regex::perl|boost::regex::icase); } catch (boost::regex_error& e) { BOOST_LOG_TRIVIAL(error) << "Invalid regex string:" << filename; - throw boss::error(boss::error::invalid_args, boost::locale::translate("Invalid regex string:").str() + " " + filename); + throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid regex string:").str() + " " + filename); } for (boost::filesystem::directory_iterator itr(parent_path); itr != boost::filesystem::directory_iterator(); ++itr) { @@ -550,7 +550,7 @@ namespace boss { if (!IsSafePath(file)) { BOOST_LOG_TRIVIAL(error) << "Invalid file path: " << file; - throw boss::error(boss::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file); + throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file); } uint32_t crc; @@ -627,7 +627,7 @@ namespace boss { BOOST_LOG_TRIVIAL(error) << "Expected \"" << what.tag << "\" at \"" << context << "\"."; - throw boss::error(boss::error::condition_eval_fail, (boost::format(boost::locale::translate("Expected \"%1%\" at \"%2%\".")) % what.tag % context).str()); + throw loot::error(loot::error::condition_eval_fail, (boost::format(boost::locale::translate("Expected \"%1%\" at \"%2%\".")) % what.tag % context).str()); } //Checks that the path (not regex) doesn't go outside any game folders. diff --git a/src/backend/streams.h b/src/backend/streams.h index d2e5aec0..22d23253 100644 --- a/src/backend/streams.h +++ b/src/backend/streams.h @@ -27,7 +27,7 @@ #include #include -namespace boss { +namespace loot { typedef boost::iostreams::stream< boost::iostreams::file_descriptor_sink > ofstream; typedef boost::iostreams::stream< boost::iostreams::file_descriptor_source > ifstream; typedef boost::iostreams::stream< boost::iostreams::file_descriptor > fstream; diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index c53fc49a..a5cf5871 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -53,16 +53,16 @@ bool TextDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString &data) { // Common Editor Class /////////////////////////////////// -CommonEditor::CommonEditor(const std::list& plugins, const boss::Game& game) : _basePlugins(plugins), _game(game) {} +CommonEditor::CommonEditor(const std::list& plugins, const loot::Game& game) : _basePlugins(plugins), _game(game) {} -CommonEditor::CommonEditor(const std::list& plugins, const boss::Game& game, std::list& editedPlugins) : _basePlugins(plugins), _game(game), _editedPlugins(editedPlugins) {} +CommonEditor::CommonEditor(const std::list& plugins, const loot::Game& game, std::list& editedPlugins) : _basePlugins(plugins), _game(game), _editedPlugins(editedPlugins) {} -boss::Plugin CommonEditor::GetMasterData(const wxString& plugin) const { +loot::Plugin CommonEditor::GetMasterData(const wxString& plugin) const { BOOST_LOG_TRIVIAL(debug) << "Getting hardcoded and masterlist metadata for plugin: " << plugin.ToUTF8(); - boss::Plugin p; - boss::Plugin p_in(string(plugin.ToUTF8())); + loot::Plugin p; + loot::Plugin p_in(string(plugin.ToUTF8())); - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), p_in); + list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), p_in); if (it != _basePlugins.end()) p = *it; @@ -70,11 +70,11 @@ boss::Plugin CommonEditor::GetMasterData(const wxString& plugin) const { return p; } -boss::Plugin CommonEditor::GetUserData(const wxString& plugin) const { +loot::Plugin CommonEditor::GetUserData(const wxString& plugin) const { BOOST_LOG_TRIVIAL(debug) << "Getting userlist metadata for plugin: " << plugin.ToUTF8(); - boss::Plugin p(string(plugin.ToUTF8())); + loot::Plugin p(string(plugin.ToUTF8())); - list::const_iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), p); + list::const_iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), p); if (it != _editedPlugins.end()) p = *it; @@ -86,12 +86,12 @@ void CommonEditor::ApplyEdits(const wxString& plugin, wxListView * wxList) { BOOST_LOG_TRIVIAL(debug) << "Applying edits to plugin: " << plugin.ToUTF8(); //Get recorded data. - boss::Plugin master(GetMasterData(plugin)); - boss::Plugin edited(GetNewData(plugin)); + loot::Plugin master(GetMasterData(plugin)); + loot::Plugin edited(GetNewData(plugin)); - boss::Plugin diff = master.DiffMetadata(edited); + loot::Plugin diff = master.DiffMetadata(edited); - list::iterator pos = std::find(_editedPlugins.begin(), _editedPlugins.end(), diff); + list::iterator pos = std::find(_editedPlugins.begin(), _editedPlugins.end(), diff); long i = wxList->FindItem(-1, plugin); if (!diff.HasNameOnly()) { @@ -108,35 +108,35 @@ void CommonEditor::ApplyEdits(const wxString& plugin, wxListView * wxList) { } } -boss::File CommonEditor::RowToFile(wxListView * list, long row) const { - return boss::File( +loot::File CommonEditor::RowToFile(wxListView * list, long row) const { + return loot::File( string(list->GetItemText(row, 0).ToUTF8()), string(list->GetItemText(row, 1).ToUTF8()), string(list->GetItemText(row, 2).ToUTF8()) ); } -boss::Tag CommonEditor::RowToTag(wxListView * list, long row) const { +loot::Tag CommonEditor::RowToTag(wxListView * list, long row) const { string name = string(list->GetItemText(row, 1).ToUTF8()); if (list->GetItemText(row, 0) == State[1]) - return boss::Tag( + return loot::Tag( name, false, string(list->GetItemText(row, 2).ToUTF8()) ); else - return boss::Tag( + return loot::Tag( name, true, string(list->GetItemText(row, 2).ToUTF8()) ); } -boss::PluginDirtyInfo CommonEditor::RowToPluginDirtyInfo(wxListView * list, long row) const { +loot::PluginDirtyInfo CommonEditor::RowToPluginDirtyInfo(wxListView * list, long row) const { string text(list->GetItemText(row, 0).ToUTF8()); uint32_t crc = strtoul(text.c_str(), NULL, 16); - return boss::PluginDirtyInfo( + return loot::PluginDirtyInfo( crc, atoi(string(list->GetItemText(row, 1).ToUTF8()).c_str()), atoi(string(list->GetItemText(row, 2).ToUTF8()).c_str()), @@ -150,7 +150,7 @@ boss::PluginDirtyInfo CommonEditor::RowToPluginDirtyInfo(wxListView * list, long /////////////////////////////////// -MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, const std::list& plugins, const boss::Game& game) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), CommonEditor(plugins, game) { +MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, const std::list& plugins, const loot::Game& game) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), CommonEditor(plugins, game) { //Initialise editing panel. editingPanel = new wxPanel(this, wxID_ANY); @@ -239,9 +239,9 @@ MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, const std::list< //Fill pluginList with the contents of basePlugins. int i = 0; - for (list::const_iterator it = _basePlugins.begin(); it != _basePlugins.end(); ++it) { + for (list::const_iterator it = _basePlugins.begin(); it != _basePlugins.end(); ++it) { pluginList->InsertItem(i, FromUTF8(it->Name())); - pluginList->SetItem(i, 1, FromUTF8(boss::IntToString(it->Priority()))); + pluginList->SetItem(i, 1, FromUTF8(loot::IntToString(it->Priority()))); if (it->FormIDs().empty()) { pluginList->SetItemTextColour(i, wxColour(122, 122, 122)); } @@ -274,11 +274,11 @@ void MiniEditor::OnPluginSelect(wxListEvent& event) { if (!currentPlugin.empty()) { ApplyEdits(currentPlugin, pluginList); //Also update the item's priority value in the plugins list in case it has changed. - pluginList->SetItem(pluginList->FindItem(-1, currentPlugin), 1, FromUTF8(boss::IntToString(prioritySpin->GetValue()))); + pluginList->SetItem(pluginList->FindItem(-1, currentPlugin), 1, FromUTF8(loot::IntToString(prioritySpin->GetValue()))); } //Merge metadata. - boss::Plugin plugin = GetMasterData(selectedPlugin); + loot::Plugin plugin = GetMasterData(selectedPlugin); plugin.MergeMetadata(GetUserData(selectedPlugin)); //Now fill editor fields with new plugin's info and update control states. @@ -288,9 +288,9 @@ void MiniEditor::OnPluginSelect(wxListEvent& event) { prioritySpin->SetValue(plugin.Priority()); loadAfterList->DeleteAllItems(); - set files = plugin.LoadAfter(); + set files = plugin.LoadAfter(); int i = 0; - for (set::const_iterator it = files.begin(), endit = files.end(); it != endit; ++it) { + for (set::const_iterator it = files.begin(), endit = files.end(); it != endit; ++it) { loadAfterList->InsertItem(i, FromUTF8(it->Name())); ++i; } @@ -331,9 +331,9 @@ void MiniEditor::OnPluginSelect(wxListEvent& event) { void MiniEditor::OnFilterToggle(wxCommandEvent& event) { //First need to merge the base and edited plugin lists so that the right priority values get displayed. - list plugins(_basePlugins); - for (list::const_iterator it = _editedPlugins.begin(); it != _editedPlugins.end(); ++it) { - list::iterator pos = std::find(plugins.begin(), plugins.end(), *it); + list plugins(_basePlugins); + for (list::const_iterator it = _editedPlugins.begin(); it != _editedPlugins.end(); ++it) { + list::iterator pos = std::find(plugins.begin(), plugins.end(), *it); pos->MergeMetadata(*it); } @@ -345,8 +345,8 @@ void MiniEditor::OnFilterToggle(wxCommandEvent& event) { pluginList->Freeze(); if (event.IsChecked()) { - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator pos = std::find(plugins.begin(), plugins.end(), plugin); + loot::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); + list::const_iterator pos = std::find(plugins.begin(), plugins.end(), plugin); if (pos != plugins.end()) { pluginList->DeleteAllItems(); @@ -354,12 +354,12 @@ void MiniEditor::OnFilterToggle(wxCommandEvent& event) { bool loadsBSA = pos->LoadsBSA(_game); int i = 0; - for (list::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { + for (list::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { //Want to filter to show only those the selected plugin can load after validly, and which also either conflict with it, //or which load a BSA (if the selected plugin loads a BSA). if (*it == *pos || !it->MustLoadAfter(*pos) && (pos->DoFormIDsOverlap(*it) || (loadsBSA && it->LoadsBSA(_game)))) { pluginList->InsertItem(i, FromUTF8(it->Name())); - pluginList->SetItem(i, 1, FromUTF8(boss::IntToString(it->Priority()))); + pluginList->SetItem(i, 1, FromUTF8(loot::IntToString(it->Priority()))); if (it->FormIDs().empty()) { pluginList->SetItemTextColour(i, wxColour(122, 122, 122)); } @@ -377,9 +377,9 @@ void MiniEditor::OnFilterToggle(wxCommandEvent& event) { else { pluginList->DeleteAllItems(); int i = 0; - for (list::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { + for (list::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { pluginList->InsertItem(i, FromUTF8(it->Name())); - pluginList->SetItem(i, 1, FromUTF8(boss::IntToString(it->Priority()))); + pluginList->SetItem(i, 1, FromUTF8(loot::IntToString(it->Priority()))); if (it->FormIDs().empty()) { pluginList->SetItemTextColour(i, wxColour(122, 122, 122)); } @@ -400,17 +400,17 @@ void MiniEditor::OnFilterToggle(wxCommandEvent& event) { } void MiniEditor::OnRowSelect(wxListEvent& event) { - boss::File file(string(loadAfterList->GetItemText(event.GetIndex(), 0).ToUTF8())); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); + loot::File file(string(loadAfterList->GetItemText(event.GetIndex(), 0).ToUTF8())); + loot::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); + list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); if (it != _basePlugins.end()) plugin = *it; else BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - set loadAfter = plugin.LoadAfter(); + set loadAfter = plugin.LoadAfter(); if (loadAfter.find(file) == loadAfter.end()) { BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Removal enabled."; @@ -443,15 +443,15 @@ void MiniEditor::OnApply(wxCommandEvent& event) { EndModal(event.GetId()); } -const std::list& MiniEditor::GetEditedPlugins() const { +const std::list& MiniEditor::GetEditedPlugins() const { return _editedPlugins; } -boss::Plugin MiniEditor::GetNewData(const wxString& plugin) const { +loot::Plugin MiniEditor::GetNewData(const wxString& plugin) const { //Get new data. Because most of it is missing in the MiniEditor, start with the existing data. - boss::Plugin edited(GetMasterData(plugin)); + loot::Plugin edited(GetMasterData(plugin)); edited.Priority(prioritySpin->GetValue()); - set files; + set files; for (int i = 0, max = loadAfterList->GetItemCount(); i < max; ++i) { files.insert(RowToFile(loadAfterList, i)); } @@ -470,7 +470,7 @@ void MiniEditor::OnResize(wxSizeEvent& event) { // Editor Class /////////////////////////////////// -Editor::Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const boss::Game& game) : wxFrame(parent, wxID_ANY, title), _userlistPath(userlistPath), CommonEditor(basePlugins, game, editedPlugins) { +Editor::Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game) : wxFrame(parent, wxID_ANY, title), _userlistPath(userlistPath), CommonEditor(basePlugins, game, editedPlugins) { //Initialise child windows. listBook = new wxNotebook(this, BOOK_Lists); @@ -641,7 +641,7 @@ Editor::Editor(wxWindow *parent, const wxString& title, const std::string userli //Fill pluginList with the contents of basePlugins. int i = 0; - for (list::const_iterator it = _basePlugins.begin(); it != _basePlugins.end(); ++it) { + for (list::const_iterator it = _basePlugins.begin(); it != _basePlugins.end(); ++it) { pluginList->InsertItem(i, FromUTF8(it->Name())); if (it->LoadsBSA(_game)) { pluginList->SetItemTextColour(i, wxColour(0, 142, 219)); @@ -673,7 +673,7 @@ void Editor::OnPluginSelect(wxListEvent& event) { ApplyEdits(currentPlugin, pluginList); //Merge metadata. - boss::Plugin plugin = GetMasterData(selectedPlugin); + loot::Plugin plugin = GetMasterData(selectedPlugin); plugin.MergeMetadata(GetUserData(selectedPlugin)); //Now fill editor fields with new plugin's info and update control states. @@ -691,9 +691,9 @@ void Editor::OnPluginSelect(wxListEvent& event) { tagsList->DeleteAllItems(); dirtyList->DeleteAllItems(); - set files = plugin.LoadAfter(); + set files = plugin.LoadAfter(); int i=0; - for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { + for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { loadAfterList->InsertItem(i, FromUTF8(it->Name())); loadAfterList->SetItem(i, 1, FromUTF8(it->DisplayName())); loadAfterList->SetItem(i, 2, FromUTF8(it->Condition())); @@ -706,7 +706,7 @@ void Editor::OnPluginSelect(wxListEvent& event) { files = plugin.Reqs(); i=0; - for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { + for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { reqsList->InsertItem(i, FromUTF8(it->Name())); reqsList->SetItem(i, 1, FromUTF8(it->DisplayName())); reqsList->SetItem(i, 2, FromUTF8(it->Condition())); @@ -719,7 +719,7 @@ void Editor::OnPluginSelect(wxListEvent& event) { files = plugin.Incs(); i=0; - for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { + for (set::const_iterator it=files.begin(), endit=files.end(); it != endit; ++it) { incsList->InsertItem(i, FromUTF8(it->Name())); incsList->SetItem(i, 1, FromUTF8(it->DisplayName())); incsList->SetItem(i, 2, FromUTF8(it->Condition())); @@ -730,13 +730,13 @@ void Editor::OnPluginSelect(wxListEvent& event) { else incsList->SetColumnWidth(0, wxLIST_AUTOSIZE); - list messages = plugin.Messages(); - vector vec(messages.begin(), messages.end()); + list messages = plugin.Messages(); + vector vec(messages.begin(), messages.end()); messageList->SetItems(vec); - set tags = plugin.Tags(); + set tags = plugin.Tags(); i=0; - for (set::const_iterator it=tags.begin(), endit=tags.end(); it != endit; ++it) { + for (set::const_iterator it=tags.begin(), endit=tags.end(); it != endit; ++it) { if (it->IsAddition()) tagsList->InsertItem(i, State[0]); else @@ -750,13 +750,13 @@ void Editor::OnPluginSelect(wxListEvent& event) { else tagsList->SetColumnWidth(0, wxLIST_AUTOSIZE); - set dirtyInfo = plugin.DirtyInfo(); + set dirtyInfo = plugin.DirtyInfo(); i=0; - for (set::const_iterator it=dirtyInfo.begin(), endit=dirtyInfo.end(); it != endit; ++it) { - dirtyList->InsertItem(i, FromUTF8(boss::IntToHexString(it->CRC()))); - dirtyList->SetItem(i, 1, FromUTF8(boss::IntToString(it->ITMs()))); - dirtyList->SetItem(i, 2, FromUTF8(boss::IntToString(it->UDRs()))); - dirtyList->SetItem(i, 3, FromUTF8(boss::IntToString(it->DeletedNavmeshes()))); + for (set::const_iterator it=dirtyInfo.begin(), endit=dirtyInfo.end(); it != endit; ++it) { + dirtyList->InsertItem(i, FromUTF8(loot::IntToHexString(it->CRC()))); + dirtyList->SetItem(i, 1, FromUTF8(loot::IntToString(it->ITMs()))); + dirtyList->SetItem(i, 2, FromUTF8(loot::IntToString(it->UDRs()))); + dirtyList->SetItem(i, 3, FromUTF8(loot::IntToString(it->DeletedNavmeshes()))); dirtyList->SetItem(i, 4, FromUTF8(it->CleaningUtility())); ++i; } @@ -788,7 +788,7 @@ void Editor::OnPluginCopyName(wxCommandEvent& event) { void Editor::OnPluginCopyMetadata(wxCommandEvent& event) { wxString selectedPlugin = pluginList->GetItemText(pluginList->GetFirstSelected()); - boss::Plugin plugin = GetUserData(selectedPlugin); + loot::Plugin plugin = GetUserData(selectedPlugin); string text; if (plugin.HasNameOnly()) @@ -817,11 +817,11 @@ void Editor::OnPluginClearMetadata(wxCommandEvent& event) { if (dialog.ShowModal() == wxID_YES) { long i = pluginList->GetFirstSelected(); wxString selectedPlugin = pluginList->GetItemText(i); - boss::Plugin p(string(selectedPlugin.ToUTF8())); + loot::Plugin p(string(selectedPlugin.ToUTF8())); //Need to clear what's currently in the editor and what's from the userlist. - list::const_iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), p); + list::const_iterator it = std::find(_editedPlugins.begin(), _editedPlugins.end(), p); //Delete existing userlist entry. if (it != _editedPlugins.end()) @@ -940,9 +940,9 @@ void Editor::OnAddRow(wxCommandEvent& event) { long i = tagsList->GetItemCount(); dirtyList->InsertItem(i, rowDialog->GetCRC()); - dirtyList->SetItem(i, 1, FromUTF8(boss::IntToString(rowDialog->GetITMs()))); - dirtyList->SetItem(i, 2, FromUTF8(boss::IntToString(rowDialog->GetUDRs()))); - dirtyList->SetItem(i, 3, FromUTF8(boss::IntToString(rowDialog->GetDeletedNavmeshes()))); + dirtyList->SetItem(i, 1, FromUTF8(loot::IntToString(rowDialog->GetITMs()))); + dirtyList->SetItem(i, 2, FromUTF8(loot::IntToString(rowDialog->GetUDRs()))); + dirtyList->SetItem(i, 3, FromUTF8(loot::IntToString(rowDialog->GetDeletedNavmeshes()))); dirtyList->SetItem(i, 4, rowDialog->GetUtility()); } } @@ -1036,9 +1036,9 @@ void Editor::OnEditRow(wxCommandEvent& event) { } dirtyList->SetItem(i, 0, rowDialog->GetCRC()); - dirtyList->SetItem(i, 1, FromUTF8(boss::IntToString(rowDialog->GetITMs()))); - dirtyList->SetItem(i, 2, FromUTF8(boss::IntToString(rowDialog->GetUDRs()))); - dirtyList->SetItem(i, 3, FromUTF8(boss::IntToString(rowDialog->GetDeletedNavmeshes()))); + dirtyList->SetItem(i, 1, FromUTF8(loot::IntToString(rowDialog->GetITMs()))); + dirtyList->SetItem(i, 2, FromUTF8(loot::IntToString(rowDialog->GetUDRs()))); + dirtyList->SetItem(i, 3, FromUTF8(loot::IntToString(rowDialog->GetDeletedNavmeshes()))); dirtyList->SetItem(i, 4, rowDialog->GetUtility()); } } @@ -1067,17 +1067,17 @@ void Editor::OnRowSelect(wxListEvent& event) { if (event.GetId() == LIST_Reqs) { //Create File object, search the masterlist vector for the plugin and search its reqs for this object. - boss::File file = RowToFile(reqsList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); + loot::File file = RowToFile(reqsList, event.GetIndex()); + loot::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); + list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); if (it != _basePlugins.end()) plugin = *it; else BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - set reqs = plugin.Reqs(); + set reqs = plugin.Reqs(); if (reqs.find(file) == reqs.end()) { BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled."; @@ -1091,17 +1091,17 @@ void Editor::OnRowSelect(wxListEvent& event) { } else if (event.GetId() == LIST_Incs) { - boss::File file = RowToFile(incsList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); + loot::File file = RowToFile(incsList, event.GetIndex()); + loot::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); + list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); if (it != _basePlugins.end()) plugin = *it; else BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - set incs = plugin.Incs(); + set incs = plugin.Incs(); if (incs.find(file) == incs.end()) { BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled."; @@ -1115,17 +1115,17 @@ void Editor::OnRowSelect(wxListEvent& event) { } else if (event.GetId() == LIST_LoadAfter) { - boss::File file = RowToFile(loadAfterList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); + loot::File file = RowToFile(loadAfterList, event.GetIndex()); + loot::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); + list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); if (it != _basePlugins.end()) plugin = *it; else BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - set loadAfter = plugin.LoadAfter(); + set loadAfter = plugin.LoadAfter(); if (loadAfter.find(file) == loadAfter.end()) { BOOST_LOG_TRIVIAL(trace) << "File \"" << file.Name() << "\" was not found in base plugin metadata. Editing enabled."; @@ -1139,41 +1139,41 @@ void Editor::OnRowSelect(wxListEvent& event) { } else if (event.GetId() == LIST_Messages) { - boss::Message message = messageList->GetItem(event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); + loot::Message message = messageList->GetItem(event.GetIndex()); + loot::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); + list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); if (it != _basePlugins.end()) plugin = *it; else BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - list messages = plugin.Messages(); + list messages = plugin.Messages(); if (find(messages.begin(), messages.end(), message) == messages.end()) { - BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(boss::g_lang_any).Str() << "\" was not found in base plugin metadata. Editing enabled."; + BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(loot::g_lang_any).Str() << "\" was not found in base plugin metadata. Editing enabled."; editBtn->Enable(true); removeBtn->Enable(true); } else { - BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(boss::g_lang_any).Str() << "\" was found in base plugin metadata. Editing disabled."; + BOOST_LOG_TRIVIAL(trace) << "Message \"" << message.ChooseContent(loot::g_lang_any).Str() << "\" was found in base plugin metadata. Editing disabled."; editBtn->Enable(false); removeBtn->Enable(false); } } else if (event.GetId() == LIST_BashTags) { - boss::Tag tag = RowToTag(tagsList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); + loot::Tag tag = RowToTag(tagsList, event.GetIndex()); + loot::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); + list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); if (it != _basePlugins.end()) plugin = *it; else BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - set tags = plugin.Tags(); + set tags = plugin.Tags(); if (tags.find(tag) == tags.end()) { BOOST_LOG_TRIVIAL(trace) << "Bash Tag \"" << tag.Name() << "\" was not found in base plugin metadata. Editing enabled."; @@ -1186,17 +1186,17 @@ void Editor::OnRowSelect(wxListEvent& event) { } } else { - boss::PluginDirtyInfo dirtyData = RowToPluginDirtyInfo(dirtyList, event.GetIndex()); - boss::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); + loot::PluginDirtyInfo dirtyData = RowToPluginDirtyInfo(dirtyList, event.GetIndex()); + loot::Plugin plugin(string(pluginText->GetLabelText().ToUTF8())); - list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); + list::const_iterator it = std::find(_basePlugins.begin(), _basePlugins.end(), plugin); if (it != _basePlugins.end()) plugin = *it; else BOOST_LOG_TRIVIAL(warning) << "Could not find plugin in base list: " << plugin.Name(); - set dirtyInfo = plugin.DirtyInfo(); + set dirtyInfo = plugin.DirtyInfo(); if (dirtyInfo.find(dirtyData) == dirtyInfo.end()) { BOOST_LOG_TRIVIAL(trace) << "Dirty info for CRC \"" << dirtyData.CRC() << "\" was not found in base plugin metadata. Editing enabled."; @@ -1229,21 +1229,21 @@ void Editor::OnQuit(wxCommandEvent& event) { << YAML::EndMap; boost::filesystem::path p(_userlistPath); - boss::ofstream out(p); + loot::ofstream out(p); out << yout.c_str(); out.close(); } Close(); } -boss::Plugin Editor::GetNewData(const wxString& plugin) const { +loot::Plugin Editor::GetNewData(const wxString& plugin) const { BOOST_LOG_TRIVIAL(debug) << "Getting metadata from editor fields for plugin: " << plugin.ToUTF8(); - boss::Plugin p(string(plugin.ToUTF8())); + loot::Plugin p(string(plugin.ToUTF8())); p.Priority(prioritySpin->GetValue()); p.Enabled(enableUserEditsBox->IsChecked()); - set files; + set files; for (int i=0,max=reqsList->GetItemCount(); i < max; ++i) { files.insert(RowToFile(reqsList, i)); } @@ -1261,20 +1261,20 @@ boss::Plugin Editor::GetNewData(const wxString& plugin) const { } p.LoadAfter(files); - set tags; + set tags; for (int i=0,max=tagsList->GetItemCount(); i < max; ++i) { tags.insert(RowToTag(tagsList, i)); } p.Tags(tags); - set dirtyInfo; + set dirtyInfo; for (int i=0,max=dirtyList->GetItemCount(); i < max; ++i) { dirtyInfo.insert(RowToPluginDirtyInfo(dirtyList, i)); } p.DirtyInfo(dirtyInfo); - vector vec = messageList->GetItems(); - list messages(vec.begin(), vec.end()); + vector vec = messageList->GetItems(); + list messages(vec.begin(), vec.end()); p.Messages(messages); return p; diff --git a/src/gui/editor.h b/src/gui/editor.h index e87e9620..8fbb8070 100644 --- a/src/gui/editor.h +++ b/src/gui/editor.h @@ -63,27 +63,27 @@ private: class CommonEditor { public: - CommonEditor(const std::list& plugins, const boss::Game& game); - CommonEditor(const std::list& plugins, const boss::Game& game, std::list& editedPlugins); + CommonEditor(const std::list& plugins, const loot::Game& game); + CommonEditor(const std::list& plugins, const loot::Game& game, std::list& editedPlugins); protected: - const boss::Game& _game; - const std::list _basePlugins; - std::list _editedPlugins; + const loot::Game& _game; + const std::list _basePlugins; + std::list _editedPlugins; - boss::Plugin GetMasterData(const wxString& plugin) const; - boss::Plugin GetUserData(const wxString& plugin) const; - virtual boss::Plugin GetNewData(const wxString& plugin) const = 0; + loot::Plugin GetMasterData(const wxString& plugin) const; + loot::Plugin GetUserData(const wxString& plugin) const; + virtual loot::Plugin GetNewData(const wxString& plugin) const = 0; void ApplyEdits(const wxString& plugin, wxListView * list); - boss::File RowToFile(wxListView * list, long row) const; - boss::Tag RowToTag(wxListView * list, long row) const; - boss::PluginDirtyInfo RowToPluginDirtyInfo(wxListView * list, long row) const; + loot::File RowToFile(wxListView * list, long row) const; + loot::Tag RowToTag(wxListView * list, long row) const; + loot::PluginDirtyInfo RowToPluginDirtyInfo(wxListView * list, long row) const; }; class MiniEditor : public wxDialog, public CommonEditor { public: - MiniEditor(wxWindow *parent, const wxString& title, const std::list& plugins, const boss::Game& game); + MiniEditor(wxWindow *parent, const wxString& title, const std::list& plugins, const loot::Game& game); void OnPluginSelect(wxListEvent& event); void OnRowSelect(wxListEvent& event); @@ -93,7 +93,7 @@ public: void OnApply(wxCommandEvent& event); void OnResize(wxSizeEvent& event); - const std::list& GetEditedPlugins() const; + const std::list& GetEditedPlugins() const; private: wxListView * pluginList; wxPanel * editingPanel; @@ -104,12 +104,12 @@ private: wxStaticText * pluginText; wxStaticText * descText; - boss::Plugin GetNewData(const wxString& plugin) const; + loot::Plugin GetNewData(const wxString& plugin) const; }; class Editor : public wxFrame, public CommonEditor { public: - Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const boss::Game& game); + Editor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game); void OnPluginSelect(wxListEvent& event); void OnPluginListRightClick(wxListEvent& event); @@ -143,6 +143,6 @@ private: const std::string _userlistPath; - boss::Plugin GetNewData(const wxString& plugin) const; + loot::Plugin GetNewData(const wxString& plugin) const; }; #endif diff --git a/src/gui/main.cpp b/src/gui/main.cpp index e3720209..fda880ee 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -65,7 +65,7 @@ wxIMPLEMENT_APP(BossGUI); -using namespace boss; +using namespace loot; using namespace std; using boost::format; @@ -74,38 +74,38 @@ namespace loc = boost::locale; struct plugin_loader { - plugin_loader(boss::Plugin& plugin, boss::Game& game) : _plugin(plugin), _game(game) { + plugin_loader(loot::Plugin& plugin, loot::Game& game) : _plugin(plugin), _game(game) { } void operator () () { - _plugin = boss::Plugin(_game, _plugin.Name(), false); + _plugin = loot::Plugin(_game, _plugin.Name(), false); } - boss::Plugin& _plugin; - boss::Game& _game; + loot::Plugin& _plugin; + loot::Game& _game; string _filename; bool _b; }; struct plugin_list_loader { - plugin_list_loader(PluginGraph& graph, boss::Game& game) : _graph(graph), _game(game) {} + plugin_list_loader(PluginGraph& graph, loot::Game& game) : _graph(graph), _game(game) {} void operator () () { - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(_graph); vit != vitend; ++vit) { if (skipPlugins.find(_graph[*vit].Name()) == skipPlugins.end()) { - _graph[*vit] = boss::Plugin(_game, _graph[*vit].Name(), false); + _graph[*vit] = loot::Plugin(_game, _graph[*vit].Name(), false); } } } PluginGraph& _graph; - boss::Game& _game; + loot::Game& _game; set skipPlugins; }; struct masterlist_updater_parser { - masterlist_updater_parser(bool doUpdate, boss::Game& game, list& errors, list& plugins, list& messages, string& revision) : _doUpdate(doUpdate), _game(game), _errors(errors), _plugins(plugins), _messages(messages), _revision(revision) {} + masterlist_updater_parser(bool doUpdate, loot::Game& game, list& errors, list& plugins, list& messages, string& revision) : _doUpdate(doUpdate), _game(game), _errors(errors), _plugins(plugins), _messages(messages), _revision(revision) {} void operator () () { @@ -113,11 +113,11 @@ struct masterlist_updater_parser { BOOST_LOG_TRIVIAL(debug) << "Updating masterlist"; try { _revision = UpdateMasterlist(_game, _errors, _plugins, _messages); - } catch (boss::error& e) { + } catch (loot::error& e) { _plugins.clear(); _messages.clear(); BOOST_LOG_TRIVIAL(error) << "Masterlist update failed. Details: " << e.what(); - _errors.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Masterlist update failed. Details: %1%")) % e.what()).str())); + _errors.push_back(loot::Message(loot::g_message_error, (format(loc::translate("Masterlist update failed. Details: %1%")) % e.what()).str())); } } @@ -125,17 +125,17 @@ struct masterlist_updater_parser { BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist..."; try { - boss::ifstream in(_game.MasterlistPath()); + loot::ifstream in(_game.MasterlistPath()); YAML::Node mlist = YAML::Load(in); in.close(); if (mlist["globals"]) - _messages = mlist["globals"].as< list >(); + _messages = mlist["globals"].as< list >(); if (mlist["plugins"]) - _plugins = mlist["plugins"].as< list >(); + _plugins = mlist["plugins"].as< list >(); } catch (YAML::Exception& e) { BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. Details: " << e.what(); - _errors.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Masterlist parsing failed. Details: %1%")) % e.what()).str())); + _errors.push_back(loot::Message(loot::g_message_error, (format(loc::translate("Masterlist parsing failed. Details: %1%")) % e.what()).str())); } BOOST_LOG_TRIVIAL(debug) << "Finished parsing masterlist."; @@ -150,10 +150,10 @@ struct masterlist_updater_parser { } bool _doUpdate; - boss::Game& _game; - list& _errors; - list& _plugins; - list& _messages; + loot::Game& _game; + list& _errors; + list& _plugins; + list& _messages; string& _revision; }; @@ -191,7 +191,7 @@ bool BossGUI::OnInit() { } if (fs::exists(g_path_settings)) { try { - boss::ifstream in(g_path_settings); + loot::ifstream in(g_path_settings); _settings = YAML::Load(in); in.close(); } catch (YAML::ParserException& e) { @@ -235,32 +235,32 @@ bool BossGUI::OnInit() { //Set the locale to get encoding and language conversions working correctly. BOOST_LOG_TRIVIAL(debug) << "Initialising language settings."; //Defaults in case language string is empty or setting is missing. - string localeId = boss::Language(boss::g_lang_any).Locale() + ".UTF-8"; + string localeId = loot::Language(loot::g_lang_any).Locale() + ".UTF-8"; wxLanguage wxLang = wxLANGUAGE_ENGLISH; if (_settings["Language"]) { - boss::Language lang(_settings["Language"].as()); + loot::Language lang(_settings["Language"].as()); BOOST_LOG_TRIVIAL(debug) << "Selected language: " << lang.Name(); localeId = lang.Locale() + ".UTF-8"; - if (lang.Code() == boss::g_lang_english) + if (lang.Code() == loot::g_lang_english) wxLang = wxLANGUAGE_ENGLISH; - else if (lang.Code() == boss::g_lang_spanish) + else if (lang.Code() == loot::g_lang_spanish) wxLang = wxLANGUAGE_SPANISH; - else if (lang.Code() == boss::g_lang_russian) + else if (lang.Code() == loot::g_lang_russian) wxLang = wxLANGUAGE_RUSSIAN; - else if (lang.Code() == boss::g_lang_french) + else if (lang.Code() == loot::g_lang_french) wxLang = wxLANGUAGE_FRENCH; - else if (lang.Code() == boss::g_lang_chinese) + else if (lang.Code() == loot::g_lang_chinese) wxLang = wxLANGUAGE_CHINESE; - else if (lang.Code() == boss::g_lang_polish) + else if (lang.Code() == loot::g_lang_polish) wxLang = wxLANGUAGE_POLISH; - else if (lang.Code() == boss::g_lang_brazilian_portuguese) + else if (lang.Code() == loot::g_lang_brazilian_portuguese) wxLang = wxLANGUAGE_PORTUGUESE_BRAZILIAN; } //Boost.Locale initialisation: Specify location of language dictionaries. boost::locale::generator gen; gen.add_messages_path(g_path_l10n.string()); - gen.add_messages_domain("boss"); + gen.add_messages_domain("loot"); //Boost.Locale initialisation: Generate and imbue locales. locale::global(gen(localeId)); @@ -299,7 +299,7 @@ bool BossGUI::OnInit() { BOOST_LOG_TRIVIAL(debug) << "Detecting installed games."; try { _games = GetGames(_settings); - } catch (boss::error& e) { + } catch (loot::error& e) { BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what(); wxMessageBox( FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()), @@ -355,7 +355,7 @@ bool BossGUI::OnInit() { try { _game.Init(); *find(_games.begin(), _games.end(), _game) = _game; //Sync changes. - } catch (boss::error& e) { + } catch (loot::error& e) { BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what(); wxMessageBox( FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()), @@ -376,7 +376,7 @@ bool BossGUI::OnInit() { return true; } -Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, vector& games) : wxFrame(NULL, wxID_ANY, title), _game(game), _settings(settings), _games(games) { +Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, vector& games) : wxFrame(NULL, wxID_ANY, title), _game(game), _settings(settings), _games(games) { //Initialise menu items. wxMenuBar * MenuBar = new wxMenuBar(); @@ -453,7 +453,7 @@ Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game& game, vector if (!fs::exists(_game.ReportPath())) ViewButton->Enable(false); - if (_game.Id() == boss::g_game_tes5) + if (_game.Id() == loot::g_game_tes5) RedatePluginsItem->Enable(true); else RedatePluginsItem->Enable(false); @@ -489,7 +489,7 @@ void Launcher::OnClose(wxCloseEvent& event) { yout.SetIndent(2); yout << _settings; - boss::ofstream out(boss::g_path_settings); + loot::ofstream out(loot::g_path_settings); out << yout.c_str(); out.close(); @@ -525,7 +525,7 @@ void Launcher::OnGameChange(wxCommandEvent& event) { *find(_games.begin(), _games.end(), _game) = _game; //Sync changes. BOOST_LOG_TRIVIAL(debug) << "New game is " << _game.Name(); } - catch (boss::error& e) { + catch (loot::error& e) { BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised." << e.what(); wxMessageBox( FromUTF8(format(loc::translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()), @@ -534,7 +534,7 @@ void Launcher::OnGameChange(wxCommandEvent& event) { NULL); } SetTitle(FromUTF8("LOOT - " + _game.Name())); - if (_game.Id() == boss::g_game_tes5) + if (_game.Id() == loot::g_game_tes5) RedatePluginsItem->Enable(true); else RedatePluginsItem->Enable(false); @@ -601,11 +601,11 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(debug) << "Beginning sorting process."; YAML::Node mlist, ulist; - list messages, mlist_messages, ulist_messages; - list mlist_plugins, ulist_plugins; - list plugins; + list messages, mlist_messages, ulist_messages; + list mlist_plugins, ulist_plugins; + list plugins; boost::thread_group group; - boss::PluginGraph graph; + loot::PluginGraph graph; string revision; wxProgressDialog *progDia = new wxProgressDialog(translate("LOOT: Working..."),translate("LOOT working..."), 1000, this, wxPD_APP_MODAL|wxPD_AUTO_HIDE|wxPD_ELAPSED_TIME); @@ -628,7 +628,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { meanFileSize += fileSize; tempMap.emplace(it->path().filename().string(), fileSize); - plugins.push_back(boss::Plugin(it->path().filename().string())); //Just in case there's an error with the graph. + plugins.push_back(loot::Plugin(it->path().filename().string())); //Just in case there's an error with the graph. } } meanFileSize /= tempMap.size(); @@ -639,7 +639,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(trace) << "Found plugin: " << it->first; - vertex_t v = boost::add_vertex(boss::Plugin(it->first), graph); + vertex_t v = boost::add_vertex(loot::Plugin(it->first), graph); if (it->second > meanFileSize) { pll.skipPlugins.insert(it->first); @@ -657,18 +657,18 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(debug) << "Parsing userlist at: " << _game.UserlistPath(); try { - boss::ifstream in(_game.UserlistPath()); + loot::ifstream in(_game.UserlistPath()); YAML::Node ulist = YAML::Load(in); in.close(); if (ulist["plugins"]) - ulist_plugins = ulist["plugins"].as< list >(); + ulist_plugins = ulist["plugins"].as< list >(); } catch (YAML::ParserException& e) { BOOST_LOG_TRIVIAL(error) << "Userlist parsing failed. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Userlist parsing failed. Details: %1%")) % e.what()).str())); + messages.push_back(loot::Message(loot::g_message_error, (format(loc::translate("Userlist parsing failed. Details: %1%")) % e.what()).str())); } if (ulist["plugins"]) - ulist_plugins = ulist["plugins"].as< list >(); + ulist_plugins = ulist["plugins"].as< list >(); } progDia->Pulse(); @@ -684,7 +684,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { if (_settings["Language"]) lang = Language(_settings["Language"].as()).Code(); else - lang = boss::g_lang_any; + lang = loot::g_lang_any; //Merge all global message lists. @@ -697,26 +697,26 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { //Evaluate any conditions in the global messages. BOOST_LOG_TRIVIAL(trace) << "Evaluating global message conditions."; try { - list::iterator it=messages.begin(); + list::iterator it=messages.begin(); while (it != messages.end()) { if (!it->EvalCondition(_game, lang)) it = messages.erase(it); else ++it; } - } catch (boss::error& e) { + } catch (loot::error& e) { BOOST_LOG_TRIVIAL(error) << "A global message contains a condition that could not be evaluated. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str())); + messages.push_back(loot::Message(loot::g_message_error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str())); } //Merge plugin list, masterlist and userlist plugin data. BOOST_LOG_TRIVIAL(debug) << "Merging plugin list, masterlist and userlist data, evaluating conditions and checking for install validity."; - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { BOOST_LOG_TRIVIAL(trace) << "Merging for plugin \"" << graph[*vit].Name() << "\""; //Check if there is a plugin entry in the masterlist. This will also find matching regex entries. - list::iterator pos = std::find(mlist_plugins.begin(), mlist_plugins.end(), graph[*vit]); + list::iterator pos = std::find(mlist_plugins.begin(), mlist_plugins.end(), graph[*vit]); if (pos != mlist_plugins.end()) { BOOST_LOG_TRIVIAL(trace) << "Merging masterlist data down to plugin list data."; @@ -737,9 +737,9 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(trace) << "Evaluate conditions for merged plugin data."; try { graph[*vit].EvalAllConditions(_game, lang); - } catch (boss::error& e) { + } catch (loot::error& e) { BOOST_LOG_TRIVIAL(error) << "\"" << graph[*vit].Name() << "\" contains a condition that could not be evaluated. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("\"%1%\" contains a condition that could not be evaluated. Details: %2%")) % graph[*vit].Name() % e.what()).str())); + messages.push_back(loot::Message(loot::g_message_error, (format(loc::translate("\"%1%\" contains a condition that could not be evaluated. Details: %2%")) % graph[*vit].Name() % e.what()).str())); } progDia->Pulse(); @@ -747,9 +747,9 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { //Also check install validity. BOOST_LOG_TRIVIAL(trace) << "Checking that the current install is valid according to this plugin's data."; vector issues = graph[*vit].CheckInstallValidity(_game); - list pluginMessages = graph[*vit].Messages(); + list pluginMessages = graph[*vit].Messages(); for (vector::const_iterator jt = issues.begin(), jtend = issues.end(); jt != jtend; ++jt) { - pluginMessages.push_back(boss::Message(boss::g_message_error, *jt)); + pluginMessages.push_back(loot::Message(loot::g_message_error, *jt)); } if (!issues.empty()) graph[*vit].Messages(pluginMessages); @@ -792,12 +792,12 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { AddOverlapEdges(graph); BOOST_LOG_TRIVIAL(debug) << "Checking to see if the graph is cyclic."; - boss::CheckForCycles(graph); + loot::CheckForCycles(graph); progDia->Pulse(); BOOST_LOG_TRIVIAL(debug) << "Performing a topological sort."; - boss::Sort(graph, plugins); + loot::Sort(graph, plugins); progDia->Destroy(); progDia = NULL; @@ -806,7 +806,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { MiniEditor editor(this, translate("LOOT: Calculated Load Order"), plugins, _game); long ret = editor.ShowModal(); - const std::list edits = editor.GetEditedPlugins(); + const std::list edits = editor.GetEditedPlugins(); if (ret != wxID_APPLY) { applyLoadOrder = false; @@ -822,9 +822,9 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { //User accepted edits, now apply them, then loop. //Apply edits to the graph vertices. - boss::vertex_it vit, vitend; + loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { - std::list::const_iterator pos = std::find(edits.begin(), edits.end(), graph[*vit]); + std::list::const_iterator pos = std::find(edits.begin(), edits.end(), graph[*vit]); if (pos != edits.end()) { BOOST_LOG_TRIVIAL(trace) << "Merging edits down to plugin list data."; @@ -840,8 +840,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { //Merge edits down to the userlist entries. BOOST_LOG_TRIVIAL(trace) << "Merging down edits to the userlist."; - for (list::const_iterator it = edits.begin(), endit = edits.end(); it != endit; ++it) { - list::iterator jt = find(ulist_plugins.begin(), ulist_plugins.end(), *it); + for (list::const_iterator it = edits.begin(), endit = edits.end(); it != endit; ++it) { + list::iterator jt = find(ulist_plugins.begin(), ulist_plugins.end(), *it); if (jt != ulist_plugins.end()) { jt->MergeMetadata(*it); @@ -859,7 +859,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { << YAML::Key << "plugins" << YAML::Value << ulist_plugins << YAML::EndMap; - boss::ofstream uout(_game.UserlistPath()); + loot::ofstream uout(_game.UserlistPath()); uout << yout.c_str(); uout.close(); @@ -873,24 +873,24 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { try { _game.SetLoadOrder(plugins); } - catch (boss::error& e) { + catch (loot::error& e) { BOOST_LOG_TRIVIAL(error) << "Failed to set the load order. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Failed to set the load order. Details: %1%")) % e.what()).str())); + messages.push_back(loot::Message(loot::g_message_error, (format(loc::translate("Failed to set the load order. Details: %1%")) % e.what()).str())); } BOOST_LOG_TRIVIAL(trace) << "Load order set:"; - for (list::iterator it = plugins.begin(), endIt = plugins.end(); it != endIt; ++it) { + for (list::iterator it = plugins.begin(), endIt = plugins.end(); it != endIt; ++it) { BOOST_LOG_TRIVIAL(trace) << '\t' << it->Name(); } } else { //User decided to cancel sorting. Just go straight to displaying the report. BOOST_LOG_TRIVIAL(info) << "The load order calculated was not applied as sorting was canceled."; - messages.push_back(boss::Message(boss::g_message_warn, loc::translate("The load order displayed in the Details tab was not applied as sorting was canceled."))); + messages.push_back(loot::Message(loot::g_message_warn, loc::translate("The load order displayed in the Details tab was not applied as sorting was canceled."))); } } catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Failed to calculate the load order. Details: " << e.what(); - messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Failed to calculate the load order. Details: %1%")) % e.what()).str())); + messages.push_back(loot::Message(loot::g_message_error, (format(loc::translate("Failed to calculate the load order. Details: %1%")) % e.what()).str())); progDia->Destroy(); progDia = NULL; @@ -905,7 +905,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { if (fs::exists(_game.ReportPath().string())) { BOOST_LOG_TRIVIAL(debug) << "Reading the previous report's details section."; //Read the whole file in. - boss::ifstream in(_game.ReportPath(), ios::binary); + loot::ifstream in(_game.ReportPath(), ios::binary); in.seekg(0, std::ios::end); oldDetails.resize(in.tellg()); in.seekg(0, std::ios::beg); @@ -934,7 +934,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { oldDetails, revision, doUpdate); - } catch (boss::error& e) { + } catch (loot::error& e) { wxMessageBox( FromUTF8(format(loc::translate("Error: %1%")) % e.what()), translate("LOOT: Error"), @@ -963,7 +963,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { void Launcher::OnEditMetadata(wxCommandEvent& event) { //Should probably check for masterlist updates before opening metadata editor. - list installed, mlist_plugins, ulist_plugins; + list installed, mlist_plugins, ulist_plugins; wxProgressDialog *progDia = new wxProgressDialog(translate("LOOT: Working..."),translate("LOOT working..."), 1000, this, wxPD_APP_MODAL|wxPD_AUTO_HIDE|wxPD_ELAPSED_TIME); @@ -971,7 +971,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(debug) << "Reading installed plugins' headers."; for (fs::directory_iterator it(_game.DataPath()); it != fs::directory_iterator(); ++it) { if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) { - installed.push_back(boss::Plugin(_game, it->path().filename().string(), true)); + installed.push_back(loot::Plugin(_game, it->path().filename().string(), true)); progDia->Pulse(); } @@ -982,7 +982,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(debug) << "Parsing masterlist."; YAML::Node mlist; try { - boss::ifstream in(_game.MasterlistPath()); + loot::ifstream in(_game.MasterlistPath()); mlist = YAML::Load(in); in.close(); } catch (YAML::ParserException& e) { @@ -994,7 +994,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { this); } if (mlist["plugins"]) - mlist_plugins = mlist["plugins"].as< list >(); + mlist_plugins = mlist["plugins"].as< list >(); } progDia->Pulse(); @@ -1004,7 +1004,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(debug) << "Parsing userlist."; YAML::Node ulist; try { - boss::ifstream in(_game.UserlistPath()); + loot::ifstream in(_game.UserlistPath()); ulist = YAML::Load(in); in.close(); } catch (YAML::ParserException& e) { @@ -1016,15 +1016,15 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { this); } if (ulist["plugins"]) - ulist_plugins = ulist["plugins"].as< list >(); + ulist_plugins = ulist["plugins"].as< list >(); } progDia->Pulse(); //Merge the masterlist down into the installed mods list. BOOST_LOG_TRIVIAL(debug) << "Merging the masterlist down into the installed mods list."; - for (list::const_iterator it = mlist_plugins.begin(), endit = mlist_plugins.end(); it != endit; ++it) { - list::iterator pos = find(installed.begin(), installed.end(), *it); + for (list::const_iterator it = mlist_plugins.begin(), endit = mlist_plugins.end(); it != endit; ++it) { + list::iterator pos = find(installed.begin(), installed.end(), *it); if (pos != installed.end()) pos->MergeMetadata(*it); @@ -1034,16 +1034,16 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { //Add empty entries for any userlist entries that aren't installed. BOOST_LOG_TRIVIAL(debug) << "Padding the installed mods list to match the plugins in the userlist."; - for (list::const_iterator it = ulist_plugins.begin(), endit = ulist_plugins.end(); it != endit; ++it) { + for (list::const_iterator it = ulist_plugins.begin(), endit = ulist_plugins.end(); it != endit; ++it) { if (find(installed.begin(), installed.end(), *it) == installed.end()) - installed.push_back(boss::Plugin(it->Name())); + installed.push_back(loot::Plugin(it->Name())); } progDia->Pulse(); //Sort into alphabetical order. BOOST_LOG_TRIVIAL(debug) << "Sorting plugin list into alphabetical order."; - installed.sort(boss::alpha_sort); + installed.sort(loot::alpha_sort); progDia->Pulse(); @@ -1052,7 +1052,7 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { if (_settings["Language"]) lang = Language(_settings["Language"].as()).Code(); else - lang = boss::g_lang_any; + lang = loot::g_lang_any; //Create editor window. BOOST_LOG_TRIVIAL(debug) << "Opening editor window."; @@ -1069,10 +1069,10 @@ void Launcher::OnRedatePlugins(wxCommandEvent& event) { if (dia->ShowModal() == wxID_YES) { BOOST_LOG_TRIVIAL(debug) << "Redating plugins."; - list loadorder; + list loadorder; try { _game.GetLoadOrder(loadorder); - } catch (boss::error& e) { + } catch (loot::error& e) { BOOST_LOG_TRIVIAL(error) << "Failed to get load order. " << e.what(); wxMessageBox( FromUTF8(format(loc::translate("Error: Failed to get load order. %1%")) % e.what()), @@ -1091,7 +1091,7 @@ void Launcher::OnRedatePlugins(wxCommandEvent& event) { lastTime = fs::last_write_time(filepath); - for (list::const_iterator it=loadorder.begin(), itend=loadorder.end(); it != itend; ++it) { + for (list::const_iterator it=loadorder.begin(), itend=loadorder.end(); it != itend; ++it) { filepath = _game.DataPath() / it->Name(); if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost")) diff --git a/src/gui/main.h b/src/gui/main.h index bc7eca97..abf8ca60 100644 --- a/src/gui/main.h +++ b/src/gui/main.h @@ -40,13 +40,13 @@ private: wxLocale * wxLoc; YAML::Node _settings; - std::vector _games; - boss::Game _game; + std::vector _games; + loot::Game _game; }; class Launcher : public wxFrame { public: - Launcher(const wxChar *title, YAML::Node& settings, boss::Game& inGame, std::vector& games); + Launcher(const wxChar *title, YAML::Node& settings, loot::Game& inGame, std::vector& games); void OnSortPlugins(wxCommandEvent& event); void OnEditMetadata(wxCommandEvent& event); @@ -66,9 +66,9 @@ private: wxMenuItem * RedatePluginsItem; wxButton * ViewButton; - boss::Game& _game; + loot::Game& _game; YAML::Node& _settings; //LOOT Settings. - std::vector& _games; + std::vector& _games; }; #endif diff --git a/src/gui/misc.cpp b/src/gui/misc.cpp index 920e2279..d26dbb46 100644 --- a/src/gui/misc.cpp +++ b/src/gui/misc.cpp @@ -42,26 +42,26 @@ MessageList::MessageList(wxWindow * parent, wxWindowID id, const unsigned int la SetItemCount(0); } -std::vector MessageList::GetItems() const { +std::vector MessageList::GetItems() const { return _messages; } -void MessageList::SetItems(const std::vector& messages) { +void MessageList::SetItems(const std::vector& messages) { _messages = messages; SetItemCount(_messages.size()); RefreshItems(0, _messages.size() - 1); } -boss::Message MessageList::GetItem(long item) const { +loot::Message MessageList::GetItem(long item) const { return _messages[item]; } -void MessageList::SetItem(long item, const boss::Message& message) { +void MessageList::SetItem(long item, const loot::Message& message) { _messages[item] = message; RefreshItem(item); } -void MessageList::AppendItem(const boss::Message& message) { +void MessageList::AppendItem(const loot::Message& message) { _messages.push_back(message); SetItemCount(_messages.size()); RefreshItem(_messages.size() - 1); @@ -78,9 +78,9 @@ wxString MessageList::OnGetItemText(long item, long column) const { return wxString(); if (column == 0) { - if (_messages[item].Type() == boss::g_message_say) + if (_messages[item].Type() == loot::g_message_say) return Type[0]; - else if (_messages[item].Type() == boss::g_message_warn) + else if (_messages[item].Type() == loot::g_message_warn) return Type[1]; else return Type[2]; @@ -92,7 +92,7 @@ wxString MessageList::OnGetItemText(long item, long column) const { return FromUTF8(_messages[item].Condition()); } else { - return FromUTF8(boss::Language(_messages[item].ChooseContent(_language).Language()).Name()); + return FromUTF8(loot::Language(_messages[item].ChooseContent(_language).Language()).Name()); } } @@ -160,7 +160,7 @@ wxString FileEditDialog::GetCondition() const { MessageEditDialog::MessageEditDialog(wxWindow *parent, const wxString& title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { wxArrayString languages; - vector langs = boss::Language::Names(); + vector langs = loot::Language::Names(); for (size_t i = 0; i < langs.size(); i++) { languages.Add(FromUTF8(langs[i])); } @@ -249,51 +249,51 @@ MessageEditDialog::MessageEditDialog(wxWindow *parent, const wxString& title) : SetSizerAndFit(bigBox); } -void MessageEditDialog::SetMessage(const boss::Message& message) { +void MessageEditDialog::SetMessage(const loot::Message& message) { - if (message.Type() == boss::g_message_say) + if (message.Type() == loot::g_message_say) _type->SetSelection(0); - else if (message.Type() == boss::g_message_warn) + else if (message.Type() == loot::g_message_warn) _type->SetSelection(1); else _type->SetSelection(2); _condition->SetValue(FromUTF8(message.Condition())); - vector contents = message.Content(); + vector contents = message.Content(); for (size_t i = 0, max = contents.size(); i < max; ++i) { - _content->InsertItem(i, FromUTF8(boss::Language(contents[i].Language()).Name())); + _content->InsertItem(i, FromUTF8(loot::Language(contents[i].Language()).Name())); _content->SetItem(i, 1, FromUTF8(contents[i].Str())); } } -boss::Message MessageEditDialog::GetMessage() const { +loot::Message MessageEditDialog::GetMessage() const { unsigned int type; string condition; if (_type->GetSelection() == 0) - type = boss::g_message_say; + type = loot::g_message_say; else if (_type->GetSelection() == 1) - type = boss::g_message_warn; + type = loot::g_message_warn; else - type = boss::g_message_error; + type = loot::g_message_error; condition = string(_condition->GetValue().ToUTF8()); - vector contents; + vector contents; for (size_t i = 0, max = _content->GetItemCount(); i < max; ++i) { string str = string(_content->GetItemText(i, 1).ToUTF8()); - unsigned int lang = boss::Language(string(_content->GetItemText(i, 0).ToUTF8())).Code(); + unsigned int lang = loot::Language(string(_content->GetItemText(i, 0).ToUTF8())).Code(); - contents.push_back(boss::MessageContent(str, lang)); + contents.push_back(loot::MessageContent(str, lang)); } - return boss::Message(type, contents, condition); + return loot::Message(type, contents, condition); } void MessageEditDialog::OnSelect(wxListEvent& event) { - _language->SetSelection(boss::Language(string(_content->GetItemText(event.GetIndex(), 0).ToUTF8())).Code()); + _language->SetSelection(loot::Language(string(_content->GetItemText(event.GetIndex(), 0).ToUTF8())).Code()); _str->SetValue(_content->GetItemText(event.GetIndex(), 1)); editBtn->Enable(true); removeBtn->Enable(true); @@ -301,7 +301,7 @@ void MessageEditDialog::OnSelect(wxListEvent& event) { void MessageEditDialog::OnAdd(wxCommandEvent& event) { long i = _content->GetItemCount(); - _content->InsertItem(i, FromUTF8(boss::Language(_language->GetSelection()).Name())); + _content->InsertItem(i, FromUTF8(loot::Language(_language->GetSelection()).Name())); _content->SetItem(i, 1, _str->GetValue()); } @@ -316,7 +316,7 @@ void MessageEditDialog::OnEdit(wxCommandEvent& event) { return; } long i = _content->GetFirstSelected(); - _content->SetItem(i, 0, FromUTF8(boss::Language(_language->GetSelection()).Name())); + _content->SetItem(i, 0, FromUTF8(loot::Language(_language->GetSelection()).Name())); _content->SetItem(i, 1, _str->GetValue()); } diff --git a/src/gui/misc.h b/src/gui/misc.h index 4835a0b9..dc7134d8 100644 --- a/src/gui/misc.h +++ b/src/gui/misc.h @@ -47,19 +47,19 @@ class MessageList : public wxListView { public: MessageList(wxWindow * parent, wxWindowID id, const unsigned int language); - void SetItems(const std::vector& messages); - std::vector GetItems() const; + void SetItems(const std::vector& messages); + std::vector GetItems() const; - boss::Message GetItem(long item) const; - void SetItem(long item, const boss::Message& message); - void AppendItem(const boss::Message& message); + loot::Message GetItem(long item) const; + void SetItem(long item, const loot::Message& message); + void AppendItem(const loot::Message& message); void OnDeleteItem(wxListEvent& event); protected: wxString OnGetItemText(long item, long column) const; private: - std::vector _messages; + std::vector _messages; const unsigned int _language; }; @@ -81,8 +81,8 @@ class MessageEditDialog : public wxDialog { public: MessageEditDialog(wxWindow *parent, const wxString& title); - void SetMessage(const boss::Message& message); - boss::Message GetMessage() const; + void SetMessage(const loot::Message& message); + loot::Message GetMessage() const; void OnSelect(wxListEvent& event); void OnAdd(wxCommandEvent& event); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index e83483a9..b2ca811d 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -35,7 +35,7 @@ using namespace std; -SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), _settings(settings), _games(games) { +SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), _settings(settings), _games(games) { //Initialise drop-down list contents. wxString DebugVerbosity[] = { @@ -52,7 +52,7 @@ SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node } wxArrayString languages; - vector langs = boss::Language::Names(); + vector langs = loot::Language::Names(); for (size_t i = 0; i < langs.size(); i++) { languages.Add(FromUTF8(langs[i])); } @@ -154,7 +154,7 @@ void SettingsFrame::SetDefaultValues() { BOOST_LOG_TRIVIAL(debug) << "Setting default values for LOOT's settings."; if (_settings["Language"]) { - LanguageChoice->SetSelection(boss::Language(_settings["Language"].as()).Code()); + LanguageChoice->SetSelection(loot::Language(_settings["Language"].as()).Code()); } if (_settings["Game"]) { @@ -186,7 +186,7 @@ void SettingsFrame::SetDefaultValues() { for (size_t i=0, max=_games.size(); i < max; ++i) { gamesList->InsertItem(i, FromUTF8(_games[i].Name())); - gamesList->SetItem(i, 1, FromUTF8(boss::Game(_games[i].Id()).FolderName())); + gamesList->SetItem(i, 1, FromUTF8(loot::Game(_games[i].Id()).FolderName())); gamesList->SetItem(i, 2, FromUTF8(_games[i].FolderName())); gamesList->SetItem(i, 3, FromUTF8(_games[i].Master())); gamesList->SetItem(i, 4, FromUTF8(_games[i].RepoURL())); @@ -210,7 +210,7 @@ void SettingsFrame::OnQuit(wxCommandEvent& event) { else _settings["Game"] = _games[GameChoice->GetSelection() - 1].FolderName(); - _settings["Language"] = boss::Language(LanguageChoice->GetSelection()).Locale(); + _settings["Language"] = loot::Language(LanguageChoice->GetSelection()).Locale(); _settings["Debug Verbosity"] = DebugVerbosityChoice->GetSelection(); @@ -245,16 +245,16 @@ void SettingsFrame::OnQuit(wxCommandEvent& event) { path = gamesList->GetItemText(i, 6).ToUTF8(); registry = gamesList->GetItemText(i, 7).ToUTF8(); - 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; + if (gamesList->GetItemText(i, 1).ToUTF8() == loot::Game(loot::g_game_tes4).FolderName()) + id = loot::g_game_tes4; + else if (gamesList->GetItemText(i, 1).ToUTF8() == loot::Game(loot::g_game_tes5).FolderName()) + id = loot::g_game_tes5; + else if (gamesList->GetItemText(i, 1).ToUTF8() == loot::Game(loot::g_game_fo3).FolderName()) + id = loot::g_game_fo3; else - id = boss::g_game_fonv; + id = loot::g_game_fonv; - _games.push_back(boss::Game(id, folder).SetDetails(name, master, repo, branch, path, registry)); + _games.push_back(loot::Game(id, folder).SetDetails(name, master, repo, branch, path, registry)); } } @@ -263,10 +263,10 @@ void SettingsFrame::OnQuit(wxCommandEvent& event) { void SettingsFrame::OnGameSelect(wxListEvent& event) { wxString name = gamesList->GetItemText(event.GetIndex()); - 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()) { + if (name == loot::Game(loot::g_game_tes4).Name() + || name == loot::Game(loot::g_game_tes5).Name() + || name == loot::Game(loot::g_game_fo3).Name() + || name == loot::Game(loot::g_game_fonv).Name()) { removeBtn->Enable(false); } else { removeBtn->Enable(true); @@ -332,14 +332,14 @@ void SettingsFrame::OnEditGame(wxCommandEvent& event) { long i = gamesList->GetFirstSelected(); int stateNo; - 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; + if (gamesList->GetItemText(i, 1) == loot::Game(loot::g_game_tes4).FolderName()) + stateNo = loot::g_game_tes4; + else if (gamesList->GetItemText(i, 1) == loot::Game(loot::g_game_tes5).FolderName()) + stateNo = loot::g_game_tes5; + else if (gamesList->GetItemText(i, 1) == loot::Game(loot::g_game_fo3).FolderName()) + stateNo = loot::g_game_fo3; else - stateNo = boss::g_game_fonv; + stateNo = loot::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), gamesList->GetItemText(i, 7)); @@ -394,10 +394,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::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()) + FromUTF8(loot::Game(loot::g_game_tes4).FolderName()), + FromUTF8(loot::Game(loot::g_game_tes5).FolderName()), + FromUTF8(loot::Game(loot::g_game_fo3).FolderName()), + FromUTF8(loot::Game(loot::g_game_fonv).FolderName()) }; //Initialise controls. @@ -467,11 +467,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& repo, const wxString& branch, const wxString& path, const wxString& registry) { - if (type == boss::g_game_tes4) + if (type == loot::g_game_tes4) _type->SetSelection(0); - else if (type == boss::g_game_tes5) + else if (type == loot::g_game_tes5) _type->SetSelection(1); - else if (type == boss::g_game_fo3) + else if (type == loot::g_game_fo3) _type->SetSelection(2); else _type->SetSelection(3); diff --git a/src/gui/settings.h b/src/gui/settings.h index c08c8cac..d15de1a7 100644 --- a/src/gui/settings.h +++ b/src/gui/settings.h @@ -33,7 +33,7 @@ class SettingsFrame : public wxDialog { public: - SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games); + SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games); void OnQuit(wxCommandEvent& event); void OnGameSelect(wxListEvent& event); @@ -55,7 +55,7 @@ private: wxButton * removeBtn; YAML::Node& _settings; - std::vector& _games; + std::vector& _games; }; class GameEditDialog : public wxDialog {