-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClick-To-Cast-Tooltip.lua
More file actions
1095 lines (983 loc) · 40.8 KB
/
Click-To-Cast-Tooltip.lua
File metadata and controls
1095 lines (983 loc) · 40.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
local addonName, addonTable = ...
-- Setup logic for adding lines to the Blizzard tooltip
local blizzardTooltip = CreateFrame("GameTooltip", "BlizzardTooltip", UIParent, "GameTooltipTemplate")
blizzardTooltip:RegisterEvent("MODIFIER_STATE_CHANGED")
-- Setup custom tooltip that will be shown at the mouse
local clickToCastTooltip = CreateFrame("GameTooltip", "ClickToCastTooltip", UIParent, "GameTooltipTemplate, BackdropTemplate")
clickToCastTooltip:SetFrameStrata("TOOLTIP")
clickToCastTooltip:RegisterEvent("MODIFIER_STATE_CHANGED")
local anchorMap = {
[1] = "TOPLEFT",
[2] = "TOP",
[3] = "TOPRIGHT",
[4] = "LEFT",
[5] = "CENTER",
[6] = "RIGHT",
[7] = "BOTTOMLEFT",
[8] = "BOTTOM",
[9] = "BOTTOMRIGHT"
}
local lastHoveredFrame = nil
-- Adds lines to a tooltip based on click bindings and settings.
-- @param db table: Addon settings table
-- @param clickBindings table: List of click binding tables
-- @param tooltip GameTooltip: Tooltip frame to add lines to
-- @param nonBlankLineCount table: Table with .value for counting non-blank lines
-- @return nil
local function updateTooltip(db, clickBindings, tooltip, nonBlankLineCount)
local blizzardBindingsAdded = false
-- Process Blizzard/WoW native bindings if enabled
if db.showBlizzardBindings ~= false then
for _, binding in ipairs(clickBindings) do
local modifier = C_ClickBindings.GetStringFromModifiers(binding.modifiers)
local actionName = tostring(binding.actionID)
if binding.type == Enum.ClickBindingType.Interaction then
if binding.actionID == Enum.ClickBindingInteraction.Target then
actionName = "Target"
elseif binding.actionID == Enum.ClickBindingInteraction.OpenContextMenu then
actionName = "Open Context Menu"
end
elseif binding.type == Enum.ClickBindingType.Spell then
-- Resolve spec-specific overrides so we show the correct spell name (e.g., Holy Shock vs. Crusader Strike)
local overrideID = binding.actionID
if C_SpellBook and C_SpellBook.FindSpellOverrideByID then
overrideID = C_SpellBook.FindSpellOverrideByID(binding.actionID) or binding.actionID
end
if C_Spell and C_Spell.GetSpellInfo then
local spellInfo = C_Spell.GetSpellInfo(overrideID)
actionName = spellInfo and spellInfo.name or actionName
end
if actionName == tostring(binding.actionID) and C_Spell and C_Spell.GetSpellName then
actionName = C_Spell.GetSpellName(overrideID)
end
elseif binding.type == Enum.ClickBindingType.Macro then
actionName = GetMacroInfo(binding.actionID)
end
local buttonColor = CreateColorFromHexString(db.buttonColor)
local actionColor = CreateColorFromHexString(db.actionColor)
local show = false
local isShiftKeyDown = IsShiftKeyDown()
local isAltKeyDown = IsAltKeyDown()
local isControlKeyDown = IsControlKeyDown()
if (isShiftKeyDown and isAltKeyDown and isControlKeyDown) and (modifier == "ALT-SHIFT-CTRL") then show = true
elseif (isShiftKeyDown and isAltKeyDown) and (modifier == "ALT-SHIFT") and not isControlKeyDown then show = true
elseif (isControlKeyDown and isAltKeyDown) and (modifier == "ALT-CTRL") and not isShiftKeyDown then show = true
elseif (isShiftKeyDown and isControlKeyDown) and (modifier == "SHIFT-CTRL") and not isAltKeyDown then show = true
elseif isShiftKeyDown and (modifier == "SHIFT") and not (isAltKeyDown or isControlKeyDown) then show = true
elseif isAltKeyDown and (modifier == "ALT") and not (isShiftKeyDown or isControlKeyDown) then show = true
elseif isControlKeyDown and (modifier == "CTRL") and not (isShiftKeyDown or isAltKeyDown) then show = true
elseif (not isAltKeyDown and not isControlKeyDown and not isShiftKeyDown) and (modifier == "") then show = true
end
if show then
local lineText = buttonColor:WrapTextInColorCode(binding.button) .. " - " .. actionColor:WrapTextInColorCode(actionName)
if lineText:match("%S") then -- contains non-whitespace
nonBlankLineCount.value = nonBlankLineCount.value + 1
tooltip:AddLine(lineText)
blizzardBindingsAdded = true
end
end
end
end
-- Add Clique bindings if available and enabled (mimicking C_ClickBindings workflow)
---@diagnostic disable-next-line: undefined-global
if db.showCliqueBindings ~= false and Clique and Clique.db and Clique.db.profile and Clique.db.profile.bindings then
---@diagnostic disable-next-line: undefined-global
local profile = Clique.db.profile
local cliqueBindings = {}
-- Convert Clique bindings to a format similar to C_ClickBindings
for key, binding in pairs(profile.bindings) do
if binding and binding.sets then
-- Check if binding should be active (similar to modifier key logic)
local shouldShow = false
local inCombat = InCombatLockdown()
for setName, _ in pairs(binding.sets) do
if setName == "default" then
shouldShow = true
elseif setName == "ooc" and not inCombat then
shouldShow = true
elseif setName == "hovercast" then
shouldShow = true
elseif setName == "global" then
shouldShow = true
end
end
if shouldShow then
table.insert(cliqueBindings, {
key = key,
binding = binding
})
end
end
end
-- Process Clique bindings similar to how we process C_ClickBindings
local cliqueBindingsAdded = false
for _, cliqueEntry in ipairs(cliqueBindings) do
local binding = cliqueEntry.binding
local bindingKey = cliqueEntry.key -- This is the array index, not the actual key
-- Extract action name (spell, macro, or action)
local actionName = "Unknown"
if binding.spell then
actionName = binding.spell
elseif binding.macro then
actionName = binding.macro or "Unknown"
elseif binding.action then
actionName = binding.action
elseif binding.type == "target" then
actionName = "Target"
elseif binding.type == "menu" then
actionName = "Open Menu"
end
-- Use the actual key from the binding, not the array index
local buttonText = binding.key
if buttonText and type(buttonText) == "string" then
-- Parse modifier keys from the Clique key string (case insensitive)
local lowerKey = buttonText:lower()
local hasShift = lowerKey:find("shift") ~= nil
local hasCtrl = lowerKey:find("ctrl") ~= nil or lowerKey:find("control") ~= nil
local hasAlt = lowerKey:find("alt") ~= nil
-- Check current modifier state
local isShiftKeyDown = IsShiftKeyDown()
local isAltKeyDown = IsAltKeyDown()
local isControlKeyDown = IsControlKeyDown()
-- Apply same filtering logic as WoW native bindings
local show = false
if (isShiftKeyDown and isAltKeyDown and isControlKeyDown) and (hasShift and hasAlt and hasCtrl) then
show = true
elseif (isShiftKeyDown and isAltKeyDown) and (hasShift and hasAlt and not hasCtrl) and not isControlKeyDown then
show = true
elseif (isControlKeyDown and isAltKeyDown) and (hasAlt and hasCtrl and not hasShift) and not isShiftKeyDown then
show = true
elseif (isShiftKeyDown and isControlKeyDown) and (hasShift and hasCtrl and not hasAlt) and not isAltKeyDown then
show = true
elseif isShiftKeyDown and (hasShift and not hasAlt and not hasCtrl) and not (isAltKeyDown or isControlKeyDown) then
show = true
elseif isAltKeyDown and (hasAlt and not hasShift and not hasCtrl) and not (isShiftKeyDown or isControlKeyDown) then
show = true
elseif isControlKeyDown and (hasCtrl and not hasShift and not hasAlt) and not (isShiftKeyDown or isAltKeyDown) then
show = true
elseif (not isAltKeyDown and not isControlKeyDown and not isShiftKeyDown) and (not hasShift and not hasAlt and not hasCtrl) then
show = true
end
if show then
-- Add separator before first Clique binding if we have both types
if not cliqueBindingsAdded and blizzardBindingsAdded then
local dividerColor = CreateColorFromHexString(db.dividerColor or "ffffffff")
local separatorLine = dividerColor:WrapTextInColorCode("--- Clique ---")
tooltip:AddLine(separatorLine)
nonBlankLineCount.value = nonBlankLineCount.value + 1
end
-- Convert Clique key format to readable format
local displayText = buttonText:gsub("BUTTON1", "Left Click")
displayText = displayText:gsub("BUTTON2", "Right Click")
displayText = displayText:gsub("BUTTON3", "Middle Click")
displayText = displayText:gsub("BUTTON4", "Button4")
displayText = displayText:gsub("BUTTON5", "Button5")
-- Handle modifiers in the key for display
displayText = displayText:gsub("shift%-", "Shift-")
displayText = displayText:gsub("ctrl%-", "Ctrl-")
displayText = displayText:gsub("alt%-", "Alt-")
local buttonColor = CreateColorFromHexString(db.buttonColor)
local actionColor = CreateColorFromHexString(db.actionColor)
local lineText = buttonColor:WrapTextInColorCode(displayText) .. " - " .. actionColor:WrapTextInColorCode(actionName)
if lineText:match("%S") then -- contains non-whitespace
nonBlankLineCount.value = nonBlankLineCount.value + 1
tooltip:AddLine(lineText)
cliqueBindingsAdded = true
end
end
end
end
end
end
-- Initialize ElvUI tooltip styling
local function initializeElvUITooltip()
---@diagnostic disable-next-line: undefined-global
if ElvUI and ElvUI[1] then
---@diagnostic disable-next-line: undefined-global
local E, L, V, P, G = unpack(ElvUI)
local TT = E:GetModule("Tooltip")
TT:SetStyle(clickToCastTooltip)
end
end
local function initializeTukUITooltip()
---@diagnostic disable-next-line: undefined-global
if Tukui then
local T, C, L = unpack(Tukui)
local Tooltip = T["Tooltips"]
Tooltip.Skin(clickToCastTooltip)
end
end
-- Builds and displays the custom tooltip at the mouse cursor.
-- @param frame Frame: The unit frame the mouse is over
local function clickToCastTooltipBuilder(frame)
local db = ClickToCastTooltip and ClickToCastTooltip.db and ClickToCastTooltip.db.global
local specID = GetSpecializationInfo(GetSpecialization())
if not (db and type(db.showCustomTooltip) == "boolean" and db.showCustomTooltip) then
clickToCastTooltip:Hide()
return
end
if specID and db and db["specToggle_" .. specID] == false then
clickToCastTooltip:Hide()
return
end
local clickBindings = C_ClickBindings.GetProfileInfo()
clickToCastTooltip:ClearLines()
clickToCastTooltip:SetOwner(UIParent, "ANCHOR_NONE")
local x, y = GetCursorPosition()
local scale = UIParent:GetEffectiveScale()
local anchor = "BOTTOMRIGHT"
if db and type(db.tooltipAnchor) == "number" then
anchor = anchorMap[db.tooltipAnchor] or "BOTTOMRIGHT"
elseif db and type(db.tooltipAnchor) == "string" then
anchor = db.tooltipAnchor
end
clickToCastTooltip:SetPoint(anchor, UIParent, "BOTTOMLEFT", x / scale, y / scale)
local nonBlankLineCount = {value = 0}
updateTooltip(db, clickBindings, clickToCastTooltip, nonBlankLineCount)
if nonBlankLineCount.value > 0 then
initializeElvUITooltip()
initializeTukUITooltip()
clickToCastTooltip:Show()
clickToCastTooltip:SetScript("OnUpdate", function(self)
local x, y = GetCursorPosition()
local scale = UIParent:GetEffectiveScale()
self:ClearAllPoints()
self:SetPoint(anchor, UIParent, "BOTTOMLEFT", x / scale, y / scale)
self:SetAlpha(db.tooltipTransparency)
end)
else
clickToCastTooltip:Hide()
end
end
-- Builds and displays the Blizzard tooltip with click binding info.
-- @param tooltip GameTooltip: The Blizzard tooltip frame
local function blizzardTooltipBuilder(tooltip)
-- Setup logic for adding lines to the Blizzard tooltip
local db = ClickToCastTooltip and ClickToCastTooltip.db and ClickToCastTooltip.db.global
if (db and db.showTooltip == false) then
return
end
local clickBindings = C_ClickBindings.GetProfileInfo()
local nonBlankLineCount = {value = 0}
if( db and type(db.showNewLineTop) == "boolean" and db.showNewLineTop) then
tooltip:AddLine(" ")
end
if( db and type(db.showHeader) == "boolean" and db.showHeader) then
local dividerColor = CreateColorFromHexString(db.dividerColor)
local headerLine = dividerColor:WrapTextInColorCode("--------------------")
tooltip:AddLine(headerLine)
end
updateTooltip(db, clickBindings, tooltip, nonBlankLineCount)
if( db and type(db.showFooter) == "boolean" and db.showFooter) then
local dividerColor = CreateColorFromHexString(db.dividerColor)
local footerLine = dividerColor:WrapTextInColorCode("--------------------")
tooltip:AddLine(footerLine)
end
if( db and type(db.showNewLineBottom) == "boolean" and db.showNewLineBottom) then
tooltip:AddLine(" ")
end
end
-- Hides and cleans up the custom tooltip.
-- @param frame Frame: The unit frame the mouse is leaving
local function clickToCastTooltipDestroyer(frame)
-- Clear OnUpdate before hiding to prevent recursive Hide calls
clickToCastTooltip:SetScript("OnUpdate", nil)
if clickToCastTooltip:IsShown() then
clickToCastTooltip:Hide()
end
end
-- Add a frame clearing timer to handle rapid frame transitions
local clearFrameTimer = nil
local function scheduleFrameClear(frame)
-- Cancel any existing timer
if clearFrameTimer then
clearFrameTimer:Cancel()
end
-- Schedule a delayed clear to allow for rapid frame transitions
clearFrameTimer = C_Timer.NewTimer(0.1, function()
if lastHoveredFrame == frame then
lastHoveredFrame = nil
end
clearFrameTimer = nil
end)
end
--#region Blizzard Frames
local blizzardFrames = {
"PlayerFrame",
"AlternatePowerBar",
"TargetFrame",
"TargetFrameToT",
"FocusFrame",
"FocusFrameToT",
"PetFrame",
-- "PitBull4_Frames_",
-- "oUF_"
}
local findHealthManaBars= function(frame)
local checked = {}
local healthBar, manaBar, altPower = nil, nil, nil
local recurse
recurse = function(frame)
if type(frame) ~= "table" then return end
if checked[frame] then return end
checked[frame] = true
for key, value in pairs(frame) do
if key == "HealthBar" then
healthBar = value
elseif key == "ManaBar" then
manaBar = value
elseif key == "AlternatePowerBar" then
altPower = value
elseif type(value) == "table" then
recurse(value)
end
end
end
recurse(frame)
return healthBar, manaBar, altPower
end
local hookedFrames = setmetatable({}, {__mode = "k"})
-- Scans all frames and hooks OnEnter/OnLeave for Blizzard unit frames.
local function scanAndHookUnitFrames()
-- Iterate through static Blizzard Frames
for _, frameName in ipairs(blizzardFrames) do
local frame = _G[frameName]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
local h, m, a = findHealthManaBars(frame)
if h then
h:SetPropagateMouseClicks(true)
h:SetPropagateMouseMotion(true)
end
if m then
m:SetPropagateMouseClicks(true)
m:SetPropagateMouseMotion(true)
end
if a then
a:SetPropagateMouseClicks(true)
a:SetPropagateMouseMotion(true)
end
frame:SetPropagateMouseClicks(true)
frame:SetPropagateMouseMotion(true)
hookedFrames[frame] = true
end
end
-- Party Frames
local partyFrame = _G["PartyFrame"]
if partyFrame then
for memberFrame in partyFrame.PartyMemberFramePool:EnumerateActive() do
if memberFrame and memberFrame.HookScript and not hookedFrames[memberFrame] then
memberFrame:HookScript("OnEnter", function(self)
lastHoveredFrame = memberFrame
clickToCastTooltipBuilder(self)
end)
memberFrame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(memberFrame)
end)
hookedFrames[memberFrame] = true
end
end
end
-- Compact Party Frames
for i = 1, 5 do
local frame = _G["CompactPartyFrameMember" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function()
lastHoveredFrame = frame
clickToCastTooltipBuilder(frame)
end)
frame:HookScript("OnLeave", function()
clickToCastTooltipDestroyer(frame)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Boss Frames
for i = 1, 10 do
local frame = _G["Boss" .. i .. "TargetFrame"]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function()
lastHoveredFrame = frame
clickToCastTooltipBuilder(frame)
end)
frame:HookScript("OnLeave", function()
clickToCastTooltipDestroyer(frame)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Compact Raid Frames
for i = 1, 8 do
for j = 1, 40 do
local frame = _G["CompactRaidGroup" .. i .. "Member" .. j]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
-- Enemy Arena Frames
-- I don't know if this will work and have not tested.
for i = 1, 5 do
local frame = _G["ArenaEnemyFrame" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function()
lastHoveredFrame = frame
clickToCastTooltipBuilder(frame)
end)
frame:HookScript("OnLeave", function()
clickToCastTooltipDestroyer(frame)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
--#endregion
--#region ElvUI Frames
-- Hook into explicit ElvUI frames if ElvUI is detected
local elvUIUnitFrames = {
"ElvUF_Player",
"ElvUF_Target",
"ElvUF_TargetTarget",
"ElvUF_TargetTargetTarget",
"ElvUF_Focus",
"ElvUF_FocusTarget",
"ElvUF_Pet",
"ElvUF_PetTarget",
"ElvUF_AssistUnitButton1"
}
-- Scans and hooks OnEnter/OnLeave for ElvUI unit frames if ElvUI is loaded.
local function scanAndHookElvUIUnitFrames()
---@diagnostic disable-next-line: undefined-global
if type(ElvUI) == "table" then
-- Hook specific ElvUI unit frames
for _, frameName in ipairs(elvUIUnitFrames) do
local frame = _G[frameName]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function()
lastHoveredFrame = frame
clickToCastTooltipBuilder(frame)
end)
frame:HookScript("OnLeave", function()
clickToCastTooltipDestroyer(frame)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Party frames
for group = 1, 4 do
for btn = 1, 5 do
local frame = _G["ElvUF_PartyGroup"..group.."UnitButton"..btn]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
-- Raid frames
for raid = 1, 3 do
for group = 1, 8 do
for btn = 1, 5 do
local frame = _G["ElvUF_Raid" .. raid .. "Group"..group.."UnitButton"..btn]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
end
-- Raid pet frames
for i = 1, 9 do
local frame = _G["ElvUF_RaidpetGroup1UnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Arena Frames
for i = 1, 5 do
local frame = _G["ElvUF_Arena" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Boss Frames
for i = 1, 8 do
local frame = _G["ElvUF_Boss" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
end
--#endregion
--#region Cell Frames
local cellFrames = {
"CellSoloFramePet",
"CellSoloFramePlayer"
}
local function scanAndHookCellFrames()
---@diagnostic disable-next-line: undefined-global
if type(Cell) == "table" then
-- Static frame names
for _, frameName in ipairs(cellFrames) do
local frame = _G[frameName]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Arena Pet Frames
for i = 1, 3 do
local frame = _G["CellArenaPet" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- NPC Frames
for i = 1, 8 do
local frame = _G["CellNPCFrameButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Party Frames
for i = 1, 5 do
local frame = _G["CellPartyFrameHeaderUnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Party Pet Frames
for i = 1, 8 do
local frame = _G["CellPartyFrameUnitButton" .. i .. "Pet"]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Pet Frames Separate
for i = 1, 20 do
local frame = _G["CellPetFrameHeaderUnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Quick Assist Frames
for i = 1, 40 do
local frame = _G["CellQuickAssistHeaderUnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Raid0 Frames
for i = 1, 40 do
local frame = _G["CellRaidFrameHeader0UnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Raid Frames
for raid = 1, 8 do
for i = 1, 5 do
local frame = _G["CellRaidFrameHeader" .. raid .. "UnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
-- Cell Spotlight Unit Frames
for i = 1, 15 do
local frame = _G["CellSpotlightFrameUnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
end
local cellUnitFrames = {
"CUF_Player",
"CUF_Focus",
"CUF_Pet",
"CUF_Target",
"CUF_TargetTarget"
}
local function scanAndHookCellUnitFrames()
---@diagnostic disable-next-line: undefined-global
if type(CUF) == "table" then
for _, frameName in ipairs(cellUnitFrames) do
local frame = _G[frameName]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
for i = 1, 10 do
local frame = _G["CUF_Boss" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
end
--#endregion
--#region Grid2 Frames
local function scanAndHookGrid2UnitFrames()
---@diagnostic disable-next-line: undefined-global
for i = 1, 8 do
for j = 1, 5 do
local frame = _G["Grid2LayoutHeader" .. i .. "UnitButton" .. j]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
end
--#endregion
--#region Shadowed Unit Frames
local sUF = {
"SUFUnitplayer",
"SUFUnitpet",
"SUFUnittarget",
"SUFUnittargettarget",
"SUFUnittargettargettarget",
"SUFUnitfocus",
"SUFUnitfocustarget",
"SUFHeadermainassistUnitButton1",
"SUFHeadermaintankUnitButton1"
}
local function scanAndHookShadowedUnitFrames()
---@diagnostic disable-next-line: undefined-global
if type(ShadowedUFDB) == "table" then
for _, frameName in ipairs(sUF) do
local frame = _G[frameName]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Party Frames
for i = 1, 5 do
local frame = _G["SUFHeaderpartyUnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Raid Frames
for i = 1, 40 do
local frame = _G["SUFHeaderraidUnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
end
end
--#endregion
--#region TukUI Frames
local tukUIFrames = {
"TukuiPlayerFrame",
"TukuiTargetFrame",
"TukuiTargetTargetFrame",
"TukuiFocusFrame",
"TukuiFocusTargetFrame",
"TukuiPetFrame"
}
local function scanAndHookTukUIFrames()
if type(T) == "table" or type(Tukui) == "table" then
-- Hook specific TukUI unit frames
for _, frameName in ipairs(tukUIFrames) do
local frame = _G[frameName]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end
-- Hook TukUI party frames
for i = 1, 4 do
local frame = _G["TukuiPartyUnitButton" .. i]
if frame and frame.HookScript and not hookedFrames[frame] then
frame:HookScript("OnEnter", function(self)
lastHoveredFrame = frame
clickToCastTooltipBuilder(self)
end)
frame:HookScript("OnLeave", function(self)
clickToCastTooltipDestroyer(self)
scheduleFrameClear(frame)
end)
hookedFrames[frame] = true
end
end