-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Aptechka.lua
4627 lines (4098 loc) · 161 KB
/
Aptechka.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 _, helpers = ...
local Aptechka = helpers.frame
Aptechka:SetScript("OnEvent", function(self, event, ...)
self[event](self, event, ...)
end)
--- Compatibility with Classic
local apiLevel = math.floor(select(4,GetBuildInfo())/10000)
local isClassic = apiLevel <= 2
local isBC = apiLevel == 2
-- local isClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local isMainline = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
local UnitHasVehicleUI = UnitHasVehicleUI
local UnitInVehicle = UnitInVehicle
local UnitUsingVehicle = UnitUsingVehicle
local UnitGetIncomingHeals = UnitGetIncomingHeals
local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs
local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs
local UnitThreatSituation = UnitThreatSituation
local UnitGroupRolesAssigned = UnitGroupRolesAssigned
local UnitPhaseReason = UnitPhaseReason
local GetSpecialization = GetSpecialization
local GetSpecializationRole = GetSpecializationRole
local GetActiveTalentGroup = GetActiveTalentGroup
local HasIncomingSummon = C_IncomingSummon and C_IncomingSummon.HasIncomingSummon
local COMBATLOG_OBJECT_AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE
local COMBATLOG_OBJECT_AFFILIATION_UPTORAID = COMBATLOG_OBJECT_AFFILIATION_RAID + COMBATLOG_OBJECT_AFFILIATION_PARTY + COMBATLOG_OBJECT_AFFILIATION_MINE
local dummyNil = function() return nil end
local dummyFalse = function() return false end
local dummy0 = function() return 0 end
if apiLevel <= 3 then
GetSpecialization = function() return 1 end
-- GetSpecializationRole = function(spec)
-- local tg = GetActiveTalentGroup()
-- return GetTalentGroupRole(tg)
-- end
GetSpecializationRole = function(spec)
local tg = GetActiveTalentGroup()
if not AptechkaDB_Char.forcedClassicRole then return "DAMAGER" end
return AptechkaDB_Char.forcedClassicRole[tg]
end
UnitGetTotalAbsorbs = dummy0
UnitGetTotalHealAbsorbs = dummy0
UnitPhaseReason = dummyFalse
HasIncomingSummon = dummyNil
end
if apiLevel <= 2 then
GetActiveTalentGroup = function() return 1 end
UnitHasVehicleUI = dummyFalse
UnitInVehicle = dummyFalse
UnitUsingVehicle = dummyFalse
UnitGroupRolesAssigned = function(unit) if GetPartyAssignment("MAINTANK", unit) then return "TANK" end end
end
-- AptechkaUserConfig = setmetatable({},{ __index = function(t,k) return AptechkaDefaultConfig[k] end })
-- When AptechkaUserConfig __empty__ field is accessed, it will return AptechkaDefaultConfig field
local AptechkaUnitInRange
local uir -- current range check function
local auras
local traceheals
local colors
local threshold = 0 --incoming heals
local ignoreplayer
local fgShowMissing
local gradientHealthColor
local damageEffect
local mergedIncomingHealing -- Show incoimng healing text in the same widget as missing health
local config = AptechkaDefaultConfig
Aptechka.loadedAuras = {}
local loadedAuras = Aptechka.loadedAuras
local customBossAuras = helpers.customBossAuras
local defaultBlacklist = helpers.auraBlacklist
local buffGainWhitelist = helpers.buffGainWhitelist or {}
local blacklist
local importantTargetedCasts = helpers.importantTargetedCasts
local loaded = {}
local Roster = {}
local guidMap = {}
local group_headers = {}
local missingFlagSpells = {}
local anchors = {}
local skinAnchorsName
local BITMASK_DISPELLABLE = 0
local RosterUpdateOccured
local LastCastSentTime = 0
local LastCastTargetName
local highlightedDebuffs = {}
local GetNumGroupMembers = GetNumGroupMembers
local AptechkaString = "|cffff7777Aptechka: |r"
local GetTime = GetTime
local UnitHealth = UnitHealth
local UnitHealthMax = UnitHealthMax
local UnitIsDeadOrGhost = UnitIsDeadOrGhost
local UnitPower = UnitPower
local UnitPowerMax = UnitPowerMax
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local UnitAura = UnitAura
local ForEachAura = helpers.ForEachAura
local UnitAffectingCombat = UnitAffectingCombat
local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local customColors
local table_wipe = table.wipe
local SetJob
local FrameSetJob
local DispelFilter
local pixelperfect = helpers.pixelperfect
Aptechka.util = helpers
Aptechka.helpers = helpers -- Used by old userconfigs
local bit_band = bit.band
local bit_bor = bit.bor
local IsInGroup = IsInGroup
local IsInRaid = IsInRaid
local pairs = pairs
local next = next
local utf8sub = helpers.utf8sub
local reverse = helpers.Reverse
local GetAuraHash = helpers.GetAuraHash
local AptechkaDB
local NickTag
local LibSpellLocks
local LibAuraTypes
local LibTargeted
local LibTargetedCasts
local tinsert = table.insert
local tremove = table.remove
local tsort = table.sort
local BuffProc
local DebuffProc, DebuffPostUpdate
local DispelTypeProc, DispelTypePostUpdate
local EffectListProc, EffectListPostUpdate, EffectIndices
local enableTraceheals
local enableAuraEvents
local enableFloatingIcon
local enableStagger
local alphaOutOfRange = 0.45
-- local enableLowHealthStatus
local debuffLimit
local tankUnits = {}
local staggerUnits = {}
local LibTranslit = LibStub("LibTranslit-1.0")
local GetIncomingHealsCustom -- upvalue to swap based on HealComm usage
-- Classic things
local HealComm
local LibClassicDurations = LibStub("LibClassicDurations", true)
local spellNameToID = helpers.spellNameToID
local L = setmetatable({}, {
__index = function(t, k)
-- print(string.format('L["%s"] = ""',k:gsub("\n","\\n")));
return k
end,
__call = function(t,k) return t[k] end,
})
Aptechka.L = L
_G.BINDING_HEADER_APTECHKA = "Aptechka"
_G.BINDING_NAME_APTECHKA_DEBUFF_TOOLTIP_HOLD = L"Debuff Tooltip Toggle(Hold)"
local defaults = {
global = {
useHealComm = true,
disableBlizzardPlayer = false,
disableBlizzardParty = true,
hideBlizzardRaid = true,
RMBClickthrough = false,
stayUnlocked = false,
singleHeaderMode = false,
enableNickTag = false,
showAFK = false,
enableRoles = apiLevel ~= 3,
translitCyrillic = false,
enableMouseoverStatus = true,
customBlacklist = {},
LDBData = {}, -- minimap icon settings
useCombatLogHealthUpdates = true,
disableTooltip = false,
disableAbsorbBar = false,
debuffTooltip = false,
debuffTooltip_bindAlt = false,
debuffTooltip_bindShift = true,
debuffTooltip_bindCtrl = true,
useDebuffOrdering = true, -- On always?
customDebuffHighlights = {},
borderWidth = 1,
enableProfileSwitching = true,
profileSelection = {
HEALER = {
solo = "Default",
party = "Default",
arena = "Default",
smallRaid = "Default",
mediumRaid = "Default",
bigRaid = "Default",
fullRaid = "Default",
},
DAMAGER = {
solo = "Default",
party = "Default",
arena = "Default",
smallRaid = "Default",
mediumRaid = "Default",
bigRaid = "Default",
fullRaid = "Default",
},
},
widgetConfig = config.DefaultWidgets,
},
profile = {
point = "CENTER",
x = 0,
y = 0,
width = 55,
height = 55,
petGroup = false,
petGroupAnchorEnabled = false,
petGroupAnchor = {
point = "CENTER",
x = 0,
y = 0,
},
-- petwidth = 55,
-- petheight = 55,
petScale = 0.8,
petUnitGrowth = "RIGHT",
petGroupGrowth = "TOP",
powerSize = 4,
healthOrientation = "VERTICAL",
unitGrowth = "RIGHT",
groupGrowth = "TOP",
groupsInRow = 1,
unitGap = 7,
groupGap = 7,
showSolo = true,
showParty = true,
showRaid = true,
cropNamesLen = 7,
sortMethod = "ROLE", -- "INDEX" or "NONE" | "ROLE" | "NAME"
showTargetedCount = false,
showCasts = true,
showGroupCasts = false,
showAggro = true,
showCCList = false,
showRaidIcons = true,
showDispels = true,
showSeparator = false,
showIconCooldownCount = false,
showFloatingIcons = true,
clampIncomingHeal = true,
healthTexture = "Gradient",
powerTexture = "Gradient",
damageEffect = true,
auraUpdateEffect = true,
gradientHealthColor = false,
healthColorByClass = true,
healthColor1 = {0,1,0},
healthColor2 = {1,1,0},
healthColor3 = {1,0,0},
incHealColor = {0.3, 1, 0.4, 0.4},
incHealColorAuto = true,
absorbColor = {0.7, 0.7, 1, 0.65},
absorbColorAuto = true,
nameColor = {1,1,1},
nameColorByClass = true,
useCustomBackgroundColor = false,
customBackgroundColor = {1,0,0},
powerColor = {0.5, 0.5, 1},
useCustomBackgroundColorPower = false,
customBackgroundColorPower = {0.5, 0.5, 1},
petColor = {1, 0.5, 0.5},
alphaOutOfRange = 0.45,
selBorderWidth = 2,
selBorderInset = 0,
scale = 1, --> into
debuffBossScale = 1.3,
nameColorMultiplier = 1,
fgShowMissing = true,
fgColorMultiplier = 1,
bgColorMultiplier = 0.2,
groupFilter = 255,
bgAlpha = 1,
widgetConfig = {},
},
}
Aptechka:RegisterEvent("PLAYER_LOGIN")
function Aptechka.PLAYER_LOGIN(self,event,arg1)
local uir2 = function(unit)
if UnitIsDeadOrGhost(unit) or UnitIsEnemy(unit, "player") then --IsSpellInRange doesn't work with dead people
return UnitInRange(unit)
else
return uir(unit)
end
end
AptechkaUnitInRange = uir2
local firstTimeUse = AptechkaDB_Global == nil
AptechkaDB_Global = AptechkaDB_Global or {}
AptechkaDB_Char = AptechkaDB_Char or {}
if apiLevel <= 3 then
if type(AptechkaDB_Char.forcedClassicRole) == "string" then
local oldRole = AptechkaDB_Char.forcedClassicRole
AptechkaDB_Char.forcedClassicRole = { [1] = oldRole }
end
end
self:DoMigrations(AptechkaDB_Global)
self.db = LibStub("AceDB-3.0"):New("AptechkaDB_Global", defaults, "Default") -- Create a DB using defaults and using a shared default profile
AptechkaDB = self.db
-- CUSTOM_CLASS_COLORS is from phanx's ClassColors addons
colors = setmetatable(customColors or {},{ __index = function(t,k) return (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[k] end })
AptechkaConfigCustom = AptechkaConfigCustom or {}
local _, class = UnitClass("player")
local categories = {"auras", "traces"}
if not AptechkaConfigCustom[class] then AptechkaConfigCustom[class] = {} end
-- Creates AptechkaConfigMerged, and updates 'config' upvalue
Aptechka:GenerateMergedConfig()
Aptechka:FixWidgetsAfterUpgrade()
-- compiling a list of spells that should activate indicator when missing
self:UpdateMissingAuraList()
Aptechka:UpdateUnprotectedUpvalues()
self.db.RegisterCallback(self, "OnProfileChanged", "Reconfigure")
self.db.RegisterCallback(self, "OnProfileCopied", "Reconfigure")
self.db.RegisterCallback(self, "OnProfileReset", "Reconfigure")
local customBlacklist = AptechkaDB.global.customBlacklist
blacklist = setmetatable({}, {
__index = function(t,k)
local custom = customBlacklist[k]
if custom ~= nil then
return custom
end
return defaultBlacklist[k]
end,
})
Aptechka.Roster = Roster
if AptechkaDB.global.disableBlizzardPlayer then
Aptechka:SafeCallDirect(helpers.DisableBlizzPlayerFrame)
end
if AptechkaDB.global.disableBlizzardParty then
helpers.DisableBlizzParty()
end
if AptechkaDB.global.hideBlizzardRaid then
helpers.DisableBlizzRaid()
end
if config.enableIncomingHeals then
if false then
function Aptechka:HealUpdated(event, casterGUID, spellID, healType, endTime, ...)
for i=1,select('#', ...) do
local targetGUID = select(i, ...)
local unit = guidMap[targetGUID]
if unit then
Aptechka:UNIT_HEAL_PREDICTION(nil, unit, targetGUID)
end
end
end
HealComm = LibStub:GetLibrary("LibHealComm-4.0",true);
local incomingHealIgnoreHots = false
if HealComm then
if incomingHealIgnoreHots then
HealComm.AptechkaHealType = HealComm.CASTED_HEALS
else
HealComm.AptechkaHealType = HealComm.ALL_HEALS
HealComm.RegisterCallback(self, "HealComm_HealUpdated", "HealUpdated"); -- hots
end
HealComm.RegisterCallback(self, "HealComm_HealStarted", "HealUpdated");
HealComm.RegisterCallback(self, "HealComm_HealStopped", "HealUpdated");
end
local incomingHealTimeframe = 3.5
GetIncomingHealsCustom = function (unit, excludePlayer)
local guid = UnitGUID(unit)
local heal = HealComm:GetHealAmount(guid, HealComm.AptechkaHealType, GetTime()+incomingHealTimeframe)
return heal or 0
end
function Aptechka.UNIT_HEAL_PREDICTION(self,event,unit)
self:UNIT_HEALTH(event, unit)
local heal = GetIncomingHealsCustom(unit, false)
local showHeal = (heal and heal > threshold)
SetJob(unit, config.IncomingHealStatus, showHeal, "INCOMING_HEAL", heal)
end
else
self:RegisterEvent("UNIT_HEAL_PREDICTION")
end
end
if LibClassicDurations then
LibClassicDurations:RegisterFrame(self)
UnitAura = LibClassicDurations.UnitAuraWrapper
Aptechka:UpdateSpellNameToIDTable()
end
if apiLevel <= 3 then
function Aptechka:SetClassicClickcastAttributes(f)
if f:CanChangeAttribute() then
-- this is only for classic, because its SGH doesn't have _initialAttributeNames
f:SetAttribute("_onenter",[[
local snippet = self:GetAttribute('clickcast_onenter'); if snippet then self:Run(snippet) end
self:CallMethod("onenter")
]])
f:SetAttribute("_onleave",[[
local snippet = self:GetAttribute('clickcast_onleave'); if snippet then self:Run(snippet) end
self:CallMethod("onleave")
]])
end
end
end
-- local tbind
-- if config.TargetBinding == nil then tbind = "*type1"
-- elseif config.TargetBinding == false then tbind = "__none__"
-- else tbind = config.TargetBinding end
-- local ccmacro = config.ClickCastingMacro or "__none__"
-- local width = pixelperfect(AptechkaDB.profile.width or config.width)
-- local height = pixelperfect(AptechkaDB.profile.height or config.height)
-- local scale = AptechkaDB.profile.scale or config.scale
-- local strata = config.frameStrata or "LOW"
self.initConfSnippet = [=[
RegisterUnitWatch(self)
local header = self:GetParent()
local width = header:GetAttribute("frameWidth")
local height = header:GetAttribute("frameHeight")
self:SetWidth(width)
self:SetHeight(height)
self:SetFrameStrata("LOW")
self:SetFrameLevel(3)
local isPetFrame = header:GetAttribute("isPetHeader")
self:SetAttribute("toggleForVehicle", not isPetFrame)
self:SetAttribute("allowVehicleTarget", false)
self:SetAttribute("*type1","target")
self:SetAttribute("shift-type2","togglemenu")
local ccheader = header:GetFrameRef("clickcast_header")
if ccheader then
ccheader:SetAttribute("clickcast_button", self)
ccheader:RunAttribute("clickcast_register")
end
header:CallMethod("initialConfigFunction", self:GetName())
]=]
if config.initialConfigPostHookSnippet then
self.initConfSnippet = self.initConfSnippet..config.initialConfigPostHookSnippet
end
Aptechka:SPELLS_CHANGED() -- Does the following:
-- Aptechka:UpdateRangeChecker()
-- Aptechka:UpdateDispelBitmask()
-- self:LayoutUpdate()
-- Switches to proper profile for the role
-- Reconf from it won't run until initialization is finished
self:UpdateDebuffScanningMethod()
self:UpdateHighlightedDebuffsHashMap()
self:RegisterEvent("UNIT_HEALTH")
if not isMainline then self:RegisterEvent("UNIT_HEALTH_FREQUENT") end
self:RegisterEvent("UNIT_MAXHEALTH")
Aptechka.UNIT_HEALTH_FREQUENT = Aptechka.UNIT_HEALTH
self:RegisterEvent("UNIT_CONNECTION")
if AptechkaDB.global.showAFK then
self:RegisterEvent("PLAYER_FLAGS_CHANGED") -- UNIT_AFK_CHANGED
end
self:RegisterEvent("UNIT_FACTION")
self:RegisterEvent("UNIT_FLAGS")
self:RegisterEvent("UNIT_PHASE")
--[[
-- default ui only checks updates alt power on these events
self:RegisterEvent("PARTY_MEMBER_ENABLE")
self:RegisterEvent("PARTY_MEMBER_DISABLE")
self.PARTY_MEMBER_ENABLE = self.UNIT_PHASE
self.PARTY_MEMBER_DISABLE = self.UNIT_PHASE
]]
if isMainline then
self:RegisterEvent("INCOMING_SUMMON_CHANGED")
end
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("CINEMATIC_STOP")
if isMainline then
self:RegisterEvent("UNIT_TARGETABLE_CHANGED")
end
if not config.disableManaBar then
self:RegisterEvent("UNIT_POWER_UPDATE")
self:RegisterEvent("UNIT_MAXPOWER")
self:RegisterEvent("UNIT_DISPLAYPOWER")
Aptechka.UNIT_MAXPOWER = Aptechka.UNIT_POWER_UPDATE
end
Aptechka:UpdateAggroConfig()
self:RegisterEvent("READY_CHECK")
self:RegisterEvent("READY_CHECK_CONFIRM")
self:RegisterEvent("READY_CHECK_FINISHED")
if config.TargetStatus then
self.previousTarget = "player"
self:RegisterEvent("PLAYER_TARGET_CHANGED")
end
if config.FocusStatus then
self.previousFocus = "player"
self:RegisterEvent("PLAYER_FOCUS_CHANGED")
end
if config.VoiceChatStatus then
self:RegisterEvent("VOICE_CHAT_CHANNEL_ACTIVATED")
self:RegisterEvent("VOICE_CHAT_CHANNEL_DEACTIVATED")
if (C_VoiceChat.GetActiveChannelType()) then
self:VOICE_CHAT_CHANNEL_ACTIVATED()
end
end
self:RegisterEvent("INCOMING_RESURRECT_CHANGED")
NickTag = LibStub("NickTag-1.0", true)
if NickTag then
NickTag.RegisterCallback("Aptechka", "NickTag_Update", function()
Aptechka:ForEachUnitFrame("player", Aptechka.FrameUpdateName)
end)
end
LibAuraTypes = LibStub("LibAuraTypes")
EffectIndices = {
[LibAuraTypes.E_SLOW] = 1,
[LibAuraTypes.E_ROOT] = 2,
[LibAuraTypes.E_DISORIENT] = 3,
[LibAuraTypes.E_DISARM] = 4,
[LibAuraTypes.E_SILENCE] = 5,
[LibAuraTypes.E_INCAP] = 6,
[LibAuraTypes.E_FEAR] = 7,
[LibAuraTypes.E_STUN] = 8,
[LibAuraTypes.E_ANTIDISPEL] = 9,
[LibAuraTypes.E_PHASED] = 10,
[LibAuraTypes.E_BADTHING] = 11,
}
-- if AptechkaDB.global.useDebuffOrdering then
LibSpellLocks = LibStub("LibSpellLocks")
LibSpellLocks.RegisterCallback("Aptechka", "UPDATE_INTERRUPT", function(event, guid)
local unit = guidMap[guid]
if unit then
Aptechka.ScanAuras(unit)
end
end)
-- end
if isMainline then
self:RegisterEvent("UNIT_ABSORB_AMOUNT_CHANGED")
self:RegisterEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED")
end
self:UpdateTargetedCountConfig()
self:UpdateIncomingCastsConfig()
self:UpdateOutgoingCastsConfig()
-- AptechkaDB.global.useCombatLogHealthUpdates = false
if apiLevel <= 3 and AptechkaDB.global.useCombatLogHealthUpdates then
local CLH = LibStub("LibCombatLogHealth-1.0")
UnitHealth = CLH.UnitHealth
self:UnregisterEvent("UNIT_HEALTH")
if not isMainline then self:UnregisterEvent("UNIT_HEALTH_FREQUENT") end
-- table.insert(config.HealthBarColor.assignto, "health2")
CLH.RegisterCallback(self, "COMBAT_LOG_HEALTH", function(event, unit, eventType)
return Aptechka:UNIT_HEALTH(eventType, unit)
-- return Aptechka:COMBAT_LOG_HEALTH(nil, unit, health)
end)
end
self:RegisterEvent("UNIT_AURA")
self:RegisterEvent("SPELLS_CHANGED")
self:RegisterEvent("GROUP_ROSTER_UPDATE")
if AptechkaDB.profile.showRaidIcons then
self:RegisterEvent("RAID_TARGET_UPDATE")
end
if config.enableVehicleSwap then
self:RegisterEvent("UNIT_ENTERED_VEHICLE")
end
skinAnchorsName = "GridSkin"
local i = 1
local maxGroups = 8
if Aptechka.db.global.singleHeaderMode then
maxGroups = 1
end
while (i <= maxGroups) do
local f = Aptechka:CreateHeader(i) -- if second arg is true then it's petgroup
group_headers[i] = f
i = i + 1
end
self:CreateAnchor(1)
self:CreateAnchor(2)
self:RepositionAnchors()
-- self.border = self:CreateBorder("AptechkaBorder")
self:UpdatePetGroupConfig()
if config.unlocked then anchors[1]:Show() end
local unitGrowth = AptechkaDB.profile.unitGrowth or config.unitGrowth
local groupGrowth = AptechkaDB.profile.groupGrowth or config.groupGrowth
Aptechka:SetGrowth(group_headers, unitGrowth, groupGrowth)
C_Timer.NewTicker(0.3, Aptechka.OnRangeUpdate)
Aptechka:Show()
if firstTimeUse or Aptechka.db.global.stayUnlocked then
Aptechka.Commands.unlock()
end
Aptechka:CreateDebuffTooltips()
Aptechka.tooltipPool.modchecks:MakeFromDB()
self:RegisterEvent("MODIFIER_STATE_CHANGED")
SLASH_APTECHKA1= "/aptechka"
SLASH_APTECHKA2= "/apt"
SLASH_APTECHKA3= "/inj"
SLASH_APTECHKA4= "/injector"
SlashCmdList["APTECHKA"] = Aptechka.SlashCmd
SLASH_APTROLEPOLL1= "/rolepoll"
SLASH_APTROLEPOLL2= "/rolecheck"
SlashCmdList["APTROLEPOLL"] = InitiateRolePoll
if config.LOSStatus then
self:RegisterEvent("UNIT_SPELLCAST_SENT")
self:RegisterEvent("UI_ERROR_MESSAGE")
end
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
if not self.db.global.LDBData.hide then
Aptechka:CreteMinimapIcon()
end
Aptechka:CreateBlizzOptionsPanel()
--[[
local f = CreateFrame('Frame', nil, InterfaceOptionsFrame)
f:SetScript('OnShow', function(self)
self:SetScript('OnShow', nil)
LoadAddOn('AptechkaOptions')
Aptechka:ForAllCustomStatuses(function(opts, status, list)
if not opts.assignto then return end
for slot in pairs(opts.assignto) do
if not list[slot] then
Aptechka:PrintDeadAssignmentWarning(slot, opts.name or status)
end
end
end, false)
end)
]]
self.isInitialized = true
end -- END PLAYER_LOGIN
function Aptechka:GenerateMergedConfig()
AptechkaConfigMerged = CopyTable(AptechkaDefaultConfig)
config = AptechkaConfigMerged
local _, class = UnitClass("player")
local function fixRemovedDefaultSpells(customConfig, defaultConfig)
if not (customConfig and defaultConfig) then return end
local toRemove = {}
for spellID, opts in pairs(customConfig) do
local dopts = defaultConfig[spellID]
if not dopts and not opts.name then
table.insert(toRemove, spellID)
elseif opts.name then -- then it's a is probably an added spell
opts.isAdded = true -- making sure it's marked as added
end
end
for _, spellID in ipairs(toRemove) do
customConfig[spellID] = nil
end
end
local fixOldAuraFormat = function(customConfigPart)
if not customConfigPart then return end
for id, opts in pairs(customConfigPart) do
if opts.id == nil then
opts.id = id
end
end
end
local templateConfig = AptechkaConfigCustom["TEMPLATES"]
Aptechka.util.MergeTable(AptechkaConfigMerged.templates, templateConfig)
local globalConfig = AptechkaConfigCustom["GLOBAL"]
if globalConfig then
fixOldAuraFormat(globalConfig.auras)
fixOldAuraFormat(globalConfig.traces)
fixRemovedDefaultSpells(globalConfig.auras, config.GLOBAL.auras)
fixRemovedDefaultSpells(globalConfig.traces, config.GLOBAL.traces)
end
Aptechka.util.MergeTable(AptechkaConfigMerged.GLOBAL, globalConfig)
local classConfig = AptechkaConfigCustom[class]
if classConfig then
fixOldAuraFormat(classConfig.auras)
fixOldAuraFormat(classConfig.traces)
fixRemovedDefaultSpells(classConfig.auras, config[class].auras)
fixRemovedDefaultSpells(classConfig.traces, config[class].traces)
end
Aptechka.util.MergeTable(AptechkaConfigMerged[class], classConfig)
local widgetConfig = AptechkaConfigCustom["WIDGET"]
Aptechka.util.MergeTable(AptechkaConfigMerged, widgetConfig)
-- Merge GLOBAL anc CLASS into one
config.auras = config.GLOBAL.auras
config.traces = config.GLOBAL.traces
Aptechka.util.MergeTable(config.auras, config[class].auras)
Aptechka.util.MergeTable(config.traces, config[class].traces)
config.GLOBAL = nil
config[class] = nil
if apiLevel == 1 then
Aptechka.spellNameToID = helpers.spellNameToID
Aptechka:UpdateSpellNameToIDTable()
end
-- Template application
helpers.UnwrapConfigTemplates(AptechkaConfigMerged.traces)
helpers.UnwrapConfigTemplates(AptechkaConfigMerged.auras)
-- Updating upvalues
config.DebuffTypes = config.DebuffTypes or {}
config.DebuffDisplay = config.DebuffDisplay or {}
config.auras = config.auras or {}
config.traces = config.traces or {}
auras = config.auras
traceheals = config.traces
-- filling up ranks for auras
local cloneIDs = {}
local rankCategories = { "auras", "traces" }
local tempTable = {}
for _, category in ipairs(rankCategories) do
table_wipe(tempTable)
for spellID, opts in pairs(config[category]) do
if not cloneIDs[spellID] and opts.clones then
opts.clones[spellID] = nil -- Removing possible input of original spell ID into clone list
for additionalSpellID, enabled in pairs(opts.clones) do
if enabled then
tempTable[additionalSpellID] = opts
cloneIDs[additionalSpellID] = true
end
end
end
end
for spellID, opts in pairs(tempTable) do
config[category][spellID] = opts
end
end
AptechkaConfigMerged.spellClones = cloneIDs
for spellID, originalSpell in pairs(traceheals) do
if not cloneIDs[spellID] and originalSpell.clones then
for additionalSpellID, enabled in pairs(originalSpell.clones) do
if enabled then
traceheals[additionalSpellID] = originalSpell
cloneIDs[additionalSpellID] = true
end
end
end
end
end
local uniqueToken = 0
local function makeUnique()
uniqueToken = uniqueToken + 1
return uniqueToken
end
function Aptechka:ToggleCompactRaidFrames()
local v = IsAddOnLoaded("Blizzard_CompactRaidFrames")
local f = v and DisableAddOn or EnableAddOn
f("Blizzard_CompactRaidFrames")
f("Blizzard_CUFProfiles")
ReloadUI()
end
function Aptechka:UpdateMissingAuraList()
table_wipe(missingFlagSpells)
for spellID, opts in pairs(auras) do
if opts.isMissing and not opts.disabled then
missingFlagSpells[opts.id] = opts
end
end
end
function Aptechka:CreatePetGroup()
local lastHeader = group_headers[#group_headers]
if lastHeader.isPetGroup then return end -- already exists
local pets = Aptechka:CreateHeader(9,true)
table.insert(group_headers, pets)
group_headers.pet = pets
pets:Show()
end
function Aptechka:UpdatePetGroupConfig()
if self.db.profile.petGroup then
Aptechka:CreatePetGroup()
end
if group_headers.pet then
group_headers.pet:UpdateVisibility()
end
end
function Aptechka.FrameUpdateName(frame, unit)
local name = frame.state.nameFull
if Aptechka.db.global.translitCyrillic then
name = LibTranslit:Transliterate(name)
end
if NickTag and Aptechka.db.global.enableNickTag then
local nickname = NickTag:GetNickname(name, nil, true) -- name, default, silent
if nickname then name = nickname end
end
frame.state.name = name and utf8sub(name,1, AptechkaDB.profile.cropNamesLen) or "Unknown"
FrameSetJob(frame, config.UnitNameStatus, true, nil, frame.state.name, makeUnique())
end
function Aptechka.GetWidgetListRaw()
local list = {}
for slot in pairs(Aptechka.optional_widgets) do
list[slot] = string.format("|cffbbbbbb%s|r",slot)--slot
end
for slot, opts in pairs(Aptechka.db.global.widgetConfig) do
if config.DefaultWidgets[slot] then
list[slot] = slot
else
list[slot] = string.format("|cff77ff77%s|r",slot)
end
end
list["border"] = "border"
list["healthColor"] = "HealthColor"
list["mouseoverHighlight"] = "MouseoverHighlight"
-- list["frameAlpha"] = "FrameAlpha"
return list
end
function Aptechka.GetWidgetList()
local list = Aptechka.GetWidgetListRaw()
list["statusIcon"] = nil
list["raidTargetIcon"] = nil
-- list["roleIcon"] = nil
list["debuffIcons"] = nil
list["mindcontrol"] = nil
-- list["unhealable"] = nil
-- list["vehicle"] = nil
-- list["text1"] = nil
list["incomingCastIcon"] = nil
list["floatingIcon"] = nil
return list
end
function Aptechka:Reconfigure()
if not self.isInitialized then return end
if InCombatLockdown() then self:RegisterEvent("PLAYER_REGEN_ENABLED"); return end
self:ReconfigureProtected()
self:ReconfigureUnprotected()
self:ReconfigureAllWidgets()
self:UpdateDebuffScanningMethod()
self:UpdateRaidIconsConfig()
self:UpdateAggroConfig()
self:UpdateIncomingCastsConfig()
self:UpdateOutgoingCastsConfig()
end
function Aptechka:RefreshAllUnitsHealth()
Aptechka:ForEachFrame(Aptechka.FrameUpdateHealth)
Aptechka:ForEachFrame(function(frame, unit)
Aptechka.FrameUpdatePower(frame, unit, "MANA")
end)
end
function Aptechka.FrameUpdateUnitColor(frame, unit)
Aptechka.FrameColorize(frame, unit)
FrameSetJob(frame, config.UnitNameStatus, true, nil, makeUnique())
FrameSetJob(frame, config.HealthBarColor, true, nil, makeUnique())
if not frame.power.disabled then FrameSetJob(frame, config.PowerBarColor, true, nil, makeUnique()) end
end
function Aptechka:RefreshAllUnitsColors()
Aptechka:ForEachFrame(Aptechka.FrameUpdateName)
Aptechka:ForEachFrame(Aptechka.FrameUpdateUnitColor)
end
function Aptechka:ReconfigureAllWidgets()
for widgetName in pairs(Aptechka.db.global.widgetConfig) do
self:ReconfigureWidget(widgetName)
end
end
function Aptechka:ReconfigureWidget(widgetName)
local gopts = Aptechka.db.global.widgetConfig[widgetName]
local popts = Aptechka.db.profile.widgetConfig[widgetName]
local reconfFunc = Aptechka.Widget[gopts.type].Reconf
if reconfFunc then
Aptechka:ForEachFrame(function(frame)
local widget = frame[widgetName]
if widget then
reconfFunc(frame, widget, popts, gopts)
end
end)
end
end
function Aptechka:ReconfigureUnprotected()
self:UpdateUnprotectedUpvalues()
for group, header in ipairs(group_headers) do
for _, f in ipairs({ header:GetChildren() }) do
f:ReconfigureUnitFrame()
Aptechka:SafeCall("PostFrameUpdate", f)
end
end
self:RefreshAllUnitsColors()
self:RefreshAllUnitsHealth() -- Updates health with new settings fg/bg settings after switch
end
function Aptechka:UpdateUnprotectedUpvalues()
ignoreplayer = config.incomingHealIgnorePlayer or false
fgShowMissing = Aptechka.db.profile.fgShowMissing
gradientHealthColor = Aptechka.db.profile.gradientHealthColor
damageEffect = Aptechka.db.profile.damageEffect
mergedIncomingHealing = AptechkaConfigMerged.HealthTextStatus.formatType == "MISSING_HEALING_SHORT"
enableTraceheals = config.enableTraceHeals and next(traceheals)
enableAuraEvents = Aptechka.db.profile.auraUpdateEffect
enableFloatingIcon = Aptechka.db.profile.showFloatingIcons
alphaOutOfRange = Aptechka.db.profile.alphaOutOfRange
end
function Aptechka:ReconfigureProtected()
if InCombatLockdown() then self:RegisterEvent("PLAYER_REGEN_ENABLED"); return end
self:RepositionAnchors()
self:UpdatePetGroupConfig()
self:ReconfigureTestHeaders()
local _width = pixelperfect(AptechkaDB.profile.width or config.width)
local _height = pixelperfect(AptechkaDB.profile.height or config.height)
local _scale = AptechkaDB.profile.scale or config.scale
-- local strata = config.frameStrata or "LOW"
-- self.initConfSnippet = self.makeConfSnippet(width, height, strata)
for groupId, header in ipairs(group_headers) do
local width = _width
local height = _height
local scale = _scale
if header.isPetGroup then
-- width = pixelperfect(AptechkaDB.profile.petwidth)
-- height = pixelperfect(AptechkaDB.profile.petheight)
scale = scale * AptechkaDB.profile.petScale
end
if header:CanChangeAttribute() then
-- header:SetAttribute("frameWidth", width)
-- header:SetAttribute("frameHeight", height)
helpers.setAttributesWithoutResponse(header,
"frameWidth", width,
"frameHeight", height)