/
Blizzard_CombatLog.lua
3758 lines (3391 loc) · 123 KB
/
Blizzard_CombatLog.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
--[[
-- Blizzard Combat Log
-- by Alexander Yoshi
--
-- This is a prototype combat log designed to serve the
-- majority of needs for WoW players. The new and improved
-- combat log event formatting should allow for the community
-- to develop even better combat logs in the future.
--
-- Thanks to:
-- Chris Heald & Xinhuan - Code Optimization Support
--
--]]
-- Version
-- Constant -- Incrementing this number will erase saved filter settings!!
COMBATLOG_FILTER_VERSION = 4.1;
-- Saved Variable
Blizzard_CombatLog_Filter_Version = 0;
-- Define the log
COMBATLOG = ChatFrame2;
-- BUFF / DEBUFF
AURA_TYPE_BUFF = "BUFF";
AURA_TYPE_DEBUFF = "DEBUFF"
-- Message Limit
COMBATLOG_LIMIT_PER_FRAME = 1;
COMBATLOG_HIGHLIGHT_MULTIPLIER = 1.5;
-- Default Colors
COMBATLOG_DEFAULT_COLORS = {
-- Unit names
unitColoring = {
[COMBATLOG_FILTER_MINE] = {a=1.0,r=0.70,g=0.70,b=0.70}; --{a=1.0,r=0.14,g=1.00,b=0.15};
[COMBATLOG_FILTER_MY_PET] = {a=1.0,r=0.70,g=0.70,b=0.70}; --{a=1.0,r=0.14,g=0.80,b=0.15};
[COMBATLOG_FILTER_FRIENDLY_UNITS] = {a=1.0,r=0.34,g=0.64,b=1.00};
[COMBATLOG_FILTER_HOSTILE_UNITS] = {a=1.0,r=0.75,g=0.05,b=0.05};
[COMBATLOG_FILTER_HOSTILE_PLAYERS] = {a=1.0,r=0.75,g=0.05,b=0.05};
[COMBATLOG_FILTER_NEUTRAL_UNITS] = {a=1.0,r=0.75,g=0.05,b=0.05}; -- {a=1.0,r=0.80,g=0.80,b=0.14};
[COMBATLOG_FILTER_UNKNOWN_UNITS] = {a=1.0,r=0.75,g=0.75,b=0.75};
};
-- School coloring
schoolColoring = {
[SCHOOL_MASK_NONE] = {a=1.0,r=1.00,g=1.00,b=1.00};
[SCHOOL_MASK_PHYSICAL] = {a=1.0,r=1.00,g=1.00,b=0.00};
[SCHOOL_MASK_HOLY] = {a=1.0,r=1.00,g=0.90,b=0.50};
[SCHOOL_MASK_FIRE] = {a=1.0,r=1.00,g=0.50,b=0.00};
[SCHOOL_MASK_NATURE] = {a=1.0,r=0.30,g=1.00,b=0.30};
[SCHOOL_MASK_FROST] = {a=1.0,r=0.50,g=1.00,b=1.00};
[SCHOOL_MASK_SHADOW] = {a=1.0,r=0.50,g=0.50,b=1.00};
[SCHOOL_MASK_ARCANE] = {a=1.0,r=1.00,g=0.50,b=1.00};
};
-- Defaults
defaults = {
spell = {a=1.0,r=1.00,g=1.00,b=1.00};
damage = {a=1.0,r=1.00,g=1.00,b=0.00};
};
-- Line coloring
eventColoring = {
};
-- Highlighted events
highlightedEvents = {
["PARTY_KILL"] = true;
};
};
COMBATLOG_DEFAULT_SETTINGS = {
-- Settings
fullText = true;
textMode = TEXT_MODE_A;
timestamp = false;
timestampFormat = TEXT_MODE_A_TIMESTAMP;
unitColoring = false;
sourceColoring = true;
destColoring = true;
lineColoring = true;
lineHighlighting = true;
abilityColoring = false;
abilityActorColoring = false;
abilitySchoolColoring = false;
abilityHighlighting = true;
actionColoring = false;
actionActorColoring = false;
actionHighlighting = false;
amountColoring = false;
amountActorColoring = false;
amountSchoolColoring = false;
amountHighlighting = true;
schoolNameColoring = false;
schoolNameActorColoring = false;
schoolNameHighlighting = true;
noMeleeSwingColoring = false;
missColoring = true;
braces = false;
unitBraces = true;
sourceBraces = true;
destBraces = true;
spellBraces = false;
itemBraces = true;
showHistory = true;
lineColorPriority = 1; -- 1 = source->dest->event, 2 = dest->source->event, 3 = event->source->dest
unitIcons = true;
hideBuffs = false;
hideDebuffs = false;
--unitTokens = true;
};
--
-- Combat Log Icons
--
COMBATLOG_ICON_RAIDTARGET1 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp:0|t";
COMBATLOG_ICON_RAIDTARGET2 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_2.blp:0|t";
COMBATLOG_ICON_RAIDTARGET3 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_3.blp:0|t";
COMBATLOG_ICON_RAIDTARGET4 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_4.blp:0|t";
COMBATLOG_ICON_RAIDTARGET5 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_5.blp:0|t";
COMBATLOG_ICON_RAIDTARGET6 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_6.blp:0|t";
COMBATLOG_ICON_RAIDTARGET7 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_7.blp:0|t";
COMBATLOG_ICON_RAIDTARGET8 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_8.blp:0|t";
--
-- Default Event List
--
COMBATLOG_EVENT_LIST = {
["ENVIRONMENTAL_DAMAGE"] = true,
["SWING_DAMAGE"] = true,
["SWING_MISSED"] = true,
["RANGE_DAMAGE"] = true,
["RANGE_MISSED"] = true,
["SPELL_CAST_START"] = false,
["SPELL_CAST_SUCCESS"] = false,
["SPELL_CAST_FAILED"] = false,
["SPELL_MISSED"] = true,
["SPELL_DAMAGE"] = true,
["SPELL_HEAL"] = true,
["SPELL_ENERGIZE"] = true,
["SPELL_DRAIN"] = true,
["SPELL_LEECH"] = true,
["SPELL_SUMMON"] = true,
["SPELL_RESURRECT"] = true,
["SPELL_CREATE"] = true,
["SPELL_INSTAKILL"] = true,
["SPELL_INTERRUPT"] = true,
["SPELL_EXTRA_ATTACKS"] = true,
["SPELL_DURABILITY_DAMAGE"] = false,
["SPELL_DURABILITY_DAMAGE_ALL"] = false,
["SPELL_AURA_APPLIED"] = false,
["SPELL_AURA_APPLIED_DOSE"] = false,
["SPELL_AURA_REMOVED"] = false,
["SPELL_AURA_REMOVED_DOSE"] = false,
["SPELL_AURA_BROKEN"] = false,
["SPELL_AURA_BROKEN_SPELL"] = false,
["SPELL_AURA_REFRESH"] = false,
["SPELL_DISPEL"] = true,
["SPELL_STOLEN"] = true,
["ENCHANT_APPLIED"] = true,
["ENCHANT_REMOVED"] = true,
["SPELL_PERIODIC_MISSED"] = true,
["SPELL_PERIODIC_DAMAGE"] = true,
["SPELL_PERIODIC_HEAL"] = true,
["SPELL_PERIODIC_ENERGIZE"] = true,
["SPELL_PERIODIC_DRAIN"] = true,
["SPELL_PERIODIC_LEECH"] = true,
["SPELL_DISPEL_FAILED"] = true,
["DAMAGE_SHIELD"] = false,
["DAMAGE_SHIELD_MISSED"] = false,
["DAMAGE_SPLIT"] = false,
["PARTY_KILL"] = true,
["UNIT_DIED"] = true,
["UNIT_DESTROYED"] = true,
["SPELL_BUILDING_DAMAGE"] = true,
["SPELL_BUILDING_HEAL"] = true,
["UNIT_DISSIPATES"] = true,
};
COMBATLOG_FLAG_LIST = {
[COMBATLOG_FILTER_MINE] = true,
[COMBATLOG_FILTER_MY_PET] = true,
[COMBATLOG_FILTER_FRIENDLY_UNITS] = true,
[COMBATLOG_FILTER_HOSTILE_UNITS] = true,
[COMBATLOG_FILTER_HOSTILE_PLAYERS] = true,
[COMBATLOG_FILTER_NEUTRAL_UNITS] = true,
[COMBATLOG_FILTER_UNKNOWN_UNITS] = true,
};
EVENT_TEMPLATE_FORMATS = {
["SPELL_AURA_BROKEN_SPELL"] = TEXT_MODE_A_STRING_3,
["SPELL_CAST_START"] = TEXT_MODE_A_STRING_2,
["SPELL_CAST_SUCCESS"] = TEXT_MODE_A_STRING_2
};
--
-- Creates an empty filter
--
function Blizzard_CombatLog_InitializeFilters( settings )
settings.filters =
{
[1] = {
eventList = {};
};
};
end
--
-- Generates a new event list from the COMBATLOG_EVENT_LIST global
--
-- I wish there was a better way built in to do this.
--
-- Returns:
-- An array, indexed by the events, with a value of true
--
function Blizzard_CombatLog_GenerateFullEventList ( )
local eventList = {}
for event, v in pairs ( COMBATLOG_EVENT_LIST ) do
eventList[event] = true;
end
return eventList;
end
function Blizzard_CombatLog_GenerateFullFlagList(flag)
local flagList = {};
for k, v in pairs(COMBATLOG_FLAG_LIST) do
if ( flag ) then
flagList[k] = true
else
flagList[k] = false;
end
end
return flagList;
end
--
-- Default CombatLog Filter
-- This table is used to create new CombatLog filters
--
DEFAULT_COMBATLOG_FILTER_TEMPLATE = {
-- Descriptive Information
hasQuickButton = true;
quickButtonDisplay = {
solo = true;
party = true;
raid = true;
};
-- Default Color and Formatting Options
settings = CopyTable(COMBATLOG_DEFAULT_SETTINGS);
-- Coloring
colors = CopyTable(COMBATLOG_DEFAULT_COLORS);
-- The actual client filters
filters = {
[1] = {
eventList = Blizzard_CombatLog_GenerateFullEventList();
sourceFlags = {
[COMBATLOG_FILTER_MINE] = true,
[COMBATLOG_FILTER_MY_PET] = true;
};
destFlags = nil;
};
[2] = {
eventList = Blizzard_CombatLog_GenerateFullEventList();
sourceFlags = nil;
destFlags = {
[COMBATLOG_FILTER_MINE] = true,
[COMBATLOG_FILTER_MY_PET] = true;
};
};
};
};
local CombatLogUpdateFrame = CreateFrame("Frame", "CombatLogUpdateFrame", UIParent)
local _G = getfenv(0)
local bit_bor = _G.bit.bor
local bit_band = _G.bit.band
local tinsert = _G.tinsert
local tremove = _G.tremove
local math_floor = _G.math.floor
local format = _G.format
local gsub = _G.gsub
local strsub = _G.strsub
-- Make all the constants upvalues. This prevents the global environment lookup + table lookup each time we use one (and they're used a lot)
local COMBATLOG_OBJECT_AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE
local COMBATLOG_OBJECT_AFFILIATION_PARTY = COMBATLOG_OBJECT_AFFILIATION_PARTY
local COMBATLOG_OBJECT_AFFILIATION_RAID = COMBATLOG_OBJECT_AFFILIATION_RAID
local COMBATLOG_OBJECT_AFFILIATION_OUTSIDER = COMBATLOG_OBJECT_AFFILIATION_OUTSIDER
local COMBATLOG_OBJECT_AFFILIATION_MASK = COMBATLOG_OBJECT_AFFILIATION_MASK
local COMBATLOG_OBJECT_REACTION_FRIENDLY = COMBATLOG_OBJECT_REACTION_FRIENDLY
local COMBATLOG_OBJECT_REACTION_NEUTRAL = COMBATLOG_OBJECT_REACTION_NEUTRAL
local COMBATLOG_OBJECT_REACTION_HOSTILE = COMBATLOG_OBJECT_REACTION_HOSTILE
local COMBATLOG_OBJECT_REACTION_MASK = COMBATLOG_OBJECT_REACTION_MASK
local COMBATLOG_OBJECT_CONTROL_PLAYER = COMBATLOG_OBJECT_CONTROL_PLAYER
local COMBATLOG_OBJECT_CONTROL_NPC = COMBATLOG_OBJECT_CONTROL_NPC
local COMBATLOG_OBJECT_CONTROL_MASK = COMBATLOG_OBJECT_CONTROL_MASK
local COMBATLOG_OBJECT_TYPE_PLAYER = COMBATLOG_OBJECT_TYPE_PLAYER
local COMBATLOG_OBJECT_TYPE_NPC = COMBATLOG_OBJECT_TYPE_NPC
local COMBATLOG_OBJECT_TYPE_PET = COMBATLOG_OBJECT_TYPE_PET
local COMBATLOG_OBJECT_TYPE_GUARDIAN = COMBATLOG_OBJECT_TYPE_GUARDIAN
local COMBATLOG_OBJECT_TYPE_OBJECT = COMBATLOG_OBJECT_TYPE_OBJECT
local COMBATLOG_OBJECT_TYPE_MASK = COMBATLOG_OBJECT_TYPE_MASK
local COMBATLOG_OBJECT_TARGET = COMBATLOG_OBJECT_TARGET
local COMBATLOG_OBJECT_FOCUS = COMBATLOG_OBJECT_FOCUS
local COMBATLOG_OBJECT_MAINTANK = COMBATLOG_OBJECT_MAINTANK
local COMBATLOG_OBJECT_MAINASSIST = COMBATLOG_OBJECT_MAINASSIST
local COMBATLOG_OBJECT_RAIDTARGET1 = COMBATLOG_OBJECT_RAIDTARGET1
local COMBATLOG_OBJECT_RAIDTARGET2 = COMBATLOG_OBJECT_RAIDTARGET2
local COMBATLOG_OBJECT_RAIDTARGET3 = COMBATLOG_OBJECT_RAIDTARGET3
local COMBATLOG_OBJECT_RAIDTARGET4 = COMBATLOG_OBJECT_RAIDTARGET4
local COMBATLOG_OBJECT_RAIDTARGET5 = COMBATLOG_OBJECT_RAIDTARGET5
local COMBATLOG_OBJECT_RAIDTARGET6 = COMBATLOG_OBJECT_RAIDTARGET6
local COMBATLOG_OBJECT_RAIDTARGET7 = COMBATLOG_OBJECT_RAIDTARGET7
local COMBATLOG_OBJECT_RAIDTARGET8 = COMBATLOG_OBJECT_RAIDTARGET8
local COMBATLOG_OBJECT_NONE = COMBATLOG_OBJECT_NONE
local COMBATLOG_OBJECT_SPECIAL_MASK = COMBATLOG_OBJECT_SPECIAL_MASK
local COMBATLOG_FILTER_ME = COMBATLOG_FILTER_ME
local COMBATLOG_FILTER_MINE = COMBATLOG_FILTER_MINE
local COMBATLOG_FILTER_MY_PET = COMBATLOG_FILTER_MY_PET
local COMBATLOG_FILTER_FRIENDLY_UNITS = COMBATLOG_FILTER_FRIENDLY_UNITS
local COMBATLOG_FILTER_HOSTILE_UNITS = COMBATLOG_FILTER_HOSTILE_UNITS
local COMBATLOG_FILTER_HOSTILE_PLAYERS = COMBATLOG_FILTER_HOSTILE_PLAYERS
local COMBATLOG_FILTER_NEUTRAL_UNITS = COMBATLOG_FILTER_NEUTRAL_UNITS
local COMBATLOG_FILTER_UNKNOWN_UNITS = COMBATLOG_FILTER_UNKNOWN_UNITS
local COMBATLOG_FILTER_EVERYTHING = COMBATLOG_FILTER_EVERYTHING
local COMBATLOG = COMBATLOG
local AURA_TYPE_BUFF = AURA_TYPE_BUFF
local AURA_TYPE_DEBUFF = AURA_TYPE_DEBUFF
local SPELL_POWER_MANA = SPELL_POWER_MANA
local SPELL_POWER_RAGE = SPELL_POWER_RAGE
local SPELL_POWER_FOCUS = SPELL_POWER_FOCUS
local SPELL_POWER_ENERGY = SPELL_POWER_ENERGY
local SPELL_POWER_RUNES = SPELL_POWER_RUNES
local SPELL_POWER_RUNIC_POWER = SPELL_POWER_RUNIC_POWER
local SPELL_POWER_SOUL_SHARDS = SPELL_POWER_SOUL_SHARDS;
local SPELL_POWER_ECLIPSE = SPELL_POWER_ECLIPSE;
local SPELL_POWER_HOLY_POWER = SPELL_POWER_HOLY_POWER;
local SCHOOL_MASK_NONE = SCHOOL_MASK_NONE
local SCHOOL_MASK_PHYSICAL = SCHOOL_MASK_PHYSICAL
local SCHOOL_MASK_HOLY = SCHOOL_MASK_HOLY
local SCHOOL_MASK_FIRE = SCHOOL_MASK_FIRE
local SCHOOL_MASK_NATURE = SCHOOL_MASK_NATURE
local SCHOOL_MASK_FROST = SCHOOL_MASK_FROST
local SCHOOL_MASK_SHADOW = SCHOOL_MASK_SHADOW
local SCHOOL_MASK_ARCANE = SCHOOL_MASK_ARCANE
local COMBATLOG_LIMIT_PER_FRAME = COMBATLOG_LIMIT_PER_FRAME
local COMBATLOG_HIGHLIGHT_MULTIPLIER = COMBATLOG_HIGHLIGHT_MULTIPLIER
local COMBATLOG_DEFAULT_COLORS = COMBATLOG_DEFAULT_COLORS
local COMBATLOG_DEFAULT_SETTINGS = COMBATLOG_DEFAULT_SETTINGS
local COMBATLOG_ICON_RAIDTARGET1 = COMBATLOG_ICON_RAIDTARGET1
local COMBATLOG_ICON_RAIDTARGET2 = COMBATLOG_ICON_RAIDTARGET2
local COMBATLOG_ICON_RAIDTARGET3 = COMBATLOG_ICON_RAIDTARGET3
local COMBATLOG_ICON_RAIDTARGET4 = COMBATLOG_ICON_RAIDTARGET4
local COMBATLOG_ICON_RAIDTARGET5 = COMBATLOG_ICON_RAIDTARGET5
local COMBATLOG_ICON_RAIDTARGET6 = COMBATLOG_ICON_RAIDTARGET6
local COMBATLOG_ICON_RAIDTARGET7 = COMBATLOG_ICON_RAIDTARGET7
local COMBATLOG_ICON_RAIDTARGET8 = COMBATLOG_ICON_RAIDTARGET8
local COMBATLOG_EVENT_LIST = COMBATLOG_EVENT_LIST
local CombatLog_OnEvent -- for later
local CombatLog_Object_IsA = CombatLog_Object_IsA
-- Create a dummy CombatLogQuickButtonFrame for line 803 of FloatingChatFrame.lua. It causes inappropriate show/hide behavior. Instead, we'll use our own frame display handling.
-- If there are more than 2 combat log frames, then the CombatLogQuickButtonFrame gets tied to the last frame tab's visibility status. Yuck! Let's just instead tie it to the combat log's tab.
local CombatLogQuickButtonFrame, CombatLogQuickButtonFrameProgressBar, CombatLogQuickButtonFrameTexture
_G.CombatLogQuickButtonFrame = CreateFrame("Frame", "CombatLogQuickButtonFrame", UIParent)
local Blizzard_CombatLog_Update_QuickButtons
local Blizzard_CombatLog_Filters
local Blizzard_CombatLog_CurrentSettings
local Blizzard_CombatLog_PreviousSettings
--
-- Persistant Variables
--
--
-- Default Filters
--
Blizzard_CombatLog_Filter_Defaults = {
-- All of the filters
filters = {
[1] = {
-- Descriptive Information
name = QUICKBUTTON_NAME_SELF;
hasQuickButton = true;
quickButtonName = QUICKBUTTON_NAME_SELF;
quickButtonDisplay = {
solo = true;
party = true;
raid = true;
};
tooltip = QUICKBUTTON_NAME_SELF_TOOLTIP;
-- Default Color and Formatting Options
settings = CopyTable(COMBATLOG_DEFAULT_SETTINGS);
-- Coloring
colors = CopyTable(COMBATLOG_DEFAULT_COLORS);
-- The actual client filters
filters = {
[1] = {
eventList = {
["ENVIRONMENTAL_DAMAGE"] = true,
["SWING_DAMAGE"] = true,
["SWING_MISSED"] = true,
["RANGE_DAMAGE"] = true,
["RANGE_MISSED"] = true,
--["SPELL_CAST_START"] = true,
--["SPELL_CAST_SUCCESS"] = true,
--["SPELL_CAST_FAILED"] = true,
["SPELL_MISSED"] = true,
["SPELL_DAMAGE"] = true,
["SPELL_HEAL"] = true,
["SPELL_ENERGIZE"] = true,
["SPELL_DRAIN"] = true,
["SPELL_LEECH"] = true,
["SPELL_INSTAKILL"] = true,
["SPELL_INTERRUPT"] = true,
["SPELL_EXTRA_ATTACKS"] = true,
--["SPELL_DURABILITY_DAMAGE"] = true,
--["SPELL_DURABILITY_DAMAGE_ALL"] = true,
["SPELL_AURA_APPLIED"] = true,
["SPELL_AURA_APPLIED_DOSE"] = true,
["SPELL_AURA_REMOVED"] = true,
["SPELL_AURA_REMOVED_DOSE"] = true,
["SPELL_AURA_BROKEN"] = true,
["SPELL_AURA_BROKEN_SPELL"] = true,
["SPELL_AURA_REFRESH"] = true,
["SPELL_DISPEL"] = true,
["SPELL_STOLEN"] = true,
["ENCHANT_APPLIED"] = true,
["ENCHANT_REMOVED"] = true,
["SPELL_PERIODIC_MISSED"] = true,
["SPELL_PERIODIC_DAMAGE"] = true,
["SPELL_PERIODIC_HEAL"] = true,
["SPELL_PERIODIC_ENERGIZE"] = true,
["SPELL_PERIODIC_DRAIN"] = true,
["SPELL_PERIODIC_LEECH"] = true,
["SPELL_DISPEL_FAILED"] = true,
--["DAMAGE_SHIELD"] = true,
--["DAMAGE_SHIELD_MISSED"] = true,
--["DAMAGE_SPLIT"] = true,
["PARTY_KILL"] = true,
["UNIT_DIED"] = true,
["UNIT_DESTROYED"] = true,
["UNIT_DISSIPATES"] = true
};
sourceFlags = {
[COMBATLOG_FILTER_MINE] = true,
[COMBATLOG_FILTER_MY_PET] = true;
};
destFlags = nil;
};
[2] = {
eventList = {
--["ENVIRONMENTAL_DAMAGE"] = true,
["SWING_DAMAGE"] = true,
["SWING_MISSED"] = true,
["RANGE_DAMAGE"] = true,
["RANGE_MISSED"] = true,
--["SPELL_CAST_START"] = true,
--["SPELL_CAST_SUCCESS"] = true,
--["SPELL_CAST_FAILED"] = true,
["SPELL_MISSED"] = true,
["SPELL_DAMAGE"] = true,
["SPELL_HEAL"] = true,
["SPELL_ENERGIZE"] = true,
["SPELL_DRAIN"] = true,
["SPELL_LEECH"] = true,
["SPELL_INSTAKILL"] = true,
["SPELL_INTERRUPT"] = true,
["SPELL_EXTRA_ATTACKS"] = true,
--["SPELL_DURABILITY_DAMAGE"] = true,
--["SPELL_DURABILITY_DAMAGE_ALL"] = true,
--["SPELL_AURA_APPLIED"] = true,
--["SPELL_AURA_APPLIED_DOSE"] = true,
--["SPELL_AURA_REMOVED"] = true,
--["SPELL_AURA_REMOVED_DOSE"] = true,
["SPELL_DISPEL"] = true,
["SPELL_STOLEN"] = true,
["ENCHANT_APPLIED"] = true,
["ENCHANT_REMOVED"] = true,
--["SPELL_PERIODIC_MISSED"] = true,
--["SPELL_PERIODIC_DAMAGE"] = true,
--["SPELL_PERIODIC_HEAL"] = true,
--["SPELL_PERIODIC_ENERGIZE"] = true,
--["SPELL_PERIODIC_DRAIN"] = true,
--["SPELL_PERIODIC_LEECH"] = true,
["SPELL_DISPEL_FAILED"] = true,
--["DAMAGE_SHIELD"] = true,
--["DAMAGE_SHIELD_MISSED"] = true,
--["DAMAGE_SPLIT"] = true,
["PARTY_KILL"] = true,
["UNIT_DIED"] = true,
["UNIT_DESTROYED"] = true,
["UNIT_DISSIPATES"] = true
};
sourceFlags = nil;
destFlags = {
[COMBATLOG_FILTER_MINE] = true,
[COMBATLOG_FILTER_MY_PET] = true;
};
};
};
};
[2] = {
-- Descriptive Information
name = QUICKBUTTON_NAME_EVERYTHING;
hasQuickButton = true;
quickButtonName = QUICKBUTTON_NAME_EVERYTHING;
quickButtonDisplay = {
solo = true;
party = true;
raid = true;
};
tooltip = QUICKBUTTON_NAME_EVERYTHING_TOOLTIP;
-- Settings
settings = CopyTable(COMBATLOG_DEFAULT_SETTINGS);
-- Coloring
colors = CopyTable(COMBATLOG_DEFAULT_COLORS);
-- The actual client filters
filters = {
[1] = {
eventList = Blizzard_CombatLog_GenerateFullEventList();
sourceFlags = Blizzard_CombatLog_GenerateFullFlagList(true);
destFlags = nil;
};
[2] = {
eventList = Blizzard_CombatLog_GenerateFullEventList();
sourceFlags = nil;
destFlags = Blizzard_CombatLog_GenerateFullFlagList(true);
};
};
};
[3] = {
-- Descriptive Information
name = QUICKBUTTON_NAME_ME;
hasQuickButton = true;
quickButtonName = QUICKBUTTON_NAME_ME;
quickButtonDisplay = {
solo = true;
party = true;
raid = true;
};
tooltip = QUICKBUTTON_NAME_ME_TOOLTIP;
-- Settings
settings = CopyTable(COMBATLOG_DEFAULT_SETTINGS);
-- Coloring
colors = CopyTable(COMBATLOG_DEFAULT_COLORS);
-- The actual client filters
filters = {
[1] = {
eventList = Blizzard_CombatLog_GenerateFullEventList();
sourceFlags = Blizzard_CombatLog_GenerateFullFlagList(false);
destFlags = nil;
};
[2] = {
eventList = Blizzard_CombatLog_GenerateFullEventList();
sourceFlags = nil;
destFlags = {
[COMBATLOG_FILTER_MINE] = true,
[COMBATLOG_FILTER_MY_PET] = true;
};
};
};
};
[4] = {
-- Descriptive Information
name = QUICKBUTTON_NAME_KILLS;
hasQuickButton = false;
quickButtonName = QUICKBUTTON_NAME_KILLS;
quickButtonDisplay = {
solo = true;
party = true;
raid = true;
};
tooltip = QUICKBUTTON_NAME_KILLS_TOOLTIP;
-- Settings
settings = CopyTable(COMBATLOG_DEFAULT_SETTINGS);
-- Coloring
colors = CopyTable(COMBATLOG_DEFAULT_COLORS);
-- The actual client filters
filters = {
[1] = {
eventList = {
["PARTY_KILL"] = true,
["UNIT_DIED"] = true,
["UNIT_DESTROYED"] = true,
["UNIT_DISSIPATES"] = true
};
sourceFlags = Blizzard_CombatLog_GenerateFullFlagList(true);
destFlags = nil;
};
[2] = {
eventList = {
["PARTY_KILL"] = true,
["UNIT_DIED"] = true,
["UNIT_DESTROYED"] = true,
["UNIT_DISSIPATES"] = true
};
sourceFlags = nil;
destFlags = Blizzard_CombatLog_GenerateFullFlagList(true);
};
};
};
};
-- Current Filter
currentFilter = 1;
};
local Blizzard_CombatLog_Filters = Blizzard_CombatLog_Filter_Defaults;
_G.Blizzard_CombatLog_Filters = Blizzard_CombatLog_Filters
-- Combat Log Filter Resetting Code
--
-- args:
-- config - the configuration array we are about to apply
--
function Blizzard_CombatLog_ApplyFilters(config)
if ( not config ) then
return;
end
CombatLogResetFilter()
-- Loop over all associated filters
local eventList;
for k,v in pairs(config.filters) do
local eList
-- Only use the first filter's eventList
eventList = config.filters[1].eventList;
if ( eventList ) then
for k2,v2 in pairs(eventList) do
if ( v2 == true ) then
eList = eList and (eList .. "," .. k2) or k2
end
end
end
local sourceFlags, destFlags;
if ( v.sourceFlags ) then
sourceFlags = 0;
for k2, v2 in pairs(v.sourceFlags) do
-- Support for GUIDs
if ( type (k2) == "string" ) then
sourceFlags = k2;
break;
end
-- Otherwise OR bits
if ( v2 ) then
sourceFlags = bit_bor(sourceFlags, k2);
end
end
end
if ( v.destFlags ) then
destFlags = 0;
for k2, v2 in pairs(v.destFlags) do
-- Support for GUIDs
if ( type (k2) == "string" ) then
destFlags = k2;
break;
end
-- Otherwise OR bits
if ( v2 ) then
destFlags = bit_bor(destFlags, k2);
end
end
end
if ( type(sourceFlags) == "string" and destFlags == 0 ) then
destFlags = nil;
end
if ( type(destFlags) == "string" and sourceFlags == 0 ) then
sourceFlags = nil;
end
-- This is a HACK!!! Need filters to be able to accept empty or zero sourceFlags or destFlags
if ( sourceFlags == 0 or destFlags == 0 ) then
CombatLogAddFilter("", COMBATLOG_FILTER_MINE, nil);
else
CombatLogAddFilter(eList, sourceFlags, destFlags);
end
end
end
--
-- Combat Log Repopulation Code
--
-- Message Limit
COMBATLOG_MESSAGE_LIMIT = 300;
--
-- Repopulate the combat log with message history
--
function Blizzard_CombatLog_Refilter()
local count = CombatLogGetNumEntries();
COMBATLOG:SetMaxLines(COMBATLOG_MESSAGE_LIMIT);
-- count should be between 1 and COMBATLOG_MESSAGE_LIMIT
count = max(1, min(count, COMBATLOG_MESSAGE_LIMIT));
CombatLogSetCurrentEntry(0);
-- Clear the combat log
COMBATLOG:Clear();
-- Moved setting the max value here, since we don't really need to reset the max every frame, do we?
-- We can't add events while refiltering (:AddFilter short circuits) so this should be safe optimization.
CombatLogQuickButtonFrameProgressBar:SetMinMaxValues(0, count);
CombatLogQuickButtonFrameProgressBar:SetValue(0);
CombatLogQuickButtonFrameProgressBar:Show();
-- Enable the distributed frame
CombatLogUpdateFrame.refiltering = true;
CombatLogUpdateFrame:SetScript("OnUpdate", Blizzard_CombatLog_RefilterUpdate)
Blizzard_CombatLog_RefilterUpdate()
end
--
-- This is a single frame "step" in the refiltering process
--
function Blizzard_CombatLog_RefilterUpdate()
local valid = CombatLogGetCurrentEntry(); -- CombatLogAdvanceEntry(0);
-- Clear the combat log
local total = 0;
while (valid and total < COMBATLOG_LIMIT_PER_FRAME) do
-- Log to the window
local text, r, g, b, a = CombatLog_OnEvent(Blizzard_CombatLog_CurrentSettings, CombatLogGetCurrentEntry());
-- NOTE: be sure to pass in nil for the color id or the color id may override the r, g, b values for this message
if ( text ) then
COMBATLOG:AddMessage( text, r, g, b, nil, true );
end
-- count can be
-- positive to advance from oldest to newest
-- negative to advance from newest to oldest
valid = CombatLogAdvanceEntry(-1)
total = total + 1;
end
-- Show filtering progress bar
CombatLogQuickButtonFrameProgressBar:SetValue(CombatLogQuickButtonFrameProgressBar:GetValue() + total);
if ( not valid or (CombatLogQuickButtonFrameProgressBar:GetValue() >= COMBATLOG_MESSAGE_LIMIT) ) then
CombatLogUpdateFrame.refiltering = false
CombatLogUpdateFrame:SetScript("OnUpdate", nil)
CombatLogQuickButtonFrameProgressBar:Hide();
end
end
--
-- Checks for an event over all filters
--
function Blizzard_CombatLog_HasEvent ( settings, ... )
-- If this actually happens, we have data corruption issues.
if ( not settings.filters ) then
settings.filters = {}
end
for _, filter in pairs (settings.filters) do
if ( filter.eventList ) then
for i = 1, select("#", ...) do
local event = select(i, ...)
if ( filter.eventList[event] == true ) then
return true
end
end
end
end
end
--
-- Checks for an event over all filters
--
function Blizzard_CombatLog_EnableEvent ( settings, ... )
-- If this actually happens, we have data corruption issues.
if ( not settings.filters ) then
settings.filters = Blizzard_CombatLog_InitializeFilters( settings );
end
for _, filter in pairs (settings.filters) do
if ( not filter.eventList ) then
filter.eventList = {};
end
for i = 1, select("#", ...) do
filter.eventList[select(i, ...)] = true;
end
end
end
--
-- Checks for an event over all filters
--
function Blizzard_CombatLog_DisableEvent ( settings, ... )
-- If this actually happens, we have data corruption issues.
if ( not settings.filters ) then
settings.filters = {}
end
for _, filter in pairs (settings.filters) do
if ( filter.eventList ) then
for i = 1, select("#", ...) do
filter.eventList[select(i, ...)] = false;
end
end
end
end
--
-- Creates the action menu popup
--
do
local eventType
local actionMenu = {
[1] = {
text = "string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_HIDE, eventType)",
func = function () Blizzard_CombatLog_SpellMenuClick ("HIDE", nil, nil, eventType); end;
},
};
function Blizzard_CombatLog_CreateActionMenu(eventType_arg)
-- Update upvalues
eventType = eventType_arg
actionMenu[1].text = string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_HIDE, eventType_arg);
return actionMenu
end
end
--
-- Creates the spell menu popup
--
do
local spellName, spellId, eventType
local spellMenu = {
[1] = {
text = "string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_LINK, spellName)",
func = function () Blizzard_CombatLog_SpellMenuClick ("LINK", spellName, spellId, eventType); end;
},
};
local spellMenu2 = {
[2] = {
text = "string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_HIDE, eventType)",
func = function () Blizzard_CombatLog_SpellMenuClick ("HIDE", spellName, spellId, eventType); end;
},
[3] = {
text = "------------------";
disabled = true;
},
};
function Blizzard_CombatLog_CreateSpellMenu(spellName_arg, spellId_arg, eventType_arg)
-- Update upvalues
spellName, spellId, eventType = spellName_arg, spellId_arg, eventType_arg;
-- Update menu text and filters
spellMenu[1].text = string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_LINK, spellName);
if ( eventType ) then
spellMenu2[2].text = string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_HIDE, eventType);
-- Copy the table references over
spellMenu[2] = spellMenu2[2];
if ( DEBUG ) then
spellMenu[3] = spellMenu2[3];
-- These 2 calls update the menus in their respective do-end blocks
spellMenu[4] = Blizzard_CombatLog_FormattingMenu(Blizzard_CombatLog_Filters.currentFilter);
spellMenu[5] = Blizzard_CombatLog_MessageTypesMenu(Blizzard_CombatLog_Filters.currentFilter);
end
else
-- Remove the table references, they are still stored in their various closures
spellMenu[2] = nil;
spellMenu[3] = nil;
spellMenu[4] = nil;
spellMenu[5] = nil;
end
return spellMenu;
end
end
--
-- Temporary Menu
--
do
-- This big table currently only has one upvalue: Blizzard_CombatLog_CurrentSettings
local messageTypesMenu = {
text = "Message Types";
hasArrow = true;
menuList = {
[1] = {
text = "Melee";
hasArrow = true;
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SWING_DAMAGE", "SWING_MISSED"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SWING_DAMAGE", "SWING_MISSED" );
end;
menuList = {
[1] = {
text = "Damage";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SWING_DAMAGE");end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SWING_DAMAGE" );
end;
};
[2] = {
text = "Failure";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SWING_MISSED"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SWING_MISSED" );
end;
};
};
};
[2] = {
text = "Ranged";
hasArrow = true;
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "RANGE_DAMAGE", "RANGE_MISSED"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "RANGED_DAMAGE", "RANGED_MISSED" );
end;
menuList = {
[1] = {
text = "Damage";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "RANGE_DAMAGE"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "RANGE_DAMAGE" );
end;
};
[2] = {
text = "Failure";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "RANGE_MISSED"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "RANGE_MISSED" );
end;
};
};
};
[3] = {
text = "Spells";
hasArrow = true;
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_DAMAGE", "SPELL_MISSED", "SPELL_HEAL", "SPELL_ENERGIZE", "SPELL_DRAIN", "SPELL_LEECH", "SPELL_INTERRUPT", "SPELL_EXTRA_ATTACKS", "SPELL_CAST_START", "SPELL_CAST_SUCCESS", "SPELL_CAST_FAILED", "SPELL_INSTAKILL", "SPELL_DURABILITY_DAMAGE" ); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SPELL_DAMAGE", "SPELL_MISSED", "SPELL_HEAL", "SPELL_ENERGIZE", "SPELL_DRAIN", "SPELL_LEECH", "SPELL_INTERRUPT", "SPELL_EXTRA_ATTACKS", "SPELL_CAST_START", "SPELL_CAST_SUCCESS", "SPELL_CAST_FAILED", "SPELL_INSTAKILL", "SPELL_DURABILITY_DAMAGE" );
end;
menuList = {
[1] = {
text = "Damage";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_DAMAGE"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SPELL_DAMAGE" );
end;
};
[2] = {
text = "Failure";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_MISSED"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SPELL_MISSED" );
end;
};
[3] = {
text = "Heals";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_HEAL"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SPELL_HEAL" );
end;
};
[4] = {
text = "Power Gains";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_ENERGIZE"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SPELL_ENERGIZE" );
end;
};
[4] = {
text = "Drains";
checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_DRAIN", "SPELL_LEECH"); end;
keepShownOnClick = true;
func = function ( self, arg1, arg2, checked )
Blizzard_CombatLog_MenuHelper ( checked, "SPELL_DRAIN", "SPELL_LEECH" );