diff options
| author | Tannin <devnull@localhost> | 2014-06-02 19:15:23 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-06-02 19:15:23 +0200 |
| commit | 5a4b6e70fd815c9052ff71a4244bdeb707e92ba1 (patch) | |
| tree | df95709e24d2d417e463f59d9e6acf21fea35780 /src | |
| parent | 18574c2ba89737b2140236bde479e87616470270 (diff) | |
- plugin-list now displays loot messages
Diffstat (limited to 'src')
| -rw-r--r-- | src/directoryrefresher.cpp | 1 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 16 | ||||
| -rw-r--r-- | src/pluginlist.cpp | 48 | ||||
| -rw-r--r-- | src/pluginlist.h | 25 |
4 files changed, 70 insertions, 20 deletions
diff --git a/src/directoryrefresher.cpp b/src/directoryrefresher.cpp index 52e16be4..33bde469 100644 --- a/src/directoryrefresher.cpp +++ b/src/directoryrefresher.cpp @@ -141,7 +141,6 @@ void DirectoryRefresher::refresh() //TODO i is the priority here, where higher = more important. the input vector is also sorted by priority but inverted! for (int i = 1; iter != m_Mods.end(); ++iter, ++i) { -qDebug("%s - %d", qPrintable(iter->modName), i); try { addModToStructure(m_DirectoryStructure, iter->modName, i, iter->absolutePath, iter->stealFiles, iter->archives); } catch (const std::exception &e) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 496d0d9e..8fcd4024 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -116,7 +116,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <scopeguard.h> #include <boost/thread.hpp> #include <boost/algorithm/string.hpp> - +#include <regex> #ifdef TEST_MODELS #include "modeltest.h" @@ -5158,6 +5158,9 @@ void MainWindow::processLOOTOut(const std::string &lootOut, std::string &reportU { std::vector<std::string> lines; boost::split(lines, lootOut, boost::is_any_of("\r\n")); + + std::tr1::regex exRequires("\"([^\"]*)\" requires \"([^\"]*)\", but it is missing\\."); + foreach (const std::string &line, lines) { if (line.length() > 0) { size_t progidx = line.find("[progress]"); @@ -5171,7 +5174,14 @@ void MainWindow::processLOOTOut(const std::string &lootOut, std::string &reportU qWarning("%s", line.c_str()); errorMessages.append(boost::algorithm::trim_copy(line.substr(erroridx + 8)) + "\n"); } else { - qDebug("%s", line.c_str()); + std::tr1::smatch match; + if (std::tr1::regex_match(line, match, exRequires)) { + std::string modName(match[1].first, match[1].second); + std::string dependency(match[2].first, match[2].second); + m_PluginList.addInformation(modName.c_str(), tr("depends on missing \"%1\"").arg(dependency.c_str())); + } else { + qDebug("%s", line.c_str()); + } } } } @@ -5258,6 +5268,8 @@ void MainWindow::on_bossButton_clicked() // we don't use the write end ::CloseHandle(stdOutWrite); + m_PluginList.clearAdditionalInformation(); + if (loot != INVALID_HANDLE_VALUE) { while (::WaitForSingleObject(loot, 100) == WAIT_TIMEOUT) { // keep processing events so the app doesn't appear dead diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index b1d2a446..0a28a45f 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -266,6 +266,29 @@ bool PluginList::isEnabled(const QString &name) } } +void PluginList::clearInformation(const QString &name) +{ + std::map<QString, int>::iterator iter = m_ESPsByName.find(name.toLower()); + + if (iter != m_ESPsByName.end()) { + m_AdditionalInfo[name.toLower()].m_Messages.clear(); + } +} + +void PluginList::clearAdditionalInformation() +{ + m_AdditionalInfo.clear(); +} + +void PluginList::addInformation(const QString &name, const QString &message) +{ + std::map<QString, int>::iterator iter = m_ESPsByName.find(name.toLower()); + + if (iter != m_ESPsByName.end()) { + m_AdditionalInfo[name.toLower()].m_Messages.append(message); + } +} + bool PluginList::isEnabled(int index) { @@ -760,14 +783,11 @@ QVariant PluginList::data(const QModelIndex &modelIndex, int role) const } } else if (role == Qt::ToolTipRole) { QString name = m_ESPs[index].m_Name.toLower(); - auto bossInfoIter = m_BossInfo.find(name); + auto addInfoIter = m_AdditionalInfo.find(name); QString toolTip; - if (bossInfoIter != m_BossInfo.end()) { - if (!bossInfoIter->second.m_BOSSMessages.isEmpty()) { - toolTip += bossInfoIter->second.m_BOSSMessages.join("<br>") + "<br><hr>"; - } - if (bossInfoIter->second.m_BOSSUnrecognized) { - toolTip += "Not recognized by BOSS<br><ht>"; + if (addInfoIter != m_AdditionalInfo.end()) { + if (!addInfoIter->second.m_Messages.isEmpty()) { + toolTip += addInfoIter->second.m_Messages.join("<br>") + "<br><hr>"; } } if (m_ESPs[index].m_ForceEnabled) { @@ -787,7 +807,9 @@ QVariant PluginList::data(const QModelIndex &modelIndex, int role) const std::set_difference(m_ESPs[index].m_Masters.begin(), m_ESPs[index].m_Masters.end(), m_ESPs[index].m_MasterUnset.begin(), m_ESPs[index].m_MasterUnset.end(), std::inserter(enabledMasters, enabledMasters.end())); - text += "<br><b>" + tr("Enabled Masters") + "</b>: " + SetJoin(enabledMasters, ", "); + if (enabledMasters.size() > 0) { + text += "<br><b>" + tr("Enabled Masters") + "</b>: " + SetJoin(enabledMasters, ", "); + } if (m_ESPs[index].m_HasIni) { text += "<br>There is an ini file connected to this esp. Its settings will be added to your game settings, overwriting " "in case of conflicts."; @@ -807,14 +829,14 @@ QVariant PluginList::data(const QModelIndex &modelIndex, int role) const if (m_LockedOrder.find(nameLower) != m_LockedOrder.end()) { result.append(QIcon(":/MO/gui/locked")); } - auto bossInfoIter = m_BossInfo.find(nameLower); - if (bossInfoIter != m_BossInfo.end()) { - if (!bossInfoIter->second.m_BOSSMessages.isEmpty()) { + auto bossInfoIter = m_AdditionalInfo.find(nameLower); + if (bossInfoIter != m_AdditionalInfo.end()) { + if (!bossInfoIter->second.m_Messages.isEmpty()) { result.append(QIcon(":/MO/gui/information")); } - if (bossInfoIter->second.m_BOSSUnrecognized) { + /*if (bossInfoIter->second.m_LOOTUnrecognized) { result.append(QIcon(":/MO/gui/help")); - } + }*/ } if (m_ESPs[index].m_HasIni) { result.append(QIcon(":/MO/gui/attachment")); diff --git a/src/pluginlist.h b/src/pluginlist.h index bb988281..d041172f 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -123,6 +123,24 @@ public: bool isEnabled(const QString &name); /** + * @brief clear all additional information we stored on plugins + */ + void clearAdditionalInformation(); + + /** + * @brief reset additional information on a mod + * @param name name of the plugin to clear the information of + */ + void clearInformation(const QString &name); + + /** + * @brief add additional information on a mod (i.e. from loot) + * @param name name of the plugin to add information about + * @param message the message to add to the plugin + */ + void addInformation(const QString &name, const QString &message); + + /** * @brief test if a plugin is enabled * * @param index index of the plugin to look up @@ -251,9 +269,8 @@ private: mutable std::set<QString> m_MasterUnset; }; - struct BossInfo { - QStringList m_BOSSMessages; - bool m_BOSSUnrecognized; + struct AdditionalInfo { + QStringList m_Messages; }; friend bool ByName(const ESPInfo& LHS, const ESPInfo& RHS); @@ -291,7 +308,7 @@ private: std::map<QString, int> m_ESPLoadOrder; std::map<QString, int> m_LockedOrder; - std::map<QString, BossInfo> m_BossInfo; // maps esp names to boss information + std::map<QString, AdditionalInfo> m_AdditionalInfo; // maps esp names to boss information QString m_CurrentProfile; QFontMetrics m_FontMetrics; |
