Mercurial > wow > skeletonkey
diff SkeletonKey/HotKey.lua @ 27:73df13211b22
- actionbar hotkey text properly updates after hotkeys get switched
- remove a unused function call
author | Nenue |
---|---|
date | Tue, 02 Aug 2016 12:33:13 -0400 |
parents | 82170735e67c |
children | bb160c04de88 |
line wrap: on
line diff
--- a/SkeletonKey/HotKey.lua Sun Jul 31 16:45:02 2016 -0400 +++ b/SkeletonKey/HotKey.lua Tue Aug 02 12:33:13 2016 -0400 @@ -15,7 +15,9 @@ -- frames divided by update categories local categoryFrames = {} -- frames indexed by action slot ID (just the action bar, for... reasons) +local actionSlots = {} local actionFrames = {} +local actionIndex = {} kb.wrap(hotkey) @@ -25,6 +27,7 @@ ["UPDATE_VEHICLE_ACTIONBAR"] = {"vehicle"}, ["UPDATE_OVERRIDE_ACTIONBAR"] = {"override"}, ["ACTIONBAR_PAGE_CHANGED"] = {"actionbar"}, + ["ACTIONBAR_SLOT_CHANGED"] = {"actionslot"}, ["PLAYER_ENTERING_WORLD"] = {"world","all"}, ["PET_UI_UPDATE"] = {"pet"}, } @@ -44,13 +47,6 @@ hotkey[event] = nil end -hotkey.ActionButton_Update = function(frame) - wrap(function() - local actionType, actionID = GetActionInfo(frame.action) - hotkey.UpdateSkeletonKeyText(frame, actionType, actionID, HasAction(frame.action)) - end) -end - hotkey.RegisterFrame = function(frame) --wrap(function() @@ -88,26 +84,33 @@ end hotkey.ui = function() - hotkey.player() - hotkey.pet() + --hotkey.player() + --hotkey.pet() end hotkey.world = function() - hotkeyEvents["UPDATE_BINDINGS"] = {"actionbar"} + hotkeyEvents["UPDATE_BINDINGS"] = {"binding"} hotkey.UPDATE_BINDINGS = hotkey.UpdateFromEvent kb:RegisterEvent("UPDATE_BINDINGS") hotkey.player() hotkey.pet() - -- Set this after, since we already full-scanned buttons - hooksecurefunc("ActionButton_Update", hotkey.ActionButton_Update) end -- requires all these arguments since non-actionbar buttons don't have all of said methods hotkey.UpdateSkeletonKeyText = function(frame, actionType, actionID, hasAction) bindings = kb.GetBindings() print(frame, actionType, actionID, hasAction) + + local indexKey = tostring(actionType) .. '_' .. tostring(actionID) + local oldKey = actionIndex[frame] + if hasAction and not actionFrames[indexKey] then + actionFrames[indexKey] = frame + actionIndex[frame] = indexKey + print('|cFF00FF00['..indexKey.. '] = '.. tostring(frame)) + end + if bindings[actionType] then --print('|cFFFFFF00'..frame:GetName(), actionType, actionID, hasAction) local binds = bindings[actionType][actionID] @@ -138,15 +141,18 @@ if ActionBarButtonEventsFrame.frames then for index, frame in ipairs(ActionBarButtonEventsFrame.frames) do local actionType, actionID = GetActionInfo(frame.action) - hotkey.UpdateSkeletonKeyText(frame, actionType, actionID, HasAction(frame.action)) + local hasAction = HasAction(frame.action) + actionSlots[frame.action] = frame + hotkey.UpdateSkeletonKeyText(frame, actionType, actionID, hasAction) end end end hotkey.actionslot = function(self, event, slot) - --print(event, slot) + print(actionSlots[slot], event, slot, GetActionInfo(slot)) --print(GetActionButtonForID(slot)) - hotkey.UpdateSkeletonKeyText(GetActionButtonForID(slot)) + local atype, aid = GetActionInfo(slot) + hotkey.UpdateSkeletonKeyText(actionSlots[slot], atype, aid, HasAction(slot)) end hotkey.player = function() @@ -154,6 +160,7 @@ end + hotkey.pet = function(self, event, arg1) if event == 'UNIT_PET' and arg1 == 'player' then if PetHasActionBar() and UnitIsVisible("pet") then @@ -176,3 +183,21 @@ end +--- used to pick up changes from user interaction +local changeIndex = 1 +hotkey.binding = function() + print('|cFFFF0088BindingsUpdate') + local changeNum = #kb.ChangedBindings + if changeNum >= changeIndex then + for i = changeIndex, changeNum do + local actionType, actionID, name = unpack(kb.ChangedBindings[i]) + local key = actionType .. '_' .. actionID + if actionFrames[key] then + hotkey.UpdateSkeletonKeyText(actionFrames[key] , actionType, actionID, HasAction(actionFrames[key].action)) + end + + changeIndex = i + 1 + end + + end +end \ No newline at end of file