mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fixed issue #107.
Inactive masters now get their own error message. Also tidied up implementation.
This commit is contained in:
@@ -699,23 +699,33 @@ namespace boss {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<string,bool> Plugin::CheckInstallValidity(const Game& game) const {
|
||||
map<string,bool> issues;
|
||||
std::vector<std::string> Plugin::CheckInstallValidity(const Game& game) const {
|
||||
std::vector<std::string> errorMessages;
|
||||
if (tags.find(Tag("Filter")) == tags.end()) {
|
||||
for (vector<string>::const_iterator it=masters.begin(), endIt=masters.end(); it != endIt; ++it) {
|
||||
if (!boost::filesystem::exists(game.DataPath() / *it) && !boost::filesystem::exists(game.DataPath() / (*it + ".ghost")))
|
||||
issues.insert(pair<string,bool>(*it,false));
|
||||
if (!boost::filesystem::exists(game.DataPath() / *it) && !boost::filesystem::exists(game.DataPath() / (*it + ".ghost"))) {
|
||||
BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << *it << "\", but it is missing.";
|
||||
errorMessages.push_back((boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % *it).str());
|
||||
}
|
||||
else if (!game.IsActive(*it)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << *it << "\", but it is inactive.";
|
||||
errorMessages.push_back((boost::format(boost::locale::translate("This plugin requires \"%1%\" to be active, but it is inactive.")) % *it).str());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (set<File>::const_iterator it=requirements.begin(), endIt=requirements.end(); it != endIt; ++it) {
|
||||
if (!boost::filesystem::exists(game.DataPath() / it->Name()) && !(IsPlugin(it->Name()) && boost::filesystem::exists(game.DataPath() / (it->Name() + ".ghost"))))
|
||||
issues.insert(pair<string,bool>(it->DisplayName(),false));
|
||||
if (!boost::filesystem::exists(game.DataPath() / it->Name()) && !(IsPlugin(it->Name()) && boost::filesystem::exists(game.DataPath() / (it->Name() + ".ghost")))) {
|
||||
BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << it->Name() << "\", but it is missing.";
|
||||
errorMessages.push_back((boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % it->Name()).str());
|
||||
}
|
||||
}
|
||||
for (set<File>::const_iterator it=incompatibilities.begin(), endIt=incompatibilities.end(); it != endIt; ++it) {
|
||||
if (boost::filesystem::exists(game.DataPath() / it->Name()) || (IsPlugin(it->Name()) && boost::filesystem::exists(game.DataPath() / (it->Name() + ".ghost"))))
|
||||
issues.insert(pair<string,bool>(it->DisplayName(),true));
|
||||
if (boost::filesystem::exists(game.DataPath() / it->Name()) || (IsPlugin(it->Name()) && boost::filesystem::exists(game.DataPath() / (it->Name() + ".ghost")))) {
|
||||
BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" is incompatible with \"" << it->Name() << "\", but both are present.";
|
||||
errorMessages.push_back((boost::format(boost::locale::translate("This plugin is incompatible with \"%1%\", but both are present.")) % it->Name()).str());
|
||||
}
|
||||
}
|
||||
return issues;
|
||||
return errorMessages;
|
||||
}
|
||||
|
||||
bool Plugin::LoadsBSA(const Game& game) const {
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace boss {
|
||||
bool MustLoadAfter(const Plugin& plugin) const; //Checks masters, reqs and loadAfter.
|
||||
|
||||
//Validity checks.
|
||||
std::map<std::string,bool> CheckInstallValidity(const Game& game) const; //Checks that reqs and masters are all present, and that no incs are present. Returns a map of filenames and whether they are missing (if bool is true, then filename is a req or master, otherwise it's an inc).
|
||||
std::vector<std::string> CheckInstallValidity(const Game& game) const; //Checks that reqs and masters are all present, and that no incs are present. Returns a map of filenames and whether they are missing (if bool is true, then filename is a req or master, otherwise it's an inc).
|
||||
private:
|
||||
std::string name;
|
||||
bool enabled; //Default to true.
|
||||
|
||||
+3
-9
@@ -738,16 +738,10 @@ 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.";
|
||||
map<string, bool> issues = graph[*vit].CheckInstallValidity(_game);
|
||||
vector<string> issues = graph[*vit].CheckInstallValidity(_game);
|
||||
list<boss::Message> pluginMessages = graph[*vit].Messages();
|
||||
for (map<string,bool>::const_iterator jt=issues.begin(), endJt=issues.end(); jt != endJt; ++jt) {
|
||||
if (jt->second) {
|
||||
BOOST_LOG_TRIVIAL(error) << "\"" << jt->first << "\" is incompatible with \"" << graph[*vit].Name() << "\" and is present.";
|
||||
pluginMessages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("\"%1%\" is incompatible with \"%2%\" and is present.")) % jt->first % graph[*vit].Name()).str()));
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "\"" << jt->first << "\" is required by \"" << graph[*vit].Name() << "\" but is missing.";
|
||||
pluginMessages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("\"%1%\" is required by \"%2%\" but is missing.")) % jt->first % graph[*vit].Name()).str()));
|
||||
}
|
||||
for (vector<string>::const_iterator jt = issues.begin(), jtend = issues.end(); jt != jtend; ++jt) {
|
||||
pluginMessages.push_back(boss::Message(boss::g_message_error, *jt));
|
||||
}
|
||||
if (!issues.empty())
|
||||
graph[*vit].Messages(pluginMessages);
|
||||
|
||||
Reference in New Issue
Block a user