From 7fa230411e3615e923f39fe85d9ccb985e3d4e5d Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Mon, 24 Dec 2018 19:46:31 -0600 Subject: Improvements to the plugin and mod counters * Fix style * Add whatsThis * Add tooltips with additional statistics * Don't count mods like overwrite, unmanaged, DLC, etc. --- src/mainwindow.cpp | 106 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 7 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 657f89bd..e3f12e39 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -458,11 +458,8 @@ MainWindow::MainWindow(QSettings &initSettings // set the name of the widget to the name of the action to allow styling ui->toolBar->widgetForAction(action)->setObjectName(action->objectName()); } - ui->activePluginsCounter->display(m_OrganizerCore.pluginList()->enabledCount()); - ui->activeModsCounter->display((int)m_OrganizerCore.currentProfile()->getActiveMods().size()); - - - + emit updatePluginCount(); + emit updateModCount(); } @@ -2193,7 +2190,7 @@ void MainWindow::directory_refreshed() void MainWindow::esplist_changed() { - ui->activePluginsCounter->display(m_OrganizerCore.pluginList()->enabledCount()); + emit updatePluginCount(); } void MainWindow::modorder_changed() @@ -2453,7 +2450,7 @@ void MainWindow::restoreBackup_clicked() void MainWindow::modlistChanged(const QModelIndex&, int) { m_OrganizerCore.currentProfile()->writeModlist(); - ui->activeModsCounter->display((int)m_OrganizerCore.currentProfile()->getActiveMods().size()); + emit updateModCount(); } void MainWindow::modlistSelectionChanged(const QModelIndex ¤t, const QModelIndex&) @@ -3004,6 +3001,101 @@ void MainWindow::searchClear_activated() } } +void MainWindow::updateModCount() +{ + int activeCount = 0; + int backupCount = 0; + int foreignCount = 0; + int separatorCount = 0; + int regularCount = 0; + + QStringList allMods = m_OrganizerCore.modList()->allMods(); + + auto hasFlag = [](std::vector flags, ModInfo::EFlag filter) { + return std::find(flags.begin(), flags.end(), filter) != flags.end(); + }; + + for (QString mod : allMods) { + int modIndex = ModInfo::getIndex(mod); + ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex); + std::vector modFlags = modInfo->getFlags(); + for (auto flag : modFlags) { + switch (flag) { + case ModInfo::FLAG_BACKUP: backupCount++; break; + case ModInfo::FLAG_FOREIGN: foreignCount++; break; + case ModInfo::FLAG_SEPARATOR: separatorCount++; break; + } + } + + if (!hasFlag(modFlags, ModInfo::FLAG_BACKUP) && + !hasFlag(modFlags, ModInfo::FLAG_FOREIGN) && + !hasFlag(modFlags, ModInfo::FLAG_SEPARATOR) && + !hasFlag(modFlags, ModInfo::FLAG_OVERWRITE)) { + if (m_OrganizerCore.currentProfile()->modEnabled(modIndex)) + activeCount++; + regularCount++; + } + } + + ui->activeModsCounter->display(activeCount); + ui->activeModsCounter->setToolTip(tr("" + "" + "" + "" + "" + "
Active mods: %1 of %2
Unmanaged mods/DLC: %3
Mod backups: %4
Separators: %5
") + .arg(activeCount) + .arg(regularCount) + .arg(foreignCount) + .arg(backupCount) + .arg(separatorCount) + ); +} + +void MainWindow::updatePluginCount() +{ + int activeMasterCount = 0; + int activeLightMasterCount = 0; + int activeRegularCount = 0; + int masterCount = 0; + int lightMasterCount = 0; + int regularCount = 0; + + PluginList *list = m_OrganizerCore.pluginList(); + + for (QString plugin : list->pluginNames()) { + bool active = list->isEnabled(plugin); + if (list->isMaster(plugin)) { + masterCount++; + activeMasterCount += active; + } else if (list->isLight(plugin) || list->isLightFlagged(plugin)) { + lightMasterCount++; + activeLightMasterCount += active; + } else { + regularCount++; + activeRegularCount += active; + } + } + + int activeCount = activeMasterCount + activeLightMasterCount + activeRegularCount; + int totalCount = masterCount + lightMasterCount + regularCount; + + ui->activePluginsCounter->display(activeCount); + ui->activePluginsCounter->setToolTip(tr("" + "" + "" + "" + "" + "" + "
Active plugins: %1 of %2
Active ESMs: %3 of %4
Active ESLs: %5 of %6
Active ESPs: %7 of %8
Active ESMs+ESPs: %9 of %10
") + .arg(activeCount).arg(totalCount) + .arg(activeMasterCount).arg(masterCount) + .arg(activeLightMasterCount).arg(lightMasterCount) + .arg(activeRegularCount).arg(regularCount) + .arg(activeMasterCount+activeRegularCount).arg(masterCount+regularCount) + ); +} + void MainWindow::information_clicked() { try { -- cgit v1.3.1