-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcDoc.lua
1205 lines (1036 loc) · 43.4 KB
/
ProcDoc.lua
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
-- ProcDoc.lua
------------------------------------------------------------
-- 0) GLOBALS
------------------------------------------------------------
-- 1) CREATE A FRAME TO INITIALIZE DB
local initFrame = CreateFrame("Frame", "ProcDocDBInitFrame", UIParent)
initFrame:RegisterEvent("ADDON_LOADED")
initFrame:SetScript("OnEvent", function()
local e = event
local a1 = arg1
if e == "ADDON_LOADED" and a1 == "ProcDoc" then
if not ProcDocDB then
ProcDocDB = {}
end
if not ProcDocDB.globalVars then
ProcDocDB.globalVars = {}
end
local gv = ProcDocDB.globalVars
minAlpha = gv.minAlpha or 0.6
maxAlpha = gv.maxAlpha or 1.0
minScale = gv.minScale or 0.8
maxScale = gv.maxScale or 1.0
alphaStep = gv.alphaStep or 0.01
pulseSpeed = gv.pulseSpeed or 1.0
topOffset = gv.topOffset or 150
sideOffset = gv.sideOffset or 150
initFrame:UnregisterEvent("ADDON_LOADED")
end
end)
------------------------------------------------------------
-- 1) MAIN ADDON FRAME
------------------------------------------------------------
local addonName = "ProcDoc"
local ProcDoc = CreateFrame("Frame", "ProcDocAlertFrame", UIParent)
------------------------------------------------------------
-- 2) TABLE OF PROCS
------------------------------------------------------------
local PROC_DATA = {
["WARLOCK"] = {
{
buffName = "Shadow Trance",
texture = "Interface\\Icons\\Spell_Shadow_Twilight",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\WarlockShadowTrance.tga",
},
},
["MAGE"] = {
{
buffName = "Clearcasting",
texture = "Interface\\Icons\\Spell_Shadow_ManaBurn",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\MageClearcasting.tga",
alertStyle = "TOP",
},
{
buffName = "Temporal Convergence",
texture = "Interface\\Icons\\Spell_Nature_StormReach",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\MageTemporalConvergence.tga",
},
{
buffName = "Flash Freeze",
texture = "Interface\\Icons\\Spell_Fire_FrostResistanceTotem",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\MageFlashFreeze.tga",
},
},
["DRUID"] = {
{
buffName = "Clearcasting",
texture = "Interface\\Icons\\Spell_Shadow_ManaBurn",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\DruidClearcasting.tga",
alertStyle = "TOP",
},
{
buffName = "Nature's Grace",
texture = "Interface\\Icons\\Spell_Nature_NaturesBlessing",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\DruidNaturesGrace.tga",
}
},
["SHAMAN"] = {
{
buffName = "Clearcasting",
texture = "Interface\\Icons\\Spell_Shadow_ManaBurn",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\ShamanClearcasting.tga",
alertStyle = "TOP",
},
},
["HUNTER"] = {
{
buffName = "Quick Shots",
texture = "Interface\\Icons\\Ability_Warrior_InnerRage",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\HunterQuickShots.tga",
},
},
["WARRIOR"] = {
{
buffName = "Enrage",
texture = "Interface\\Icons\\Spell_Shadow_UnholyFrenzy",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\WarriorEnrage.tga",
},
},
["PRIEST"] = {
{
buffName = "Resurgence",
texture = "Interface\\Icons\\Spell_Holy_MindVision",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\PriestResurgence.tga",
},
{
buffName = "Enlightened",
texture = "Interface\\Icons\\Spell_Holy_PowerInfusion",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\PriestEnlightened.tga",
alertStyle = "TOP",
},
{
buffName = "Searing Light",
texture = "Interface\\Icons\\Spell_Holy_SearingLightPriest",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\PriestSearingLight.tga",
},
},
["PALADIN"] = {},
["ROGUE"] = {
{
buffName = "Remorseless",
texture = "Interface\\Icons\\Ability_FiegnDead",
alertTexturePath = "Interface\\AddOns\\ProcDoc\\img\\RogueRemorseless.tga",
},
},
}
local ACTION_PROCS = {
["ROGUE"] = {
{
buffName = "Riposte",
texture = "Interface\\Icons\\Ability_Warrior_Challange",
alertTexturePath= "Interface\\AddOns\\ProcDoc\\img\\RogueRiposte.tga",
alertStyle = "SIDES",
spellName = "Riposte"
},
},
["WARRIOR"] = {
{
buffName = "Overpower",
texture = "Interface\\Icons\\Ability_MeleeDamage",
alertTexturePath= "Interface\\AddOns\\ProcDoc\\img\\WarriorOverpower.tga",
alertStyle = "TOP",
spellName = "Overpower"
},
{
buffName = "Execute",
texture = "Interface\\Icons\\inv_sword_48",
alertTexturePath= "Interface\\AddOns\\ProcDoc\\img\\WarriorExecute.tga",
alertStyle = "TOP",
spellName = "Execute"
},
},
["MAGE"] = {
{
buffName = "Arcane Surge",
texture = "Interface\\Icons\\INV_Enchant_EssenceMysticalLarge",
alertTexturePath= "Interface\\AddOns\\ProcDoc\\img\\MageArcaneSurge.tga",
alertStyle = "TOP",
spellName = "Arcane Surge"
},
},
["HUNTER"] = {
{
buffName = "Counterattack",
texture = "Interface\\Icons\\Ability_Warrior_Challange",
alertTexturePath= "Interface\\AddOns\\ProcDoc\\img\\HunterCounterattack.tga",
alertStyle = "TOP",
spellName = "Counterattack"
},
{
buffName = "Mongoose Bite",
texture = "Interface\\Icons\\Ability_Hunter_Swiftstrike",
alertTexturePath= "Interface\\AddOns\\ProcDoc\\img\\HunterMongooseBite.tga",
alertStyle = "TOP",
spellName = "Mongoose Bite"
},
},
["PALADIN"] = {
{
buffName = "Hammer of Wrath",
texture = "Interface\\Icons\\Ability_Thunderclap",
alertTexturePath= "Interface\\AddOns\\ProcDoc\\img\\PaladinHammer.tga",
alertStyle = "SIDES",
spellName = "Hammer of Wrath"
},
},
}
local DEFAULT_ALERT_TEXTURE = "Interface\\AddOns\\ProcDoc\\img\\ProcDocAlert.tga"
----------------------------------------------------------------
-- 3) ALERT FRAME POOL
----------------------------------------------------------------
local alertFrames = {}
local function CreateAlertFrame(style)
local alertObj = {}
alertObj.isActive = false
alertObj.isActionBased = false
alertObj.style = style
alertObj.textures = {}
alertObj.pulseAlpha = minAlpha
alertObj.pulseDir = alphaStep
-- Decide frame size based on style
if style == "TOP" then
alertObj.baseWidth = 256
alertObj.baseHeight = 128
local tex = ProcDoc:CreateTexture(nil, "OVERLAY")
tex:SetPoint("CENTER", UIParent, "CENTER", 0, topOffset)
tex:SetWidth(alertObj.baseWidth)
tex:SetHeight(alertObj.baseHeight)
tex:SetAlpha(0)
tex:Hide()
table.insert(alertObj.textures, tex)
else
alertObj.baseWidth = 128
alertObj.baseHeight = 256
local left = ProcDoc:CreateTexture(nil, "OVERLAY")
left:SetPoint("CENTER", UIParent, "CENTER", -sideOffset, topOffset - 150)
left:SetWidth(alertObj.baseWidth)
left:SetHeight(alertObj.baseHeight)
left:SetAlpha(0)
left:Hide()
local right = ProcDoc:CreateTexture(nil, "OVERLAY")
right:SetPoint("CENTER", UIParent, "CENTER", sideOffset, topOffset - 150)
right:SetWidth(alertObj.baseWidth)
right:SetHeight(alertObj.baseHeight)
right:SetTexCoord(1,0,0,1)
right:SetAlpha(0)
right:Hide()
table.insert(alertObj.textures, left)
table.insert(alertObj.textures, right)
end
return alertObj
end
-- Acquire a frame for either buff-based OR action-based usage
local function AcquireAlertFrame(style, isActionBased)
for _, alertObj in ipairs(alertFrames) do
if (not alertObj.isActive)
and (alertObj.style == style)
and (alertObj.isActionBased == isActionBased)
then
return alertObj
end
end
local newAlert = CreateAlertFrame(style)
newAlert.isActionBased = isActionBased
table.insert(alertFrames, newAlert)
return newAlert
end
----------------------------------------------------------------
-- 4) ONUPDATE PULSE
----------------------------------------------------------------
local function OnUpdateHandler()
if maxAlpha <= minAlpha then
maxAlpha = minAlpha + 0.01
end
if maxScale <= minScale then
maxScale = minScale + 0.01
end
for _, alertObj in ipairs(alertFrames) do
if alertObj.isActive then
alertObj.pulseAlpha = alertObj.pulseAlpha + (alertObj.pulseDir * pulseSpeed)
if alertObj.pulseAlpha < minAlpha then
alertObj.pulseAlpha = minAlpha
alertObj.pulseDir = alphaStep
elseif alertObj.pulseAlpha > maxAlpha then
alertObj.pulseAlpha = maxAlpha
alertObj.pulseDir = -alphaStep
end
local aRange = maxAlpha - minAlpha
local scale = 1.0
if aRange > 0 then
local fraction = (alertObj.pulseAlpha - minAlpha) / aRange
scale = minScale + fraction * (maxScale - minScale)
end
for _, tex in ipairs(alertObj.textures) do
tex:SetAlpha(alertObj.pulseAlpha)
tex:SetWidth(alertObj.baseWidth * scale)
tex:SetHeight(alertObj.baseHeight * scale)
end
end
end
end
ProcDoc:SetScript("OnUpdate", OnUpdateHandler)
ProcDoc:SetWidth(1)
ProcDoc:SetHeight(1)
ProcDoc:SetPoint("CENTER", UIParent, "CENTER")
----------------------------------------------------------------
-- 5) MERGE “BUFF” & “ACTION” PROCS FOR THIS CLASS
----------------------------------------------------------------
local _, playerClass = UnitClass("player")
local normalProcs = PROC_DATA[playerClass] or {}
local actionProcs = ACTION_PROCS[playerClass] or {} -- e.g. Overpower
-- Merge them into one big “classProcs” table
local classProcs = {}
for _, p in ipairs(normalProcs) do
table.insert(classProcs, p)
end
for _, q in ipairs(actionProcs) do
table.insert(classProcs, q)
end
----------------------------------------------------------------
-- 5) BUFF-BASED DETECTION
----------------------------------------------------------------
local function CheckProcs()
-- Hide only the normal (buff-based) frames first
-- i.e. only frames that are `not isActionBased`.
for _, alertObj in ipairs(alertFrames) do
if (not alertObj.isActionBased) then
alertObj.isActive = false
for _, tex in ipairs(alertObj.textures) do
tex:Hide()
end
end
end
local activeBuffProcs = {}
for i = 0, 31 do
local buffTexture = GetPlayerBuffTexture(i)
if buffTexture then
GameTooltip:SetOwner(UIParent, "ANCHOR_NONE")
GameTooltip:SetPlayerBuff(i)
local buffName = (GameTooltipTextLeft1 and GameTooltipTextLeft1:GetText()) or ""
GameTooltip:Hide()
for _, procInfo in ipairs(normalProcs) do
if (buffTexture == procInfo.texture)
and (buffName == procInfo.buffName)
then
table.insert(activeBuffProcs, procInfo)
end
end
end
end
for _, procInfo in ipairs(activeBuffProcs) do
local style = procInfo.alertStyle or "SIDES"
local alertObj = AcquireAlertFrame(style, false)
alertObj.isActive = true
alertObj.pulseAlpha = minAlpha
alertObj.pulseDir = alphaStep
local path = procInfo.alertTexturePath or DEFAULT_ALERT_TEXTURE
for _, tex in ipairs(alertObj.textures) do
tex:SetTexture(path)
tex:Show()
end
end
end
----------------------------------------------------------------
-- 6) ACTION-BASED DETECTION (Multiple)
----------------------------------------------------------------
-- track states per ability
local actionProcStates = {}
local function ShowActionProcAlert(actionProc)
local spellName = actionProc.spellName or "UnknownSpell"
local state = actionProcStates[spellName] or {}
actionProcStates[spellName] = state
local alertObj = state.alertObj
if alertObj and alertObj.isActive then
alertObj.pulseAlpha = minAlpha
alertObj.pulseDir = alphaStep
else
-- Acquire a new alert frame for isActionBased = true
alertObj = AcquireAlertFrame(actionProc.alertStyle or "SIDES", true)
alertObj.isActive = true
alertObj.pulseAlpha = minAlpha
alertObj.pulseDir = alphaStep
local path = actionProc.alertTexturePath or actionProc.texture or DEFAULT_ALERT_TEXTURE
for _, tex in ipairs(alertObj.textures) do
tex:SetTexture(path)
tex:SetAlpha(minAlpha)
tex:SetWidth(alertObj.baseWidth * minScale)
tex:SetHeight(alertObj.baseHeight * minScale)
tex:Show()
end
state.alertObj = alertObj
end
state.isActive = true
end
local function HideActionProcAlert(actionProc)
local spellName = actionProc.spellName or "UnknownSpell"
local state = actionProcStates[spellName]
if not state or not state.isActive then
return
end
local alertObj = state.alertObj
if alertObj and alertObj.isActive then
alertObj.isActive = false
for _, tex in ipairs(alertObj.textures) do
tex:Hide()
end
end
state.isActive = false
end
local function FindActionSlotAndCheck(actionProc)
local spellName = actionProc.spellName or "UnknownSpell"
local texPath = actionProc.texture or ""
if texPath == "" then
return
end
-- find slot
local foundSlot = nil
for slot = 1, 120 do
local actionTex = GetActionTexture(slot)
if actionTex then
local lowerActionTex = string.lower(actionTex)
local lowerWanted = string.lower(texPath)
if lowerActionTex == lowerWanted then
foundSlot = slot
break
end
end
end
local state = actionProcStates[spellName] or {}
actionProcStates[spellName] = state
state.slot = foundSlot
if not foundSlot then
-- if previously active, hide
if state.isActive then
HideActionProcAlert(actionProc)
end
return
end
local usable = IsUsableAction(foundSlot)
if usable then
if not state.isActive then
ShowActionProcAlert(actionProc)
end
else
if state.isActive then
HideActionProcAlert(actionProc)
end
end
end
local function CheckAllActionProcs()
for _, actionProc in ipairs(actionProcs) do
FindActionSlotAndCheck(actionProc)
end
end
local function OnSpellcastSucceeded(arg1, arg2)
print("|cffffff00[DEBUG]|r OnSpellcastSucceeded => "..tostring(arg1).." => "..tostring(arg2))
for _, actionProc in ipairs(actionProcs) do
if arg1 == "player" and (arg2 == actionProc.spellName) then
print("|cffffff00[DEBUG]|r => Hiding after cast for "..arg2)
HideActionProcAlert(actionProc)
end
end
end
------------------------------------------------------------
--7) The event frame for action-based procs
------------------------------------------------------------
-- If your older client needs the old style event usage, do the "global event" trick:
local actionFrame = CreateFrame("Frame", "ProcDocActionFrame", UIParent)
actionFrame:RegisterEvent("PLAYER_LOGIN")
actionFrame:RegisterEvent("ACTIONBAR_UPDATE_USABLE")
actionFrame:RegisterEvent("ACTIONBAR_PAGE_CHANGED")
actionFrame:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
actionFrame:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
actionFrame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
actionFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
actionFrame:SetScript("OnEvent", function()
local e = event
local a1 = arg1
local a2 = arg2
local a3 = arg3
if e == "PLAYER_LOGIN" then
CheckAllActionProcs()
CheckProcs() -- run buff-based as well
elseif e == "ACTIONBAR_PAGE_CHANGED"
or e == "UPDATE_BONUS_ACTIONBAR"
or e == "UPDATE_SHAPESHIFT_FORM"
or e == "PLAYER_TARGET_CHANGED"
or e == "ACTIONBAR_UPDATE_USABLE"
then
CheckAllActionProcs()
elseif e == "UNIT_SPELLCAST_SUCCEEDED" then
-- if we just cast Overpower / Riposte / Arcane Surge, hide them
for _, actionProc in ipairs(actionProcs) do
if a1 == "player" and (a2 == actionProc.spellName) then
HideActionProcAlert(actionProc)
end
end
CheckAllActionProcs()
end
end)
----------------------------------------------------------------
-- 8) AURA FRAME
----------------------------------------------------------------
-- Also old-style event usage if needed:
local auraFrame = CreateFrame("Frame", "ProcDocAuraFrame", UIParent)
auraFrame:RegisterEvent("PLAYER_AURAS_CHANGED")
auraFrame:SetScript("OnEvent", function()
CheckProcs()
end)
DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00ProcDoc|r Loaded. Tracking procs for "..(UnitClass("player"))..". Type |cff00ffff/procdoc|r for options.")
------------------------------------------------------------
-- 9) TEST PROC + OPTIONS FRAME
------------------------------------------------------------
local testProcActive = false
local testProcAlertObj = nil
local testProcAlerts = {}
local function RefreshTestProc()
for buffName, alertObj in pairs(testProcAlerts) do
if alertObj.isActive then
if alertObj.style == "TOP" then
local tex = alertObj.textures[1]
tex:ClearAllPoints()
tex:SetPoint("CENTER", UIParent, "CENTER", 0, topOffset)
else
local left = alertObj.textures[1]
local right= alertObj.textures[2]
left:ClearAllPoints()
left:SetPoint("CENTER", UIParent, "CENTER", -sideOffset, topOffset - 150)
right:ClearAllPoints()
right:SetPoint("CENTER", UIParent, "CENTER", sideOffset, topOffset - 150)
end
end
end
if testProcActive and testProcAlertObj then
-- Update base alpha/scale
if not minAlpha then minAlpha=0.6 end
if not maxAlpha then maxAlpha=1.0 end
if not minScale then minScale=0.8 end
if not maxScale then maxScale=1.0 end
-- Actually move the frames for the test proc
-- Because we only anchored them once at creation.
if testProcAlertObj.style == "TOP" then
-- We only have 1 texture in TOP style
local tex = testProcAlertObj.textures[1]
tex:ClearAllPoints()
tex:SetPoint("CENTER", UIParent, "CENTER", 0, topOffset)
else
-- We have 2 textures for SIDES style
local left = testProcAlertObj.textures[1]
local right = testProcAlertObj.textures[2]
left:ClearAllPoints()
left:SetPoint("CENTER", UIParent, "CENTER", -sideOffset, topOffset - 150)
right:ClearAllPoints()
right:SetPoint("CENTER", UIParent, "CENTER", sideOffset, topOffset - 150)
end
-- Now apply alpha & size
for _, tex in ipairs(testProcAlertObj.textures) do
tex:SetAlpha(minAlpha)
tex:SetWidth(testProcAlertObj.baseWidth * minScale)
tex:SetHeight(testProcAlertObj.baseHeight * minScale)
tex:Show()
end
-- Reset the pulse animation
testProcAlertObj.pulseAlpha = minAlpha
testProcAlertObj.pulseDir = alphaStep
DEFAULT_CHAT_FRAME:AddMessage("|cFF00FFFF[ProcDoc]|r Test proc refreshed with updated offsets.")
end
end
------------------------------------------------------------
-- 10) MULTI-TEST ALERTS
------------------------------------------------------------
local function ShowTestBuffAlert(procInfo)
local style = procInfo.alertStyle or "SIDES"
-- If this buff's alert is already active, reuse it:
local alertObj = testProcAlerts[procInfo.buffName]
if alertObj and alertObj.isActive then
alertObj.pulseAlpha = minAlpha
alertObj.pulseDir = alphaStep
else
-- Otherwise, acquire a new alert frame
alertObj = AcquireAlertFrame(style)
alertObj.isActive = true
alertObj.pulseAlpha = minAlpha
alertObj.pulseDir = alphaStep
-- Assign textures
local alertPath = procInfo.alertTexturePath or DEFAULT_ALERT_TEXTURE
for _, tex in ipairs(alertObj.textures) do
tex:SetTexture(alertPath)
tex:SetAlpha(minAlpha)
tex:SetWidth(alertObj.baseWidth * minScale)
tex:SetHeight(alertObj.baseHeight * minScale)
tex:Show()
end
-- Store it so we can hide/update later
testProcAlerts[procInfo.buffName] = alertObj
end
-- Now **always** re-anchor them using the current topOffset/sideOffset
if style == "TOP" then
local tex = alertObj.textures[1]
tex:ClearAllPoints()
tex:SetPoint("CENTER", UIParent, "CENTER", 0, topOffset)
else
local left = alertObj.textures[1]
local right = alertObj.textures[2]
left:ClearAllPoints()
left:SetPoint("CENTER", UIParent, "CENTER", -sideOffset, topOffset - 150)
right:ClearAllPoints()
right:SetPoint("CENTER", UIParent, "CENTER", sideOffset, topOffset - 150)
end
end
local function HideTestBuffAlert(procInfo)
local alertObj = testProcAlerts[procInfo.buffName]
if alertObj and alertObj.isActive then
alertObj.isActive = false
for _, tex in ipairs(alertObj.textures) do
tex:Hide()
end
testProcAlerts[procInfo.buffName] = nil
end
end
------------------------------------------------------------
-- 11) CREATE OPTIONS UI
------------------------------------------------------------
local function CreateProcDocOptionsFrame()
if not ProcDocOptionsFrame then
local f = CreateFrame("Frame", "ProcDocOptionsFrame", UIParent)
f:SetWidth(340)
f:SetHeight(700)
f:SetPoint("CENTER", UIParent, "CENTER", -360, 0)
f:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = true,
tileSize = 16,
edgeSize = 16,
insets = { left=4, right=4, top=4, bottom=4 },
})
f:SetBackdropColor(0, 0, 0, 0.8)
f:EnableMouse(true)
f:SetMovable(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", function() f:StartMoving() end)
f:SetScript("OnDragStop", function() f:StopMovingOrSizing() end)
-- SECTION FRAME
local sectionFrame = CreateFrame("Frame", nil, f)
sectionFrame:SetPoint("TOPLEFT", f, "TOPLEFT", 15, -30)
sectionFrame:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -15, 245)
sectionFrame:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 8, edgeSize = 16,
insets = { left = 3, right = 3, top = 3, bottom = 3 }
})
sectionFrame:SetBackdropColor(0.2, 0.2, 0.2, 1)
sectionFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
table.insert(UISpecialFrames, "ProcDocOptionsFrame")
-----------------------------------------------------
-- TITLE
-----------------------------------------------------
local titleFrame = CreateFrame("Frame", nil, f)
titleFrame:SetPoint("TOP", f, "TOP", 0, 12)
titleFrame:SetWidth(256)
titleFrame:SetHeight(64)
local titleTex = titleFrame:CreateTexture(nil, "OVERLAY")
titleTex:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
titleTex:SetAllPoints()
local title = titleFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
title:SetText("|cff00ff00[ProcDoc]|r Options")
title:SetPoint("TOP", 0, -14)
-----------------------------------------------------
-- MIN TRANSPARENCY SLIDER
-----------------------------------------------------
local sliderLabel1 = sectionFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
sliderLabel1:SetPoint("TOPLEFT", 10, -10)
sliderLabel1:SetText("Min Transparency:")
local minTransSlider = CreateFrame("Slider", "ProcDocMinTransSlider", f, "OptionsSliderTemplate")
minTransSlider:SetPoint("TOPLEFT", 20, -60)
minTransSlider:SetWidth(300)
minTransSlider:SetMinMaxValues(0, 1)
minTransSlider:SetValueStep(0.05)
minTransSlider:SetValue(minAlpha)
local low1 = getglobal(minTransSlider:GetName().."Low")
local high1 = getglobal(minTransSlider:GetName().."High")
local txt1 = getglobal(minTransSlider:GetName().."Text")
if low1 then low1:SetText("0") end
if high1 then high1:SetText("1") end
if txt1 then txt1:SetText(string.format("%.2f", minAlpha)) end
-- Using older style: no arguments, use `this`
minTransSlider:SetScript("OnValueChanged", function()
local slider = this
local value = slider:GetValue()
if not minAlpha then minAlpha = 0.6 end
if not maxAlpha then maxAlpha = 1.0 end
if value >= maxAlpha then
value = maxAlpha - 0.01
if value < 0 then value = 0 end
end
minAlpha = value
-- SAVE to DB:
if ProcDocDB and ProcDocDB.globalVars then
ProcDocDB.globalVars.minAlpha = minAlpha
end
local localText = getglobal(slider:GetName().."Text")
if localText then
localText:SetText(string.format("%.2f", value))
end
RefreshTestProc()
end)
-----------------------------------------------------
-- MAX TRANSPARENCY SLIDER
-----------------------------------------------------
local sliderLabel2 = sectionFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
sliderLabel2:SetPoint("TOPLEFT", 10, -70)
sliderLabel2:SetText("Max Transparency:")
local maxTransSlider = CreateFrame("Slider", "ProcDocMaxTransSlider", f, "OptionsSliderTemplate")
maxTransSlider:SetPoint("TOPLEFT", 20, -120)
maxTransSlider:SetWidth(300)
maxTransSlider:SetMinMaxValues(0, 1)
maxTransSlider:SetValueStep(0.05)
maxTransSlider:SetValue(maxAlpha)
local low2 = getglobal(maxTransSlider:GetName().."Low")
local high2 = getglobal(maxTransSlider:GetName().."High")
local txt2 = getglobal(maxTransSlider:GetName().."Text")
if low2 then low2:SetText("0") end
if high2 then high2:SetText("1") end
if txt2 then txt2:SetText(string.format("%.2f", maxAlpha)) end
maxTransSlider:SetScript("OnValueChanged", function()
local slider = this
local value = slider:GetValue()
if not minAlpha then minAlpha = 0.6 end
if value <= minAlpha then
value = minAlpha + 0.01
if value > 1 then value = 1 end
end
maxAlpha = value
-- SAVE to DB:
if ProcDocDB and ProcDocDB.globalVars then
ProcDocDB.globalVars.maxAlpha = maxAlpha
end
local localText = getglobal(slider:GetName().."Text")
if localText then
localText:SetText(string.format("%.2f", value))
end
RefreshTestProc()
end)
-----------------------------------------------------
-- MIN SIZE SLIDER
-----------------------------------------------------
local sizeLabel1 = sectionFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
sizeLabel1:SetPoint("TOPLEFT", 10, -130)
sizeLabel1:SetText("Min Size:")
local minSizeSlider = CreateFrame("Slider", "ProcDocMinSizeSlider", f, "OptionsSliderTemplate")
minSizeSlider:SetPoint("TOPLEFT", 20, -180)
minSizeSlider:SetWidth(300)
minSizeSlider:SetMinMaxValues(0.5, 2)
minSizeSlider:SetValueStep(0.05)
minSizeSlider:SetValue(minScale)
local low3 = getglobal(minSizeSlider:GetName().."Low")
local high3 = getglobal(minSizeSlider:GetName().."High")
local txt3 = getglobal(minSizeSlider:GetName().."Text")
if low3 then low3:SetText("0.5") end
if high3 then high3:SetText("2.0") end
if txt3 then txt3:SetText(string.format("%.2f", minScale)) end
minSizeSlider:SetScript("OnValueChanged", function()
local slider = this
local value = slider:GetValue()
if not maxScale then maxScale = 1.0 end
if value >= maxScale then
value = maxScale - 0.01
if value < 0.5 then value = 0.5 end
end
minScale = value
-- SAVE to DB:
if ProcDocDB and ProcDocDB.globalVars then
ProcDocDB.globalVars.minScale = minScale
end
local localText = getglobal(slider:GetName().."Text")
if localText then
localText:SetText(string.format("%.2f", value))
end
RefreshTestProc()
end)
-----------------------------------------------------
-- MAX SIZE SLIDER
-----------------------------------------------------
local sizeLabel2 = sectionFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
sizeLabel2:SetPoint("TOPLEFT", 10, -190)
sizeLabel2:SetText("Max Size:")
local maxSizeSlider = CreateFrame("Slider", "ProcDocMaxSizeSlider", f, "OptionsSliderTemplate")
maxSizeSlider:SetPoint("TOPLEFT", 20, -240)
maxSizeSlider:SetWidth(300)
maxSizeSlider:SetMinMaxValues(0.5, 2)
maxSizeSlider:SetValueStep(0.05)
maxSizeSlider:SetValue(maxScale)
local low4 = getglobal(maxSizeSlider:GetName().."Low")
local high4 = getglobal(maxSizeSlider:GetName().."High")
local txt4 = getglobal(maxSizeSlider:GetName().."Text")
if low4 then low4:SetText("0.5") end
if high4 then high4:SetText("2.0") end
if txt4 then txt4:SetText(string.format("%.2f", maxScale)) end
maxSizeSlider:SetScript("OnValueChanged", function()
local slider = this
local value = slider:GetValue()
if not minScale then minScale = 0.8 end
if value <= minScale then
value = minScale + 0.01
if value > 2 then value = 2 end
end
maxScale = value
-- SAVE to DB:
if ProcDocDB and ProcDocDB.globalVars then
ProcDocDB.globalVars.maxScale = maxScale
end
local localText = getglobal(slider:GetName().."Text")
if localText then
localText:SetText(string.format("%.2f", value))
end
RefreshTestProc()
end)
-----------------------------------------------------
-- Pulse Speed Slider
-----------------------------------------------------
local speedLabel = sectionFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
speedLabel:SetPoint("TOPLEFT", 10, -250)
speedLabel:SetText("Pulse Speed:")
local pulseSpeedSlider = CreateFrame("Slider", "ProcDocPulseSpeedSlider", f, "OptionsSliderTemplate")
pulseSpeedSlider:SetPoint("TOPLEFT", 20, -300)
pulseSpeedSlider:SetWidth(300)
pulseSpeedSlider:SetMinMaxValues(0.1, 5.0)
pulseSpeedSlider:SetValueStep(0.1)
pulseSpeedSlider:SetValue(pulseSpeed)
local lowSpeed = getglobal(pulseSpeedSlider:GetName().."Low")
local highSpeed = getglobal(pulseSpeedSlider:GetName().."High")
local txtSpeed = getglobal(pulseSpeedSlider:GetName().."Text")
if lowSpeed then lowSpeed:SetText("0.1") end
if highSpeed then highSpeed:SetText("5.0") end
if txtSpeed then txtSpeed:SetText(string.format("%.2f", pulseSpeed)) end
pulseSpeedSlider:SetScript("OnValueChanged", function()
local slider = this
local value = slider:GetValue()
pulseSpeed = value -- store globally
-- SAVE to DB:
if ProcDocDB and ProcDocDB.globalVars then
ProcDocDB.globalVars.pulseSpeed = pulseSpeed
end
-- Update label
local labelObj = getglobal(slider:GetName().."Text")
if labelObj then
labelObj:SetText(string.format("%.2f", value))
end
end)
local function ReanchorAllLiveProcs()
for _, alertObj in ipairs(alertFrames) do
if alertObj.isActive and not alertObj.isTest then
if alertObj.style == "TOP" then
local tex = alertObj.textures[1]
tex:ClearAllPoints()
tex:SetPoint("CENTER", UIParent, "CENTER", 0, topOffset)
else
local left = alertObj.textures[1]
local right = alertObj.textures[2]
left:ClearAllPoints()
left:SetPoint("CENTER", UIParent, "CENTER", -sideOffset, topOffset - 150)
right:ClearAllPoints()
right:SetPoint("CENTER", UIParent, "CENTER", sideOffset, topOffset - 150)
end
end
end
end
------------------------------------
-- Top Offset Slider
------------------------------------
local topLabel = sectionFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
topLabel:SetPoint("TOPLEFT", 10, -310)
topLabel:SetText("Top Offset:")
local topOffsetSlider = CreateFrame("Slider", "ProcDocTopOffsetSlider", f, "OptionsSliderTemplate")
topOffsetSlider:SetPoint("TOPLEFT", 20, -360)
topOffsetSlider:SetWidth(300)
topOffsetSlider:SetMinMaxValues(0, 300) -- e.g. range 0 -> 300
topOffsetSlider:SetValueStep(10)
topOffsetSlider:SetValue(topOffset) -- current global