diff --git a/src/backend/helpers.cpp b/src/backend/helpers.cpp index 3dd5fc3f..bdc89e2b 100644 --- a/src/backend/helpers.cpp +++ b/src/backend/helpers.cpp @@ -164,22 +164,6 @@ namespace loot { return out; } - //Turns a positive integer into a more qualitative description of its value (eg. "few", "many"). - std::string IntToVagueString(const unsigned int i) { - if (i < 10) { - return boost::locale::translate("a few"); - } - else if (i < 100) { - return boost::locale::translate("several"); - } - else if (i < 1000) { - return boost::locale::translate("a lot of"); - } - else { - return boost::locale::translate("a plethora of"); - } - } - #ifdef _WIN32 //Get registry subkey value string. string RegKeyStringValue(const std::string& keyStr, const std::string& subkey, const std::string& value) { diff --git a/src/backend/helpers.h b/src/backend/helpers.h index db79701e..bd1092ec 100644 --- a/src/backend/helpers.h +++ b/src/backend/helpers.h @@ -50,9 +50,6 @@ namespace loot { //Converts an integer to a hex string using BOOST's Spirit.Karma. Faster than a stringstream conversion. std::string IntToHexString(const int n); - //Turns a positive integer into a more qualitative description of its value (eg. "few", "many"). - std::string IntToVagueString(const unsigned int i); - #ifdef _WIN32 //Get registry subkey value string. std::string RegKeyStringValue(const std::string& keyStr, const std::string& subkey, const std::string& value); diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index 334558f6..d9d60689 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -79,34 +79,6 @@ namespace loot { return id; } - PluginDirtyInfo::PluginDirtyInfo() : _crc(0), _itm(0), _ref(0), _nav(0) {} - - PluginDirtyInfo::PluginDirtyInfo(uint32_t crc, unsigned int itm, unsigned int ref, unsigned int nav, const std::string& utility) : _crc(crc), _itm(itm), _ref(ref), _nav(nav), _utility(utility) {} - - bool PluginDirtyInfo::operator < (const PluginDirtyInfo& rhs) const { - return _crc < rhs.CRC(); - } - - uint32_t PluginDirtyInfo::CRC() const { - return _crc; - } - - unsigned int PluginDirtyInfo::ITMs() const { - return _itm; - } - - unsigned int PluginDirtyInfo::DeletedRefs() const { - return _ref; - } - - unsigned int PluginDirtyInfo::DeletedNavmeshes() const { - return _nav; - } - - std::string PluginDirtyInfo::CleaningUtility() const { - return _utility; - } - ConditionStruct::ConditionStruct() {} ConditionStruct::ConditionStruct(const string& condition) : _condition(condition) {} @@ -282,6 +254,59 @@ namespace loot { return _content; } + PluginDirtyInfo::PluginDirtyInfo() : _crc(0), _itm(0), _ref(0), _nav(0) {} + + PluginDirtyInfo::PluginDirtyInfo(uint32_t crc, unsigned int itm, unsigned int ref, unsigned int nav, const std::string& utility) : _crc(crc), _itm(itm), _ref(ref), _nav(nav), _utility(utility) {} + + bool PluginDirtyInfo::operator < (const PluginDirtyInfo& rhs) const { + return _crc < rhs.CRC(); + } + + uint32_t PluginDirtyInfo::CRC() const { + return _crc; + } + + unsigned int PluginDirtyInfo::ITMs() const { + return _itm; + } + + unsigned int PluginDirtyInfo::DeletedRefs() const { + return _ref; + } + + unsigned int PluginDirtyInfo::DeletedNavmeshes() const { + return _nav; + } + + std::string PluginDirtyInfo::CleaningUtility() const { + return _utility; + } + + Message PluginDirtyInfo::AsMessage() const { + boost::format f; + if (this->_itm > 0 && this->_ref > 0 && this->_nav > 0) + f = boost::format(boost::locale::translate("Contains %1% ITM records, %2% deleted references and %3% deleted navmeshes. Clean with %4%.")) % this->_itm % this->_ref % this->_nav % this->_utility; + else if (this->_itm == 0 && this->_ref == 0 && this->_nav == 0) + f = boost::format(boost::locale::translate("Clean with %1%.")) % this->_utility; + + else if (this->_itm == 0 && this->_ref > 0 && this->_nav > 0) + f = boost::format(boost::locale::translate("Contains %1% deleted references and %2% deleted navmeshes. Clean with %3%.")) % this->_ref % this->_nav % this->_utility; + else if (this->_itm == 0 && this->_ref == 0 && this->_nav > 0) + f = boost::format(boost::locale::translate("Contains %1% deleted navmeshes. Clean with %2%.")) % this->_nav % this->_utility; + else if (this->_itm == 0 && this->_ref > 0 && this->_nav == 0) + f = boost::format(boost::locale::translate("Contains %1% deleted references. Clean with %2%.")) % this->_ref % this->_utility; + + else if (this->_itm > 0 && this->_ref == 0 && this->_nav > 0) + f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% deleted navmeshes. Clean with %3%.")) % this->_itm % this->_nav % this->_utility; + else if (this->_itm > 0 && this->_ref == 0 && this->_nav == 0) + f = boost::format(boost::locale::translate("Contains %1% ITM records. Clean with %2%.")) % this->_itm % this->_utility; + + else if (this->_itm > 0 && this->_ref > 0 && this->_nav == 0) + f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% deleted references. Clean with %3%.")) % this->_itm % this->_ref % this->_utility; + + return Message(Message::warn, f.str()); + } + File::File() {} File::File(const std::string& name, const std::string& display, const std::string& condition) : _name(name), _display(display), ConditionStruct(condition) {} @@ -906,28 +931,7 @@ namespace loot { // Also evaluate dirty info. bool isDirty = false; for (const auto &element : _dirtyInfo) { - boost::format f; - if (element.ITMs() > 0 && element.DeletedRefs() > 0 && element.DeletedNavmeshes() > 0) - f = boost::format(boost::locale::translate("Contains %1% ITM records, %2% deleted references and %3% deleted navmeshes. Clean with %4%.")) % IntToVagueString(element.ITMs()) % IntToVagueString(element.DeletedRefs()) % IntToVagueString(element.DeletedNavmeshes()) % element.CleaningUtility(); - else if (element.ITMs() == 0 && element.DeletedRefs() == 0 && element.DeletedNavmeshes() == 0) - f = boost::format(boost::locale::translate("Clean with %1%.")) % element.CleaningUtility(); - - else if (element.ITMs() == 0 && element.DeletedRefs() > 0 && element.DeletedNavmeshes() > 0) - f = boost::format(boost::locale::translate("Contains %1% deleted references and %2% deleted navmeshes. Clean with %3%.")) % IntToVagueString(element.DeletedRefs()) % IntToVagueString(element.DeletedNavmeshes()) % element.CleaningUtility(); - else if (element.ITMs() == 0 && element.DeletedRefs() == 0 && element.DeletedNavmeshes() > 0) - f = boost::format(boost::locale::translate("Contains %1% deleted navmeshes. Clean with %2%.")) % IntToVagueString(element.DeletedNavmeshes()) % element.CleaningUtility(); - else if (element.ITMs() == 0 && element.DeletedRefs() > 0 && element.DeletedNavmeshes() == 0) - f = boost::format(boost::locale::translate("Contains %1% deleted references. Clean with %2%.")) % IntToVagueString(element.DeletedRefs()) % element.CleaningUtility(); - - else if (element.ITMs() > 0 && element.DeletedRefs() == 0 && element.DeletedNavmeshes() > 0) - f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% deleted navmeshes. Clean with %3%.")) % IntToVagueString(element.ITMs()) % IntToVagueString(element.DeletedNavmeshes()) % element.CleaningUtility(); - else if (element.ITMs() > 0 && element.DeletedRefs() == 0 && element.DeletedNavmeshes() == 0) - f = boost::format(boost::locale::translate("Contains %1% ITM records. Clean with %2%.")) % IntToVagueString(element.ITMs()) % element.CleaningUtility(); - - else if (element.ITMs() > 0 && element.DeletedRefs() > 0 && element.DeletedNavmeshes() == 0) - f = boost::format(boost::locale::translate("Contains %1% ITM records and %2% deleted references. Clean with %3%.")) % IntToVagueString(element.ITMs()) % IntToVagueString(element.DeletedRefs()) % element.CleaningUtility(); - - messages.push_back(loot::Message(loot::Message::warn, f.str())); + messages.push_back(element.AsMessage()); isDirty = true; } diff --git a/src/backend/metadata.h b/src/backend/metadata.h index d527ef0f..4e50d3ba 100644 --- a/src/backend/metadata.h +++ b/src/backend/metadata.h @@ -56,26 +56,6 @@ namespace loot { uint32_t id; }; - class PluginDirtyInfo { - public: - PluginDirtyInfo(); - PluginDirtyInfo(uint32_t crc, unsigned int itm, unsigned int ref, unsigned int nav, const std::string& utility); - - bool operator < (const PluginDirtyInfo& rhs) const; - - uint32_t CRC() const; - unsigned int ITMs() const; - unsigned int DeletedRefs() const; - unsigned int DeletedNavmeshes() const; - std::string CleaningUtility() const; - private: - uint32_t _crc; - unsigned int _itm; - unsigned int _ref; - unsigned int _nav; - std::string _utility; - }; - class ConditionStruct { public: ConditionStruct(); @@ -130,6 +110,28 @@ namespace loot { std::vector _content; }; + class PluginDirtyInfo { + public: + PluginDirtyInfo(); + PluginDirtyInfo(uint32_t crc, unsigned int itm, unsigned int ref, unsigned int nav, const std::string& utility); + + bool operator < (const PluginDirtyInfo& rhs) const; + + uint32_t CRC() const; + unsigned int ITMs() const; + unsigned int DeletedRefs() const; + unsigned int DeletedNavmeshes() const; + std::string CleaningUtility() const; + + Message AsMessage() const; + private: + uint32_t _crc; + unsigned int _itm; + unsigned int _ref; + unsigned int _nav; + std::string _utility; + }; + class File : public ConditionStruct { public: File();