List of commits:
Subject Hash Author Date (UTC)
fix(choir): Improve choirBindingKey attribute handling 6c5c2214cc1809e5e5e59cd3672da3cca3f2701f Vladyslav Bondarenko 2021-10-31 13:23:24
feat(choir)!: Add spell shortcut prototype d34f22a6983ffc41122acb40d22e3cb29c208a3c Vladyslav Bondarenko 2021-10-31 12:39:39
feat(choir)!: Add spell effects on unit d581df9fce342709267a3221dead4d00b9d14319 Vladyslav Bondarenko 2021-10-31 10:49:19
feat(choir)!: Close spoiler by pressing Esc 22d7370011ac45d25a410a3f569183d0cc9fb232 Vladyslav Bondarenko 2021-10-29 16:10:08
feat(choir)!: Range indicator 931a0510b562986ec76dc22f329f4af4ed723cdf Vladyslav Bondarenko 2021-10-29 10:40:46
fix(choir)!: Health bar in combat a6622578dd5a1b4e4babf699a4cf1e4eb6bb70d6 Vladyslav Bondarenko 2021-10-28 07:42:57
feat(choir)!: Decorate unit buttons 4dc5ed44a9519b275f4256cfe4281110b7a94c9a Vladyslav Bondarenko 2021-10-25 21:20:56
feat(choir)!: Copy action bar binding 70ce056ffda7f12d913ce9a42b128ea257bdd0dc Vladyslav Bondarenko 2021-10-23 23:34:56
feat!: Initial commit 45c4e781e5ff0a69f8b0bea3a869e2384c7ca454 Vladyslav Bondarenko 2021-10-23 06:03:14
Commit 6c5c2214cc1809e5e5e59cd3672da3cca3f2701f - fix(choir): Improve choirBindingKey attribute handling
Make the feature that choirBindingKey custom secure button attribute
provides easily reusable.

Previously the same logic related to assigning override bindigns
was duplicated in the script. Remove the duplications by providing a
dedicated secure handler factory for it.
Author: Vladyslav Bondarenko
Author date (UTC): 2021-10-31 13:23
Committer name: Vladyslav Bondarenko
Committer date (UTC): 2021-10-31 13:23
Parent(s): d34f22a6983ffc41122acb40d22e3cb29c208a3c
Signer:
Signing key:
Signing status: N
Tree: 1467a2c25ec7e0ae9167195ce88c08bdf3697204
File Lines added Lines deleted
choir.lua 42 39
File choir.lua changed (mode: 100644) (index a9eb218..a766c1e)
... ... local function createClearcastingSection(unitButton)
81 81 return section return section
82 82 end end
83 83
84 local function createBindingKeyHandler(button)
85 assert (button ~= nil)
86
87 local handler = CreateFrame('FRAME', button:GetName() .. 'ChoirBindingKeyHandler',
88 button, 'SecureHandlerShowHideTemplate')
89
90 handler:WrapScript(button, 'OnShow', [=[
91 local key = self:GetAttribute('choirBindingKey')
92 if key then
93 self:SetBindingClick(true, key, self)
94 end
95
96 ]=])
97
98 handler:WrapScript(button, 'OnHide', [=[
99 self:ClearBindings()
100 ]=])
101
102
103 return handler
104 end
105
84 106 local function createSpellShortcut(unitButton, frameDesignation, spellName) local function createSpellShortcut(unitButton, frameDesignation, spellName)
85 107 assert (unitButton ~= nil) assert (unitButton ~= nil)
86 108
 
... ... local function createSpellShortcut(unitButton, frameDesignation, spellName)
102 124 b:SetAttribute('unit', unitDesignation) b:SetAttribute('unit', unitDesignation)
103 125 b:SetAttribute('spell', spellName) b:SetAttribute('spell', spellName)
104 126
127 createBindingKeyHandler(b)
128
105 129 assert (b ~= nil) assert (b ~= nil)
106 130 return b return b
107 131 end end
 
... ... local function unitButtonEventProcessor(unitButton)
303 327 updateUnitButtonBarText(bar, unitDesignation) updateUnitButtonBarText(bar, unitDesignation)
304 328 end end
305 329
306 local function createDelegator(unitButton)
330 local function createInheritanceHandler(unitButton)
307 331 assert (unitButton ~= nil) assert (unitButton ~= nil)
308 332
309 local delegator = CreateFrame('FRAME', unitButton:GetName() .. 'Delegator', ChoirFrame, 'SecureHandlerAttributeTemplate')
333 local n = (unitButton:GetName() or 'Choir') .. 'InheritanceHandler'
334 local inheritor = CreateFrame('FRAME', n, unitButton, 'SecureHandlerAttributeTemplate')
310 335
311 delegator:WrapScript(unitButton, 'OnAttributeChanged', [=[
336 --[[ When a button's target unit changes, make sure that all children buttons of this button update,
337 -- to also target the same unit.
338 -- Spell shortcut feature applied by createSpellShortcut funciton depends on the inheritance handler. ]]--
339 inheritor:WrapScript(unitButton, 'OnAttributeChanged', [=[
312 340 local unitButton = self local unitButton = self
313 341
314 342 local unitDesignation = unitButton:GetAttribute('unit') local unitDesignation = unitButton:GetAttribute('unit')
 
... ... local function createDelegator(unitButton)
326 354 end end
327 355 ]=]) ]=])
328 356
329 delegator:WrapScript(unitButton, 'OnShow', [=[
330 local buttonChildList = self:GetChildList(newtable())
331 local i = 0
332 while (i < #buttonChildList) do
333 i = i + 1
334 local child = buttonChildList[i]
335
336 local key = child:GetAttribute('choirBindingKey')
337 if key then
338 self:SetBindingClick(true, key, child)
339 end
340 end
341
342 ]=])
343
344 delegator:WrapScript(unitButton, 'OnHide', [=[
345 self:ClearBindings()
346 ]=])
347
348 return delegator
357 return inheritor
349 358 end end
350 359
351 360 local function createUnitButton(parentFrame, frameName, unit) local function createUnitButton(parentFrame, frameName, unit)
 
... ... local function createUnitButton(parentFrame, frameName, unit)
362 371 u:SetAttribute('type', 'target') u:SetAttribute('type', 'target')
363 372 u:SetAttribute('unit', unit) u:SetAttribute('unit', unit)
364 373
374 createBindingKeyHandler(u)
375 createInheritanceHandler(u)
376
365 377 u:SetSize(24 * 5 + 2 * 6, 36 * 2 + 2 * 3 + 24 * 2) u:SetSize(24 * 5 + 2 * 6, 36 * 2 + 2 * 3 + 24 * 2)
366 378
367 379 local t = createLabel(u) local t = createLabel(u)
 
... ... local function createSpoiler(spoilerParent, spoilerDesignation)
403 415 --[[ Override binding key to toggle the spoiler on Escape key press. ]]-- --[[ Override binding key to toggle the spoiler on Escape key press. ]]--
404 416 self:SetBindingClick(true, 'CTRL-W', self) self:SetBindingClick(true, 'CTRL-W', self)
405 417 self:SetBindingClick(true, 'ESCAPE', self) self:SetBindingClick(true, 'ESCAPE', self)
418
406 419 self:Show() self:Show()
407 420
408 --[[ Apply override bindings to children which are unit buttons of a specific raid group. ]]--
409 local j = 0
410 421 local childTable = self:GetChildList(newtable()) local childTable = self:GetChildList(newtable())
411 while (j < #childTable) do
412 j = j + 1
413 local child = childTable[j]
422 local i = 0
423 while (i < #childTable) do
424 i = i + 1
425 local child = childTable[i]
414 426 child:Show() child:Show()
415
416 local key = child:GetAttribute('choirBindingKey')
417 if key then
418 self:SetBindingClick(true, key, child)
419 end
420 427 end end
421 428 ]=]) ]=])
422 429
 
... ... local function createSpoiler(spoilerParent, spoilerDesignation)
436 443 end end
437 444 ]=]) ]=])
438 445
439 --[[ Override key bindings are set when _onclick script is executed.
440 -- Reset the bindings when the frame is hidden to allow other frames,
441 -- especially nested spoilers, to re-use the keys. ]]--
442 446 spoiler:WrapScript(spoiler, 'OnHide', [=[ spoiler:WrapScript(spoiler, 'OnHide', [=[
443 447 self:ClearBindings() self:ClearBindings()
444 448 ]=]) ]=])
445 449
450 createBindingKeyHandler(spoiler)
451
446 452 return spoiler return spoiler
447 453 end end
448 454
 
... ... local function createUnitButtonSpellShortcut(unitButton, key)
480 486 --[[createSpellShortcut(unitButton, unitButton:GetName() .. 'CureDiseaseButton', 'Cure Disease')]]-- --[[createSpellShortcut(unitButton, unitButton:GetName() .. 'CureDiseaseButton', 'Cure Disease')]]--
481 487 --[[createSpellShortcut(unitButton, unitButton:GetName() .. 'LesserHealButton', 'Lesser Heal')]]-- --[[createSpellShortcut(unitButton, unitButton:GetName() .. 'LesserHealButton', 'Lesser Heal')]]--
482 488
483 local delegator = createDelegator(unitButton)
484 489
485 490 local shortcut local shortcut
486 491
 
... ... local function createUnitButtonSpellShortcut(unitButton, key)
497 502
498 503 shortcut = createSpellShortcut(unitButton, unitButton:GetName() .. 'PowerWordShieldButton', 'Power Word: Shield') shortcut = createSpellShortcut(unitButton, unitButton:GetName() .. 'PowerWordShieldButton', 'Power Word: Shield')
499 504 shortcut:SetAttribute('choirBindingKey', 'CTRL-SHIFT-' .. key) shortcut:SetAttribute('choirBindingKey', 'CTRL-SHIFT-' .. key)
500
501 return delegator
502 505 end end
503 506
504 507 local function createGroup(rootFrame, groupNumber, unitTable) local function createGroup(rootFrame, groupNumber, unitTable)
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/choir

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/choir

Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/choir

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main