diff ActionTemplates.lua @ 76:6623b7f2c1ca v7.1.5-78-release

Added: - key assignment and unbinding for inactive talents Bug Fixes: - fixed spell access check for talents - fixed detection of Legion PvP talents - fixed unbind command not clearing assigned key text - fixed frame content not loading after combat Miscellaneous: - bindings are determined from the button's assignment list - increment profile version to remove deprecated talents list
author Nenue
date Mon, 23 Jan 2017 20:07:30 -0500
parents e75a2fd448c0
children d4c100b0fd01
line wrap: on
line diff
--- a/ActionTemplates.lua	Mon Jan 23 18:59:02 2017 -0500
+++ b/ActionTemplates.lua	Mon Jan 23 20:07:30 2017 -0500
@@ -198,6 +198,7 @@
 
 
 do
+  local PROFILE_VERSION = 320
   local commandActions = {}
   local bindings = kb.bindings
   local key, macro = SkeletonKeyKey, SkeletonKeyMacro
@@ -218,17 +219,19 @@
     local specialButtonType
     if actionType == 'spell' then
       cprint(GetSpellInfo(actionID))
-      if GetSpellInfo(actionID) then
-        isAvailable = true
-      end
       local dynamicInfo = kb.DynamicSpells[name]
       if dynamicInfo then
-        configTable.assignedKeys = configTable.assignedKeys or {GetBindingKey(configTable.command)}
+        configTable.assignedKeys = configTable.assignedKeys or {GetBindingKey(configTable.command) }
+
         cprint('|cFF00FFFFDynamicInfo:|r', dynamicInfo.dynamicType, table.concat(configTable.assignedKeys, ','))
         for k, v in pairs(dynamicInfo) do
           --cprint(' --', k, v)
           configTable[k] = v
         end
+        isAvailable = configTable.isAvailable
+      elseif GetSpellInfo(actionID) then
+        isAvailable = true
+
       end
     elseif actionType == 'item' then
       actionID = configTable.actionName
@@ -345,6 +348,13 @@
         profile.commands[command] = nil
       end
     end
+
+    if profile.talents then
+      profile.talents = nil
+    end
+
+
+    profile.versionID = PROFILE_VERSION
   end
 
   kb.ApplyBindings = function (profile)
@@ -352,29 +362,16 @@
     --cprint('binding profile', profile)
 
     local version = profile.versionID or 0
-    if version < 310 then
+    if version < PROFILE_VERSION then
       kb.UpgradeProfile(profile)
     end
 
-    -- do flat bindings to start
-    for key, command in pairs(profile.bindings) do
-      command = command:gsub('KeyBinder', 'SkeletonKey')
-      profile.bindings[key] = command
-      cprint('|cFF00FFFF'.. key .. '|r to|cFF00FF00', command)
-      SetBinding(key, command)
-      if commandActions[command] and not tContains(commandActions[command], key) then
-        tinsert(commandActions[command], key)
-      end
-    end
 
     -- then buttons
     for slot, configTable in pairs(profile.buttons) do
       -- convert old style table
       if kb.LoadBinding(configTable) then
-        local talent = profile.talents[configTable.actionName]
-        if talent then
-          configTable.assignedKeys = talent.assignedKeys
-        end
+
         if not configTable.assignedKeys then
           configTable.assignedKeys = {GetBindingKey(configTable.command)}
         end
@@ -382,8 +379,12 @@
         --  kb:print(table.concat(configTable.assignedKeys, ', ') .. ' bound to '.. configTable.actionName)
         --end
         for _, key in pairs(configTable.assignedKeys) do
-
-          SetBinding(key, configTable.command)
+          local command = configTable.command
+          cprint('|cFF00FFFF'.. key .. '|r to|cFF00FF00', command)
+          SetBinding(key, command)
+          if commandActions[command] and not tContains(commandActions[command], key) then
+            tinsert(commandActions[command], key)
+          end
         end
 
       end
@@ -463,11 +464,13 @@
     for col = 1, MAX_PVP_TALENT_COLUMNS do
       local id, name, icon, selected, available, spellID, unlocked = GetPvpTalentInfo(row, col, 1)
       if spellID then
-      local talentInfo = kb.TalentCache[spellID] or {}
+        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