File choir.lua changed (mode: 100644) (index 091d36e..da528f4) |
1 |
1 |
--[[ TODO Add pet target button ]]-- |
--[[ TODO Add pet target button ]]-- |
2 |
|
--[[ TODO Add close spoiler button ]]-- |
|
3 |
|
--[[ TODO Add next and previous spoiler button ]]-- |
|
4 |
2 |
--[[ TODO Add new spoiler for enemy team in arena ]]-- |
--[[ TODO Add new spoiler for enemy team in arena ]]-- |
5 |
3 |
--[[ TODO Add permanent unit buttons for player, target, focus and pet units ]]-- |
--[[ TODO Add permanent unit buttons for player, target, focus and pet units ]]-- |
6 |
4 |
--[[ TODO Add offline indicator ]]-- |
--[[ TODO Add offline indicator ]]-- |
7 |
5 |
--[[ TODO Add rest indicator ]]-- |
--[[ TODO Add rest indicator ]]-- |
8 |
|
--[[ TODO Add right-click context menu ]]-- |
|
9 |
|
--[[ TODO Add role check indicator ]]-- |
|
10 |
6 |
--[[ FIXME Raid frame and spoiler overlap when raid roster updates ]]-- |
--[[ FIXME Raid frame and spoiler overlap when raid roster updates ]]-- |
11 |
7 |
--[[ FIXME Range indicator sometimes does not update in time ]]-- |
--[[ FIXME Range indicator sometimes does not update in time ]]-- |
12 |
8 |
|
|
|
... |
... |
local function createLabel(ownerFrame, fontObject) |
67 |
63 |
assert (ownerFrame ~= nil) |
assert (ownerFrame ~= nil) |
68 |
64 |
|
|
69 |
65 |
local t = ownerFrame:CreateFontString((ownerFrame:GetName() or '') .. 'Text', 'OVERLAY') |
local t = ownerFrame:CreateFontString((ownerFrame:GetName() or '') .. 'Text', 'OVERLAY') |
70 |
|
fontObject = fontObject or NumberFont_OutlineThick_Mono_Small |
|
|
66 |
|
fontObject = fontObject or ArimoRegular12 or CousineRegular12 or NumberFont_OutlineThick_Mono_Small |
71 |
67 |
assert (fontObject ~= nil) |
assert (fontObject ~= nil) |
72 |
68 |
t:SetFontObject(fontObject) |
t:SetFontObject(fontObject) |
73 |
69 |
t:SetAllPoints() |
t:SetAllPoints() |
|
... |
... |
local function getUnitHealthDeficit(unitDesignation) |
173 |
169 |
return math.abs(c) - math.abs(m) |
return math.abs(c) - math.abs(m) |
174 |
170 |
end |
end |
175 |
171 |
|
|
176 |
|
local function getUnitHealthRatio(unitDesignation) |
|
177 |
|
assert (unitDesignation ~= nil) |
|
178 |
|
|
|
179 |
|
local m = math.abs(math.max(UnitHealthMax(unitDesignation) or 1, 1)) |
|
180 |
|
local c = math.abs(UnitHealth(unitDesignation) or 1) |
|
181 |
|
|
|
182 |
|
return c / m |
|
183 |
|
end |
|
184 |
|
|
|
185 |
172 |
local function getClassColor(classDesignation) |
local function getClassColor(classDesignation) |
186 |
173 |
assert (classDesignation ~= nil) |
assert (classDesignation ~= nil) |
187 |
174 |
assert ('string' == type(classDesignation)) |
assert ('string' == type(classDesignation)) |
|
... |
... |
local function getClassColor(classDesignation) |
196 |
183 |
return t['r'], t['g'], t['b'] |
return t['r'], t['g'], t['b'] |
197 |
184 |
end |
end |
198 |
185 |
|
|
199 |
|
local function healthBarUpdateOverlay(healthBarFrame, overlay, unitDesignation) |
|
200 |
|
assert (healthBarFrame ~= nil) |
|
201 |
|
assert (overlay ~= nil) |
|
202 |
|
assert (unitDesignation ~= nil) |
|
203 |
|
|
|
204 |
|
local ratio = 1 |
|
205 |
|
if UnitExists(unitDesignation) then |
|
206 |
|
ratio = getUnitHealthRatio(unitDesignation) or 1 |
|
207 |
|
end |
|
208 |
|
ratio = math.min(math.max(0, ratio or 1), 1) |
|
209 |
|
|
|
210 |
|
--[[ Apply health bar width changes. ]]-- |
|
211 |
|
overlay:SetPoint('BOTTOMLEFT', healthBarFrame, 'BOTTOMLEFT', 0, 0) |
|
212 |
|
overlay:SetPoint('TOPRIGHT', healthBarFrame, 'TOPRIGHT', (ratio - 1) * healthBarFrame:GetWidth(), 0) |
|
213 |
|
|
|
214 |
|
--[[ Apply health bar color changes. ]]-- |
|
215 |
|
local a = 1 |
|
216 |
|
local rangeSpell = ChoirRangeSpellName |
|
217 |
|
--[[ NOTE IsSpellInRange returns either 0, 1 or nil ]]-- |
|
218 |
|
if rangeSpell and 1 ~= IsSpellInRange(rangeSpell, unitDesignation) then |
|
219 |
|
a = 0.5 |
|
220 |
|
end |
|
221 |
|
|
|
222 |
|
if ratio <= 0.35 then |
|
223 |
|
overlay:SetVertexColor(1, 0, 0, a) |
|
224 |
|
elseif ratio <= 0.5 then |
|
225 |
|
overlay:SetVertexColor(1, 1, 0, a) |
|
226 |
|
else |
|
227 |
|
overlay:SetVertexColor(0, 1, 0, a) |
|
228 |
|
end |
|
229 |
|
end |
|
230 |
|
|
|
231 |
186 |
local function healthBarUpdateText(healthBarFrame, label, unitDesignation) |
local function healthBarUpdateText(healthBarFrame, label, unitDesignation) |
232 |
187 |
assert (healthBarFrame ~= nil) |
assert (healthBarFrame ~= nil) |
233 |
188 |
assert (label ~= nil) |
assert (label ~= nil) |
|
... |
... |
local function healthBarUpdateText(healthBarFrame, label, unitDesignation) |
252 |
207 |
end |
end |
253 |
208 |
|
|
254 |
209 |
label:SetText(t) |
label:SetText(t) |
255 |
|
|
|
256 |
210 |
end |
end |
257 |
211 |
|
|
258 |
|
local function healthBarEventProcessor(healthBarFrame, eventCategory, targetUnitDesignation) |
|
259 |
|
assert (healthBarFrame ~= nil) |
|
260 |
|
assert (eventCategory == 'UNIT_HEALTH' or eventCategory == 'UNIT_COMBAT') |
|
|
212 |
|
local function powerBarUpdateText(barFrame, label, unitDesignation) |
|
213 |
|
assert (barFrame ~= nil) |
|
214 |
|
assert (label ~= nil) |
|
215 |
|
assert (unitDesignation ~= nil) |
261 |
216 |
|
|
262 |
|
local unitButton = healthBarFrame:GetParent() |
|
263 |
|
assert (unitButton ~= nil) |
|
|
217 |
|
local d = UnitPower(unitDesignation) or 0 |
|
218 |
|
local t |
|
219 |
|
if math.abs(d) > 1000 then |
|
220 |
|
t = math.floor(d / 1000) .. ' K' |
|
221 |
|
elseif math.abs(d) > 1000000 then |
|
222 |
|
t = math.floor(d / 1000000) .. ' M' |
|
223 |
|
else |
|
224 |
|
t = tostring(math.floor(d)) |
|
225 |
|
end |
|
226 |
|
label:SetText(t) |
|
227 |
|
end |
264 |
228 |
|
|
265 |
|
local unitDesignation = unitButton:GetAttribute('unit') |
|
|
229 |
|
local function progressBarUpdateText(barFrame, label, unitDesignation, eventCategory) |
|
230 |
|
if 'UNIT_HEALTH' == eventCategory then |
|
231 |
|
healthBarUpdateText(barFrame, label, unitDesignation) |
|
232 |
|
else |
|
233 |
|
powerBarUpdateText(barFrame, label, unitDesignation) |
|
234 |
|
end |
|
235 |
|
end |
|
236 |
|
|
|
237 |
|
local function getUnitProgress(unitDesignation, eventCategory) |
266 |
238 |
assert (unitDesignation ~= nil) |
assert (unitDesignation ~= nil) |
|
239 |
|
assert ('string' == type(unitDesignation)) |
|
240 |
|
assert (string.len(unitDesignation) >= 2) |
267 |
241 |
|
|
268 |
242 |
if not UnitExists(unitDesignation) then |
if not UnitExists(unitDesignation) then |
269 |
243 |
return |
return |
270 |
244 |
end |
end |
271 |
245 |
|
|
272 |
|
--[[ Assume UNIT_HEALTH event is processed for the relevant unit. ]]-- |
|
273 |
|
if targetUnitDesignation ~= unitDesignation then |
|
274 |
|
return |
|
|
246 |
|
assert (eventCategory ~= nil) |
|
247 |
|
assert ('string' == type(eventCategory)) |
|
248 |
|
assert (string.len(eventCategory) >= 2) |
|
249 |
|
|
|
250 |
|
local progressRatio |
|
251 |
|
if 'UNIT_HEALTH' == eventCategory then |
|
252 |
|
local a = math.abs(UnitHealth(unitDesignation) or 0) |
|
253 |
|
local b = math.abs(UnitHealthMax(unitDesignation) or 1) |
|
254 |
|
progressRatio = a / b |
|
255 |
|
elseif 'UNIT_MANA' == eventCategory then |
|
256 |
|
local a = math.abs(UnitMana(unitDesignation) or 0) |
|
257 |
|
local b = math.abs(UnitManaMax(unitDesignation) or 1) |
|
258 |
|
progressRatio = a / b |
|
259 |
|
else |
|
260 |
|
local a = math.abs(UnitPower(unitDesignation) or 0) |
|
261 |
|
local b = math.abs(UnitPowerMax(unitDesignation) or 1) |
|
262 |
|
progressRatio = a / b |
275 |
263 |
end |
end |
276 |
264 |
|
|
277 |
|
local overlay = healthBarFrame.overlay |
|
278 |
|
assert (overlay ~= nil) |
|
|
265 |
|
assert (progressRatio ~= nil) |
|
266 |
|
assert (progressRatio >= 0) |
|
267 |
|
assert (progressRatio <= 1) |
|
268 |
|
return progressRatio |
|
269 |
|
end |
279 |
270 |
|
|
280 |
|
healthBarUpdateOverlay(healthBarFrame, overlay, unitDesignation) |
|
|
271 |
|
local function progressBarUpdateOverlay(barFrame, overlay, unitDesignation, eventCategory) |
|
272 |
|
assert (barFrame~= nil) |
|
273 |
|
assert (overlay ~= nil) |
|
274 |
|
assert (unitDesignation ~= nil) |
|
275 |
|
assert (eventCategory ~= nil) |
281 |
276 |
|
|
282 |
|
--[[ Apply health bar text content. ]]-- |
|
283 |
|
local label = healthBarFrame.label |
|
284 |
|
assert (label ~= nil) |
|
|
277 |
|
if not UnitExists(unitDesignation) then |
|
278 |
|
return |
|
279 |
|
end |
285 |
280 |
|
|
286 |
|
healthBarUpdateText(healthBarFrame, label, unitDesignation) |
|
|
281 |
|
local ratio = getUnitProgress(unitDesignation, eventCategory) |
|
282 |
|
if not ratio then |
|
283 |
|
ratio = 0 |
|
284 |
|
elseif 'number' ~= type(ratio) then |
|
285 |
|
ratio = 0 |
|
286 |
|
else |
|
287 |
|
ratio = math.min(math.max(0, ratio), 1) |
|
288 |
|
end |
287 |
289 |
|
|
288 |
|
local updateFrequencyPerSecond = 0.5 |
|
289 |
|
healthBarFrame.idleDurationSec = updateFrequencyPerSecond |
|
|
290 |
|
--[[ Apply health bar width changes. ]]-- |
|
291 |
|
local overlayHeight = overlay:GetHeight() |
|
292 |
|
local barHeight = barFrame:GetHeight() |
|
293 |
|
local marginTop = (barHeight - overlayHeight) / 2 |
|
294 |
|
overlay:SetWidth(barFrame:GetWidth()) |
|
295 |
|
overlay:SetPoint('BOTTOMLEFT', barFrame, 'BOTTOMLEFT', 0, marginTop) |
|
296 |
|
overlay:SetPoint('TOPRIGHT', barFrame, 'TOPRIGHT', (ratio - 1) * barFrame:GetWidth(), -marginTop) |
|
297 |
|
|
|
298 |
|
--[[ FIXME When druid shapeshifts the power bar only assumes the color of the primary resource that is mana, |
|
299 |
|
-- instead of changing depending on the current shape's resource. |
|
300 |
|
-- The number that the text label shows remains correct. ]]-- |
|
301 |
|
if 'UNIT_POWER' == eventCategory then |
|
302 |
|
local colorMap = PowerBarColor |
|
303 |
|
assert (colorMap ~= nil) |
|
304 |
|
assert ('table' == type(colorMap)) |
|
305 |
|
local unitPowerTypeIndex = UnitPowerType(unitDesignation) |
|
306 |
|
local powerColor = colorMap[unitPowerTypeIndex] |
|
307 |
|
if powerColor then |
|
308 |
|
assert ('table' == type(powerColor)) |
|
309 |
|
local red = powerColor['r'] |
|
310 |
|
local green = powerColor['g'] |
|
311 |
|
local blue = powerColor['b'] |
|
312 |
|
overlay:SetVertexColor(red, green, blue) |
|
313 |
|
end |
|
314 |
|
end |
290 |
315 |
end |
end |
291 |
316 |
|
|
292 |
|
local function healthBarUpdateProcessor(self, elapsedDurationSec) |
|
293 |
|
assert (self ~= nil) |
|
294 |
|
assert (elapsedDurationSec ~= nil) |
|
|
317 |
|
local function progressBarEventProcessor(barFrame, eventCategory) |
|
318 |
|
assert (barFrame ~= nil) |
|
319 |
|
assert (eventCategory ~= nil) |
|
320 |
|
assert ('string' == type(eventCategory)) |
295 |
321 |
|
|
296 |
|
local updateFrequencyPerSecond = 0.5 |
|
|
322 |
|
local unitButton = barFrame:GetParent() |
|
323 |
|
assert (unitButton ~= nil) |
297 |
324 |
|
|
298 |
|
local idleDurationSec = self.idleDurationSec or 0 |
|
299 |
|
if idleDurationSec > 0 then |
|
300 |
|
self.idleDurationSec = idleDurationSec - elapsedDurationSec |
|
301 |
|
else |
|
302 |
|
self.idleDurationSec = math.abs(updateFrequencyPerSecond) |
|
|
325 |
|
local unitDesignation = unitButton:GetAttribute('unit') |
|
326 |
|
assert (unitDesignation ~= nil) |
303 |
327 |
|
|
304 |
|
local unitButton = self:GetParent() |
|
305 |
|
assert (unitButton ~= nil) |
|
|
328 |
|
if not UnitExists(unitDesignation) then |
|
329 |
|
return |
|
330 |
|
end |
306 |
331 |
|
|
307 |
|
local unitDesignation = unitButton:GetAttribute('unit') |
|
308 |
|
assert (unitDesignation ~= nil) |
|
|
332 |
|
local overlay = barFrame.overlay |
|
333 |
|
assert (overlay ~= nil) |
309 |
334 |
|
|
310 |
|
local overlay = self.overlay |
|
311 |
|
assert (overlay ~= nil) |
|
|
335 |
|
local strategy = barFrame.strategy or 'UNIT_HEALTH' |
|
336 |
|
assert (strategy ~= nil) |
|
337 |
|
assert ('string' == type(strategy)) |
|
338 |
|
assert (string.len(strategy) >= 1) |
312 |
339 |
|
|
313 |
|
healthBarUpdateOverlay(self, overlay, unitDesignation) |
|
314 |
|
end |
|
|
340 |
|
barFrame:SetWidth(unitButton:GetWidth()) |
|
341 |
|
progressBarUpdateOverlay(barFrame, overlay, unitDesignation, strategy) |
|
342 |
|
|
|
343 |
|
--[[ Apply health bar text content. ]]-- |
|
344 |
|
local label = barFrame.label |
|
345 |
|
assert (label ~= nil) |
|
346 |
|
|
|
347 |
|
progressBarUpdateText(barFrame, label, unitDesignation, strategy) |
315 |
348 |
end |
end |
316 |
349 |
|
|
317 |
|
local function createHealthBar(unitButton, width, height) |
|
|
350 |
|
local function createProgressBar(n, unitButton, strategy, width, height, red, green, blue) |
|
351 |
|
assert (n ~= nil) |
318 |
352 |
assert (unitButton ~= nil) |
assert (unitButton ~= nil) |
|
353 |
|
assert ('UNIT_HEALTH' == strategy or 'UNIT_POWER' == strategy) |
319 |
354 |
|
|
320 |
355 |
assert (width ~= nil) |
assert (width ~= nil) |
321 |
356 |
assert ('number' == type(width)) |
assert ('number' == type(width)) |
|
... |
... |
local function createHealthBar(unitButton, width, height) |
327 |
362 |
assert (height >= 12) |
assert (height >= 12) |
328 |
363 |
assert (height <= 288) |
assert (height <= 288) |
329 |
364 |
|
|
330 |
|
local n = (unitButton:GetName() or '') .. 'HealthBarFrame' |
|
331 |
|
local healthBarFrame = CreateFrame('FRAME', n, unitButton) |
|
332 |
|
healthBarFrame:SetSize(width, height) |
|
|
365 |
|
if not n then |
|
366 |
|
n = (unitButton:GetName() or '') .. 'ProgressBarFrame' |
|
367 |
|
end |
|
368 |
|
|
|
369 |
|
local barFrame = _G[n] |
|
370 |
|
if barFrame then |
|
371 |
|
return barFrame |
|
372 |
|
end |
|
373 |
|
|
|
374 |
|
barFrame = CreateFrame('FRAME', n, unitButton) |
|
375 |
|
barFrame:SetSize(width, height) |
333 |
376 |
|
|
334 |
|
local b = healthBarFrame:CreateTexture(n .. 'Overlay', 'OVERLAY') |
|
335 |
|
b:SetAllPoints() |
|
|
377 |
|
local b = barFrame:CreateTexture(n .. 'Overlay', 'OVERLAY') |
|
378 |
|
b:SetWidth(width) |
|
379 |
|
b:SetHeight(math.min(height, 12)) |
|
380 |
|
local marginBottom = (height - b:GetHeight()) / 2 |
|
381 |
|
b:SetPoint('BOTTOMLEFT', 0, marginBottom) |
|
382 |
|
b:SetPoint('TOPRIGHT', 0, -marginBottom) |
336 |
383 |
b:SetTexture("Interface\\AddOns\\choir\\share\\Minimalist.tga") |
b:SetTexture("Interface\\AddOns\\choir\\share\\Minimalist.tga") |
337 |
|
b:SetVertexColor(0, 1, 0, 1) |
|
338 |
384 |
|
|
339 |
|
local t = createLabel(healthBarFrame, UnifontRegular16) |
|
|
385 |
|
if not red then |
|
386 |
|
red = 0 |
|
387 |
|
end |
|
388 |
|
if not green then |
|
389 |
|
green = 1 |
|
390 |
|
end |
|
391 |
|
if not blue then |
|
392 |
|
blue = 0 |
|
393 |
|
end |
|
394 |
|
assert (red >= 0) |
|
395 |
|
assert (red <= 1) |
|
396 |
|
assert (green >= 0) |
|
397 |
|
assert (green <= 1) |
|
398 |
|
assert (blue >= 0) |
|
399 |
|
assert (blue <= 1) |
|
400 |
|
b:SetVertexColor(red, green, blue) |
340 |
401 |
|
|
341 |
|
healthBarFrame.label = t |
|
342 |
|
healthBarFrame.overlay = b |
|
|
402 |
|
local t = createLabel(barFrame) |
343 |
403 |
|
|
344 |
|
healthBarFrame:RegisterEvent('UNIT_COMBAT') |
|
345 |
|
healthBarFrame:RegisterEvent('UNIT_HEALTH') |
|
|
404 |
|
barFrame.strategy = strategy |
|
405 |
|
barFrame.label = t |
|
406 |
|
barFrame.overlay = b |
346 |
407 |
|
|
347 |
|
healthBarFrame:SetScript('OnEvent', healthBarEventProcessor) |
|
|
408 |
|
barFrame:RegisterEvent('PLAYER_LOGIN') |
|
409 |
|
barFrame:RegisterEvent('ADDON_LOADED') |
348 |
410 |
|
|
349 |
|
healthBarFrame:SetScript('OnUpdate', healthBarUpdateProcessor) |
|
|
411 |
|
barFrame:RegisterEvent('UNIT_HEALTH') |
350 |
412 |
|
|
351 |
|
healthBarFrame:SetScript('OnShow', function(self) |
|
352 |
|
assert (self ~= nil) |
|
353 |
|
self.idleDurationSec = 0 |
|
354 |
|
self:SetScript('OnUpdate', healthBarUpdateProcessor) |
|
355 |
|
end) |
|
|
413 |
|
barFrame:RegisterEvent('UNIT_ENERGY') |
|
414 |
|
barFrame:RegisterEvent('UNIT_MANA') |
|
415 |
|
barFrame:RegisterEvent('UNIT_POWER') |
|
416 |
|
barFrame:RegisterEvent('UNIT_RAGE') |
|
417 |
|
barFrame:RegisterEvent('UNIT_RUNIC_POWER') |
356 |
418 |
|
|
357 |
|
healthBarFrame:SetScript('OnHide', function(self) |
|
358 |
|
assert (self ~= nil) |
|
359 |
|
self.idleDurationSec = 0 |
|
360 |
|
self:SetScript('OnUpdate', nil) |
|
361 |
|
end) |
|
|
419 |
|
barFrame:SetScript('OnEvent', progressBarEventProcessor) |
362 |
420 |
|
|
363 |
|
return healthBarFrame |
|
|
421 |
|
return barFrame, t, b |
364 |
422 |
end |
end |
365 |
423 |
|
|
366 |
424 |
local function headerEventProcessor(headerFrame) |
local function headerEventProcessor(headerFrame) |
|
... |
... |
local function headerEventProcessor(headerFrame) |
384 |
442 |
n = unitName |
n = unitName |
385 |
443 |
end |
end |
386 |
444 |
|
|
387 |
|
local m = math.floor(headerFrame:GetWidth() / 16) |
|
|
445 |
|
local fontWidth = 6 |
|
446 |
|
local m = math.floor(headerFrame:GetWidth() / fontWidth) |
388 |
447 |
local sanitizedName = string.sub(n, 1, m) |
local sanitizedName = string.sub(n, 1, m) |
389 |
448 |
if string.len(sanitizedName) < string.len(unitName) then |
if string.len(sanitizedName) < string.len(unitName) then |
390 |
449 |
sanitizedName = sanitizedName .. '…' |
sanitizedName = sanitizedName .. '…' |
|
... |
... |
local function createHeader(unitButton, width, height) |
436 |
495 |
local headerFrame = CreateFrame('FRAME', n, unitButton) |
local headerFrame = CreateFrame('FRAME', n, unitButton) |
437 |
496 |
headerFrame:SetSize(width, height) |
headerFrame:SetSize(width, height) |
438 |
497 |
|
|
439 |
|
local t = createLabel(headerFrame, UnifontRegular16) |
|
|
498 |
|
local t = createLabel(headerFrame) |
440 |
499 |
assert (t ~= nil) |
assert (t ~= nil) |
441 |
500 |
|
|
442 |
501 |
headerFrame.label = t |
headerFrame.label = t |
|
... |
... |
local function contextualMenuOnShowCallback(targetFrame, unitDesignation, mouseB |
650 |
709 |
ToggleDropDownMenu(1, nil, menuFrame, targetFrame:GetName(), 144, 12) |
ToggleDropDownMenu(1, nil, menuFrame, targetFrame:GetName(), 144, 12) |
651 |
710 |
end |
end |
652 |
711 |
|
|
|
712 |
|
local function rangeWidgetUpdateProcessor(self, elapsedDurationSec) |
|
713 |
|
assert (self ~= nil) |
|
714 |
|
assert (elapsedDurationSec ~= nil) |
|
715 |
|
|
|
716 |
|
local updateFrequencyPerSecond = 0.5 |
|
717 |
|
|
|
718 |
|
local idleDurationSec = self.idleDurationSec or 0 |
|
719 |
|
if idleDurationSec > 0 then |
|
720 |
|
self.idleDurationSec = idleDurationSec - elapsedDurationSec |
|
721 |
|
else |
|
722 |
|
self.idleDurationSec = math.abs(updateFrequencyPerSecond) |
|
723 |
|
|
|
724 |
|
local unitButton = self:GetParent() |
|
725 |
|
assert (unitButton ~= nil) |
|
726 |
|
|
|
727 |
|
local unitDesignation = unitButton:GetAttribute('unit') |
|
728 |
|
assert (unitDesignation ~= nil) |
|
729 |
|
|
|
730 |
|
--[[ Change button transparency according to range ]]-- |
|
731 |
|
local a = 1 |
|
732 |
|
local rangeSpell = ChoirRangeSpellName |
|
733 |
|
--[[ NOTE IsSpellInRange returns either 0, 1 or nil ]]-- |
|
734 |
|
if rangeSpell and 1 ~= IsSpellInRange(rangeSpell, unitDesignation) then |
|
735 |
|
a = 0.5 |
|
736 |
|
end |
|
737 |
|
unitButton:SetAlpha(a) |
|
738 |
|
end |
|
739 |
|
end |
|
740 |
|
|
|
741 |
|
local function createRangeWidget(unitButton) |
|
742 |
|
assert (unitButton ~= nil) |
|
743 |
|
|
|
744 |
|
local n = (unitButton:GetName() or '') .. 'RangeWidget' |
|
745 |
|
local w = CreateFrame('FRAME', n, unitButton) |
|
746 |
|
w:SetScript('OnUpdate', rangeWidgetUpdateProcessor) |
|
747 |
|
|
|
748 |
|
return w |
|
749 |
|
end |
|
750 |
|
|
653 |
751 |
local function createUnitButton(parentFrame, frameName, unit, |
local function createUnitButton(parentFrame, frameName, unit, |
654 |
752 |
someFilterDescriptorFirst, someFilterDescriptorLast, width, height) |
someFilterDescriptorFirst, someFilterDescriptorLast, width, height) |
655 |
753 |
assert (parentFrame ~= nil) |
assert (parentFrame ~= nil) |
|
... |
... |
local function createUnitButton(parentFrame, frameName, unit, |
686 |
784 |
SecureUnitButton_OnLoad(u, unit, contextualMenuOnShowCallback); |
SecureUnitButton_OnLoad(u, unit, contextualMenuOnShowCallback); |
687 |
785 |
|
|
688 |
786 |
local roleWidget = createRoleWidget(u) |
local roleWidget = createRoleWidget(u) |
689 |
|
local headerFrame = createHeader(u, width, 24) |
|
690 |
|
local healthBarFrame = createHealthBar(u, width, 24) |
|
|
787 |
|
local headerFrame = createHeader(u, width, 16) |
|
788 |
|
local healthBarFrame = createProgressBar(frameName .. 'HealthBarFrame', u, 'UNIT_HEALTH', width, 16) |
|
789 |
|
local powerBarFrame = createProgressBar(frameName .. 'PowerBarFrame', u, 'UNIT_POWER', width, 16) |
691 |
790 |
local threatWidget = createThreatWidget(u, width, 6) |
local threatWidget = createThreatWidget(u, width, 6) |
692 |
791 |
|
|
|
792 |
|
local rangeWidget = createRangeWidget(u) |
|
793 |
|
assert (rangeWidget ~= nil) |
|
794 |
|
|
693 |
795 |
local buffRowFirst |
local buffRowFirst |
694 |
796 |
local buffRowLast |
local buffRowLast |
695 |
797 |
if someFilterDescriptorFirst then |
if someFilterDescriptorFirst then |
|
... |
... |
local function createUnitButton(parentFrame, frameName, unit, |
699 |
801 |
buffRowLast = createClearcastingSubset(u, someFilterDescriptorLast) |
buffRowLast = createClearcastingSubset(u, someFilterDescriptorLast) |
700 |
802 |
end |
end |
701 |
803 |
|
|
702 |
|
local sectionTable = {roleWidget, headerFrame, healthBarFrame, threatWidget, buffRowFirst, buffRowLast} |
|
|
804 |
|
local sectionTable = {roleWidget, headerFrame, healthBarFrame, powerBarFrame, threatWidget, buffRowFirst, buffRowLast} |
703 |
805 |
|
|
704 |
806 |
local i = 0 |
local i = 0 |
705 |
807 |
local j = 0 |
local j = 0 |
|
... |
... |
local function createSpoilerPaginatorButton(buttonDesignation, spoiler, clickBut |
745 |
847 |
local artwork = createBackground(paginatorButton) |
local artwork = createBackground(paginatorButton) |
746 |
848 |
paginatorButton:SetNormalTexture(artwork) |
paginatorButton:SetNormalTexture(artwork) |
747 |
849 |
|
|
748 |
|
local label = createLabel(paginatorButton, UnifontRegular16) |
|
|
850 |
|
local label = createLabel(paginatorButton) |
749 |
851 |
paginatorButton:SetFontString(label) |
paginatorButton:SetFontString(label) |
750 |
852 |
paginatorButton:SetText(labelText) |
paginatorButton:SetText(labelText) |
751 |
853 |
|
|
|
... |
... |
local function createGroup(rootFrame, groupNumber, unitTable) |
1071 |
1173 |
local marginLeft = 0 |
local marginLeft = 0 |
1072 |
1174 |
local padding = 4 |
local padding = 4 |
1073 |
1175 |
local buttonWidth = 12 * 16 |
local buttonWidth = 12 * 16 |
1074 |
|
local buttonHeight = 12 * 12 |
|
|
1176 |
|
local buttonHeight = 12 * 6 |
1075 |
1177 |
while (i < #u) do |
while (i < #u) do |
1076 |
1178 |
i = i + 1 |
i = i + 1 |
1077 |
1179 |
local unitDesignation = u[i] |
local unitDesignation = u[i] |
|
... |
... |
local function createGroup(rootFrame, groupNumber, unitTable) |
1105 |
1207 |
spoiler:SetSize(marginLeft, 12 * 20) |
spoiler:SetSize(marginLeft, 12 * 20) |
1106 |
1208 |
spoiler:SetPoint('CENTER', 0, 12 * 6) |
spoiler:SetPoint('CENTER', 0, 12 * 6) |
1107 |
1209 |
|
|
1108 |
|
local title = createLabel(spoiler, UnifontRegular16) |
|
|
1210 |
|
local title = createLabel(spoiler) |
1109 |
1211 |
title:SetPoint('TOPRIGHT', 0, 0) |
title:SetPoint('TOPRIGHT', 0, 0) |
1110 |
1212 |
title:SetPoint('BOTTOMLEFT', spoiler, 'TOPLEFT', spoiler:GetWidth() / 2 - title:GetWidth() / 2, -24) |
title:SetPoint('BOTTOMLEFT', spoiler, 'TOPLEFT', spoiler:GetWidth() / 2 - title:GetWidth() / 2, -24) |
1111 |
1213 |
title:SetText('Group ' .. tostring(groupNumber)) |
title:SetText('Group ' .. tostring(groupNumber)) |
|
... |
... |
local function createRaidGroupLabel(groupFrame, groupNumber) |
1200 |
1302 |
local labelWidth = 60 |
local labelWidth = 60 |
1201 |
1303 |
|
|
1202 |
1304 |
local groupLabel = groupFrame:CreateFontString(groupFrame:GetName() .. 'Label', 'OVERLAY') |
local groupLabel = groupFrame:CreateFontString(groupFrame:GetName() .. 'Label', 'OVERLAY') |
1203 |
|
local fontObject = UnifontRegular16 or NumberFont_OutlineThick_Mono_Small |
|
|
1305 |
|
local fontObject = ArimoRegular16 or CousineRegular16 or NumberFont_OutlineThick_Mono_Small |
1204 |
1306 |
assert (fontObject ~= nil) |
assert (fontObject ~= nil) |
1205 |
1307 |
groupLabel:SetFontObject(fontObject) |
groupLabel:SetFontObject(fontObject) |
1206 |
1308 |
groupLabel:SetPoint('BOTTOMLEFT', groupFrame, 'BOTTOMLEFT', 0, 0) |
groupLabel:SetPoint('BOTTOMLEFT', groupFrame, 'BOTTOMLEFT', 0, 0) |
|
... |
... |
local function createRaidGroupFrame(raidFrame, groupNumber, unitSetOverride) |
1236 |
1338 |
end |
end |
1237 |
1339 |
|
|
1238 |
1340 |
local buttonWidth = 36 * 2 |
local buttonWidth = 36 * 2 |
1239 |
|
local buttonHeight = 12 * 12 |
|
|
1341 |
|
local buttonHeight = 12 * 6 |
1240 |
1342 |
local padding = 34 |
local padding = 34 |
1241 |
1343 |
local labelWidth = 60 |
local labelWidth = 60 |
1242 |
1344 |
|
|