summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Rimpo <jeremy.rimpo@servermonkey.com>2023-10-03 23:15:42 -0500
committerGitHub <noreply@github.com>2023-10-03 23:15:42 -0500
commitf8a3d5b86e4a6884953df6737a762c0f2e28aec3 (patch)
treed65cb8bd982d95ef0163028903f1327c957c76b4 /src
parentb5ba8522d81ddd6231ae6063c3f3181605d96898 (diff)
parenta705938ffdc8aa2422ea936b0e2d1f629e6f9d11 (diff)
Merge pull request #1894 from ModOrganizer2/loot_0_22
WIP: Plugin sorting updates
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp25
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/organizercore.cpp2
-rw-r--r--src/organizercore.h3
-rw-r--r--src/pluginlist.cpp76
-rw-r--r--src/pluginlist.h8
6 files changed, 76 insertions, 40 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b576c318..dae91806 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -371,12 +371,7 @@ MainWindow::MainWindow(Settings& settings, OrganizerCore& organizerCore,
ui->groupCombo->installEventFilter(noWheel);
ui->profileBox->installEventFilter(noWheel);
- if (organizerCore.managedGame()->sortMechanism() ==
- MOBase::IPluginGame::SortMechanism::NONE) {
- ui->sortButton->setDisabled(true);
- ui->sortButton->setToolTip(tr("There is no supported sort mechanism for this game. "
- "You will probably have to use a third-party tool."));
- }
+ updateSortButton();
connect(&m_PluginContainer, SIGNAL(diagnosisUpdate()), this,
SLOT(scheduleCheckForProblems()));
@@ -399,6 +394,9 @@ MainWindow::MainWindow(Settings& settings, OrganizerCore& organizerCore,
SLOT(updateAvailable()));
connect(m_OrganizerCore.updater(), SIGNAL(motdAvailable(QString)), this,
SLOT(motdReceived(QString)));
+ connect(&m_OrganizerCore, &OrganizerCore::refreshTriggered, this, [this]() {
+ updateSortButton();
+ });
connect(&NexusInterface::instance(), SIGNAL(requestNXMDownload(QString)),
&m_OrganizerCore, SLOT(downloadRequestedNXM(QString)));
@@ -2766,6 +2764,8 @@ void MainWindow::on_actionSettings_triggered()
m_OrganizerCore.refreshLists();
+ updateSortButton();
+
if (settings.paths().profiles() != oldProfilesDirectory) {
refreshProfiles();
}
@@ -3033,6 +3033,19 @@ void MainWindow::toggleUpdateAction()
ui->actionUpdate->setVisible(s.checkForUpdates());
}
+void MainWindow::updateSortButton()
+{
+ if (m_OrganizerCore.managedGame()->sortMechanism() !=
+ IPluginGame::SortMechanism::NONE) {
+ ui->sortButton->setEnabled(true);
+ ui->sortButton->setToolTip(tr("Sort the plugins using LOOT."));
+ } else {
+ ui->sortButton->setDisabled(true);
+ ui->sortButton->setToolTip(tr("There is no supported sort mechanism for this game. "
+ "You will probably have to use a third-party tool."));
+ }
+}
+
void MainWindow::nxmEndorsementsAvailable(QVariant userData, QVariant resultData, int)
{
QVariantList data = resultData.toList();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 99feca83..fb424403 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -243,6 +243,8 @@ private:
void toggleMO2EndorseState();
void toggleUpdateAction();
+ void updateSortButton();
+
// update info
struct NxmUpdateInfoData
{
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 178ba04e..c06bbae2 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -1220,6 +1220,8 @@ void OrganizerCore::refresh(bool saveChanges)
m_ModList.notifyChange(-1);
refreshDirectoryStructure();
+
+ emit refreshTriggered();
}
void OrganizerCore::refreshESPList(bool force)
diff --git a/src/organizercore.h b/src/organizercore.h
index 7238466a..5bf6f4b6 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -471,6 +471,9 @@ signals:
// Use queued connections
void directoryStructureReady();
+ // Notify of a general UI refresh
+ void refreshTriggered();
+
private:
std::pair<unsigned int, ModInfo::Ptr> doInstall(const QString& archivePath,
MOBase::GuessedValue<QString> modName,
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp
index efa51ac7..1a780584 100644
--- a/src/pluginlist.cpp
+++ b/src/pluginlist.cpp
@@ -176,6 +176,7 @@ void PluginList::refresh(const QString& profileName,
ChangeBracket<PluginList> layoutChange(this);
QStringList primaryPlugins = m_GamePlugin->primaryPlugins();
+ QStringList enabledPlugins = m_GamePlugin->enabledPlugins();
GamePlugins* gamePlugins = m_GamePlugin->feature<GamePlugins>();
const bool lightPluginsAreSupported =
gamePlugins ? gamePlugins->lightPluginsAreSupported() : false;
@@ -203,11 +204,12 @@ void PluginList::refresh(const QString& profileName,
continue;
}
- bool forceEnabled = Settings::instance().game().forceEnableCoreFiles() &&
- primaryPlugins.contains(filename, Qt::CaseInsensitive);
+ bool forceLoaded = Settings::instance().game().forceEnableCoreFiles() &&
+ primaryPlugins.contains(filename, Qt::CaseInsensitive);
+ bool forceEnabled = enabledPlugins.contains(filename, Qt::CaseInsensitive);
bool forceDisabled =
m_GamePlugin->loadOrderMechanism() == IPluginGame::LoadOrderMechanism::None &&
- !forceEnabled;
+ !forceLoaded && !forceEnabled;
bool archive = false;
try {
@@ -236,8 +238,8 @@ void PluginList::refresh(const QString& profileName,
originName = modInfo->name();
}
- m_ESPs.push_back(ESPInfo(filename, forceEnabled, forceDisabled, originName,
- ToQString(current->getFullPath()), hasIni,
+ m_ESPs.push_back(ESPInfo(filename, forceLoaded, forceEnabled, forceDisabled,
+ originName, ToQString(current->getFullPath()), hasIni,
loadedArchives, lightPluginsAreSupported,
overridePluginsAreSupported));
m_ESPs.rbegin()->priority = -1;
@@ -395,6 +397,7 @@ void PluginList::enableESP(const QString& name, bool enable)
if (iter != m_ESPsByName.end()) {
auto enabled = m_ESPs[iter->second].enabled;
m_ESPs[iter->second].enabled = (enable && !m_ESPs[iter->second].forceDisabled) ||
+ m_ESPs[iter->second].forceLoaded ||
m_ESPs[iter->second].forceEnabled;
emit writePluginsList();
@@ -421,7 +424,8 @@ void PluginList::setEnabled(const QModelIndexList& indices, bool enabled)
{
QStringList dirty;
for (auto& idx : indices) {
- if (m_ESPs[idx.row()].forceEnabled || m_ESPs[idx.row()].forceDisabled)
+ if (m_ESPs[idx.row()].forceLoaded || m_ESPs[idx.row()].forceEnabled ||
+ m_ESPs[idx.row()].forceDisabled)
continue;
if (m_ESPs[idx.row()].enabled != enabled) {
m_ESPs[idx.row()].enabled = enabled;
@@ -439,7 +443,7 @@ void PluginList::setEnabledAll(bool enabled)
{
QStringList dirty;
for (ESPInfo& info : m_ESPs) {
- if (info.forceEnabled || info.forceDisabled)
+ if (info.forceLoaded || info.forceEnabled || info.forceDisabled)
continue;
if (info.enabled != enabled) {
info.enabled = enabled;
@@ -457,7 +461,7 @@ void PluginList::sendToPriority(const QModelIndexList& indices, int newPriority)
{
std::vector<int> pluginsToMove;
for (auto& idx : indices) {
- if (!m_ESPs[idx.row()].forceEnabled) {
+ if (!m_ESPs[idx.row()].forceLoaded) {
pluginsToMove.push_back(idx.row());
}
}
@@ -608,7 +612,7 @@ void PluginList::readLockedOrderFrom(const QString& fileName)
int pluginIndex = it->second;
// Do not allow locking forced plugins
- if (m_ESPs[pluginIndex].forceEnabled) {
+ if (m_ESPs[pluginIndex].forceLoaded) {
continue;
}
@@ -628,14 +632,14 @@ void PluginList::readLockedOrderFrom(const QString& fileName)
};
// See if we can just set the given priority
- if (!m_ESPs[m_ESPsByPriority.at(priority)].forceEnabled && !alreadyLocked()) {
+ if (!m_ESPs[m_ESPsByPriority.at(priority)].forceLoaded && !alreadyLocked()) {
m_LockedOrder[pluginName] = priority;
continue;
}
// Find the next higher priority we can set the plugin to
while (++priority < m_ESPs.size()) {
- if (!m_ESPs[m_ESPsByPriority.at(priority)].forceEnabled && !alreadyLocked()) {
+ if (!m_ESPs[m_ESPsByPriority.at(priority)].forceLoaded && !alreadyLocked()) {
m_LockedOrder[pluginName] = priority;
break;
}
@@ -755,7 +759,7 @@ bool PluginList::isESPLocked(int index) const
void PluginList::lockESPIndex(int index, bool lock)
{
if (lock) {
- if (!m_ESPs.at(index).forceEnabled)
+ if (!m_ESPs.at(index).forceLoaded)
m_LockedOrder[getName(index)] = m_ESPs.at(index).loadOrder;
else
return;
@@ -866,7 +870,7 @@ void PluginList::setState(const QString& name, PluginStates state)
if (iter != m_ESPsByName.end()) {
m_ESPs[iter->second].enabled =
(state == IPluginList::STATE_ACTIVE && !m_ESPs[iter->second].forceDisabled) ||
- m_ESPs[iter->second].forceEnabled;
+ m_ESPs[iter->second].forceLoaded || m_ESPs[iter->second].forceEnabled;
} else {
log::warn("Plugin not found: {}", name);
}
@@ -1181,7 +1185,7 @@ QVariant PluginList::checkstateData(const QModelIndex& modelIndex) const
{
const int index = modelIndex.row();
- if (m_ESPs[index].forceEnabled) {
+ if (m_ESPs[index].forceLoaded || m_ESPs[index].forceEnabled) {
return Qt::Checked;
} else if (m_ESPs[index].forceDisabled) {
return Qt::Unchecked;
@@ -1194,7 +1198,7 @@ QVariant PluginList::foregroundData(const QModelIndex& modelIndex) const
{
const int index = modelIndex.row();
- if ((modelIndex.column() == COL_NAME) && m_ESPs[index].forceEnabled) {
+ if ((modelIndex.column() == COL_NAME) && m_ESPs[index].forceLoaded) {
return QBrush(Qt::gray);
}
@@ -1253,6 +1257,12 @@ QVariant PluginList::tooltipData(const QModelIndex& modelIndex) const
toolTip += "<b>" + tr("Origin") + "</b>: " + esp.originName;
+ if (esp.forceLoaded) {
+ toolTip += "<br><b><i>" +
+ tr("This plugin can't be disabled or moved (enforced by the game).") +
+ "</i></b>";
+ }
+
if (esp.forceEnabled) {
toolTip += "<br><b><i>" +
tr("This plugin can't be disabled (enforced by the game).") + "</i></b>";
@@ -1485,8 +1495,9 @@ bool PluginList::setData(const QModelIndex& modIndex, const QVariant& value, int
bool result = false;
if (role == Qt::CheckStateRole) {
- m_ESPs[modIndex.row()].enabled =
- value.toInt() == Qt::Checked || m_ESPs[modIndex.row()].forceEnabled;
+ m_ESPs[modIndex.row()].enabled = value.toInt() == Qt::Checked ||
+ m_ESPs[modIndex.row()].forceLoaded ||
+ m_ESPs[modIndex.row()].forceEnabled;
m_LastCheck.restart();
emit dataChanged(modIndex, modIndex);
@@ -1543,12 +1554,13 @@ Qt::ItemFlags PluginList::flags(const QModelIndex& modelIndex) const
Qt::ItemFlags result = QAbstractItemModel::flags(modelIndex);
if (modelIndex.isValid()) {
- if (!m_ESPs[index].forceEnabled && !m_ESPs[index].forceDisabled) {
- result |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
- }
- if (modelIndex.column() == COL_PRIORITY) {
+ if (!m_ESPs[index].forceLoaded && !m_ESPs[index].forceDisabled)
+ result |= Qt::ItemIsDragEnabled;
+ if (!m_ESPs[index].forceLoaded && !m_ESPs[index].forceEnabled &&
+ !m_ESPs[index].forceDisabled)
+ result |= Qt::ItemIsUserCheckable;
+ if (modelIndex.column() == COL_PRIORITY)
result |= Qt::ItemIsEditable;
- }
result &= ~Qt::ItemIsDropEnabled;
} else {
result |= Qt::ItemIsDropEnabled;
@@ -1586,7 +1598,7 @@ void PluginList::setPluginPriority(int row, int& newPriority, bool isForced)
}
// also don't allow "regular" esms to be moved above primary plugins
while ((newPriorityTemp < static_cast<int>(m_ESPsByPriority.size() - 1)) &&
- (m_ESPs.at(m_ESPsByPriority.at(newPriorityTemp)).forceEnabled)) {
+ (m_ESPs.at(m_ESPsByPriority.at(newPriorityTemp)).forceLoaded)) {
++newPriorityTemp;
}
}
@@ -1656,7 +1668,7 @@ void PluginList::changePluginPriority(std::vector<int> rows, int newPriority)
// don't try to move plugins before force-enabled plugins
for (std::vector<ESPInfo>::const_iterator iter = m_ESPs.begin(); iter != m_ESPs.end();
++iter) {
- if (iter->forceEnabled) {
+ if (iter->forceLoaded) {
newPriority = std::max(newPriority, iter->priority + 1);
}
maxPriority = std::max(maxPriority, iter->priority + 1);
@@ -1742,13 +1754,15 @@ QModelIndex PluginList::parent(const QModelIndex&) const
return QModelIndex();
}
-PluginList::ESPInfo::ESPInfo(const QString& name, bool enabled, bool forceDisabled,
- const QString& originName, const QString& fullPath,
- bool hasIni, std::set<QString> archives,
- bool lightSupported, bool overrideSupported)
- : name(name), fullPath(fullPath), enabled(enabled), forceEnabled(enabled),
- forceDisabled(forceDisabled), priority(0), loadOrder(-1), originName(originName),
- hasIni(hasIni), archives(archives.begin(), archives.end()), modSelected(false)
+PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEnabled,
+ bool forceDisabled, const QString& originName,
+ const QString& fullPath, bool hasIni,
+ std::set<QString> archives, bool lightSupported,
+ bool overrideSupported)
+ : name(name), fullPath(fullPath), enabled(forceLoaded), forceLoaded(forceLoaded),
+ forceEnabled(forceEnabled), forceDisabled(forceDisabled), priority(0),
+ loadOrder(-1), originName(originName), hasIni(hasIni),
+ archives(archives.begin(), archives.end()), modSelected(false)
{
try {
ESP::File file(ToWString(fullPath));
diff --git a/src/pluginlist.h b/src/pluginlist.h
index 0c53fc25..db32d911 100644
--- a/src/pluginlist.h
+++ b/src/pluginlist.h
@@ -313,13 +313,15 @@ signals:
private:
struct ESPInfo
{
- ESPInfo(const QString& name, bool enabled, bool forceDisabled,
- const QString& originName, const QString& fullPath, bool hasIni,
- std::set<QString> archives, bool lightSupported, bool overrideSupported);
+ ESPInfo(const QString& name, bool forceLoaded, bool forceEnabled,
+ bool forceDisabled, const QString& originName, const QString& fullPath,
+ bool hasIni, std::set<QString> archives, bool lightSupported,
+ bool overrideSupported);
QString name;
QString fullPath;
bool enabled;
+ bool forceLoaded;
bool forceEnabled;
bool forceDisabled;
int priority;