-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGreyOnCooldown.lua
More file actions
1160 lines (1112 loc) · 43.8 KB
/
GreyOnCooldown.lua
File metadata and controls
1160 lines (1112 loc) · 43.8 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
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- ------------------------------------------------------------ --
-- Addon: GreyOnCooldown --
-- --
-- Version: 2.0.0 --
-- WoW Game Version: 12.0.0 --
-- Author: Millán - Sanguino --
-- --
-- License: GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007 --
-- ------------------------------------------------------------ --
GreyOnCooldown = LibStub("AceAddon-3.0"):NewAddon("GreyOnCooldown", "AceConsole-3.0")
local AceConfig = LibStub("AceConfig-3.0")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local AceDB = LibStub("AceDB-3.0")
local AceDBOptions = LibStub("AceDBOptions-3.0")
GreyOnCooldown.frame = GreyOnCooldown.frame or CreateFrame("Frame", "GreyOnCooldownFrame")
function GreyOnCooldown:OnEvent(event, ...) -- functions created in "object:method"-style have an implicit first parameter of "self", which points to object
GreyOnCooldown[event](GreyOnCooldown, ...) -- route event parameters to GreyOnCooldown:event methods
end
GreyOnCooldown.frame:SetScript("OnEvent", GreyOnCooldown.OnEvent)
local L = LibStub("AceLocale-3.0"):GetLocale("GreyOnCooldown")
local _G = _G
local _
local STANDARD_EPSILON = 0.0001
local type = type
local pairs = pairs
local ipairs = ipairs
local next = next
local InCombatLockdown = InCombatLockdown
local GetActionInfo = GetActionInfo
local GetPetActionInfo = GetPetActionInfo
local GetPetActionSlotUsable = GetPetActionSlotUsable
local GetPetActionCooldown = GetPetActionCooldown
local C_ActionBar_IsUsableAction = C_ActionBar.IsUsableAction
local C_ActionBar_GetActionCooldown = C_ActionBar.GetActionCooldown
local C_ActionBar_GetActionCooldownDuration = C_ActionBar.GetActionCooldownDuration
local C_Item_GetItemCooldown = C_Item.GetItemCooldown
local C_Spell_IsSpellUsable = C_Spell.IsSpellUsable
local C_Spell_GetSpellCooldown = C_Spell.GetSpellCooldown
local C_Spell_GetSpellCooldownDuration = C_Spell.GetSpellCooldownDuration
-- Default settings
GreyOnCooldown.defaults = {
profile = {
enabled = true,
disabledConsoleStatusMessages = false,
disabledAddonCompartmentIntegration = false,
desaturateUnusableActions = true,
desaturatePetActionButtons = true
}
}
-- Global variables
GreyOnCooldown.VERSION = "2.0.0"
GreyOnCooldown.GCD = 1.88
GreyOnCooldown.NUM_ACTIONBAR_BUTTONS = NUM_ACTIONBAR_BUTTONS or 12
GreyOnCooldown.NUM_PET_ACTION_SLOTS = NUM_PET_ACTION_SLOTS or 10
GreyOnCooldown.RelatedActionSpells = {
[372608] = { 372610 },
[372610] = { 372608 },
[403092] = { 372608, 372610 },
[425782] = { 372608, 372610 },
[372606] = { 372608, 372610 }
}
GreyOnCooldown.RegisteredActionSpells = {}
GreyOnCooldown.CheckAddonsWindowTime = 90
GreyOnCooldown.CheckAddonsTickTime = 4
GreyOnCooldown.CheckAddonsTicker = nil
GreyOnCooldown.AddonLABIsPresent = nil
GreyOnCooldown.AddonBT4IsPresent = nil
GreyOnCooldown.AddonDominosIsPresent = nil
GreyOnCooldown.LABButtonsTable = {}
GreyOnCooldown.LABUpdateFuncCache1 = {}
GreyOnCooldown.LABUpdateFuncCache2 = {}
GreyOnCooldown.GOCLoadTimestamp = nil
GreyOnCooldown.ACIaddonData = {
text = "GreyOnCooldown",
icon = "Interface\\Addons\\GreyOnCooldown\\micon",
notCheckable = true,
func = function()
GreyOnCooldown:ShowConfig(GreyOnCooldown.optionsFramesCatId.general)
end
}
-- Sets up a frame and flags to defer protected functions until combat ends
local fclFrame = CreateFrame("Frame")
local delayFunc_GOC_ShowConfig = { false, 0 }
fclFrame:SetScript("OnEvent", function(self, event)
if event=="PLAYER_REGEN_ENABLED" then
fclFrame:UnregisterEvent("PLAYER_REGEN_ENABLED")
if (delayFunc_GOC_ShowConfig[1]) then
delayFunc_GOC_ShowConfig[1] = false
GreyOnCooldown:ShowConfig(delayFunc_GOC_ShowConfig[2])
end
end
end)
-- First function fired
function GreyOnCooldown:OnInitialize()
self.GOCLoadTimestamp = GetTime()
self.db = AceDB:New("GreyOnCooldown_DB", self.defaults, true)
self.optionsTable.args.profiles = AceDBOptions:GetOptionsTable(self.db)
AceConfig:RegisterOptionsTable("GreyOnCooldown", self.optionsTable)
self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig")
self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig")
self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig")
self.optionsFramesCatId = {}
self.optionsFrames = {}
self.optionsFrames.general, self.optionsFramesCatId.general = AceConfigDialog:AddToBlizOptions("GreyOnCooldown", nil, nil, "general")
self.optionsFrames.profiles, self.optionsFramesCatId.profiles = AceConfigDialog:AddToBlizOptions("GreyOnCooldown", L["Profiles"], "GreyOnCooldown", "profiles")
self:RegisterChatCommand("GreyOnCooldown", "SlashCommand")
self:RegisterChatCommand("GOC", "SlashCommand")
if NUM_ACTIONBAR_BUTTONS ~= nil then
GreyOnCooldown.NUM_ACTIONBAR_BUTTONS = NUM_ACTIONBAR_BUTTONS
end
if NUM_PET_ACTION_SLOTS ~= nil then
GreyOnCooldown.NUM_PET_ACTION_SLOTS = NUM_PET_ACTION_SLOTS
end
if (not(self.db.profile.disabledAddonCompartmentIntegration)) then
self:AddonCompartmentIntegration(true)
end
-- Start GreyOnCooldown Core
if (self.db.profile.enabled) then
self:Enable()
self:MainFunction()
else
self:Disable()
end
end
-- Executed after modifying, resetting or changing profiles from the profile configuration menu
function GreyOnCooldown:RefreshConfig()
if (self:IsEnabled()) then
if (not self.db.profile.enabled) then
self:Disable()
ReloadUI()
else
self:Enable()
self:MainFunction()
end
else
if (self.db.profile.enabled) then
self:Enable()
self:MainFunction()
else
self:Disable()
end
end
end
-- Function to control the slash commands
function GreyOnCooldown:SlashCommand(str)
local cmd, arg1 = GreyOnCooldown:GetArgs(str, 2, 1)
cmd = strlower(cmd or "")
arg1 = strlower(arg1 or "")
if (cmd == "enable") or (cmd == "on") then
if (not GreyOnCooldown:IsEnabled()) then
GreyOnCooldown.db.profile.enabled = true
GreyOnCooldown:Enable()
GreyOnCooldown:MainFunction()
end
elseif (cmd == "disable") or (cmd == "off") then
if (GreyOnCooldown:IsEnabled()) then
GreyOnCooldown.db.profile.enabled = false
GreyOnCooldown:Disable()
ReloadUI()
end
elseif (cmd == "disableconsolestatusmessages") or (cmd == "disablecsm") or (cmd == "dcsm") then
local newValue
if (arg1 == "") or (arg1 == "toggle") then
newValue = not(GreyOnCooldown.db.profile.disabledConsoleStatusMessages)
elseif (arg1 == "default") then
newValue = GreyOnCooldown.db.defaults.profile.disabledConsoleStatusMessages
elseif (arg1 == "on") or (arg1 == "enable") or (arg1 == "1") then
newValue = true
elseif (arg1 == "off") or (arg1 == "disable") or (arg1 == "0") or (arg1 == "-1") then
newValue = false
end
if (newValue ~= nil) then
if (GreyOnCooldown.db.profile.disabledConsoleStatusMessages ~= newValue) then
GreyOnCooldown.db.profile.disabledConsoleStatusMessages = newValue
end
if not(GreyOnCooldown.db.profile.disabledConsoleStatusMessages) then
GreyOnCooldown:Print("|cffd2a679" .. L['GreyOnCooldown'] .. '->disabledConsoleStatusMessages = ' .. tostring(GreyOnCooldown.db.profile.disabledConsoleStatusMessages) .. "|r")
end
end
elseif (cmd == "desaturateunusableactions") or (cmd == "desaturateua") or (cmd == "dua") then
local newValue
if (arg1 == "") or (arg1 == "toggle") then
newValue = not(GreyOnCooldown.db.profile.desaturateUnusableActions)
elseif (arg1 == "default") then
newValue = GreyOnCooldown.db.defaults.profile.desaturateUnusableActions
elseif (arg1 == "on") or (arg1 == "enable") or (arg1 == "1") then
newValue = true
elseif (arg1 == "off") or (arg1 == "disable") or (arg1 == "0") or (arg1 == "-1") then
newValue = false
end
if (newValue ~= nil) then
if (GreyOnCooldown.db.profile.desaturateUnusableActions ~= newValue) then
GreyOnCooldown.db.profile.desaturateUnusableActions = newValue
if (GreyOnCooldown:IsEnabled()) then
if (GREYONCOOLDOWN_HOOKED == GreyOnCooldown) then
GreyOnCooldown:UpdateAllActionButtons()
end
end
end
if not(GreyOnCooldown.db.profile.disabledConsoleStatusMessages) then
GreyOnCooldown:Print("|cffd2a679" .. L['GreyOnCooldown'] .. '->desaturateUnusableActions = ' .. tostring(GreyOnCooldown.db.profile.desaturateUnusableActions) .. "|r")
end
end
elseif (cmd == "desaturatepetactionbuttons") or (cmd == "desaturatepab") or (cmd == "dpab") then
local newValue
if (arg1 == "") or (arg1 == "toggle") then
newValue = not(GreyOnCooldown.db.profile.desaturatePetActionButtons)
elseif (arg1 == "default") then
newValue = GreyOnCooldown.db.defaults.profile.desaturatePetActionButtons
elseif (arg1 == "on") or (arg1 == "enable") or (arg1 == "1") then
newValue = true
elseif (arg1 == "off") or (arg1 == "disable") or (arg1 == "0") or (arg1 == "-1") then
newValue = false
end
if (newValue ~= nil) then
if (GreyOnCooldown.db.profile.desaturatePetActionButtons ~= newValue) then
GreyOnCooldown.db.profile.desaturatePetActionButtons = newValue
if (GreyOnCooldown:IsEnabled()) then
if (GREYONCOOLDOWN_HOOKED == GreyOnCooldown) then
GreyOnCooldown:HookGOCPetActionButtons()
if (GreyOnCooldown:CheckAddonBT4()) then
GreyOnCooldown:HookGOCBT4PetActionButtons()
end
end
end
end
if not(GreyOnCooldown.db.profile.disabledConsoleStatusMessages) then
GreyOnCooldown:Print("|cffd2a679" .. L['GreyOnCooldown'] .. '->desaturatePetActionButtons = ' .. tostring(GreyOnCooldown.db.profile.desaturatePetActionButtons) .. "|r")
end
end
elseif (cmd == "profiles") then
GreyOnCooldown:ShowConfig(1)
elseif (cmd == "help") then
GreyOnCooldown:ShowHelp()
else
GreyOnCooldown:ShowConfig()
end
end
-- Function to register/unregister the addon integration in the Blizzard AddonCompartment dropdown menu
function GreyOnCooldown:AddonCompartmentIntegration(registerState)
if (registerState) then
if (AddonCompartmentFrame ~= nil and self.ACIaddonData ~= nil and AddonCompartmentFrame.registeredAddons ~= nil) then
local aciIndex
for k, v in pairs(AddonCompartmentFrame.registeredAddons) do
if (v == self.ACIaddonData) then
aciIndex = k
break
end
end
if not(aciIndex) then
AddonCompartmentFrame:RegisterAddon(self.ACIaddonData)
end
end
else
if (AddonCompartmentFrame ~= nil and self.ACIaddonData ~= nil and AddonCompartmentFrame.registeredAddons ~= nil) then
local aciIndex
for k, v in pairs(AddonCompartmentFrame.registeredAddons) do
if (v == self.ACIaddonData) then
aciIndex = k
break
end
end
if (aciIndex ~= nil) then
table.remove(AddonCompartmentFrame.registeredAddons, aciIndex)
AddonCompartmentFrame:UpdateDisplay()
end
end
end
end
-- Print the help
function GreyOnCooldown:ShowHelp()
GreyOnCooldown:Print('|cffd78900' .. L['GreyOnCooldown'] .. ' v' .. GreyOnCooldown.VERSION .. '|r')
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_HELP_LINE1'] .. "|r")
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_HELP_LINE2'] .. "|r")
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_HELP_LINE3'] .. "|r")
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_HELP_LINE4'] .. "|r")
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_HELP_LINE5'] .. "|r")
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_HELP_LINE6'] .. "|r")
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_HELP_LINE7'] .. "|r")
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_HELP_LINE8'] .. "|r")
end
-- Function loaded when GreyOnCooldown is Enabled
function GreyOnCooldown:OnEnable()
if not(GreyOnCooldown.db.profile.disabledConsoleStatusMessages) then
DEFAULT_CHAT_FRAME:AddMessage('|cffd78900' .. L['GreyOnCooldown'] .. ' v' .. GreyOnCooldown.VERSION .. '|r ' .. L['enabled'])
end
end
-- Function loaded when GreyOnCooldown is Disabled
function GreyOnCooldown:OnDisable()
if not(GreyOnCooldown.db.profile.disabledConsoleStatusMessages) then
DEFAULT_CHAT_FRAME:AddMessage('|cffd78900' .. L['GreyOnCooldown'] .. ' v' .. GreyOnCooldown.VERSION .. '|r ' .. L['disabled'])
end
end
-- Show Options Menu
function GreyOnCooldown:ShowConfig(category)
if InCombatLockdown() then
delayFunc_GOC_ShowConfig[1] = true
delayFunc_GOC_ShowConfig[2] = category
if (not fclFrame:IsEventRegistered("PLAYER_REGEN_ENABLED")) then
fclFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
end
GreyOnCooldown:Print("|cffd2a679" .. L['GREYONCOOLDOWN_OPENPANEL_AFTERCOMBAT'] .. "|r")
return
end
if (category ~= nil) then
if (category == 0) then
Settings.OpenToCategory(self.optionsFramesCatId.general)
elseif (category == 1) then
Settings.OpenToCategory(self.optionsFramesCatId.profiles)
end
else
Settings.OpenToCategory(self.optionsFramesCatId.general)
end
end
-- Function to call the GOCUpdateCheck() for all action buttons
function GreyOnCooldown:UpdateAllActionButtons()
for i = 1, GreyOnCooldown.NUM_ACTIONBAR_BUTTONS do
local actionButton
actionButton = _G["ExtraActionButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
actionButton = _G["ActionButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
actionButton = _G["MultiBarBottomLeftButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
actionButton = _G["MultiBarBottomRightButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
actionButton = _G["MultiBarLeftButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
actionButton = _G["MultiBarRightButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
actionButton = _G["StanceButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
actionButton = _G["PossessButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
actionButton = _G["OverrideActionBarButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
end
for i = 1, 40 do
local actionButton = _G["SpellFlyoutPopupButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
end
if (GreyOnCooldown.db.profile.desaturatePetActionButtons) then
for i = 1, GreyOnCooldown.NUM_PET_ACTION_SLOTS do
local actionButton = _G["PetActionButton"..i]
if (actionButton and actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
end
if (GreyOnCooldown:CheckAddonBT4()) then
local petBarModule = Bartender4 ~= nil and Bartender4.GetModule ~= nil and Bartender4:GetModule("PetBar")
if (petBarModule) then
if (petBarModule.bar and petBarModule.bar.buttons) then
for _, petActionButton in ipairs(petBarModule.bar.buttons) do
if (petActionButton.GOCUpdateCheck) then
petActionButton:GOCUpdateCheck()
end
end
end
end
end
end
if (GreyOnCooldown:CheckAddonLAB()) then
local LibActionButton = LibStub:GetLibrary("LibActionButton-1.0", true)
if LibActionButton then
for actionButton in next, LibActionButton.buttonRegistry do
if (actionButton.GOCUpdateCheck) then
actionButton:GOCUpdateCheck()
end
end
end
end
if (GreyOnCooldown:CheckAddonDominos()) then
if (Dominos ~= nil and Dominos.ActionButtons ~= nil and Dominos.ActionButtons.buttons ~= nil) then
for button in next, Dominos.ActionButtons.buttons do
GreyOnCooldown:HookGOCActionButtonUpdate(button)
end
end
end
end
-- Function to update the RegisteredActionSpells table (ActionButtons)
GreyOnCooldown.UpdateActionButtonAction = function(button)
local action
if GreyOnCooldown:CheckAddonLAB() then
if (button._state_type == "action") then
action = button._state_action
end
else
action = button.action
end
if (action) then
local actionInfoType, actionInfoID, actionInfoSubType = GetActionInfo(action)
if (actionInfoType == "spell" or actionInfoSubType == "spell" or actionInfoSubType == "pet") then
if (actionInfoID ~= button._actionSpellId) then
if (button._actionSpellId and GreyOnCooldown.RegisteredActionSpells[button._actionSpellId]) then
GreyOnCooldown.RegisteredActionSpells[button._actionSpellId][button] = nil
end
if (GreyOnCooldown.RegisteredActionSpells[actionInfoID] == nil) then
GreyOnCooldown.RegisteredActionSpells[actionInfoID] = { }
end
GreyOnCooldown.RegisteredActionSpells[actionInfoID][button] = true
button._actionSpellId = actionInfoID
end
else
if (button._actionSpellId and GreyOnCooldown.RegisteredActionSpells[button._actionSpellId]) then
GreyOnCooldown.RegisteredActionSpells[button._actionSpellId][button] = nil
end
button._actionSpellId = nil
end
else
if (button._actionSpellId and GreyOnCooldown.RegisteredActionSpells[button._actionSpellId]) then
GreyOnCooldown.RegisteredActionSpells[button._actionSpellId][button] = nil
end
button._actionSpellId = nil
end
if (button.GOCUpdateCheck) then
button:GOCUpdateCheck()
end
end
-- Function to update the RegisteredActionSpells table (PetActionButtons)
GreyOnCooldown.UpdatePetActionButtonAction = function(button)
local index = button.index or button.id
if (index) then
local _, _, _, _, _, _, spellID = GetPetActionInfo(index)
if (spellID ~= nil) then
if (spellID ~= button._actionSpellId) then
if (button._actionSpellId and GreyOnCooldown.RegisteredActionSpells[button._actionSpellId]) then
GreyOnCooldown.RegisteredActionSpells[button._actionSpellId][button] = nil
end
if (GreyOnCooldown.RegisteredActionSpells[spellID] == nil) then
GreyOnCooldown.RegisteredActionSpells[spellID] = { }
end
GreyOnCooldown.RegisteredActionSpells[spellID][button] = true
button._actionSpellId = spellID
end
else
if (button._actionSpellId and GreyOnCooldown.RegisteredActionSpells[button._actionSpellId]) then
GreyOnCooldown.RegisteredActionSpells[button._actionSpellId][button] = nil
end
button._actionSpellId = nil
end
else
if (button._actionSpellId and GreyOnCooldown.RegisteredActionSpells[button._actionSpellId]) then
GreyOnCooldown.RegisteredActionSpells[button._actionSpellId][button] = nil
end
button._actionSpellId = nil
end
if (button.GOCUpdateCheck) then
button:GOCUpdateCheck()
end
end
-- Main GOC ActionButton Update function to desaturate the entire action icon when the spell is on cooldown or unusable
GreyOnCooldown.GOCActionButtonUpdateCheck = function(self, isOnGCD)
if not(self.icon) then return end
local duration
local useGCDCurve = false
local action
local spellID
if GreyOnCooldown:CheckAddonLAB() then
if (self._state_type == "action") then
action = self._state_action
elseif (self._state_type == "spell") then
spellID = self._state_action
end
else
action = self.action
spellID = self.spellID
end
if (action) then
if (GreyOnCooldown.db.profile.desaturateUnusableActions) then
local isUsable, notEnoughMana = C_ActionBar_IsUsableAction(action)
if not(isUsable or notEnoughMana) then
self.icon:SetDesaturation(1)
return
end
end
duration = C_ActionBar_GetActionCooldownDuration(action)
if duration:HasSecretValues() then
local actionInfoType, actionInfoID, actionInfoSubType = GetActionInfo(action)
if actionInfoType == "item" then
local _, durationSeconds, enableCooldownTimer = C_Item_GetItemCooldown(actionInfoID)
if (isOnGCD == nil) then
isOnGCD = (enableCooldownTimer and durationSeconds > 0 and durationSeconds <= GreyOnCooldown.GCD) or false
end
if not(isOnGCD) then
duration = durationSeconds
else
duration = nil
end
else
if (isOnGCD == nil) then
local actionCooldownInfo = C_ActionBar_GetActionCooldown(action)
if actionCooldownInfo then
isOnGCD = actionCooldownInfo.isOnGCD or false
if not(isOnGCD) then
if actionInfoType == "macro" and actionInfoSubType=="item" then
useGCDCurve = true
end
end
end
end
if isOnGCD then
duration = nil
end
end
else
if not(isOnGCD) then
local actionCooldownInfo = C_ActionBar_GetActionCooldown(action)
if actionCooldownInfo then
isOnGCD = actionCooldownInfo.isOnGCD or (not(issecretvalue(actionCooldownInfo.activeCategory)) and actionCooldownInfo.activeCategory == 2316) or false
if not(isOnGCD) then
local actionInfoType, _, actionInfoSubType = GetActionInfo(action)
if actionInfoType ~= "spell" and actionInfoSubType~="spell" and actionInfoSubType~="pet" then
isOnGCD = (actionCooldownInfo.isEnabled and duration:GetRemainingDuration() > 0 and duration:GetTotalDuration() <= GreyOnCooldown.GCD) or false
end
end
end
end
if isOnGCD then
duration = nil
end
end
elseif (spellID) then
if (GreyOnCooldown.db.profile.desaturateUnusableActions) then
local isUsable, notEnoughMana = C_Spell_IsSpellUsable(spellID)
if not(isUsable or notEnoughMana) then
self.icon:SetDesaturation(1)
return
end
end
if (isOnGCD == nil) then
local spellCooldownInfo = C_Spell_GetSpellCooldown(spellID)
if spellCooldownInfo then
isOnGCD = spellCooldownInfo.isOnGCD or (not(issecretvalue(spellCooldownInfo.activeCategory)) and spellCooldownInfo.activeCategory == 2316) or false
end
end
if not(isOnGCD) then
duration = C_Spell_GetSpellCooldownDuration(spellID)
end
end
if duration then
if type(duration)=="number" then
if (duration > 0) then
self.icon:SetDesaturation(1)
else
self.icon:SetDesaturation(0)
end
else
if duration:HasSecretValues() then
if not(useGCDCurve) then
self.icon:SetDesaturation(duration:EvaluateRemainingDuration(GreyOnCooldown.DesaturationCurve))
else
self.icon:SetDesaturation(duration:EvaluateRemainingDuration(GreyOnCooldown.DesaturationCurveGCD))
end
else
if (duration:GetRemainingDuration() > 0) then
self.icon:SetDesaturation(1)
else
self.icon:SetDesaturation(0)
end
end
end
else
self.icon:SetDesaturation(0)
end
end
-- Main GOC PetActionButton Update function to desaturate the entire action icon when the spell is on cooldown or unusable
GreyOnCooldown.GOCPetActionButtonUpdateCheck = function(self)
local index = self.index or self.id
if not(self.icon and index and GetPetActionInfo(index)) then return end
if (GreyOnCooldown.db.profile.desaturatePetActionButtons) then
if (GreyOnCooldown.db.profile.desaturateUnusableActions) then
if not(GetPetActionSlotUsable(index)) then
self.icon:SetDesaturation(1)
return
end
end
local _, duration, enable = GetPetActionCooldown(index)
if (enable and duration and duration > 0 and duration > GreyOnCooldown.GCD) then
self.icon:SetDesaturation(1)
else
self.icon:SetDesaturation(0)
end
else
self.icon:SetDesaturation(0)
end
end
-- Hook function to update the ActionButton (self)
GreyOnCooldown.ButtonUpdateHookFunc = function(self)
if (self.GOCUpdateCheck) then
self:GOCUpdateCheck()
end
end
-- Hook function to update the ActionButton (self:GetParent())
GreyOnCooldown.ButtonParentUpdateHookFunc = function(self)
if (self:GetParent().GOCUpdateCheck) then
self:GetParent():GOCUpdateCheck()
end
end
-- Function that establishes the needed GOC hooks for an ActionButton
function GreyOnCooldown:HookGOCActionButtonUpdate(button)
-- Establish the main GOC ActionButton Update function
if (GREYONCOOLDOWN_UPDATECHECK_SET_AB == nil) then
GREYONCOOLDOWN_UPDATECHECK_SET_AB = {}
end
if not(GREYONCOOLDOWN_UPDATECHECK_SET_AB[button]) then
button.GOCUpdateCheck = ActionButton_GreyOnCooldown_UpdateCheck
GREYONCOOLDOWN_UPDATECHECK_SET_AB[button] = true
end
-- ActionButton essentials GOC hooks (AB hooks: OnCooldownDone, OnShow, OnHide, Update, UpdateUsable)
if button.cooldown then
if (GREYONCOOLDOWN_ONCOOLDOWNDONE_HOOKED_ABC == nil) then
GREYONCOOLDOWN_ONCOOLDOWNDONE_HOOKED_ABC = {}
end
if not(GREYONCOOLDOWN_ONCOOLDOWNDONE_HOOKED_ABC[button]) then
button.cooldown:HookScript("OnCooldownDone", GreyOnCooldown.ButtonParentUpdateHookFunc)
GREYONCOOLDOWN_ONCOOLDOWNDONE_HOOKED_ABC[button] = true
end
if (GREYONCOOLDOWN_ONSHOW_HOOKED_ABC == nil) then
GREYONCOOLDOWN_ONSHOW_HOOKED_ABC = {}
end
if not(GREYONCOOLDOWN_ONSHOW_HOOKED_ABC[button]) then
button.cooldown:HookScript("OnShow", GreyOnCooldown.ButtonParentUpdateHookFunc)
GREYONCOOLDOWN_ONSHOW_HOOKED_ABC[button] = true
end
if (GREYONCOOLDOWN_ONHIDE_HOOKED_ABC == nil) then
GREYONCOOLDOWN_ONHIDE_HOOKED_ABC = {}
end
if not(GREYONCOOLDOWN_ONHIDE_HOOKED_ABC[button]) then
button.cooldown:HookScript("OnHide", GreyOnCooldown.ButtonParentUpdateHookFunc)
GREYONCOOLDOWN_ONHIDE_HOOKED_ABC[button] = true
end
end
if type(button.Update)=="function" then
if (GREYONCOOLDOWN_UPDATE_HOOKED_AB == nil) then
GREYONCOOLDOWN_UPDATE_HOOKED_AB = {}
end
if not(GREYONCOOLDOWN_UPDATE_HOOKED_AB[button]) then
hooksecurefunc(button, "Update", GreyOnCooldown.ButtonUpdateHookFunc)
GREYONCOOLDOWN_UPDATE_HOOKED_AB[button] = true
end
end
if type(button.UpdateUsable)=="function" then
if (GREYONCOOLDOWN_UPDATEUSABLE_HOOKED_AB == nil) then
GREYONCOOLDOWN_UPDATEUSABLE_HOOKED_AB = {}
end
if not(GREYONCOOLDOWN_UPDATEUSABLE_HOOKED_AB[button]) then
hooksecurefunc(button, "UpdateUsable", GreyOnCooldown.ButtonUpdateHookFunc)
GREYONCOOLDOWN_UPDATEUSABLE_HOOKED_AB[button] = true
end
end
-- ActionButton GOC hooks to update the RegisteredActionSpells when needed (AB hooks: UpdateAction)
if type(button.UpdateAction) == "function" then
if (GREYONCOOLDOWN_UPDATEACTION_HOOKED_AB == nil) then
GREYONCOOLDOWN_UPDATEACTION_HOOKED_AB = {}
end
if not(GREYONCOOLDOWN_UPDATEACTION_HOOKED_AB[button]) then
hooksecurefunc(button, "UpdateAction", GreyOnCooldown.UpdateActionButtonAction)
GREYONCOOLDOWN_UPDATEACTION_HOOKED_AB[button] = true
end
end
GreyOnCooldown.UpdateActionButtonAction(button)
end
-- Function that establishes the needed GOC hooks for an PetActionButton
function GreyOnCooldown:HookGOCPetActionButtonUpdate(button)
-- Establish the main GOC PetActionButton Update function
if (GREYONCOOLDOWN_UPDATECHECK_SET_AB == nil) then
GREYONCOOLDOWN_UPDATECHECK_SET_AB = {}
end
if not(GREYONCOOLDOWN_UPDATECHECK_SET_AB[button]) then
button.GOCUpdateCheck = PetActionButton_GreyOnCooldown_UpdateCheck
GREYONCOOLDOWN_UPDATECHECK_SET_AB[button] = true
end
-- PetActionButton essentials GOC hooks (AB hooks: OnCooldownDone, OnShow, OnHide, Update, UpdateCooldowns)
if button.cooldown then
if (GREYONCOOLDOWN_ONCOOLDOWNDONE_HOOKED_ABC == nil) then
GREYONCOOLDOWN_ONCOOLDOWNDONE_HOOKED_ABC = {}
end
if not(GREYONCOOLDOWN_ONCOOLDOWNDONE_HOOKED_ABC[button]) then
button.cooldown:HookScript("OnCooldownDone", GreyOnCooldown.ButtonParentUpdateHookFunc)
GREYONCOOLDOWN_ONCOOLDOWNDONE_HOOKED_ABC[button] = true
end
if (GREYONCOOLDOWN_ONSHOW_HOOKED_ABC == nil) then
GREYONCOOLDOWN_ONSHOW_HOOKED_ABC = {}
end
if not(GREYONCOOLDOWN_ONSHOW_HOOKED_ABC[button]) then
button.cooldown:HookScript("OnShow", GreyOnCooldown.ButtonParentUpdateHookFunc)
GREYONCOOLDOWN_ONSHOW_HOOKED_ABC[button] = true
end
if (GREYONCOOLDOWN_ONHIDE_HOOKED_ABC == nil) then
GREYONCOOLDOWN_ONHIDE_HOOKED_ABC = {}
end
if not(GREYONCOOLDOWN_ONHIDE_HOOKED_ABC[button]) then
button.cooldown:HookScript("OnHide", GreyOnCooldown.ButtonParentUpdateHookFunc)
GREYONCOOLDOWN_ONHIDE_HOOKED_ABC[button] = true
end
end
if type(button.Update)=="function" then
if (GREYONCOOLDOWN_UPDATE_HOOKED_AB == nil) then
GREYONCOOLDOWN_UPDATE_HOOKED_AB = {}
end
if not(GREYONCOOLDOWN_UPDATE_HOOKED_AB[button]) then
hooksecurefunc(button, "Update", GreyOnCooldown.ButtonUpdateHookFunc)
GREYONCOOLDOWN_UPDATE_HOOKED_AB[button] = true
end
end
if not(GREYONCOOLDOWN_UPDATECOOLDOWNS_HOOKED_PAB) then
if (PetActionBar ~= nil and type(PetActionBar.UpdateCooldowns) == "function") then
hooksecurefunc(PetActionBar, "UpdateCooldowns", function(self)
for i = 1, GreyOnCooldown.NUM_PET_ACTION_SLOTS do
local button = self.actionButtons[i]
if button then
GreyOnCooldown.UpdatePetActionButtonAction(button)
end
end
end)
end
GREYONCOOLDOWN_UPDATECOOLDOWNS_HOOKED_PAB = true
end
GreyOnCooldown.UpdatePetActionButtonAction(button)
end
-- Function to handle the SPELL_UPDATE_COOLDOWN event
function GreyOnCooldown:SPELL_UPDATE_COOLDOWN(spellID, baseSpellID, category, startRecoveryCategory)
if (spellID == nil) then
spellID = baseSpellID
if (spellID == nil) then
return
end
end
local spellCooldownInfo = C_Spell_GetSpellCooldown(spellID)
if (spellCooldownInfo) then
if (GreyOnCooldown.RegisteredActionSpells[spellID]) then
for k, _ in pairs(GreyOnCooldown.RegisteredActionSpells[spellID]) do
if (k.GOCUpdateCheck) then
k:GOCUpdateCheck(spellCooldownInfo.isOnGCD or false)
end
end
end
end
if (GreyOnCooldown.RelatedActionSpells[spellID] ~= nil) then
for _, relatedSpellID in pairs(GreyOnCooldown.RelatedActionSpells[spellID]) do
spellCooldownInfo = C_Spell_GetSpellCooldown(relatedSpellID)
if (spellCooldownInfo) then
if (GreyOnCooldown.RegisteredActionSpells[relatedSpellID]) then
for k, _ in pairs(GreyOnCooldown.RegisteredActionSpells[relatedSpellID]) do
if (k.GOCUpdateCheck) then
k:GOCUpdateCheck(spellCooldownInfo.isOnGCD or false)
end
end
end
end
end
end
end
-- Function to set hooks for SpellFlyout frame to detect the newly created SpellFlyoutButtons
function GreyOnCooldown:HookGOCSpellFlyout()
if not(GREYONCOOLDOWN_SPELLFLYOUT_HOOKED) then
hooksecurefunc(SpellFlyout, "Toggle", function(self, flyoutButton, flyoutID, isActionBar, specID, showFullTooltip, reason)
if (not(self:IsShown()) and self.glyphActivating) then
return
end
if (not(self:IsShown()) and self.flyoutButton == nil) then
return
end
local offSpec = specID and (specID ~= 0)
local _, _, numSlots, isKnown = GetFlyoutInfo(flyoutID)
if ((not isKnown and not offSpec) or numSlots == 0) then
return
end
local numButtons = 0
for i = 1, numSlots do
local spellID, _, isKnownSlot, _, slotSpecID = GetFlyoutSlotInfo(flyoutID, i)
local visible = true
local petIndex, petName = GetCallPetSpellInfo(spellID)
if (isActionBar and petIndex and (not petName or petName == "")) then
visible = false
end
if (((not offSpec or slotSpecID == 0) and visible and isKnownSlot) or (offSpec and slotSpecID == specID)) then
local button = _G["SpellFlyoutPopupButton"..numButtons+1]
if (button ~= nil) then
GreyOnCooldown:HookGOCActionButtonUpdate(button)
end
numButtons = numButtons+1
end
end
end)
GREYONCOOLDOWN_SPELLFLYOUT_HOOKED = true
end
end
-- Function to iterate through ActionButtons and hook them
function GreyOnCooldown:HookGOCActionButtons()
for i = 1, GreyOnCooldown.NUM_ACTIONBAR_BUTTONS do
local actionButton
actionButton = _G["ExtraActionButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
actionButton = _G["ActionButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
actionButton = _G["MultiBarBottomLeftButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
actionButton = _G["MultiBarBottomRightButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
actionButton = _G["MultiBarLeftButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
actionButton = _G["MultiBarRightButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
actionButton = _G["StanceButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
actionButton = _G["PossessButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
actionButton = _G["OverrideActionBarButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
end
for i = 1, 40 do
local actionButton = _G["SpellFlyoutPopupButton"..i]
if (actionButton) then
GreyOnCooldown:HookGOCActionButtonUpdate(actionButton)
end
end
-- SpellFlyoutButtons are created dynamically as needed. This needs to be monitored to apply GOC hooks to new ones.
GreyOnCooldown:HookGOCSpellFlyout()
if not(GREYONCOOLDOWN_ACTIONBUTTON_UPDATECOOLDOWN_HOOKED) then
hooksecurefunc("ActionButton_UpdateCooldown", GreyOnCooldown.ButtonUpdateHookFunc)
GREYONCOOLDOWN_ACTIONBUTTON_UPDATECOOLDOWN_HOOKED = true
end
if not(GREYONCOOLDOWN_MULTICASTSPELLBUTTON_UPDATECOOLDOWN_HOOKED) then
hooksecurefunc("MultiCastSpellButton_UpdateCooldown", GreyOnCooldown.ButtonUpdateHookFunc)
GREYONCOOLDOWN_MULTICASTSPELLBUTTON_UPDATECOOLDOWN_HOOKED = true
end
end
-- Function to iterate through PetActionButtons and hook them
function GreyOnCooldown:HookGOCPetActionButtons()
for i = 1, GreyOnCooldown.NUM_PET_ACTION_SLOTS do
local petActionButton = _G["PetActionButton"..i]
if (petActionButton) then
GreyOnCooldown:HookGOCPetActionButtonUpdate(petActionButton)
end
end
end
-- GreyOnCooldown MainFunction
function GreyOnCooldown:MainFunction()
-- Main desaturation Curve that distinguishes between zero and a non-zero value
GreyOnCooldown.DesaturationCurve = C_CurveUtil.CreateCurve()
GreyOnCooldown.DesaturationCurve:SetType(Enum.LuaCurveType.Step)
GreyOnCooldown.DesaturationCurve:AddPoint(0, 0)
GreyOnCooldown.DesaturationCurve:AddPoint(0.001, 1)
-- Alternative desaturation Curve that establishes the GCD duration as the step-point (for cases where isOnGCD is not available/reliable)
GreyOnCooldown.DesaturationCurveGCD = C_CurveUtil.CreateCurve()
GreyOnCooldown.DesaturationCurveGCD:SetType(Enum.LuaCurveType.Step)
GreyOnCooldown.DesaturationCurveGCD:AddPoint(0, 0)
GreyOnCooldown.DesaturationCurveGCD:AddPoint(GreyOnCooldown.GCD, 1)
-- Set ActionButton hooks to desaturate the entire action icon when the spell is on cooldown or unusable
if not(GREYONCOOLDOWN_HOOKED) then
ActionButton_GreyOnCooldown_UpdateCheck = GreyOnCooldown.GOCActionButtonUpdateCheck
PetActionButton_GreyOnCooldown_UpdateCheck = GreyOnCooldown.GOCPetActionButtonUpdateCheck
-- Register the SPELL_UPDATE_COOLDOWN event to update the AB (isOnGCD is updated at this event)
if not(GreyOnCooldown.frame:IsEventRegistered("SPELL_UPDATE_COOLDOWN")) then
GreyOnCooldown.frame:RegisterEvent("SPELL_UPDATE_COOLDOWN")
end
-- Main ActionButtons
GreyOnCooldown:HookGOCActionButtons()
-- Handle PetActionButtons
if (GreyOnCooldown.db.profile.desaturatePetActionButtons) then
GreyOnCooldown:HookGOCPetActionButtons()
end
-- Check for the presence of addons (LAB, BT4 and Dominos)
GreyOnCooldown:CheckAddonLAB()
GreyOnCooldown:CheckAddonBT4()
GreyOnCooldown:CheckAddonDominos()
-- Create a ticker to periodically check for the presence of addons
if (GreyOnCooldown.AddonLABIsPresent == nil or GreyOnCooldown.AddonBT4IsPresent == nil or GreyOnCooldown.AddonDominosIsPresent == nil) then
GreyOnCooldown.CheckAddonsTicker = C_Timer.NewTicker(GreyOnCooldown.CheckAddonsTickTime, function()
GreyOnCooldown:CheckAddonLAB()
GreyOnCooldown:CheckAddonBT4()
GreyOnCooldown:CheckAddonDominos()
if (GreyOnCooldown.AddonLABIsPresent ~= nil and GreyOnCooldown.AddonBT4IsPresent ~= nil and GreyOnCooldown.AddonDominosIsPresent ~= nil) then
GreyOnCooldown.CheckAddonsTicker:Cancel()
GreyOnCooldown.CheckAddonsTicker = nil
end
end, math.floor(GreyOnCooldown.CheckAddonsWindowTime/GreyOnCooldown.CheckAddonsTickTime)+1)
end
GREYONCOOLDOWN_HOOKED = GreyOnCooldown or true
end
end
-- Hook function to update the LAB ActionButton (self)
GreyOnCooldown.LABButtonUpdateHookFunc = function(self)
local func = GreyOnCooldown.LABUpdateFuncCache1[self]
if not func then
func = function() self:GOCUpdateCheck() end
GreyOnCooldown.LABUpdateFuncCache1[self] = func
end
C_Timer.After(0.01, func)
end
-- Hook function to update the LAB ActionButton (self:GetParent())
GreyOnCooldown.LABButtonParentUpdateHookFunc = function(self)
local func = GreyOnCooldown.LABUpdateFuncCache2[self]
if not func then
func = function() self:GetParent():GOCUpdateCheck() end
GreyOnCooldown.LABUpdateFuncCache2[self] = func
end
C_Timer.After(0.01, func)
end
-- Function to set the hooks for a new LAB ActionButton
function GreyOnCooldown:HookGOCLABActionButtonUpdate(button)
if ((button ~= nil) and not(self.LABButtonsTable[button])) then
if (not button.GREYONCOOLDOWN_LAB_HOOKED) then
self.LABButtonsTable[button] = true
self:HookGOCActionButtonUpdate(button)
-- Hook 'GetPassiveCooldownSpellID' (LABButton) function because we can't hook the local 'UpdateCooldown' (LABButton) function
hooksecurefunc(button, "GetPassiveCooldownSpellID", GreyOnCooldown.LABButtonUpdateHookFunc)
-- Hook 'icon.SetVertexColor' (LABButton) function because we can't hook the local 'UpdateUsable' (LABButton) function
hooksecurefunc(button.icon, "SetVertexColor", GreyOnCooldown.LABButtonParentUpdateHookFunc)
button.GREYONCOOLDOWN_LAB_HOOKED = true
end
end
end
-- Function to fast-check if some LibActionButtons-1.0 addon is present
function GreyOnCooldown:CheckAddonLAB()
if (self.AddonLABIsPresent == false) then
return false