diff SkeletonKey/HotKey.lua @ 62:04c23ceaf9e0

- fix taint caused by loading in combat
author Nenue
date Mon, 05 Sep 2016 14:56:38 -0400
parents b7be92f62b05
children 2409fe9b81e1
line wrap: on
line diff
--- a/SkeletonKey/HotKey.lua	Sun Aug 28 10:06:59 2016 -0400
+++ b/SkeletonKey/HotKey.lua	Mon Sep 05 14:56:38 2016 -0400
@@ -31,11 +31,13 @@
   ["ACTIONBAR_SLOT_CHANGED"] = {"actionslot"},
   ["PLAYER_ENTERING_WORLD"] = {"world","all"},
   ["PET_UI_UPDATE"] = {"pet"},
+  ["PLAYER_SPECIALIZATION_CHANGED"] = {"player"},
+  ["PLAYER_TALENTS_UPDATED"] = {"player"},
 }
 
 
 hotkey.wrapEvent = function(event, ...)
-  kb:RegisterEvent(event)
+  hotkey:RegisterEvent(event)
   hotkeyEvents[event] = {...}
   hotkey[event] = hotkey.UpdateFromEvent
 end
@@ -63,7 +65,7 @@
     for i, func  in ipairs(hotkeyEvents[event]) do
 
       if hotkey[func] then
-        --print(' ', func)
+        print('->|cFF88FF00', func)
         hotkey[func](self, event, ...)
       end
     end
@@ -75,7 +77,8 @@
   print('variables')
   bindings = kb.GetBindings()
   for event, manifest in pairs(hotkeyEvents) do
-    kb:RegisterEvent(event)
+    print('-', event, table.concat(manifest, ', '))
+    hotkey:RegisterEvent(event)
     hotkey[event] = hotkey.UpdateFromEvent
   end
   hotkey.wrapEvent('UNIT_PET', 'pet')
@@ -90,40 +93,39 @@
 end
 
 hotkey.ui = function()
-  print('ui')
-  --hotkey.player()
-  --hotkey.pet()
+  hotkey.player()
+  hotkey.pet()
 end
 
 
 hotkey.world = function()
-  print('world')
+  -- needs to be delayed so it isn't fired 50 times at login
   hotkeyEvents["UPDATE_BINDINGS"] = {"binding"}
   hotkey.UPDATE_BINDINGS = hotkey.UpdateFromEvent
   hotkey:RegisterEvent("UPDATE_BINDINGS")
 
   hotkey.player()
   hotkey.pet()
-
 end
 
 -- requires all these arguments since non-actionbar buttons don't have all of said methods
+local kprint = (DEVIAN_WORKSPACE and function(...) _G.print('HotKeyUpdate', ...) end) or function() end
 hotkey.UpdateHotKey = function(frame, actionType, actionID, hasAction)
   bindings = kb.GetBindings()
 
   local indexKey = kb.FormatActionID(actionType, actionID)
-  print('|cFF00FFFFUpdate|r', frame, indexKey, hasAction)
+  --kprint(frame:GetName(), '|cFF88FF00'..indexKey..'|r',  hasAction)
 
 
   if bindings[indexKey] then
-    print('|cFFFFFF00'..frame:GetName(), actionType, actionID, hasAction)
+    kprint(' |cFFFF0088', actionType ..'|r', actionID, hasAction)
     local binds = bindings[indexKey]
     if binds and (not frame.HotKey:IsVisible()) then
       if hasAction then
         local bindingsText = kb.BindingString(unpack(binds))
 
         if not hotkeyText[frame] then
-          print('-new hotkey element')
+          kprint('-new hotkey element')
           hotkeyText[frame] = frame:CreateFontString(frame:GetName()..'SkeletonKey', 'OVERLAY')
           hotkeyText[frame]:SetFont(frame.HotKey:GetFont())
           hotkeyText[frame]:SetTextColor(frame.HotKey:GetTextColor())
@@ -136,7 +138,7 @@
 
         hotkeyText[frame]:SetText(bindingsText)
         hotkeyText[frame]:Show()
-        print('|cFF00FFFFUpdate text for', frame:GetName(), '|cFFFFFF00'..tostring(bindingsText)..'|r')
+        kprint('   |cFF00FFFF', frame:GetName(), '|cFFFFFF00'..tostring(bindingsText)..'|r')
 
         return
       end
@@ -145,7 +147,7 @@
 
   if hotkeyText[frame] then
     hotkeyText[frame]:SetText(nil)
-    --print('|cFFFF4400cleared text from', frame:GetName())
+    print('|cFFFF4400' .. frame:GetName() .. '|r', 'remove text')
   end
 end
 
@@ -160,6 +162,7 @@
       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
@@ -174,10 +177,14 @@
 
 hotkey.actionslot = function(self, event, slot)
   print(actionSlots[slot], event, slot, GetActionInfo(slot))
-  --print(GetActionButtonForID(slot))
   local atype, aid = GetActionInfo(slot)
   local indexKey = kb.FormatActionID(atype, aid)
   local frame = actionSlots[slot]
+  actionFrames[indexKey] = actionFrames[indexKey] or {}
+  if not tContains(actionFrames[indexKey]) then
+    tinsert(actionFrames[indexKey], frame)
+    actionIndex[slot] = indexKey
+  end
   if frame then
     hotkey.UpdateHotKey(frame, atype, aid, HasAction(slot))
   end