From d1594798e6e78bb329e744a72e92d3f292f38a20 Mon Sep 17 00:00:00 2001 From: Tannin Date: Fri, 1 Nov 2013 14:59:25 +0100 Subject: - added a new diagnosis to detect potential problems in regards to esp vs. asset ordering (not fully functional yet) - new plugin interfaces to the mod list - plugins can now query the origin (mod) of a esp/esm - bugfix: potential access to profile before one was activated - bugfix: regression in previous (not-yet-released) commit prevented changes to bsa list from being saved --- src/modlist.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/modlist.cpp') diff --git a/src/modlist.cpp b/src/modlist.cpp index 0fdcf6fa..541e1e6e 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -551,6 +551,46 @@ void ModList::changeModPriority(int sourceIndex, int newPriority) emit modorder_changed(); } +IModList::ModState ModList::state(const QString &name) const +{ + unsigned int modIndex = ModInfo::getIndex(name); + if (modIndex == UINT_MAX) { + return IModList::STATE_MISSING; + } else { + ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex); + if (modInfo->canBeEnabled()) { + return m_Profile->modEnabled(modIndex) ? IModList::STATE_ACTIVE : IModList::STATE_INACTIVE; + } else { + return IModList::STATE_NOTOPTIONAL; + } + } +} + +int ModList::priority(const QString &name) const +{ + unsigned int modIndex = ModInfo::getIndex(name); + if (modIndex == UINT_MAX) { + return -1; + } else { + return m_Profile->getModPriority(modIndex); + } +} + +bool ModList::setPriority(const QString &name, int newPriority) +{ + if ((newPriority < 0) || (newPriority >= static_cast(m_Profile->numRegularMods()))) { + return false; + } + + unsigned int modIndex = ModInfo::getIndex(name); + if (modIndex == UINT_MAX) { + return false; + } else { + m_Profile->setModPriority(modIndex, newPriority); + notifyChange(modIndex); + return true; + } +} bool ModList::dropURLs(const QMimeData *mimeData, int row, const QModelIndex &parent) { -- cgit v1.3.1