diff SkeletonKey/ActionTemplates.lua @ 63:2409fe9b81e1

- check macro spells when considering whether a binding should be treated as a talent - clean up talent binding data when releasing/unbinding slots with a related macro/spell
author Nenue
date Thu, 08 Sep 2016 16:52:55 -0400
parents 04c23ceaf9e0
children 178d489f387c
line wrap: on
line diff
--- a/SkeletonKey/ActionTemplates.lua	Mon Sep 05 14:56:38 2016 -0400
+++ b/SkeletonKey/ActionTemplates.lua	Thu Sep 08 16:52:55 2016 -0400
@@ -147,10 +147,12 @@
 
 
 do
+  local commandActions = {}
   local bindings = kb.bindings
   local key, macro = KeyBinderKey, KeyBinderMacro
   kb.LoadBinding = function(command, name, icon, actionType, actionID, macroName, macroText )
 
+    local indexKey = actionType..'_'..actionID
     local buttonTypeKey, buttonTypeValue = "*type-"..name, actionType
     local buttonActionKey, buttonActionValue = "*"..actionType.."-"..name, actionID
     local button = key
@@ -177,33 +179,31 @@
     end
 
     --cprint(actionType, actionID, name)
-    --cprint(button:GetName(), buttonTypeKey,'=', buttonTypeValue)
     kb.SecureAttribute(button, buttonTypeKey, buttonTypeValue)
     if buttonActionKey then
       --cprint(button:GetName(), buttonActionKey,'=', buttonActionValue)
       kb.SecureAttribute(button, buttonActionKey, buttonActionValue)
     end
 
-    local indexKey = actionType..'_'..actionID
-    bindings[indexKey] = bindings[indexKey] or {}
-    bindings[command] = bindings[indexKey]
+    kb.bindings[indexKey] = kb.bindings[indexKey] or {}
+    kb.bindings[command] = kb.bindings[indexKey]
+    commandActions[command] = indexKey
     return bindings[indexKey], actionID
   end
 
   kb.ApplyBindings = function (profile)
     --cprint('binding profile', profile)
+
     for slot, data in pairs(profile.buttons) do
-      kb.LoadBinding(unpack(data))
+      local bindsTable, actionID = kb.LoadBinding(unpack(data))
+      local command = data[1]
     end
 
     for key, command in pairs(profile.bindings) do
-
-      --cprint(' *', key, '->', command)
-
-      --_G.print('HotKey','loading', key, command)
+      cprint('|cFF00FFFF'.. key .. '|r to|cFF00FF00', command, commandActions[command])
       SetBinding(key, command)
-      if bindings[command] and not tContains(bindings[command], key) then
-        tinsert(bindings[command], key)
+      if kb.bindings[command] then
+        tinsert(kb.bindings[command], key)
       end
     end
 
@@ -215,7 +215,7 @@
         --cprint('|cFFBBFF00Active:|r', dummy)
         local macroName, spellName, actionType, actionID = unpack(talentInfo)
         local indexKey = actionType .. '_' .. actionID
-        bindings[indexKey] = {}
+        kb.bindings[indexKey] = {}
         func = kb.ApplyTalentBinding
         dest = kb.bindings[indexKey]
       else
@@ -230,7 +230,7 @@
   kb.ApplyAllBindings =function ()
     wipe(kb.TalentBindings)
     wipe(kb.bindings)
-    kb:print('Loading binding profile', kb.profileName)
+    --kb:print('Loading binding profile', kb.profileName)
 
     -- reflect action key settings
     if GetCVarBool("ActionButtonUseKeyDown") then
@@ -247,7 +247,6 @@
     -- do this after to ensure that profession binds are properly overridden
     kb.UpdateProfessionInfo()
 
-
     SaveBindings(GetCurrentBindingSet())
   end
 end
@@ -259,6 +258,13 @@
   kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id)
 end
 
+kb.UpdateMacroInfo =  function()
+  for i = 1, GetNumMacros() do
+    local name = GetMacroInfo(index)
+    kb.SecureAttribute(KeyBinderMacro, "*macro_"..tostring(name), i)
+  end
+end
+
 kb.UpdateTalentInfo = function()
   if kb.talentsPushed then
     return
@@ -488,7 +494,7 @@
 
   else
 
-    --print(target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"')
+    cprint('|cFFFF4444' .. target:GetName()..'|r.|cFFFFFF00'.. tostring(name)..'|r = "'..tostring(value)..'"')
     target:SetAttribute(name, value)
   end
 end
@@ -499,6 +505,7 @@
     while args do
       local target, name, value = unpack(args)
       --print(target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"')
+      cprint('deferred', target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"')
       target:SetAttribute(name, value)
       args = tremove(kb.pendingAttributes)
     end