changeset 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 4ca4cc031e99
files ActionTemplates.lua BindingsFrame.lua Events.lua KeyButton.lua SkeletonKey.lua
diffstat 5 files changed, 62 insertions(+), 66 deletions(-) [+]
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
--- a/BindingsFrame.lua	Mon Jan 23 18:59:02 2017 -0500
+++ b/BindingsFrame.lua	Mon Jan 23 20:07:30 2017 -0500
@@ -168,8 +168,11 @@
   print(self.zoomScale, self.scrollOffset)
 end
 
+function SkeletonKeyMixin:OnShow()
+  self:Update()
+end
 function SkeletonKeyMixin:OnHide()
-  KeyBinderImportLog:Hide()
+
 end
 
 
@@ -512,20 +515,6 @@
     tinsert(self.assignedKeys, 1, binding)
   end
 
-  local talentInfo = kb.DynamicSpells[spellName]
-  if spellName and talentInfo then
-    print('store dynamicType talent')
-    if talentInfo.dynamicType == 'talent' then
-      talentInfo = {
-        macroName = self.macroName,
-        actionName = self.actionName,
-        actionType = self.actionType,
-        actionID = self.actionID,
-        assignedKeys = self.assignedKeys
-      }
-      kb.currentProfile.talents[spellName] = talentInfo
-    end
-  end
 
   for _, key in ipairs(self.assignedKeys) do
     if not kb.currentProfile.bindings[key] then
@@ -538,9 +527,6 @@
       profile.bindings[binding] = nil
       profile.commands[self.command] = nil
       profile.bound[self.command] = nil
-      if spellName then
-        profile.talents[spellName] = nil
-      end
     end
   end
 
@@ -566,6 +552,7 @@
 
 function ActionListPanel:UnbindSlot (button)
 
+  local configTable = kb.currentProfile.buttons[button:GetID()]
   local button = button or kb.saveTarget
   if not button then
     return
@@ -575,10 +562,6 @@
   local actionType = button.actionType
   local actionID = button.actionID
 
-  local keys = {GetBindingKey(command) }
-  if #keys >= 1 then
-    kb.UpdateBindingsCache(actionType, actionID, {})
-  end
 
   local talentName = button.actionName
   if actionType == 'macro' then
@@ -586,28 +569,42 @@
     talentName = spellName
   end
 
+  local keys = {GetBindingKey(command) }
+  if configTable and configTable.assignedKeys then
+    for _, key in ipairs(configTable.assignedKeys) do
+      if not tContains(keys, key) then
+        tinsert(keys, key)
+      end
+    end
+  end
 
-  --print('detected', #keys, 'bindings')
-  for i, key in pairs(keys) do
-    --print('clearing', key)
-    SetBinding(key, nil)
-    SaveBindings(GetCurrentBindingSet())
-    if kb.currentProfile.bindings[key] then
-      --kb:print(L('BINDING_REMOVED', self.actionName, kb.currentHeader))
-      kb.currentProfile.bindings[key] = nil
-    end
-    if kb.currentProfile.talents[talentName] then
-      kb.currentProfile.talents[talentName] = nil
+  -- only manipulate bindings if its an available ability
+  if button.isAvailable then
+    --print('detected', #keys, 'bindings')
+
+    if #keys >= 1 then
+      kb.UpdateBindingsCache(actionType, actionID, {})
     end
 
-    kb.bindings[tostring(actionType)..'_'..tostring(actionID)] = nil
+    for i, key in pairs(keys) do
+      --print('clearing', key)
+      SetBinding(key, nil)
+      kb.bindings[tostring(actionType)..'_'..tostring(actionID)] = nil
+    end
+    SaveBindings(GetCurrentBindingSet())
   end
+
+
+  if configTable and configTable.assignedKeys then
+    table.wipe(configTable.assignedKeys)
+  end
+
   if kb.currentProfile.bound[command] then
     kb.currentProfile.bound[command] = nil
     --kb:print(BINDING_REMOVED:format(self.actionName, configHeaders[db.bindMode]))
   end
   kb.saveTarget = nil
-
+  button:UpdateSlot(true)
   return true
 end
 
--- a/Events.lua	Mon Jan 23 18:59:02 2017 -0500
+++ b/Events.lua	Mon Jan 23 20:07:30 2017 -0500
@@ -28,9 +28,11 @@
   return true
 end
 
+
 kb.PLAYER_TALENT_UPDATE = function()
   kb.TalentsChanged = true
 end
+kb.PLAYER_PVP_TALENT_UPDATE = kb.PLAYER_TALENT_UPDATE
 
 -- only need to respond to this for pet actions
 kb.PLAYER_SPECIALIZATION_CHANGED = function(self, event, unit)
--- a/KeyButton.lua	Mon Jan 23 18:59:02 2017 -0500
+++ b/KeyButton.lua	Mon Jan 23 20:07:30 2017 -0500
@@ -133,7 +133,7 @@
     if cursorType then
       self:DropToSlot()
     else
-      if self.command and self.isAvailable then
+      if self.command then
         if IsShiftKeyDown() then
           kb.db.stickyMode = true
           KeyBinderStickyMode:SetChecked(true)
@@ -421,10 +421,7 @@
   if self.actionType == 'macro' then
     talentName = GetMacroSpell(self.actionID)
   end
-    -- remove any matching talent data
-  if talentName and kb.currentProfile.talents[talentName] then
-    kb.currentProfile.talents[talentName] = nil
-  end
+
   local droppedKeys = {}
 
   -- doing removal in second loop to avoid possible iterator shenanigans
@@ -461,10 +458,6 @@
 
 end
 
-local DoMacroCheck = function(name, macroText, searchID, roughResult)
-
-  return matchID, matchName, matchBody, endOfSearch
-end
 --- Assigns the slot via table copy; any manipulations from this point are temporary and
 function skb:SetSlot(slotInfo)
   print('slot info', self:GetID())
--- a/SkeletonKey.lua	Mon Jan 23 18:59:02 2017 -0500
+++ b/SkeletonKey.lua	Mon Jan 23 20:07:30 2017 -0500
@@ -397,6 +397,7 @@
   self:RegisterEvent('PLAYER_REGEN_ENABLED')
   self:RegisterEvent('SPELLS_CHANGED')
   self:RegisterEvent('PLAYER_TALENT_UPDATE')
+  self:RegisterEvent('PLAYER_PVP_TALENT_UPDATE')
 
   self:RegisterForDrag('LeftButton')
   self:SetMovable(true)