File daybreak.lua changed (mode: 100644) (index e99adab..a5b992b) |
... |
... |
local function acceptUnitAura(button, eventCategory) |
6 |
6 |
assert (button ~= nil) |
assert (button ~= nil) |
7 |
7 |
assert (eventCategory ~= nil) |
assert (eventCategory ~= nil) |
8 |
8 |
|
|
9 |
|
local auraName = button:GetAttribute('spell') |
|
|
9 |
|
local auraName = button.spell |
10 |
10 |
assert (auraName ~= nil) |
assert (auraName ~= nil) |
11 |
11 |
|
|
12 |
|
local unitDesignation = button:GetAttribute('unit') |
|
|
12 |
|
local unitDesignation = button.unit |
13 |
13 |
assert (unitDesignation ~= nil) |
assert (unitDesignation ~= nil) |
14 |
14 |
|
|
15 |
|
local name, rank, icon, count, debuffType, duration, expirationInstance, |
|
16 |
|
unitCaster, isStealable, shouldConsolidate, |
|
17 |
|
spellId = UnitBuff(unitDesignation, auraName) |
|
18 |
|
if nil == expirationInstance then |
|
19 |
|
expirationInstance = 0 |
|
20 |
|
end |
|
21 |
|
local now = GetTime() |
|
22 |
|
if not name or not expirationInstance then |
|
23 |
|
button:Hide() |
|
24 |
|
elseif name and expirationInstance > now then |
|
25 |
|
local elapsedDuration = expirationInstance - now |
|
26 |
|
local durationRemaining = duration - elapsedDuration |
|
27 |
|
button:SetText(durationRemaining) |
|
|
15 |
|
local name, _, icon = UnitBuff(unitDesignation, auraName) |
|
16 |
|
if name then |
28 |
17 |
--[[ FIXME Apply graphics only once instead of every aura update ]]-- |
--[[ FIXME Apply graphics only once instead of every aura update ]]-- |
29 |
18 |
button:SetNormalTexture(icon) |
button:SetNormalTexture(icon) |
30 |
19 |
button:Show() |
button:Show() |
|
... |
... |
end |
36 |
25 |
local function applyUpdate(button, updateDuration) |
local function applyUpdate(button, updateDuration) |
37 |
26 |
assert (button ~= nil) |
assert (button ~= nil) |
38 |
27 |
|
|
39 |
|
local auraName = button:GetAttribute('spell') |
|
|
28 |
|
local auraName = button.spell |
40 |
29 |
assert (auraName ~= nil) |
assert (auraName ~= nil) |
41 |
30 |
|
|
42 |
|
local unitDesignation = button:GetAttribute('unit') |
|
|
31 |
|
local unitDesignation = button.unit |
43 |
32 |
assert (unitDesignation ~= nil) |
assert (unitDesignation ~= nil) |
44 |
33 |
|
|
45 |
34 |
local name, _, _, _, _, duration, expirationInstance = UnitBuff(unitDesignation, auraName) |
local name, _, _, _, _, duration, expirationInstance = UnitBuff(unitDesignation, auraName) |
|
... |
... |
local function createHolyPowerIndicator(frameName, parentFrame, unitDesignation) |
99 |
88 |
return f |
return f |
100 |
89 |
end |
end |
101 |
90 |
|
|
102 |
|
local function createButton(buttonName, parentFrame, auraName) |
|
|
91 |
|
--[[-- |
|
92 |
|
@function createButton |
|
93 |
|
@param buttonName string |
|
94 |
|
@param parentFrame |
|
95 |
|
@param localizedSpellName string |
|
96 |
|
@return button frame |
|
97 |
|
@treturn spell string |
|
98 |
|
@treturn unit string |
|
99 |
|
]] |
|
100 |
|
local function createButton(buttonName, parentFrame, localizedSpellName) |
103 |
101 |
assert (buttonName ~= nil) |
assert (buttonName ~= nil) |
|
102 |
|
assert ('string' == type(buttonName)) |
|
103 |
|
assert (string.len(buttonName) >= 2) |
|
104 |
|
assert (string.len(buttonName) <= 256) |
|
105 |
|
|
104 |
106 |
assert (parentFrame ~= nil) |
assert (parentFrame ~= nil) |
105 |
|
assert (auraName ~= nil) |
|
106 |
107 |
|
|
107 |
|
local button = CreateFrame('BUTTON', buttonName, parentFrame, 'SecureActionButtonTemplate') |
|
|
108 |
|
assert (localizedSpellName ~= nil) |
|
109 |
|
assert ('string' == type(localizedSpellName)) |
|
110 |
|
assert (string.len(localizedSpellName) >= 2) |
|
111 |
|
assert (string.len(localizedSpellName) <= 256) |
|
112 |
|
|
|
113 |
|
local button = CreateFrame('BUTTON', buttonName, parentFrame) |
108 |
114 |
local size = getDefaultButtonSize() |
local size = getDefaultButtonSize() |
109 |
115 |
button:SetSize(size, size) |
button:SetSize(size, size) |
110 |
116 |
|
|
|
... |
... |
local function createButton(buttonName, parentFrame, auraName) |
113 |
119 |
text:SetAllPoints() |
text:SetAllPoints() |
114 |
120 |
|
|
115 |
121 |
button:SetFontString(text) |
button:SetFontString(text) |
116 |
|
button:SetText('?') |
|
|
122 |
|
button:SetText(nil) |
117 |
123 |
|
|
118 |
|
button:SetAttribute('type', 'cancelaura') |
|
119 |
|
button:SetAttribute('spell', auraName) |
|
120 |
|
button:SetAttribute('unit', 'player') |
|
|
124 |
|
button.spell = localizedSpellName |
|
125 |
|
button.unit = 'player' |
121 |
126 |
|
|
122 |
127 |
button:RegisterEvent('UNIT_AURA') |
button:RegisterEvent('UNIT_AURA') |
123 |
128 |
button:SetScript('OnEvent', acceptUnitAura) |
button:SetScript('OnEvent', acceptUnitAura) |