-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNugComboBar.lua
1839 lines (1635 loc) · 60 KB
/
NugComboBar.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 addonName, ns = ...
local NugComboBar = CreateFrame("Frame", "NugComboBar", UIParent)
local user
local flags
local allowedUnit = "player"
local allowedCaster = "player"
local allowedTargetUnit = "player"
local fadeAfter = 6
local combatFade = true -- whether to fade in combat
local defaultValue = 0
local defaultProgress = 0
local currentSpec = -1
local playerClass
local GetNamePlateForUnit = C_NamePlate.GetNamePlateForUnit
local isDefaultSkin = nil
local enablePrettyRunes = nil
local UnitAura = UnitAura
local GetSpellCharges = GetSpellCharges
local UnitPower = UnitPower
local UnitPowerMax = UnitPowerMax
local GetRuneCooldown = GetRuneCooldown
local tsort = table.sort
local math_max = math.max
local math_min = math.min
local dummy = function() return 0 end
local GetComboPoints = dummy
local LoadAddOn = LoadAddOn or C_AddOns.LoadAddOn
local function GetSpecializationWithFallback()
local spec = _G.GetSpecialization()
if spec == 5 then -- spec below lvl 10
return 1
-- windwalker 3
end
return spec
end
--- Compatibility with Classic
local APILevel = math.floor(select(4,GetBuildInfo())/10000)
-- local isClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local IsInPetBattle = APILevel <= 4 and function() end or C_PetBattles.IsInBattle
local GetSpecialization = APILevel <= 4 and function() return 1 end or GetSpecializationWithFallback
local configs = {}
local currentConfigName
local currentTriggerState = {}
NugComboBar:SetScript("OnEvent", function(self, event, ...)
return self[event](self, event, ...)
end)
NugComboBar:RegisterEvent("ADDON_LOADED")
local L = setmetatable({}, {
__index = function(t, k)
t[k] = k
return k
end,
__call = function(t,k)
return t[k]
end,
})
NugComboBar.L = L
local AuraTimerOnUpdate = function(self, time)
self._elapsed = (self._elapsed or 0) + time
if self._elapsed < 0.03 then return end
self._elapsed = 0
if not self.startTime then return end
local progress
if self.isReversed then
progress = self.duration - (GetTime() - self.startTime)
else
progress = self.duration - ( (self.startTime+self.duration) - GetTime())
end
self:SetValue(progress)
end
local defaults = {
global = {
enable3d = false,
disableBlizz = false,
disableBlizzNP = false,
enablePrettyRunes = true,
classConfig = {
ROGUE = { "ComboPointsRogue", "ComboPointsRogue", "ComboPointsAndShadowdance" },
DRUID = { "ShapeshiftDruid", "ComboPointsDruid", "ShapeshiftDruid", "ComboPointsDruid" },
PALADIN = { "HolyPower", "HolyPower", "HolyPower" },
MONK = { "PurifyingBrew", "Teachings", "Chi" },
WARLOCK = { "SoulShards", "SoulShards", "SoulShards" },
DEMONHUNTER = { "Disabled", "SoulFragments" },
DEATHKNIGHT = { "Runes", "Runes", "Runes" },
MAGE = { "ArcaneCharges", "Fireblast", "Icicles" },
WARRIOR = { "Disabled", "Meatcleaver", "ShieldBlock" },
SHAMAN = { "Icefury", "MaelstromWeapon", "Disabled" },
HUNTER = { "Disabled", "Disabled", "Disabled" },
PRIEST = { "Disabled", "Disabled", "Disabled" },
EVOKER = { "Essence", "Essence", "Essence" },
},
specProfiles = {
ROGUE = { "Default", "Default", "Default" },
DRUID = { "Default", "Default", "Default", "Default" },
PALADIN = { "Default", "Default", "Default" },
MONK = { "Default", "Default", "Default" },
WARLOCK = { "Default", "Default", "Default" },
DEMONHUNTER = { "Default", "Default" },
DEATHKNIGHT = { "Default", "Default", "Default" },
MAGE = { "Default", "Default", "Default" },
WARRIOR = { "Default", "Default", "Default" },
SHAMAN = { "Default", "Default", "Default" },
HUNTER = { "Default", "Default", "Default" },
PRIEST = { "Default", "Default", "Default" },
EVOKER = { "Default", "Default", "Default" },
}
},
profile = {
apoint = "CENTER",
parent = "UIParent",
point = "CENTER", --to
x = 0, y = 0,
anchorpoint = "LEFT",
frameparent = nil, -- for SetParent
scale = 1.3,
showEmpty = false,
enableFullColor = false,
hideSlowly = true,
colors = {
['*'] = {1, 0.33, 0.74}, -- points
["full"] = { 1, 0.7, 0.2 },
["bar1"] = { 0.9,0.1,0.1 },
["bar2"] = { 0.71, 0.16, 0 },
["layer2"] = { 0.74, 0.06, 0 },
["row2"] = { 0.80, 0.23, 0.79 },
},
glowIntensity = 0.7,
preset3d = "glowPurple",
preset3dlayer2 = "glowArcshot",
preset3dpointbar2 = "void",
bar2_x = 13,
bar2_y = -20,
classThemes = false,
colors3d = true,
showAlways = false,
onlyCombat = false,
secondLayer = true,
disableProgress = false,
cooldownOnTop = false,
chargeCooldown = true,
animationLevel = 2,
alpha = 1,
nameplateAttach = false,
nameplateAttachTarget = false,
nameplateOffsetX = 0,
nameplateOffsetY = 0,
hideWithoutTarget = false,
vertical = false,
overrideLayout = false,
soundChannel = "SFX",
soundNameFull = "none",
soundNameFullCustom = "Interface\\AddOns\\YourSound.mp3",
},
}
NugComboBar.defaults = defaults
if APILevel <= 2 then
defaults.global.classConfig = {
ROGUE = { "ComboPointsRogueClassic", "ComboPointsRogueClassic", "ComboPointsRogueClassic" },
DRUID = { "ShapeshiftDruid", "ComboPointsDruid", "ShapeshiftDruid", "ComboPointsDruid" },
PALADIN = { "Disabled", "Disabled", "Disabled" },
MONK = { "Disabled", "Disabled", "Disabled" },
WARLOCK = { "Disabled", "Disabled", "Disabled" },
DEMONHUNTER = { "Disabled", "Disabled" },
DEATHKNIGHT = { "Disabled", "Disabled", "Disabled" },
MAGE = { "ArcaneBlastClassic", "ArcaneBlastClassic", "ArcaneBlastClassic" },
WARRIOR = { "Disabled", "Disabled", "Disabled" },
SHAMAN = { "Disabled", "Disabled", "Disabled" },
HUNTER = { "Disabled", "Disabled", "Disabled" },
PRIEST = { "Disabled", "Disabled", "Disabled" },
}
if APILevel == 1 then -- Now there's Arcane Blast in SoD
-- defaults.global.classConfig.MAGE = { "ArcaneBlastSoD", "ArcaneBlastSoD", "ArcaneBlastSoD" }
defaults.global.classConfig.SHAMAN = { "MaelstromWeapon", "MaelstromWeapon", "MaelstromWeapon" }
end
end
if APILevel == 3 then
defaults.global.classConfig = {
ROGUE = { "ComboPointsRogueClassic", "ComboPointsRogueClassic", "ComboPointsRogueClassic" },
DRUID = { "ShapeshiftDruid", "ComboPointsDruid", "ShapeshiftDruid", "ComboPointsDruid" },
PALADIN = { "Disabled", "Disabled", "Disabled" },
MONK = { "Disabled", "Disabled", "Disabled" },
WARLOCK = { "Disabled", "Disabled", "Disabled" },
DEMONHUNTER = { "Disabled", "Disabled" },
DEATHKNIGHT = { "Disabled", "Disabled", "Disabled" },
MAGE = { "ArcaneBlastClassic", "ArcaneBlastClassic", "ArcaneBlastClassic" },
WARRIOR = { "Disabled", "Disabled", "Disabled" },
SHAMAN = { "MaelstromWeapon", "MaelstromWeapon", "MaelstromWeapon" },
HUNTER = { "Disabled", "Disabled", "Disabled" },
PRIEST = { "Disabled", "Disabled", "Disabled" },
}
end
if APILevel == 4 then
defaults.global.classConfig = {
ROGUE = { "ComboPointsRogueClassic", "ComboPointsRogueClassic", "ComboPointsRogueClassic" },
DRUID = { "ShapeshiftDruid", "ComboPointsDruid", "ShapeshiftDruid", "ComboPointsDruid" },
PALADIN = { "HolyPower", "HolyPower", "HolyPower" },
MONK = { "Disabled", "Disabled", "Disabled" },
WARLOCK = { "SoulShards", "SoulShards", "SoulShards" },
DEMONHUNTER = { "Disabled", "Disabled" },
DEATHKNIGHT = { "Disabled", "Disabled", "Disabled" },
MAGE = { "ArcaneBlastClassic", "ArcaneBlastClassic", "ArcaneBlastClassic" },
WARRIOR = { "Disabled", "Disabled", "Disabled" },
SHAMAN = { "MaelstromWeapon", "MaelstromWeapon", "MaelstromWeapon" },
HUNTER = { "Disabled", "Disabled", "Disabled" },
PRIEST = { "ShadowOrbs", "ShadowOrbs", "ShadowOrbs" },
}
end
function NugComboBar:LoadClassSettings()
local class = select(2,UnitClass("player"))
self.MAX_POINTS = 0
self.isTempDisabled = nil
if self.bar then self.bar:SetColor(unpack(self.db.profile.colors.bar1)) end
self:RegisterEvent("SPELLS_CHANGED")
end
function NugComboBar:SPELLS_CHANGED()
local spec = GetSpecialization()
local class = select(2,UnitClass("player"))
local currentProfile = self.db:GetCurrentProfile()
local newSpecProfile = self.db.global.specProfiles[class][spec] or "Default"
if not self.db.profiles[newSpecProfile] then
self.db.global.specProfiles[class][spec] = "Default"
newSpecProfile = "Default"
end
if newSpecProfile ~= currentProfile then
self.db:SetProfile(newSpecProfile)
end
local newConfigName = self.db.global.classConfig[class][spec] or "Disabled"
-- If using missing config reset to default
if newConfigName ~= "Disabled" and not configs[newConfigName] then
self.db.global.classConfig[class][spec] = defaults.global.classConfig[class][spec]
newConfigName = self.db.global.classConfig[class][spec] or "Disabled"
end
if newConfigName == "Disabled" then
self:ResetConfig()
self:Disable()
currentConfigName = nil
return
else
self:Enable()
end
local currentConfig = configs[currentConfigName]
local needUpdate
local changedConfig = currentConfigName ~= newConfigName
if changedConfig then
needUpdate = true
else
local newTriggerState = self:GetTriggerState(currentConfig)
needUpdate = not self:IsTriggerStateEqual(currentTriggerState, newTriggerState)
end
if needUpdate then
self:SelectConfig(newConfigName)
self:Update()
end
end
NugComboBar.SkinVersion = 600
do
function NugComboBar.ADDON_LOADED(self,event,arg1)
if arg1 == addonName then
NugComboBarDB_Global = NugComboBarDB_Global or {}
NugComboBarDB_Character = NugComboBarDB_Character or {}
self:DoMigrations(NugComboBarDB_Global)
self.db = LibStub("AceDB-3.0"):New("NugComboBarDB_Global", defaults, "Default") -- Create a DB using defaults and using a shared default profile
NugComboBarDB = self.db
self.db.RegisterCallback(self, "OnProfileChanged", "Reconfigure")
self.db.RegisterCallback(self, "OnProfileCopied", "Reconfigure")
self.db.RegisterCallback(self, "OnProfileReset", "Reconfigure")
playerClass = select(2,UnitClass("player"))
self:RegisterEvent("PLAYER_LOGIN")
-- self:RegisterEvent("PLAYER_LOGOUT")
if self.db.global.disableBlizz then NugComboBar.disableBlizzFrames() end
-- if self.db.global.disableBlizzNP then NugComboBar.disableBlizzNameplates() end
local f = CreateFrame('Frame', nil, SettingsPanel or InterfaceOptionsFrame) -- helper frame to load GUI and to watch specialization changes
f:SetScript('OnShow', function(self)
self:SetScript('OnShow', nil)
LoadAddOn('NugComboBarGUI')
end)
SLASH_NCBSLASH1 = "/ncb";
SLASH_NCBSLASH2 = "/nugcombobar";
SLASH_NCBSLASH3 = "/NugComboBar";
SlashCmdList["NCBSLASH"] = NugComboBar.SlashCmd
end
end
end
NugComboBar.soundFiles = {
["none"] = "none",
["gm_chatwarning"] = SOUNDKIT.GM_CHAT_WARNING,
["coldblood"] = 6774,
["alarmclockwarning3"] = SOUNDKIT.ALARM_CLOCK_WARNING_3,
["auctionwindowopen"] = SOUNDKIT.AUCTION_WINDOW_OPEN,
["wispwhat1"] = 6343,
["custom"] = "custom",
}
NugComboBar.soundChoices = {
"none",
"gm_chatwarning",
"coldblood",
"alarmclockwarning3",
"auctionwindowopen",
"wispwhat1",
"custom",
}
local trim = function(v)
return math.floor(v*1000)/1000
end
local ResolutionOffsets = {
[trim(48/9)] = { 0.77, 0.75 },
[trim(16/10)] = { 2.25, 2.25 },
[trim(16/9)] = { 0.83, 0.83 },
[trim(4/3)] = { 2.5, 2.5 },
}
function NugComboBar:IsDefaultSkin(set)
if set then
isDefaultSkin = set
else
return isDefaultSkin
end
end
local pmult = 1
function NugComboBar.pixelperfect(size)
return floor(size/pmult + 0.5)*pmult
-- return PixelUtil.GetNearestPixelSize(size, NugComboBar:GetEffectiveScale(), size) -- No PixelUtil on classic
end
local pixelperfect = NugComboBar.pixelperfect
do
local initial = true
function NugComboBar.PLAYER_LOGIN(self, event)
if NugComboBar.isDisabled then return end
local res = GetCVar("gxWindowedResolution") --select(GetCurrentResolution(), GetScreenResolutions())
if res then
local w,h = string.match(res, "(%d+)x(%d+)")
pmult = (768/h) / UIParent:GetScale()
end
isDefaultSkin = NugComboBar:IsDefaultSkin()
if initial then self:Create() end
-- Always calling :Create will allow switching to vertical without reload?
local profile = self.db.profile
if profile.frameparent and _G[profile.frameparent] then
NugComboBar:SetParent(_G[profile.frameparent])
end
local presets = NugComboBar.presets
if not presets[profile.preset3dlayer2] then
profile.preset3dlayer2 = defaults.preset3dlayer2
if not presets[profile.preset3dlayer2] then
profile.preset3dlayer2 = next(presets)
end
end
if not NugComboBar.soundFiles[profile.soundNameFull] then
profile.soundNameFull = "none"
end
enablePrettyRunes = self.db.global.enablePrettyRunes
self:SetAlpha(0)
self:SetScale(profile.scale)
self.eventProxy = CreateFrame("Frame", nil, self)
self.eventProxy:SetScript("OnEvent", function(proxy, event, ...)
return proxy[event](NugComboBar, event, ...)
end)
self.flags = setmetatable({}, {
__index = function(t,k)
return NugComboBar.db.profile[k]
end
})
flags = self.flags
self:LoadClassSettings()
if initial then
self:CreateAnchor()
else
self.anchor:ClearAllPoints()
self.anchor:SetPoint(profile.apoint, profile.parent, profile.point,profile.x,profile.y)
end
self:UpdatePosition()
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_TARGET_CHANGED")
if APILevel >= 5 then
self:RegisterEvent("PET_BATTLE_OPENING_START")
self:RegisterEvent("PET_BATTLE_CLOSE")
end
self.PLAYER_ENTERING_WORLD = self.CheckComboPoints -- Update on looading screen to clear after battlegrounds
self.PLAYER_REGEN_ENABLED = self.CheckComboPoints
self.PLAYER_REGEN_DISABLED = self.CheckComboPoints
self.PET_BATTLE_OPENING_START = self.CheckComboPoints
self.PET_BATTLE_CLOSE = self.CheckComboPoints
initial = false
--self:AttachAnimationGroup()
-- self:UNIT_COMBO_POINTS("INIT", allowedUnit, nil, true)
end
end
function NugComboBar:Reconfigure()
self:UpdatePosition()
local profile = self.db.profile
self:SetScale(profile.scale)
self.forceHidden = false
if currentConfigName then
self:SelectConfig(currentConfigName)
self:Update() -- will update alpha
end
-- colors & col 3d & glow int:
-- Fixed by SetColor inside SetMaxPoints
-- NugComboBar:Set3DPreset()
-- bar2 offset: Inside skin.lua Will get updated by SetMaxPoints,
-- but only if frame was actually reconstructed by config switch
-- disable progress: Reselect config
-- -- cd on top -- Nothing?
end
local fadeTime = 1
local fader = CreateFrame("Frame")
local HideTimer = function(self, time)
self.OnUpdateCounter = (self.OnUpdateCounter or 0) + time
if self.OnUpdateCounter < fadeAfter then return end
local ncb = NugComboBar
local a = math_max(0, 1-((self.OnUpdateCounter - fadeAfter) / fadeTime))
ncb:SetAlpha(NugComboBar.db.profile.alpha*a)
if self.OnUpdateCounter >= fadeAfter + fadeTime then
self:SetScript("OnUpdate",nil)
ncb:SetAlpha(0)
ncb.hiding = false
self.OnUpdateCounter = 0
end
end
function NugComboBar.PLAYER_TARGET_CHANGED(self, event)
if self.db.profile.nameplateAttachTarget then
local targetFrame = C_NamePlate.GetNamePlateForUnit("target")
local isAttackable = UnitCanAttack("player", "target")
local isFriendly = (UnitReaction("target", "player") or 0) > 4
if targetFrame and isAttackable and not isFriendly then
self:Show()
self:ClearAllPoints()
self:SetPoint("BOTTOM", targetFrame, "TOP", self.db.profile.nameplateOffsetX, self.db.profile.nameplateOffsetY)
else
self:Hide()
end
elseif self.db.profile.hideWithoutTarget and not self:IsDisabled() then
self.forceHidden = not UnitExists("target")
self:Update()
end
end
function NugComboBar.CheckComboPoints(self)
if GetComboPoints ~= dummy then
self:UNIT_COMBO_POINTS(nil, allowedUnit, nil)
end
end
NugComboBar.ShowCooldownCharge = function(self, arg1, arg2, point) point.cd:Hide() end -- dummy to not break Valeera with NCB 7.1.4
function NugComboBar.EnableBar(self, min, max, btype, isTimer, isReversed)
if not self.bar then return end
if self.db.profile.disableProgress then return end
self.bar.enabled = true
if min and max then
self.bar:SetMinMaxValues(min, max)
end
self.bar.isReversed = isReversed
self.bar.max = max
if not flags.chargeCooldown then
if not btype or btype == "Small" then
self.bar:SetWidth(pixelperfect(45))
self.bar:SetHeight(pixelperfect(4))
end
if type(btype) == "number" then
self.bar:SetWidth(pixelperfect(btype))
self.bar:SetHeight(pixelperfect(4))
end
end
if isTimer then
self.bar:SetScript("OnUpdate", AuraTimerOnUpdate)
end
return true
end
function NugComboBar.DisableBar(self)
if not self.bar then return end
self.bar:SetScript("OnUpdate", nil)
self.bar.enabled = false
self.bar:Hide()
end
local function AnticipationIn(point, i)
local r,g,b = unpack(NugComboBar:GetColor("layer2"))
point:SetColor(r,g,b)
point.anticipationColor = true
point:SetPreset(NugComboBar:Get3DPreset("preset3dlayer2"))
end
local function AnticipationOut(point, i)
local r,g,b = unpack(NugComboBar:GetColor(i))
point:SetColor(r,g,b)
point.anticipationColor = false
point:SetPreset(NugComboBar:Get3DPreset("preset3d"))
end
function NugComboBar:GetPoint(i)
return self.p[i]
end
function NugComboBar:SelectPoint(i)
local point = self:GetPoint(i)
if not point.Select then return end
point:Select()
point.isSelected = true
end
function NugComboBar:DeselectPoint(i)
local point = self:GetPoint(i)
if not point.Deselect then return end
if point.isSelected then
AnticipationOut(point, i)
end
point:Deselect()
point.isSelected = nil
end
function NugComboBar:DeselectAllPoints()
for i = 1, self.MAX_POINTS do
local point = self.p[i]
if point.isSelected then
AnticipationOut(point, i)
end
end
for i, point in ipairs(self.point) do
if point.Deselect then
point:Deselect()
point.isSelected = nil
end
end
end
local comboPointsBefore = 0
local targetBefore
function NugComboBar.UNIT_COMBO_POINTS(self, event, unit, ...)
if unit ~= allowedUnit then return end
self:Update(unit, ...)
end
function NugComboBar:Update(unit, ...)
local profile = self.db.profile
if flags.onlyCombat and not UnitAffectingCombat("player") then
self:Hide()
return
else
if not profile.nameplateAttachTarget then
self:Show()
else
self:PLAYER_TARGET_CHANGED()
end
end -- usually frame is set to 0 alpha
local animationLevel = self.db.profile.animationLevel
-- local arg1, arg2
local comboPoints, arg1, arg2, secondLayerPoints, secondBarPoints = GetComboPoints(unit);
local progress = not arg2 and arg1 or nil
if self.bar and self.bar.enabled then
if arg1 then
self.bar:Show()
if arg2 then
local startTime, duration = arg1, arg2
self.bar.startTime = startTime
self.bar.duration = duration
self.bar:SetMinMaxValues(0, duration)
else
self.bar:SetValue(progress)
end
else
self.bar:Hide()
end
end
if flags.soundFullEnabled then
-- print(comboPoints, self.MAX_POINTS, comboPoints ~= comboPointsBefore)
if comboPoints == self.MAX_POINTS and
comboPoints ~= comboPointsBefore and
-- comboPointsBefore ~= 0 then
UnitGUID(allowedTargetUnit) == targetBefore then
local sound = NugComboBar.soundFiles[profile.soundNameFull]
if sound == "custom" then
sound = profile.soundNameFullCustom
PlaySoundFile(sound, profile.soundChannel)
else
if type(sound) == "number" then
PlaySound(sound, profile.soundChannel)
end
end
end
targetBefore = UnitGUID(allowedTargetUnit)
end
if flags.isRuneTracker and isDefaultSkin then
local runeIndex, isEnergize = ...
self:UpdateRunes(runeIndex, isEnergize)
else
local isFull = comboPoints == self.MAX_POINTS
for i = 1, self.MAX_POINTS do
local point = self.p[i]
if self.db.profile.enableFullColor then
local r,g,b = unpack(NugComboBar:GetColor(isFull and "full" or i))
point:SetColor(r,g,b)
end
if i <= comboPoints then
point:Activate(animationLevel)
if flags.secondLayer then
if point.isSelected then
if comboPoints == i then
AnticipationIn(point, i)
else
AnticipationOut(point, i)
end
end
end
end
if i > comboPoints then
point:Deactivate(animationLevel)
end
if flags.secondLayer then
if secondLayerPoints then -- Anticipation stuff
if i <= secondLayerPoints then
if (point.currentPreset and point.currentPreset ~= profile.preset3dlayer2)
or
(not point.anticipationColor) then
point:Reappear(animationLevel, AnticipationIn, i)
end
else
if not point.isSelected and
((point.currentPreset and point.currentPreset ~= profile.preset3d)
or
(point.anticipationColor)) then
if i <= comboPoints then
point:Reappear(animationLevel, AnticipationOut, i)
else
AnticipationOut(point, i)
end
end
end
end
end
end
end
if flags.chargeCooldown and not flags.chargeCooldownOnSecondBar then
if isDefaultSkin then
if comboPoints ~= self.MAX_POINTS then
local point = self.p[comboPoints+1]
if point then
NugComboBar:MoveCharger(point)
end
end
end
end
--second bar
if self.MAX_POINTS2 then
for i = 1, self.MAX_POINTS2 do
local point = self.p[i+self.MAX_POINTS]
if i <= secondBarPoints then
point:Activate(animationLevel)
end
if i > secondBarPoints then
point:Deactivate(animationLevel)
end
end
if flags.chargeCooldown and flags.chargeCooldownOnSecondBar then
if isDefaultSkin then
if secondBarPoints ~= self.MAX_POINTS2 then
local point = self.p[self.MAX_POINTS+secondBarPoints+1]
NugComboBar:MoveCharger(point)
end
end
end
end
local forceHide = IsInPetBattle() or self.forceHidden or self.isDisabled
if forceHide or
(
not flags.showAlways and
comboPoints == defaultValue and -- or (defaultValue == -1 and lastChangeTime < GetTime() - 9)) and
(progress == nil or progress == defaultProgress) and
(not UnitAffectingCombat("player") or not flags.showEmpty)
)
then
local hidden = self:GetAlpha() == 0
if flags.hideSlowly and not forceHide then
-- print("hiding, hidden:", self.hiding, hidden)
if (not self.hiding and not hidden) then
-- print("start hiding")
fader:SetScript("OnUpdate", HideTimer)
fader.OnUpdateCounter = 0
self.hiding = true
end
else
self:SetAlpha(0)
end
else
fader:SetScript("OnUpdate", nil)
self.hiding = false
self:SetAlpha(profile.alpha)
end
comboPointsBefore = comboPoints
end
function NugComboBar.SetColor(point, r, g, b)
if b then
NugComboBar.db.profile.colors[point] = {r,g,b}
else
local clr = NugComboBar.db.profile.colors[point]
if not clr then return end
r,g,b = unpack(clr)
end
if NugComboBar.bar and point == "bar1" then
return NugComboBar.bar:SetColor(r,g,b)
end
if point == "bar2" then
local self = NugComboBar
if self.MAX_POINTS2 then
for i = 1, self.MAX_POINTS2 do
local point = self.p[i+self.MAX_POINTS]
point:SetColor(r,g,b)
end
end
end
local p = NugComboBar.p[point]
if p then
return p:SetColor(r,g,b)
end
end
function NugComboBar.CreateAnchor(frame)
local self = CreateFrame("Frame",nil,UIParent)
self:SetWidth(10)
self:SetHeight(frame:GetHeight())
local t = self:CreateTexture(nil, "ARTWORK")
t:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
t:SetAllPoints(self)
t:SetVertexColor(1, 0, 0, 0.8)
self:SetFrameStrata("HIGH")
local profile = NugComboBar.db.profile
self:SetPoint(profile.apoint, profile.parent, profile.point,profile.x,profile.y)
frame.anchor = self
self:EnableMouse(true)
self:RegisterForDrag("LeftButton")
self:SetMovable(true)
self:SetScript("OnDragStart",function(self) self:StartMoving(); self:SetUserPlaced(false) end)
self:SetScript("OnDragStop",function(self)
self:StopMovingOrSizing();
self:SetUserPlaced(false)
local parent
local profile = NugComboBar.db.profile
profile.apoint, parent, profile.point, profile.x, profile.y = self:GetPoint(1)
profile.parent = "UIParent"
end)
self:Hide()
end
----------------------
-- CLASS THEMES
----------------------
function NugComboBar:GetCurrentTheme()
local theme
if isDefaultSkin and self.db.profile.classThemes then
local classTable = self.themes[playerClass]
if not classTable then return end
-- local modeCategory = self.db.global.enable3d and "mode3d" or "mode2d"
local modeCategory = "mode2d"
local specThemes = classTable[modeCategory]
if not specThemes then return end
local spec = GetSpecialization()
theme = specThemes[spec] or specThemes[0]
end
return theme
end
function NugComboBar:GetColor(key)
local theme = self:GetCurrentTheme()
local overridenColor
if theme then
if theme.colors then
overridenColor = theme.colors[key] or theme.colors["normal"]
end
end
if overridenColor then
return overridenColor
else
local profileColors = self.db.profile.colors
return profileColors[key]
end
end
function NugComboBar:Get3DPreset(presetType)
local theme = self:GetCurrentTheme()
local overridenPreset
if theme then
overridenPreset = theme[presetType]
end
if overridenPreset then
return overridenPreset
else
local preset = self.db.profile[presetType]
if not NugComboBar.presets[preset] then -- filled in skin.lua currently
self.db.profile[presetType] = defaults.profile[presetType]
preset = defaults.profile[presetType]
end
return preset
end
end
-----------------------
function NugComboBar:UpdatePosition()
local playerNameplateEnabled = GetCVar("nameplateShowSelf") == "1"
local profile = self.db.profile
if profile.nameplateAttachTarget then
self:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
self:RegisterEvent("NAME_PLATE_UNIT_ADDED")
elseif playerNameplateEnabled and profile.nameplateAttach then
if C_NamePlate.GetNamePlateForUnit("player") then
NugComboBar:NAME_PLATE_UNIT_ADDED(nil, "player")
else
NugComboBar:NAME_PLATE_UNIT_REMOVED(nil, "player")
end
self:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
self:RegisterEvent("NAME_PLATE_UNIT_ADDED")
else
local p1 = profile.anchorpoint
local p2
if p1 == "LEFT" then p2 = "RIGHT"
elseif p1 == "RIGHT" then p2 = "LEFT"
elseif p1 == "TOP" then p2 = "BOTTOM"
end
self:ClearAllPoints()
self:SetPoint(p1, self.anchor, p2, 0, 0)
self.anchor:ClearAllPoints()
self.anchor:SetPoint(profile.apoint, profile.parent, profile.point,profile.x,profile.y)
self:UnregisterEvent("NAME_PLATE_UNIT_REMOVED")
self:UnregisterEvent("NAME_PLATE_UNIT_ADDED")
end
end
function NugComboBar.ShowColorPicker(self,color)
ColorPickerFrame:Hide()
local upcolor = (color > 0) and color or 5
NugComboBar.colorPickerColor = color
if ColorPickerFrame.SetupColorPickerAndShow then
local r2, g2, b2 = unpack(NugComboBar.db.profile.colors[upcolor])
local SaveColor = function(colorID,r,g,b)
if colorID == 0 then
for i=1,#self.point do
NugComboBar.SetColor(i, r,g,b)
end
elseif colorID == -1 then
for i=1, self.MAX_POINTS2 do
local index = i+self.MAX_POINTS
NugComboBar.SetColor(index, r,g,b)
end
else
NugComboBar.SetColor(colorID, r,g,b)
end
end
local info = {
swatchFunc = function()
local r, g, b = ColorPickerFrame:GetColorRGB()
local a = ColorPickerFrame:GetColorAlpha()
SaveColor(color, r, g, b)
end,
hasOpacity = false,
-- opacityFunc = function()
-- local r, g, b = ColorPickerFrame:GetColorRGB()
-- local a = ColorPickerFrame:GetColorAlpha()
-- ColorCallback(self, r, g, b, a, true)
-- end,
opacity = 1,
cancelFunc = function()
SaveColor(color, r2, g2, b2)
end,
r = r2,
g = g2,
b = b2,
}
ColorPickerFrame:SetupColorPickerAndShow(info)
else
ColorPickerFrame:SetColorRGB(unpack(NugComboBar.db.profile.colors[upcolor]))
ColorPickerFrame.hasOpacity = false
ColorPickerFrame.previousValues = {unpack(NugComboBar.db.profile.colors[upcolor])} -- otherwise we'll get reference to changed table
ColorPickerFrame.func = function(previousValues)
local r,g,b
local color = NugComboBar.colorPickerColor
if previousValues then
r,g,b = unpack(previousValues)
else
r,g,b = ColorPickerFrame:GetColorRGB();
end
if color == 0 then
for i=1,#self.point do
NugComboBar.SetColor(i,r,g,b)
end
elseif color == -1 then
for i=1, self.MAX_POINTS2 do
local index = i+self.MAX_POINTS
NugComboBar.SetColor(index,r,g,b)
end