diff ActionTemplates.lua @ 78:d4c100b0fd01 v7.1.5-80-release

- Fixed an issue with talent bindings not loading between specialization changes. - Fixed action button text corruption that occurred after changing assignments on an inactive spell.
author Nenue
date Thu, 26 Jan 2017 20:25:04 -0500
parents 6623b7f2c1ca
children b9a53385462c
line wrap: on
line diff
--- a/ActionTemplates.lua	Mon Jan 23 20:09:08 2017 -0500
+++ b/ActionTemplates.lua	Thu Jan 26 20:25:04 2017 -0500
@@ -40,8 +40,6 @@
 local petSpellCache,petSubtextCache
 local SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544
 
---kb.ChangedBindings = {}
---kb.ActionTypes = {}
 
 local atype = kb.ActionTypes
 
@@ -65,8 +63,9 @@
 
 atype['spell'] = function(id, name)
   local attributeName = name
-  if kb.ProfessionCache[id] then
-    attributeName = "profession_".. kb.ProfessionCache[id].dynamicIndex .. '_' .. kb.ProfessionCache[id].dynamicSubIndex
+  local profInfo = kb.DynamicSpells.profession[id]
+  if profInfo then
+    attributeName = "profession_".. profInfo.dynamicIndex .. '_' .. profInfo.dynamicSubIndex
   end
   return CLICK_KEYBINDER_KEY, attributeName, name, SkeletonKeyKey
 end
@@ -178,25 +177,6 @@
   return info
 end
 
-
-kb.ApplyTalentBinding = function(talentInfo, cache)
-  talentInfo.assignedKeys = talentInfo.assignedKeys or {}
-  for i , key in pairs(talentInfo.assignedKeys) do
-    local command = CLICK_KEYBINDER_KEY.. talentInfo.actionName
-    SetBinding(key, command)
-    cprint(' **', i, '->', command)
-    tinsert(cache, talentInfo)
-  end
-end
-kb.CacheTalentBinding = function(talentInfo, cache)
-
-  local spellID = talentInfo.actionID
-  cache[spellID] = cache[spellID] or {}
-  cache[spellID] = talentInfo
-  cprint(spellID, unpack(kb.TalentBindings[spellID]))
-end
-
-
 do
   local PROFILE_VERSION = 320
   local commandActions = {}
@@ -393,7 +373,6 @@
 
   kb.ApplyAllBindings =function ()
     print('|cFFFFFF00ApplyAllBindings()')
-    wipe(kb.TalentBindings)
     wipe(kb.bindings)
     --kb:print('Loading binding profile', kb.profileName)
 
@@ -419,7 +398,28 @@
 end
 
 
-kb.specInfo = {}
+local AddSpellInfo = function(id, name, icon, dynamicType, dynamicID, dynamicIndex, dynamicSubIndex, isAvailable)
+  local spell = kb.DynamicSpells[id] or {}
+  spell.actionName = name
+  spell.dynamicType = dynamicType
+  spell.dynamicID = dynamicID
+  spell.iconPath = icon
+  spell.dynamicIndex = dynamicIndex
+  spell.dynamicSubIndex = dynamicSubIndex
+  spell.isAvailable = isAvailable
+  spell.actionType = 'spell'
+  spell.spellbookType = BOOKTYPE_SPELL
+  kb.DynamicSpells[name] = spell
+
+  local spellList = dynamicType and kb.DynamicSpells[dynamicType]
+  if spellList then
+    spellList[dynamicIndex] = spellList[dynamicIndex] or {}
+    spellList[dynamicIndex][dynamicSubIndex] = spell
+  end
+
+  cprint('|cFF00FFFFSpellInfo:|r', name, isAvailable, dynamicType or 'spell')
+end
+
 kb.UpdateSpecInfo = function()
   kb.specInfo.id = GetSpecialization()
   kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id)
@@ -434,54 +434,61 @@
   end
 end
 
+
 kb.UpdateTalentInfo = function()
-  print('|cFFFFFF00kb.UpdateTalentInfo()|r')
+  print('|cFFFFFF00kb.UpdateSpells()|r')
+  cprint('|cFFFFFF00kb.UpdateSpells()|r')
   if kb.talentsPushed then
     return
   end
   for row =1, MAX_TALENT_TIERS do
     for col = 1, NUM_TALENT_COLUMNS do
       local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1)
-      local talentInfo = kb.TalentCache[spellID] or {}
+      local talentInfo = kb.DynamicSpells[spellID] or {}
       if spellID then
-        talentInfo.actionType = 'spell'
-        talentInfo.actionName = talentName
-        talentInfo.dynamicType = 'talent'
-        talentInfo.dynamicID = talentID
-        talentInfo.dynamicIndex = row
-        talentInfo.dynamicSubIndex = col
-        talentInfo.actionID = spellID
-        talentInfo.isAvailable = selected
-        kb.DynamicSpells[spellID] = talentInfo
-        kb.DynamicSpells[talentName] = talentInfo
+        AddSpellInfo(spellID, talentName, icon, 'talent', talentID, row, col, selected)
       end
 
-      --print('Talent ', row, col, spellID, talentName)
     end
   end
 
   for row = 1, MAX_PVP_TALENT_TIERS do
     for col = 1, MAX_PVP_TALENT_COLUMNS do
-      local id, name, icon, selected, available, spellID, unlocked = GetPvpTalentInfo(row, col, 1)
+      local talentID, talentName, icon, selected, available, spellID, unlocked = GetPvpTalentInfo(row, col, 1)
       if spellID then
-        local talentInfo = kb.TalentCache[spellID] or {}
-        talentInfo.actionType = 'spell'
-        talentInfo.actionName = name
-        talentInfo.dynamicType = 'talent'
-        talentInfo.dynamicID = id
-        talentInfo.dynamicIndex = row
-        talentInfo.dynamicSubIndex = col
-        talentInfo.actionID = spellID
-        talentInfo.isAvailable = selected
-        kb.DynamicSpells[spellID] = talentInfo
-        kb.DynamicSpells[name] = talentInfo
+        AddSpellInfo(spellID, talentName, icon, 'talent', talentID, row, col, selected)
       end
     end
   end
 
+  local numTabs = GetNumSpellTabs()
+  for i = 1, numTabs do
+    local name, texture, offset, numSpells = GetSpellTabInfo(i)
+    for spellLine = offset+1, offset+numSpells do
+      local skillType, spellID = GetSpellBookItemInfo(spellLine)
+      if skillType == 'SPELL' then
+        local name, _, icon = GetSpellInfo(spellID)
+        AddSpellInfo(spellID, name, icon, nil, nil, nil, nil, true)
+      elseif skillType == 'FLYOUT' then
+        local flyoutID = GetFlyoutID(spellLine)
+        local _, _, numSlots = GetFlyoutInfo(flyoutID)
+        if numSlots then
+          for slot = 1, numSlots do
+            local spellID, isKnown = GetFlyoutSlotInfo(flyoutID, slot)
+            local name, rank, icon = GetSpellInfo(spellID)
+            AddSpellInfo(spellID, name, icon, nil, nil, nil, nil, true)
+          end
+        end
+      end
+    end
+  end
+
+
+
   kb.talentsPushed = true
   kb.UpdateDynamicButtons('talent')
 end
+kb.UpdateSpells = kb.UpdateTalentInfo
 
 kb.UpdateProfessionInfo = function()
   wipe(kb.ProfessionCache)
@@ -500,15 +507,12 @@
       cprint(i, profNum)
 
 
-      kb.ProfessionCache[profNum] = kb.ProfessionCache[profNum] or {}
-
       for j = 1, numSpells do
         local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION)
         cprint(j, spellName)
         local profInfo = {
           actionType = 'spell',
           actionName = spellName,
-          statusText = 'Profession ' .. i,
           actionID = spellID,
           iconPath = icon,
           dynamicIndex = i,
@@ -517,19 +521,18 @@
           spellbookOffset = (spellOffset+j),
           spellbookType = BOOKTYPE_PROFESSION,
           isAvailable = true,
-          -- need to check if necessary
-          uniqueID = profID,
+          dynamicID = profID,
         }
 
         kb.SecureAttribute(SkeletonKeyKey, "*type-profession_"..i .. '_' ..j, "spell")
         kb.SecureAttribute(SkeletonKeyKey, "*spell-profession_"..i .. '_' ..j, spellName)
 
-        kb.ProfessionCache[spellName] = profInfo
-        kb.ProfessionCache[spellID] = profInfo
 
         kb.DynamicSpells[spellName] = profInfo
         kb.DynamicSpells[spellID] = profInfo
 
+        kb.DynamicSpells.profession[spellName] = profInfo
+        kb.DynamicSpells.profession[spellID] = profInfo
         kb.DynamicSpells.profession[i] = kb.DynamicSpells.profession[i] or {}
         kb.DynamicSpells.profession[i][j] = profInfo
         --print('  |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j)
@@ -621,6 +624,7 @@
 
           kb.PetCache.special[spellName] = info
           kb.PetCache.subtext[subText][specialNum[subText]] = info
+
           kb.DynamicSpells[spellName] = info
           kb.DynamicSpells[spellID] = info