forked from Hekili/hekili
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UI.lua
3134 lines (2529 loc) · 126 KB
/
UI.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
-- UI.lua
-- Dynamic UI Elements
local addon, ns = ...
local Hekili = _G[addon]
local class = Hekili.Class
local state = Hekili.State
local FindUnitBuffByID, FindUnitDebuffByID = ns.FindUnitBuffByID, ns.FindUnitDebuffByID
-- Atlas/Textures
local AddTexString, GetTexString, AtlasToString, GetAtlasFile, GetAtlasCoords = ns.AddTexString, ns.GetTexString, ns.AtlasToString, ns.GetAtlasFile, ns.GetAtlasCoords
local frameStratas = ns.FrameStratas
local getInverseDirection = ns.getInverseDirection
local multiUnpack = ns.multiUnpack
local orderedPairs = ns.orderedPairs
local round = ns.round
local IsCurrentItem = C_Item.IsCurrentItem
local IsUsableItem = C_Item.IsUsableItem
local IsCurrentSpell = C_Spell.IsCurrentSpell
local GetItemCooldown = C_Item.GetItemCooldown
local GetItemInfoInstant = C_Item.GetItemInfoInstant
local GetSpellTexture = C_Spell.GetSpellTexture
local IsUsableSpell = C_Spell.IsSpellUsable
local GetSpellCooldown = function(spellID)
local spellCooldownInfo = C_Spell.GetSpellCooldown(spellID)
if spellCooldownInfo then
return spellCooldownInfo.startTime, spellCooldownInfo.duration, spellCooldownInfo.isEnabled, spellCooldownInfo.modRate
end
return 0, 0, false, 0
end
local floor, format, insert = math.floor, string.format, table.insert
local HasVehicleActionBar, HasOverrideActionBar, IsInPetBattle, UnitHasVehicleUI, UnitOnTaxi = HasVehicleActionBar, HasOverrideActionBar, C_PetBattles.IsInBattle, UnitHasVehicleUI, UnitOnTaxi
local Tooltip = ns.Tooltip
local Masque, MasqueGroup
local _
function Hekili:GetScale()
return PixelUtil.GetNearestPixelSize( 1, PixelUtil.GetPixelToUIUnitFactor(), 1 )
--[[ local monitorIndex = (tonumber(GetCVar("gxMonitor")) or 0) + 1
local resolutions = {GetScreenResolutions()}
local resolution = resolutions[GetCurrentResolution()] or GetCVar("gxWindowedResolution")
return (GetCVar("UseUIScale") == "1" and (GetScreenHeight() / resolution:match("%d+x(%d+)")) or 1) ]]
end
local movementData = {}
local function startScreenMovement(frame)
movementData.origX, movementData.origY = select( 4, frame:GetPoint() )
frame:StartMoving()
movementData.fromX, movementData.fromY = select( 4, frame:GetPoint() )
frame.Moving = true
end
local function stopScreenMovement(frame)
local resolution = C_VideoOptions.GetCurrentGameWindowSize()
local scrW, scrH = resolution.x, resolution.y
local scale, pScale = Hekili:GetScale(), UIParent:GetScale()
scrW = scrW / ( scale * pScale )
scrH = scrH / ( scale * pScale )
local limitX = (scrW - frame:GetWidth() ) / 2
local limitY = (scrH - frame:GetHeight()) / 2
movementData.toX, movementData.toY = select( 4, frame:GetPoint() )
frame:StopMovingOrSizing()
frame.Moving = false
frame:ClearAllPoints()
frame:SetPoint( "CENTER", nil, "CENTER",
max(-limitX, min(limitX, movementData.origX + (movementData.toX - movementData.fromX))),
max(-limitY, min(limitY, movementData.origY + (movementData.toY - movementData.fromY))) )
Hekili:SaveCoordinates()
end
local function Mover_OnMouseUp(self, btn)
local obj = self.moveObj or self
if (btn == "LeftButton" and obj.Moving) then
stopScreenMovement(obj)
Hekili:SaveCoordinates()
elseif btn == "RightButton" then
if obj:GetName() == "HekiliNotification" then
LibStub( "AceConfigDialog-3.0" ):SelectGroup( "Hekili", "displays", "nPanel" )
return
elseif obj and obj.id then
LibStub( "AceConfigDialog-3.0" ):SelectGroup( "Hekili", "displays", obj.id )
return
end
end
end
local function Mover_OnMouseDown( self, btn )
local obj = self.moveObj or self
if Hekili.Config and btn == "LeftButton" and not obj.Moving then
startScreenMovement(obj)
end
end
local function Button_OnMouseUp( self, btn )
local display = self.display
local mover = _G[ "HekiliDisplay" .. display ]
if (btn == "LeftButton" and mover.Moving) then
stopScreenMovement(mover)
elseif (btn == "RightButton") then
if mover.Moving then
stopScreenMovement(mover)
end
local mouseInteract = Hekili.Pause or Hekili.Config
for i = 1, #ns.UI.Buttons do
for j = 1, #ns.UI.Buttons[i] do
ns.UI.Buttons[i][j]:EnableMouse(mouseInteract)
end
end
ns.UI.Notification:EnableMouse( Hekili.Config )
-- Hekili:SetOption( { "locked" }, true )
GameTooltip:Hide()
end
Hekili:SaveCoordinates()
end
local function Button_OnMouseDown(self, btn)
local display = self.display
local mover = _G[ "HekiliDisplay" .. display ]
if Hekili.Config and btn == "LeftButton" and not mover.Moving then
startScreenMovement(mover)
end
end
function ns.StartConfiguration( external )
Hekili.Config = true
local scaleFactor = Hekili:GetScale()
local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
-- Notification Panel
ns.UI.Notification.Mover = ns.UI.Notification.Mover or CreateFrame( "Frame", "HekiliNotificationMover", ns.UI.Notification, "BackdropTemplate" )
ns.UI.Notification.Mover:SetAllPoints(HekiliNotification)
ns.UI.Notification.Mover:SetBackdrop( {
bgFile = "Interface/Buttons/WHITE8X8",
edgeFile = "Interface/Buttons/WHITE8X8",
tile = false,
tileSize = 0,
edgeSize = 1,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
} )
ns.UI.Notification.Mover:SetBackdropColor( 0, 0, 0, .8 )
ns.UI.Notification.Mover:SetBackdropBorderColor( ccolor.r, ccolor.g, ccolor.b, 1 )
ns.UI.Notification.Mover:Show()
local f = ns.UI.Notification.Mover
if not f.Header then
f.Header = f:CreateFontString( "HekiliNotificationHeader", "OVERLAY", "GameFontNormal" )
local path = f.Header:GetFont()
f.Header:SetFont( path, 18, "OUTLINE" )
end
f.Header:SetAllPoints( HekiliNotificationMover )
f.Header:SetText( "Notifications" )
f.Header:SetJustifyH( "CENTER" )
f.Header:Show()
if HekiliNotificationMover:GetFrameLevel() > HekiliNotification:GetFrameLevel() then
local orig = HekiliNotificationMover:GetFrameLevel()
HekiliNotification:SetFrameLevel(orig)
HekiliNotificationMover:SetFrameLevel(orig-1)
end
ns.UI.Notification:EnableMouse( true )
ns.UI.Notification:SetMovable( true )
HekiliNotification:SetScript( "OnMouseDown", Mover_OnMouseDown )
HekiliNotification:SetScript( "OnMouseUp", Mover_OnMouseUp )
HekiliNotification:SetScript( "OnEnter", function( self )
local H = Hekili
if H.Config then
Tooltip:SetOwner( self, "ANCHOR_TOPRIGHT" )
Tooltip:SetText( "Hekili: Notifications" )
Tooltip:AddLine( "Left-click and hold to move.", 1, 1, 1 )
Tooltip:AddLine( "Right-click to open Notification panel settings.", 1, 1, 1 )
Tooltip:Show()
end
end )
HekiliNotification:SetScript( "OnLeave", function(self)
Tooltip:Hide()
end )
Hekili:ProfileFrame( "NotificationFrame", HekiliNotification )
for i, v in pairs( ns.UI.Displays ) do
if v.Backdrop then
v.Backdrop:Hide()
end
if v.Header then
v.Header:Hide()
end
if ns.UI.Buttons[ i ][ 1 ] and Hekili.DB.profile.displays[ i ] then
-- if not Hekili:IsDisplayActive( i ) then v:Show() end
v.Backdrop = v.Backdrop or CreateFrame( "Frame", v:GetName().. "_Backdrop", UIParent, "BackdropTemplate" )
v.Backdrop:ClearAllPoints()
if not v:IsAnchoringRestricted() then
v:EnableMouse( true )
v:SetMovable( true )
for id, btn in ipairs( ns.UI.Buttons[ i ] ) do
btn:EnableMouse( false )
end
local left, right, top, bottom = v:GetPerimeterButtons()
if left and right and top and bottom then
v.Backdrop:SetPoint( "LEFT", left, "LEFT", -2, 0 )
v.Backdrop:SetPoint( "RIGHT", right, "RIGHT", 2, 0 )
v.Backdrop:SetPoint( "TOP", top, "TOP", 0, 2 )
v.Backdrop:SetPoint( "BOTTOM", bottom, "BOTTOM", 0, -2 )
else
v.Backdrop:SetWidth( v:GetWidth() + 2 )
v.Backdrop:SetHeight( v:GetHeight() + 2 )
v.Backdrop:SetPoint( "CENTER", v, "CENTER" )
end
end
v.Backdrop:SetFrameStrata( v:GetFrameStrata() )
v.Backdrop:SetFrameLevel( v:GetFrameLevel() + 1 )
v.Backdrop.moveObj = v
v.Backdrop:SetBackdrop( {
bgFile = "Interface/Buttons/WHITE8X8",
edgeFile = "Interface/Buttons/WHITE8X8",
tile = false,
tileSize = 0,
edgeSize = 1,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
} )
local ccolor = RAID_CLASS_COLORS[ select(2, UnitClass("player")) ]
if Hekili:IsDisplayActive( v.id, true ) then
v.Backdrop:SetBackdropBorderColor( ccolor.r, ccolor.g, ccolor.b, 1 )
else
v.Backdrop:SetBackdropBorderColor( 0.5, 0.5, 0.5, 0.5 )
end
v.Backdrop:SetBackdropColor( 0, 0, 0, 0.8 )
v.Backdrop:Show()
v.Backdrop:SetScript( "OnMouseDown", Mover_OnMouseDown )
v.Backdrop:SetScript( "OnMouseUp", Mover_OnMouseUp )
v.Backdrop:SetScript( "OnEnter", function( self )
local H = Hekili
if H.Config then
Tooltip:SetOwner( self, "ANCHOR_TOPRIGHT" )
Tooltip:SetText( "Hekili: " .. i )
Tooltip:AddLine( "Left-click and hold to move.", 1, 1, 1 )
Tooltip:AddLine( "Right-click to open " .. i .. " display settings.", 1, 1, 1 )
if not H:IsDisplayActive( i, true ) then Tooltip:AddLine( "This display is not currently active.", 0.5, 0.5, 0.5 ) end
Tooltip:Show()
end
end )
v.Backdrop:SetScript( "OnLeave", function( self )
Tooltip:Hide()
end )
v:Show()
if not v.Header then
v.Header = v.Backdrop:CreateFontString( "HekiliDisplay" .. i .. "Header", "OVERLAY", "GameFontNormal" )
local path = v.Header:GetFont()
v.Header:SetFont( path, 18, "OUTLINE" )
end
v.Header:ClearAllPoints()
v.Header:SetAllPoints( v.Backdrop )
if i == "Defensives" then v.Header:SetText( AtlasToString( "nameplates-InterruptShield" ) )
elseif i == "Interrupts" then v.Header:SetText( AtlasToString( "voicechat-icon-speaker-mute" ) )
elseif i == "Cooldowns" then v.Header:SetText( AtlasToString( "chromietime-32x32" ) )
else v.Header:SetText( i ) end
v.Header:SetJustifyH("CENTER")
v.Header:Show()
else
v:Hide()
end
end
if not external then
if not Hekili.OptionsReady then Hekili:RefreshOptions() end
local ACD = LibStub( "AceConfigDialog-3.0" )
ACD:SetDefaultSize( "Hekili", 800, 608 )
ACD:Open( "Hekili" )
local oFrame = ACD.OpenFrames["Hekili"].frame
oFrame:SetResizeBounds( 800, 120 )
ns.OnHideFrame = ns.OnHideFrame or CreateFrame( "Frame" )
ns.OnHideFrame:SetParent( oFrame )
ns.OnHideFrame:SetScript( "OnHide", function(self)
ns.StopConfiguration()
self:SetScript( "OnHide", nil )
self:SetParent( nil )
if not InCombatLockdown() then
collectgarbage()
Hekili:UpdateDisplayVisibility()
else
C_Timer.After( 0, function() Hekili:UpdateDisplayVisibility() end )
end
end )
if not ns.OnHideFrame.firstTime then
ACD:SelectGroup( "Hekili", "packs" )
ACD:SelectGroup( "Hekili", "displays" )
ACD:SelectGroup( "Hekili", "displays", "Multi" )
ACD:SelectGroup( "Hekili", "general" )
ns.OnHideFrame.firstTime = true
end
Hekili:ProfileFrame( "CloseOptionsFrame", ns.OnHideFrame )
end
Hekili:UpdateDisplayVisibility()
end
function Hekili:OpenConfiguration()
ns.StartConfiguration()
end
function ns.StopConfiguration()
Hekili.Config = false
local scaleFactor = Hekili:GetScale()
local mouseInteract = Hekili.Pause
for id, display in pairs( Hekili.DisplayPool ) do
display:EnableMouse( false )
if not display:IsAnchoringRestricted() then display:SetMovable( true ) end
-- v:SetBackdrop( nil )
if display.Header then
display.Header:Hide()
end
if display.Backdrop then
display.Backdrop:Hide()
end
for i, btn in ipairs( display.Buttons ) do
btn:EnableMouse( mouseInteract )
btn:SetMovable( false )
end
end
HekiliNotification:EnableMouse( false )
HekiliNotification:SetMovable( false )
HekiliNotification.Mover:Hide()
-- HekiliNotification.Mover.Header:Hide()
end
local function MasqueUpdate( Addon, Group, SkinID, Gloss, Backdrop, Colors, Disabled )
if Disabled then
for dispID, display in ipairs( ns.UI.Buttons ) do
for btnID, button in ipairs( display ) do
button.__MSQ_NormalTexture:Hide()
button.Texture:SetAllPoints( button )
end
end
end
end
do
ns.UI.Menu = ns.UI.Menu or CreateFrame( "Frame", "HekiliMenu", UIParent, "UIDropDownMenuTemplate" )
local menu = ns.UI.Menu
Hekili:ProfileFrame( "HekiliMenu", menu )
menu.info = {}
menu.AddButton = UIDropDownMenu_AddButton
menu.AddSeparator = UIDropDownMenu_AddSeparator
local function SetDisplayMode( mode )
Hekili.DB.profile.toggles.mode.value = mode
if WeakAuras and WeakAuras.ScanEvents then WeakAuras.ScanEvents( "HEKILI_TOGGLE", "mode", mode ) end
if ns.UI.Minimap then ns.UI.Minimap:RefreshDataText() end
Hekili:UpdateDisplayVisibility()
Hekili:ForceUpdate( "HEKILI_TOGGLE", true )
end
local function IsDisplayMode( p, mode )
return Hekili.DB.profile.toggles.mode.value == mode
end
local menuData = {
{
isTitle = 1,
text = "Hekili",
notCheckable = 1,
},
{
text = "Enable",
func = function () Hekili:Toggle() end,
checked = function () return Hekili.DB.profile.enabled end,
},
{
text = "Pause",
func = function () return Hekili:TogglePause() end,
checked = function () return Hekili.Pause end,
},
{
isSeparator = 1,
},
{
isTitle = 1,
text = "Display Mode",
notCheckable = 1,
},
{
text = "Auto",
func = function () SetDisplayMode( "automatic" ) end,
checked = function () return IsDisplayMode( p, "automatic" ) end,
},
{
text = "Single",
func = function () SetDisplayMode( "single" ) end,
checked = function () return IsDisplayMode( p, "single" ) end,
},
{
text = "AOE",
func = function () SetDisplayMode( "aoe" ) end,
checked = function () return IsDisplayMode( p, "aoe" ) end,
},
{
text = "Dual",
func = function () SetDisplayMode( "dual" ) end,
checked = function () return IsDisplayMode( p, "dual" ) end,
},
{
text = "Reactive",
func = function () SetDisplayMode( "reactive" ) end,
checked = function () return IsDisplayMode( p, "reactive" ) end,
},
{
isSeparator = 1,
},
{
isTitle = 1,
text = "Toggles",
notCheckable = 1,
},
{
text = "Cooldowns",
func = function() Hekili:FireToggle( "cooldowns" ); ns.UI.Minimap:RefreshDataText() end,
checked = function () return Hekili.DB.profile.toggles.cooldowns.value end,
},
{
text = "Minor CDs",
func = function() Hekili:FireToggle( "essences" ); ns.UI.Minimap:RefreshDataText() end,
checked = function () return Hekili.DB.profile.toggles.essences.value end,
},
{
text = "Interrupts",
func = function() Hekili:FireToggle( "interrupts" ); ns.UI.Minimap:RefreshDataText() end,
checked = function () return Hekili.DB.profile.toggles.interrupts.value end,
},
{
text = "Defensives",
func = function() Hekili:FireToggle( "defensives" ); ns.UI.Minimap:RefreshDataText() end,
checked = function () return Hekili.DB.profile.toggles.defensives.value end,
},
{
text = "Potions",
func = function() Hekili:FireToggle( "potions" ); ns.UI.Minimap:RefreshDataText() end,
checked = function () return Hekili.DB.profile.toggles.potions.value end,
}
}
local specsParsed = false
menu.args = {}
UIDropDownMenu_SetDisplayMode( menu, "MENU" )
function menu:initialize( level, list )
if not level and not list then
return
end
if level == 1 then
if not specsParsed then
-- Add specialization toggles where applicable.
for i, spec in pairs( Hekili.Class.specs ) do
if i > 0 then
insert( menuData, {
isSeparator = 1,
hidden = function () return Hekili.State.spec.id ~= i end,
} )
insert( menuData, {
isTitle = 1,
text = spec.name,
notCheckable = 1,
hidden = function () return Hekili.State.spec.id ~= i end,
} )
insert( menuData, {
text = "|TInterface\\Addons\\Hekili\\Textures\\Cycle:0|t Recommend Target Swaps",
tooltipTitle = "|TInterface\\Addons\\Hekili\\Textures\\Cycle:0|t Recommend Target Swaps",
tooltipText = "If checked, the |TInterface\\Addons\\Hekili\\Textures\\Cycle:0|t indicator may be displayed which means you should use the ability on a different target.",
tooltipOnButton = true,
func = function ()
local spec = rawget( Hekili.DB.profile.specs, i )
if spec then
spec.cycle = not spec.cycle
if Hekili.DB.profile.notifications.enabled then
Hekili:Notify( "Recommend Target Swaps: " .. ( spec.cycle and "ON" or "OFF" ) )
else
Hekili:Print( "Recommend Target Swaps: " .. ( spec.cycle and " |cFF00FF00ENABLED|r." or " |cFFFF0000DISABLED|r." ) )
end
end
end,
checked = function ()
local spec = rawget( Hekili.DB.profile.specs, i )
return spec.cycle
end,
hidden = function () return Hekili.State.spec.id ~= i end,
} )
local potionMenu = {
text = "|T967533:0|t Preferred Potion",
tooltipTitle = "|T967533:0|t Preferred Potion",
tooltipText = "Select the potion you would like to use when the |cFFFFD100Potions|r toggle is enabled.",
tooltipOnButton = true,
hasArrow = true,
menuList = {},
notCheckable = true,
hidden = function () return Hekili.State.spec.id ~= i end,
}
for k, v in orderedPairs( class.potionList ) do
insert( potionMenu.menuList, {
text = v,
func = function ()
Hekili.DB.profile.specs[ Hekili.State.spec.id ].potion = k
for _, display in pairs( Hekili.DisplayPool ) do
display:OnEvent( "HEKILI_MENU" )
end
end,
checked = function ()
return Hekili.DB.profile.specs[ Hekili.State.spec.id ].potion == k
end,
} )
end
insert( menuData, potionMenu )
-- Check for Toggles.
for n, setting in pairs( spec.settings ) do
if setting.info and ( not setting.info.arg or setting.info.arg() ) then
if setting.info.type == "toggle" then
local name = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name
local submenu
submenu = {
text = name,
tooltipTitle = name,
tooltipText = type( setting.info.desc ) == "function" and setting.info.desc() or setting.info.desc,
tooltipOnButton = true,
func = function ()
menu.args[1] = setting.name
setting.info.set( menu.args, not setting.info.get( menu.args ) )
local nm = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name
if Hekili.DB.profile.notifications.enabled then
Hekili:Notify( nm .. ": " .. ( setting.info.get( menu.args ) and "ON" or "OFF" ) )
else
Hekili:Print( nm .. ": " .. ( setting.info.get( menu.args ) and " |cFF00FF00ENABLED|r." or " |cFFFF0000DISABLED|r." ) )
end
submenu.text = nm
submenu.tooltipTitle = nm
submenu.tooltipText = type( setting.info.desc ) == "function" and setting.info.desc() or setting.info.desc
end,
checked = function ()
menu.args[1] = setting.name
return setting.info.get( menu.args )
end,
hidden = function () return Hekili.State.spec.id ~= i end,
}
insert( menuData, submenu )
elseif setting.info.type == "select" then
local name = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name
local submenu
submenu = {
text = name,
tooltipTitle = name,
tooltipText = type( setting.info.desc ) == "function" and setting.info.desc() or setting.info.desc,
tooltipOnButton = true,
hasArrow = true,
menuList = {},
notCheckable = true,
hidden = function () return Hekili.State.spec.id ~= i end,
}
local values = setting.info.values
if type( values ) == "function" then values = values() end
if values then
if setting.info.sorting then
for _, k in orderedPairs( setting.info.sorting ) do
local v = values[ k ]
insert( submenu.menuList, {
text = v,
func = function ()
menu.args[1] = setting.name
setting.info.set( menu.args, k )
local nm = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name
submenu.text = nm
submenu.tooltipTitle = nm
submenu.tooltipText = type( setting.info.desc ) == "function" and setting.info.desc() or setting.info.desc
for k, v in pairs( Hekili.DisplayPool ) do
v:OnEvent( "HEKILI_MENU" )
end
end,
checked = function ()
menu.args[1] = setting.name
return setting.info.get( menu.args ) == k
end,
hidden = function () return Hekili.State.spec.id ~= i end,
} )
end
else
for k, v in orderedPairs( values ) do
insert( submenu.menuList, {
text = v,
func = function ()
menu.args[1] = setting.name
setting.info.set( menu.args, k )
local nm = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name
submenu.text = nm
submenu.tooltipTitle = nm
submenu.tooltipText = type( setting.info.desc ) == "function" and setting.info.desc() or setting.info.desc
for k, v in pairs( Hekili.DisplayPool ) do
v:OnEvent( "HEKILI_MENU" )
end
end,
checked = function ()
menu.args[1] = setting.name
return setting.info.get( menu.args ) == k
end,
hidden = function () return Hekili.State.spec.id ~= i end,
} )
end
end
end
insert( menuData, submenu )
elseif setting.info.type == "range" then
local submenu = {
text = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name,
tooltipTitle = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name,
tooltipText = type( setting.info.desc ) == "function" and setting.info.desc() or setting.info.desc,
tooltipOnButton = true,
notCheckable = true,
hidden = function () return Hekili.State.spec.id ~= i end,
hasArrow = true,
menuList = {}
}
local slider = {
text = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name,
tooltipTitle = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name,
tooltipText = type( setting.info.desc ) == "function" and setting.info.desc() or setting.info.desc,
tooltipOnButton = true,
notCheckable = true,
hidden = function () return Hekili.State.spec.id ~= i end,
}
local cn = "HekiliSpec" .. i .. "Option" .. n
local cf = CreateFrame( "Frame", cn, UIParent, "HekiliPopupDropdownRangeTemplate" )
cf.Slider:SetAccessorFunction( function()
menu.args[1] = setting.name
return setting.info.get( menu.args )
end )
cf.Slider:SetMutatorFunction( function( val )
menu.args[1] = setting.name
return setting.info.set( menu.args, val )
end )
cf.Slider:SetMinMaxValues( setting.info.min, setting.info.max )
cf.Slider:SetValueStep( setting.info.step or 1 )
cf.Slider:SetObeyStepOnDrag( true )
cf.Slider:SetScript( "OnEnter", function( self )
local tooltip = GetAppropriateTooltip()
tooltip:SetOwner( cf.Slider, "ANCHOR_RIGHT", 0, 2 )
GameTooltip_SetTitle( tooltip, slider.tooltipTitle )
GameTooltip_AddNormalLine( tooltip, slider.tooltipText, true )
tooltip:Show()
end )
cf.Slider:SetScript( "OnLeave", function( self )
GameTooltip:Hide()
end )
slider.customFrame = cf
insert( submenu.menuList, slider )
--[[ local low, high, step = setting.info.min, setting.info.max, setting.info.step
local fractional, factor = step < 1, 1 / step
if fractional then
low = low * factor
high = high * factor
step = step * factor
end
if ceil( ( high - low ) / step ) > 20 then
step = ceil( ( high - low ) / 20 )
if step % ( setting.info.step or 1 ) ~= 0 then
step = step - ( step % ( setting.info.step or 1 ) )
end
end
for j = low, high, step do
local actual = j / factor
insert( submenu.menuList, {
text = tostring( actual ),
func = function ()
menu.args[1] = setting.name
setting.info.set( menu.args, actual )
local name = type( setting.info.name ) == "function" and setting.info.name() or setting.info.name
if Hekili.DB.profile.notifications.enabled then
Hekili:Notify( name .. " set to |cFF00FF00" .. actual .. "|r." )
else
Hekili:Print( name .. " set to |cFF00FF00" .. actual .. "|r." )
end
end,
checked = function ()
menu.args[1] = setting.name
return setting.info.get( menu.args ) == actual
end,
hidden = function () return Hekili.State.spec.id ~= i end,
} )
end ]]
insert( menuData, submenu )
end
end
end
end
end
specsParsed = true
end
end
local use = list or menuData
local classic = Hekili.IsClassic()
for i, data in ipairs( use ) do
data.classicChecks = classic
if not data.hidden or ( type( data.hidden ) == 'function' and not data.hidden() ) then
if data.isSeparator then
menu.AddSeparator( level )
else
menu.AddButton( data, level )
end
end
end
end
end
do
ns.UI.Displays = ns.UI.Displays or {}
local dPool = ns.UI.Displays
Hekili.DisplayPool = dPool
local alphaUpdateEvents = {
PET_BATTLE_OPENING_START = 1,
PET_BATTLE_CLOSE = 1,
BARBER_SHOP_OPEN = 1,
BARBER_SHOP_CLOSE = 1,
PLAYER_GAINS_VEHICLE_DATA = 1,
PLAYER_LOSES_VEHICLE_DATA = 1,
UNIT_ENTERING_VEHICLE = 1,
UNIT_ENTERED_VEHICLE = 1,
UNIT_EXITED_VEHICLE = 1,
UNIT_EXITING_VEHICLE = 1,
VEHICLE_ANGLE_SHOW = 1,
VEHICLE_UPDATE = 1,
UPDATE_VEHICLE_ACTIONBAR = 1,
UPDATE_OVERRIDE_ACTIONBAR = 1,
CLIENT_SCENE_OPENED = 1,
CLIENT_SCENE_CLOSED = 1,
-- UNIT_FLAGS = 1,
PLAYER_TARGET_CHANGED = 1,
PLAYER_ENTERING_WORLD = 1,
PLAYER_REGEN_ENABLED = 1,
PLAYER_REGEN_DISABLED = 1,
ACTIVE_TALENT_GROUP_CHANGED = 1,
ZONE_CHANGED = 1,
ZONE_CHANGED_INDOORS = 1,
ZONE_CHANGED_NEW_AREA = 1,
PLAYER_CONTROL_LOST = 1,
PLAYER_CONTROL_GAINED = 1,
PLAYER_MOUNT_DISPLAY_CHANGED = 1,
UPDATE_ALL_UI_WIDGETS = 1,
}
local kbEvents = {
-- ACTIONBAR_SLOT_CHANGED = 1,
ACTIONBAR_PAGE_CHANGED = 1,
ACTIONBAR_UPDATE_STATE = 1,
SPELLS_CHANGED = 1,
UPDATE_SHAPESHIFT_FORM = 1,
}
local flashEvents = {
-- This unregisters flash frames in SpellFlash.
ACTIONBAR_SHOWGRID = 1,
-- These re-register flash frames in SpellFlash (after 0.5 - 1.0s).
ACTIONBAR_HIDEGRID = 1,
LEARNED_SPELL_IN_TAB = 1,
CHARACTER_POINTS_CHANGED = 1,
ACTIVE_TALENT_GROUP_CHANGED = 1,
UPDATE_MACROS = 1,
VEHICLE_UPDATE = 1,
}
-- Opportunity for Performance Preference, maybe.
local pulseDisplay = 0.25
local pulseRange = TOOLTIP_UPDATE_TIME
local LRC = LibStub( "LibRangeCheck-3.0" )
local LSF = SpellFlashCore
local catchFlash, lastFramesFlashed = nil, {}
if LSF then
hooksecurefunc( LSF, "FlashFrame", function( frame )
local flash = frame and frame.SpellFlashCoreAddonFlashFrame
-- We need to know what flashed so we can force it to stop flashing when the recommendation changes.
if catchFlash and flash then
lastFramesFlashed[ flash ] = 1
end
end )
end
local LSR = LibStub("SpellRange-1.0")
local Glower = LibStub("LibCustomGlow-1.0")
local function CalculateAlpha( id )
if IsInPetBattle() or Hekili.Barber or Hekili.ClientScene or UnitHasVehicleUI( "player" ) or HasVehicleActionBar() or HasOverrideActionBar() or UnitOnTaxi( "player" ) or not Hekili:IsDisplayActive( id ) then
return 0
end
local prof = Hekili.DB.profile
local conf = prof.displays[ id ]
local spec = state.spec.id and prof.specs[ state.spec.id ]
local aoe = spec and spec.aoe or 3
local _, zoneType = IsInInstance()
if not conf.enabled then
return 0
elseif id == "AOE" and Hekili:GetToggleState( "mode" ) == "reactive" and Hekili:GetNumTargets() < aoe then
return 0
elseif zoneType == "pvp" or zoneType == "arena" then
if not conf.visibility.advanced then return conf.visibility.pvp.alpha end
if conf.visibility.pvp.hideMounted and IsMounted() then return 0 end
if conf.visibility.pvp.combatTarget > 0 and state.combat > 0 and UnitExists( "target" ) and not UnitIsDead( "target" ) and UnitCanAttack( "player", "target" ) then
return conf.visibility.pvp.combatTarget
elseif conf.visibility.pvp.combat > 0 and state.combat > 0 then
return conf.visibility.pvp.combat
elseif conf.visibility.pvp.target > 0 and UnitExists( "target" ) and not UnitIsDead( "target" ) and UnitCanAttack( "player", "target" ) then
return conf.visibility.pvp.target
elseif conf.visibility.pvp.always > 0 then
return conf.visibility.pvp.always
end
return 0
end
if not conf.visibility.advanced then return conf.visibility.pve.alpha end
if conf.visibility.pve.hideMounted and IsMounted() then return 0 end
if conf.visibility.pve.combatTarget > 0 and state.combat > 0 and UnitExists( "target" ) and not UnitIsDead( "target" ) and UnitCanAttack( "player", "target" ) then
return conf.visibility.pve.combatTarget
elseif conf.visibility.pve.combat > 0 and state.combat > 0 then
return conf.visibility.pve.combat
elseif conf.visibility.pve.target > 0 and UnitExists( "target" ) and not UnitIsDead( "target" ) and UnitCanAttack( "player", "target" ) then
return conf.visibility.pve.target
elseif conf.visibility.pve.always > 0 then
return conf.visibility.pve.always
end
return 0
end
local numDisplays = 0
function Hekili:CreateDisplay( id )
local conf = rawget( self.DB.profile.displays, id )
if not conf then return end
if not dPool[ id ] then
numDisplays = numDisplays + 1
dPool[ id ] = CreateFrame( "Frame", "HekiliDisplay" .. id, UIParent )
dPool[ id ].index = numDisplays
Hekili:ProfileFrame( "HekiliDisplay" .. id, dPool[ id ] )
end
local d = dPool[ id ]
d.id = id
d.alpha = 0
d.numIcons = conf.numIcons
d.firstForce = 0
d.threadLocked = false
local scale = self:GetScale()
local border = 2
d:SetSize( scale * ( border + ( conf.primaryWidth or 50 ) ), scale * ( border + ( conf.primaryHeight or 50 ) ) )
--[[ d:SetIgnoreParentScale( true )
d:SetScale( UIParent:GetScale() ) ]]
d:ClearAllPoints()
d:SetPoint( "CENTER", UIParent, "CENTER", conf.x or 0, conf.y or -225 )
d:SetParent( UIParent )
d:SetFrameStrata( conf.frameStrata or "MEDIUM" )
d:SetFrameLevel( conf.frameLevel or ( 10 * d.index ) )