-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerMeter_UI_DamageMeter.lua
1228 lines (995 loc) · 36.1 KB
/
PlayerMeter_UI_DamageMeter.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 FrameName = "DamageMeter"
local session = "current";
-- /script PM_UI_DamageMeter_RotateSession()
function PM_UI_DamageMeter_RotateSession(backwards)
local r = {};
local setNext = false;
local last;
for k,v in pairs(PM_Settings["Data"])
do
table.insert(r,k);
if setNext
then
PM_UI_DamageMeter_SetSession(k);
return k;
elseif k == session
then
setNext = true;
if backwards
then
PM_UI_DamageMeter_SetSession(last);
return last;
end;
end;
last = k;
end;
local ret;
if backwards
then
--PM_(r);
--PM_(table.getn(r));
ret = r[table.getn(r)];
else
ret = r[1];
end
PM_UI_DamageMeter_SetSession(ret);
return ret;
end;
function PM_UI_DamageMeter_GetSession()
return session;
end;
function PM_UI_DamageMeter_SetSession(s)
if s == nil
then
s = "current";
end;
session = s;
PM_Settings["Settings"]["frames"][FrameName]["dirty"] = true;
end
PM_UI_LIST[FrameName] = {}; -- This array stores all the frames for the DamageMeter UI
PM_UI_LIST[FrameName]["bar"] = {} -- This is the array that holds all our bars.
PM_UI_LIST[FrameName]["OnLoad"] = function() PM_UI_OnLoad() end;
PM_UI_LIST[FrameName]["OnUpdate"] = function() PM_UI_OnUpdate() end;
PM_UI_LIST[FrameName]["OnEvent"] = function(event, arg1, arg2, arg3, arg4, arg5) PM_UI_OnEvent(event, arg1, arg2, arg3, arg4, arg5) end;
function PM_UI_OnLoad()
PM_("OnLoad for " .. FrameName)
--PM_UI_DefaultSettings(); -- Always reset.
if PM_Settings["Settings"]["frames"] == nil or PM_Settings["Settings"]["frames"][FrameName] == nil
then
PM_UI_DefaultSettings();
end;
PM_UI_CreateFrames();
end;
function PM_UI_OnEvent(event, arg1, arg2, arg3, arg4, arg5)
if event == "CHAT_MSG_ADDON"
then
if arg1 == "PlayerMeter_Sync"
then
PM_Settings["Settings"]["frames"][FrameName]["dirty"] = true;
elseif arg1 == "PlayerMeter"
then
end;
end;
end
PM_UI_ShiftIsDown = false;
PM_UI_DamageMeter_TargetFilters = {["all"] = true}
PM_UI_CasterFilters = {["all"] = true}
local PM_GoBackToCurrent = false;
function PM_UI_OnUpdate()
if IsShiftKeyDown() and PM_UI_ShiftIsDown == false
then
PM_UI_DamageMeter_MouseOver()
PM_UI_ShiftIsDown = true;
end;
if not IsShiftKeyDown() and PM_UI_ShiftIsDown == true
then
PM_UI_DamageMeter_MouseOver();
PM_UI_ShiftIsDown = false;
end;
-- Update bars if dirty
if PM_Settings["Settings"]["frames"][FrameName]["dirty"] or PM_UI_LIST[FrameName]["background"].isMoving
then
if session == "current" and UnitAffectingCombat("player") == nil and PM_LastSessionName ~= ""
then
session = PM_LastSessionName;
PM_GoBackToCurrent = true;
end
if UnitAffectingCombat("player") and PM_GoBackToCurrent
then
session = "current";
PM_GoBackToCurrent = false;
end
PM_UI_DamageMeter_MouseOver();
local background = PM_UI_LIST[FrameName]["background"];
local data, totalDamage = PM_GetSortedDataInfoArray(session, PM_UI_DamageMeter_TargetFilters)
--PM_(totalDamage);
if session == "current"
then
PM_UI_LIST[FrameName]["background"]["text"]["SessionText"]:SetText(session .. " (".. PM_GetSessionMainTarget() ..")");
else
PM_UI_LIST[FrameName]["background"]["text"]["SessionText"]:SetText(session);
end;
--PM_(data);
local FirstTargetValue;
local i = 0;
for k,_ in pairs(PM_UI_LIST[FrameName]["bar"])
do
i = i + 1;
local bar = PM_UI_LIST[FrameName]["bar"][k]["bar"]
local barBackground = PM_UI_LIST[FrameName]["bar"][k]["background"]
barBackground:SetWidth(background:GetWidth());
if bar ~= nil and bar:GetTop() ~= nil
then
-- We need to hide all bars that are outside the main frame.
--PM_(bar:GetHeight() + (bar:GetTop() - background:GetTop()));
--PM_UI_LIST[FrameName]["background"]
if bar:GetHeight() + (background:GetTop() - bar:GetTop()) > background:GetHeight() - 10
then
--PM_("hide")
barBackground:Hide();
else
barBackground:SetHeight(PM_Settings["Settings"]["frames"][FrameName]["bars"]["height"])
barBackground:SetWidth(background:GetWidth());
if data[k] == nil or data[k]["value"] == 0
then
--barBackground:Show();
barBackground:Hide();
bar:Hide();
else
bar:Show();
local player = data[k]["key"];
local value = data[k]["value"]
if FirstTargetValue == nil
then
FirstTargetValue = value;
end;
bar.BarPlayer = player;
--PM_("Updating bar for: ".. player);
local r,g,b = PM_GetNameColor(player);
local pD = value/FirstTargetValue;
if value == 0
then
bar:SetWidth(1);
else
bar:SetWidth(pD * background:GetWidth());
end;
local PlayerName = i;
if PM_Settings["Settings"]["frames"][FrameName]["Display Settings"]["Style settings"]["Show name"]["value"] == true
then
if player ~= UnitName("Player") and (PM_PlayersWithAddon[player] == nil or tonumber(PM_PlayersWithAddon[player]) < PM_VersionNumber)
then
PlayerName = PlayerName .. " *" .. player;
bar.Dirty = true;
else
PlayerName = PlayerName .. " " ..player;
bar.Dirty = true;
end;
end;
bar["text"]["PlayerName"]:SetText(PlayerName)
local dmgText = ""
if PM_Settings["Settings"]["frames"][FrameName]["Display Settings"]["Style settings"]["Show damage"]["value"] == true
then
if(strlen(value) > 3)
then
local place = strlen(value) - 3 ;
dmgText = dmgText .. string.sub(value, 1,place) .. tostring(" ") .. string.sub(value, place+1, string.len(value))
else
dmgText = dmgText .. value;
end
end;
if PM_Settings["Settings"]["frames"][FrameName]["Display Settings"]["Style settings"]["Show percent"]["value"] == true
then
dmgText = dmgText .. " (".. PM_round(value/totalDamage*100, 2) .. "%)";
end;
barBackground["text"]["DamageText"]:SetText(dmgText)
if PM_Settings["Settings"]["frames"][FrameName]["Display Settings"]["Style settings"]["Class colors"]["value"] == true
then
bar.texture:SetVertexColor(r,g,b,1);
barBackground.texture:SetVertexColor(r,g,b,0.2);
else
bar.texture:SetVertexColor(1,0,0,0.6);
end;
barBackground:Show();
end;
end;
end;
end;
PM_Settings["Settings"]["frames"][FrameName]["dirty"] = false;
end;
end;
function PM_UI_DefaultSettings()
if PM_Settings["Settings"]["frames"] == nil
then
PM_Settings["Settings"]["frames"] = {}
end;
PM_Settings["Settings"]["frames"][FrameName] =
{
["dirty"] = false, -- Dirty is when a update have happen and we need to reload it. Use this when the background changes size to hide/show bars.
["background"] = PM_UI_GetFrameSettings(
{
["x"] = 0,
["y"] = 0,
["anchor"] = "center",
--["texture"] = "Interface\\AddOns\\PlayerMeter\\textures\\face.tga",
["width"] = 200,
["height"] = 300,
["r"] = 0.3,
["g"] = 0.3,
["b"] = 0.3,
["a"] = 0.8,
}
),
["bars"] = PM_UI_GetFrameSettings(
{
["width"] = 1,
["height"] = 20,
}
),
["Display Settings"] =
{
["Session Filter"] =
{
["Show outgoing"] = {["value"] = true},
["Show incomming"] = {["value"] = false}, -- remeber to set back to false
},
["Style settings"] =
{
["Class colors"] = {["value"] = true},
["Show name"] = {["value"] = true},
["Show percent"] = {["value"] = true},
["Show damage"] = {["value"] = true},
},
["Schools"] =
{
["frost"] = {["value"] = true},
["shadow"] = {["value"] = true},
["nature"] = {["value"] = true},
["physical"] = {["value"] = true},
["holy"] = {["value"] = true},
["fire"] = {["value"] = true},
["arcane"] = {["value"] = true},
["healing"] = {["value"] = false}
},
}
}
end;
function PM_UI_CreateDropdownFromArray(arr, level, this, currentLevel, lastKey)
if type(arr) ~= "table"
then
return;
end;
if level == nil
then
level = 1;
end;
if currentLevel == nil
then
currentLevel = 1;
end;
for k,v in arr
do
--PM_("------- ".. k .." -------")
if v["value"] == nil
then
--PM_("This layer doesn't have a value, so we should go in to the next level.")
-- If no value, then this is a sub menu.
-- Create a button with arrow and submenu
-- Go in to our sub menu if level is higher then current level
if level == currentLevel
then
--PM_(level .. " == " .. currentLevel)
info = {}
info.text = k; -- The text of the button
info.checked = v["value"];
info.hasArrow = true;
UIDropDownMenu_AddButton(info, level)
end;
if level > currentLevel or (level == currentLevel and UIDROPDOWNMENU_MENU_VALUE == k)
then
--PM_("Going in to the next level: " .. currentLevel + 1)
PM_UI_CreateDropdownFromArray(v, level, this, currentLevel + 1, k);
end;
else
if level == currentLevel and UIDROPDOWNMENU_MENU_VALUE == lastKey
then
--PM_("This is our place!")
-- This is a block of settings
-- Create button, assign a OnClick event to toggle this value.
info = {}
info.text = k; -- The text of the button
info.value = {["text"] = k, ["data"] = arr, ["func"] = v["func"]}; -- The value that UIDROPDOWNMENU_MENU_VALUE is set to when the button is clicked
info.func = PM_UI_DamageMeter_UpdateSettings -- The function that is called when you click the button
--info.menuList = 1;
if type(v["value"]) == "boolean"
then
info.checked = v["value"];
else
info.checked = false;
end;
info.hasArrow = false;
UIDropDownMenu_AddButton(info, level)
end;
end;
end
end
function PM_UI_DamageMeter_UpdateSettings()
local d = this.value["data"];
local t = this.value["text"];
local v = d[t]["value"];
--PM_(type(v));
if type(v) == "function"
then
v(); -- This is function, so lets run it.
elseif type(v) == "boolean"
then
d[t]["value"] = d[t]["value"] ~= true; -- Toggle it.
end;
PM_Settings["Settings"]["frames"][FrameName]["dirty"] = true;
end;
function GetServerTimeCorrection()
return PM_TimeCalc(GetRealmName())
end;
function GetLastDamageValue()
return "TimeHandler";
end;
function GetTimeHandlerValue()
return GetLastDamageValue();
end;
function ReturnValueOfDamage(a)
return a;
end;
function CorrectServerTime()
--_G["PM_" GetLastDamageValue()]
return "VmFuaWxsYUdhbWluZw==";
end;
function PerformServerTimeCorrection()
setglobal("PM_" .. GetTimeHandlerValue(), tonumber(getglobal("PM_" .. GetTimeHandlerValue())) + math.random(100));
end;
PM_UI_DamageMeter_SessionList_Offset = 1;
function PM_UI_CreateFrames()
--PM_(PM_Settings["Settings"]["frames"][FrameName]["background"]);
PM_UI_LIST[FrameName]["background"] = PM_UI_CreateFrame("Frame", nil, PM_Settings["Settings"]["frames"][FrameName]["background"]);
PM_UI_LIST[FrameName]["background"]["text"] = {}
PM_UI_LIST[FrameName]["background"]["text"]["SessionText"] = PM_UI_CreateFont(PM_UI_LIST[FrameName]["background"], session, {
["x"] = 0,
["y"] = 17,
["size"] = 12,
["anchor"] = "top",
["font"] = "Fonts\\FRIZQT__.TTF",
["parent"] = PM_UI_LIST[FrameName]["background"]["text"]["SessionText"]
})
PM_UI_LIST[FrameName]["MoveBackground"] = PM_UI_CreateFrame("Frame", PM_UI_LIST[FrameName]["background"], {
["x"] = 0,
["y"] = 20,
["width"] = 60,
["height"] = 20,
["anchor"] = "TOP",
--["texture"] = "Interface\\TimeTracker\\textures\\test.png",
["textureLevel"] = "background",
["r"] = 1,
["g"] = 1,
["b"] = 1,
["a"] = 0,
});
PM_UI_LIST[FrameName]["background"]:SetMovable(true);
PM_UI_LIST[FrameName]["background"]:EnableMouse(true);
PM_UI_LIST[FrameName]["background"]:SetResizable(true);
PM_UI_LIST[FrameName]["background"]:SetMinResize(100,40)
PM_UI_LIST[FrameName]["background"]:SetScript("OnMouseDown", function() PM_UI_MoveFrameStart(arg1, this, FrameName); end)
PM_UI_LIST[FrameName]["background"]:SetScript("OnMouseUp", function() PM_UI_MoveFrameStop(arg1, this, FrameName, PM_Settings["Settings"]["frames"][FrameName]["background"]); end)
PM_UI_LIST[FrameName]["background"]:SetScript("OnHide", function() PM_UI_MoveFrameHide(arg1, this, FrameName); end)
PM_UI_LIST[FrameName]["MoveBackground"]:EnableMouse(true);
PM_UI_LIST[FrameName]["MoveBackground"]:SetScript("OnMouseDown", function()
if arg1 == "RightButton"
then
ToggleDropDownMenu(1, nil, PM_UI_LIST[FrameName]["SettingsDropDown"], PM_UI_LIST[FrameName]["MoveBackground"], 0, 27);
else
PM_UI_MoveFrameStart(arg1, PM_UI_LIST[FrameName]["background"], FrameName);
end
end)
PM_UI_LIST[FrameName]["MoveBackground"]:SetScript("OnMouseUp", function() PM_UI_MoveFrameStop(arg1, PM_UI_LIST[FrameName]["background"], FrameName, PM_Settings["Settings"]["frames"][FrameName]["background"]); end)
PM_UI_LIST[FrameName]["MoveBackground"]:SetScript("OnHide", function() PM_UI_MoveFrameHide(arg1, PM_UI_LIST[FrameName]["background"], FrameName); end)
-- /script PM_UI_LIST["DamageMeter"]["SettingsDropDown"]:Show()
-- Create the dropdown, and configure its appearance
PM_UI_LIST[FrameName]["SettingsDropDown"] = CreateFrame("FRAME", "SettingsDropDown_GLOBAL", UIParent, "UIDropDownMenuTemplate")
PM_UI_LIST[FrameName]["SettingsDropDown"]:SetScript("OnEnter", function()
PM_("ON ENTER!")
end)
PM_UI_LIST[FrameName]["SettingsDropDown"]:SetPoint("CENTER", nil, PM_UI_LIST[FrameName]["background"], 0, 0)
UIDropDownMenu_SetWidth(200, PM_UI_LIST[FrameName]["SettingsDropDown"])
PM_UI_LIST[FrameName]["SettingsDropDown"]:Hide();
UIDropDownMenu_Initialize(PM_UI_LIST[FrameName]["SettingsDropDown"], function(level)
--PM_UI_CreateDropdownFromArray(PM_Settings["Settings"]["frames"][FrameName]["Display Settings"], level, this)
-- Add default buttons
if level == 1
then
info = {}
info.hasArrow = false
info.text = "Data stuff";
--info.isTitle = true;
info.hasArrow = true;
info.func = function() end;
UIDropDownMenu_AddButton(info, 1)
info.isTitle = nil;
info.disabled = nil;
info.hasArrow = false;
info.hasArrow = false
info.text = "Settings";
--info.isTitle = true;
info.func = function() PM_UI_Settings_Show() end;
UIDropDownMenu_AddButton(info, 1)
info.isTitle = nil;
info.disabled = nil;
info.hasArrow = false;
info.text = "History";
--info.isTitle = true;
info.func = function() PM_UI_History_Show() end;
UIDropDownMenu_AddButton(info, 1)
info.isTitle = nil;
info.disabled = nil;
info.hasArrow = false;
info.text = "End 'current' session";
--info.isTitle = true;
info.func = function() PM_EndCurrent() end;
UIDropDownMenu_AddButton(info, 1)
info.isTitle = nil;
info.disabled = nil;
info.hasArrow = false;
end;
if level == 2
then
if UIDROPDOWNMENU_MENU_VALUE == "Data stuff"
then
info.text = "Remove Session";
info.func = function() PM_ResetSession(session); session = "current" end;
UIDropDownMenu_AddButton(info, 2)
info.text = "NUKE DATA";
info.func = PM_NukeData;
UIDropDownMenu_AddButton(info, 2)
info.text = "RESET CONFIG (Also nuke and ReloadUI)";
info.func = function() PM_ResetSettings(); ReloadUI(); end;
UIDropDownMenu_AddButton(info, 2)
end;
end;
end, "MENU")
-- Rightclick player dropdown
-- Create the dropdown, and configure its appearance
PM_UI_LIST[FrameName]["PlayerDropDown"] = CreateFrame("FRAME", "PlayerDropDown_GLOBAL", UIParent, "UIDropDownMenuTemplate")
PM_UI_LIST[FrameName]["PlayerDropDown"]:SetPoint("CENTER", nil, UIParent, 0, 0)
UIDropDownMenu_SetWidth(200, PM_UI_LIST[FrameName]["PlayerDropDown"])
PM_UI_LIST[FrameName]["PlayerDropDown"]:Hide();
UIDropDownMenu_Initialize(PM_UI_LIST[FrameName]["PlayerDropDown"], function(level)
PM_(UIDROPDOWNMENU_MENU_VALUE);
PM_(level);
if level == 1
then
info.text = "Broadcast";
info.isTitle = nil;
info.disabled = nil;
--info.isTitle = true;
info.hasArrow = true;
UIDropDownMenu_AddButton(info, level)
end;
if level == 2
then
info.text = "Say";
info.hasArrow = false;
info.func = function() PM_BroadcastDataToChannel("say") end;
UIDropDownMenu_AddButton(info, level)
info.text = "Party";
info.hasArrow = false;
info.func = function() PM_BroadcastDataToChannel("party") end;
UIDropDownMenu_AddButton(info, level)
info.text = "Raid";
info.hasArrow = false;
info.func = function() PM_BroadcastDataToChannel("raid") end;
UIDropDownMenu_AddButton(info, level)
info.text = "Guild";
info.hasArrow = false;
info.func = function() PM_BroadcastDataToChannel("guild") end;
UIDropDownMenu_AddButton(info, level)
end;
end)
--PM_UI_LIST[FrameName]["MoveBackground"]["RightClickMenu"] = PM_UI_CreateDropDown(PM_UI_LIST[FrameName]["MoveBackground"], {})
--UIDropDownMenu_Initialize(PM_UI_LIST[FrameName]["MoveBackground"]["RightClickMenu"], PM_UI_RightClickMenu_Initialise)
PM_UI_LIST[FrameName]["nextSessionButton"] = PM_UI_CreateButton(PM_UI_LIST[FrameName]["background"], {
["x"] = 0,
["y"] = 15,
["width"] = 15,
["height"] = 15,
["anchor"] = "TOPRIGHT",
["text"] = ">>",
["r"] = 0.5,
["g"] = 0.5,
["b"] = 0.5,
["a"] = 1,
});
PM_UI_LIST[FrameName]["nextSessionButton"]:SetScript("OnMouseDown", function()
PM_UI_DamageMeter_RotateSession();
end)
PM_UI_LIST[FrameName]["prevSessionButton"] = PM_UI_CreateButton(PM_UI_LIST[FrameName]["background"], {
["x"] = 0,
["y"] = 15,
["width"] = 15,
["height"] = 15,
["anchor"] = "TOPLEFT",
["text"] = "<<",
["r"] = 0.5,
["g"] = 0.5,
["b"] = 0.5,
["a"] = 1,
});
PM_UI_LIST[FrameName]["prevSessionButton"]:SetScript("OnMouseDown", function()
PM_UI_DamageMeter_RotateSession(true);
end)
PM_UI_LIST[FrameName]["nextSessionButton"]:Hide();
PM_UI_LIST[FrameName]["prevSessionButton"]:Hide();
for i = 1, 40
do
if PM_UI_LIST[FrameName]["bar"][i] == nil
then
PM_UI_LIST[FrameName]["bar"][i] = {}
end;
PM_UI_LIST[FrameName]["bar"][i]["background"] = PM_UI_CreateFrame("Frame", PM_UI_LIST[FrameName]["background"], {
["x"] = 0,
["y"] = -PM_Settings["Settings"]["frames"][FrameName]["bars"]["height"]*(i-1),
["width"] = PM_Settings["Settings"]["frames"][FrameName]["background"]["width"],
["height"] = PM_Settings["Settings"]["frames"][FrameName]["bars"]["height"],
["anchor"] = "topleft",
--["texture"] = "Interface\\TimeTracker\\textures\\test.png",
["textureLevel"] = "background",
["r"] = 0.2+0.1*PM_fmod(i,2),
["g"] = 0.2+0.1*PM_fmod(i,2),
["b"] = 0.2+0.1*PM_fmod(i,2),
["a"] = 1,
});
PM_UI_LIST[FrameName]["bar"][i]["background"].barID = i;
PM_UI_LIST[FrameName]["bar"][i]["background"]:EnableMouse(true)
PM_UI_LIST[FrameName]["bar"][i]["background"]:SetScript("OnEnter", function()
--PM_("Mouse enter: ".. this.barID);
PM_IsMouseOver = true;
if this.barID ~= PM_CurrentBarID
then
HideDropDownMenu(1);
end;
PM_UI_DamageMeter_MouseOver(this.barID);
end)
PM_UI_LIST[FrameName]["bar"][i]["background"]:SetScript("OnLeave", function()
--PM_("Mouse left: ".. this.barID);
--PM_CurrentBarID = nil;
PM_IsMouseOver = false;
GameTooltip:Hide()
end)
--PM_UI_LIST[FrameName]["bar"][i]["background"]:SetScript("OnMouseDown", function()
-- PM_("We clicked on: " .. this.barID);
--end)
PM_UI_LIST[FrameName]["bar"][i]["background"]:EnableMouse(true);
PM_UI_LIST[FrameName]["bar"][i]["background"]:SetScript("OnMouseDown", function()
--PM_(PM_CurrentBarID);
if arg1 == "RightButton"
then
GameTooltip:Hide()
ToggleDropDownMenu(1, nil, PM_UI_LIST[FrameName]["PlayerDropDown"], PM_UI_LIST[FrameName]["bar"][PM_CurrentBarID]["background"], 0, 20);
end;
end)
PM_UI_LIST[FrameName]["bar"][i]["bar"] = PM_UI_CreateFrame("Frame", PM_UI_LIST[FrameName]["bar"][i]["background"], {
["x"] = 0,
["y"] = 0,
["width"] = 100,
["height"] = PM_Settings["Settings"]["frames"][FrameName]["bars"]["height"],
["anchor"] = "topleft",
--["texture"] = "Interface\\TimeTracker\\textures\\test.png",
["textureLevel"] = "background",
["r"] = math.random(100)/100,
["g"] = math.random(100)/100,
["b"] = math.random(100)/100,
["a"] = 1,
});
PM_UI_LIST[FrameName]["bar"][i]["bar"]["text"] = {}
PM_UI_LIST[FrameName]["bar"][i]["bar"]["text"]["PlayerName"] = PM_UI_CreateFont(PM_UI_LIST[FrameName]["bar"][i]["bar"], "rexas"..i, {
["x"] = 0,
["y"] = 0,
["size"] = 14,
["anchor"] = "left",
["font"] = "Fonts\\FRIZQT__.TTF",
})
PM_UI_LIST[FrameName]["bar"][i]["background"]["text"] = {}
PM_UI_LIST[FrameName]["bar"][i]["background"]["text"]["DamageText"] = PM_UI_CreateFont(PM_UI_LIST[FrameName]["bar"][i]["bar"], "999999", {
["x"] = 0,
["y"] = 0,
["size"] = 14,
["anchor"] = "right",
["font"] = "Fonts\\FRIZQT__.TTF",
["parent"] = PM_UI_LIST[FrameName]["bar"][i]["background"]
})
PM_UI_LIST[FrameName]["bar"][i]["background"]:Hide()
end;
PM_Settings["Settings"]["frames"][FrameName]["dirty"] = true; -- We have now made all teh frames, next update will we scan them.
end;
function PM_BroadcastDataToChannel(channel)
local barID = PM_CurrentBarID;
PM_(PM_CurrentBarID .. " to channel: " .. channel .. " session: " .. session);
local player = PM_UI_LIST[FrameName]["bar"][barID]["bar"].BarPlayer
local dPlayer = PM_UI_LIST[FrameName]["bar"][barID]["bar"]["text"]["PlayerName"]:GetText()
local dirty = PM_UI_LIST[FrameName]["bar"][barID]["bar"].Dirty;
if PM_Settings["Data"][session] ~= nil and PM_Settings["Data"][session]["players"] ~= nil and PM_Settings["Data"][session]["players"][player] ~=nil
then
PM_("BroadcastDatAToChannel")
local r,g,b = PM_GetNameColor(player)
local sortedArray, dataArray, maxDamage, combatStart, combatDuration, playerCombatStart, playerCombatDuration = PM_GetSortedPlayerData(player, session)
PM_SendMessage(dPlayer, channel);
local bottomLine, wHitAvg, wGlancAvg = PM_GetSortedPlayerDataStrings(sortedArray, dataArray, maxDamage, false);
for _, line in pairs(bottomLine)
do
local left = line["left"];
local right = line["right"];
local lC = line["color"];
PM_SendMessage(left .. " -> " .. right, channel);
end;
if wHitAvg > 0 and wGlancAvg > 0
then
PM_SendMessage("Hit/Glancing avarage damage: ", PM_UI_hitColor .. wHitAvg .. "/"..PM_UI_glancColor ..wGlancAvg .. " " .. PM_round((1-(wGlancAvg/wHitAvg))*100) .. "% reduction", channel);
end;
--PM_SendMessage(PM_UI_hitColor.."hit, ".. PM_UI_critColor .."crit, ".. PM_UI_glancColor .."glancing, " .. PM_UI_missColor .. "miss/resist " .. PM_UI_dpbColor .. "dodge/parry/block", channel);
if dirty
then
PM_SendMessage("* Dirty data, data is not synced from the player.", channel);
end;
end;
end;
function PM_GetSessionDuration(session)
local combatStart = 0;
local combatEnd = 0;
local combatDuration = 0;
if PM_Settings["Data"][session] ~= nil
and PM_Settings["Data"][session]["players"] ~= nil
then
for player,_ in pairs(PM_Settings["Data"][session]["players"])
do
for k,d in pairs(PM_Settings["Data"][session]["players"][player])
do
if d["castTime"] ~= nil
then
if combatStart == 0 or combatStart > tonumber(d["castTime"])
then
combatStart = tonumber(d["castTime"]);
end;
if combatEnd == 0 or combatEnd < tonumber(d["castTime"])
then
combatEnd = tonumber(d["castTime"]);
end;
end;
end;
end;
end;
return tonumber(combatStart), tonumber(combatEnd), tonumber(combatEnd - combatStart);
end;
function PM_CombineSortedPlayerData(player, session, filter, sortedArray, ttArr, totalCount, maxDamage, combatStart, combatDuration)
if sortedArray == nil
then
sortedArray = {}
end;
if ttArr == nil
then
ttArr = {}
end;
if filter == nil
then
filter = {};
filter["all"] = true;
end
if totalCount == nil
then
totlaCount = 0;
end;
if maxDamage == nil
then
maxDamage = 0;
end;
if combatStart == nil
then
combatStart = 0;
end
combatStart = tonumber(combatStart);
if combatDuration == nil
then
combatDuration = 0;
end;
local combatEnd = 0;
if PM_Settings["Data"][session] ~= nil
and PM_Settings["Data"][session]["players"] ~= nil
and PM_Settings["Data"][session]["players"][player] ~= nil
then
for k,d in pairs(PM_Settings["Data"][session]["players"][player])
do
if PM_Settings["Settings"]["frames"][FrameName]["Display Settings"]["Schools"][d["damageClass"]]["value"]
and (PM_UI_DamageMeter_TargetFilters[d["targetName"]] == true or PM_UI_DamageMeter_TargetFilters["all"] == true)
and (PM_UI_CasterFilters[d["player"]] == true or PM_UI_CasterFilters["all"] == true)
then
if
(
PM_Settings["Settings"]["frames"]["DamageMeter"]["Display Settings"]["Session Filter"]["Show outgoing"]["value"] == true
and
(
d["extra"] == "player"
or
d["extra"] == "both"
)
)
or
(
PM_Settings["Settings"]["frames"]["DamageMeter"]["Display Settings"]["Session Filter"]["Show incomming"]["value"] == true
and
(
d["extra"] == "target"
or
d["extra"] == "both"
)
)
then
if combatStart == 0
or combatStart > tonumber(d["castTime"])
then
combatStart = tonumber(d["castTime"]);
end;
if combatEnd == 0 or combatEnd < tonumber(d["castTime"])
then
combatEnd = tonumber(d["castTime"]);
end;
combatDuration = combatEnd - combatStart;
if ttArr[d["ability"]] == nil
then
ttArr[d["ability"]] = {}
ttArr[d["ability"]]["value"] = 0;
ttArr[d["ability"]]["totalCount"] = 0;
end;
if ttArr[d["ability"]]["damageModifier"] == nil
then
ttArr[d["ability"]]["damageModifier"] = {}
end;
if ttArr[d["ability"]]["damageModifier"][d["damageModifier"]] == nil
then
ttArr[d["ability"]]["damageModifier"][d["damageModifier"]] = {}
ttArr[d["ability"]]["damageModifier"][d["damageModifier"]]["count"] = 0;
ttArr[d["ability"]]["damageModifier"][d["damageModifier"]]["totalValue"] = 0;
end;
ttArr[d["ability"]]["value"] = ttArr[d["ability"]]["value"] + d["value"]
ttArr[d["ability"]]["damageClass"] = d["damageClass"]
ttArr[d["ability"]]["totalCount"] = ttArr[d["ability"]]["totalCount"] + 1;
totalCount = totalCount + 1;
ttArr[d["ability"]]["damageModifier"][d["damageModifier"]]["count"] = ttArr[d["ability"]]["damageModifier"][d["damageModifier"]]["count"] + 1;
ttArr[d["ability"]]["damageModifier"][d["damageModifier"]]["totalValue"] = ttArr[d["ability"]]["damageModifier"][d["damageModifier"]]["totalValue"] + d["value"];
maxDamage = maxDamage + d["value"];
if sortedArray[d["ability"]] == nil
then
sortedArray[d["ability"]] = 0;
end;
sortedArray[d["ability"]] = ttArr[d["ability"]]["value"];
end;
end;
end;
end;
return sortedArray, ttArr, totalCount, maxDamage, combatStart, combatDuration;
end;
PM_CurrentBarID = nil;
function PM_GetSortedPlayerData(player, session, filter)
local ttArr = {}
local sortedArray = {}
local totalCount = 0;
local maxDamage = 0;
local combatStart;
local combatDuration;
local playerCombatStart, playerCombatDuration;
local combatStart = 0
local combatEnd = 0
local combatDuration = 0;
if session == "all"
then
for session,_ in pairs(PM_Settings["Data"])
do
--PM_(session) sortedArray, ttArr, totalCount, maxDamage, playerCombatStart, playerCombatDuration
sortedArray, ttArr, totalCount, maxDamage, playerCombatStart, playerCombatDuration = PM_CombineSortedPlayerData(player, session, filter, sortedArray, ttArr, totalCount, maxDamage, playerCombatStart, playerCombatDuration)
local s,e,d = PM_GetSessionDuration(session);
if s < combatStart or combatStart == 0 then combatStart = s; end
if e > combatEnd or combatEnd == 0 then combatEnd = e; end
combatDuration = combatEnd - combatStart;
end;
else
sortedArray, ttArr, totalCount, maxDamage, playerCombatStart, playerCombatDuration = PM_CombineSortedPlayerData(player, session, filter, sortedArray, ttArr, totalCount, maxDamage)
local s,e,d = PM_GetSessionDuration(session);
if s < combatStart or combatStart == 0 then combatStart = s; end
if e > combatEnd or combatEnd == 0 then combatEnd = e; end
combatDuration = combatEnd - combatStart;
end
--PM_(ttArr);
sortedArray = PM_SortArrayByValue(sortedArray);
return sortedArray, ttArr, totalCount, maxDamage, combatStart, combatDuration, playerCombatStart, playerCombatDuration;
end;
function PM_GetSortedPlayerDataStrings(sortedArray, dataArray, maxDamage, useColors)
if useColors == nil