From 58b6e0eb48b4d4b201613f1062796a9af68fe454 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 20 Jan 2021 18:16:20 +0100 Subject: Increase robustness of mods priority in profile. --- src/profile.cpp | 200 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 123 insertions(+), 77 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index bb3a11e2..098cff6e 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -230,14 +230,13 @@ void Profile::doWriteModlist() return; } - for (std::map::const_reverse_iterator iter = m_ModIndexByPriority.crbegin(); iter != m_ModIndexByPriority.crend(); iter++ ) { + for (auto iter = m_ModIndexByPriority.crbegin(); iter != m_ModIndexByPriority.crend(); iter++) { // the priority order was inverted on load so it has to be inverted again unsigned int index = iter->second; if (index != UINT_MAX) { ModInfo::Ptr modInfo = ModInfo::getByIndex(index); - std::vector flags = modInfo->getFlags(); - if ((modInfo->getFixedPriority() == INT_MIN)) { - if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_FOREIGN) != flags.end()) { + if (!modInfo->isFixedPriority()) { + if (modInfo->isForeign()) { file->write("*"); } else if (m_ModStatus[index].m_Enabled) { file->write("+"); @@ -270,10 +269,9 @@ void Profile::createTweakedIniFile() return; } - for (int i = getPriorityMinimum(); i < getPriorityMinimum() + (int)numRegularMods(); ++i) { - unsigned int idx = modIndexByPriority(i); - if (m_ModStatus[idx].m_Enabled) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(idx); + for (auto& [priority, index] : m_ModIndexByPriority) { + if (m_ModStatus[index].m_Enabled) { + ModInfo::Ptr modInfo = ModInfo::getByIndex(index); mergeTweaks(modInfo, tweakedIni); } } @@ -368,6 +366,38 @@ void Profile::renameModInList(QFile &modList, const QString &oldName, const QStr void Profile::refreshModStatus() { + // this function refreshes mod status (enabled/disabled) and priority + // using the profile mod list file and the mods in the mods folder using + // the following steps + // + // 1) the mod list file is read and mods status/priority are updated by + // considering the content of the file (for status) and the order (for + // priority), missing or invalid mods are discarded (with a warning) + // 2) the priority are reversed to match the plugin list (highest wins) + // since the mod list is written in reverse order + // 3) at the same time, new mods (not in the mod list file) are added + // - foreign mods are given low priority (below 0) + // - regular mods are given high priority (above mods from the mod list) + // 4) the priority are shifted to ensure that the minimum priority is 0 + // 5) the priority of backups are computed such that the first backup is + // above all regular mods + // + // in the context of the profile, "regular mods" means a mod whose priority + // can be set by the user (i.e. not a backup or overwrite) + // + // this method ensures that the mods priority is as follow + // + // 0 mod1 + // 1 mod2 + // ... + // K-1 modK (K = m_NumRegularMods) + // K backup1 + // K+1 backup2 + // ... + // N-2 backupX + // N-1 overwrite (N = number of mods) + // + writeModlistNow(true); // if there are pending changes write them first QFile file(getModlistFileName()); @@ -387,6 +417,8 @@ void Profile::refreshModStatus() int index = 0; while (!file.atEnd()) { QByteArray line = file.readLine().trimmed(); + + // find the mod name and the enabled status bool enabled = true; QString modName; if (line.length() == 0) { @@ -398,89 +430,106 @@ void Profile::refreshModStatus() } else if (line.at(0) == '-') { enabled = false; modName = QString::fromUtf8(line.mid(1).trimmed().constData()); - } else if ((line.at(0) == '+') - || (line.at(0) == '*')) { + } else if (line.at(0) == '+' || line.at(0) == '*') { modName = QString::fromUtf8(line.mid(1).trimmed().constData()); } else { modName = QString::fromUtf8(line.trimmed().constData()); } - if (modName.size() > 0) { - QString lookupName = modName; - if (modName.compare("overwrite", Qt::CaseInsensitive) == 0) { - warnAboutOverwrite = true; - } - if (namesRead.find(lookupName) != namesRead.end()) { - continue; - } else { - namesRead.insert(lookupName); - } - unsigned int modIndex = ModInfo::getIndex(lookupName); - if (modIndex != UINT_MAX) { - ModInfo::Ptr info = ModInfo::getByIndex(modIndex); - if ((modIndex < m_ModStatus.size()) - && (info->getFixedPriority() == INT_MIN)) { - m_ModStatus[modIndex].m_Enabled = enabled; - if (m_ModStatus[modIndex].m_Priority == -1) { - if (static_cast(index) >= m_ModStatus.size()) { - throw MyException(tr("invalid mod index: %1").arg(index)); - } - m_ModStatus[modIndex].m_Priority = index++; - } - } else { - log::warn( - "no mod state for \"{}\" (profile \"{}\")", - modName, m_Directory.path()); - // need to rewrite the modlist to fix this - modStatusModified = true; + + if (modName.isEmpty()) { + continue; + } + + if (modName.compare("overwrite", Qt::CaseInsensitive) == 0) { + warnAboutOverwrite = true; + } + + // check if the name was already read + if (namesRead.find(modName) != namesRead.end()) { + continue; + } + namesRead.insert(modName); + + unsigned int modIndex = ModInfo::getIndex(modName); + if (modIndex == UINT_MAX) { + log::debug( + "mod not found: \"{}\" (profile \"{}\")", + modName, m_Directory.path()); + // need to rewrite the modlist to fix this + modStatusModified = true; + continue; + } + + // find the mod and check that this is a regular mod (and not a backup) + ModInfo::Ptr info = ModInfo::getByIndex(modIndex); + if (modIndex < m_ModStatus.size() && !info->isFixedPriority()) { + m_ModStatus[modIndex].m_Enabled = enabled; + if (m_ModStatus[modIndex].m_Priority == -1) { + if (static_cast(index) >= m_ModStatus.size()) { + throw Exception(tr("invalid mod index: %1").arg(index)); } - } else { - log::debug( - "mod not found: \"{}\" (profile \"{}\")", - modName, m_Directory.path()); - // need to rewrite the modlist to fix this - modStatusModified = true; + m_ModStatus[modIndex].m_Priority = index++; } + } else { + log::warn( + "no mod state for \"{}\" (profile \"{}\")", + modName, m_Directory.path()); + // need to rewrite the modlist to fix this + modStatusModified = true; } - } - int numKnownMods = index; + } // while (!file.atEnd()) + file.close(); + + const int numKnownMods = index; int topInsert = 0; - // invert priority order to match that of the pluginlist. Also - // give priorities to mods not referenced in the profile + // invert priority order to match that of the pluginlist, also + // give priorities to mods not referenced in the profile and + // count the number of regular mods + m_NumRegularMods = 0; for (size_t i = 0; i < m_ModStatus.size(); ++i) { ModInfo::Ptr modInfo = ModInfo::getByIndex(static_cast(i)); if (modInfo->alwaysEnabled()) { m_ModStatus[i].m_Enabled = true; } - if (modInfo->getFixedPriority() == INT_MAX) { + if (modInfo->isOverwrite()) { + m_ModStatus[i].m_Priority = m_ModStatus.size() - 1; continue; } if (m_ModStatus[i].m_Priority != -1) { m_ModStatus[i].m_Priority = numKnownMods - m_ModStatus[i].m_Priority - 1; + ++m_NumRegularMods; } else { if (static_cast(index) >= m_ModStatus.size()) { - throw MyException(tr("invalid mod index: %1").arg(index)); + throw Exception(tr("invalid mod index: %1").arg(index)); } - if (modInfo->hasFlag(ModInfo::FLAG_FOREIGN)) { + + // skip backups on purpose to avoid inserting backups in-between + // regular mods + if (modInfo->isForeign()) { m_ModStatus[i].m_Priority = --topInsert; - } else { + ++m_NumRegularMods; + } else if (!modInfo->isBackup()) { m_ModStatus[i].m_Priority = index++; + ++m_NumRegularMods; } + // also, mark the mod-list as changed modStatusModified = true; } } - // to support insertion of new mods at the top we may now have mods with negative priority. shift them all up - // to align priority with 0 + + // to support insertion of new mods at the top we may now have mods with negative priority, + // so shift them all up to align priority with 0 if (topInsert < 0) { int offset = topInsert * -1; for (size_t i = 0; i < m_ModStatus.size(); ++i) { ModInfo::Ptr modInfo = ModInfo::getByIndex(static_cast(i)); - if (modInfo->getFixedPriority() == INT_MAX) { + if (modInfo->isFixedPriority()) { continue; } @@ -488,7 +537,15 @@ void Profile::refreshModStatus() } } - file.close(); + // set the backups priority + int backupPriority = m_NumRegularMods; + for (size_t i = 0; i < m_ModStatus.size(); ++i) { + ModInfo::Ptr modInfo = ModInfo::getByIndex(static_cast(i)); + if (modInfo->isBackup()) { + m_ModStatus[i].m_Priority = backupPriority++; + } + } + updateIndices(); // User has a mod named some variation of "overwrite". Tell them about it. @@ -519,17 +576,10 @@ void Profile::dumpModStatus() const void Profile::updateIndices() { - m_NumRegularMods = 0; m_ModIndexByPriority.clear(); for (unsigned int i = 0; i < m_ModStatus.size(); ++i) { int priority = m_ModStatus[i].m_Priority; - if (priority == INT_MIN) { - // don't assign this to mapping at all, it's probably the overwrite mod - continue; - } else { - ++m_NumRegularMods; - m_ModIndexByPriority[priority] = i; - } + m_ModIndexByPriority[priority] = i; } } @@ -631,27 +681,21 @@ int Profile::getModPriority(unsigned int index) const } -void Profile::setModPriority(unsigned int index, int &newPriority) +bool Profile::setModPriority(unsigned int index, int &newPriority) { - if (m_ModStatus.at(index).m_Overwrite) { - // can't change priority of the overwrite - return; + if (ModInfo::getByIndex(index)->isFixedPriority()) { + // can't change priority of overwrite/backups + return false; } + newPriority = std::clamp(newPriority, 0, static_cast(m_NumRegularMods) - 1); + int oldPriority = m_ModStatus.at(index).m_Priority; int lastPriority = INT_MIN; if (newPriority == oldPriority) { // nothing to do - return; - } - - // we need to put the mod before backups - auto it = std::find_if(m_ModIndexByPriority.begin(), m_ModIndexByPriority.end(), [](auto&& p) { - return ModInfo::getByIndex(p.second)->isBackup(); - }); - if (it != m_ModIndexByPriority.end() && it->first <= newPriority) { - newPriority = it->first - 1; + return false; } for (auto& [priority, index] : m_ModIndexByPriority) { @@ -669,6 +713,8 @@ void Profile::setModPriority(unsigned int index, int &newPriority) updateIndices(); m_ModListWriter.write(); + + return true; } Profile *Profile::createPtrFrom(const QString &name, const Profile &reference, MOBase::IPluginGame const *gamePlugin) -- cgit v1.3.1 From 36489c7d8fd6f1b79f29edc5d1f6c2d8b231adf9 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Thu, 21 Jan 2021 19:21:27 +0100 Subject: Add const-qualifier to for loop variable. --- src/profile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index 098cff6e..c45ecd30 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -269,7 +269,7 @@ void Profile::createTweakedIniFile() return; } - for (auto& [priority, index] : m_ModIndexByPriority) { + for (const auto& [priority, index] : m_ModIndexByPriority) { if (m_ModStatus[index].m_Enabled) { ModInfo::Ptr modInfo = ModInfo::getByIndex(index); mergeTweaks(modInfo, tweakedIni); -- cgit v1.3.1 From 62a9d13948e6e299d41eb6876c0f1fbaf0160d79 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Thu, 21 Jan 2021 19:31:05 +0100 Subject: Remove unused priority-related functions from Profile. --- src/profile.cpp | 18 +----------------- src/profile.h | 11 ----------- 2 files changed, 1 insertion(+), 28 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index c45ecd30..caea776c 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -600,17 +600,6 @@ std::vector > Profile::getActiveMods() return result; } - -unsigned int Profile::modIndexByPriority(int priority) const -{ - try { - return m_ModIndexByPriority.at(priority); - } catch (std::out_of_range) { - throw MyException(tr("invalid priority %1").arg(priority)); - } -} - - void Profile::setModEnabled(unsigned int index, bool enabled) { if (index >= m_ModStatus.size()) { @@ -698,7 +687,7 @@ bool Profile::setModPriority(unsigned int index, int &newPriority) return false; } - for (auto& [priority, index] : m_ModIndexByPriority) { + for (const auto& [priority, index] : m_ModIndexByPriority) { if (newPriority < oldPriority && priority >= newPriority && priority < oldPriority) { m_ModStatus.at(index).m_Priority += 1; } @@ -1085,11 +1074,6 @@ void Profile::storeSettingsByArray(const QString &prefix, const QListendArray(); } -int Profile::getPriorityMinimum() const -{ - return m_ModIndexByPriority.begin()->first; -} - bool Profile::forcedLibrariesEnabled(const QString &executable) const { return setting("forced_libraries", executable + "/enabled", false).toBool(); diff --git a/src/profile.h b/src/profile.h index 903a8553..d354dd48 100644 --- a/src/profile.h +++ b/src/profile.h @@ -261,15 +261,6 @@ public: **/ size_t numMods() const { return m_ModStatus.size(); } - /** - * @brief retrieve the mod index based on the priority - * - * @param priority priority to look up - * @return the index of the mod - * @throw std::exception an exception is thrown if there is no mod with the specified priority - **/ - unsigned int modIndexByPriority(int priority) const; - /** * @brief enable or disable a mod * @@ -333,8 +324,6 @@ public: QList settingsByArray(const QString &prefix) const; void storeSettingsByArray(const QString &prefix, const QList &values); - int getPriorityMinimum() const; - bool forcedLibrariesEnabled(const QString &executable) const; void setForcedLibrariesEnabled(const QString &executable, bool enabled); QList determineForcedLibraries(const QString &executable) const; -- cgit v1.3.1 From 1747dcf5632a7887906b9b6d412e95e3af9c8249 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Thu, 21 Jan 2021 19:42:41 +0100 Subject: INT_MAX -> std::numeric_limits, plus minor clean. --- src/modlistbypriorityproxy.cpp | 2 +- src/organizercore.cpp | 2 +- src/profile.cpp | 2 +- src/profile.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/modlistbypriorityproxy.cpp b/src/modlistbypriorityproxy.cpp index 7dae7a54..d1d045fc 100644 --- a/src/modlistbypriorityproxy.cpp +++ b/src/modlistbypriorityproxy.cpp @@ -234,7 +234,7 @@ bool ModListByPriorityProxy::canDropMimeData(const QMimeData* data, Qt::DropActi bool hasSeparator = false; unsigned int firstRowIndex = -1; - int firstRowPriority = INT_MAX; + int firstRowPriority = std::numeric_limits::max(); for (auto sourceRow : dropInfo.rows()) { hasSeparator = hasSeparator || ModInfo::getByIndex(sourceRow)->isSeparator(); if (m_sortOrder == Qt::AscendingOrder && m_profile->getModPriority(sourceRow) < firstRowPriority diff --git a/src/organizercore.cpp b/src/organizercore.cpp index d6c22d3c..cf641886 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1943,7 +1943,7 @@ std::vector OrganizerCore::fileMapping(const QString &profileName, bool overwriteActive = false; - for (auto mod : profile.getActiveMods()) { + for (const auto& mod : profile.getActiveMods()) { if (std::get<0>(mod).compare("overwrite", Qt::CaseInsensitive) == 0) { continue; } diff --git a/src/profile.cpp b/src/profile.cpp index caea776c..acda465b 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -591,7 +591,7 @@ std::vector > Profile::getActiveMods() if ((iter->second != UINT_MAX) && m_ModStatus[iter->second].m_Enabled) { ModInfo::Ptr modInfo = ModInfo::getByIndex(iter->second); if (modInfo->hasFlag(ModInfo::FLAG_OVERWRITE)) - result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), INT_MAX)); + result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), std::numeric_limits::max())); else result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), m_ModStatus[iter->second].m_Priority)); } diff --git a/src/profile.h b/src/profile.h index d354dd48..d1e3f104 100644 --- a/src/profile.h +++ b/src/profile.h @@ -243,7 +243,7 @@ public: * * @return list of active mods sorted by priority (ascending). "first" is the mod name, "second" is its path **/ - std::vector > getActiveMods(); + std::vector> getActiveMods(); /** * @brief retrieve a mod of the indexes ordered by priority -- cgit v1.3.1 From 60085ae4b662cfd5a3f3d4da78994a275904af96 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Thu, 21 Jan 2021 20:01:43 +0100 Subject: Use actual priority of overwrite instead of INT_MAX, and remove useless checks. --- src/profile.cpp | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/profile.cpp b/src/profile.cpp index acda465b..6b8d0709 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -232,20 +232,18 @@ void Profile::doWriteModlist() for (auto iter = m_ModIndexByPriority.crbegin(); iter != m_ModIndexByPriority.crend(); iter++) { // the priority order was inverted on load so it has to be inverted again - unsigned int index = iter->second; - if (index != UINT_MAX) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(index); - if (!modInfo->isFixedPriority()) { - if (modInfo->isForeign()) { - file->write("*"); - } else if (m_ModStatus[index].m_Enabled) { - file->write("+"); - } else { - file->write("-"); - } - file->write(modInfo->name().toUtf8()); - file->write("\r\n"); + const auto index = iter->second; + ModInfo::Ptr modInfo = ModInfo::getByIndex(index); + if (!modInfo->isFixedPriority()) { + if (modInfo->isForeign()) { + file->write("*"); + } else if (m_ModStatus[index].m_Enabled) { + file->write("+"); + } else { + file->write("-"); } + file->write(modInfo->name().toUtf8()); + file->write("\r\n"); } } @@ -587,13 +585,10 @@ void Profile::updateIndices() std::vector > Profile::getActiveMods() { std::vector > result; - for (std::map::const_iterator iter = m_ModIndexByPriority.begin(); iter != m_ModIndexByPriority.end(); iter++ ) { - if ((iter->second != UINT_MAX) && m_ModStatus[iter->second].m_Enabled) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(iter->second); - if (modInfo->hasFlag(ModInfo::FLAG_OVERWRITE)) - result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), std::numeric_limits::max())); - else - result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), m_ModStatus[iter->second].m_Priority)); + for (const auto& [priority, index] : m_ModIndexByPriority) { + if (m_ModStatus[index].m_Enabled) { + ModInfo::Ptr modInfo = ModInfo::getByIndex(index); + result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), m_ModStatus[index].m_Priority)); } } -- cgit v1.3.1 From 34c87a0efa18ad77cbf773bc99bd9f08082b27e9 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Thu, 21 Jan 2021 21:12:46 +0100 Subject: Prevent backups from being enabled. --- src/modinfo.h | 6 +++--- src/modinfobackup.h | 1 + src/profile.cpp | 9 ++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/modinfo.h b/src/modinfo.h index 0fbcd1c0..ff6c4001 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -606,10 +606,10 @@ public: // Methods after this do not come from IModInterface: // bool isFixedPriority() const { return isBackup() || isOverwrite(); } - /** - * @return true if the mod is always enabled. - */ + // check if this mod should always be enabled or disabled + // virtual bool alwaysEnabled() const { return false; } + virtual bool alwaysDisabled() const { return false; } /** * @return true if the mod can be updated. diff --git a/src/modinfobackup.h b/src/modinfobackup.h index 9529855b..853a1211 100644 --- a/src/modinfobackup.h +++ b/src/modinfobackup.h @@ -20,6 +20,7 @@ public: virtual void setNexusID(int) override {} virtual void endorse(bool) override {} virtual void ignoreUpdate(bool) override {} + virtual bool alwaysDisabled() const override { return true; } virtual bool canBeUpdated() const override { return false; } virtual QDateTime getExpires() const override { return QDateTime(); } virtual bool canBeEnabled() const override { return false; } diff --git a/src/profile.cpp b/src/profile.cpp index 6b8d0709..66c23ea1 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -602,11 +602,15 @@ void Profile::setModEnabled(unsigned int index, bool enabled) } ModInfo::Ptr modInfo = ModInfo::getByIndex(index); + // we could quit in the following case, this shouldn't be a change anyway, // but at least this allows the situation to be fixed in case of an error if (modInfo->alwaysEnabled()) { enabled = true; } + if (modInfo->alwaysDisabled()) { + enabled = false; + } if (enabled != m_ModStatus[index].m_Enabled) { m_ModStatus[index].m_Enabled = enabled; @@ -614,7 +618,7 @@ void Profile::setModEnabled(unsigned int index, bool enabled) } } -void Profile::setModsEnabled(const QList &modsToEnable, const QList &modsToDisable) +void Profile::setModsEnabled(const QList& modsToEnable, const QList& modsToDisable) { QList dirtyMods; for (auto idx : modsToEnable) { @@ -622,6 +626,9 @@ void Profile::setModsEnabled(const QList &modsToEnable, const QLis log::error("invalid mod index: {}", idx); continue; } + if (ModInfo::getByIndex(idx)->alwaysDisabled()) { + continue; + } if (!m_ModStatus[idx].m_Enabled) { m_ModStatus[idx].m_Enabled = true; dirtyMods.append(idx); -- cgit v1.3.1 From d81fb09f33f8cd668db20b6120c481580c6c938e Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Thu, 21 Jan 2021 21:20:01 +0100 Subject: Replace isFixedPriority by hasAutomaticPriority. --- src/modinfo.h | 5 +++-- src/modlist.cpp | 4 ++-- src/profile.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/profile.cpp') diff --git a/src/modinfo.h b/src/modinfo.h index ff6c4001..f93296d2 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -602,9 +602,10 @@ public: // Methods after this do not come from IModInterface: */ virtual void ignoreUpdate(bool ignore) = 0; - // check if this mod has a fixed priority (i.e. that cannot be modified by users) + // check if the priority of this mod is not user-modifiable (i.e. + // computed by MO2 automatically) // - bool isFixedPriority() const { return isBackup() || isOverwrite(); } + bool hasAutomaticPriority() const { return isBackup() || isOverwrite(); } // check if this mod should always be enabled or disabled // diff --git a/src/modlist.cpp b/src/modlist.cpp index 6637f48a..e2a443bd 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -197,7 +197,7 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const return version; } else if (column == COL_PRIORITY) { - if (modInfo->isFixedPriority()) { + if (modInfo->hasAutomaticPriority()) { return QVariant(); // hide priority for mods where it's fixed } else { @@ -642,7 +642,7 @@ Qt::ItemFlags ModList::flags(const QModelIndex &modelIndex) const } if (modelIndex.isValid()) { ModInfo::Ptr modInfo = ModInfo::getByIndex(modelIndex.row()); - if (!modInfo->isFixedPriority()) { + if (!modInfo->hasAutomaticPriority()) { result |= Qt::ItemIsDragEnabled; result |= Qt::ItemIsUserCheckable; if ((modelIndex.column() == COL_PRIORITY) || diff --git a/src/profile.cpp b/src/profile.cpp index 66c23ea1..2546661b 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -234,7 +234,7 @@ void Profile::doWriteModlist() // the priority order was inverted on load so it has to be inverted again const auto index = iter->second; ModInfo::Ptr modInfo = ModInfo::getByIndex(index); - if (!modInfo->isFixedPriority()) { + if (!modInfo->hasAutomaticPriority()) { if (modInfo->isForeign()) { file->write("*"); } else if (m_ModStatus[index].m_Enabled) { @@ -460,7 +460,7 @@ void Profile::refreshModStatus() // find the mod and check that this is a regular mod (and not a backup) ModInfo::Ptr info = ModInfo::getByIndex(modIndex); - if (modIndex < m_ModStatus.size() && !info->isFixedPriority()) { + if (modIndex < m_ModStatus.size() && !info->hasAutomaticPriority()) { m_ModStatus[modIndex].m_Enabled = enabled; if (m_ModStatus[modIndex].m_Priority == -1) { if (static_cast(index) >= m_ModStatus.size()) { @@ -527,7 +527,7 @@ void Profile::refreshModStatus() int offset = topInsert * -1; for (size_t i = 0; i < m_ModStatus.size(); ++i) { ModInfo::Ptr modInfo = ModInfo::getByIndex(static_cast(i)); - if (modInfo->isFixedPriority()) { + if (modInfo->hasAutomaticPriority()) { continue; } @@ -674,7 +674,7 @@ int Profile::getModPriority(unsigned int index) const bool Profile::setModPriority(unsigned int index, int &newPriority) { - if (ModInfo::getByIndex(index)->isFixedPriority()) { + if (ModInfo::getByIndex(index)->hasAutomaticPriority()) { // can't change priority of overwrite/backups return false; } -- cgit v1.3.1