Skip to content

Commit

Permalink
Additional overlay plugin support
Browse files Browse the repository at this point in the history
* Add isOverlayFlagged to IPluginList
* Further notate plugin list
* Rename to match xEdit / Wrye / LOOT
* Update counter
  • Loading branch information
Silarn committed Oct 8, 2023
1 parent 48e8fdf commit 028c8ea
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
27 changes: 20 additions & 7 deletions src/pluginlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,13 +1006,13 @@ bool PluginList::isLightFlagged(const QString& name) const
}
}

bool PluginList::isOverrideFlagged(const QString& name) const
bool PluginList::isOverlayFlagged(const QString& name) const
{
auto iter = m_ESPsByName.find(name);
if (iter == m_ESPsByName.end()) {
return false;
} else {
return m_ESPs[iter->second].isOverrideFlagged;
return m_ESPs[iter->second].isOverlayFlagged;
}
}

Expand Down Expand Up @@ -1093,7 +1093,7 @@ void PluginList::generatePluginIndexes()
.arg((numESLs) % 4096, 3, 16, QChar('0'))
.toUpper();
++numESLs;
} else if (overridePluginsSupported && m_ESPs[i].isOverrideFlagged) {
} else if (overridePluginsSupported && m_ESPs[i].isOverlayFlagged) {
m_ESPs[i].index = QString("");
++numSkipped;
} else {
Expand Down Expand Up @@ -1233,6 +1233,8 @@ QVariant PluginList::fontData(const QModelIndex& modelIndex) const
result.setWeight(QFont::Bold);
} else if (m_ESPs[index].isLightFlagged) {
result.setItalic(true);
} else if (m_ESPs[index].isOverlayFlagged) {
result.setUnderline(true);
}

return result;
Expand Down Expand Up @@ -1327,6 +1329,13 @@ QVariant PluginList::tooltipData(const QModelIndex& modelIndex) const
.arg(type);
}

if (esp.isOverlayFlagged) {
toolTip +=
"<br><br>" + tr("This plugin is flagged as an overlay plugin. It contains only "
"modified records and will overlay those changes onto the "
"existing records in memory. It takes no memory space.");
}

if (esp.forceDisabled) {
toolTip += "<br><br>" + tr("This game does not currently permit custom plugin "
"loading. There may be manual workarounds.");
Expand Down Expand Up @@ -1447,6 +1456,10 @@ QVariant PluginList::iconData(const QModelIndex& modelIndex) const
result.append(":/MO/gui/awaiting");
}

if (esp.isOverlayFlagged) {
result.append(":/MO/gui/instance_switch");
}

if (info && !info->loot.dirty.empty()) {
result.append(":/MO/gui/edit_clear");
}
Expand Down Expand Up @@ -1759,7 +1772,7 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEn
bool forceDisabled, const QString& originName,
const QString& fullPath, bool hasIni,
std::set<QString> archives, bool lightSupported,
bool overrideSupported)
bool overlaySupported)
: name(name), fullPath(fullPath), enabled(forceLoaded), forceLoaded(forceLoaded),
forceEnabled(forceEnabled), forceDisabled(forceDisabled), priority(0),
loadOrder(-1), originName(originName), hasIni(hasIni),
Expand All @@ -1771,9 +1784,9 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEn
hasMasterExtension = (extension == "esm");
hasLightExtension = lightSupported && (extension == "esl");
isMasterFlagged = file.isMaster();
isOverrideFlagged = overrideSupported && file.isOverride();
isOverlayFlagged = overlaySupported && file.isOverlay();
isLightFlagged =
lightSupported && !isOverrideFlagged && file.isLight(overrideSupported);
lightSupported && !isOverlayFlagged && file.isLight(overlaySupported);

author = QString::fromLatin1(file.author().c_str());
description = QString::fromLatin1(file.description().c_str());
Expand All @@ -1786,7 +1799,7 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEn
hasMasterExtension = false;
hasLightExtension = false;
isMasterFlagged = false;
isOverrideFlagged = false;
isOverlayFlagged = false;
isLightFlagged = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pluginlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class PluginList : public QAbstractItemModel
bool hasLightExtension(const QString& name) const;
bool isMasterFlagged(const QString& name) const;
bool isLightFlagged(const QString& name) const;
bool isOverrideFlagged(const QString& name) const;
bool isOverlayFlagged(const QString& name) const;

boost::signals2::connection onRefreshed(const std::function<void()>& callback);
boost::signals2::connection
Expand Down Expand Up @@ -333,7 +333,7 @@ public slots:
bool hasLightExtension;
bool isMasterFlagged;
bool isLightFlagged;
bool isOverrideFlagged;
bool isOverlayFlagged;
bool modSelected;
QString author;
QString description;
Expand Down
5 changes: 5 additions & 0 deletions src/pluginlistproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,8 @@ bool PluginListProxy::isLightFlagged(const QString& name) const
{
return m_Proxied->isLightFlagged(name);
}

bool PluginListProxy::isOverlayFlagged(const QString& name) const
{
return m_Proxied->isOverlayFlagged(name);
}
1 change: 1 addition & 0 deletions src/pluginlistproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class PluginListProxy : public MOBase::IPluginList
bool hasLightExtension(const QString& name) const override;
bool isMasterFlagged(const QString& name) const override;
bool isLightFlagged(const QString& name) const override;
bool isOverlayFlagged(const QString& name) const override;

private:
friend class OrganizerProxy;
Expand Down
16 changes: 13 additions & 3 deletions src/pluginlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ void PluginListView::updatePluginCount()
{
int activeMasterCount = 0;
int activeLightMasterCount = 0;
int activeOverlayCount = 0;
int activeRegularCount = 0;
int masterCount = 0;
int lightMasterCount = 0;
int overlayCount = 0;
int regularCount = 0;
int activeVisibleCount = 0;

Expand All @@ -78,15 +80,20 @@ void PluginListView::updatePluginCount()
masterCount++;
activeMasterCount += active;
activeVisibleCount += visible && active;
} else if (list->isOverlayFlagged(plugin)) {
overlayCount++;
activeOverlayCount += active;
activeVisibleCount += visible && active;
} else {
regularCount++;
activeRegularCount += active;
activeVisibleCount += visible && active;
}
}

int activeCount = activeMasterCount + activeLightMasterCount + activeRegularCount;
int totalCount = masterCount + lightMasterCount + regularCount;
int activeCount = activeMasterCount + activeLightMasterCount + activeOverlayCount +
activeRegularCount;
int totalCount = masterCount + lightMasterCount + overlayCount + regularCount;

ui.counter->display(activeVisibleCount);
ui.counter->setToolTip(
Expand All @@ -99,6 +106,7 @@ void PluginListView::updatePluginCount()
"<tr><td>ESMs+ESPs:</td><td align=right>%9 </td><td "
"align=right>%10</td></tr>"
"<tr><td>ESLs:</td><td align=right>%5 </td><td align=right>%6</td></tr>"
"<tr><td>Overlay:</td><td align=right>%11 </td><td align=right>%12</td></tr>"
"</table>")
.arg(activeCount)
.arg(totalCount)
Expand All @@ -109,7 +117,9 @@ void PluginListView::updatePluginCount()
.arg(activeRegularCount)
.arg(regularCount)
.arg(activeMasterCount + activeRegularCount)
.arg(masterCount + regularCount));
.arg(masterCount + regularCount)
.arg(activeOverlayCount)
.arg(overlayCount));
}

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

0 comments on commit 028c8ea

Please sign in to comment.