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) |