Mercurial > wow > skeletonkey
comparison SkeletonKey/HotKey.lua @ 14:82170735e67c
- move co-routine handler to general lib
- slightly better handling of pet actions
author | Nenue |
---|---|
date | Thu, 28 Jul 2016 23:58:53 -0400 |
parents | eeec4a600064 |
children | 73df13211b22 |
comparison
equal
deleted
inserted
replaced
13:eeec4a600064 | 14:82170735e67c |
---|---|
2 -- HotKey.lua | 2 -- HotKey.lua |
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 kb, print = LibStub("LibKraken").register(KeyBinder, 'HotKey') | 7 local kb, print, wrap = LibStub("LibKraken").register(KeyBinder, 'HotKey') |
8 local hotkey = {} | 8 local hotkey = {} |
9 local hotkeyText = {} | 9 local hotkeyText = {} |
10 local blizHotKey = {} | 10 local blizHotKey = {} |
11 local bindings | 11 local bindings |
12 | 12 |
27 ["ACTIONBAR_PAGE_CHANGED"] = {"actionbar"}, | 27 ["ACTIONBAR_PAGE_CHANGED"] = {"actionbar"}, |
28 ["PLAYER_ENTERING_WORLD"] = {"world","all"}, | 28 ["PLAYER_ENTERING_WORLD"] = {"world","all"}, |
29 ["PET_UI_UPDATE"] = {"pet"}, | 29 ["PET_UI_UPDATE"] = {"pet"}, |
30 } | 30 } |
31 | 31 |
32 do | |
33 local tickerQueue = {} | |
34 local ticker | |
35 local instant = false | |
36 hotkey.tick = function() | |
37 | |
38 if #tickerQueue == 0 then | |
39 instant = true | |
40 return | |
41 else | |
42 instant = false | |
43 end | |
44 local func = tremove(tickerQueue, 1) | |
45 if func then | |
46 --print('#', #tickerQueue) | |
47 func() | |
48 end | |
49 end | |
50 hotkey.wrap = function(f) | |
51 if not ticker then | |
52 --print('create ticker') | |
53 ticker = C_Timer.NewTicker(0, hotkey.tick) | |
54 end | |
55 if instant then | |
56 f() | |
57 else | |
58 tinsert(tickerQueue, f) | |
59 end | |
60 end | |
61 end | |
62 | 32 |
63 hotkey.wrapEvent = function(event, ...) | 33 hotkey.wrapEvent = function(event, ...) |
64 kb:RegisterEvent(event) | 34 kb:RegisterEvent(event) |
65 hotkeyEvents[event] = {...} | 35 hotkeyEvents[event] = {...} |
66 hotkey[event] = hotkey.UpdateFromEvent | 36 hotkey[event] = hotkey.UpdateFromEvent |
73 hotkeyEvents[event] = nil | 43 hotkeyEvents[event] = nil |
74 hotkey[event] = nil | 44 hotkey[event] = nil |
75 end | 45 end |
76 | 46 |
77 hotkey.ActionButton_Update = function(frame) | 47 hotkey.ActionButton_Update = function(frame) |
78 hotkey.wrap(function() | 48 wrap(function() |
79 local actionType, actionID = GetActionInfo(frame.action) | 49 local actionType, actionID = GetActionInfo(frame.action) |
80 hotkey.UpdateSkeletonKeyText(frame, actionType, actionID, HasAction(frame.action)) | 50 hotkey.UpdateSkeletonKeyText(frame, actionType, actionID, HasAction(frame.action)) |
81 end) | 51 end) |
82 end | 52 end |
83 | 53 |
84 | 54 |
85 hotkey.RegisterFrame = function(frame) | 55 hotkey.RegisterFrame = function(frame) |
86 --hotkey.wrap(function() | 56 --wrap(function() |
87 --print('ActionBarButtonEventsFrame_RegisterFrame(', frame:GetName(), frame.action, frame:IsVisible(), frame:IsShown()) | 57 --print('ActionBarButtonEventsFrame_RegisterFrame(', frame:GetName(), frame.action, frame:IsVisible(), frame:IsShown()) |
88 --end) | 58 --end) |
89 blizHotKey[frame] = frame.HotKey | 59 blizHotKey[frame] = frame.HotKey |
90 loadedFrames[frame] = true | 60 loadedFrames[frame] = true |
91 end | 61 end |