comparison SkeletonKey/HotKey.lua @ 61:b7be92f62b05

unbreak hotkey startup sequence
author Nenue
date Sun, 28 Aug 2016 10:06:59 -0400
parents d8bb2629fea8
children 04c23ceaf9e0
comparison
equal deleted inserted replaced
60:256585077cdd 61:b7be92f62b05
3 -- Created: 7/22/2016 10:28 PM 3 -- Created: 7/22/2016 10:28 PM
4 -- %file-revision% 4 -- %file-revision%
5 -- Module for fixing actionbar hotkey text 5 -- Module for fixing actionbar hotkey text
6 6
7 local _G, wipe, tContains, tinsert = _G, table.wipe, tContains, tinsert 7 local _G, wipe, tContains, tinsert = _G, table.wipe, tContains, tinsert
8 local kb, print, wrap = LibStub("LibKraken").register(KeyBinder, "HotKey") 8
9 local hotkey = CreateFrame('Frame', 'SkeletonHotKeys', UIParent)
10 local kb, print, wrap = LibStub("LibKraken").register(KeyBinder, hotkey)
9 local hotkeyText = {} 11 local hotkeyText = {}
10 local blizHotKey = {} 12 local blizHotKey = {}
11 local bindings 13 local bindings
12 local hotkey = {}
13 14
14 -- frames obtained via post-load hooks, created by addons like Dominos or BarTender4 15 -- frames obtained via post-load hooks, created by addons like Dominos or BarTender4
15 local loadedFrames = {} 16 local loadedFrames = {}
16 -- frames divided by update categories 17 -- frames divided by update categories
17 local categoryFrames = {} 18 local categoryFrames = {}
18 -- frames indexed by action slot ID (just the action bar, for... reasons) 19 -- frames indexed by action slot ID (just the action bar, for... reasons)
19 local actionSlots = {} 20 local actionSlots = {}
20 local actionFrames = {} 21 local actionFrames = {}
21 local actionIndex = {} 22 local actionIndex = {}
22 23
23 kb:wrap(hotkey)
24 24
25 --- Used to determine which groups of action buttons need updating 25 --- Used to determine which groups of action buttons need updating
26 local hotkeyEvents = { 26 local hotkeyEvents = {
27 ["UPDATE_BONUS_ACTIONBAR"] = {"bonus"}, 27 ["UPDATE_BONUS_ACTIONBAR"] = {"bonus"},
28 ["UPDATE_VEHICLE_ACTIONBAR"] = {"vehicle"}, 28 ["UPDATE_VEHICLE_ACTIONBAR"] = {"vehicle"},
49 end 49 end
50 50
51 51
52 hotkey.RegisterFrame = function(frame) 52 hotkey.RegisterFrame = function(frame)
53 --wrap(function() 53 --wrap(function()
54 --print('ActionBarButtonEventsFrame_RegisterFrame(', frame:GetName(), frame.action, frame:IsVisible(), frame:IsShown()) 54 print('ActionBarButtonEventsFrame_RegisterFrame(', frame:GetName(), frame.action, frame:IsVisible(), frame:IsShown())
55 --end) 55 --end)
56 blizHotKey[frame] = frame.HotKey 56 blizHotKey[frame] = frame.HotKey
57 loadedFrames[frame] = true 57 loadedFrames[frame] = true
58 end 58 end
59 59
70 end 70 end
71 return true 71 return true
72 end 72 end
73 73
74 hotkey.variables = function() 74 hotkey.variables = function()
75 print('variables')
75 bindings = kb.GetBindings() 76 bindings = kb.GetBindings()
76 for event, manifest in pairs(hotkeyEvents) do 77 for event, manifest in pairs(hotkeyEvents) do
77 kb:RegisterEvent(event) 78 kb:RegisterEvent(event)
78 hotkey[event] = hotkey.UpdateFromEvent 79 hotkey[event] = hotkey.UpdateFromEvent
79 end 80 end
80 hotkey.wrapEvent('UNIT_PET', 'pet') 81 hotkey.wrapEvent('UNIT_PET', 'pet')
82 hotkey.player()
81 end 83 end
82 84
83 85
84 hotkey.init = function() 86 hotkey.init = function()
87
85 hooksecurefunc("ActionBarButtonEventsFrame_RegisterFrame", hotkey.RegisterFrame) 88 hooksecurefunc("ActionBarButtonEventsFrame_RegisterFrame", hotkey.RegisterFrame)
89
86 end 90 end
87 91
88 hotkey.ui = function() 92 hotkey.ui = function()
93 print('ui')
89 --hotkey.player() 94 --hotkey.player()
90 --hotkey.pet() 95 --hotkey.pet()
91 end 96 end
92 97
98
93 hotkey.world = function() 99 hotkey.world = function()
100 print('world')
94 hotkeyEvents["UPDATE_BINDINGS"] = {"binding"} 101 hotkeyEvents["UPDATE_BINDINGS"] = {"binding"}
95 hotkey.UPDATE_BINDINGS = hotkey.UpdateFromEvent 102 hotkey.UPDATE_BINDINGS = hotkey.UpdateFromEvent
96 kb:RegisterEvent("UPDATE_BINDINGS") 103 hotkey:RegisterEvent("UPDATE_BINDINGS")
97 104
98 hotkey.player() 105 hotkey.player()
99 hotkey.pet() 106 hotkey.pet()
100 107
101 end 108 end
107 local indexKey = kb.FormatActionID(actionType, actionID) 114 local indexKey = kb.FormatActionID(actionType, actionID)
108 print('|cFF00FFFFUpdate|r', frame, indexKey, hasAction) 115 print('|cFF00FFFFUpdate|r', frame, indexKey, hasAction)
109 116
110 117
111 if bindings[indexKey] then 118 if bindings[indexKey] then
112 --print('|cFFFFFF00'..frame:GetName(), actionType, actionID, hasAction) 119 print('|cFFFFFF00'..frame:GetName(), actionType, actionID, hasAction)
113 local binds = bindings[indexKey] 120 local binds = bindings[indexKey]
114 if binds and (not frame.HotKey:IsVisible()) then 121 if binds and (not frame.HotKey:IsVisible()) then
115 if hasAction then 122 if hasAction then
116 local bindingsText = kb.BindingString(unpack(binds)) 123 local bindingsText = kb.BindingString(unpack(binds))
117 124
143 end 150 end
144 151
145 hotkey.actionbar = function() 152 hotkey.actionbar = function()
146 wipe(actionFrames) 153 wipe(actionFrames)
147 -- reset frames list 154 -- reset frames list
148 155 print('actionbar')
149 if ActionBarButtonEventsFrame.frames then 156 if ActionBarButtonEventsFrame.frames then
150 for index, frame in ipairs(ActionBarButtonEventsFrame.frames) do 157 for index, frame in ipairs(ActionBarButtonEventsFrame.frames) do
158
151 local slot = frame.action 159 local slot = frame.action
152 local actionType, actionID = GetActionInfo(slot) 160 local actionType, actionID = GetActionInfo(slot)
153 local hasAction = HasAction(slot) 161 local hasAction = HasAction(slot)
154 local indexKey = kb.FormatActionID(actionType, actionID) 162 local indexKey = kb.FormatActionID(actionType, actionID)
155 actionSlots[slot] = frame 163 actionSlots[slot] = frame
175 end 183 end
176 184
177 end 185 end
178 186
179 hotkey.player = function() 187 hotkey.player = function()
188 print('player')
180 hotkey.actionbar() 189 hotkey.actionbar()
181 end 190 end
182 191
183 192
184 193