diff SkeletonKey/HotKey.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
line wrap: on
line diff
--- a/SkeletonKey/HotKey.lua	Mon Sep 05 14:56:38 2016 -0400
+++ b/SkeletonKey/HotKey.lua	Thu Sep 08 16:52:55 2016 -0400
@@ -113,63 +113,83 @@
 hotkey.UpdateHotKey = function(frame, actionType, actionID, hasAction)
   bindings = kb.GetBindings()
 
-  local indexKey = kb.FormatActionID(actionType, actionID)
-  --kprint(frame:GetName(), '|cFF88FF00'..indexKey..'|r',  hasAction)
+  if hasAction then
+    local indexKey = kb.FormatActionID(actionType, actionID)
+    kprint(frame:GetName(), '|cFF88FF00'..indexKey..'|r',  hasAction)
 
 
-  if bindings[indexKey] then
-    kprint(' |cFFFF0088', actionType ..'|r', actionID, hasAction)
+    local actionName
+    if actionType == 'spell' then
+      actionName = GetSpellInfo(actionID)
+    elseif actionType == 'macro' then
+      actionName = GetMacroInfo(actionID)
+    elseif actionType == 'summonmount' then
+      actionName = C_MountJournal.GetMountInfoByID(actionID)
+    elseif actionType == 'item' then
+      actionName = GetItemInfo(actionID)
+    end
+    kprint(' ', actionName)
+
     local binds = bindings[indexKey]
+    kprint(binds)
     if binds and (not frame.HotKey:IsVisible()) then
-      if hasAction then
-        local bindingsText = kb.BindingString(unpack(binds))
+      local bindingsText = kb.BindingString(unpack(binds))
 
-        if not hotkeyText[frame] then
-          kprint('-new hotkey element')
-          hotkeyText[frame] = frame:CreateFontString(frame:GetName()..'SkeletonKey', 'OVERLAY')
-          hotkeyText[frame]:SetFont(frame.HotKey:GetFont())
-          hotkeyText[frame]:SetTextColor(frame.HotKey:GetTextColor())
-          hotkeyText[frame]:SetPoint('TOPRIGHT', frame.HotKey, 'TOPRIGHT')
+      if not hotkeyText[frame] then
+        kprint('-new hotkey element')
+        hotkeyText[frame] = frame:CreateFontString(frame:GetName()..'SkeletonKey', 'OVERLAY')
+        hotkeyText[frame]:SetFont(frame.HotKey:GetFont())
+        hotkeyText[frame]:SetTextColor(frame.HotKey:GetTextColor())
+        hotkeyText[frame]:SetPoint('TOPRIGHT', frame.HotKey, 'TOPRIGHT')
 
-          hooksecurefunc(frame.HotKey, 'SetVertexColor', function(self, r,g,b,a)
-            hotkeyText[frame]:SetTextColor(r,g,b,a)
-          end)
-        end
+        hooksecurefunc(frame.HotKey, 'SetVertexColor', function(self, r,g,b,a)
+          hotkeyText[frame]:SetTextColor(r,g,b,a)
+        end)
+      end
 
-        hotkeyText[frame]:SetText(bindingsText)
-        hotkeyText[frame]:Show()
-        kprint('   |cFF00FFFF', frame:GetName(), '|cFFFFFF00'..tostring(bindingsText)..'|r')
+      hotkeyText[frame]:SetText(bindingsText)
+      hotkeyText[frame]:Show()
+      kprint('   |cFF00FFFF', frame:GetName(), '|cFFFFFF00'..tostring(bindingsText)..'|r')
 
-        return
-      end
+      return
     end
   end
 
   if hotkeyText[frame] then
+    local oldText = hotkeyText[frame]:GetText()
+    if oldText then
     hotkeyText[frame]:SetText(nil)
-    print('|cFFFF4400' .. frame:GetName() .. '|r', 'remove text')
+    print('|cFFFF4400' .. frame:GetName() .. '|r', 'removed text', oldText)
+    end
+
   end
 end
 
 hotkey.actionbar = function()
-  wipe(actionFrames)
   -- reset frames list
   print('actionbar')
+  wipe(actionFrames)
   if ActionBarButtonEventsFrame.frames then
     for index, frame in ipairs(ActionBarButtonEventsFrame.frames) do
-
       local slot = frame.action
       local actionType, actionID = GetActionInfo(slot)
       local hasAction = HasAction(slot)
-      local indexKey = kb.FormatActionID(actionType, actionID)
 
       actionSlots[slot] = frame
-      actionFrames[indexKey] = actionFrames[indexKey] or {}
-      if not tContains(actionFrames[indexKey]) then
-        tinsert(actionFrames[indexKey], frame)
-        actionIndex[slot] = indexKey
+      if hasAction then
+        local indexKey = kb.FormatActionID(actionType, actionID)
+
+        actionFrames[indexKey] = actionFrames[indexKey] or {}
+        local result = ''
+        if not tContains(actionFrames[indexKey], frame) then
+          tinsert(actionFrames[indexKey], frame)
+          actionIndex[slot] = indexKey
+          result = 'added'
+        end
+        print('#'..index, frame:GetName(), indexKey, result)
       end
 
+
       hotkey.UpdateHotKey(frame, actionType, actionID, hasAction)
     end
   end