forked from Aviana/LunaUnitFrames
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LunaUnitFrames.lua
1361 lines (1246 loc) · 44.2 KB
/
LunaUnitFrames.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
-- Luna Unit Frames 4.0 by Aviana
LUF = select(2, ...)
LUF.version = 4060
local L = LUF.L
local ACR = LibStub("AceConfigRegistry-3.0", true)
local SML = LibStub:GetLibrary("LibSharedMedia-3.0")
local oUF = LUF.oUF
-- Disable oUFs Anti Blizzard function since we make our own
oUF.DisableBlizzard = function() end
LUF.frameIndex = {}
L.player = PLAYER
L.pet = PET
L.target = TARGET
L.party = PARTY
L.raid = RAID
L.maintank = MAINTANK
L.mainassist = MAIN_ASSIST
LUF.stateMonitor = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate")
LUF.stateMonitor:WrapScript(LUF.stateMonitor, "OnAttributeChanged", [[
if( name == "partyEnabled" or name == "partytargetEnabled" or name == "partypetEnabled" ) then return end
local partyFrame = self:GetFrameRef("partyFrame")
local partytargetFrame = self:GetFrameRef("partytargetFrame")
local partypetFrame = self:GetFrameRef("partypetFrame")
local status = self:GetAttribute("state-raidstatus")
local setting = self:GetAttribute("hideraid")
local showParty = setting == "never" or status ~= "full" and setting == "5man" or setting == "always" and status == "none"
if partyFrame and self:GetAttribute("partyEnabled") then
partyFrame:SetAttribute("raidHidden", not showParty)
if showParty then
partyFrame:Show()
else
partyFrame:Hide()
end
end
if partytargetFrame and self:GetAttribute("partytargetEnabled") then
partytargetFrame:SetAttribute("raidHidden", not showParty)
if showParty then
partytargetFrame:Show()
else
partytargetFrame:Hide()
end
end
if partypetFrame and self:GetAttribute("partypetEnabled") then
partypetFrame:SetAttribute("raidHidden", not showParty)
if showParty then
partypetFrame:Show()
else
partypetFrame:Hide()
end
end
]])
LUF.unitList = {
"player",
"pet",
"pettarget",
"pettargettarget",
"target",
"targettarget",
"targettargettarget",
"party",
"partytarget",
"partypet",
"raid",
"raidpet",
"maintank",
"maintanktarget",
"maintanktargettarget",
"mainassist",
"mainassisttarget",
"mainassisttargettarget",
}
LUF.fakeUnits = {
["targettarget"] = true,
["targettargettarget"] = true,
["pettarget"] = true,
["pettargettarget"] = true,
["partytarget"] = true,
["maintanktarget"] = true,
["maintanktargettarget"] = true,
["mainassisttarget"] = true,
["mainassisttargettarget"] = true
}
LUF.HeaderFrames = {
["party"] = true,
["partytarget"] = true,
["partypet"] = true,
["raid"] = true,
["raidpet"] = true,
["maintank"] = true,
["maintanktarget"] = true,
["maintanktargettarget"] = true,
["mainassist"] = true,
["mainassisttarget"] = true,
["mainassisttargettarget"] = true,
}
function LUF:Print(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cFF2150C2LunaUnitFrames|cFFFFFFFF: ".. msg)
end
function LUF:LoadoUFSettings()
self.oUF.LUF_fakePlayerClassification = self.db.profile.units.player.indicators.elite.enabled and self.db.profile.units.player.indicators.elite.type or nil
self.oUF.LUF_fakePetClassification = self.db.profile.units.pet.indicators.elite.enabled and self.db.profile.units.pet.indicators.elite.type or nil
local colors = self.db.profile.colors
self.oUF.colors.smooth = { colors.red.r, colors.red.g, colors.red.b, colors.yellow.r, colors.yellow.g, colors.yellow.b, colors.green.r, colors.green.g, colors.green.b }
self.oUF.colors.health = {colors.static.r, colors.static.g, colors.static.b}
self.oUF.colors.disconnected = {colors.offline.r, colors.offline.g, colors.offline.b}
self.oUF.colors.tapped = {colors.tapped.r, colors.tapped.g, colors.tapped.b}
self.oUF.colors.civilian = {colors.enemyCivilian.r, colors.enemyCivilian.g, colors.enemyCivilian.b}
self.oUF.colors.class.HUNTER = {colors.HUNTER.r, colors.HUNTER.g, colors.HUNTER.b}
self.oUF.colors.class.WARLOCK = {colors.WARLOCK.r, colors.WARLOCK.g, colors.WARLOCK.b}
self.oUF.colors.class.PRIEST = {colors.PRIEST.r, colors.PRIEST.g, colors.PRIEST.b}
self.oUF.colors.class.PALADIN = {colors.PALADIN.r, colors.PALADIN.g, colors.PALADIN.b}
self.oUF.colors.class.MAGE = {colors.MAGE.r, colors.MAGE.g, colors.MAGE.b}
self.oUF.colors.class.ROGUE = {colors.ROGUE.r, colors.ROGUE.g, colors.ROGUE.b}
self.oUF.colors.class.DRUID = {colors.DRUID.r, colors.DRUID.g, colors.DRUID.b}
self.oUF.colors.class.SHAMAN = {colors.SHAMAN.r, colors.SHAMAN.g, colors.SHAMAN.b}
self.oUF.colors.class.WARRIOR = {colors.WARRIOR.r, colors.WARRIOR.g, colors.WARRIOR.b}
self.oUF.colors.power.MANA = {colors.MANA.r, colors.MANA.g, colors.MANA.b}
self.oUF.colors.power[0] = self.oUF.colors.power.MANA
self.oUF.colors.power.RAGE = {colors.RAGE.r, colors.RAGE.g, colors.RAGE.b}
self.oUF.colors.power[1] = self.oUF.colors.power.RAGE
self.oUF.colors.power.FOCUS = {colors.FOCUS.r, colors.FOCUS.g, colors.FOCUS.b}
self.oUF.colors.power[2] = self.oUF.colors.power.FOCUS
self.oUF.colors.power.ENERGY = {colors.ENERGY.r, colors.ENERGY.g, colors.ENERGY.b}
self.oUF.colors.power[3] = self.oUF.colors.power.ENERGY
self.oUF.colors.power.COMBO_POINTS = {colors.COMBOPOINTS.r, colors.COMBOPOINTS.g, colors.COMBOPOINTS.b}
self.oUF.colors.power[4] = self.oUF.colors.power.COMBOPOINTS
self.oUF.colors.happiness[1] = {colors.unhappy.r, colors.unhappy.g, colors.unhappy.b}
self.oUF.colors.happiness[2] = {colors.content.r, colors.content.g, colors.content.b}
self.oUF.colors.happiness[3] = {colors.happy.r, colors.happy.g, colors.happy.b}
self.oUF.colors.reaction[1] = {colors.hated.r, colors.hated.g, colors.hated.b}
self.oUF.colors.reaction[2] = {colors.hostile.r, colors.hated.g, colors.hated.b}
self.oUF.colors.reaction[3] = {colors.unfriendly.r, colors.unfriendly.g, colors.unfriendly.b}
self.oUF.colors.reaction[4] = {colors.neutral.r, colors.neutral.g, colors.neutral.b}
self.oUF.colors.reaction[5] = {colors.friendly.r, colors.friendly.g, colors.friendly.b}
self.oUF.colors.reaction[6] = {colors.honored.r, colors.honored.g, colors.honored.b}
self.oUF.colors.reaction[7] = {colors.revered.r, colors.revered.g, colors.revered.b}
self.oUF.colors.reaction[8] = {colors.exalted.r, colors.exalted.g, colors.exalted.b}
self.oUF.colors.threat[1] = self.oUF.colors.reaction[8]
self.oUF.colors.threat[2] = self.oUF.colors.reaction[4]
self.oUF.colors.threat[3] = self.oUF.colors.reaction[2]
self.oUF.colors.threat[4] = self.oUF.colors.reaction[1]
self.oUF.TagsWithHealTimeFrame = self.db.profile.inchealTime
self.oUF.TagsWithHealDisableHots = self.db.profile.disablehots
end
function LUF:ResetColors()
for name, color in pairs(LUF.db.profile.colors) do
local default = LUF.defaults.profile.colors[name]
color.r = default.r
color.g = default.g
color.b = default.b
color.a = default.a
end
ACR:NotifyChange("LunaUnitFrames")
self:LoadoUFSettings()
self:ReloadAll()
end
function LUF:OnLoad()
self:LoadDefaults()
-- Initialize DB
self.db = LibStub:GetLibrary("AceDB-3.0"):New("LunaUFDB", self.defaults, true)
self.db.RegisterCallback(self, "OnProfileChanged", "ProfilesChanged")
self.db.RegisterCallback(self, "OnProfileCopied", "ProfilesChanged")
self.db.RegisterCallback(self, "OnProfileReset", "ProfileReset")
self.db.RegisterCallback(self, "OnProfileDeleted", "OnProfileDeleted")
self.db.profile.version = self.version
SML.RegisterCallback(self, "LibSharedMedia_Registered", "MediaRegistered")
SML.RegisterCallback(self, "LibSharedMedia_SetGlobal", "MediaForced")
self:LoadoUFSettings()
self:SpawnUnits()
self:HideBlizzardFrames()
self:CreateConfig()
self:UpdateMovers()
self:PlaceAllFrames()
self:AutoswitchProfileSetup()
if self.db.global.switchtype == "RESOLUTION" then
self:AutoswitchProfile("DISPLAY_SIZE_CHANGED")
elseif self.db.global.switchtype == "GROUP" then
self:AutoswitchProfile("GROUP_ROSTER_UPDATE")
end
end
local mediaNeeded = {}
function LUF:LoadMedia(type, name)
local mediaName = name or self.db.profile[type]
local media = SML:Fetch(type, mediaName or SML.DefaultMedia[type], true)
if( not media ) then
mediaNeeded[type] = mediaName
return SML:Fetch(type, SML.DefaultMedia[type], true)
end
return media
end
function LUF:MediaRegistered(event, mediaType, key)
if( mediaNeeded[mediaType] == key ) then
mediaNeeded[mediaType] = nil
self:ReloadAll()
end
end
function LUF:MediaForced(mediaType)
self:ReloadAll()
end
function LUF:ProfilesChanged()
if( resetTimer ) then resetTimer:Hide() end
self.db:RegisterDefaults(self.defaults)
-- No active layout, register the default one
if( not self.db.profile.loadedLayout ) then
self:LoadDefaults()
end
self:LoadoUFSettings()
self:HideBlizzardFrames()
self:ReloadAll()
self:SetupAllHeaders()
self:UpdateMovers()
self:PlaceAllFrames()
end
local resetTimer
function LUF:ProfileReset()
self:Print("The Profile was reset!")
if( not resetTimer ) then
resetTimer = CreateFrame("Frame")
resetTimer:SetScript("OnUpdate", function(self)
LUF:ProfilesChanged()
self:Hide()
end)
end
resetTimer:Show()
end
function LUF:OnProfileDeleted(event, key, name)
-- Remove deleted profiles from autoswitching
if self.db.global.resdb then
for k,v in pairs(self.db.global.resdb) do
if v == name then
self.db.global.resdb[k] = nil
end
end
end
if self.db.global.grpdb then
for k,v in pairs(self.db.global.grpdb) do
if v == name then
self.db.global.grpdb[k] = nil
end
end
end
end
function LUF:AutoswitchProfile(event)
local profile
if event == "DISPLAY_SIZE_CHANGED" then
local resolutions = {GetScreenResolutions()}
profile = self.db.char.resdb[resolutions[GetCurrentResolution()]]
else
local groupType
if IsInRaid() then
local maxGrp = 1
for i=1,MAX_RAID_MEMBERS do
maxGrp = math.max((select(3,GetRaidRosterInfo(i)) or 0),maxGrp)
end
if maxGrp == 1 then
groupType = "RAID5"
elseif maxGrp == 2 then
groupType = "RAID10"
elseif maxGrp == 3 then
groupType = "RAID15"
elseif maxGrp == 4 then
groupType = "RAID20"
else
groupType = "RAID40"
end
elseif IsInGroup() then
groupType = "PARTY"
else
groupType = "SOLO"
end
profile = self.db.char.grpdb[groupType]
end
if profile and profile ~= self.db:GetCurrentProfile() then
self.db:SetProfile(profile)
end
end
local hiddenParent = CreateFrame("Frame", nil, UIParent)
hiddenParent:SetAllPoints()
hiddenParent:Hide()
local function handleFrame(baseName)
local frame
if(type(baseName) == "string") then
frame = _G[baseName]
else
frame = baseName
end
if(frame) then
frame:UnregisterAllEvents()
frame:Hide()
frame:SetParent(hiddenParent)
local health = frame.healthBar or frame.healthbar
if(health) then
health:UnregisterAllEvents()
end
local power = frame.manabar
if(power) then
power:UnregisterAllEvents()
end
local spell = frame.castBar or frame.spellbar
if(spell) then
spell:UnregisterAllEvents()
end
local altpowerbar = frame.powerBarAlt
if(altpowerbar) then
altpowerbar:UnregisterAllEvents()
end
local buffFrame = frame.BuffFrame
if(buffFrame) then
buffFrame:UnregisterAllEvents()
end
end
end
local active_hiddens = {
}
function LUF:HideBlizzardFrames()
if( self.db.profile.hidden.cast ) then
handleFrame(CastingBarFrame)
active_hiddens.cast = true
elseif( not self.db.profile.hidden.cast and not active_hiddens.cast ) then
CastingBarFrame_OnLoad(CastingBarFrame, "player", true, false) --restore castbar as oUF kills it
end
if( CompactRaidFrameManager ) then
if( self.db.profile.hidden.raid and not active_hiddens.raid ) then
active_hiddens.raid = true
local function hideRaid()
CompactRaidFrameManager:UnregisterAllEvents()
CompactRaidFrameContainer:UnregisterAllEvents()
if( InCombatLockdown() ) then return end
CompactRaidFrameManager:Hide()
local shown = CompactRaidFrameManager_GetSetting("IsShown")
if( shown and shown ~= "0" ) then
CompactRaidFrameManager_SetSetting("IsShown", "0")
end
end
hooksecurefunc("CompactRaidFrameManager_UpdateShown", function()
if( self.db.profile.hidden.raid ) then
hideRaid()
end
end)
hideRaid()
CompactRaidFrameContainer:HookScript("OnShow", hideRaid)
CompactRaidFrameManager:HookScript("OnShow", hideRaid)
end
end
if( self.db.profile.hidden.buffs and not active_hiddens.buffs ) then
BuffFrame:UnregisterAllEvents()
BuffFrame:Hide()
TemporaryEnchantFrame:UnregisterAllEvents()
TemporaryEnchantFrame:Hide()
TemporaryEnchantFrame_Hide()
end
if( self.db.profile.hidden.player and not active_hiddens.player ) then
handleFrame(PlayerFrame)
end
if( self.db.profile.hidden.pet and not active_hiddens.pet ) then
handleFrame(PetFrame)
end
if( self.db.profile.hidden.target and not active_hiddens.target ) then
handleFrame(TargetFrame)
handleFrame(ComboFrame)
handleFrame(TargetFrameToT)
end
if( self.db.profile.hidden.party and not active_hiddens.party ) then
for i = 1, MAX_PARTY_MEMBERS do
handleFrame(string.format("PartyMemberFrame%d", i))
end
end
-- As a reload is required to reset the hidden hooks, we can just set this to true if anything is true
for type, flag in pairs(self.db.profile.hidden) do
if( flag ) then
active_hiddens[type] = true
end
end
end
local moduleSettings = {
healthBar = function(mod, config)
mod.texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
mod:SetStatusBarTexture(LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar))
if config.background or config.invert then
mod.bg:SetTexture(mod.texture)
mod.bg:Show()
mod.bg:SetAlpha(config.invert and 1 or config.backgroundAlpha)
else
mod.bg:Hide()
end
mod.colorHappiness = config.colorType == "happiness"
mod.colorClass = config.colorType == "class"
mod.colorReaction = config.reactionType ~= "none" and config.reactionType
mod.colorSmooth = config.colorType == "percent"
mod.colorInvert = config.invert
mod:SetOrientation(config.vertical and "VERTICAL" or "HORIZONTAL")
if mod.__owner.unit == "pet" then
if config.enabled then
mod.__owner:RegisterEvent("UNIT_HAPPINESS", LUF.overrides["Health"].UpdateColor) -- Fix for bug in oUF not updating
else
mod.__owner:UnregisterEvent("UNIT_HAPPINESS", LUF.overrides["Health"].UpdateColor)
end
end
end,
powerBar = function(mod, config)
mod.texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
mod:SetStatusBarTexture(LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar))
if config.background then
mod.bg:SetTexture(mod.texture)
mod.bg:Show()
mod.bg:SetAlpha(config.backgroundAlpha)
else
mod.bg:Hide()
end
mod.colorClass = config.colorType == "class"
mod.colorClassNPC = config.colorType == "class"
mod.colorPower = config.colorType == "type"
mod:SetOrientation(config.vertical and "VERTICAL" or "HORIZONTAL")
end,
castBar = function(mod, config)
mod.texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
mod:SetStatusBarTexture(LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar))
if config.background then
mod.bg:SetTexture(mod.texture)
mod.bg:SetVertexColor(1, 1, 1)
mod.bg:Show()
mod.bg:SetAlpha(config.backgroundAlpha)
else
mod.bg:Hide()
end
if config.icon == "HIDE" then
mod.Icon:Hide()
else
mod.Icon:Show()
mod.Icon:ClearAllPoints()
if config.icon == "LEFT" then
mod.Icon:SetPoint("RIGHT", mod, "LEFT")
else
mod.Icon:SetPoint("LEFT", mod, "RIGHT")
end
end
end,
emptyBar = function(mod, config)
mod.texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
mod:SetStatusBarTexture(LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar))
mod.alpha = config.alpha
mod.colorReaction = config.reactionType ~= "none" and config.reactionType
mod.colorClass = config.class
mod:SetOrientation(config.vertical and "VERTICAL" or "HORIZONTAL")
end,
comboPoints = function(mod, config)
local texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
for i=1, 5 do
local point = mod.ComboPoints[i]
point:SetStatusBarTexture(texture)
point.bg:SetTexture(texture)
point.bg:SetAlpha(config.backgroundAlpha)
if config.background then
point.bg:Show()
else
point.bg:Hide()
end
end
mod.autoHide = config.autoHide
mod.growth = config.growth
mod:Update()
end,
totemBar = function(mod, config)
local texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
local totemColors = {
[1] = {1,0,0},
[2] = {0.78,0.61,0.43},
[3] = {0,0,1},
[4] = {0.41,0.8,0.94},
}
for i=1, 4 do
local totem = mod.Totems[i]
totem:SetStatusBarTexture(texture)
totem:SetStatusBarColor(unpack(totemColors[i]))
totem.bg:SetTexture(texture)
totem.bg:SetVertexColor(unpack(totemColors[i]))
totem.bg:SetAlpha(config.backgroundAlpha)
if config.background then
totem.bg:Show()
else
totem.bg:Hide()
end
end
mod.autoHide = config.autoHide
mod:Update()
end,
druidBar = function(mod, config)
mod.texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
mod:SetStatusBarTexture(LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar))
if config.background then
mod.bg:SetTexture(mod.texture)
mod.bg:Show()
mod.bg:SetAlpha(config.backgroundAlpha)
else
mod.bg:Hide()
end
mod:SetOrientation(config.vertical and "VERTICAL" or "HORIZONTAL")
end,
reckStacks = function(mod, config)
local texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
local color = LUF.db.profile.colors.COMBOPOINTS
for i=1, 4 do
local point = mod.Reckoning[i]
point:SetStatusBarTexture(texture)
point:SetStatusBarColor(color.r, color.g, color.b)
point.bg:SetTexture(texture)
point.bg:SetVertexColor(color.r, color.g, color.b)
point.bg:SetAlpha(config.backgroundAlpha)
if config.background then
point.bg:Show()
else
point.bg:Hide()
end
end
mod.autoHide = config.autoHide
mod.growth = config.growth
mod:Update()
end,
xpBar = function(mod, config)
if not config.enabled then mod:Hide() return end
local texture = LUF:LoadMedia(SML.MediaType.STATUSBAR, config.statusbar)
mod:GetParent()[mod.name].tooltip = config.mouse
mod.xpBar:SetStatusBarTexture(texture)
mod.xpBar.rested:SetStatusBarTexture(texture)
mod.xpBar:SetAlpha(config.alpha)
local normal = LUF.db.profile.colors.normal
mod.xpBar:SetStatusBarColor(normal.r, normal.g, normal.b)
local rested = LUF.db.profile.colors.rested
mod.xpBar.rested:SetStatusBarColor(rested.r, rested.g, rested.b)
if mod.repBar then
mod.repBar:SetStatusBarTexture(texture)
mod.repBar:SetAlpha(config.alpha)
end
if config.background then
mod.xpBar.bg:SetTexture(texture)
mod.xpBar.bg:Show()
mod.xpBar.bg:SetAlpha(config.backgroundAlpha)
if mod.repBar then
mod.repBar.bg:SetTexture(texture)
mod.repBar.bg:Show()
mod.repBar.bg:SetAlpha(config.backgroundAlpha)
end
else
mod.xpBar.bg:Hide()
if mod.repBar then
mod.repBar.bg:Hide()
end
end
end,
}
local fstringoffsets = { left = 3, center = 0, right = -3 }
function LUF.ApplySettings(frame)
local config = LUF.db.profile.units[frame:GetAttribute("oUF-guessUnit")]
-- Background
local bgColor = LUF.db.profile.colors.background
frame.bg:SetVertexColor(bgColor.r, bgColor.g, bgColor.b, bgColor.a)
-- Bars
for barname,barobj in pairs(frame.modules) do
if moduleSettings[barname] then
moduleSettings[barname](barobj, config[barname])
end
end
-- Portrait
if frame.StatusPortrait then
frame.StatusPortrait.showStatus = config.portrait.showStatus
frame.StatusPortrait.verbosePortraitIcon = config.portrait.verboseStatus
frame.StatusPortrait.type = config.portrait.type
end
-- Regen Ticker
if frame.RegenTicker then
if (config.powerBar.ticker or config.powerBar.fivesecond) and select(2, UnitClass("player")) ~= "WARRIOR" then
frame:EnableElement("RegenTicker")
frame.RegenTicker.hideTicks = not config.powerBar.ticker
frame.RegenTicker.hideFive = not config.powerBar.fivesecond
frame.RegenTicker.autoHide = config.powerBar.hideticker
frame.RegenTicker.vertical = config.powerBar.vertical
else
frame:DisableElement("RegenTicker")
end
end
-- Additional Regen Ticker
if frame.AdditionalRegenTicker then
if (config.druidBar.ticker or config.druidBar.fivesecond) then
frame:EnableElement("RegenTickerAlt")
frame.AdditionalRegenTicker.hideTicks = not config.druidBar.ticker
frame.AdditionalRegenTicker.hideFive = not config.druidBar.fivesecond
frame.AdditionalRegenTicker.autoHide = config.druidBar.hideticker
frame.AdditionalRegenTicker.vertical = config.druidBar.vertical
else
frame:DisableElement("RegenTickerAlt")
end
end
-- Power Prediction
if frame.PowerPrediction then
if config.manaPrediction.enabled then
frame:EnableElement("PowerPrediction")
local predColor = config.manaPrediction.color
frame.PowerPrediction.mainBar:SetStatusBarColor(predColor.r, predColor.g, predColor.b)
frame.PowerPrediction.mainBar:SetAlpha(predColor.a)
else
frame:DisableElement("PowerPrediction")
end
end
-- Tags
for barname,fstrings in pairs(frame.tags) do
for side,fstring in pairs(fstrings) do
fstring:ClearAllPoints()
if frame.modules[barname] then
fstring:SetPoint(strupper(side), frame.modules[barname], strupper(side), fstringoffsets[side], config.tags[barname][side].offset or 0)
elseif barname == "top" then
if side ~= "center" then
fstring:SetPoint("BOTTOM"..strupper(side), frame, "TOP"..strupper(side), fstringoffsets[side], config.tags[barname][side].offset or 0)
else
fstring:SetPoint("BOTTOM", frame, "TOP", fstringoffsets[side], config.tags[barname][side].offset or 0)
end
else
if side ~= "center" then
fstring:SetPoint("TOP"..strupper(side), frame, "BOTTOM"..strupper(side), fstringoffsets[side], config.tags[barname][side].offset or 0)
else
fstring:SetPoint("TOP", frame, "BOTTOM", fstringoffsets[side], config.tags[barname][side].offset or 0)
end
end
fstring:SetFont(LUF:LoadMedia(SML.MediaType.FONT, config.tags[barname].font), config.tags[barname].size)
fstring:SetShadowColor(0, 0, 0, 1.0)
fstring:SetShadowOffset(0.80, -0.80)
frame:Tag(fstring, config.tags[barname][side].tagline)
end
end
-- Indicators
for iname,iobj in pairs(frame.indicators) do
local objconfig = config.indicators[iname]
local objdata = LUF.IndicatorData[iname]
if objconfig.enabled then
frame:EnableElement(objdata.name)
if iname ~= "elite" then
iobj:ClearAllPoints()
iobj:SetPoint("CENTER", frame, objconfig.anchorPoint, objconfig.x, objconfig.y )
iobj:SetSize(objconfig.size, objconfig.size)
else
iobj.side = objconfig.side
end
else
frame:DisableElement(objdata.name)
end
end
-- Range
if frame.Range then
if config.range.enabled then
frame.Range.range = LUF.db.profile.range.dist
frame.Range.outsideAlpha = LUF.db.profile.range.alpha
frame:EnableElement("Range")
else
frame:DisableElement("Range")
end
end
-- Combat Fader
if frame.SimpleFader then
if config.fader.enabled then
frame.SimpleFader.combatAlpha = config.fader.combatAlpha
frame.SimpleFader.inactiveAlpha = config.fader.inactiveAlpha
frame.SimpleFader.fastFade = config.fader.speedyFade
frame:EnableElement("SimpleFader")
else
frame:DisableElement("SimpleFader")
end
end
-- Auras
if config.auras.buffs or config.auras.weaponbuffs or config.auras.debuffs then
frame:EnableElement("SimpleAuras")
local Auras = frame.SimpleAuras
local AuraConfig = config.auras
Auras.weapons = AuraConfig.weaponbuffs
Auras.buffs = AuraConfig.buffs
Auras.buffAnchor = AuraConfig.buffpos
Auras.buffFilter = AuraConfig.filterbuffs
Auras.buffSize = AuraConfig.buffsize
Auras.largeBuffSize = AuraConfig.enlargedbuffsize
Auras.wrapBuffSide = AuraConfig.wrapbuffside
Auras.wrapBuff = AuraConfig.wrapbuff
Auras.debuffs = AuraConfig.debuffs
Auras.debuffAnchor = AuraConfig.debuffpos
Auras.debuffFilter = AuraConfig.filterdebuffs
Auras.debuffSize = AuraConfig.debuffsize
Auras.largeDebuffSize = AuraConfig.enlargeddebuffsize
Auras.wrapDebuffSide = AuraConfig.wrapdebuffside
Auras.wrapDebuff = AuraConfig.wrapdebuff
Auras.timer = AuraConfig.timer
Auras.spacing = AuraConfig.padding
Auras.forceShow = LUF.db.profile.previewauras and not LUF.db.profile.locked
Auras.showType = AuraConfig.bordercolor
Auras.disableOCC = LUF.db.profile.omnicc
Auras.disableBCC = LUF.db.profile.blizzardcc
local auraborderType = LUF.db.profile.auraborderType
Auras.overlay = auraborderType and auraborderType ~= "blizzard" and "Interface\\AddOns\\LunaUnitFrames\\media\\textures\\borders\\border-" .. auraborderType
else
frame:DisableElement("SimpleAuras")
end
-- Combat Text
if frame.CombatText then
frame.CombatText.feedbackFontHeight = config.combatText.size
frame.CombatText.font = LUF:LoadMedia(SML.MediaType.FONT, config.combatText.font)
if config.combatText.enabled then
frame:EnableElement("CombatText")
frame.CombatText:ClearAllPoints()
if config.portrait.enabled and config.portrait.alignment ~= "CENTER" then
frame.CombatText:SetAllPoints(frame.StatusPortrait.model)
else
frame.CombatText:SetAllPoints(frame)
end
else
frame:DisableElement("CombatText")
end
end
-- Highlight
if frame.Highlight then
local target, mouseover, aggro, debuff = config.highlight.target, config.highlight.mouseover, config.highlight.aggro, config.highlight.debuff
if target or mouseover or aggro or debuff ~=1 then
frame:EnableElement("Highlight")
frame.Highlight.target = target
frame.Highlight.mouseover = mouseover
frame.Highlight.aggro = aggro
frame.Highlight.debuff = debuff
frame.Highlight.mouseoverColor = {LUF.db.profile.colors.mouseover.r, LUF.db.profile.colors.mouseover.g, LUF.db.profile.colors.mouseover.b}
frame.Highlight.targetColor = {LUF.db.profile.colors.target.r, LUF.db.profile.colors.target.g, LUF.db.profile.colors.target.b}
else
frame:DisableElement("Highlight")
end
end
-- Border Highlight
if frame.BorderHighlight then
local target, mouseover, aggro, debuff = config.borders.target, config.borders.mouseover, config.borders.aggro, config.borders.debuff
if target or mouseover or aggro or debuff ~=1 then
frame:EnableElement("BorderHighlight")
frame.BorderHighlight.target = target
frame.BorderHighlight.mouseover = mouseover
frame.BorderHighlight.aggro = aggro
frame.BorderHighlight.debuff = debuff
frame.BorderHighlight.mouseoverColor = {LUF.db.profile.colors.mouseover.r, LUF.db.profile.colors.mouseover.g, LUF.db.profile.colors.mouseover.b}
frame.BorderHighlight.targetColor = {LUF.db.profile.colors.target.r, LUF.db.profile.colors.target.g, LUF.db.profile.colors.target.b}
frame.BorderHighlight.size = config.borders.size
else
frame:DisableElement("BorderHighlight")
end
end
--Squares
if frame.RaidStatusIndicators then
local isEnabled
for name in pairs(LUF.defaults.profile.units.player.squares) do
local indicator = frame.RaidStatusIndicators[name]
local squarecfg = config.squares
if squarecfg[name].enabled then
isEnabled = true
indicator.type = squarecfg[name].type
indicator.showTexture = squarecfg[name].texture
indicator.timer = squarecfg[name].timer
if indicator.type == "missing" then
indicator.nameID = {}
for i,v in ipairs({strsplit(";", squarecfg[name].value or "")}) do
table.insert(indicator.nameID, {strsplit("/",v)})
end
else
indicator.nameID = {strsplit(";", squarecfg[name].value or "")}
end
else
indicator.type = nil
indicator:Hide()
end
indicator:SetSize(squarecfg[name].size, squarecfg[name].size)
end
if isEnabled then
frame:EnableElement("RaidStatusIndicators")
else
frame:DisableElement("RaidStatusIndicators")
end
end
--Healing Prediction
if frame.BetterHealthPrediction then
local healConfig = config.incHeal
if healConfig.enabled then
frame.BetterHealthPrediction.timeFrame = LUF.db.profile.inchealTime
frame.BetterHealthPrediction.maxOverflow = healConfig.cap
frame.BetterHealthPrediction.disableHots = LUF.db.profile.disablehots
local color = LUF.db.profile.colors.incheal
frame.BetterHealthPrediction.otherBeforeBar:SetStatusBarColor(color.r, color.g, color.b, healConfig.alpha)
frame.BetterHealthPrediction.otherAfterBar:SetStatusBarColor(color.r, color.g, color.b, healConfig.alpha)
color = LUF.db.profile.colors.incownheal
frame.BetterHealthPrediction.myBar:SetStatusBarColor(color.r, color.g, color.b, healConfig.alpha)
color = LUF.db.profile.colors.inchots
frame.BetterHealthPrediction.hotBar:SetStatusBarColor(color.r, color.g, color.b, healConfig.alpha)
frame:EnableElement("BetterHealthPrediction")
else
frame:DisableElement("BetterHealthPrediction")
end
end
frame:UpdateAllElements("RefreshUnit")
end
local sortUp = function(a, b) return a.order < b.order end
local sortDown = function(a, b) return a.order > b.order end
local horiz,vert = {},{}
function LUF.PlaceModules(frame)
local frame = frame:IsObjectType("Statusbar") and frame:GetParent() or frame
local config = LUF.db.profile.units[frame:GetAttribute("oUF-guessUnit")]
if not config then return end
wipe(horiz)
wipe(vert)
local attFrame, point = frame, "TOPLEFT"
local xOffset, yOffset = 1, -1
local usableX, usableY = frame:GetWidth() - 2
local vertValue, horizValue = 0, 0
frame.tags.top.left:SetWidth(usableX*config.tags.top.left.size/100)
frame.tags.top.center:SetWidth(usableX*config.tags.top.center.size/100)
frame.tags.top.right:SetWidth(usableX*config.tags.top.right.size/100)
frame.tags.bottom.left:SetWidth(usableX*config.tags.bottom.left.size/100)
frame.tags.bottom.center:SetWidth(usableX*config.tags.bottom.center.size/100)
frame.tags.bottom.right:SetWidth(usableX*config.tags.bottom.right.size/100)
for k,v in pairs(frame.modules) do
v:ClearAllPoints()
if config[k].enabled then
frame:EnableElement(v.name)
if k == "totemBar" then -- Bandaid for oUF totems being broken
for _,totem in ipairs(frame.Totems) do
totem:Show()
end
end
if k == "portrait" and config.portrait.alignment ~= "CENTER" then
v:SetPoint(config.portrait.alignment, frame, config.portrait.alignment, config.portrait.alignment == "LEFT" and 1 or -1, 0)
v:SetHeight(frame:GetHeight() - 2)
usableX = (frame:GetWidth() - 2) * config.portrait.width
v:SetWidth(usableX)
usableX = frame:GetWidth() - usableX - 2
elseif (not config[k].autoHide or v:IsShown()) and not v.isDisabled then
if config[k].vertical then
table.insert(vert,{key = k, order = config[k].order, size = config[k].height})
vertValue = vertValue + config[k].height
else
table.insert(horiz, {key = k, order = config[k].order, size = config[k].height})
horizValue = horizValue + config[k].height
end
end
else
frame:DisableElement(v.name)
end
end
table.sort(vert,sortDown)
table.sort(horiz,sortUp)
usableY = frame:GetHeight() - #horiz - 1
if vertValue > 0 and horizValue > 0 then
usableX = usableX - 1
end
-- Horizontal bars
if config.portrait.enabled and config.portrait.alignment == "LEFT" then
xOffset = xOffset + frame.modules.portrait:GetWidth()
end
local attrPoint = point
local sqrX
for i,data in pairs(horiz) do
if sqrX then
frame.modules[data.key]:SetPoint(point, attFrame, attrPoint, xOffset-sqrX, yOffset)
sqrX = nil
elseif frame.modules[data.key] ~= attFrame then
frame.modules[data.key]:SetPoint(point, attFrame, attrPoint, xOffset, yOffset)
end
local width = usableX * (horizValue/(horizValue+vertValue))
local height = usableY*(data.size/horizValue)
frame.modules[data.key]:SetWidth(width)
frame.modules[data.key]:SetHeight(height)
if frame.tags[data.key] then
local tagconfig = config.tags[data.key]
frame.tags[data.key].left:SetWidth(width*tagconfig.left.size/100)
frame.tags[data.key].left:SetHeight(height)
frame.tags[data.key].center:SetWidth(width*tagconfig.center.size/100)
frame.tags[data.key].center:SetHeight(height)
frame.tags[data.key].right:SetWidth(width*tagconfig.right.size/100)
frame.tags[data.key].right:SetHeight(height)
end
if frame.modules[data.key].Update then
frame.modules[data.key]:Update()
end
if data.key == "castBar" and config.castBar.icon ~= "HIDE" then
sqrX = frame.modules.castBar:GetHeight()
frame.modules.castBar.Icon:SetSize(sqrX, sqrX)
frame.modules.castBar:SetWidth(frame.modules.castBar:GetWidth() - sqrX)
if config.castBar.icon == "LEFT" then
frame.modules.castBar:ClearAllPoints()
frame.modules.castBar:SetPoint(point, attFrame, attrPoint, xOffset + sqrX, yOffset)
else
sqrX = nil
end
end
xOffset = 0
attrPoint = "BOTTOMLEFT"
attFrame = frame.modules[data.key]
end
-- Vertical bars
attFrame = frame
point = "TOPRIGHT"
xOffset = -1
usableX = usableX - #vert + 1
if config.portrait.enabled and config.portrait.alignment == "RIGHT" then
xOffset = xOffset - frame.modules.portrait:GetWidth()
end
yOffset = -1
attrPoint = point
for i,data in pairs(vert) do
frame.modules[data.key]:SetPoint(point, attFrame, attrPoint, xOffset, yOffset)
local width = usableX*(vertValue/(horizValue+vertValue))*(data.size/vertValue)
local height = frame:GetHeight()-2
frame.modules[data.key]:SetWidth(width)
frame.modules[data.key]:SetHeight(height)
if frame.tags[data.key] then