From 5a4b6e70fd815c9052ff71a4244bdeb707e92ba1 Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 2 Jun 2014 19:15:23 +0200 Subject: - plugin-list now displays loot messages --- src/directoryrefresher.cpp | 1 - src/mainwindow.cpp | 16 ++++++++++++++-- src/pluginlist.cpp | 48 +++++++++++++++++++++++++++++++++------------- src/pluginlist.h | 25 ++++++++++++++++++++---- 4 files changed, 70 insertions(+), 20 deletions(-) (limited to 'src') 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 . #include #include #include - +#include #ifdef TEST_MODELS #include "modeltest.h" @@ -5158,6 +5158,9 @@ void MainWindow::processLOOTOut(const std::string &lootOut, std::string &reportU { std::vector 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::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::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("
") + "

"; - } - if (bossInfoIter->second.m_BOSSUnrecognized) { - toolTip += "Not recognized by BOSS
"; + if (addInfoIter != m_AdditionalInfo.end()) { + if (!addInfoIter->second.m_Messages.isEmpty()) { + toolTip += addInfoIter->second.m_Messages.join("
") + "

"; } } 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 += "
" + tr("Enabled Masters") + ": " + SetJoin(enabledMasters, ", "); + if (enabledMasters.size() > 0) { + text += "
" + tr("Enabled Masters") + ": " + SetJoin(enabledMasters, ", "); + } if (m_ESPs[index].m_HasIni) { text += "
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 @@ -122,6 +122,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 * @@ -251,9 +269,8 @@ private: mutable std::set 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 m_ESPLoadOrder; std::map m_LockedOrder; - std::map m_BossInfo; // maps esp names to boss information + std::map m_AdditionalInfo; // maps esp names to boss information QString m_CurrentProfile; QFontMetrics m_FontMetrics; -- cgit v1.3.1