-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFlashTaskBar.lua
1366 lines (1224 loc) · 49.5 KB
/
FlashTaskBar.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
---@type detailsframework
local DF = _G ["DetailsFramework"]
if (not DF) then
print ("|cFFFFAA00FlashTaskBar: framework not found, if you just installed or updated the addon, please restart your client.|r")
return
end
local _
local L = LibStub ("AceLocale-3.0"):GetLocale ("FlashTaskbarLocales", true)
if (not L) then
DF:ShowPanicWarning ("FlashTaskbar Locale failed to load, restart your game client to finish addon updates.")
return
end
--> when true it will print what triggered the flash
local FlashDebug = false
do
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
SharedMedia:Register ("sound", "d_whip1", [[Interface\Addons\FlashTaskBar\sounds\sound_whip1.ogg]])
end
local default_config = {
profile = {
readycheck = true,
arena_queue = true,
group_queue = true,
petbattle_queue = true,
brawlers_queue = true,
pull_timers = true,
enter_combat = false,
end_taxi = false,
chat_scan = false,
chat_scan_keywords = {},
combat_log = false,
combat_log_keywords = {},
rare_scan = true,
any_rare = true,
rare_names = {},
disconnect_logout = false,
invite = true,
invite_ignore_on_autoaccept = false,
trade = true,
bags_full = false,
worldpvp = true,
duel_request = true,
summon = true,
fatigue = true,
on_chat_player_name = false,
whisper_blink = true,
battleground_end = false,
timer_start = false,
low_health = false,
lost_health = false,
player_died = true,
chromie_chest = false,
sound_enabled = {
readycheck = {enabled = false, sound = "d_whip1"},
arena_queue = {enabled = false, sound = "d_whip1"},
group_queue = {enabled = false, sound = "d_whip1"},
petbattle_queue = {enabled = false, sound = "d_whip1"},
brawlers_queue = {enabled = false, sound = "d_whip1"},
pull_timers = {enabled = false, sound = "d_whip1"},
enter_combat = {enabled = false, sound = "d_whip1"},
end_taxi = {enabled = false, sound = "d_whip1"},
chat_scan = {enabled = false, sound = "d_whip1"},
combat_log = {enabled = false, sound = "d_whip1"},
rare_scan = {enabled = false, sound = "d_whip1"},
disconnect_logout = {enabled = false, sound = "d_whip1"},
invite = {enabled = false, sound = "d_whip1"},
trade = {enabled = false, sound = "d_whip1"},
bags_full = {enabled = false, sound = "d_whip1"},
worldpvp = {enabled = false, sound = "d_whip1"},
duel_request = {enabled = false, sound = "d_whip1"},
summon = {enabled = false, sound = "d_whip1"},
fatigue = {enabled = false, sound = "d_whip1"},
on_chat_player_name = {enabled = false, sound = "d_whip1"},
whisper_blink = {enabled = false, sound = "d_whip1"},
battleground_end = {enabled = false, sound = "d_whip1"},
timer_start = {enabled = false, sound = "d_whip1"},
low_health = {enabled = false, sound = "d_whip1"},
lost_health = {enabled = false, sound = "d_whip1"},
player_died = {enabled = false, sound = "d_whip1"},
},
}
}
local options_table = {
name = "FlashTaskBar",
type = "group",
args = {
}
}
local FlashTaskBar = DF:CreateAddOn ("FlashTaskBar", "FlashTaskbarDB", default_config, options_table)
local lower = string.lower
--store the address of the original chat func
local ChatFrame_MessageEventHandler_Original = ChatFrame_MessageEventHandler
FlashTaskBar.last_flash = 0
function FlashTaskBar:DoFlash (config_key)
if (FlashTaskBar.last_flash + 5 < GetTime()) then
if (FlashDebug) then
FlashTaskBar:Msg ("Flash Reason: " .. (config_key or "unknown"))
end
FlashClientIcon()
local has_sound = FlashTaskBar.db.profile.sound_enabled
if (has_sound and has_sound [config_key] and has_sound [config_key].enabled) then
local file = LibStub:GetLibrary("LibSharedMedia-3.0"):Fetch ("sound", has_sound [config_key].sound)
PlaySoundFile (file, "Master")
end
FlashTaskBar.last_flash = GetTime()
end
end
function FlashTaskBar.OnInit (self)
--register slash
SLASH_FLASHTASKBAR1 = "/flashtaskbar"
function SlashCmdList.FLASHTASKBAR (msg, editbox)
if (msg == "reason") then
FlashDebug = not FlashDebug
FlashTaskBar:Msg ("Flash Reason " .. (FlashDebug and "Enabled" or "Disabled"))
return
end
InterfaceOptionsFrame_OpenToCategory ("FlashTaskBar")
InterfaceOptionsFrame_OpenToCategory ("FlashTaskBar")
end
--invite
function FlashTaskBar:DelayInviteCheck()
--if already in a group, ignore the invite call
--but the player might have received a request to join the group
--may be in the future this might need a flash as well
if (IsInGroup() or IsInRaid()) then
return
else
FlashTaskBar:DoFlash("invite")
end
end
--> wait 2 seconds before flash, other addons may auto answer the group invite
function FlashTaskBar:CheckForGroupInvite()
if (StaticPopup1 and StaticPopup1:IsShown()) then
FlashTaskBar:DoFlash("invite")
end
end
function FlashTaskBar:PARTY_INVITE_REQUEST()
if (FlashTaskBar.db.profile.invite) then
if (FlashTaskBar.db.profile.invite_ignore_on_autoaccept) then
FlashTaskBar:ScheduleTimer ("DelayInviteCheck", 1.0)
else
FlashTaskBar:ScheduleTimer ("CheckForGroupInvite", 2.0)
end
end
end
FlashTaskBar:RegisterEvent ("PARTY_INVITE_REQUEST")
--pet battle queue
function FlashTaskBar:CheckPetBattleQueue()
if (PetBattleQueueReadyFrame and PetBattleQueueReadyFrame:IsShown()) then
FlashTaskBar:DoFlash("petbattle_queue")
end
end
function FlashTaskBar:PET_BATTLE_QUEUE_STATUS (...)
if (FlashTaskBar.db.profile.petbattle_queue) then
FlashTaskBar:ScheduleTimer ("CheckPetBattleQueue", 1.5)
end
end
FlashTaskBar:RegisterEvent ("PET_BATTLE_QUEUE_STATUS")
function FlashTaskBar:UPDATE_BATTLEFIELD_STATUS()
if (FlashTaskBar.db.profile.battleground_end) then
if (WorldStateScoreFrame and WorldStateScoreFrame:IsShown()) then
FlashTaskBar:DoFlash("battleground_end")
end
end
end
FlashTaskBar:RegisterEvent ("UPDATE_BATTLEFIELD_STATUS")
--premade groups ready
if (not DetailsFramework.IsTimewalkWoW()) then
hooksecurefunc ("LFGListInviteDialog_Show", function()
if (FlashTaskBar.db.profile.group_queue) then
FlashTaskBar:DoFlash("group_queue")
FlashTaskBar.last_flash = 0
end
end)
--lfg lfpvp windows
hooksecurefunc ("LFGDungeonReadyStatus_ResetReadyStates", function()
if (FlashTaskBar.db.profile.group_queue) then
FlashTaskBar:DoFlash("group_queue")
FlashTaskBar.last_flash = 0
end
end)
hooksecurefunc ("PVPReadyDialog_Display", function()
if (FlashTaskBar.db.profile.arena_queue) then
FlashTaskBar:DoFlash("arena_queue")
FlashTaskBar.last_flash = 0
end
end)
end
--general alerts
hooksecurefunc ("StaticPopup_Show", function (token, text_arg1, text_arg2, data, insertedFrame)
if (token == "BFMGR_INVITED_TO_ENTER") then --> generic world pvp alert
if (FlashTaskBar.db.profile.worldpvp) then
FlashTaskBar:DoFlash("worldpvp")
end
elseif (token == "DUEL_REQUESTED" or token == "PET_BATTLE_PVP_DUEL_REQUESTED") then
if (FlashTaskBar.db.profile.duel_request) then
FlashTaskBar:DoFlash("duel_request")
end
elseif (token == "CONFIRM_SUMMON" or token == "CONFIRM_SUMMON_STARTING_AREA") then
if (FlashTaskBar.db.profile.summon) then
FlashTaskBar:DoFlash("summon")
end
elseif (token == "CHANNEL_INVITE" or token == "CHAT_CHANNEL_INVITE") then
FlashTaskBar:DoFlash("chat_channel_invite")
elseif (token == "PARTY_INVITE" or token == "PARTY_INVITE_XREALM") then
if (not FlashTaskBar.db.profile.invite) then
return
end
if (FlashTaskBar.db.profile.invite_ignore_on_autoaccept) then
FlashTaskBar:ScheduleTimer ("DelayInviteCheck", 1.5)
else
FlashTaskBar:DoFlash("invite")
end
elseif (token == "TRADE_WITH_QUESTION") then
if (FlashTaskBar.db.profile.trade) then
FlashTaskBar:DoFlash("trade")
end
end
end)
--brawlers guild
function FlashTaskBar:CHAT_MSG_MONSTER_YELL (event, msg, source, _, _, player_name)
if (player_name == UnitName ("player")) then
if (FlashTaskBar.db.profile.brawlers_queue) then
FlashTaskBar:DoFlash("brawlers_queue")
end
end
end
function FlashTaskBar:CheckForBrawlersGuild()
local zoneName, zoneType, _, _, _, _, _, zoneMapID = GetInstanceInfo()
if (zoneMapID == 369 or zoneMapID == 1043) then
FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_YELL")
else
FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_YELL")
end
end
function FlashTaskBar:PLAYER_ENTERING_WORLD()
FlashTaskBar:ScheduleTimer ("CheckForBrawlersGuild", 3)
end
function FlashTaskBar:ZONE_CHANGED_NEW_AREA()
FlashTaskBar:ScheduleTimer ("CheckForBrawlersGuild", 3)
end
FlashTaskBar:RegisterEvent ("PLAYER_ENTERING_WORLD")
FlashTaskBar:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
--pull timers
function FlashTaskBar:CommReceived (_, prefix)
if (not FlashTaskBar.db.profile.pull_timers) then
return
end
if (prefix:find ("PT")) then
FlashTaskBar:DoFlash("pull_timers")
elseif (prefix:find ("BWPull")) then
FlashTaskBar:DoFlash("pull_timers")
end
end
FlashTaskBar:RegisterComm ("D4", "CommReceived")
FlashTaskBar:RegisterComm ("BigWigs", "CommReceived")
--scenario update
function FlashTaskBar:SCENARIO_UPDATE()
if (FlashTaskBar.db.profile.chromie_chest) then
if (C_Map) then
local mapId = C_Map.GetBestMapForUnit("player")
if (not mapId or mapId ~= 2025) then
return
end
FlashTaskBar:DoFlash("chromie_chest")
end
end
end
FlashTaskBar:RegisterEvent("SCENARIO_UPDATE")
--readycheck
function FlashTaskBar:READY_CHECK()
if (FlashTaskBar.db.profile.readycheck) then
FlashTaskBar:DoFlash("readycheck")
end
end
FlashTaskBar:RegisterEvent ("READY_CHECK")
--combat
function FlashTaskBar:PLAYER_REGEN_DISABLED()
if (FlashTaskBar.db.profile.enter_combat) then
FlashTaskBar:DoFlash("enter_combat")
end
end
FlashTaskBar:RegisterEvent ("PLAYER_REGEN_DISABLED")
--taxi
--after a true for UnitOnTaxi, wait until it is false again
local CheckIfFlyingEnded = function (tickObject)
if (not UnitOnTaxi ("player")) then
tickObject:Cancel()
FlashTaskBar:DoFlash("end_taxi")
FlashTaskBar:Msg (L["STRING_CHAT_FLYPOINTENDED"])
end
end
--after closing, check if the player is on a taxi
local CheckIfIsFlying = function (tickObject)
if (UnitOnTaxi ("player")) then
if (FlashTaskBar.FlyingHasEndedCheck) then
FlashTaskBar.FlyingHasEndedCheck:Cancel()
end
FlashTaskBar.FlyingHasEndedCheck = C_Timer.NewTicker (1, CheckIfFlyingEnded)
tickObject:Cancel()
end
end
--run when the player closes the taxi map
function FlashTaskBar:TAXIMAP_CLOSED()
if (FlashTaskBar.db.profile.end_taxi) then
if (FlashTaskBar.IsFlyingTaxiCheck) then
FlashTaskBar.IsFlyingTaxiCheck:Cancel()
end
FlashTaskBar.IsFlyingTaxiCheck = C_Timer.NewTicker (1, CheckIfIsFlying, 5) --only check for 5 seconds
end
end
FlashTaskBar:RegisterEvent ("TAXIMAP_CLOSED")
--disconenct
--don't run this line on wow 11
if (DF.IsDragonflightOrBelow()) then
GameMenuButtonLogout:HookScript ("OnClick", function()
FlashTaskBar.LogoutTolerance = GetTime()+30
end)
function FlashTaskBar:PLAYER_LOGOUT()
if (FlashTaskBar.db.profile.disconnect_logout) then
if (FlashTaskBar.LogoutTolerance and FlashTaskBar.LogoutTolerance > GetTime()) then
return
end
FlashTaskBar:DoFlash("disconnect_logout")
end
end
FlashTaskBar:RegisterEvent ("PLAYER_LOGOUT")
end
--trade
function FlashTaskBar:TRADE_SHOW()
if (FlashTaskBar.db.profile.trade) then
FlashTaskBar:Msg ("somebody opened a trade with you!")
FlashTaskBar:DoFlash("trade")
end
end
FlashTaskBar:RegisterEvent ("TRADE_SHOW")
--bags full
function FlashTaskBar:BAG_UPDATE()
if (FlashTaskBar.db.profile.bags_full) then
for backpack = 0, 4 do
for slot = 1, C_Container.GetContainerNumSlots (backpack) do
local itemId = C_Container.GetContainerItemID (backpack, slot)
if (not itemId) then
return
end
end
end
FlashTaskBar:DoFlash("bags_full")
end
end
FlashTaskBar:RegisterEvent ("BAG_UPDATE")
--fatigue
function FlashTaskBar:MIRROR_TIMER_START (event, name, value, maxvalue, step, pause, label)
if (FlashTaskBar.db.profile.fatigue) then
if (name == "EXHAUSTION" and step == -1) then
FlashTaskBar:DoFlash ("fatigue")
end
end
end
FlashTaskBar:RegisterEvent ("MIRROR_TIMER_START")
--timer start
function FlashTaskBar:START_TIMER()
if (FlashTaskBar.db.profile.timer_start) then
FlashTaskBar:DoFlash ("timer_start")
end
end
FlashTaskBar:RegisterEvent ("START_TIMER")
--low health
FlashTaskBar.LastHealthBlink = time() - 30
function FlashTaskBar.CheckTargetHealth()
local targetHealth = UnitHealth ("target")
if (targetHealth > 1) then
local targetMaxHealth = UnitHealthMax ("target")
if (targetMaxHealth) then
if (FlashTaskBar.db.profile.low_health) then
local percent = targetHealth / targetMaxHealth
if (percent < 0.17) then
if (FlashTaskBar.LastHealthBlink + 30 < time()) then
FlashTaskBar:DoFlash ("low_health")
FlashTaskBar.LastHealthBlink = time()
end
end
end
if (FlashTaskBar.db.profile.lost_health) then
local percent = targetHealth / targetMaxHealth
if (percent < 0.95) then
if (FlashTaskBar.LastHealthBlink + 30 < time()) then
FlashTaskBar:DoFlash ("lost_health")
FlashTaskBar.LastHealthBlink = time()
end
end
end
end
end
end
function FlashTaskBar:EnableCheckHealth (state)
if (FlashTaskBar.HealthTicker) then
FlashTaskBar.HealthTicker:Cancel()
end
if (state) then
FlashTaskBar.HealthTicker = C_Timer.NewTicker (2, FlashTaskBar.CheckTargetHealth)
else
FlashTaskBar.HealthTicker = nil
end
end
if (FlashTaskBar.db.profile.low_health) then
FlashTaskBar:EnableCheckHealth (true)
end
if (FlashTaskBar.db.profile.lost_health) then
FlashTaskBar:EnableCheckHealth (true)
end
--------> chat scan
local player_name = lower (UnitName ("player"))
local do_chat_scan = function (_, message)
message = lower (message)
if (FlashTaskBar.db.profile.chat_scan) then
for _, keyword in ipairs (FlashTaskBar.db.profile.chat_scan_keywords) do
if (message:find (lower (keyword))) then
FlashTaskBar:DoFlash ("chat_scan")
FlashTaskBar:Msg ("work " .. keyword .. " found in chat!")
return
end
end
end
if (FlashTaskBar.db.profile.on_chat_player_name) then
if (message:find (player_name)) then
FlashTaskBar:Msg ("somebody mentioned your name in the chat!")
FlashTaskBar:DoFlash("on_chat_player_name")
end
end
end
function FlashTaskBar:EnableChatScan()
FlashTaskBar:RegisterEvent ("CHAT_MSG_EMOTE", do_chat_scan)
--FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_EMOTE", do_chat_scan)
--FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_SAY", do_chat_scan)
--FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_WHISPER", do_chat_scan)
--FlashTaskBar:RegisterEvent ("CHAT_MSG_MONSTER_YELL", do_chat_scan)
--FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID_BOSS_EMOTE", do_chat_scan)
--FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID_BOSS_WHISPER", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_SYSTEM", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_SAY", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_YELL", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_CHANNEL", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_PARTY", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_GUILD", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_INSTANCE_CHAT", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_OFFICER", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_PARTY_LEADER", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID_LEADER", do_chat_scan)
FlashTaskBar:RegisterEvent ("CHAT_MSG_RAID_WARNING", do_chat_scan)
player_name = lower (UnitName ("player"))
end
function FlashTaskBar:DisableChatScan()
FlashTaskBar:UnregisterEvent ("CHAT_MSG_EMOTE")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_EMOTE")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_SAY")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_WHISPER")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_MONSTER_YELL")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID_BOSS_EMOTE")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID_BOSS_WHISPER")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_SYSTEM")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_SAY")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_YELL")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_CHANNEL")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_PARTY")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_GUILD")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_INSTANCE_CHAT")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_OFFICER")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_PARTY_LEADER")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID_LEADER")
FlashTaskBar:UnregisterEvent ("CHAT_MSG_RAID_WARNING")
end
--> player died
local healthFrame = CreateFrame ("frame", nil, UIParent)
healthFrame:SetScript ("OnEvent", function (self, unit)
local health = UnitHealth ("player")
if (health < 1) then
if (FlashTaskBar.db.profile.player_died) then
FlashTaskBar:DoFlash ("player_died")
end
end
end)
function FlashTaskBar:EnablePlayerHealthMonitor()
healthFrame:RegisterUnitEvent ("UNIT_HEALTH", "player")
end
function FlashTaskBar:DisablePlayerHealthMonitor()
healthFrame:UnregisterEvent ("UNIT_HEALTH", "player")
end
if (FlashTaskBar.db.profile.player_died) then
FlashTaskBar:EnablePlayerHealthMonitor()
end
--need a cleanup in the future
function FlashTaskBar:DoNotFlashOnWhisper()
--_G.ChatFrame_MessageEventHandler = ChatFrame_MessageEventHandler_WithNoFlash
end
function FlashTaskBar:EnableFlashOnWhisper()
--_G.ChatFrame_MessageEventHandler = ChatFrame_MessageEventHandler_Original
end
if (FlashTaskBar.db.profile.whisper_blink) then
--FlashTaskBar:EnableFlashOnWhisper()
else
--FlashTaskBar:DoNotFlashOnWhisper()
end
--------> combat log scan
local combat_log_keywords = {}
local do_combat_log_scan = function (self, event)
local time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2 = CombatLogGetCurrentEventInfo()
if (target_name and combat_log_keywords [lower (target_name)]) then
FlashTaskBar:DoFlash("combat_log")
end
end
function FlashTaskBar:BuildCombatLogKeywordTable()
wipe (combat_log_keywords)
for _, keyword in ipairs (FlashTaskBar.db.profile.combat_log_keywords) do
combat_log_keywords [lower (keyword)] = true
end
end
function FlashTaskBar:EnableCombatLogScan()
FlashTaskBar:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED", do_combat_log_scan)
FlashTaskBar:BuildCombatLogKeywordTable()
end
function FlashTaskBar:DisableCombatLogScan()
FlashTaskBar:UnregisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
end
--------> rare mob scan
--> store the timers for flash for each rare
FlashTaskBar.RareFlashCooldown = {}
local do_rare_mob_scan = function()
--/dump C_VignetteInfo.GetVignetteInfo (C_VignetteInfo.GetVignettes()[1])
--/dump C_VignetteInfo.GetVignettes()
--track special events
--[=[]]
for i, vignetteID in ipairs (C_VignetteInfo.GetVignettes()) do
local vignetteInfo = C_VignetteInfo.GetVignetteInfo (vignetteID)
if (vignetteInfo) then
local serial = vignetteInfo.objectGUID
if (serial) then
local name = vignetteInfo.name
local objectIcon = vignetteInfo.atlasName
--naga event
if (objectIcon == "nazjatar-nagaevent") then
WorldQuestTracker.NagaEventCooldown = WorldQuestTracker.NagaEventCooldown or 0
if (WorldQuestTracker.NagaEventCooldown < time()) then
WorldQuestTracker:Msg("a naga event is happening, open the map for location.|r")
WorldQuestTracker.NagaEventCooldown = time() + 360 --6min
end
end
end
end
end
--]=]
-----------------------
for _, vignetteID in ipairs (C_VignetteInfo.GetVignettes()) do
local vignetteInfo = C_VignetteInfo.GetVignetteInfo (vignetteID)
--special event on icecrown map 9.0.1 event
if (vignetteInfo and C_Map.GetBestMapForUnit ("player") == 118) then
local objectIcon = vignetteInfo.atlasName
if (objectIcon == "nazjatar-nagaevent") then
FlashTaskBar:DoFlash ("rare_scan")
end
end
if (vignetteInfo and vignetteInfo.onMinimap and not vignetteInfo.isDead and vignetteInfo.atlasName == "VignetteKill") then --vignetteID == 2004
local objectGUID = vignetteInfo.objectGUID
if (FlashTaskBar.db.profile.any_rare) then
if (not UnitOnTaxi ("player")) then
if (not FlashTaskBar.RareFlashCooldown [objectGUID] or FlashTaskBar.RareFlashCooldown [objectGUID] < time()) then
FlashTaskBar:DoFlash ("rare_scan")
FlashTaskBar.RareFlashCooldown [objectGUID] = time() + 180
end
end
elseif (vignetteInfo.name) then
for _, npcName in ipairs(FlashTaskBar.db.profile.rare_names) do
npcName = lower(npcName)
local vignetteName = lower(vignetteInfo.name)
if (npcName == vignetteName) then
if (not FlashTaskBar.RareFlashCooldown[objectGUID] or FlashTaskBar.RareFlashCooldown[objectGUID] < time()) then
FlashTaskBar:DoFlash ("rare_scan")
FlashTaskBar.RareFlashCooldown [objectGUID] = time() + 180
end
end
end
end
end
end
end
function FlashTaskBar:EnableRareMobScan()
if (not DetailsFramework.IsTimewalkWoW()) then
FlashTaskBar:RegisterEvent ("VIGNETTES_UPDATED", do_rare_mob_scan)
end
end
function FlashTaskBar:DisableRareMobScan()
if (not DetailsFramework.IsTimewalkWoW()) then
FlashTaskBar:UnregisterEvent ("VIGNETTES_UPDATED")
end
end
--> overrides
--replace the built-in flash function from the game client to flash when the player enters in combat
if (LowHealthFrame) then
function LowHealthFrame:SetInCombat(inCombat)
if self.inCombat ~= inCombat then
self.inCombat = inCombat;
if ( self.inCombat ) then
--FlashClientIcon();
end
self:EvaluateVisibleState();
end
end
end
--> build options panel
local options = {
{
type = "toggle",
name = L["STRING_READYCHECK"],
desc = L["STRING_READYCHECK_DESC"],
order = 1,
get = function() return FlashTaskBar.db.profile.readycheck end,
set = function (self, val)
FlashTaskBar.db.profile.readycheck = not FlashTaskBar.db.profile.readycheck
end,
},
{
type = "toggle",
name = L["STRING_PVPQUEUES"],
desc = L["STRING_PVPQUEUES_DESC"],
order = 2,
get = function() return FlashTaskBar.db.profile.arena_queue end,
set = function (self, val)
FlashTaskBar.db.profile.arena_queue = not FlashTaskBar.db.profile.arena_queue
end,
},
{
type = "toggle",
name = L["STRING_FINDERQUEUES"],
desc = L["STRING_FINDERQUEUES_DESC"],
order = 3,
get = function() return FlashTaskBar.db.profile.group_queue end,
set = function (self, val)
FlashTaskBar.db.profile.group_queue = not FlashTaskBar.db.profile.group_queue
end,
},
{
type = "toggle",
name = L["STRING_PETBATTLES"] ,
desc = L["STRING_PETBATTLES_DESC"] ,
order = 6,
get = function() return FlashTaskBar.db.profile.petbattle_queue end,
set = function (self, val)
FlashTaskBar.db.profile.petbattle_queue = not FlashTaskBar.db.profile.petbattle_queue
end,
},
{
type = "toggle",
name = L["STRING_BRAWLERS"],
desc = L["STRING_BRAWLERS_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.brawlers_queue end,
set = function (self, val)
FlashTaskBar.db.profile.brawlers_queue = not FlashTaskBar.db.profile.brawlers_queue
end,
},
{
type = "toggle",
name = L["STRING_PULL"],
desc = L["STRING_PULL_DESC"],
order = 4,
get = function() return FlashTaskBar.db.profile.pull_timers end,
set = function (self, val)
FlashTaskBar.db.profile.pull_timers = not FlashTaskBar.db.profile.pull_timers
end,
},
{
type = "toggle",
name = L["STRING_ENTERCOMBAT"],
desc = L["STRING_ENTERCOMBAT_DESC"],
order = 5,
get = function() return FlashTaskBar.db.profile.enter_combat end,
set = function (self, val)
FlashTaskBar.db.profile.enter_combat = not FlashTaskBar.db.profile.enter_combat
end,
},
{
type = "toggle",
name = L["STRING_FLYPOINT"],
desc = L["STRING_FLYPOINT_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.end_taxi end,
set = function (self, val)
FlashTaskBar.db.profile.end_taxi = not FlashTaskBar.db.profile.end_taxi
end,
},
{
type = "toggle",
name = L["STRING_DISCONNECT"],
desc = L["STRING_DISCONNECT_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.disconnect_logout end,
set = function (self, val)
FlashTaskBar.db.profile.disconnect_logout = not FlashTaskBar.db.profile.disconnect_logout
end,
},
{
type = "toggle",
name = L["STRING_INVITES"],
desc = L["STRING_INVITES_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.invite end,
set = function (self, val)
FlashTaskBar.db.profile.invite = not FlashTaskBar.db.profile.invite
end,
},
{
type = "toggle",
name = L["STRING_INVITEIGNORE"],
desc = L["STRING_INVITEIGNORE_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.invite_ignore_on_autoaccept end,
set = function (self, val)
FlashTaskBar.db.profile.invite_ignore_on_autoaccept = not FlashTaskBar.db.profile.invite_ignore_on_autoaccept
end,
},
{
type = "toggle",
name = L["STRING_TRADE"],
desc = L["STRING_TRADE_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.trade end,
set = function (self, val)
FlashTaskBar.db.profile.trade = not FlashTaskBar.db.profile.trade
end,
},
{
type = "toggle",
name = L["STRING_BAGSFULL"],
desc = L["STRING_BAGSFULL_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.bags_full end,
set = function (self, val)
FlashTaskBar.db.profile.bags_full = not FlashTaskBar.db.profile.bags_full
end,
},
{
type = "toggle",
name = L["STRING_WORLDPVP"],
desc = L["STRING_WORLDPVP_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.worldpvp end,
set = function (self, val)
FlashTaskBar.db.profile.worldpvp = not FlashTaskBar.db.profile.worldpvp
end,
},
{
type = "toggle",
name = L["STRING_DUELREQUEST"] ,
desc = L["STRING_DUELREQUEST_DESC"] ,
order = 6,
get = function() return FlashTaskBar.db.profile.duel_request end,
set = function (self, val)
FlashTaskBar.db.profile.duel_request = not FlashTaskBar.db.profile.duel_request
end,
},
{
type = "toggle",
name = L["STRING_SUMMON"],
desc = L["STRING_SUMMON_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.summon end,
set = function (self, val)
FlashTaskBar.db.profile.summon = not FlashTaskBar.db.profile.summon
end,
},
{
type = "toggle",
name = L["STRING_FATIGUE"],
desc = L["STRING_FATIGUE_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.fatigue end,
set = function (self, val)
FlashTaskBar.db.profile.fatigue = not FlashTaskBar.db.profile.fatigue
end,
},
{
type = "toggle",
name = L["STRING_PLAYERNAME"],
desc = L["STRING_PLAYERNAME_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.on_chat_player_name end,
set = function (self, val)
FlashTaskBar.db.profile.on_chat_player_name = not FlashTaskBar.db.profile.on_chat_player_name
if (FlashTaskBar.db.profile.on_chat_player_name) then
FlashTaskBar:EnableChatScan()
else
--ver se tem alguma outra fun��o usando o chat scan
if (not FlashTaskBar.db.profile.chat_scan) then
FlashTaskBar:DisableChatScan()
end
end
end,
},
--[=[
{
type = "toggle",
name = L["STRING_ONWHISPER"],
desc = L["STRING_ONWHISPER_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.whisper_blink end,
set = function (self, val)
FlashTaskBar.db.profile.whisper_blink = not FlashTaskBar.db.profile.whisper_blink
if (FlashTaskBar.db.profile.whisper_blink) then
FlashTaskBar:EnableFlashOnWhisper()
else
FlashTaskBar:DoNotFlashOnWhisper()
end
end,
},
--]=]
{
type = "toggle",
name = L["STRING_BATTLEGROUND"],
desc = L["STRING_BATTLEGROUND_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.battleground_end end,
set = function (self, val)
FlashTaskBar.db.profile.battleground_end = not FlashTaskBar.db.profile.battleground_end
end,
},
{
type = "toggle",
name = L["STRING_ONCOUNTDOWN"],
desc = L["STRING_ONCOUNTDOWN_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.timer_start end,
set = function (self, val)
FlashTaskBar.db.profile.timer_start = not FlashTaskBar.db.profile.timer_start
end,
},
{
type = "toggle",
name = L["STRING_TARGETLOWHEALTH"],
desc = L["STRING_TARGETLOWHEALTH_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.low_health end,
set = function (self, val)
FlashTaskBar.db.profile.low_health = not FlashTaskBar.db.profile.low_health
if (FlashTaskBar.db.profile.low_health) then
FlashTaskBar:EnableCheckHealth (true)
else
FlashTaskBar:EnableCheckHealth (false)
end
end,
},
{
type = "toggle",
name = L["STRING_TARGETLOSTHEALTH"],
desc = L["STRING_TARGETLOSTHEALTH_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.lost_health end,
set = function (self, val)
FlashTaskBar.db.profile.lost_health = not FlashTaskBar.db.profile.lost_health
if (FlashTaskBar.db.profile.lost_health) then
FlashTaskBar:EnableCheckHealth (true)
else
FlashTaskBar:EnableCheckHealth (false)
end
end,
},
{
type = "toggle",
name = L["STRING_ONPLAYERDEATH"],
desc = L["STRING_ONPLAYERDEATH_DESC"],
order = 6,
get = function() return FlashTaskBar.db.profile.player_died end,
set = function (self, val)
FlashTaskBar.db.profile.player_died = not FlashTaskBar.db.profile.player_died
if (FlashTaskBar.db.profile.player_died) then
FlashTaskBar:EnablePlayerHealthMonitor()
else
FlashTaskBar:DisablePlayerHealthMonitor()
end
end,
},
{
type = "toggle",
name = "Chromie Chest",
desc = "Chromie Chest",
order = 6,
get = function() return FlashTaskBar.db.profile.chromie_chest end,
set = function (self, val)
FlashTaskBar.db.profile.chromie_chest = not FlashTaskBar.db.profile.chromie_chest
end,
},
}
local options_text_template = FlashTaskBar:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
local options_dropdown_template = FlashTaskBar:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
local options_switch_template = FlashTaskBar:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
local options_slider_template = FlashTaskBar:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
local options_button_template = FlashTaskBar:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
local general_text1 = FlashTaskBar:CreateLabel (FlashTaskBar.OptionsFrame1, L["STRING_GENERALSETTINGS"] .. ":", FlashTaskBar:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
general_text1:SetPoint ("topleft", main_frame, "topleft", 10, -50)
FlashTaskBar:SetFontSize (general_text1, 16)
local general_settings_frame = CreateFrame ("frame", "FlashTaskBarGeneralOptionsFrame", FlashTaskBar.OptionsFrame1)
general_settings_frame:SetPoint ("topleft", 0, 0)
general_settings_frame:SetSize (1, 1)