-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.lua
More file actions
774 lines (678 loc) · 19.4 KB
/
Core.lua
File metadata and controls
774 lines (678 loc) · 19.4 KB
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
local addonName, addonTable = ...
local NoPoizen = _G.NoPoizen or addonTable or {}
_G.NoPoizen = NoPoizen
NoPoizen.addonName = addonName or "NoPoizen"
NoPoizen.MISSING_SOUND_FILE_PATH = "Interface\\AddOns\\NoPoizen\\nopoizen.wav"
NoPoizen.SATISFIED_SOUND_FILE_PATH = "Interface\\AddOns\\NoPoizen\\hahaha.wav"
NoPoizen.DRAGON_TEMPERED_BLADES_SPELL_ID = 381801
NoPoizen.WIDGET_SCALE_MIN = 0.6
NoPoizen.WIDGET_SCALE_MAX = 2.0
NoPoizen.WIDGET_SCALE_STEP = 0.05
NoPoizen.AUDIO_VOLUME_MIN = 0
NoPoizen.AUDIO_VOLUME_MAX = 1
NoPoizen.AUDIO_VOLUME_STEP = 0.05
NoPoizen.AUDIO_TRANSITION_ARM_DELAY_SECONDS = 5.0
NoPoizen.POST_LOAD_POISON_REFRESH_DELAY_SECONDS = 1.5
NoPoizen.DEFAULT_INDICATOR_ANCHOR = {
point = "CENTER",
relativePoint = "CENTER",
x = 0,
y = 140,
}
NoPoizen.DEFAULTS = {
enabled = true,
showVisualIndicator = true,
playAudioIndicator = true,
audioVolume = 0.5,
playSatisfiedAudioIndicator = true,
satisfiedAudioVolume = 0.5,
widgetScale = 1.0,
indicatorAnchor = {
point = "CENTER",
relativePoint = "CENTER",
x = 0,
y = 140,
},
}
NoPoizen.isInitialized = NoPoizen.isInitialized or false
NoPoizen.hasLoggedIn = NoPoizen.hasLoggedIn or false
NoPoizen.isEnabled = NoPoizen.isEnabled or false
NoPoizen.audioMissingState = NoPoizen.audioMissingState or false
NoPoizen.audioTransitionsArmed = NoPoizen.audioTransitionsArmed or false
NoPoizen.audioTransitionsArmAt = NoPoizen.audioTransitionsArmAt or 0
NoPoizen.isLoadingScreenActive = NoPoizen.isLoadingScreenActive or false
NoPoizen.postLoadRefreshAt = NoPoizen.postLoadRefreshAt or 0
NoPoizen.postLoadRefreshToken = NoPoizen.postLoadRefreshToken or 0
NoPoizen.runtimeEvents = {
"PLAYER_ENTERING_WORLD",
"LOADING_SCREEN_ENABLED",
"LOADING_SCREEN_DISABLED",
"UNIT_AURA",
"SPELLS_CHANGED",
"PLAYER_TALENT_UPDATE",
"ACTIVE_TALENT_GROUP_CHANGED",
"PLAYER_SPECIALIZATION_CHANGED",
"TRAIT_CONFIG_UPDATED",
"TRAIT_CONFIG_LIST_UPDATED",
}
NoPoizen.API = NoPoizen.API or {
Delay = function(delaySeconds, callbackFn)
if C_Timer and C_Timer.After then
C_Timer.After(delaySeconds, callbackFn)
end
end,
GetTime = function()
return GetTime and GetTime() or 0
end,
}
local function IsNonEmptyString(value)
return type(value) == "string" and value ~= ""
end
function NoPoizen:SafeToString(value, fallback)
if value == nil then
return fallback or ""
end
return tostring(value)
end
function NoPoizen:DeepCopy(value)
if type(value) ~= "table" then
return value
end
local copy = {}
for key, item in pairs(value) do
copy[key] = self:DeepCopy(item)
end
return copy
end
function NoPoizen:ApplyDefaults(destination, defaults)
if type(destination) ~= "table" or type(defaults) ~= "table" then
return destination
end
for key, defaultValue in pairs(defaults) do
if destination[key] == nil then
destination[key] = self:DeepCopy(defaultValue)
elseif type(defaultValue) == "table" and type(destination[key]) == "table" then
self:ApplyDefaults(destination[key], defaultValue)
end
end
return destination
end
function NoPoizen:Print(message)
local text = "|cffff4f4fNoPoizen|r: " .. self:SafeToString(message)
if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
DEFAULT_CHAT_FRAME:AddMessage(text)
else
print("NoPoizen:", self:SafeToString(message))
end
end
function NoPoizen:GetPlayerClassFile()
local _, classFile = UnitClass("player")
return classFile
end
function NoPoizen:IsPlayerRogue()
return self:GetPlayerClassFile() == "ROGUE"
end
function NoPoizen:NormalizeWidgetScale(value)
local numberValue = tonumber(value)
if not numberValue then
return nil
end
local step = self.WIDGET_SCALE_STEP
numberValue = math.floor((numberValue / step) + 0.5) * step
numberValue = math.floor((numberValue * 100) + 0.5) / 100
if numberValue < self.WIDGET_SCALE_MIN or numberValue > self.WIDGET_SCALE_MAX then
return nil
end
return numberValue
end
function NoPoizen:NormalizeAudioVolume(value)
local numberValue = tonumber(value)
if not numberValue then
return nil
end
local step = self.AUDIO_VOLUME_STEP
numberValue = math.floor((numberValue / step) + 0.5) * step
numberValue = math.floor((numberValue * 100) + 0.5) / 100
if numberValue < self.AUDIO_VOLUME_MIN or numberValue > self.AUDIO_VOLUME_MAX then
return nil
end
return numberValue
end
function NoPoizen:GetEffectiveAudioVolume(value)
local normalized = self:NormalizeAudioVolume(value)
if not normalized then
normalized = self:NormalizeAudioVolume(self:GetOption("audioVolume")) or self.DEFAULTS.audioVolume
end
return math.min(1, normalized * 2)
end
function NoPoizen:ResetAudioTransitionArming(delaySeconds)
local delay = tonumber(delaySeconds)
if not delay or delay < 0 then
delay = self.AUDIO_TRANSITION_ARM_DELAY_SECONDS
end
local now = 0
if self.API and self.API.GetTime then
now = tonumber(self.API.GetTime()) or 0
elseif GetTime then
now = tonumber(GetTime()) or 0
end
self.audioMissingState = false
self.audioTransitionsArmed = false
self.audioTransitionsArmAt = now + delay
end
function NoPoizen:SchedulePostLoadPoisonRefresh(delaySeconds)
local delay = tonumber(delaySeconds)
if not delay or delay < 0 then
delay = self.POST_LOAD_POISON_REFRESH_DELAY_SECONDS
end
local now = 0
if self.API and self.API.GetTime then
now = tonumber(self.API.GetTime()) or 0
elseif GetTime then
now = tonumber(GetTime()) or 0
end
self.postLoadRefreshAt = now + delay
self.postLoadRefreshToken = (self.postLoadRefreshToken or 0) + 1
local scheduledToken = self.postLoadRefreshToken
-- Arm transition audio no earlier than the first post-loading refresh.
self.audioTransitionsArmed = false
self.audioTransitionsArmAt = self.postLoadRefreshAt
if self.API and self.API.Delay then
self.API.Delay(delay, function()
if scheduledToken ~= self.postLoadRefreshToken then
return
end
if not self.isEnabled or self.isLoadingScreenActive then
return
end
if self.RefreshPoisonState then
self:RefreshPoisonState("POST_LOADING_REFRESH")
end
end)
end
end
function NoPoizen:InitializeDatabase()
if type(_G.NoPoizenDBChar) ~= "table" then
_G.NoPoizenDBChar = {}
end
self.db = _G.NoPoizenDBChar
self:ApplyDefaults(self.db, self.DEFAULTS)
self.db.widgetScale = self:NormalizeWidgetScale(self.db.widgetScale) or self.DEFAULTS.widgetScale
self.db.audioVolume = self:NormalizeAudioVolume(self.db.audioVolume) or self.DEFAULTS.audioVolume
self.db.satisfiedAudioVolume = self:NormalizeAudioVolume(self.db.satisfiedAudioVolume) or self.DEFAULTS.satisfiedAudioVolume
end
function NoPoizen:GetOption(optionKey)
if not self.db then
return nil
end
return self.db[optionKey]
end
function NoPoizen:SetOption(optionKey, value)
if not self.db then
return false
end
local normalizedValue = value
if
optionKey == "showVisualIndicator"
or optionKey == "playAudioIndicator"
or optionKey == "playSatisfiedAudioIndicator"
or optionKey == "enabled"
then
normalizedValue = value and true or false
elseif optionKey == "widgetScale" then
normalizedValue = self:NormalizeWidgetScale(value)
if not normalizedValue then
return false
end
elseif optionKey == "audioVolume" or optionKey == "satisfiedAudioVolume" then
normalizedValue = self:NormalizeAudioVolume(value)
if not normalizedValue then
return false
end
else
return false
end
local oldValue = self.db[optionKey]
if oldValue == normalizedValue then
return true
end
self.db[optionKey] = normalizedValue
if optionKey == "enabled" then
if normalizedValue then
self:Enable()
else
self:Disable()
end
else
if self.RefreshPoisonState then
self:RefreshPoisonState("OPTION_CHANGED")
end
if self.RefreshPoisonIndicatorVisualState then
self:RefreshPoisonIndicatorVisualState()
end
end
if self.RefreshOptionsWindow then
self:RefreshOptionsWindow()
end
return true
end
function NoPoizen:GetIndicatorAnchor()
local anchor = (self.db and self.db.indicatorAnchor) or self.DEFAULT_INDICATOR_ANCHOR
return {
point = IsNonEmptyString(anchor.point) and anchor.point or self.DEFAULT_INDICATOR_ANCHOR.point,
relativePoint = IsNonEmptyString(anchor.relativePoint) and anchor.relativePoint or self.DEFAULT_INDICATOR_ANCHOR.relativePoint,
x = tonumber(anchor.x) or self.DEFAULT_INDICATOR_ANCHOR.x,
y = tonumber(anchor.y) or self.DEFAULT_INDICATOR_ANCHOR.y,
}
end
function NoPoizen:SetIndicatorAnchor(point, relativePoint, x, y)
if not self.db then
return false
end
if not IsNonEmptyString(point) or not IsNonEmptyString(relativePoint) then
return false
end
local roundedX = tonumber(x) or 0
local roundedY = tonumber(y) or 0
if roundedX >= 0 then
roundedX = math.floor(roundedX + 0.5)
else
roundedX = math.ceil(roundedX - 0.5)
end
if roundedY >= 0 then
roundedY = math.floor(roundedY + 0.5)
else
roundedY = math.ceil(roundedY - 0.5)
end
local existing = self:GetIndicatorAnchor()
local changed = existing.point ~= point
or existing.relativePoint ~= relativePoint
or existing.x ~= roundedX
or existing.y ~= roundedY
if not changed then
return false
end
self.db.indicatorAnchor = {
point = point,
relativePoint = relativePoint,
x = roundedX,
y = roundedY,
}
if self.ApplySavedIndicatorAnchor then
self:ApplySavedIndicatorAnchor()
end
return true
end
function NoPoizen:ResetIndicatorAnchor()
return self:SetIndicatorAnchor(
self.DEFAULT_INDICATOR_ANCHOR.point,
self.DEFAULT_INDICATOR_ANCHOR.relativePoint,
self.DEFAULT_INDICATOR_ANCHOR.x,
self.DEFAULT_INDICATOR_ANCHOR.y
)
end
function NoPoizen:ForEachHelpfulAura(unitToken, callback)
if type(callback) ~= "function" then
return
end
if C_UnitAuras and C_UnitAuras.GetAuraDataByIndex then
for auraIndex = 1, 255 do
local aura = C_UnitAuras.GetAuraDataByIndex(unitToken, auraIndex, "HELPFUL")
if not aura then
break
end
callback(aura.spellId, aura.name, aura.icon)
end
return
end
if UnitAura then
for auraIndex = 1, 40 do
local name, icon, _, _, _, _, _, _, _, spellID = UnitAura(unitToken, auraIndex, "HELPFUL")
if not name then
break
end
callback(spellID, name, icon)
end
end
end
local function ClampZeroToOne(value)
local numberValue = tonumber(value) or 0
if numberValue < 0 then
return 0
end
if numberValue > 1 then
return 1
end
return numberValue
end
function NoPoizen:AcquireTemporaryChannelVolume(cvarName, targetVolume)
if not cvarName or cvarName == "" or type(SetCVar) ~= "function" then
return false
end
self.activeChannelVolumeLocks = self.activeChannelVolumeLocks or {}
local lock = self.activeChannelVolumeLocks[cvarName]
if not lock then
lock = {
depth = 0,
original = tonumber(GetCVar and GetCVar(cvarName)) or 1,
}
self.activeChannelVolumeLocks[cvarName] = lock
end
lock.depth = lock.depth + 1
local clampedTarget = ClampZeroToOne(targetVolume)
SetCVar(cvarName, tostring(clampedTarget))
return true
end
function NoPoizen:ReleaseTemporaryChannelVolume(cvarName)
if not cvarName or cvarName == "" or type(SetCVar) ~= "function" then
return
end
if not self.activeChannelVolumeLocks then
return
end
local lock = self.activeChannelVolumeLocks[cvarName]
if not lock then
return
end
lock.depth = (lock.depth or 0) - 1
if lock.depth > 0 then
return
end
SetCVar(cvarName, tostring(ClampZeroToOne(lock.original)))
self.activeChannelVolumeLocks[cvarName] = nil
end
function NoPoizen:RestoreChannelVolumeAfterPlayback(cvarName, soundHandle)
local maxWaitSeconds = 10
local pollSeconds = 0.05
if soundHandle and C_Sound and type(C_Sound.IsPlaying) == "function" and self.API and self.API.GetTime and self.API.Delay then
local startTime = self.API.GetTime()
local function Poll()
local isPlaying = C_Sound.IsPlaying(soundHandle)
local elapsed = (self.API.GetTime() or 0) - (startTime or 0)
if isPlaying and elapsed < maxWaitSeconds then
self.API.Delay(pollSeconds, Poll)
return
end
self:ReleaseTemporaryChannelVolume(cvarName)
end
self.API.Delay(pollSeconds, Poll)
return
end
if self.API and self.API.Delay then
self.API.Delay(1.25, function()
self:ReleaseTemporaryChannelVolume(cvarName)
end)
else
self:ReleaseTemporaryChannelVolume(cvarName)
end
end
function NoPoizen:PlayAlertSound(soundFilePath, volumeOptionKey)
if type(soundFilePath) ~= "string" or soundFilePath == "" then
return false
end
local volume = self:GetEffectiveAudioVolume(self:GetOption(volumeOptionKey))
if volume <= 0 then
return false
end
local channel = "Dialog"
local channelVolumeCVar = "Sound_DialogVolume"
if GetCVar and GetCVar("Sound_EnableDialog") == "0" then
channel = "SFX"
channelVolumeCVar = "Sound_SFXVolume"
end
if not self:AcquireTemporaryChannelVolume(channelVolumeCVar, volume) then
local willPlay = PlaySoundFile(soundFilePath, channel)
return willPlay and true or false
end
local willPlay, soundHandle = PlaySoundFile(soundFilePath, channel)
if not willPlay then
self:ReleaseTemporaryChannelVolume(channelVolumeCVar)
return false
end
self:RestoreChannelVolumeAfterPlayback(channelVolumeCVar, type(soundHandle) == "number" and soundHandle or nil)
return true
end
function NoPoizen:PlayMissingPoisonSound()
return self:PlayAlertSound(self.MISSING_SOUND_FILE_PATH, "audioVolume")
end
function NoPoizen:PlaySatisfiedPoisonSound()
return self:PlayAlertSound(self.SATISFIED_SOUND_FILE_PATH, "satisfiedAudioVolume")
end
function NoPoizen:RegisterRuntimeEvents()
self.registeredRuntimeEvents = self.registeredRuntimeEvents or {}
wipe(self.registeredRuntimeEvents)
for _, eventName in ipairs(self.runtimeEvents) do
self.eventFrame:RegisterEvent(eventName)
self.registeredRuntimeEvents[eventName] = true
end
end
function NoPoizen:UnregisterRuntimeEvents()
for eventName in pairs(self.registeredRuntimeEvents or {}) do
self.eventFrame:UnregisterEvent(eventName)
end
if self.registeredRuntimeEvents then
wipe(self.registeredRuntimeEvents)
end
end
function NoPoizen:Enable()
if not self.db then
return false
end
self.db.enabled = true
if not self.hasLoggedIn then
return true
end
if self.isEnabled then
return true
end
self:RegisterRuntimeEvents()
self.isEnabled = true
self.isLoadingScreenActive = false
self.postLoadRefreshAt = 0
self.postLoadRefreshToken = (self.postLoadRefreshToken or 0) + 1
self:ResetAudioTransitionArming()
if self.EnsurePoisonIndicatorWidget then
self:EnsurePoisonIndicatorWidget()
end
if self.TryInstallPoisonIndicatorEditModeHooks then
self:TryInstallPoisonIndicatorEditModeHooks()
end
if self.RefreshPoisonState then
self:RefreshPoisonState("ENABLE")
end
if self.RefreshPoisonIndicatorVisualState then
self:RefreshPoisonIndicatorVisualState()
end
return true
end
function NoPoizen:Disable()
if not self.db then
return false
end
self.db.enabled = false
if not self.isEnabled then
return true
end
self:UnregisterRuntimeEvents()
self.isEnabled = false
self.isLoadingScreenActive = false
self.postLoadRefreshAt = 0
self.postLoadRefreshToken = (self.postLoadRefreshToken or 0) + 1
self.audioMissingState = false
self.audioTransitionsArmed = false
self.audioTransitionsArmAt = 0
if self.DeselectPoisonIndicatorAnchor then
self:DeselectPoisonIndicatorAnchor()
end
if self.RefreshPoisonIndicatorVisualState then
self:RefreshPoisonIndicatorVisualState()
end
return true
end
function NoPoizen:OpenHudEditMode()
if not EditModeManagerFrame then
UIParentLoadAddOn("Blizzard_EditMode")
end
if EditModeManagerFrame and ShowUIPanel then
ShowUIPanel(EditModeManagerFrame)
return true
end
return false
end
function NoPoizen:InitializeSlashCommands()
SLASH_NOPOIZEN1 = "/nopoizen"
SLASH_NOPOIZEN2 = "/np"
SlashCmdList.NOPOIZEN = function(input)
NoPoizen:HandleSlashCommand(input or "")
end
end
function NoPoizen:HandleSlashCommand(input)
local command = string.match(input or "", "^(%S+)") or ""
command = string.lower(command)
if command == "" or command == "options" then
if not self:OpenOptionsWindow() then
self:Print("Options are unavailable right now.")
end
return
end
if command == "edit" then
if not self:OpenHudEditMode() then
self:Print("HUD Edit Mode is unavailable.")
end
return
end
if command == "test" then
if self.RunTests then
self:RunTests()
else
self:Print("Tests are unavailable.")
end
return
end
if command == "enable" then
self:SetOption("enabled", true)
self:Print("NoPoizen enabled.")
return
end
if command == "disable" then
self:SetOption("enabled", false)
self:Print("NoPoizen disabled.")
return
end
self:Print("Commands: /nopoizen options | edit | enable | disable | test")
end
function NoPoizen:OnInitialize()
self:InitializeDatabase()
self:InitializeSlashCommands()
if self.InitializeOptionsWindow then
self:InitializeOptionsWindow()
end
if self.TryInstallPoisonIndicatorEditModeHooks then
self:TryInstallPoisonIndicatorEditModeHooks()
end
self.isInitialized = true
end
function NoPoizen:OnLogin()
self.hasLoggedIn = true
if self:GetOption("enabled") then
self:Enable()
else
self:Disable()
end
end
function NoPoizen:ADDON_LOADED(_, loadedAddonName)
if loadedAddonName == "Blizzard_EditMode" and self.TryInstallPoisonIndicatorEditModeHooks then
self:TryInstallPoisonIndicatorEditModeHooks()
end
if loadedAddonName ~= self.addonName then
return
end
if not self.isInitialized then
self:OnInitialize()
end
end
function NoPoizen:PLAYER_LOGIN()
if not self.isInitialized then
self:OnInitialize()
end
self:OnLogin()
end
function NoPoizen:PLAYER_ENTERING_WORLD()
if self.isEnabled then
if self.isLoadingScreenActive or (tonumber(self.postLoadRefreshAt) or 0) > 0 then
return
end
self:ResetAudioTransitionArming()
end
if self.isEnabled and self.RefreshPoisonState then
self:RefreshPoisonState("PLAYER_ENTERING_WORLD")
end
end
function NoPoizen:LOADING_SCREEN_ENABLED()
if not self.isEnabled then
return
end
self.isLoadingScreenActive = true
self.postLoadRefreshAt = 0
self.postLoadRefreshToken = (self.postLoadRefreshToken or 0) + 1
self:ResetAudioTransitionArming()
end
function NoPoizen:LOADING_SCREEN_DISABLED()
if not self.isEnabled then
return
end
self.isLoadingScreenActive = false
self:SchedulePostLoadPoisonRefresh()
end
function NoPoizen:UNIT_AURA(_, unitToken)
if not self.isEnabled or unitToken ~= "player" then
return
end
if self.RefreshPoisonState then
self:RefreshPoisonState("UNIT_AURA")
end
end
function NoPoizen:PLAYER_TALENT_UPDATE()
if self.isEnabled and self.RefreshPoisonState then
self:RefreshPoisonState("PLAYER_TALENT_UPDATE")
end
end
function NoPoizen:SPELLS_CHANGED()
if self.isEnabled and self.RefreshPoisonState then
self:RefreshPoisonState("SPELLS_CHANGED")
end
end
function NoPoizen:ACTIVE_TALENT_GROUP_CHANGED()
if self.isEnabled and self.RefreshPoisonState then
self:RefreshPoisonState("ACTIVE_TALENT_GROUP_CHANGED")
end
end
function NoPoizen:PLAYER_SPECIALIZATION_CHANGED(_, unitToken)
if unitToken ~= "player" then
return
end
if self.isEnabled and self.RefreshPoisonState then
self:RefreshPoisonState("PLAYER_SPECIALIZATION_CHANGED")
end
end
function NoPoizen:TRAIT_CONFIG_UPDATED()
if self.isEnabled and self.RefreshPoisonState then
self:RefreshPoisonState("TRAIT_CONFIG_UPDATED")
end
end
function NoPoizen:TRAIT_CONFIG_LIST_UPDATED()
if self.isEnabled and self.RefreshPoisonState then
self:RefreshPoisonState("TRAIT_CONFIG_LIST_UPDATED")
end
end
local function DispatchEvent(_, eventName, ...)
local handler = NoPoizen[eventName]
if type(handler) ~= "function" then
return
end
handler(NoPoizen, eventName, ...)
end
NoPoizen.eventFrame = NoPoizen.eventFrame or CreateFrame("Frame")
NoPoizen.eventFrame:SetScript("OnEvent", DispatchEvent)
NoPoizen.eventFrame:RegisterEvent("ADDON_LOADED")
NoPoizen.eventFrame:RegisterEvent("PLAYER_LOGIN")