Repository navigation
Expand file tree
/
Copy pathCore.lua
More file actions
904 lines (836 loc) · 31.9 KB
/
Copy pathCore.lua
File metadata and controls
904 lines (836 loc) · 31.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
local _, addon = ...
_, addon.Class = UnitClass("player")
addon.events = CreateFrame("Frame")
addon.events:RegisterEvent("SPELL_UPDATE_USABLE")
addon.events:RegisterEvent("SPELL_UPDATE_COOLDOWN")
addon.events:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
addon.events:RegisterEvent("PLAYER_REGEN_ENABLED")
addon.events:RegisterEvent("PLAYER_REGEN_DISABLED")
addon.events:RegisterEvent("PLAYER_UNGHOST")
addon.events:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
addon.events:RegisterEvent("PLAYER_TALENT_UPDATE")
addon.events:RegisterEvent("PLAYER_ENTERING_WORLD")
addon.events:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR")
addon.events:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
addon.events:RegisterEvent("UPDATE_VEHICLE_ACTIONBAR")
addon.events:RegisterEvent("BAG_UPDATE_COOLDOWN")
addon.events:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN")
local itemSlotCache = {}
local LCG = LibStub("LibCustomGlow-1.0", true)
local lcgWarnedOnce = false
local activeGlows = {}
local GLOW_KEY = "ProcGlows"
local allGlowingButtons = {}
local spellButtonCache = {}
local itemAnchorCache = {}
local spellAnchorCache = {}
local cdmSpellFrameCache = {}
local actionSlotSnapshot = {}
local spellCacheDirty = true
local itemCacheDirty = true
local stackTexts = {}
local recentSounds = {}
local LSM = LibStub("LibSharedMedia-3.0")
local CUSTOM_BORDER_ATLAS = "ClickCast-Highlight-Spellbook"
local CUSTOM_BORDER_TEXCOORD = {0.001953125, 0.142578125, 0.451171875, 0.591796875}
local CUSTOM_BORDER_FADE_DURATION = 0.25
local function CustomBorderGlow_Start(button, color)
local frame = button._CustomBorderGlow
if not frame then
frame = CreateFrame("Frame", nil, button)
frame:SetPoint("TOPLEFT", button, "TOPLEFT", -16, 16)
frame:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 16, -16)
frame:SetFrameLevel(button:GetFrameLevel() + 8)
local tex = frame:CreateTexture(nil, "OVERLAY", nil, 7)
local info = C_Texture.GetAtlasInfo(CUSTOM_BORDER_ATLAS)
if info then
tex:SetTexture(info.file or info.filename)
tex:SetTexCoord(unpack(CUSTOM_BORDER_TEXCOORD))
end
tex:SetAllPoints(frame)
tex:SetDesaturated(true)
-- tex:SetPoint("TOPLEFT", button.NormalTexture, "TOPLEFT", -2.5, 2.5)
-- tex:SetPoint("BOTTOMRIGHT", button.NormalTexture, "BOTTOMRIGHT", 1.5, -1.5)
tex:SetBlendMode("ADD")
frame.tex = tex
local fadeIn = frame:CreateAnimationGroup()
local aIn = fadeIn:CreateAnimation("Alpha")
aIn:SetFromAlpha(0)
aIn:SetToAlpha(1)
aIn:SetDuration(CUSTOM_BORDER_FADE_DURATION)
aIn:SetSmoothing("OUT")
fadeIn:SetScript("OnFinished", function()
frame:SetAlpha(1)
end)
frame.fadeIn = fadeIn
local fadeOut = frame:CreateAnimationGroup()
local aOut = fadeOut:CreateAnimation("Alpha")
aOut:SetFromAlpha(1)
aOut:SetToAlpha(0)
aOut:SetDuration(CUSTOM_BORDER_FADE_DURATION)
aOut:SetSmoothing("OUT")
fadeOut:SetScript("OnFinished", function()
frame:Hide()
end)
frame.fadeOut = fadeOut
button._CustomBorderGlow = frame
end
if color then
frame.tex:SetVertexColor(color[1], color[2], color[3], color[4] or 1)
else
frame.tex:SetVertexColor(1, 0.7, 0, 1)
end
if frame.fadeOut:IsPlaying() then
frame.fadeOut:Stop()
end
if not frame:IsShown() then
frame:SetAlpha(0)
frame:Show()
frame.fadeIn:Play()
elseif not frame.fadeIn:IsPlaying() and frame:GetAlpha() < 1 then
frame.fadeIn:Play()
end
end
local function CustomBorderGlow_Stop(button)
local frame = button._CustomBorderGlow
if not frame or not frame:IsShown() then
return
end
if frame.fadeIn:IsPlaying() then
frame.fadeIn:Stop()
end
if not frame.fadeOut:IsPlaying() then
frame.fadeOut:Play()
end
end
local BUTTON_PREFIXES = {"ActionButton", "MultiBarBottomLeftButton", "MultiBarBottomRightButton", "MultiBarRightButton", "MultiBarLeftButton",
"MultiBar5Button", "MultiBar6Button", "MultiBar7Button", "MultiBar8Button"}
local MAX_ACTION_SLOT = 180
-- ─── Third-party action bar support (Bartender4, Dominos, ElvUI) ─────────────
-- Returns the action slot for both Blizzard (.action) and LAB-based (._state_action) buttons
local function GetButtonActionSlot(button)
return button._state_action or button.action
end
local thirdPartyButtons = {}
local thirdPartyDirty = true
local function CollectThirdPartyButtons()
wipe(thirdPartyButtons)
local seen = {}
-- LibActionButton-1.0 registry (catches Bartender4, Dominos, and any other LAB addon)
local LAB = LibStub and LibStub("LibActionButton-1.0", true)
if LAB and LAB.GetAllButtons then
for btn in pairs(LAB:GetAllButtons()) do
if not seen[btn] then
seen[btn] = true
thirdPartyButtons[#thirdPartyButtons + 1] = btn
end
end
end
-- Bartender4 (BT4Button1 … BT4Button180, up to 15 bars × 12 buttons)
if _G["Bartender4"] then
for i = 1, 180 do
local btn = _G["BT4Button" .. i]
if btn and not seen[btn] then
seen[btn] = true
thirdPartyButtons[#thirdPartyButtons + 1] = btn
end
end
end
-- Dominos (DominosActionButton1 … DominosActionButton168)
if _G["Dominos"] then
for i = 1, 168 do
local btn = _G["DominosActionButton" .. i]
if btn and not seen[btn] then
seen[btn] = true
thirdPartyButtons[#thirdPartyButtons + 1] = btn
end
end
end
-- ElvUI (ElvUI_Bar<1-15>Button<1-14>)
if _G["ElvUI"] then
for bar = 1, 15 do
for slot = 1, 14 do
local btn = _G["ElvUI_Bar" .. bar .. "Button" .. slot]
if btn and not seen[btn] then
seen[btn] = true
thirdPartyButtons[#thirdPartyButtons + 1] = btn
end
end
end
end
-- ElvUI LibActionButton-1.0-ElvUI fork
local LAB_Elv = LibStub and LibStub("LibActionButton-1.0-ElvUI", true)
if LAB_Elv and LAB_Elv.GetAllButtons then
for btn in pairs(LAB_Elv:GetAllButtons()) do
if not seen[btn] then
seen[btn] = true
thirdPartyButtons[#thirdPartyButtons + 1] = btn
end
end
end
thirdPartyDirty = false
end
-- ─── Stack count overlay ─────────────────────────────────────────────────────
local STACK_FONT = "Fonts\\FRIZQT__.TTF"
local STACK_FONT_SIZE = 20
local STACK_FONT_FLAGS = "OUTLINE"
function addon:ShowStackCount(frame, count)
if not count then
addon:HideStackCount(frame)
return
end
local text = stackTexts[frame]
if not text then
text = frame:CreateFontString(nil, "OVERLAY", "NumberFontNormal")
text:SetFont(STACK_FONT, STACK_FONT_SIZE, STACK_FONT_FLAGS)
text:SetPoint("CENTER", frame, "CENTER", 0, 0)
text:SetTextColor(1, 0, 0, 1)
stackTexts[frame] = text
end
text:SetText(count)
text:Show()
end
function addon:HideStackCount(frame)
local text = stackTexts[frame]
if text then
text:Hide()
end
end
function addon:ShowProcGlow(button, r, g, b, soundKey, entryGlowType)
local glowType = entryGlowType and entryGlowType ~= "Default" and entryGlowType or (self.db and self.db.profile.glowType or "Proc Glow")
local color = r and {r, g, b, 1} or nil
if glowType == "Proc Glow" then
if not LCG.ProcGlow_Start then
if not lcgWarnedOnce then
lcgWarnedOnce = true
print("|cffff4444ProcGlows:|r LibCustomGlow did not fully initialize (ProcGlow_Start is missing). " ..
"This is likely caused by a conflicting addon or a WoW build incompatibility with " ..
"the embedded LibCustomGlow-1.0 (version " .. (LCG.minor or "?") .. "). " ..
"Glows will not display until this is resolved.")
end
return
end
local opts = {
startAnim = true,
key = GLOW_KEY
}
if color then
opts.color = color
end
LCG.ProcGlow_Start(button, opts)
local glowFrame = button["_ProcGlow" .. GLOW_KEY]
if glowFrame then
glowFrame.startAnim = false
end
elseif glowType == "Pixel Glow" then
if LCG.PixelGlow_Start then
LCG.PixelGlow_Start(button, color, nil, nil, nil, nil, nil, nil, nil, GLOW_KEY)
end
elseif glowType == "Autocast Shine" then
if LCG.AutoCastGlow_Start then
LCG.AutoCastGlow_Start(button, color, nil, nil, nil, nil, nil, GLOW_KEY)
end
elseif glowType == "Action Button Glow" then
if LCG.ButtonGlow_Start then
LCG.ButtonGlow_Start(button, color)
end
elseif glowType == "Glow Texture" then
CustomBorderGlow_Start(button, color)
end
if not allGlowingButtons[button] then
-- Play per-entry proc sound (once per sound key per frame)
if soundKey and soundKey ~= "None" and not recentSounds[soundKey] then
local soundFile = LSM:Fetch(LSM.MediaType.SOUND, soundKey, true)
if soundFile then
PlaySoundFile(soundFile, "Master")
recentSounds[soundKey] = true
C_Timer.After(0, function()
recentSounds[soundKey] = nil
end)
end
end
end
allGlowingButtons[button] = true
end
local function StopAllGlowTypes(button)
if LCG.ProcGlow_Stop then
LCG.ProcGlow_Stop(button, GLOW_KEY)
end
if LCG.PixelGlow_Stop then
LCG.PixelGlow_Stop(button, GLOW_KEY)
end
if LCG.AutoCastGlow_Stop then
LCG.AutoCastGlow_Stop(button, GLOW_KEY)
end
if LCG.ButtonGlow_Stop then
LCG.ButtonGlow_Stop(button)
end
CustomBorderGlow_Stop(button)
end
function addon:HideProcGlow(button)
StopAllGlowTypes(button)
allGlowingButtons[button] = nil
addon:HideStackCount(button)
end
function addon:HideAllGlows()
for button in pairs(allGlowingButtons) do
StopAllGlowTypes(button)
activeGlows[button] = nil
addon:HideStackCount(button)
end
wipe(allGlowingButtons)
end
function addon:IsCombatOnly()
return self.db and self.db.profile.combatOnly and not UnitAffectingCombat("player")
end
function addon:CleanupOrphanedGlows()
-- Collect all buttons that are still in a cache
local cached = {}
if addon.Auras then
for _, entries in pairs(addon.Auras) do
for _, entry in ipairs(entries) do
if entry.buttons then
for _, button in ipairs(entry.buttons) do
cached[button] = true
end
end
end
end
end
for _, buttons in pairs(spellAnchorCache) do
for _, button in ipairs(buttons) do
cached[button] = true
end
end
for _, buttons in pairs(itemAnchorCache) do
for _, button in ipairs(buttons) do
cached[button] = true
end
end
for _, frames in pairs(cdmSpellFrameCache) do
for _, frame in ipairs(frames) do
cached[frame] = true
end
end
-- Include BuffIconCooldownViewer aura frames that may have icon glows
if BuffIconCooldownViewer and BuffIconCooldownViewer.itemFramePool then
for aura in BuffIconCooldownViewer.itemFramePool:EnumerateActive() do
if aura and aura.GetBaseSpellID then
local spellID = aura:GetBaseSpellID()
if spellID and addon.Auras and addon.Auras[spellID] then
cached[aura] = true
end
end
end
end
-- Remove glows from buttons that are no longer in any cache
for button in pairs(allGlowingButtons) do
if not cached[button] then
StopAllGlowTypes(button)
allGlowingButtons[button] = nil
activeGlows[button] = nil
end
end
end
function addon:HasProcGlow(button)
local pg = button["_ProcGlow" .. GLOW_KEY]
if pg and pg:IsShown() then
return true
end
local px = button["_PixelGlow" .. GLOW_KEY]
if px and px:IsShown() then
return true
end
local ac = button["_AutoCastGlow" .. GLOW_KEY]
if ac and ac:IsShown() then
return true
end
if button._ButtonGlow and button._ButtonGlow:IsShown() then
return true
end
if button._CustomBorderGlow and button._CustomBorderGlow:IsShown() then
return true
end
return false
end
function addon:FindButtonsForSlot(slot)
local result = {}
local seen = {}
if ActionBarButtonEventsFrame and ActionBarButtonEventsFrame.frames then
for _, button in pairs(ActionBarButtonEventsFrame.frames) do
if not seen[button] and GetButtonActionSlot(button) == slot then
seen[button] = true
result[#result + 1] = button
end
end
end
for _, prefix in ipairs(BUTTON_PREFIXES) do
for i = 1, 12 do
local button = _G[prefix .. i]
if button and not seen[button] and GetButtonActionSlot(button) == slot then
seen[button] = true
result[#result + 1] = button
end
end
end
-- Third-party action bar addons (Bartender4, Dominos, ElvUI)
if thirdPartyDirty then
CollectThirdPartyButtons()
end
for _, button in ipairs(thirdPartyButtons) do
if not seen[button] and GetButtonActionSlot(button) == slot then
seen[button] = true
result[#result + 1] = button
end
end
return result
end
function addon:LookupSpellButtons(spellID)
local result = {}
local seen = {}
-- Collect all action slots for this spell (base + override)
local allSlots = {}
local slots = C_ActionBar.FindSpellActionButtons(spellID)
if slots then
for _, s in ipairs(slots) do
allSlots[#allSlots + 1] = s
end
end
if C_Spell.GetOverrideSpell then
local overrideID = C_Spell.GetOverrideSpell(spellID)
if overrideID and overrideID ~= spellID then
slots = C_ActionBar.FindSpellActionButtons(overrideID)
if slots then
for _, s in ipairs(slots) do
allSlots[#allSlots + 1] = s
end
end
end
end
-- For each slot, find every button that owns it
for _, slot in ipairs(allSlots) do
local buttons = addon:FindButtonsForSlot(slot)
for _, button in ipairs(buttons) do
if not seen[button] then
seen[button] = true
result[#result + 1] = button
end
end
end
return result
end
function addon:FindButtonsBySpellID(spellID)
if spellCacheDirty then
wipe(spellButtonCache)
spellCacheDirty = false
end
if not spellButtonCache[spellID] then
spellButtonCache[spellID] = addon:LookupSpellButtons(spellID)
end
return spellButtonCache[spellID]
end
function addon:InvalidateAllCaches()
spellCacheDirty = true
itemCacheDirty = true
thirdPartyDirty = true
addon:RebuildAuraAnchorCache()
addon:RebuildSpellButtonCache()
addon:RebuildItemButtonCache()
addon:RebuildCDMSpellFrameCache()
addon:CleanupOrphanedGlows()
end
function addon:ScanItemButtons()
if InCombatLockdown() then
itemCacheDirty = true
return
end
wipe(itemSlotCache)
for slot = 1, MAX_ACTION_SLOT do
if HasAction(slot) then
local actionType, id = GetActionInfo(slot)
if actionType == "item" and id then
if not itemSlotCache[id] then
itemSlotCache[id] = {}
end
itemSlotCache[id][#itemSlotCache[id] + 1] = slot
end
end
end
itemCacheDirty = false
end
function addon:FindButtonsByItemID(itemID)
if itemCacheDirty and not InCombatLockdown() then
addon:ScanItemButtons()
end
local slots = itemSlotCache[itemID]
if not slots then
return {}
end
local result = {}
local seen = {}
for _, slot in ipairs(slots) do
local buttons = addon:FindButtonsForSlot(slot)
for _, button in ipairs(buttons) do
if not seen[button] then
seen[button] = true
result[#result + 1] = button
end
end
end
return result
end
function addon:RebuildAuraAnchorCache()
if not addon.Auras then
return
end
-- Force spell cache refresh so LookupSpellButtons gets fresh data
spellCacheDirty = true
for buffSpellID, entries in pairs(addon.Auras) do
for _, entry in ipairs(entries) do
entry.buttons = addon:FindButtonsBySpellID(entry.anchorSpellID)
end
end
end
function addon:RebuildItemButtonCache()
wipe(itemAnchorCache)
if not addon.Items then
return
end
for key, item in pairs(addon.Items) do
itemAnchorCache[item.itemID] = addon:FindButtonsByItemID(item.itemID)
end
end
function addon:RebuildSpellButtonCache()
wipe(spellAnchorCache)
if not addon.Spells then
return
end
-- Force spell cache refresh so LookupSpellButtons gets fresh data
spellCacheDirty = true
for spellID, _ in pairs(addon.Spells) do
spellAnchorCache[spellID] = addon:FindButtonsBySpellID(spellID)
end
end
-- Build a spellID -> {frames} cache from EssentialCooldownViewer's pool.
-- The pool is dynamic so we rebuild every check cycle.
function addon:RebuildCDMSpellFrameCache()
wipe(cdmSpellFrameCache)
if not EssentialCooldownViewer or not EssentialCooldownViewer.itemFramePool then
return
end
for frame in EssentialCooldownViewer.itemFramePool:EnumerateActive() do
if frame and frame.GetBaseSpellID then
local spellID = frame:GetBaseSpellID()
if spellID then
if not cdmSpellFrameCache[spellID] then
cdmSpellFrameCache[spellID] = {}
end
cdmSpellFrameCache[spellID][#cdmSpellFrameCache[spellID] + 1] = frame
end
end
end
end
function addon:CheckAuras()
if not addon.Auras then
return
end
local suppressed = addon:IsCombatOnly()
for aura in BuffIconCooldownViewer.itemFramePool:EnumerateActive() do
local spellID = aura:GetBaseSpellID()
local entries = spellID and addon.Auras[spellID]
if entries then
-- shouldShow: hide aura if ALL entries say not to show
local anyShow = false
for _, auraData in ipairs(entries) do
if auraData.shouldShow then
anyShow = true
break
end
end
if not anyShow then
aura:Hide()
end
-- Glow on the aura icon itself: use first entry with glowIcon
local iconGlowData = nil
for _, auraData in ipairs(entries) do
if auraData.glowIcon then
iconGlowData = auraData
break
end
end
if iconGlowData then
if aura.Cooldown:IsShown() and not suppressed then
if not activeGlows[aura] or not addon:HasProcGlow(aura) then
activeGlows[aura] = true
if iconGlowData.useDefaultColor then
addon:ShowProcGlow(aura, nil, nil, nil, iconGlowData.procSound, iconGlowData.glowType)
else
addon:ShowProcGlow(aura, iconGlowData.color.r, iconGlowData.color.g, iconGlowData.color.b, iconGlowData.procSound,
iconGlowData.glowType)
end
end
else
if activeGlows[aura] then
activeGlows[aura] = nil
addon:HideProcGlow(aura)
end
end
end
-- Fetch stack count once per buff for all entries
local stackCount = aura.Applications.Applications:GetText()
-- Per-entry: action bar buttons and CDM spell frames
for _, auraData in ipairs(entries) do
local buttons = auraData.buttons
if buttons then
for _, button in ipairs(buttons) do
if aura.Cooldown:IsShown() and not suppressed then
if not addon:HasProcGlow(button) then
if auraData.useDefaultColor then
addon:ShowProcGlow(button, nil, nil, nil, auraData.procSound, auraData.glowType)
else
addon:ShowProcGlow(button, auraData.color.r, auraData.color.g, auraData.color.b, auraData.procSound,
auraData.glowType)
end
end
-- Show stack count on the action button
if auraData.showStacks then
addon:ShowStackCount(button, stackCount)
end
else
addon:HideProcGlow(button)
end
end
end
-- Glow matching spell icon in EssentialCooldownViewer (CooldownManager)
if auraData.glowCooldownManager then
local cdmFrames = cdmSpellFrameCache[auraData.anchorSpellID]
if cdmFrames then
for _, frame in ipairs(cdmFrames) do
if aura.Cooldown:IsShown() and not suppressed and C_Spell.IsSpellUsable(auraData.anchorSpellID) then
if not activeGlows[frame] or not addon:HasProcGlow(frame) then
activeGlows[frame] = true
if auraData.useDefaultColor then
addon:ShowProcGlow(frame, nil, nil, nil, auraData.procSound, auraData.glowType)
else
addon:ShowProcGlow(frame, auraData.color.r, auraData.color.g, auraData.color.b, auraData.procSound,
auraData.glowType)
end
end
-- Show stack count on the CDM spell frame
if auraData.showStacks then
addon:ShowStackCount(frame, stackCount)
end
else
if activeGlows[frame] then
activeGlows[frame] = nil
addon:HideProcGlow(frame)
end
end
end
end
end
end
end
end
end
function addon:CheckItemCooldowns()
if not addon.Items then
return
end
local suppressed = addon:IsCombatOnly()
for _, item in pairs(addon.Items) do
local buttons = itemAnchorCache[item.itemID]
if buttons then
for _, button in ipairs(buttons) do
if not suppressed and C_Item.GetItemCount(item.itemID) > 0 and C_Item.IsUsableItem(item.itemID) and (not button.cooldown:IsShown()) then
if not addon:HasProcGlow(button) then
if item.useDefaultColor then
addon:ShowProcGlow(button, nil, nil, nil, item.procSound, item.glowType)
else
addon:ShowProcGlow(button, item.color.r, item.color.g, item.color.b, item.procSound, item.glowType)
end
end
else
addon:HideProcGlow(button)
end
end
end
end
end
function addon:CheckSpellCooldowns()
if not addon.Spells then
return
end
local suppressed = addon:IsCombatOnly()
for spellID, spellData in pairs(addon.Spells) do
local cdInfo = C_Spell.GetSpellCooldown(spellID)
local isOnGCD = cdInfo and cdInfo.isOnGCD
local isUsable = C_Spell.IsSpellUsable(spellID)
local buttons = spellAnchorCache[spellID]
if buttons then
for _, button in ipairs(buttons) do
local onCooldown = button.cooldown:IsShown() and not isOnGCD
local shouldGlow = not suppressed and isUsable and not onCooldown
if shouldGlow then
if not activeGlows[button] or not addon:HasProcGlow(button) then
activeGlows[button] = true
if spellData.useDefaultColor then
addon:ShowProcGlow(button, nil, nil, nil, spellData.procSound, spellData.glowType)
else
addon:ShowProcGlow(button, spellData.color.r, spellData.color.g, spellData.color.b, spellData.procSound,
spellData.glowType)
end
end
else
if activeGlows[button] then
activeGlows[button] = nil
addon:HideProcGlow(button)
end
end
end
end
-- Glow spell icons in EssentialCooldownViewer (CooldownManager)
if spellData.glowCooldownManager then
local cdmFrames = cdmSpellFrameCache[spellID]
if cdmFrames then
for _, frame in ipairs(cdmFrames) do
local cd = frame.Cooldown or frame.cooldown
local onCooldown = cd and cd:IsShown() and not isOnGCD
local shouldGlow = not suppressed and isUsable and not onCooldown
if shouldGlow then
if not activeGlows[frame] or not addon:HasProcGlow(frame) then
activeGlows[frame] = true
if spellData.useDefaultColor then
addon:ShowProcGlow(frame, nil, nil, nil, spellData.procSound, spellData.glowType)
else
addon:ShowProcGlow(frame, spellData.color.r, spellData.color.g, spellData.color.b, spellData.procSound,
spellData.glowType)
end
end
else
if activeGlows[frame] then
activeGlows[frame] = nil
addon:HideProcGlow(frame)
end
end
end
end
end
end
end
-- Hooks
addon.events:HookScript("OnEvent", function(self, event, ...)
if event == "PLAYER_SPECIALIZATION_CHANGED" or event == "PLAYER_TALENT_UPDATE" or event == "PLAYER_ENTERING_WORLD" or event ==
"UPDATE_OVERRIDE_ACTIONBAR" or event == "UPDATE_BONUS_ACTIONBAR" or event == "UPDATE_VEHICLE_ACTIONBAR" then
-- Rebuild the slot snapshot so ACTIONBAR_SLOT_CHANGED can detect real changes
wipe(actionSlotSnapshot)
for s = 1, MAX_ACTION_SLOT do
if HasAction(s) then
local aType, id = GetActionInfo(s)
actionSlotSnapshot[s] = aType and (aType .. ":" .. (id or 0)) or nil
end
end
addon:InvalidateAllCaches()
addon:CheckAuras()
addon:CheckItemCooldowns()
addon:CheckSpellCooldowns()
-- DB / CDM / third-party frames may not be fully ready at PLAYER_ENTERING_WORLD.
-- Wipe any glow shown during the racy initial pass so colors are repainted from the
-- (now-valid) DB instead of being frozen by HasProcGlow=true.
C_Timer.After(1, function()
addon:HideAllGlows()
addon:InvalidateAllCaches()
addon:CheckAuras()
addon:CheckItemCooldowns()
addon:CheckSpellCooldowns()
end)
return
end
if event == "ACTIONBAR_SLOT_CHANGED" then
local slot = ...
if slot == 0 then
-- slot 0 means "all slots" – full rebuild
wipe(actionSlotSnapshot)
for s = 1, MAX_ACTION_SLOT do
if HasAction(s) then
local aType, id = GetActionInfo(s)
actionSlotSnapshot[s] = aType and (aType .. ":" .. (id or 0)) or nil
end
end
addon:InvalidateAllCaches()
else
local newKey
if HasAction(slot) then
local aType, id = GetActionInfo(slot)
newKey = aType and (aType .. ":" .. (id or 0)) or nil
end
if actionSlotSnapshot[slot] ~= newKey then
actionSlotSnapshot[slot] = newKey
addon:InvalidateAllCaches()
end
end
return
end
if event == "PLAYER_REGEN_DISABLED" then
-- Entering combat: refresh all checks so glows appear immediately
addon:CheckAuras()
addon:CheckItemCooldowns()
addon:CheckSpellCooldowns()
return
end
if event == "PLAYER_REGEN_ENABLED" then
-- Leaving combat: if combat-only mode, hide all glows
if addon.db and addon.db.profile.combatOnly then
addon:HideAllGlows()
end
return
end
if event == "SPELL_UPDATE_COOLDOWN" then
addon:CheckSpellCooldowns()
return
end
addon:CheckItemCooldowns()
end)
BuffIconCooldownViewer:HookScript("OnEvent", addon.CheckAuras)
-- ─── Replace Blizzard's spell activation alert ───────────────────────────────
-- Secure-hook ShowAlert / HideAlert. When the toggle is on, immediately hide
-- the Blizzard alert frame that Show just created and start our own glow.
if ActionButtonSpellAlertManager and ActionButtonSpellAlertManager.ShowAlert then
local replacedButtons = {}
addon._replacedBlizzardProcButtons = replacedButtons
local function GetBlizzardAlertFrame(self, button)
local alertType = self.activeAlerts and self.activeAlerts[button]
if alertType == self.SpellAlertType.Default then
return button.SpellActivationAlert
elseif alertType == self.SpellAlertType.AssistedCombatRotation then
local acrf = button.AssistedCombatRotationFrame
return acrf and acrf.SpellActivationAlert
end
end
hooksecurefunc(ActionButtonSpellAlertManager, "ShowAlert", function(self, button)
if not button or not addon.db or not addon.db.profile.replaceBlizzardProc then
return
end
local alertFrame = GetBlizzardAlertFrame(self, button)
if alertFrame then
alertFrame:Hide()
end
replacedButtons[button] = true
addon:ShowProcGlow(button, nil, nil, nil, nil, addon.db.profile.blizzardProcGlowType or "Proc Glow")
end)
hooksecurefunc(ActionButtonSpellAlertManager, "HideAlert", function(_, button)
if button and replacedButtons[button] then
replacedButtons[button] = nil
addon:HideProcGlow(button)
end
end)
end
function addon:ClearReplacedBlizzardProcs()
if not addon._replacedBlizzardProcButtons then
return
end
for button in pairs(addon._replacedBlizzardProcButtons) do
addon:HideProcGlow(button)
end
wipe(addon._replacedBlizzardProcButtons)
end