From cee8d5ed72299a34f7b2ccd4c31e35f9eff0801d Mon Sep 17 00:00:00 2001 From: Chris Bessent Date: Sun, 23 Jan 2022 09:47:25 -0700 Subject: Enforce relationships between plugins Masters must be above their children and children must be below their masters. Currently only applies when trying to move plugins. --- src/pluginlist.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/pluginlist.cpp') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 692d03dd..657ada17 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -1485,8 +1485,35 @@ void PluginList::setPluginPriority(int row, int &newPriority, bool isForced) } } + int oldPriority = m_ESPs.at(row).priority; + if (newPriorityTemp < oldPriority) { // moving up + // don't allow plugins to be moved above their masters + for (auto master : m_ESPs[row].masters) { + auto iter = m_ESPsByName.find(master); + if (iter != m_ESPsByName.end()) { + int masterPriority = m_ESPs[iter->second].priority; + if (masterPriority >= newPriorityTemp) + { + newPriorityTemp = masterPriority + 1; + } + } + } + } + else if (newPriorityTemp > oldPriority) { // moving down + // don't allow masters to be moved below their children + //for (auto idx : m_ESPsByPriority) { + for (int i = oldPriority + 1; i <= newPriorityTemp; i++) { + PluginList::ESPInfo* otherInfo = &m_ESPs.at(m_ESPsByPriority[i]); + for (auto master : otherInfo->masters) { + if (master.compare(m_ESPs[row].name, Qt::CaseInsensitive) == 0) { + newPriorityTemp = otherInfo->priority - 1; + break; + } + } + } + } + try { - int oldPriority = m_ESPs.at(row).priority; if (newPriorityTemp > oldPriority) { // priority is higher than the old, so the gap we left is in lower priorities for (int i = oldPriority + 1; i <= newPriorityTemp; ++i) { -- cgit v1.3.1