forked from Hekili/hekili
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UI.lua
2930 lines (2351 loc) · 112 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 format, insert = string.format, table.insert
local HasVehicleActionBar, HasOverrideActionBar, IsInPetBattle, UnitHasVehicleUI, UnitOnTaxi = HasVehicleActionBar, HasOverrideActionBar, C_PetBattles.IsInBattle, UnitHasVehicleUI, UnitOnTaxi
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 = frame:GetPoint()
frame:StartMoving()
_, _, _, movementData.fromX, movementData.fromY = frame:GetPoint()
frame.Moving = true
end
local function stopScreenMovement(frame)
local monitor = (tonumber(GetCVar("gxMonitor")) or 0) + 1
local resolutions = {GetScreenResolutions()}
local resolution = resolutions[GetCurrentResolution()] or GetCVar("gxWindowedResolution") or "1024x768"
local scrW, scrH = resolution:match("(%d+)x(%d+)")
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 = 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
GameTooltip:SetOwner( self, "ANCHOR_TOPRIGHT" )
GameTooltip:SetText( "Hekili: Notifications" )
GameTooltip:AddLine( "Left-click and hold to move.", 1, 1, 1 )
GameTooltip:AddLine( "Right-click to open Notification panel settings.", 1, 1, 1 )
GameTooltip:Show()
end
end )
HekiliNotification:SetScript( "OnLeave", function(self)
GameTooltip: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
GameTooltip:SetOwner( self, "ANCHOR_TOPRIGHT" )
GameTooltip:SetText( "Hekili: " .. i )
GameTooltip:AddLine( "Left-click and hold to move.", 1, 1, 1 )
GameTooltip:AddLine( "Right-click to open " .. i .. " display settings.", 1, 1, 1 )
if not H:IsDisplayActive( i, true ) then GameTooltip:AddLine( "This display is not currently active.", 0.5, 0.5, 0.5 ) end
GameTooltip:Show()
end
end )
v.Backdrop:SetScript( "OnLeave", function( self )
GameTooltip: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
if not Hekili.IsDragonflight() then oFrame:SetMinResize( 800,608 ) end
ns.OnHideFrame = ns.OnHideFrame or CreateFrame( "Frame" )
ns.OnHideFrame:SetParent( oFrame )
ns.OnHideFrame:SetScript( "OnHide", function(self)
ns.StopConfiguration()
self:SetScript( "OnHide", nil )
collectgarbage()
Hekili:UpdateDisplayVisibility()
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()
Hekili:UpdateDisplayVisibility()
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 = "Covenants",
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 = {}
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 = "Recommend Target Swaps",
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
self: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,
} )
-- Check for Toggles.
for n, setting in pairs( spec.settings ) do
if not setting.info.arg or setting.info.arg() then
if setting.info.type == "toggle" then
insert( menuData, {
text = setting.info.name,
func = function ()
menu.args[1] = setting.name
setting.info.set( menu.args, not setting.info.get( menu.args ) )
if Hekili.DB.profile.notifications.enabled then
Hekili:Notify( setting.info.name .. ": " .. ( setting.info.get( menu.args ) and "ON" or "OFF" ) )
else
self:Print( setting.info.name .. ": " .. ( setting.info.get( menu.args ) and " |cFF00FF00ENABLED|r." or " |cFFFF0000DISABLED|r." ) )
end
end,
checked = function ()
menu.args[1] = setting.name
return setting.info.get( menu.args )
end,
hidden = function () return Hekili.State.spec.id ~= i end,
} )
elseif setting.info.type == "select" then
local submenu = {
text = setting.info.name,
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
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 )
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
insert( menuData, submenu )
elseif setting.info.type == "range" and setting.info.step == 1 and ( ( setting.info.max or 999 ) - ( setting.info.min or -999 ) ) < 30 then
local submenu = {
text = setting.info.name,
hasArrow = true,
menuList = {},
notCheckable = true,
hidden = function () return Hekili.State.spec.id ~= i end,
}
for j = setting.info.min, setting.info.max do
insert( submenu.menuList, {
text = tostring( j ),
func = function ()
menu.args[1] = setting.name
setting.info.set( menu.args, j )
end,
checked = function ()
menu.args[1] = setting.name
return setting.info.get( menu.args ) == j
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,
}
local pulseAuras = 0.1
local pulseDelay = 0.05
local pulseGlow = 0.25
local pulseTargets = 0.1
local pulseRange = TOOLTIP_UPDATE_TIME
local pulseFlash = 0.5
local flashOffset = {
Primary = 0,
AOE = 0.25,
Interrupts = 0.125,
Defensives = 0.333,
Cooldowns = 0.416
}
local oocRefresh = 1
local icRefresh = {
Primary = 0.25,
AOE = 0.25,
Interrupts = 0.25,
Defensives = 0.5,
Cooldowns = 0.25
}
local LRC = LibStub("LibRangeCheck-2.0")
local LSF = SpellFlashCore
local catchFlash, lastFramesFlashed = nil, {}
if LSF then
hooksecurefunc( LSF, "FlashFrame", function( frame )
local flash = frame and frame.SpellFlashCoreAddonFlashFrame
if flash and not flash.HekiliHooked then
flash.FlashTexture:SetTexture( Hekili.DB.profile.flashTexture or "Interface\\Cooldown\\star4" )
flash:HookScript( "OnUpdate", function( self )
flash.FlashTexture:SetTexture( Hekili.DB.profile.flashTexture or "Interface\\Cooldown\\star4" )
if Hekili.DB.profile.fixedSize then
flash.FlashTexture:SetHeight( flash:GetHeight() * flash.FlashSize )
flash.FlashTexture:SetWidth( flash:GetWidth() * flash.FlashSize )
end
if Hekili.DB.profile.fixedBrightness then
flash.FlashTexture:SetAlpha( flash.FlashBrightness )
end
end )
flash.HekiliHooked = true
end
-- 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.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()
local frame
--[[ if conf.relativeTo == "CUSTOM" then
frame = _G[ conf.customFrame ]
elseif conf.relativeTo == "PERSONAL" then
frame = C_NamePlate.GetNamePlateForUnit( "player" )
end ]]
if not frame then frame = UIParent end
d:SetPoint( "CENTER", frame, "CENTER", conf.x or 0, conf.y or -225 )
d:SetParent( frame )
d:SetFrameStrata( conf.frameStrata or "MEDIUM" )
d:SetFrameLevel( conf.frameLevel or ( 10 * d.index ) )
if not d:IsAnchoringRestricted() then
d:SetClampedToScreen( true )
d:EnableMouse( false )
d:SetMovable( true )
end
function d:UpdateKeybindings()
local conf = Hekili.DB.profile.displays[ self.id ]
if conf.keybindings and conf.keybindings.enabled then
for i, b in ipairs( self.Buttons ) do
local a = b.Action
if a then
b.Keybind, b.KeybindFrom = Hekili:GetBindingForAction( a, conf, i )
if i == 1 or conf.keybindings.queued then
b.Keybinding:SetText( b.Keybind )
else
b.Keybinding:SetText( nil )
end
else
b.Keybinding:SetText( nil )
end
end
end
end
function d:IsThreadLocked()
return self.threadLocked
end
function d:SetThreadLocked( locked )
self.threadLocked = locked
end
function d:OnUpdate( elapsed )
if not self.Recommendations or not Hekili.PLAYER_ENTERING_WORLD then
return
end
local init = debugprofilestop()
local profile = Hekili.DB.profile
local conf = profile.displays[ self.id ]
self.alphaCheck = self.alphaCheck - elapsed
if self.alphaCheck <= 0 then
self.alphaCheck = 0.5
self:UpdateAlpha()
end
if not self.id == "Primary" and not ( self.Buttons[ 1 ] and self.Buttons[ 1 ].Action ) and not ( self.HasRecommendations or not self.NewRecommendations ) then
return
end
local postAlpha = debugprofilestop()
if Hekili.Pause and not self.paused then
self.Buttons[ 1 ].Overlay:Show()
self.paused = true
elseif not Hekili.Pause and self.paused then
self.Buttons[ 1 ].Overlay:Hide()
self.paused = false
end
local now = GetTime()
self.recTimer = self.recTimer - elapsed
if not self:IsThreadLocked() and ( self.NewRecommendations or self.recTimer < 0 ) then
local alpha = self.alpha
local options = Hekili:GetActiveSpecOption( "abilities" )
if self.HasRecommendations and self.RecommendationsStr and self.RecommendationsStr:len() == 0 then
for i, b in ipairs( self.Buttons ) do b:Hide() end
self.HasRecommendations = false
else
self.HasRecommendations = true
for i, b in ipairs( self.Buttons ) do
b.Recommendation = self.Recommendations[ i ]
local action = b.Recommendation.actionName
local caption = b.Recommendation.caption
local indicator = b.Recommendation.indicator
local keybind = b.Recommendation.keybind
local exact_time = b.Recommendation.exact_time
local ability = class.abilities[ action ]
if ability then
if ( conf.flash.enabled and conf.flash.suppress ) then b:Hide()
else b:Show() end
if i == 1 then
-- print( "Changing", GetTime() )
end
if action ~= b.lastAction or self.NewRecommendations or not b.Image then
if ability.item then
b.Image = b.Recommendation.texture or ability.texture or select( 10, GetItemInfo( ability.item ) )
else
local override = options and rawget( options, action )
b.Image = override and override.icon or b.Recommendation.texture or ability.texture or GetSpellTexture( ability.id )
end
b.Texture:SetTexture( b.Image )
b.Texture:SetTexCoord( unpack( b.texCoords ) )
b.lastAction = action
end
b.Texture:Show()
if i == 1 then
-- local ability = b.Ability
local id = ability.item or ability.id
local isItem = ability.item ~= nil
if id and ( isItem and IsCurrentItem( id ) or IsCurrentSpell( id ) ) and exact_time > GetTime() then
b.Highlight:Show()