File daybreak.lua changed (mode: 100644) (index 11564d9..774ed4e) |
... |
... |
local function acceptUnitAura(button, eventCategory) |
114 |
114 |
end |
end |
115 |
115 |
end |
end |
116 |
116 |
|
|
|
117 |
|
--[[-- |
|
118 |
|
Process UNIT_POWER event for holy power indicator. |
|
119 |
|
@function acceptUnitPower |
|
120 |
|
@tparam frame self this holy power indicator |
|
121 |
|
]] |
|
122 |
|
local function acceptUnitPower(self) |
|
123 |
|
assert (self ~= nil) |
|
124 |
|
|
|
125 |
|
local unitDesignation = self.unit |
|
126 |
|
assert (unitDesignation ~= nil) |
|
127 |
|
assert ('string' == type(unitDesignation)) |
|
128 |
|
assert (string.len(unitDesignation) >= 2) |
|
129 |
|
assert (string.len(unitDesignation) <= 256) |
|
130 |
|
|
|
131 |
|
--[[ Assume the table is sorted appropriately ]]-- |
|
132 |
|
local t = self.children |
|
133 |
|
assert (t ~= nil) |
|
134 |
|
assert ('table' == type(t)) |
|
135 |
|
assert (#t >= 1) |
|
136 |
|
assert (#t <= 256) |
|
137 |
|
|
|
138 |
|
local maxQuantity = getMaxHolyPower() |
|
139 |
|
assert (maxQuantity ~= nil) |
|
140 |
|
|
|
141 |
|
--[[ Access the quantity of holy power point property of a given unit ]]-- |
|
142 |
|
local hppq = UnitPower(unitDesignation, SPELL_POWER_HOLY_POWER) |
|
143 |
|
assert ('number' == type(hppq)) |
|
144 |
|
assert (hppq >= 0) |
|
145 |
|
assert (hppq <= 1024) |
|
146 |
|
hppq = math.abs(math.ceil(hppq)) |
|
147 |
|
assert (hppq <= maxQuantity) |
|
148 |
|
|
|
149 |
|
--[[ Display the indicators according to the current unit state ]]-- |
|
150 |
|
local i = 0 |
|
151 |
|
while (i < hppq) do |
|
152 |
|
i = i + 1 |
|
153 |
|
local p = t[i] |
|
154 |
|
assert (p ~= nil) |
|
155 |
|
p:Show() |
|
156 |
|
end |
|
157 |
|
|
|
158 |
|
while (i < maxQuantity) do |
|
159 |
|
i = i + 1 |
|
160 |
|
local p = t[i] |
|
161 |
|
assert (p ~= nil) |
|
162 |
|
p:Hide() |
|
163 |
|
end |
|
164 |
|
end |
|
165 |
|
|
|
166 |
|
--[[-- |
|
167 |
|
Access constant default indicator color. |
|
168 |
|
@function getHolyPowerIndicatorColor |
|
169 |
|
@return red green blue |
|
170 |
|
]] |
|
171 |
|
local function getHolyPowerIndicatorColor() |
|
172 |
|
return 153 / 255, 0 / 255, 102 / 255 |
|
173 |
|
end |
|
174 |
|
|
117 |
175 |
--[[-- |
--[[-- |
118 |
176 |
Produce frame that tracks and displays given unit holy power. |
Produce frame that tracks and displays given unit holy power. |
119 |
177 |
The new frame possesses custom attribute "unit". |
The new frame possesses custom attribute "unit". |
|
... |
... |
The new frame possesses custom attribute "unit". |
124 |
182 |
@treturn frame newly allocated frame |
@treturn frame newly allocated frame |
125 |
183 |
]] |
]] |
126 |
184 |
local function createHolyPowerIndicator(frameName, parentFrame, unitDesignation) |
local function createHolyPowerIndicator(frameName, parentFrame, unitDesignation) |
|
185 |
|
assert (frameName ~= nil) |
|
186 |
|
assert ('string' == type(frameName)) |
|
187 |
|
assert (string.len(frameName) >= 2) |
|
188 |
|
assert (string.len(frameName) <= 256) |
|
189 |
|
|
127 |
190 |
assert (parentFrame ~= nil) |
assert (parentFrame ~= nil) |
128 |
191 |
|
|
129 |
192 |
assert (unitDesignation ~= nil) |
assert (unitDesignation ~= nil) |
|
... |
... |
local function createHolyPowerIndicator(frameName, parentFrame, unitDesignation) |
132 |
195 |
assert (string.len(unitDesignation) <= 256) |
assert (string.len(unitDesignation) <= 256) |
133 |
196 |
|
|
134 |
197 |
local f = CreateFrame('FRAME', frameName, parentFrame) |
local f = CreateFrame('FRAME', frameName, parentFrame) |
135 |
|
f.unit = unitDesignation |
|
136 |
|
f:SetSize(64, 64) |
|
|
198 |
|
local size = 24 |
|
199 |
|
local padding = 4 |
|
200 |
|
local maxQuantity = getMaxHolyPower() |
|
201 |
|
f:SetSize(maxQuantity * (size + padding) + 4, size + padding + 4) |
|
202 |
|
|
|
203 |
|
local background = f:CreateTexture(frameName .. 'Background', 'BACKGROUND') |
|
204 |
|
background:SetAllPoints() |
|
205 |
|
background:SetTexture(0, 0, 0, 0.64) |
|
206 |
|
f.background = background |
|
207 |
|
|
137 |
208 |
local t = {} |
local t = {} |
138 |
209 |
local q = 0 |
local q = 0 |
139 |
210 |
local x = 0 |
local x = 0 |
140 |
|
local maxQuantity = getMaxHolyPower() |
|
|
211 |
|
local y = 0 |
141 |
212 |
while (q < maxQuantity) do |
while (q < maxQuantity) do |
142 |
213 |
q = q + 1 |
q = q + 1 |
143 |
214 |
local p = f:CreateTexture(frameName .. tostring(q), 'OVERLAY') |
local p = f:CreateTexture(frameName .. tostring(q), 'OVERLAY') |
144 |
|
p:SetTexture(255 / 255, 204 / 255, 0 / 255, 1) |
|
145 |
|
p:SetSize(24, 24) |
|
146 |
|
p:SetPoint('BOTTOMLEFT', x * 28, 0) |
|
|
215 |
|
p:SetTexture(getHolyPowerIndicatorColor()) |
|
216 |
|
p:SetSize(size, size) |
|
217 |
|
p:SetPoint('BOTTOMLEFT', padding + x * (size + padding), y + padding) |
147 |
218 |
p:Hide() |
p:Hide() |
148 |
219 |
x = x + 1 |
x = x + 1 |
149 |
220 |
t[q] = p |
t[q] = p |
150 |
221 |
end |
end |
|
222 |
|
|
|
223 |
|
f.unit = unitDesignation |
151 |
224 |
f.children = t |
f.children = t |
152 |
225 |
|
|
153 |
226 |
f:RegisterEvent('UNIT_POWER_FREQUENT') |
f:RegisterEvent('UNIT_POWER_FREQUENT') |
154 |
|
f:SetScript('OnEvent', function() |
|
155 |
|
local i = 0 |
|
156 |
|
local hppq = UnitPower(unitDesignation, SPELL_POWER_HOLY_POWER) |
|
157 |
|
while (i < maxQuantity) do |
|
158 |
|
i = i + 1 |
|
159 |
|
local p = t[i] |
|
160 |
|
if i <= hppq then |
|
161 |
|
p:Show() |
|
162 |
|
else |
|
163 |
|
p:Hide() |
|
164 |
|
end |
|
165 |
|
end |
|
166 |
|
end) |
|
|
227 |
|
f:SetScript('OnEvent', acceptUnitPower) |
167 |
228 |
return f |
return f |
168 |
229 |
end |
end |
169 |
230 |
|
|