diff options
| author | Chris Bessent <lost.dragonist@gmail.com> | 2022-01-23 09:47:25 -0700 |
|---|---|---|
| committer | Chris Bessent <lost.dragonist@gmail.com> | 2022-01-23 11:11:22 -0700 |
| commit | cee8d5ed72299a34f7b2ccd4c31e35f9eff0801d (patch) | |
| tree | 2315de7eeca2d3ea691541f89c2b895edebe5fee | |
| parent | 0783eb373b4c00ce1f943e41583c97b664fe29b8 (diff) | |
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.
| -rw-r--r-- | src/pluginlist.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
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) {
|
