Mercurial > wow > skeletonkey
comparison 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 |
comparison
equal
deleted
inserted
replaced
62:04c23ceaf9e0 | 63:2409fe9b81e1 |
---|---|
111 -- requires all these arguments since non-actionbar buttons don't have all of said methods | 111 -- requires all these arguments since non-actionbar buttons don't have all of said methods |
112 local kprint = (DEVIAN_WORKSPACE and function(...) _G.print('HotKeyUpdate', ...) end) or function() end | 112 local kprint = (DEVIAN_WORKSPACE and function(...) _G.print('HotKeyUpdate', ...) end) or function() end |
113 hotkey.UpdateHotKey = function(frame, actionType, actionID, hasAction) | 113 hotkey.UpdateHotKey = function(frame, actionType, actionID, hasAction) |
114 bindings = kb.GetBindings() | 114 bindings = kb.GetBindings() |
115 | 115 |
116 local indexKey = kb.FormatActionID(actionType, actionID) | 116 if hasAction then |
117 --kprint(frame:GetName(), '|cFF88FF00'..indexKey..'|r', hasAction) | 117 local indexKey = kb.FormatActionID(actionType, actionID) |
118 | 118 kprint(frame:GetName(), '|cFF88FF00'..indexKey..'|r', hasAction) |
119 | 119 |
120 if bindings[indexKey] then | 120 |
121 kprint(' |cFFFF0088', actionType ..'|r', actionID, hasAction) | 121 local actionName |
122 if actionType == 'spell' then | |
123 actionName = GetSpellInfo(actionID) | |
124 elseif actionType == 'macro' then | |
125 actionName = GetMacroInfo(actionID) | |
126 elseif actionType == 'summonmount' then | |
127 actionName = C_MountJournal.GetMountInfoByID(actionID) | |
128 elseif actionType == 'item' then | |
129 actionName = GetItemInfo(actionID) | |
130 end | |
131 kprint(' ', actionName) | |
132 | |
122 local binds = bindings[indexKey] | 133 local binds = bindings[indexKey] |
134 kprint(binds) | |
123 if binds and (not frame.HotKey:IsVisible()) then | 135 if binds and (not frame.HotKey:IsVisible()) then |
124 if hasAction then | 136 local bindingsText = kb.BindingString(unpack(binds)) |
125 local bindingsText = kb.BindingString(unpack(binds)) | 137 |
126 | 138 if not hotkeyText[frame] then |
127 if not hotkeyText[frame] then | 139 kprint('-new hotkey element') |
128 kprint('-new hotkey element') | 140 hotkeyText[frame] = frame:CreateFontString(frame:GetName()..'SkeletonKey', 'OVERLAY') |
129 hotkeyText[frame] = frame:CreateFontString(frame:GetName()..'SkeletonKey', 'OVERLAY') | 141 hotkeyText[frame]:SetFont(frame.HotKey:GetFont()) |
130 hotkeyText[frame]:SetFont(frame.HotKey:GetFont()) | 142 hotkeyText[frame]:SetTextColor(frame.HotKey:GetTextColor()) |
131 hotkeyText[frame]:SetTextColor(frame.HotKey:GetTextColor()) | 143 hotkeyText[frame]:SetPoint('TOPRIGHT', frame.HotKey, 'TOPRIGHT') |
132 hotkeyText[frame]:SetPoint('TOPRIGHT', frame.HotKey, 'TOPRIGHT') | 144 |
133 | 145 hooksecurefunc(frame.HotKey, 'SetVertexColor', function(self, r,g,b,a) |
134 hooksecurefunc(frame.HotKey, 'SetVertexColor', function(self, r,g,b,a) | 146 hotkeyText[frame]:SetTextColor(r,g,b,a) |
135 hotkeyText[frame]:SetTextColor(r,g,b,a) | 147 end) |
136 end) | 148 end |
137 end | 149 |
138 | 150 hotkeyText[frame]:SetText(bindingsText) |
139 hotkeyText[frame]:SetText(bindingsText) | 151 hotkeyText[frame]:Show() |
140 hotkeyText[frame]:Show() | 152 kprint(' |cFF00FFFF', frame:GetName(), '|cFFFFFF00'..tostring(bindingsText)..'|r') |
141 kprint(' |cFF00FFFF', frame:GetName(), '|cFFFFFF00'..tostring(bindingsText)..'|r') | 153 |
142 | 154 return |
143 return | |
144 end | |
145 end | 155 end |
146 end | 156 end |
147 | 157 |
148 if hotkeyText[frame] then | 158 if hotkeyText[frame] then |
159 local oldText = hotkeyText[frame]:GetText() | |
160 if oldText then | |
149 hotkeyText[frame]:SetText(nil) | 161 hotkeyText[frame]:SetText(nil) |
150 print('|cFFFF4400' .. frame:GetName() .. '|r', 'remove text') | 162 print('|cFFFF4400' .. frame:GetName() .. '|r', 'removed text', oldText) |
163 end | |
164 | |
151 end | 165 end |
152 end | 166 end |
153 | 167 |
154 hotkey.actionbar = function() | 168 hotkey.actionbar = function() |
155 wipe(actionFrames) | |
156 -- reset frames list | 169 -- reset frames list |
157 print('actionbar') | 170 print('actionbar') |
171 wipe(actionFrames) | |
158 if ActionBarButtonEventsFrame.frames then | 172 if ActionBarButtonEventsFrame.frames then |
159 for index, frame in ipairs(ActionBarButtonEventsFrame.frames) do | 173 for index, frame in ipairs(ActionBarButtonEventsFrame.frames) do |
160 | |
161 local slot = frame.action | 174 local slot = frame.action |
162 local actionType, actionID = GetActionInfo(slot) | 175 local actionType, actionID = GetActionInfo(slot) |
163 local hasAction = HasAction(slot) | 176 local hasAction = HasAction(slot) |
164 local indexKey = kb.FormatActionID(actionType, actionID) | |
165 | 177 |
166 actionSlots[slot] = frame | 178 actionSlots[slot] = frame |
167 actionFrames[indexKey] = actionFrames[indexKey] or {} | 179 if hasAction then |
168 if not tContains(actionFrames[indexKey]) then | 180 local indexKey = kb.FormatActionID(actionType, actionID) |
169 tinsert(actionFrames[indexKey], frame) | 181 |
170 actionIndex[slot] = indexKey | 182 actionFrames[indexKey] = actionFrames[indexKey] or {} |
171 end | 183 local result = '' |
184 if not tContains(actionFrames[indexKey], frame) then | |
185 tinsert(actionFrames[indexKey], frame) | |
186 actionIndex[slot] = indexKey | |
187 result = 'added' | |
188 end | |
189 print('#'..index, frame:GetName(), indexKey, result) | |
190 end | |
191 | |
172 | 192 |
173 hotkey.UpdateHotKey(frame, actionType, actionID, hasAction) | 193 hotkey.UpdateHotKey(frame, actionType, actionID, hasAction) |
174 end | 194 end |
175 end | 195 end |
176 end | 196 end |