Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show blueprint master count in plugin counter tooltip, hide unsupported plugin types #2143

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 47 additions & 13 deletions src/pluginlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <widgetutility.h>

#include "copyeventfilter.h"
#include "gameplugins.h"
#include "genericicondelegate.h"
#include "mainwindow.h"
#include "modelutils.h"
Expand Down Expand Up @@ -59,10 +60,12 @@ void PluginListView::updatePluginCount()
int activeMasterCount = 0;
int activeMediumMasterCount = 0;
int activeLightMasterCount = 0;
int activeBlueprintCount = 0;
int activeRegularCount = 0;
int masterCount = 0;
int mediumMasterCount = 0;
int lightMasterCount = 0;
int blueprintCount = 0;
int regularCount = 0;
int activeVisibleCount = 0;

Expand All @@ -89,37 +92,68 @@ void PluginListView::updatePluginCount()
activeRegularCount += active;
activeVisibleCount += visible && active;
}

if (list->isBlueprintFlagged(plugin)) {
// separate if-statement because blueprint masters are also counted as
// (medium/light) masters
blueprintCount++;
activeBlueprintCount += active;
}
}

int activeCount = activeMasterCount + activeMediumMasterCount +
activeLightMasterCount + activeRegularCount;
int totalCount = masterCount + mediumMasterCount + lightMasterCount + regularCount;

ui.counter->display(activeVisibleCount);
ui.counter->setToolTip(
auto toolTip =
tr("<table cellspacing=\"6\">"
"<tr><th>Type</th><th>Active </th><th>Total</th></tr>"
"<tr><td>All plugins:</td><td align=right>%1 </td><td "
"align=right>%2</td></tr>"
"<tr><td>ESMs:</td><td align=right>%3 </td><td align=right>%4</td></tr>"
"<tr><td>ESPs:</td><td align=right>%7 </td><td align=right>%8</td></tr>"
"<tr><td>ESMs+ESPs:</td><td align=right>%9 </td><td "
"align=right>%10</td></tr>"
"<tr><td>ESHs:</td><td align=right>%11 </td><td align=right>%12</td></tr>"
"<tr><td>ESLs:</td><td align=right>%5 </td><td align=right>%6</td></tr>"
"</table>")
"<tr><td>ESPs:</td><td align=right>%5 </td><td align=right>%6</td></tr>"
"<tr><td>ESMs+ESPs:</td><td align=right>%7 </td><td "
"align=right>%8</td></tr>")
.arg(activeCount)
.arg(totalCount)
.arg(activeMasterCount)
.arg(masterCount)
.arg(activeLightMasterCount)
.arg(lightMasterCount)
.arg(activeRegularCount)
.arg(regularCount)
.arg(activeMasterCount + activeRegularCount)
.arg(masterCount + regularCount)
.arg(activeMediumMasterCount)
.arg(mediumMasterCount));
.arg(masterCount + regularCount);

auto gamePlugins = m_core->gameFeatures().gameFeature<GamePlugins>();
const bool lightPluginsAreSupported =
gamePlugins ? gamePlugins->lightPluginsAreSupported() : false;
const bool mediumPluginsAreSupported =
gamePlugins ? gamePlugins->mediumPluginsAreSupported() : false;
const bool blueprintPluginsAreSupported =
gamePlugins ? gamePlugins->blueprintPluginsAreSupported() : false;

if (mediumPluginsAreSupported) {
toolTip +=
tr("<tr><td>ESHs:</td><td align=right>%1 </td><td align=right>%2</td></tr>")
.arg(activeMediumMasterCount)
.arg(mediumMasterCount);
}
if (lightPluginsAreSupported) {
toolTip +=
tr("<tr><td>ESLs:</td><td align=right>%1 </td><td align=right>%2</td></tr>")
.arg(activeLightMasterCount)
.arg(lightMasterCount);
}
if (blueprintPluginsAreSupported) {
toolTip += tr("<tr><td>Blueprint masters:</td><td align=right>%1 </td><td "
"align=right>%2</td></tr>")
.arg(activeBlueprintCount)
.arg(blueprintCount);
}

toolTip += "</table>";

ui.counter->display(activeVisibleCount);
ui.counter->setToolTip(toolTip);
}

void PluginListView::onFilterChanged(const QString& filter)
Expand Down
Loading