From 1cafda1147c06a647e3d3f1e3f986d7296ccbd08 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 1 Jul 2013 23:18:52 +0300 Subject: add support for drag and drop in spells window. --- src/spellmanager.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/spellmanager.cpp') diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index bad5cd78b..83fb746a7 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -393,3 +393,37 @@ std::string SpellManager::autoComplete(const std::string &partName) const } return newName; } + +void SpellManager::swap(const int id1, const int id2) +{ + TextCommand *const spell1 = mSpells[id1]; + TextCommand *const spell2 = mSpells[id2]; + // swap in map + mSpells[id1] = spell2; + mSpells[id2] = spell1; + + // swap id + int tmp = spell1->getId(); + spell1->setId(spell2->getId()); + spell2->setId(tmp); + + // swap in vector + const int sz = SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; + for (unsigned f = 0; f < sz; f++) + { + const TextCommand *const spellA = mSpellsVector[f]; + if (spellA == spell1) + { + for (unsigned d = 0; d < sz; d++) + { + const TextCommand *const spellB = mSpellsVector[d]; + if (spellB == spell2) + { + mSpellsVector[f] = spell2; + mSpellsVector[d] = spell1; + return; + } + } + } + } +} -- cgit v1.2.3-60-g2f50