File choir.lua changed (mode: 100644) (index a28775e..8aae38b) |
... |
... |
local function getDefaultUnitButtonBarColor() |
6 |
6 |
return 0, 1, 0 |
return 0, 1, 0 |
7 |
7 |
end |
end |
8 |
8 |
|
|
9 |
|
local function createClearcastingSection(unitButton) |
|
|
9 |
|
local function createClearcastingSubset(unitButton) |
10 |
10 |
assert (unitButton ~= nil) |
assert (unitButton ~= nil) |
11 |
11 |
|
|
12 |
12 |
if not ClearcastingFrame then |
if not ClearcastingFrame then |
|
... |
... |
local function createClearcastingSection(unitButton) |
14 |
14 |
return |
return |
15 |
15 |
end |
end |
16 |
16 |
|
|
17 |
|
local locale = GetLocale() |
|
18 |
|
assert (locale == 'enGB' or locale == 'enUS', 'requires English localization') |
|
19 |
|
|
|
20 |
|
local columnQuantity = 5 |
|
21 |
|
local rowQuantity = 2 |
|
22 |
|
|
|
23 |
|
local x = 0 |
|
24 |
|
local y = 0 |
|
25 |
|
|
|
26 |
|
local createIndicator = ClearcastingFrame.createIndicator |
|
27 |
|
assert (createIndicator ~= nil) |
|
|
17 |
|
local createSubset = ClearcastingFrame.createSubset |
|
18 |
|
assert (createSubset ~= nil) |
28 |
19 |
|
|
29 |
|
local padding = 2 |
|
30 |
|
|
|
31 |
|
--[[ FIXME Update indicator unit designation when unit button attribute changes at runtime. ]]-- |
|
|
20 |
|
--[[ FIXME Update indicator unit designation when unit button attribute changes at runtime. |
|
21 |
|
-- This is not an expected use-case. Rather it is a matter of robustness. ]]-- |
32 |
22 |
local unitDesignation = unitButton:GetAttribute('unit') |
local unitDesignation = unitButton:GetAttribute('unit') |
33 |
23 |
assert (unitDesignation ~= nil) |
assert (unitDesignation ~= nil) |
34 |
24 |
|
|
35 |
|
local section = CreateFrame('FRAME', unitButton:GetName() .. 'ClearcastingSection', unitButton) |
|
36 |
|
section:SetPoint('BOTTOMLEFT', 0, 0) |
|
37 |
|
section:SetPoint('TOPRIGHT', 0, (36 * rowQuantity + padding * (rowQuantity + 1)) - unitButton:GetHeight()) |
|
38 |
|
|
|
39 |
|
local d |
|
40 |
|
local harmfulSpellCategoryList = { |
|
41 |
|
'Magic', 'Poison', 'Disease', 'Curse', 'HARMFUL', |
|
42 |
|
} |
|
43 |
|
|
|
44 |
|
local i = 0 |
|
45 |
|
while (i < #harmfulSpellCategoryList) do |
|
46 |
|
i = i + 1 |
|
47 |
|
local category = harmfulSpellCategoryList[i] |
|
48 |
|
d = createIndicator(section, category, unitDesignation, 'HARMFUL') |
|
49 |
|
d:SetPoint('BOTTOMLEFT', d:GetWidth() * x + padding * (x + 1), 12 + (d:GetHeight() + 12) * y + padding * (y + 1)) |
|
50 |
|
x = x + 1 |
|
51 |
|
end |
|
52 |
|
|
|
53 |
|
local helpfulSpellMap = { |
|
54 |
|
--[[PALADIN]]-- |
|
55 |
|
{'Hand of Freedom', 'Hand of Protection', 'Sacred Shield', 'Beacon of Light'}, |
|
56 |
|
--[[PRIEST]]-- |
|
57 |
|
{'Power Word: Shield', 'Renew', 'Grace', 'Power Infusion', 'Pain Suppression'}, |
|
58 |
|
--[[DRUID]]-- |
|
59 |
|
{'Rejuvenation', 'Regrowth', 'Wild Growth'}, |
|
60 |
|
--[[SHAMAN]]-- |
|
61 |
|
{'Earth Shield'}, |
|
62 |
|
} |
|
|
25 |
|
local harmSubset = createSubset(unitButton, unitButton:GetName() .. 'HarmfulSubsetFrame', |
|
26 |
|
unitDesignation, 'HARMFUL', |
|
27 |
|
5, 1) |
|
28 |
|
harmSubset:SetPoint('BOTTOMLEFT', 0, 0) |
63 |
29 |
|
|
64 |
|
y = y + 1 |
|
65 |
|
local p = 0 |
|
66 |
|
while (p < #helpfulSpellMap) do |
|
67 |
|
p = p + 1 |
|
68 |
|
local list = helpfulSpellMap[p] |
|
69 |
|
local q = 0 |
|
70 |
|
x = 0 |
|
71 |
|
assert (#list <= columnQuantity) |
|
72 |
|
while (q < #list) do |
|
73 |
|
q = q + 1 |
|
74 |
|
local spellName = list[q] |
|
75 |
|
d = createIndicator(section, spellName, unitDesignation, 'PLAYER HELPFUL') |
|
76 |
|
d:SetPoint('BOTTOMLEFT', d:GetWidth() * x + padding * (x + 1), 12 + (d:GetHeight() + 12) * y + padding * (y + 1)) |
|
77 |
|
x = x + 1 |
|
78 |
|
end |
|
79 |
|
end |
|
|
30 |
|
--[[ TODO Track tank defensives in addition to player (healer) buffs. ]]-- |
|
31 |
|
local helpSubset = createSubset(unitButton, unitButton:GetName() .. 'HelpfulSubsetFrame', |
|
32 |
|
unitDesignation, 'PLAYER HELPFUL', |
|
33 |
|
5, 1) |
|
34 |
|
helpSubset:SetPoint('BOTTOMLEFT', 0, harmSubset:GetHeight()) |
80 |
35 |
|
|
81 |
|
return section |
|
|
36 |
|
return harmSubset, helpSubset |
82 |
37 |
end |
end |
83 |
38 |
|
|
84 |
39 |
local function createBindingKeyHandler(button) |
local function createBindingKeyHandler(button) |
|
... |
... |
local function createUnitButtonBar(unitButton) |
272 |
227 |
local n = unitButton:GetName() or '' |
local n = unitButton:GetName() or '' |
273 |
228 |
local padding = 4 |
local padding = 4 |
274 |
229 |
local marginTop = 24 |
local marginTop = 24 |
275 |
|
local marginBottom = 36 * 2 + (2 * 3) |
|
|
230 |
|
local marginBottom = 40 * 2 + (3 * 3) |
276 |
231 |
local bar = CreateFrame('FRAME', n .. 'Bar', unitButton) |
local bar = CreateFrame('FRAME', n .. 'Bar', unitButton) |
277 |
232 |
bar:SetPoint('BOTTOMLEFT', unitButton, 'BOTTOMLEFT', padding, padding + marginBottom) |
bar:SetPoint('BOTTOMLEFT', unitButton, 'BOTTOMLEFT', padding, padding + marginBottom) |
278 |
233 |
bar:SetPoint('TOPRIGHT', unitButton, 'TOPRIGHT', -padding, -padding - marginTop) |
bar:SetPoint('TOPRIGHT', unitButton, 'TOPRIGHT', -padding, -padding - marginTop) |
|
... |
... |
local function createUnitButtonBar(unitButton) |
300 |
255 |
bar:RegisterEvent('PLAYER_FOCUS_CHANGED') |
bar:RegisterEvent('PLAYER_FOCUS_CHANGED') |
301 |
256 |
bar:RegisterEvent('PLAYER_TARGET_CHANGED') |
bar:RegisterEvent('PLAYER_TARGET_CHANGED') |
302 |
257 |
bar:RegisterEvent('UNIT_HEALTH') |
bar:RegisterEvent('UNIT_HEALTH') |
|
258 |
|
--[[ NOTE UNIT_SPELLCAST_* family of events are relied on to render range indicator correctly, |
|
259 |
|
-- instead of the more expensive update hook. ]]-- |
303 |
260 |
bar:RegisterEvent('UNIT_SPELLCAST_FAILED') |
bar:RegisterEvent('UNIT_SPELLCAST_FAILED') |
304 |
261 |
bar:RegisterEvent('UNIT_SPELLCAST_FAILED_QUIET') |
bar:RegisterEvent('UNIT_SPELLCAST_FAILED_QUIET') |
305 |
262 |
bar:RegisterEvent('UNIT_SPELLCAST_SENT') |
bar:RegisterEvent('UNIT_SPELLCAST_SENT') |
|
... |
... |
local function createUnitButton(parentFrame, frameName, unit) |
374 |
331 |
createBindingKeyHandler(u) |
createBindingKeyHandler(u) |
375 |
332 |
createInheritanceHandler(u) |
createInheritanceHandler(u) |
376 |
333 |
|
|
377 |
|
u:SetSize(24 * 5 + 2 * 6, 36 * 2 + 2 * 3 + 24 * 2) |
|
|
334 |
|
u:SetSize(24 * 5 + 3 * 6, 40 * 2 + 3 * 3 + 24 * 2) |
378 |
335 |
|
|
379 |
336 |
local t = createLabel(u) |
local t = createLabel(u) |
380 |
337 |
t:SetPoint('BOTTOMLEFT', u, 'BOTTOMLEFT', 4, u:GetHeight() - 24 - 4) |
t:SetPoint('BOTTOMLEFT', u, 'BOTTOMLEFT', 4, u:GetHeight() - 24 - 4) |
|
... |
... |
local function createUnitButton(parentFrame, frameName, unit) |
387 |
344 |
local bar = createUnitButtonBar(u) |
local bar = createUnitButtonBar(u) |
388 |
345 |
u.bar = bar |
u.bar = bar |
389 |
346 |
|
|
390 |
|
local clearcasting = createClearcastingSection(u) |
|
391 |
|
u.clearcasting = clearcasting |
|
|
347 |
|
createClearcastingSubset(u) |
392 |
348 |
|
|
393 |
349 |
u:SetScript('OnEvent', unitButtonEventProcessor) |
u:SetScript('OnEvent', unitButtonEventProcessor) |
394 |
350 |
u:RegisterEvent('PARTY_CONVERTED_TO_RAID') |
u:RegisterEvent('PARTY_CONVERTED_TO_RAID') |