Mercurial > wow > skeletonkey
comparison SkeletonKey.lua @ 74:9824d524a661
- binding slot mixin:
- store key binding definitions under their slot's data table
- apply action button attributes when a slot is assigned
- obtain correct macro body text when a macro is slotted
- fix algorithm for resolving renamed macro indices
- move spell detail lookup code out of mixin script
- event chains:
- initialize addon from PLAYER_LOGIN
- reload keybinds from PLAYER_SPECIALIZATION_CHANGED, after spec profile is resolved
- refresh interface content from SPELLS_CHANGED
- hotkey text:
- restore communication and detection of key binding updates and reflect them accordingly
- properly respond to dynamic bindings that result from talent updates
author | Nenue |
---|---|
date | Sat, 14 Jan 2017 02:29:33 -0500 |
parents | c48913c5924c |
children | 6623b7f2c1ca |
comparison
equal
deleted
inserted
replaced
73:68365bda5ab5 | 74:9824d524a661 |
---|---|
149 kb.BindingString = function(...) | 149 kb.BindingString = function(...) |
150 local stack = {} | 150 local stack = {} |
151 for i = 1, select('#', ...) do | 151 for i = 1, select('#', ...) do |
152 local key = select(i, ...) | 152 local key = select(i, ...) |
153 if type(key) == 'string' then | 153 if type(key) == 'string' then |
154 stack[i] = key:gsub('SHIFT', 's'):gsub('ALT', 'a'):gsub('CTRL', 'c'):gsub('SPACE', 'Sp'):gsub('BUTTON', 'M '):gsub('NUMPAD', '# ') | 154 stack[i] = key:gsub('SHIFT', 's'):gsub('ALT', 'a'):gsub('CTRL', 'c'):gsub('SPACE', 'Sp'):gsub('BUTTON', 'M '):gsub('NUMPAD', '# ') |
155 end | 155 end |
156 end | 156 end |
157 | 157 |
158 if #stack >= 1 then | 158 if #stack >= 1 then |
159 return concat(stack, ',') | 159 return concat(stack, ',') |
160 else | 160 else |
241 kb.SelectProfileSet = function(name) | 241 kb.SelectProfileSet = function(name) |
242 | 242 |
243 local defaultMode | 243 local defaultMode |
244 --- General info | 244 --- General info |
245 classHeader, className, classID = UnitClass('player') | 245 classHeader, className, classID = UnitClass('player') |
246 print('|cFF00FF00profile:|r', name) | 246 --kb:print('|cFF00FF00profile:|r', name) |
247 print('|cFF00FF00class:|r', UnitClass('player')) | 247 --kb:print('|cFF00FF00class:|r', UnitClass('player')) |
248 | 248 |
249 defaultMode = BINDING_TYPE_GLOBAL | 249 defaultMode = BINDING_TYPE_GLOBAL |
250 if db[name] then | 250 if db[name] then |
251 defaultMode = BINDING_TYPE_CHARACTER | 251 defaultMode = BINDING_TYPE_CHARACTER |
252 if db[name][kb.specInfo.id] then | 252 if db[name][kb.specInfo.id] then |
285 | 285 |
286 setmetatable(kb.loadedProfiles[BINDING_TYPE_GLOBAL], {__tostring =function() return kb.configHeaders[BINDING_TYPE_GLOBAL] end}) | 286 setmetatable(kb.loadedProfiles[BINDING_TYPE_GLOBAL], {__tostring =function() return kb.configHeaders[BINDING_TYPE_GLOBAL] end}) |
287 setmetatable(kb.loadedProfiles[BINDING_TYPE_CHARACTER], {__tostring =function() return kb.configHeaders[BINDING_TYPE_CHARACTER] end}) | 287 setmetatable(kb.loadedProfiles[BINDING_TYPE_CHARACTER], {__tostring =function() return kb.configHeaders[BINDING_TYPE_CHARACTER] end}) |
288 setmetatable(kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION], {__tostring =function() return kb.configHeaders[BINDING_TYPE_SPECIALIZATION] end}) | 288 setmetatable(kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION], {__tostring =function() return kb.configHeaders[BINDING_TYPE_SPECIALIZATION] end}) |
289 | 289 |
290 print('|cFF00FF00bindMode:|r', db.bindMode) | |
291 kb.currentProfile = kb.loadedProfiles[db.bindMode] | 290 kb.currentProfile = kb.loadedProfiles[db.bindMode] |
292 kb.currentHeader = kb.configHeaders[db.bindMode] | 291 kb.currentHeader = kb.configHeaders[db.bindMode] |
292 | |
293 print('|cFF88FF00SelectProfile()|r', kb.profileName, classHeader, kb.specInfo.name) | |
293 end | 294 end |
294 | 295 |
295 | 296 |
296 function SkeletonKeyMixin:SetTab (id) | 297 function SkeletonKeyMixin:SetTab (id) |
297 self.scrollCache[db.bindMode] = kb.scrollOffset | 298 self.scrollCache[db.bindMode] = kb.scrollOffset |
315 function SkeletonKeyMixin:OnLoad() | 316 function SkeletonKeyMixin:OnLoad() |
316 kb.frame = self | 317 kb.frame = self |
317 print('|cFF0088FF'..self:GetName()..':OnLoad()') | 318 print('|cFF0088FF'..self:GetName()..':OnLoad()') |
318 | 319 |
319 self.CloseButton:SetScript('OnClick', CloseButton_OnClick) | 320 self.CloseButton:SetScript('OnClick', CloseButton_OnClick) |
320 self:RegisterEvent('PLAYER_LOGIN') | |
321 self:RegisterEvent('PLAYER_ENTERING_WORLD') | 321 self:RegisterEvent('PLAYER_ENTERING_WORLD') |
322 self:RegisterEvent('ADDON_LOADED') | 322 self:RegisterEvent('ADDON_LOADED') |
323 self:RegisterEvent('PLAYER_LOGIN') | |
324 self:RegisterUnitEvent('PLAYER_SPECIALIZATION_CHANGED', 'player') | |
323 self:EnableKeyboard(false) | 325 self:EnableKeyboard(false) |
324 | 326 |
325 self.zoomScale = self:GetScale() | 327 self.zoomScale = self:GetScale() |
326 self.backdrop = self:GetBackdrop() | 328 self.backdrop = self:GetBackdrop() |
327 self.backdropColor = {self:GetBackdropColor() } | 329 self.backdropColor = {self:GetBackdropColor() } |
328 self.backdropBorder = {self:GetBackdropBorderColor() } | 330 self.backdropBorder = {self:GetBackdropBorderColor() } |
329 | 331 |
330 end | 332 end |
331 | 333 |
332 function SkeletonKeyMixin:OnEvent(event, arg) | 334 function SkeletonKeyMixin:OnEvent(event, arg) |
333 if event == 'ADDON_LOADED' then | 335 print('|cFFFF0088'.. event..'|r', unit) |
336 if event == 'PLAYER_LOGIN' then | |
334 | 337 |
335 print('|cFF00FFFF'..event ..'|r', arg or '', IsLoggedIn()) | 338 print('|cFF00FFFF'..event ..'|r', arg or '', IsLoggedIn()) |
336 if IsLoggedIn() and not self.initialized then | 339 if not self.initialized then |
337 self:Setup() | 340 self:Setup() |
338 self.initialized = true | 341 self.initialized = true |
339 self:Update() | 342 kb.ApplyAllBindings() |
343 self:Update(true) | |
340 end | 344 end |
341 | 345 |
342 | 346 |
343 elseif kb[event] then | 347 elseif kb[event] then |
344 if self.initialized then | 348 if self.initialized then |
349 print('|cFF004488'..event ..'|r', arg or '') | 353 print('|cFF004488'..event ..'|r', arg or '') |
350 end | 354 end |
351 end | 355 end |
352 end | 356 end |
353 | 357 |
358 function SkeletonKeyMixin:RefreshSpells() | |
359 | |
360 kb.UpdateTalentInfo() | |
361 kb.UpdatePetInfo() | |
362 end | |
354 | 363 |
355 --- post ADDON_LOADED | 364 --- post ADDON_LOADED |
356 function SkeletonKeyMixin:Setup () | 365 function SkeletonKeyMixin:Setup () |
357 print('|cFF00FFFF'..self:GetName()..':Setup()') | 366 print('|cFF00FFFF'..self:GetName()..':Setup()') |
358 SkeletonKeyDB = kb.InitProfile(SkeletonKeyDB, {}) | 367 SkeletonKeyDB = kb.InitProfile(SkeletonKeyDB, {}) |
363 db = kb.db | 372 db = kb.db |
364 | 373 |
365 kb.UpdateSpecInfo() | 374 kb.UpdateSpecInfo() |
366 kb.UpdateTalentInfo() | 375 kb.UpdateTalentInfo() |
367 kb.SelectProfileSet(kb.profileName) | 376 kb.SelectProfileSet(kb.profileName) |
377 self:SetShown(kb.db.showUI) | |
368 -- todo: redo import checking | 378 -- todo: redo import checking |
369 | 379 |
370 kb.UpdateSystemBinds() | 380 kb.UpdateSystemBinds() |
371 kb.ApplyAllBindings() | |
372 | 381 |
373 if not InCombatLockdown() then | 382 if not InCombatLockdown() then |
374 kb.CreateHooks() | 383 kb.CreateHooks() |
375 else | 384 else |
376 kb:print('Some functionality will not load until breaking combat.') | 385 kb:print('Some functionality will not load until breaking combat.') |
378 end | 387 end |
379 SLASH_SKB1 = "/skb" | 388 SLASH_SKB1 = "/skb" |
380 SLASH_SKB2 = "/skeletonkey" | 389 SLASH_SKB2 = "/skeletonkey" |
381 SlashCmdList.SKB = kb.Command | 390 SlashCmdList.SKB = kb.Command |
382 | 391 |
383 self:SetShown(kb.db.showUI) | |
384 self:Update(true) | |
385 | 392 |
386 self:RegisterEvent('UPDATE_MACROS') | 393 self:RegisterEvent('UPDATE_MACROS') |
387 self:RegisterEvent('UPDATE_BINDINGS') | 394 --self:RegisterEvent('UPDATE_BINDINGS') |
388 self:RegisterUnitEvent('UNIT_PORTRAIT_UPDATE', 'player', 'pet') | 395 self:RegisterUnitEvent('UNIT_PORTRAIT_UPDATE', 'player', 'pet') |
389 self:RegisterUnitEvent('PLAYER_SPECIALIZATION_CHANGED', 'player', 'pet') | |
390 self:RegisterUnitEvent('SPELLS_CHANGED') | |
391 self:RegisterUnitEvent('TALENT_UPDATE', 'player', 'pet') | |
392 self:RegisterEvent('PLAYER_REGEN_DISABLED') | 396 self:RegisterEvent('PLAYER_REGEN_DISABLED') |
393 self:RegisterEvent('PLAYER_REGEN_ENABLED') | 397 self:RegisterEvent('PLAYER_REGEN_ENABLED') |
398 self:RegisterEvent('SPELLS_CHANGED') | |
399 self:RegisterEvent('PLAYER_TALENT_UPDATE') | |
394 | 400 |
395 self:RegisterForDrag('LeftButton') | 401 self:RegisterForDrag('LeftButton') |
396 self:SetMovable(true) | 402 self:SetMovable(true) |
397 for index, frame in ipairs(self.Plugins) do | 403 for index, frame in ipairs(self.Plugins) do |
398 frame:Setup() | 404 frame:Setup() |