Mercurial > wow > skeletonkey
comparison SkeletonKey/ActionTemplates.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 | 178d489f387c |
comparison
equal
deleted
inserted
replaced
62:04c23ceaf9e0 | 63:2409fe9b81e1 |
---|---|
145 --cprint(spellID, unpack(kb.TalentBindings[spellID])) | 145 --cprint(spellID, unpack(kb.TalentBindings[spellID])) |
146 end | 146 end |
147 | 147 |
148 | 148 |
149 do | 149 do |
150 local commandActions = {} | |
150 local bindings = kb.bindings | 151 local bindings = kb.bindings |
151 local key, macro = KeyBinderKey, KeyBinderMacro | 152 local key, macro = KeyBinderKey, KeyBinderMacro |
152 kb.LoadBinding = function(command, name, icon, actionType, actionID, macroName, macroText ) | 153 kb.LoadBinding = function(command, name, icon, actionType, actionID, macroName, macroText ) |
153 | 154 |
155 local indexKey = actionType..'_'..actionID | |
154 local buttonTypeKey, buttonTypeValue = "*type-"..name, actionType | 156 local buttonTypeKey, buttonTypeValue = "*type-"..name, actionType |
155 local buttonActionKey, buttonActionValue = "*"..actionType.."-"..name, actionID | 157 local buttonActionKey, buttonActionValue = "*"..actionType.."-"..name, actionID |
156 local button = key | 158 local button = key |
157 if actionType == 'spell' then | 159 if actionType == 'spell' then |
158 buttonTypeKey = "*type-"..name | 160 buttonTypeKey = "*type-"..name |
175 buttonTypeValue = macroText | 177 buttonTypeValue = macroText |
176 buttonActionKey = nil | 178 buttonActionKey = nil |
177 end | 179 end |
178 | 180 |
179 --cprint(actionType, actionID, name) | 181 --cprint(actionType, actionID, name) |
180 --cprint(button:GetName(), buttonTypeKey,'=', buttonTypeValue) | |
181 kb.SecureAttribute(button, buttonTypeKey, buttonTypeValue) | 182 kb.SecureAttribute(button, buttonTypeKey, buttonTypeValue) |
182 if buttonActionKey then | 183 if buttonActionKey then |
183 --cprint(button:GetName(), buttonActionKey,'=', buttonActionValue) | 184 --cprint(button:GetName(), buttonActionKey,'=', buttonActionValue) |
184 kb.SecureAttribute(button, buttonActionKey, buttonActionValue) | 185 kb.SecureAttribute(button, buttonActionKey, buttonActionValue) |
185 end | 186 end |
186 | 187 |
187 local indexKey = actionType..'_'..actionID | 188 kb.bindings[indexKey] = kb.bindings[indexKey] or {} |
188 bindings[indexKey] = bindings[indexKey] or {} | 189 kb.bindings[command] = kb.bindings[indexKey] |
189 bindings[command] = bindings[indexKey] | 190 commandActions[command] = indexKey |
190 return bindings[indexKey], actionID | 191 return bindings[indexKey], actionID |
191 end | 192 end |
192 | 193 |
193 kb.ApplyBindings = function (profile) | 194 kb.ApplyBindings = function (profile) |
194 --cprint('binding profile', profile) | 195 --cprint('binding profile', profile) |
196 | |
195 for slot, data in pairs(profile.buttons) do | 197 for slot, data in pairs(profile.buttons) do |
196 kb.LoadBinding(unpack(data)) | 198 local bindsTable, actionID = kb.LoadBinding(unpack(data)) |
199 local command = data[1] | |
197 end | 200 end |
198 | 201 |
199 for key, command in pairs(profile.bindings) do | 202 for key, command in pairs(profile.bindings) do |
200 | 203 cprint('|cFF00FFFF'.. key .. '|r to|cFF00FF00', command, commandActions[command]) |
201 --cprint(' *', key, '->', command) | |
202 | |
203 --_G.print('HotKey','loading', key, command) | |
204 SetBinding(key, command) | 204 SetBinding(key, command) |
205 if bindings[command] and not tContains(bindings[command], key) then | 205 if kb.bindings[command] then |
206 tinsert(bindings[command], key) | 206 tinsert(kb.bindings[command], key) |
207 end | 207 end |
208 end | 208 end |
209 | 209 |
210 for spellName, talentInfo in pairs(profile.talents) do | 210 for spellName, talentInfo in pairs(profile.talents) do |
211 local dummy = GetSpellInfo(spellName) | 211 local dummy = GetSpellInfo(spellName) |
213 local dest = kb.TalentBindings | 213 local dest = kb.TalentBindings |
214 if dummy then | 214 if dummy then |
215 --cprint('|cFFBBFF00Active:|r', dummy) | 215 --cprint('|cFFBBFF00Active:|r', dummy) |
216 local macroName, spellName, actionType, actionID = unpack(talentInfo) | 216 local macroName, spellName, actionType, actionID = unpack(talentInfo) |
217 local indexKey = actionType .. '_' .. actionID | 217 local indexKey = actionType .. '_' .. actionID |
218 bindings[indexKey] = {} | 218 kb.bindings[indexKey] = {} |
219 func = kb.ApplyTalentBinding | 219 func = kb.ApplyTalentBinding |
220 dest = kb.bindings[indexKey] | 220 dest = kb.bindings[indexKey] |
221 else | 221 else |
222 | 222 |
223 --cprint('|cFFFF4400Inactive:|r', talentInfo[2]) | 223 --cprint('|cFFFF4400Inactive:|r', talentInfo[2]) |
228 end | 228 end |
229 | 229 |
230 kb.ApplyAllBindings =function () | 230 kb.ApplyAllBindings =function () |
231 wipe(kb.TalentBindings) | 231 wipe(kb.TalentBindings) |
232 wipe(kb.bindings) | 232 wipe(kb.bindings) |
233 kb:print('Loading binding profile', kb.profileName) | 233 --kb:print('Loading binding profile', kb.profileName) |
234 | 234 |
235 -- reflect action key settings | 235 -- reflect action key settings |
236 if GetCVarBool("ActionButtonUseKeyDown") then | 236 if GetCVarBool("ActionButtonUseKeyDown") then |
237 KeyBinderMacro:RegisterForClicks("AnyDown") | 237 KeyBinderMacro:RegisterForClicks("AnyDown") |
238 KeyBinderKey:RegisterForClicks("AnyDown") | 238 KeyBinderKey:RegisterForClicks("AnyDown") |
245 kb.ApplyBindings(profile) | 245 kb.ApplyBindings(profile) |
246 end | 246 end |
247 -- do this after to ensure that profession binds are properly overridden | 247 -- do this after to ensure that profession binds are properly overridden |
248 kb.UpdateProfessionInfo() | 248 kb.UpdateProfessionInfo() |
249 | 249 |
250 | |
251 SaveBindings(GetCurrentBindingSet()) | 250 SaveBindings(GetCurrentBindingSet()) |
252 end | 251 end |
253 end | 252 end |
254 | 253 |
255 | 254 |
256 kb.specInfo = {} | 255 kb.specInfo = {} |
257 kb.UpdateSpecInfo = function() | 256 kb.UpdateSpecInfo = function() |
258 kb.specInfo.id = GetSpecialization() | 257 kb.specInfo.id = GetSpecialization() |
259 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) | 258 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) |
259 end | |
260 | |
261 kb.UpdateMacroInfo = function() | |
262 for i = 1, GetNumMacros() do | |
263 local name = GetMacroInfo(index) | |
264 kb.SecureAttribute(KeyBinderMacro, "*macro_"..tostring(name), i) | |
265 end | |
260 end | 266 end |
261 | 267 |
262 kb.UpdateTalentInfo = function() | 268 kb.UpdateTalentInfo = function() |
263 if kb.talentsPushed then | 269 if kb.talentsPushed then |
264 return | 270 return |
486 tinsert(kb.pendingAttributes, {target, name, value}) | 492 tinsert(kb.pendingAttributes, {target, name, value}) |
487 kb:RegisterEvent('PLAYER_REGEN_ENABLED') | 493 kb:RegisterEvent('PLAYER_REGEN_ENABLED') |
488 | 494 |
489 else | 495 else |
490 | 496 |
491 --print(target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"') | 497 cprint('|cFFFF4444' .. target:GetName()..'|r.|cFFFFFF00'.. tostring(name)..'|r = "'..tostring(value)..'"') |
492 target:SetAttribute(name, value) | 498 target:SetAttribute(name, value) |
493 end | 499 end |
494 end | 500 end |
495 | 501 |
496 kb.PLAYER_REGEN_ENABLED = function() | 502 kb.PLAYER_REGEN_ENABLED = function() |
497 if #kb.pendingAttributes >= 1 then | 503 if #kb.pendingAttributes >= 1 then |
498 local args = tremove(kb.pendingAttributes) | 504 local args = tremove(kb.pendingAttributes) |
499 while args do | 505 while args do |
500 local target, name, value = unpack(args) | 506 local target, name, value = unpack(args) |
501 --print(target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"') | 507 --print(target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"') |
508 cprint('deferred', target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"') | |
502 target:SetAttribute(name, value) | 509 target:SetAttribute(name, value) |
503 args = tremove(kb.pendingAttributes) | 510 args = tremove(kb.pendingAttributes) |
504 end | 511 end |
505 end | 512 end |
506 | 513 |