File daybreak.lua changed (mode: 100644) (index fbf87c6..72266ca) |
... |
... |
local function createButton(column, row, localizedSpellName, buttonName, parentF |
412 |
412 |
return button |
return button |
413 |
413 |
end |
end |
414 |
414 |
|
|
|
415 |
|
--[[-- |
|
416 |
|
Process combat log events to track Blessed Life effect. |
|
417 |
|
See COMBAT_LOG_EVENT event category. |
|
418 |
|
@function blessedLifeEventProcessor |
|
419 |
|
]] |
|
420 |
|
local function blessedLifeEventProcessor(blessedLife, eventCategory, instance, |
|
421 |
|
combatLogEventCategory, ...) |
|
422 |
|
local now = GetTime() |
|
423 |
|
local unitDesignation = 'player' |
|
424 |
|
|
|
425 |
|
--[[ Process if blessed life effect occurred |
|
426 |
|
-- if it did, remember the time instance ]]-- |
|
427 |
|
local unitName = select(7, ...) |
|
428 |
|
local playerName = UnitName(unitDesignation) |
|
429 |
|
if 'SPELL_ENERGIZE' == combatLogEventCategory and playerName == unitName then |
|
430 |
|
local spellName = select(11, ...) |
|
431 |
|
if 'Blessed Life' == spellName then |
|
432 |
|
blessedLife.lastEffectInstance = now |
|
433 |
|
end |
|
434 |
|
end |
|
435 |
|
|
|
436 |
|
--[[ Calculate amount of seconds passed since last proc ]]-- |
|
437 |
|
local blessedLifeCooldown = 8 |
|
438 |
|
local lastEffectInstance = blessedLife.lastEffectInstance or 0 |
|
439 |
|
local blessedLifeReady = math.abs(now - lastEffectInstance) > blessedLifeCooldown |
|
440 |
|
|
|
441 |
|
--[[ If player is in combat and more than eight seconds passed since last proc |
|
442 |
|
-- then show that blessed life is ready to proc ]]-- |
|
443 |
|
local combatFlag = 1 == UnitAffectingCombat(unitDesignation) or false |
|
444 |
|
if combatFlag and blessedLifeReady then |
|
445 |
|
blessedLife:Show() |
|
446 |
|
else |
|
447 |
|
blessedLife:Hide() |
|
448 |
|
end |
|
449 |
|
end |
|
450 |
|
|
|
451 |
|
--[[-- |
|
452 |
|
Create an indicator for Blessed Life effect. |
|
453 |
|
@function initBlessedLife |
|
454 |
|
@tparam frame rootFrame |
|
455 |
|
@treturn frame |
|
456 |
|
]] |
|
457 |
|
local function initBlessedLife(rootFrame) |
|
458 |
|
assert (rootFrame ~= nil) |
|
459 |
|
|
|
460 |
|
local blessedLife = CreateFrame('FRAME', 'DaybreakBlessedLifeFrame', rootFrame) |
|
461 |
|
local size = getDefaultButtonSize() |
|
462 |
|
local padding = math.max(32 - size, 0) |
|
463 |
|
local s = size + padding |
|
464 |
|
local column = 2 |
|
465 |
|
local row = 0 |
|
466 |
|
blessedLife:SetSize(size, size) |
|
467 |
|
blessedLife:SetPoint('BOTTOMLEFT', s * column, s * row) |
|
468 |
|
|
|
469 |
|
local artwork = blessedLife:CreateTexture(blessedLife:GetName() .. 'Artwork', 'ARTWORK') |
|
470 |
|
artwork:SetAllPoints() |
|
471 |
|
artwork:SetTexture("Interface\\Icons\\Spell_holy_blessedlife") |
|
472 |
|
blessedLife.artwork = artwork |
|
473 |
|
|
|
474 |
|
blessedLife:SetScript('OnEvent', blessedLifeEventProcessor) |
|
475 |
|
blessedLife:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') |
|
476 |
|
|
|
477 |
|
blessedLife:Hide() |
|
478 |
|
|
|
479 |
|
return blessedLife |
|
480 |
|
end |
|
481 |
|
|
415 |
482 |
--[[-- |
--[[-- |
416 |
483 |
When variables loaded then create and configure all required frames. |
When variables loaded then create and configure all required frames. |
417 |
484 |
Must only be executed once per script lifetime. |
Must only be executed once per script lifetime. |
|
... |
... |
local function init(rootFrame) |
461 |
528 |
|
|
462 |
529 |
--[[ Retribution ]]-- |
--[[ Retribution ]]-- |
463 |
530 |
|
|
|
531 |
|
initBlessedLife(rootFrame) |
|
532 |
|
|
464 |
533 |
print('[Daybreak]: addon loaded') |
print('[Daybreak]: addon loaded') |
465 |
534 |
|
|
466 |
535 |
return rootFrame |
return rootFrame |