-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElvUI_Extras.lua
1813 lines (1643 loc) · 59.1 KB
/
ElvUI_Extras.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
local E, L, _, P = unpack(ElvUI)
local core = E:NewModule("Extras", "AceHook-3.0", "AceEvent-3.0")
local UF = E:GetModule("UnitFrames")
local NP = E:GetModule("NamePlates")
local S = E:GetModule("Skins")
local EP = E.Libs.EP
local LSM = E.Libs.LSM
local ElvUF = E.oUF
core.modules = {}
core.nameUpdates = {}
core.areaUpdates = {}
core.frameUpdates = {}
core.taggedFrames = {}
core.healthEnabled = {}
core.plateAnchoring = {
["Elite"] = function(unitType, frame, element)
if unitType == "ENEMY_NPC" or unitType == "FRIENDLY_NPC" then
local points = NP.db.units[unitType].eliteIcon
frame.Elite:ClearAllPoints()
frame.Elite:Point(points.position, element, points.xOffset, points.yOffset)
end
end
}
core.PurgeList = {
MAGE = true,
PRIEST = true,
SHAMAN = true,
WARLOCK = true,
}
core.DispellList = {
PRIEST = {Magic = true, Disease = true},
SHAMAN = {Poison = true, Disease = true, Curse = false},
PALADIN = {Poison = true, Magic = true, Disease = true},
MAGE = {Curse = true},
DRUID = {Curse = true, Poison = true},
WARLOCK = {Magic = true},
}
local AddOnName = ...
local isAwesome = C_NamePlate and E.private.nameplates.enable
local printing = false
local nameUpdates = core.nameUpdates
local frameUpdates = core.frameUpdates
local healthEnabled = core.healthEnabled
local plateAnchoring = core.plateAnchoring
local taggedFrames = core.taggedFrames
local areaUpdates = core.areaUpdates
local CreateFrame, UIParent, UIDropDownMenu_Refresh = CreateFrame, UIParent, UIDropDownMenu_Refresh
local _G, unpack, pairs, ipairs, select, tonumber, print = _G, unpack, pairs, ipairs, select, tonumber, print
local gsub, find, sub, lower, upper = string.gsub, string.find, string.sub, string.lower, string.upper
local format, match, gmatch = string.format, string.match, string.gmatch
local max, ceil, floor = math.max, math.ceil, math.floor
local tinsert, twipe, tsort = table.insert, table.wipe, table.sort
local UnitGUID, UnitClass, UnitExists = UnitGUID, UnitClass, UnitExists
local UnitThreatSituation, GetThreatStatusColor = UnitThreatSituation, GetThreatStatusColor
local UnitReaction, UnitIsPlayer, UnitCanAttack = UnitReaction, UnitIsPlayer, UnitCanAttack
local GetNumMacroIcons, GetMacroIconInfo, GameTooltip = GetNumMacroIcons, GetMacroIconInfo, GameTooltip
local UnitPopupMenus, UnitPopupShown = UnitPopupMenus, UnitPopupShown
local GetRaidRosterInfo, IsPartyLeader, IsRaidOfficer = GetRaidRosterInfo, IsPartyLeader, IsRaidOfficer
local InCombatLockdown, IsControlKeyDown = InCombatLockdown, IsControlKeyDown
local IsInInstance, IsResting = IsInInstance, IsResting
local LUA_ERROR, FORMATTING, ERROR_CAPS = LUA_ERROR, FORMATTING, ERROR_CAPS
local function colorConvert(r, g, b)
if tonumber(r) then
return format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
else
local hex = gsub(r, "|c%w%w", "")
r = tonumber(sub(hex, 1, 2), 16) / 255
g = tonumber(sub(hex, 3, 4), 16) / 255
b = tonumber(sub(hex, 5, 6), 16) / 255
return r, g, b
end
end
local function getEntry(tbl, path)
for key in gmatch(path, "[^%.]+") do
local index = tonumber(key)
if type(tbl) ~= "table" or (tbl[index] == nil and tbl[key] == nil) then
return nil
end
tbl = tbl[index or key]
end
return tbl
end
-- make worlmap quests open quest log on ctrl-click
if not core:IsHooked("WorldMapQuestFrame_OnMouseUp") then
core:SecureHook("WorldMapQuestFrame_OnMouseUp", function(self)
if InCombatLockdown() then
return
elseif IsControlKeyDown() then
if not QuestLogFrame:IsShown() then
ShowUIPanel(QuestLogFrame)
end
QuestLog_SetSelection(self.questLogIndex)
QuestLog_Update()
end
end)
end
-- restored raid controls
local function createSecurePromoteButton(name, role)
local button = CreateFrame("Button", name, UIParent, "SecureActionButtonTemplate")
button:SetFrameStrata("TOOLTIP")
button:Hide()
button:SetAttribute("type", role)
button:SetAttribute("unit", "target")
button:SetAttribute("action", "toggle")
button:RegisterEvent("PLAYER_REGEN_DISABLED")
button:RegisterEvent("PLAYER_REGEN_ENABLED")
RegisterStateDriver(button, "visibility", "[combat] hide")
return button
end
local function setButton(unit, button, newButton)
newButton:SetAllPoints(button)
newButton:SetAttribute("unit", unit or "target")
newButton:SetScript("OnEnter", function()
button:GetScript("OnEnter")(button)
end)
newButton:SetScript("OnLeave", function()
button:GetScript("OnLeave")(button)
end)
newButton:SetScript("OnMouseDown", function()
button:SetButtonState("PUSHED")
end)
newButton:SetScript("OnMouseUp", function()
button:SetButtonState("NORMAL")
end)
newButton:SetScript("PostClick", function()
button:GetScript("OnClick")(button)
end)
newButton:SetScript("OnEvent", function(self, event)
if event == "PLAYER_REGEN_DISABLED" then
self:EnableMouse(false)
button:EnableMouse(false)
button:SetAlpha(0.5)
else
self:EnableMouse(true)
button:EnableMouse(true)
button:SetAlpha(1)
end
end)
newButton:Show()
end
local secureTankButton = createSecurePromoteButton("ElvUI_SecureTankButton", "maintank")
local secureAssistButton = createSecurePromoteButton("ElvUI_SecureAssistButton", "mainassist")
if not core:IsHooked("UnitPopup_OnClick") then
core:SecureHook("UnitPopup_OnClick", function(self)
local button = self.value
local dropdownFrame = UIDROPDOWNMENU_INIT_MENU
if button == "RAID_MAINTANK" or button == "RAID_MAINASSIST" then
UIDropDownMenu_Refresh(dropdownFrame, nil, 1)
end
end)
end
if not core:IsHooked("UnitPopup_ShowMenu") then
core:SecureHook("UnitPopup_ShowMenu", function(_, _, unit)
if UIDROPDOWNMENU_MENU_LEVEL ~= 1 then return end
for i = 1, UIDROPDOWNMENU_MAXBUTTONS do
local button = _G["DropDownList1Button"..i]
if button and button:IsShown() then
if button.value == "RAID_MAINTANK" then
setButton(unit, button, secureTankButton)
elseif button.value == "RAID_MAINASSIST" then
setButton(unit, button, secureAssistButton)
end
end
end
end)
end
if not core:IsHooked("UnitPopup_HideButtons") then
core:SecureHook("UnitPopup_HideButtons", function()
local dropdownMenu = UIDROPDOWNMENU_INIT_MENU
local isAuthority = IsPartyLeader() or IsRaidOfficer()
if dropdownMenu.which ~= "RAID" or not isAuthority then return end
for index, value in ipairs(UnitPopupMenus[dropdownMenu.which]) do
if value == "RAID_MAINTANK" then
local role = select(10,GetRaidRosterInfo(dropdownMenu.userData))
if role ~= "MAINTANK" or not dropdownMenu.name then
UnitPopupShown[UIDROPDOWNMENU_MENU_LEVEL][index] = 1
end
elseif value == "RAID_MAINASSIST" then
local role = select(10,GetRaidRosterInfo(dropdownMenu.userData))
if role ~= "MAINASSIST" or not dropdownMenu.name then
UnitPopupShown[UIDROPDOWNMENU_MENU_LEVEL][index] = 1
end
end
end
end)
end
if not core:IsHooked(DropDownList1, "OnHide") then
core:SecureHookScript(DropDownList1, "OnHide", function()
if InCombatLockdown() then return end
secureTankButton:Hide()
secureAssistButton:Hide()
end)
end
function core:getAllFrameTypes()
return {
["player"] = true,
["target"] = true,
["targettarget"] = true,
["targettargettarget"] = true,
["focus"] = true,
["focustarget"] = true,
["pet"] = true,
["pettarget"] = true,
["raid"] = true,
["raid40"] = true,
["raidpet"] = true,
["party"] = true,
["partypet"] = true,
["partytarget"] = true,
["boss"] = true,
["arena"] = true,
["assist"] = true,
["assisttarget"] = true,
["tank"] = true,
["tanktarget"] = true,
}
end
function core:getSelected(cat, modName, path, fallback)
local base, selected = match(path, "(.-)%[(.-)%]")
local baseTable = getEntry(E.db.Extras[cat][modName], base)
if not baseTable then
E.db.Extras[cat][modName] = E:CopyTable({}, P.Extras[cat][modName])
if not printing then
printing = true
E:Delay(0.1, function()
printing = false
print(format(self.customColorAlpha.."ElvUI "..self.pluginColor.."Extras"..self.customColorAlpha..","..
self.customColorBeta.." %s"..self.customColorAlpha..":|r %s", modName, self.customColorBad..ERROR_CAPS))
print(format(self.customColorAlpha.."ElvUI "..self.pluginColor.."Extras"..self.customColorAlpha..","..
self.customColorBeta.." %s"..self.customColorAlpha..":|r ??? -> %s.%s.%s", modName, cat, modName, path))
end)
end
return
end
if baseTable[tonumber(selected) or selected] then
return baseTable[tonumber(selected) or selected]
else
if not printing then
printing = true
E:Delay(0.1, function()
printing = false
print(format(self.customColorAlpha.."ElvUI "..self.pluginColor.."Extras"..self.customColorAlpha..","..
self.customColorBeta.." %s"..self.customColorAlpha..":|r %s", modName, self.customColorBad..ERROR_CAPS))
print(format(self.customColorAlpha.."ElvUI "..self.pluginColor.."Extras"..self.customColorAlpha..","..
self.customColorBeta.." %s"..self.customColorAlpha..":|r ??? -> %s.%s.%s", modName, cat, modName, path))
end)
end
if not baseTable[fallback] then
baseTable[fallback] = E:CopyTable({}, getEntry(P.Extras[cat][modName], base)[fallback])
end
return baseTable[fallback]
end
end
function core:print(type, ...)
if type == 'LUA' then
print(format(self.customColorAlpha.."ElvUI "..self.pluginColor.."Extras"..self.customColorAlpha..","..
self.customColorBeta.." %s "..self.customColorBad..LUA_ERROR..self.customColorAlpha..":|r %s", ...))
elseif type == 'FORMATTING' then
print(format(self.customColorAlpha.."ElvUI "..self.pluginColor.."Extras"..self.customColorAlpha..","..
self.customColorBeta.." %s"..self.customColorAlpha..":|r "..self.customColorBad..FORMATTING.." "..ERROR_CAPS, ...))
elseif type == 'FAIL' then
print(format(self.customColorAlpha.."ElvUI "..self.pluginColor.."Extras"..self.customColorAlpha..","..
self.customColorBeta.." %s"..self.customColorAlpha..":|r %s", ...))
elseif type == 'ADDED' then
print(format(self.customColorAlpha.."%s"..self.customColorBeta..(select(2,...) and "%s" or L[" added."]), ...))
elseif type == 'REMOVED' then
print(format(self.customColorAlpha.."%s"..self.customColorBeta..(select(2,...) and "%s" or L[" removed."]), ...))
end
end
-- Awesome WOTLK
if isAwesome then
local target = CreateFrame("Frame")
local mouseover = CreateFrame("Frame")
local GetNamePlates = C_NamePlate.GetNamePlates
local GetNamePlateForUnit = C_NamePlate.GetNamePlateForUnit
local LAI = E.Libs.LAI
core:RegisterEvent("PLAYER_TARGET_CHANGED", function()
local exists = UnitExists("target")
if target.exists then
if not exists then
target.exists = false
target:SetScript("OnUpdate", nil)
end
elseif exists then
target.exists = true
target:SetScript("OnUpdate", function()
for _, np in ipairs(GetNamePlates()) do
np:SetAlpha(1)
end
end)
end
for _, np in ipairs(GetNamePlates()) do
NP:SetTargetFrame(np.UnitFrame)
end
end)
core:RegisterEvent("UPDATE_MOUSEOVER_UNIT", function()
for _, np in ipairs(GetNamePlates()) do
local unitframe = np.UnitFrame
if unitframe then
NP:SetMouseoverFrame(unitframe)
end
end
local plate = GetNamePlateForUnit("mouseover")
local mouseOverFrame = plate and plate.UnitFrame
if mouseOverFrame then
mouseOverFrame.isMouseover = true
NP:Update_Highlight(mouseOverFrame)
mouseover:SetScript("OnUpdate", function()
if not UnitExists("mouseover") then
mouseOverFrame.isMouseover = nil
NP:Update_Highlight(mouseOverFrame)
mouseover:SetScript("OnUpdate", nil)
end
end)
end
end)
core:RegisterEvent("UNIT_THREAT_LIST_UPDATE", function(_, unit)
if not unit or not find(unit, "nameplate", 1, true) then return end
local plate = GetNamePlateForUnit(unit)
if plate then
local frame = plate.UnitFrame
if frame then
local status = UnitThreatSituation("player", unit)
if frame.ThreatStatus ~= status then
frame.ThreatStatus = status
NP:Update_HealthColor(frame)
end
end
end
end)
core:RegisterEvent("NAME_PLATE_CREATED", function(_, plate)
local onShow, onHide = plate:GetScript("OnShow"), plate:GetScript("OnHide")
NP:OnCreated(plate)
plate:SetScript("OnShow", onShow)
plate:SetScript("OnHide", onHide)
end)
core:RegisterEvent("NAME_PLATE_OWNER_CHANGED", function(_, unit)
local plate = GetNamePlateForUnit(unit)
core:UpdateNameplate(plate.UnitFrame, unit)
NP.OnHide(plate, nil, true)
NP.OnShow(plate, nil, true)
end)
core:RegisterEvent("NAME_PLATE_UNIT_REMOVED", function(_, unit)
local plate = GetNamePlateForUnit(unit)
if plate then plate.unit = nil end
NP.OnHide(plate, nil, true)
end)
core:RegisterEvent("NAME_PLATE_UNIT_ADDED", function(_, unit)
local plate = GetNamePlateForUnit(unit)
if plate then plate.unit = unit end
core:UpdateNameplate(plate.UnitFrame, unit)
NP.OnShow(plate, nil, true)
end)
function core:UpdateNameplate(frame, unit)
LAI:RemoveAllAurasFromGUID(UnitGUID(unit))
LAI.frame:UNIT_AURA(nil, unit)
frame.ThreatStatus = UnitThreatSituation("player", unit)
end
function core:SetTargetFrame(_, frame)
local parent = frame:GetParent()
local unit = parent.unit
if not unit then return end
local isTargetUnit = UnitGUID(unit) == UnitGUID("target")
if isTargetUnit then
if not frame.isTarget then
frame.isTarget = true
if NP.db.useTargetScale then
NP:SetFrameScale(frame, (frame.ThreatScale or 1) * NP.db.targetScale)
end
if not healthEnabled[frame.UnitType] and NP.db.alwaysShowTargetHealth then
frame.Health.r, frame.Health.g, frame.Health.b = nil, nil, nil
NP:Configure_HealthBar(frame)
NP:Configure_CastBar(frame)
NP:Configure_Elite(frame)
NP:Configure_CPoints(frame)
NP:RegisterEvents(frame)
NP:UpdateElement_All(frame, true)
end
NP:PlateFade(frame, NP.db.fadeIn and 1 or 0, frame:GetAlpha(), 1)
NP:Update_Highlight(frame)
NP:Update_CPoints(frame)
NP:StyleFilterUpdate(frame, "PLAYER_TARGET_CHANGED")
NP:ResetNameplateFrameLevel(frame)
end
else
if frame.isTarget then
frame.isTarget = nil
if NP.db.useTargetScale then
NP:SetFrameScale(frame, (frame.ThreatScale or 1))
end
if not healthEnabled[frame.UnitType] then
NP:UpdateAllFrame(frame, nil, true)
end
NP:Update_CPoints(frame)
frame:SetFrameLevel(parent:GetFrameLevel() + 1)
end
if not frame.AlphaChanged then
NP:PlateFade(frame, NP.db.fadeIn and 1 or 0, frame:GetAlpha(), target.exists and NP.db.nonTargetTransparency or 1)
end
NP:StyleFilterUpdate(frame, "PLAYER_TARGET_CHANGED")
NP:ResetNameplateFrameLevel(frame)
end
NP:Configure_Glow(frame)
NP:Update_Glow(frame)
end
function core:SetMouseoverFrame(_, frame)
if GetNamePlateForUnit("mouseover") == frame:GetParent() then
if not frame.isMouseover then
frame.isMouseover = true
NP:Update_Highlight(frame)
end
elseif frame.isMouseover then
frame.isMouseover = nil
NP:Update_Highlight(frame)
end
end
function core:GetUnitByName(self, frame, ...)
local plate = frame:GetParent()
if plate.unit then
return plate.unit
else
return core.hooks[NP].GetUnitByName(self, frame, ...)
end
end
function core:UnitClass(self, frame, ...)
local plate = frame:GetParent()
if plate.unit then
return select(2,UnitClass(plate.unit))
else
return core.hooks[NP].UnitClass(self, frame, ...)
end
end
function core:GetUnitInfo(self, frame, ...)
local plate = frame:GetParent()
local unit = plate.unit
if unit then
local reaction = UnitReaction(unit, "player")
local isPlayer = UnitIsPlayer(unit)
local unitType
if reaction and reaction >= 5 then
if isPlayer then
unitType = "FRIENDLY_PLAYER"
else
unitType = "FRIENDLY_NPC"
end
reaction = 5
elseif reaction == 4 then
if UnitCanAttack("player", unit) then
unitType = "ENEMY_NPC"
else
unitType = "FRIENDLY_NPC"
end
elseif not isPlayer then
unitType = "ENEMY_NPC"
else
unitType = "ENEMY_PLAYER"
end
return reaction, unitType
end
return core.hooks[NP].GetUnitInfo(self, frame, ...)
end
function core:UnitDetailedThreatSituation(self, frame, ...)
local plate = frame:GetParent()
if plate.unit then
return UnitThreatSituation("player", plate.unit)
else
return core.hooks[NP].UnitDetailedThreatSituation(self, frame, ...)
end
end
function core:ResetNameplateFrameLevel(_, frame)
if frame.FrameLevelChanged then
--calculate Style Filter FrameLevelChanged leveling
--level method: (10*(40*2)) max 800 + max 80 (40*2) = max 880
--highest possible should be level 880 and we add 1 to all so 881
--local leveledCount = NP.CollectedFrameLevelCount or 1
--level = (frame.FrameLevelChanged*(40*NP.levelStep)) + (leveledCount*NP.levelStep)
local level = (frame:GetParent():GetFrameLevel() + 1) + frame.FrameLevelChanged * 10
frame:SetFrameLevel(level)
frame.Shadow:SetFrameLevel(level-1)
frame.Buffs:SetFrameLevel(level)
frame.Debuffs:SetFrameLevel(level)
frame.LevelHandled = true
local targetPlate = GetNamePlateForUnit("target")
local plate = targetPlate and targetPlate.UnitFrame
if plate and frame ~= plate and level > plate:GetFrameLevel() then
plate:SetFrameLevel(level + 10)
end
elseif frame.LevelHandled then
local level = frame:GetParent():GetFrameLevel() + 1
frame:SetFrameLevel(level)
frame.Shadow:SetFrameLevel(level-1)
frame.Buffs:SetFrameLevel(level)
frame.Debuffs:SetFrameLevel(level)
frame.LevelHandled = false
end
end
if not core:IsHooked(NP, "OnUpdate") then
core:RawHook(NP, "OnUpdate", function(self) self:SetScript("OnUpdate", nil) end)
end
end
--
function core:RegisterNPElement(element, func)
if func then
plateAnchoring[element] = func
else
plateAnchoring[element] = nil
end
end
function core:OnShowHide(frame, health)
local unitType = frame.UnitType or select(2,NP:GetUnitInfo(frame))
if unitType and not healthEnabled[unitType] then
local name = frame.Name
for _, func in pairs(plateAnchoring) do
func(unitType, frame, health or name)
end
end
end
core:SecureHook(NP, "OnCreated", function(_, plate)
local frame = plate.UnitFrame
local health = frame.Health
core:SecureHookScript(health, "OnShow", function(self)
core:OnShowHide(frame, self)
end)
core:SecureHookScript(health, "OnHide", function()
if frame:IsVisible() then
core:OnShowHide(frame)
end
end)
end)
core:SecureHook(NP, "Configure_Elite", function(_, frame)
local unitType = frame.UnitType
local db = unitType and NP.db.units[unitType].eliteIcon
if db then
local icon = frame.Elite
icon:ClearAllPoints()
icon:Point(db.position, healthEnabled[unitType] and frame.Health or frame.Name, db.xOffset, db.yOffset)
end
end)
function core:AggregateUnitFrames()
local units = {}
for _, frame in ipairs(ElvUF.objects) do
tinsert(units, frame)
end
return units
end
function core:GetUnitDropdownOptions(db)
local options = {}
for option in pairs(db) do
options[option] = L[option] and L[option] or option
end
return options
end
function core:GetIconList(texList)
local list = {}
local sortedKeys = {}
for path, info in pairs(texList) do
tinsert(sortedKeys, {path = path, label = info.label, ["icon"] = info.icon})
end
tsort(sortedKeys, function(a, b)
return a.label < b.label
end)
for _, item in ipairs(sortedKeys) do
list[item.path] = item.label..' |T'..item.icon..':16:16|t'
end
return list
end
function core:OpenEditor(title, text, acceptFunc)
if not self.EditFrame then
self.EditFrame = CreateFrame("Frame", "ElvUI_Extras_Editor", UIParent)
self.EditFrame:Size(600, 400)
self.EditFrame:SetPoint("CENTER")
self.EditFrame:SetMovable(true)
self.EditFrame:SetTemplate('Transparent')
self.EditFrame:SetBackdropBorderColor(unpack(E.media.rgbvaluecolor))
self.EditFrame:SetScript("OnKeyDown", function(_, key)
if key == "ESCAPE" then
self.EditFrame:Hide()
E:ToggleOptionsUI()
end
end)
self.EditFrame.header = CreateFrame("Button", nil, self.EditFrame)
self.EditFrame.header:SetTemplate(nil, true)
self.EditFrame.header:Size(100, 25)
self.EditFrame.header:Point("CENTER", self.EditFrame, "TOP")
self.EditFrame.header:SetFrameLevel(self.EditFrame.header:GetFrameLevel() + 2)
self.EditFrame.header:SetBackdropBorderColor(unpack(E.media.rgbvaluecolor))
self.EditFrame.header:SetScript("OnShow", E.MoverNudgeOnShow)
self.EditFrame.header:EnableMouse(true)
self.EditFrame.header:RegisterForClicks("AnyUp", "AnyDown")
self.EditFrame.header:SetScript("OnMouseDown", function()
self.EditFrame:StartMoving()
end)
self.EditFrame.header:SetScript("OnMouseUp", function()
self.EditFrame:StopMovingOrSizing()
end)
self.EditFrame.title = self.EditFrame.header:CreateFontString("OVERLAY")
self.EditFrame.title:FontTemplate()
self.EditFrame.title:Point("CENTER", self.EditFrame.header, "CENTER")
self.EditFrame.title:SetText(title)
self.EditFrame.title:SetTextColor(1, 0.82, 0)
self.EditFrame.header:Width(self.EditFrame.title:GetStringWidth() + 16)
self.EditFrame.scrollFrame = CreateFrame("ScrollFrame", "ElvUI_Extras_EditorScrollFrame", self.EditFrame, "UIPanelScrollFrameTemplate")
self.EditFrame.scrollFrame:Point("TOP", self.EditFrame.title, "BOTTOM", 0, -16)
self.EditFrame.scrollFrame:Size(540, 330)
local scrollBar = _G['ElvUI_Extras_EditorScrollFrameScrollBar']
scrollBar:SetAlpha(0)
self.EditFrame.editBox = CreateFrame("EditBox", "ElvUI_Extras_EditorEditBox", self.EditFrame.scrollFrame)
self.EditFrame.editBox:SetMultiLine(true)
self.EditFrame.editBox:SetFontObject(ChatFontNormal)
self.EditFrame.editBox:Size(540, 330)
self.EditFrame.editBox:SetAutoFocus(false)
self.EditFrame.editBox:SetFrameLevel(self.EditFrame:GetFrameLevel() + 10)
self.EditFrame.editBox:SetText(text)
self.EditFrame.editBox:SetTextColor(1,0.82,0)
self.EditFrame.editBox:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
self.EditFrame.editBox:SetScript("OnTabPressed", function(self)
self:Insert(" ")
end)
self.EditFrame.scrollFrame:SetScrollChild(self.EditFrame.editBox)
self.EditFrame.acceptButton = CreateFrame("Button", "ElvUI_Extras_EditorAccept", self.EditFrame, "UIPanelButtonTemplate")
self.EditFrame.acceptButton:Size(80, 22)
self.EditFrame.acceptButton:Point("BOTTOMLEFT", self.EditFrame, "BOTTOMLEFT", 20, 20)
self.EditFrame.acceptButton:SetText(L["Accept"])
self.EditFrame.acceptButton:SetScript("OnClick", function()
acceptFunc()
E:ToggleOptionsUI()
self.EditFrame:Hide()
end)
self.EditFrame.cancelButton = CreateFrame("Button", "ElvUI_Extras_EditorCancel", self.EditFrame, "UIPanelButtonTemplate")
self.EditFrame.cancelButton:Size(80, 22)
self.EditFrame.cancelButton:Point("BOTTOMRIGHT", self.EditFrame, "BOTTOMRIGHT", -20, 20)
self.EditFrame.cancelButton:SetText(L["Cancel"])
self.EditFrame.cancelButton:SetScript("OnClick", function()
self.EditFrame:Hide()
E:ToggleOptionsUI()
end)
S:HandleScrollBar(scrollBar)
S:HandleButton(self.EditFrame.acceptButton)
S:HandleButton(self.EditFrame.cancelButton)
tinsert(UISpecialFrames, 'ElvUI_Extras_Editor')
else
self.EditFrame:Show()
self.EditFrame.title:SetText(title)
self.EditFrame.header:Width(self.EditFrame.title:GetStringWidth() + 16)
self.EditFrame.editBox:SetText(text)
self.EditFrame.acceptButton:SetScript("OnClick", function()
acceptFunc()
E:ToggleOptionsUI()
self.EditFrame:Hide()
end)
end
E:ToggleOptionsUI()
end
function core:Tag(name, tagfunc, updatefunc)
if tagfunc and not next(nameUpdates) then
ElvUF.Tags.Events["updateshandler"] = "UNIT_NAME_UPDATE"
ElvUF.Tags.Methods["updateshandler"] = function(unit)
local frame = UF[unit]
local guid = UnitGUID(unit)
if frame and guid ~= frame.lastGUID then
if frame.ThreatIndicator and (frame.db.threatStyle == 'BORDERS' or frame.db.threatStyle == 'HEALTHBORDERS') then
local status = UnitThreatSituation(unit)
frame.ThreatIndicator:PostUpdate(unit, status, GetThreatStatusColor(status))
end
for _, auraType in ipairs({'Buffs', 'Debuffs'}) do
if frame[auraType] and frame[auraType].db.enable and frame[auraType].PostUpdate then
frame[auraType]:PostUpdate()
end
end
for _, func in pairs(nameUpdates) do
func(nil, frame, unit)
end
frame.lastGUID = guid
end
end
end
nameUpdates[name] = tagfunc
if updatefunc and not next(frameUpdates) then
for _, frame in ipairs(self:AggregateUnitFrames()) do
local type_db = E.db.unitframe.units[frame.unitframeType]
if type_db and type_db.enable then
if not taggedFrames[frame] then
frame.updatesHandler = frame:CreateFontString(nil, "OVERLAY")
frame.updatesHandler:FontTemplate()
frame:Tag(frame.updatesHandler, "[updateshandler]")
taggedFrames[frame] = true
end
end
end
for frameType in pairs(self:getAllFrameTypes()) do
local type_db = E.db.unitframe.units[frameType]
if type_db and type_db.enable then
local frameTypeCapital = gsub(gsub(frameType, "target", "Target"), "^(.)", function(firstLetter) return upper(firstLetter) end)
local func = "Update_"..frameTypeCapital.."Frame"
local groupFunc = "Update_"..frameTypeCapital.."Frames"
if (UF[func] or UF[groupFunc]) and not self:IsHooked(UF, UF[func] and func or groupFunc) then
self:SecureHook(UF, UF[func] and func or groupFunc, function(self, frame, ...)
if not taggedFrames[frame] then
frame.updatesHandler = frame:CreateFontString(nil, "OVERLAY")
frame.updatesHandler:FontTemplate()
frame:Tag(frame.updatesHandler, "[updateshandler]")
taggedFrames[frame] = true
end
for _, updateFunc in pairs(frameUpdates) do
updateFunc(self, frame, ...)
end
end)
end
end
end
end
frameUpdates[name] = updatefunc
end
function core:Untag(name)
nameUpdates[name] = nil
if not next(nameUpdates) then
ElvUF.Tags.Events["updateshandler"] = nil
ElvUF.Tags.Methods["updateshandler"] = nil
end
frameUpdates[name] = nil
if not next(frameUpdates) then
for _, frame in ipairs({self:AggregateUnitFrames()}) do
if taggedFrames[frame] then
frame.updatesHandler:Hide()
frame.updatesHandler = nil
taggedFrames[frame] = nil
end
end
for frameType in pairs(self:getAllFrameTypes()) do
if E.db.unitframe.units[frameType] then
local frameTypeCapital = gsub(gsub(frameType, "target", "Target"), "^(.)", function(firstLetter) return upper(firstLetter) end)
local func = "Update_"..frameTypeCapital.."Frame"
local groupFunc = "Update_"..frameTypeCapital.."Frames"
if (UF[func] or UF[groupFunc]) and self:IsHooked(UF, UF[func] and func or groupFunc) then
self:Unhook(UF, UF[func] and func or groupFunc)
end
end
end
end
end
function core:RegisterAreaUpdate(name, func)
if func then
if not next(areaUpdates) then
for _, event in ipairs({"PLAYER_UPDATE_RESTING", "ZONE_CHANGED_NEW_AREA"}) do
self:RegisterEvent(event, function(...)
for _, f in pairs(areaUpdates) do
f(...)
end
end)
end
end
areaUpdates[name] = func
else
areaUpdates[name] = nil
if not next(areaUpdates) then
for _, event in ipairs({"PLAYER_UPDATE_RESTING", "ZONE_CHANGED_NEW_AREA"}) do
self:UnregisterEvent(event)
end
end
end
end
function core:GetCurrentAreaType()
local areaType
if IsResting() then
areaType = "showCity"
else
local _, instanceType = IsInInstance()
if instanceType == "pvp" then
areaType = "showBG"
elseif instanceType == "arena" then
areaType = "showArena"
elseif instanceType == "party" or instanceType == "raid" then
areaType = "showInstance"
else
areaType = "showWorld"
end
end
return areaType
end
P["Extras"] = {
["pluginColor"] = '|cffaf73cd',
["customColorBad"] = '|cffce1a1a',
["customColorAlpha"] = '|cff9999ff',
["customColorBeta"] = '|cffff8c00',
["classList"] = {
["WARRIOR"] = L['Warrior'],
["WARLOCK"] = L['Warlock'],
["PRIEST"] = L['Priest'],
["PALADIN"] = L['Paladin'],
["DRUID"] = L['Druid'],
["ROGUE"] = L['Rogue'],
["MAGE"] = L['Mage'],
["HUNTER"] = L['Hunter'],
["SHAMAN"] = L['Shaman'],
["DEATHKNIGHT"] = L['Deathknight']
},
["modifiers"] = {
["ANY"] = L['Any'],
["Alt"] = 'ALT',
["Shift"] = 'SHIFT',
["Control"] = 'CTRL',
},
["frameStrata"] = {
["BACKGROUND"] = 'BACKGROUND',
["LOW"] = 'LOW',
["MEDIUM"] = 'MEDIUM',
["HIGH"] = 'HIGH',
["DIALOG"] = 'DIALOG',
["FULLSCREEN"] = 'FULLSCREEN',
["FULLSCREEN_DIALOG"] = 'FULLSCREEN_DIALOG',
["TOOLTIP"] = 'TOOLTIP',
},
["pointOptions"] = {
["TOP"] = 'TOP',
["BOTTOM"] = 'BOTTOM',
["LEFT"] = 'LEFT',
["RIGHT"] = 'RIGHT',
["CENTER"] = 'CENTER',
["TOPLEFT"] = 'TOPLEFT',
["TOPRIGHT"] = 'TOPRIGHT',
["BOTTOMLEFT"] = 'BOTTOMLEFT',
["BOTTOMRIGHT"] = 'BOTTOMRIGHT',
},
["texClass"] = {
["Interface\\Icons\\spell_deathknight_classicon"] = {
["icon"] = 'Interface\\Icons\\spell_deathknight_classicon',
["label"] = 'Death Knight',
},
["Interface\\Icons\\inv_misc_monsterclaw_04"] = {
["icon"] = 'Interface\\Icons\\inv_misc_monsterclaw_04',
["label"] = 'Druid',
},
["Interface\\Icons\\inv_weapon_bow_07"] = {
["icon"] = 'Interface\\Icons\\inv_weapon_bow_07',
["label"] = 'Hunter',
},
["Interface\\Icons\\inv_staff_13"] = {
["icon"] = 'Interface\\Icons\\inv_staff_13',
["label"] = 'Mage',
},
["Interface\\Icons\\inv_hammer_01"] = {
["icon"] = 'Interface\\Icons\\inv_hammer_01',
["label"] = 'Paladin',
},
["Interface\\Icons\\inv_staff_30"] = {
["icon"] = 'Interface\\Icons\\inv_staff_30',
["label"] = 'Priest',
},
["Interface\\Icons\\inv_throwingknife_04"] = {
["icon"] = 'Interface\\Icons\\inv_throwingknife_04',
["label"] = 'Rogue',
},
["Interface\\Icons\\inv_jewelry_talisman_04"] = {
["icon"] = 'Interface\\Icons\\inv_jewelry_talisman_04',
["label"] = 'Shaman',
},
["Interface\\Icons\\spell_nature_drowsy"] = {
["icon"] = 'Interface\\Icons\\spell_nature_drowsy',
["label"] = 'Warlock',
},
["Interface\\Icons\\inv_sword_27"] = {
["icon"] = 'Interface\\Icons\\inv_sword_27',
["label"] = 'Warrior',
},
},
["texClassVector"] = {
["Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_deathknight"] = {
["icon"] = 'Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_deathknight',
["label"] = 'Death Knight',
},
["Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_druid"] = {
["icon"] = 'Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_druid',
["label"] = 'Druid',
},
["Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_hunter"] = {
["icon"] = 'Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_hunter',
["label"] = 'Hunter',
},
["Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_mage"] = {
["icon"] = 'Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_mage',
["label"] = 'Mage',
},
["Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_paladin"] = {
["icon"] = 'Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_paladin',
["label"] = 'Paladin',
},
["Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_priest"] = {
["icon"] = 'Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_priest',
["label"] = 'Priest',
},
["Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_rogue"] = {
["icon"] = 'Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_rogue',
["label"] = 'Rogue',
},
["Interface\\AddOns\\ElvUI_Extras\\Media\\Class\\wow_flat_shaman"] = {