-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMizusRaidTracker_GUI.lua
More file actions
1600 lines (1531 loc) · 69.7 KB
/
Copy pathMizusRaidTracker_GUI.lua
File metadata and controls
1600 lines (1531 loc) · 69.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
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
-- ********************************************************
-- ** Mizus RaidTracker - GUI **
-- ** <http://cosmocanyon.de> **
-- ********************************************************
--
-- This addon is written and copyrighted by:
-- * Mîzukichan @ EU-Antonidas (2010-2021)
--
-- This file is part of Mizus RaidTracker.
--
-- Mizus RaidTracker is free software: you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 3 of the
-- License, or (at your option) any later version.
--
-- Mizus RaidTracker is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Mizus RaidTracker.
-- If not, see <http://www.gnu.org/licenses/>.
-- Check for addon table
if (not MizusRaidTracker) then MizusRaidTracker = {}; end
local mrt = MizusRaidTracker
--------------
-- Locals --
--------------
local deformat = LibStub("LibDeformat-3.0");
local ScrollingTable = LibStub("ScrollingTable");
local MRT_GUI_RaidLogTableSelection = nil;
local MRT_GUI_RaidBosskillsTableSelection = nil;
local MRT_ExternalLootNotifier = {};
local lastShownNumOfRaids = nil;
local lastSelectedRaidNum = nil;
local lastShownNumOfBosses = nil;
local lastSelectedBossNum = nil;
-- table definitions
local MRT_RaidLogTableColDef = {
{["name"] = MRT_L.GUI["Col_Num"], ["width"] = 25, ["defaultsort"] = "dsc"},
{["name"] = MRT_L.GUI["Col_Date"], ["width"] = 75},
{["name"] = MRT_L.GUI["Col_Zone"], ["width"] = 100},
{["name"] = MRT_L.GUI["Col_Size"], ["width"] = 25},
};
local MRT_RaidAttendeesTableColDef = {
{["name"] = "", ["width"] = 1}, -- invisible column for storing the player number index from the raidlog-table
{["name"] = MRT_L.GUI["Col_Name"], ["width"] = 74},
{["name"] = MRT_L.GUI["Col_Join"], ["width"] = 45},
{["name"] = MRT_L.GUI["Col_Leave"], ["width"] = 45},
};
local MRT_RaidBosskillsTableColDef = {
{["name"] = MRT_L.GUI["Col_Num"], ["width"] = 25, ["defaultsort"] = "dsc"},
{["name"] = MRT_L.GUI["Col_Time"], ["width"] = 40},
{["name"] = MRT_L.GUI["Col_Name"], ["width"] = 105},
{["name"] = MRT_L.GUI["Col_Difficulty"], ["width"] = 45},
};
local MRT_BossLootTableColDef = {
{["name"] = "", ["width"] = 1}, -- invisible column for storing the loot number index from the raidlog-table
{ -- coloumn for Item Icon - need to store ID
["name"] = "Icon",
["width"] = 30,
["DoCellUpdate"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, self, ...)
-- icon handling
if fShow then
local itemId = self:GetCell(realrow, column);
local itemTexture = GetItemIcon(itemId);
if not (cellFrame.cellItemTexture) then
cellFrame.cellItemTexture = cellFrame:CreateTexture();
end
cellFrame.cellItemTexture:SetTexture(itemTexture);
cellFrame.cellItemTexture:SetTexCoord(0, 1, 0, 1);
cellFrame.cellItemTexture:Show();
cellFrame.cellItemTexture:SetPoint("CENTER", cellFrame.cellItemTexture:GetParent(), "CENTER");
cellFrame.cellItemTexture:SetWidth(30);
cellFrame.cellItemTexture:SetHeight(30);
end
-- tooltip handling
local itemLink = self:GetCell(realrow, 6);
cellFrame:SetScript("OnEnter", function()
MRT_GUI_ItemTT:SetOwner(cellFrame, "ANCHOR_RIGHT");
MRT_GUI_ItemTT:SetHyperlink(itemLink);
MRT_GUI_ItemTT:Show();
end);
cellFrame:SetScript("OnLeave", function()
MRT_GUI_ItemTT:Hide();
MRT_GUI_ItemTT:SetOwner(UIParent, "ANCHOR_NONE");
end);
end,
},
{["name"] = MRT_L.GUI["Col_Name"], ["width"] = 179},
{["name"] = MRT_L.GUI["Col_Looter"], ["width"] = 85},
{["name"] = MRT_L.GUI["Col_Cost"], ["width"] = 30},
{["name"] = "", ["width"] = 1}, -- invisible column for itemString (needed for tooltip)
{
["name"] = MRT_L.GUI["Note"],
["width"] = 30,
["DoCellUpdate"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, self, ...)
-- icon handling
local lootNote = self:GetCell(realrow, column);
if fShow and lootNote then
if not (cellFrame.cellLootNoteTexture) then
cellFrame.cellLootNoteTexture = cellFrame:CreateTexture();
end
cellFrame.cellLootNoteTexture:SetTexture("Interface\\BUTTONS\\UI-GuildButton-PublicNote-Up")
cellFrame.cellLootNoteTexture:SetTexCoord(0, 1, 0, 1);
cellFrame.cellLootNoteTexture:Show();
cellFrame.cellLootNoteTexture:SetPoint("CENTER", cellFrame.cellLootNoteTexture:GetParent(), "CENTER");
cellFrame:SetScript("OnEnter", function()
MRT_GUI_ItemTT:SetOwner(cellFrame, "ANCHOR_RIGHT");
MRT_GUI_ItemTT:SetText(lootNote);
MRT_GUI_ItemTT:Show();
end);
cellFrame:SetScript("OnLeave", function()
MRT_GUI_ItemTT:Hide();
MRT_GUI_ItemTT:SetOwner(UIParent, "ANCHOR_NONE");
end);
else
if (cellFrame.cellLootNoteTexture) then
cellFrame.cellLootNoteTexture:Hide();
end
cellFrame:SetScript("OnEnter", nil);
cellFrame:SetScript("OnLeave", nil);
MRT_GUI_ItemTT:Hide();
MRT_GUI_ItemTT:SetOwner(UIParent, "ANCHOR_NONE");
end
end,
},
};
local MRT_BossAttendeesTableColDef = {
{["name"] = "", ["width"] = 1}, -- invisible column for storing the attendee number index from the raidlog-table
{["name"] = MRT_L.GUI["Col_Name"], ["width"] = 85},
};
local MRT_PlayerDropDownTableColDef = {
{["name"] = "", ["width"] = 100},
};
-----------------
-- API-Stuff --
-----------------
function MRT_RegisterLootNotifyGUI(functionToCall)
local isRegistered = nil;
for i, val in ipairs(MRT_ExternalLootNotifier) do
if (val == functionToCall) then
isRegistered = true;
end
end
if (isRegistered) then
return false;
else
tinsert(MRT_ExternalLootNotifier, functionToCall);
return true;
end
end
function MRT_UnregisterLootNotifyGUI(functionCalled)
local isRegistered = nil;
for i, val in ipairs(MRT_ExternalLootNotifier) do
if (val == functionCalled) then
isRegistered = i;
end
end
if (isRegistered) then
tremove(MRT_ExternalLootNotifier, isRegistered);
return true;
else
return false;
end
end
---------------------------------------------------------------
-- parse localization and set up tables after ADDON_LOADED --
---------------------------------------------------------------
function MRT_GUI_ParseValues()
-- Parse title strings
MRT_GUIFrame_Title:SetText(MRT_L.GUI["Header_Title"]);
MRT_GUIFrame_RaidLogTitle:SetText(MRT_L.GUI["Tables_RaidLogTitle"]);
MRT_GUIFrame_RaidAttendeesTitle:SetText(MRT_L.GUI["Tables_RaidAttendeesTitle"]);
MRT_GUIFrame_RaidBosskillsTitle:SetText(MRT_L.GUI["Tables_RaidBosskillsTitle"]);
MRT_GUIFrame_BossLootTitle:SetText(MRT_L.GUI["Tables_RaidLootTitle"]);
MRT_GUIFrame_BossAttendeesTitle:SetText(MRT_L.GUI["Tables_BossAttendeesTitle"]);
-- Create and anchor tables
MRT_GUI_RaidLogTable = ScrollingTable:CreateST(MRT_RaidLogTableColDef, 12, nil, nil, MRT_GUIFrame);
MRT_GUI_RaidLogTable.frame:SetPoint("TOPLEFT", MRT_GUIFrame_RaidLogTitle, "BOTTOMLEFT", 0, -15);
MRT_GUI_RaidLogTable:EnableSelection(true);
MRT_GUI_RaidAttendeesTable = ScrollingTable:CreateST(MRT_RaidAttendeesTableColDef, 12, nil, nil, MRT_GUIFrame);
MRT_GUI_RaidAttendeesTable.frame:SetPoint("TOPLEFT", MRT_GUIFrame_RaidAttendeesTitle, "BOTTOMLEFT", 0, -15);
MRT_GUI_RaidAttendeesTable:EnableSelection(true);
MRT_GUI_RaidBosskillsTable = ScrollingTable:CreateST(MRT_RaidBosskillsTableColDef, 12, nil, nil, MRT_GUIFrame);
MRT_GUI_RaidBosskillsTable.frame:SetPoint("TOPLEFT", MRT_GUIFrame_RaidBosskillsTitle, "BOTTOMLEFT", 0, -15);
MRT_GUI_RaidBosskillsTable:EnableSelection(true);
MRT_GUI_BossLootTable = ScrollingTable:CreateST(MRT_BossLootTableColDef, 6, 30, nil, MRT_GUIFrame); -- ItemId should be squared - so use 30x30 -> 30 pixels high
MRT_GUI_BossLootTable.head:SetHeight(15); -- Manually correct the height of the header (standard is rowHight - 30 pix would be different from others tables around and looks ugly)
MRT_GUI_BossLootTable.frame:SetPoint("TOPLEFT", MRT_GUIFrame_BossLootTitle, "BOTTOMLEFT", 0, -15);
MRT_GUI_BossLootTable:EnableSelection(true);
MRT_GUI_BossAttendeesTable = ScrollingTable:CreateST(MRT_BossAttendeesTableColDef, 12, nil, nil, MRT_GUIFrame);
MRT_GUI_BossAttendeesTable.frame:SetPoint("TOPLEFT", MRT_GUIFrame_BossAttendeesTitle, "BOTTOMLEFT", 0, -15);
MRT_GUI_BossAttendeesTable:EnableSelection(true);
-- parse button local / anchor buttons relative to tables
MRT_GUIFrame_RaidLog_Export_Button:SetText(MRT_L.GUI["Button_Export"]);
MRT_GUIFrame_RaidLog_Export_Button:SetPoint("TOPLEFT", MRT_GUI_RaidLogTable.frame, "BOTTOMLEFT", 0, -5);
MRT_GUIFrame_RaidLog_Delete_Button:SetText(MRT_L.GUI["Button_Delete"]);
MRT_GUIFrame_RaidLog_Delete_Button:SetPoint("LEFT", MRT_GUIFrame_RaidLog_Export_Button, "RIGHT", 10, 0);
MRT_GUIFrame_RaidLog_ExportNormal_Button:SetText(MRT_L.GUI["Button_ExportNormal"]);
MRT_GUIFrame_RaidLog_ExportNormal_Button:SetPoint("TOP", MRT_GUIFrame_RaidLog_Export_Button, "BOTTOM", 0, -5);
MRT_GUIFrame_RaidLog_ExportHeroic_Button:SetText(MRT_L.GUI["Button_ExportHeroic"]);
MRT_GUIFrame_RaidLog_ExportHeroic_Button:SetPoint("LEFT", MRT_GUIFrame_RaidLog_ExportNormal_Button, "RIGHT", 10, 0);
MRT_GUIFrame_RaidBosskills_Add_Button:SetText(MRT_L.GUI["Button_Add"]);
MRT_GUIFrame_RaidBosskills_Add_Button:SetPoint("TOPLEFT", MRT_GUI_RaidBosskillsTable.frame, "BOTTOMLEFT", 0, -5);
MRT_GUIFrame_RaidBosskills_Delete_Button:SetText(MRT_L.GUI["Button_Delete"]);
MRT_GUIFrame_RaidBosskills_Delete_Button:SetPoint("LEFT", MRT_GUIFrame_RaidBosskills_Add_Button, "RIGHT", 10, 0);
MRT_GUIFrame_RaidBosskills_Export_Button:SetText(MRT_L.GUI["Button_Export"]);
MRT_GUIFrame_RaidBosskills_Export_Button:SetPoint("TOP", MRT_GUIFrame_RaidBosskills_Add_Button, "BOTTOM", 0, -5);
MRT_GUIFrame_RaidBosskills_Rename_Button:SetText(MRT_L.GUI["Button_Rename"]);
MRT_GUIFrame_RaidBosskills_Rename_Button:SetPoint("LEFT", MRT_GUIFrame_RaidBosskills_Export_Button, "RIGHT", 10, 0);
MRT_GUIFrame_RaidAttendees_Add_Button:SetText(MRT_L.GUI["Button_Add"]);
MRT_GUIFrame_RaidAttendees_Add_Button:SetPoint("TOPLEFT", MRT_GUI_RaidAttendeesTable.frame, "BOTTOMLEFT", 0, -5);
MRT_GUIFrame_RaidAttendees_Delete_Button:SetText(MRT_L.GUI["Button_Delete"]);
MRT_GUIFrame_RaidAttendees_Delete_Button:SetPoint("LEFT", MRT_GUIFrame_RaidAttendees_Add_Button, "RIGHT", 10, 0);
MRT_GUIFrame_BossLoot_Add_Button:SetText(MRT_L.GUI["Button_Add"]);
MRT_GUIFrame_BossLoot_Add_Button:SetPoint("TOPLEFT", MRT_GUI_BossLootTable.frame, "BOTTOMLEFT", 0, -5);
MRT_GUIFrame_BossLoot_Modify_Button:SetText(MRT_L.GUI["Button_Modify"]);
MRT_GUIFrame_BossLoot_Modify_Button:SetPoint("LEFT", MRT_GUIFrame_BossLoot_Add_Button, "RIGHT", 10, 0);
MRT_GUIFrame_BossLoot_Delete_Button:SetText(MRT_L.GUI["Button_Delete"]);
MRT_GUIFrame_BossLoot_Delete_Button:SetPoint("LEFT", MRT_GUIFrame_BossLoot_Modify_Button, "RIGHT", 10, 0);
MRT_GUIFrame_BossAttendees_Add_Button:SetText(MRT_L.GUI["Button_Add"]);
MRT_GUIFrame_BossAttendees_Add_Button:SetPoint("TOPLEFT", MRT_GUI_BossAttendeesTable.frame, "BOTTOMLEFT", 0, -5);
MRT_GUIFrame_BossAttendees_Delete_Button:SetText(MRT_L.GUI["Button_Delete"]);
MRT_GUIFrame_BossAttendees_Delete_Button:SetPoint("TOP", MRT_GUIFrame_BossAttendees_Add_Button, "BOTTOM", 0, -5);
MRT_GUIFrame_TakeSnapshot_Button:SetText(MRT_L.GUI["Button_TakeSnapshot"]);
MRT_GUIFrame_TakeSnapshot_Button:SetPoint("TOPLEFT", MRT_GUI_BossLootTable.frame, "TOPLEFT", -215, 0);
MRT_GUIFrame_StartNewRaid_Button:SetText(MRT_L.GUI["Button_StartNewRaid"]);
MRT_GUIFrame_MakeAttendanceCheck_Button:SetText(MRT_L.GUI["Button_MakeGuildAttendanceCheck"]);
MRT_GUIFrame_EndCurrentRaid_Button:SetText(MRT_L.GUI["Button_EndCurrentRaid"]);
MRT_GUIFrame_ResumeLastRaid_Button:SetText(MRT_L.GUI["Button_ResumeLastRaid"]);
-- Create difficulty drop down menu
mrt:UI_CreateTwoRowDDM()
-- Insert table data
MRT_GUI_CompleteTableUpdate();
-- Create and anchor drop down menu table for add/modify loot dialog
MRT_GUI_PlayerDropDownTable = ScrollingTable:CreateST(MRT_PlayerDropDownTableColDef, 9, nil, nil, MRT_GUI_FourRowDialog);
MRT_GUI_PlayerDropDownTable.head:SetHeight(1);
MRT_GUI_PlayerDropDownTable.frame:SetFrameLevel(3);
MRT_GUI_PlayerDropDownTable.frame:Hide();
MRT_GUI_PlayerDropDownTable:EnableSelection(false);
MRT_GUI_PlayerDropDownTable:RegisterEvents({
["OnClick"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
if (not realrow) then return true; end
local playerName = MRT_GUI_PlayerDropDownTable:GetCell(realrow, column);
if (playerName) then
MRT_GUI_FourRowDialog_EB2:SetText(playerName);
MRT_GUI_PlayerDropDownList_Toggle();
end
return true;
end
});
end
function mrt:UI_CreateTwoRowDDM()
-- Create DropDownFrame
if (not MRT_GUI_TwoRowDialog_DDM) then
CreateFrame("Frame", "MRT_GUI_TwoRowDialog_DDM", MRT_GUI_TwoRowDialog, "MRT_Lib_UIDropDownMenuTemplate")
MRT_GUI_TwoRowDialog_DDM:CreateFontString("MRT_GUI_TwoRowDialog_DDM_Text", "OVERLAY", "ChatFontNormal")
end
-- List of DropDownMenuItems
local items = {}
if mrt.isClassic then
items = {
{ [16] = RAID_DIFFICULTY_40PLAYER },
{ [4] = RAID_DIFFICULTY_20PLAYER },
{ [3] = RAID_DIFFICULTY_10PLAYER }
}
elseif mrt.isBCC then
items = {
{ [4] = RAID_DIFFICULTY_25PLAYER }, -- 25 Player
{ [3] = RAID_DIFFICULTY_10PLAYER }, -- 10 Player
{ [9] = RAID_DIFFICULTY_40PLAYER }, -- 40 Player
{ [148] = RAID_DIFFICULTY_20PLAYER }, -- 20 Player
}
elseif mrt.isWrath then
items = {
{ [6] = RAID_DIFFICULTY_25PLAYER_HEROIC },
{ [5] = RAID_DIFFICULTY_10PLAYER_HEROIC },
{ [4] = RAID_DIFFICULTY_25PLAYER },
{ [3] = RAID_DIFFICULTY_10PLAYER },
}
else
items = {
{ [16] = select(1, GetDifficultyInfo(16)).." (20)" },
{ [15] = select(1, GetDifficultyInfo(15)).." (30)" },
{ [14] = select(1, GetDifficultyInfo(14)).." (30)" },
{ [17] = select(1, GetDifficultyInfo(17)).." (30)" },
{ [9] = select(1, GetDifficultyInfo(9)) }, -- 40 Player
{ [4] = select(1, GetDifficultyInfo(4)) }, -- 25 Player
{ [3] = select(1, GetDifficultyInfo(3)) }, -- 10 Player
}
end
-- Anchor DropDownFrame
MRT_GUI_TwoRowDialog_DDM:ClearAllPoints();
MRT_GUI_TwoRowDialog_DDM:SetPoint("TOP", MRT_GUI_TwoRowDialog_EB1, "TOP", -4, -64);
MRT_GUI_TwoRowDialog_DDM_Text:ClearAllPoints();
MRT_GUI_TwoRowDialog_DDM_Text:SetPoint("BOTTOMLEFT", MRT_GUI_TwoRowDialog_DDM, "TOPLEFT", 14, 0);
MRT_GUI_TwoRowDialog_DDM:Show();
-- Click handler function
local function OnClick(self)
MRT_Lib_UIDropDownMenu_SetSelectedID(MRT_GUI_TwoRowDialog_DDM, self:GetID())
end
-- DropDownMenu initialize function
local function initialize(self, level)
local info = MRT_Lib_UIDropDownMenu_CreateInfo()
for k2, v2 in ipairs(items) do
for k, v in pairs(v2) do
info = MRT_Lib_UIDropDownMenu_CreateInfo()
info.text = v
info.value = k
info.func = OnClick
MRT_Lib_UIDropDownMenu_AddButton(info, level)
end
end
end
-- Setup DropDownMenu
MRT_Lib_UIDropDownMenu_Initialize(MRT_GUI_TwoRowDialog_DDM, initialize);
MRT_Lib_UIDropDownMenu_SetWidth(MRT_GUI_TwoRowDialog_DDM, 236);
MRT_Lib_UIDropDownMenu_SetButtonWidth(MRT_GUI_TwoRowDialog_DDM, 260);
MRT_Lib_UIDropDownMenu_SetSelectedID(MRT_GUI_TwoRowDialog_DDM, 3);
MRT_Lib_UIDropDownMenu_JustifyText(MRT_GUI_TwoRowDialog_DDM, "LEFT");
-- Setup text
MRT_GUI_TwoRowDialog_DDM_Text:SetText(MRT_L.GUI["Raid size"])
-- Hide element
MRT_GUI_TwoRowDialog_DDM:Hide();
end
---------------------
-- Show/Hide GUI --
---------------------
function MRT_GUI_Toggle()
if (not MRT_GUIFrame:IsShown()) then
MRT_GUIFrame:Show();
MRT_GUIFrame:SetScript("OnUpdate", function() MRT_GUI_OnUpdateHandler(); end);
if (lastShownNumOfRaids ~= #MRT_RaidLog) then
MRT_GUI_CompleteTableUpdate();
elseif (lastSelectedRaidNum and lastShownNumOfBosses ~= #MRT_RaidLog[lastSelectedRaidNum]["Bosskills"]) then
MRT_GUI_RaidDetailsTableUpdate(lastSelectedRaidNum);
else
MRT_GUI_RaidAttendeesTableUpdate(lastSelectedRaidNum);
MRT_GUI_BossDetailsTableUpdate(lastSelectedBossNum);
end
else
MRT_GUIFrame:Hide();
MRT_GUIFrame:SetScript("OnUpdate", nil);
end
end
----------------------
-- Button handler --
----------------------
function MRT_GUI_RaidExportComplete()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
MRT_CreateRaidExport(raidnum, nil, nil);
end
function MRT_GUI_RaidExportNormal()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
MRT_CreateRaidExport(raidnum, nil, "N");
end
function MRT_GUI_RaidExportHard()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
MRT_CreateRaidExport(raidnum, nil, "H");
end
function MRT_GUI_RaidDelete()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
if (raidnum == MRT_NumOfCurrentRaid) then
MRT_Print(MRT_L.GUI["Can not delete current raid"]);
return;
end
StaticPopupDialogs.MRT_GUI_ZeroRowDialog.text = string.format(MRT_L.GUI["Confirm raid entry deletion"], raidnum);
StaticPopupDialogs.MRT_GUI_ZeroRowDialog.OnAccept = function() MRT_GUI_RaidDeleteAccept(raidnum); end
StaticPopup_Show("MRT_GUI_ZeroRowDialog");
end
function MRT_GUI_RaidDeleteAccept(raidnum)
table.remove(MRT_RaidLog, raidnum);
-- Modify MRT_NumOfCurrentRaid if there is an active raid
if (MRT_NumOfCurrentRaid ~= nil) then
MRT_NumOfCurrentRaid = #MRT_RaidLog;
end
-- Do a table update
MRT_GUI_CompleteTableUpdate();
end
function MRT_GUI_BossAdd()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
local raidDiff;
if (not mrt.isClassic) then
raidDiff = GetRaidDifficultyID();
else
raidDiff = 16;
end
MRT_GUI_ThreeRowDialog_Title:SetText(MRT_L.GUI["Add bosskill"]);
MRT_GUI_ThreeRowDialog_EB1_Text:SetText(MRT_L.GUI["Bossname"]);
MRT_GUI_ThreeRowDialog_EB1:SetText("");
MRT_GUI_ThreeRowDialog_EB2_Text:SetText(MRT_L.GUI["Difficulty N or H"]);
if (raidDiff < 3) then
MRT_GUI_ThreeRowDialog_EB2:SetText("N");
else
MRT_GUI_ThreeRowDialog_EB2:SetText("H");
end
MRT_GUI_ThreeRowDialog_EB3_Text:SetText(MRT_L.GUI["Time"]);
MRT_GUI_ThreeRowDialog_EB3:SetText("");
MRT_GUI_ThreeRowDialog_EB3:SetScript("OnEnter", function() MRT_GUI_SetTT(MRT_GUI_ThreeRowDialog_EB3, "Boss_Add_TimeEB"); end);
MRT_GUI_ThreeRowDialog_EB3:SetScript("OnLeave", function() MRT_GUI_HideTT(); end);
MRT_GUI_ThreeRowDialog_OKButton:SetText(MRT_L.GUI["Button_Add"]);
MRT_GUI_ThreeRowDialog_OKButton:SetScript("OnClick", function() MRT_GUI_BossAddAccept(raidnum); end);
MRT_GUI_ThreeRowDialog_CancelButton:SetText(MRT_L.Core["MB_Cancel"]);
MRT_GUI_ThreeRowDialog:Show();
end
function MRT_GUI_BossAddAccept(raidnum)
-- sanity check inputs - if error, print error message (bossname is free text, Time has to match HH:MM)
local bossname = MRT_GUI_ThreeRowDialog_EB1:GetText();
local difficulty = MRT_GUI_ThreeRowDialog_EB2:GetText();
local enteredTime = MRT_GUI_ThreeRowDialog_EB3:GetText();
local hours = nil;
local minutes = nil;
local bossTimestamp = nil;
if (bossname == "") then
MRT_Print(MRT_L.GUI["No boss name entered"]);
return;
end
if (enteredTime == "") then
-- check if there is an active raid
if (MRT_NumOfCurrentRaid == nil) then
MRT_Print(MRT_L.GUI["No active raid in progress. Please enter time."]);
return;
end
hours = 255;
minutes = 255;
else
hours, minutes = deformat(enteredTime, "%d:%d");
if (hours == nil or minutes == nil or hours > 23 or hours < 0 or minutes > 59 or minutes < 0) then
MRT_Print(MRT_L.GUI["No valid time entered"]);
return;
end
-- check timeline of chosen raid
local raidStart = MRT_RaidLog[raidnum]["StartTime"];
local raidStartDateTable = date("*t", raidStart);
raidStartDateTable.hour = hours;
raidStartDateTable.min = minutes;
bossTimestamp = time(raidStartDateTable);
-- if bossTimestamp < raidStart, try raidStart + 24 hours (one day - time around 01:25 is next day)
if (bossTimestamp < raidStart) then
bossTimestamp = bossTimestamp + 86400;
end
local raidStop = MRT_RaidLog[raidnum]["StopTime"];
if (MRT_RaidLog[raidnum]["StopTime"] == nil) then
if (bossTimestamp < raidStart or bossTimestamp > time()) then
MRT_Print(MRT_L.GUI["Entered time is not between start and end of raid"]);
return;
end
else
if (bossTimestamp < raidStart or bossTimestamp > raidStop) then
MRT_Print(MRT_L.GUI["Entered time is not between start and end of raid"]);
return;
end
end
end
MRT_GUI_HideDialogs();
local insertPos = nil;
-- add boss to kill list
-- if boss shall be added as last recent boss kill, just call 'AddBosskill' - else do it manually
if (hours == 255 and minutes == 255) then
if (difficulty == "H") then
MRT_AddBosskill(bossname, "H");
else
MRT_AddBosskill(bossname, "N");
end;
else
-- prepare bossdata table
local bossdata = {};
bossdata["Players"] = {};
bossdata["Name"] = bossname;
bossdata["Date"] = bossTimestamp;
bossdata["Difficulty"] = MRT_RaidLog[raidnum]["DiffID"];
if (difficulty == "H" and (bossdata["Difficulty"] == 3 or bossdata["Difficulty"] == 4)) then
bossdata["Difficulty"] = bossdata["Difficulty"] + 2;
end
-- search position in RaidLog (based on time) and insert data
if (#MRT_RaidLog[raidnum]["Bosskills"] > 0) then
insertPos = 1;
for i, val in ipairs(MRT_RaidLog[raidnum]["Bosskills"]) do
if (bossTimestamp > val["Date"]) then
insertPos = i + 1;
end
end
tinsert(MRT_RaidLog[raidnum]["Bosskills"], insertPos, bossdata);
-- update data of associated loot
for i, val in ipairs(MRT_RaidLog[raidnum]["Loot"]) do
if (insertPos <= val["BossNumber"]) then
val["BossNumber"] = val["BossNumber"] + 1;
end
end
else
tinsert(MRT_RaidLog[raidnum]["Bosskills"], bossdata);
insertPos = 1;
end
-- if current raid was modified, change raid parameters accordingly
if (MRT_NumOfCurrentRaid and raidnum == MRT_NumOfCurrentRaid) then
MRT_NumOfLastBoss = #MRT_RaidLog[raidnum]["Bosskills"];
end
-- save raid attendees as boss attendees for the new boss
for key, val in pairs(MRT_RaidLog[raidnum]["Players"]) do
if (val["Join"] < bossTimestamp and (val["Leave"] == nil or val["Leave"] > bossTimestamp)) then
tinsert(MRT_RaidLog[raidnum]["Bosskills"][insertPos]["Players"], val["Name"]);
end
end
end
-- Do a table update, if the displayed raid was modified
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then return; end
local raidnum_selected = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
if (raidnum_selected == raidnum) then
MRT_GUI_RaidDetailsTableUpdate(raidnum);
end
end
function MRT_GUI_BossDelete()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local boss_select = MRT_GUI_RaidBosskillsTable:GetSelection();
if (boss_select == nil) then
MRT_Print(MRT_L.GUI["No boss selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
local bossnum = MRT_GUI_RaidBosskillsTable:GetCell(boss_select, 1);
local bossname = MRT_GUI_RaidBosskillsTable:GetCell(boss_select, 3);
StaticPopupDialogs.MRT_GUI_ZeroRowDialog.text = string.format(MRT_L.GUI["Confirm boss entry deletion"], bossnum, bossname);
StaticPopupDialogs.MRT_GUI_ZeroRowDialog.OnAccept = function() MRT_GUI_BossDeleteAccept(raidnum, bossnum); end
StaticPopup_Show("MRT_GUI_ZeroRowDialog");
end
function MRT_GUI_BossDeleteAccept(raidnum, bossnum)
table.remove(MRT_RaidLog[raidnum]["Bosskills"], bossnum);
-- Modify MRT_NumOfLastBoss if active raid was modified
if (MRT_NumOfCurrentRaid == raidnum) then
MRT_NumOfLastBoss = #MRT_RaidLog[raidnum]["Bosskills"];
end
-- update data of associated loot
local lootDeleteList = {}
for i, val in ipairs(MRT_RaidLog[raidnum]["Loot"]) do
if (bossnum == val["BossNumber"]) then
tinsert(lootDeleteList, i);
end
if (bossnum < val["BossNumber"]) then
val["BossNumber"] = val["BossNumber"] - 1;
end
end
-- sort table - descending order
table.sort(lootDeleteList, function(val1, val2) return (val1 > val2); end);
-- delete loot associated with deleted boss
for i, num in ipairs(lootDeleteList) do
tremove(MRT_RaidLog[raidnum]["Loot"], num);
end
-- Do a table update, if the displayed raid was modified
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then return; end
local raidnum_selected = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
if (raidnum_selected == raidnum) then
MRT_GUI_RaidDetailsTableUpdate(raidnum);
end
end
function MRT_GUI_BossExport()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local boss_select = MRT_GUI_RaidBosskillsTable:GetSelection();
if (boss_select == nil) then
MRT_Print(MRT_L.GUI["No boss selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
local bossnum = MRT_GUI_RaidBosskillsTable:GetCell(boss_select, 1);
MRT_CreateRaidExport(raidnum, bossnum, nil);
end
function MRT_GUI_BossRename()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local boss_select = MRT_GUI_RaidBosskillsTable:GetSelection();
if (boss_select == nil) then
MRT_Print(MRT_L.GUI["No boss selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
local bossnum = MRT_GUI_RaidBosskillsTable:GetCell(boss_select, 1);
local bossname = MRT_GUI_RaidBosskillsTable:GetCell(boss_select, 3);
MRT_GUI_OneRowDialog_Title:SetText(MRT_L.GUI["Rename boss"]);
MRT_GUI_OneRowDialog_EB1_Text:SetText(MRT_L.GUI["Col_Name"]);
MRT_GUI_OneRowDialog_EB1:SetText(bossname);
MRT_GUI_OneRowDialog_OKButton:SetText(MRT_L.GUI["Button_Rename"]);
MRT_GUI_OneRowDialog_OKButton:SetScript("OnClick", function() MRT_GUI_BossRenameAccept(raidnum, bossnum); end);
MRT_GUI_OneRowDialog_CancelButton:SetText(MRT_L.Core["MB_Cancel"]);
MRT_GUI_OneRowDialog:Show();
end
function MRT_GUI_BossRenameAccept(raidnum, bossnum)
MRT_GUI_HideDialogs();
local bossname = MRT_GUI_OneRowDialog_EB1:GetText();
if (bossname == "") then
MRT_Print(MRT_L.GUI["No boss name entered"]);
return;
end
MRT_RaidLog[raidnum]["Bosskills"][bossnum]["Name"] = bossname;
-- Do a table update, if the displayed raid was modified
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then return; end
local raidnum_selected = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
if (raidnum_selected == raidnum) then
MRT_GUI_RaidDetailsTableUpdate(raidnum);
end
end
function MRT_GUI_RaidAttendeeAdd()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
MRT_GUI_ThreeRowDialog_Title:SetText(MRT_L.GUI["Add raid attendee"]);
MRT_GUI_ThreeRowDialog_EB1_Text:SetText(MRT_L.GUI["Col_Name"]);
MRT_GUI_ThreeRowDialog_EB1:SetText("");
MRT_GUI_ThreeRowDialog_EB2_Text:SetText(MRT_L.GUI["Col_Join"]);
MRT_GUI_ThreeRowDialog_EB2:SetText("");
MRT_GUI_ThreeRowDialog_EB2:SetScript("OnEnter", function() MRT_GUI_SetTT(MRT_GUI_ThreeRowDialog_EB2, "Attendee_Add_JoinEB"); end);
MRT_GUI_ThreeRowDialog_EB2:SetScript("OnLeave", function() MRT_GUI_HideTT(); end);
MRT_GUI_ThreeRowDialog_EB3_Text:SetText(MRT_L.GUI["Col_Leave"]);
MRT_GUI_ThreeRowDialog_EB3:SetText("");
MRT_GUI_ThreeRowDialog_EB3:SetScript("OnEnter", function() MRT_GUI_SetTT(MRT_GUI_ThreeRowDialog_EB3, "Attendee_Add_LeaveEB"); end);
MRT_GUI_ThreeRowDialog_EB3:SetScript("OnLeave", function() MRT_GUI_HideTT(); end);
MRT_GUI_ThreeRowDialog_OKButton:SetText(MRT_L.GUI["Button_Add"]);
MRT_GUI_ThreeRowDialog_OKButton:SetScript("OnClick", function() MRT_GUI_RaidAttendeeAddAccept(raidnum); end);
MRT_GUI_ThreeRowDialog_CancelButton:SetText(MRT_L.Core["MB_Cancel"]);
MRT_GUI_ThreeRowDialog:Show();
end
function MRT_GUI_RaidAttendeeAddAccept(raidnum)
-- sanity check inputs - if error, print error message (bossname is free text, time has to match HH:MM)
local currentTime = MRT_GetCurrentTime();
local playerName = MRT_GUI_ThreeRowDialog_EB1:GetText();
local joinTime = MRT_GUI_ThreeRowDialog_EB2:GetText();
local leaveTime = MRT_GUI_ThreeRowDialog_EB3:GetText();
local joinTimestamp, leaveTimestamp;
local raidStart = MRT_RaidLog[raidnum]["StartTime"];
local raidStop;
if (raidnum == MRT_NumOfCurrentRaid) then
raidStop = currentTime;
else
raidStop = MRT_RaidLog[raidnum]["StopTime"];
end
-- check name
if (playerName == "") then
MRT_Print(MRT_L.GUI["No name entered"]);
return;
end
-- check format of join time and create join timestamp
if (joinTime == "") then
joinTimestamp = MRT_RaidLog[raidnum]["StartTime"] + 1;
else
local joinHours, joinMinutes = deformat(joinTime, "%d:%d");
if (joinHours == nil or joinMinutes == nil or joinHours > 23 or joinHours < 0 or joinMinutes > 59 or joinMinutes < 0) then
MRT_Print(MRT_L.GUI["No valid time entered"]);
return;
end
-- check timeline of chosen raid
local raidStartDateTable = date("*t", raidStart);
raidStartDateTable.hour = joinHours;
raidStartDateTable.min = joinMinutes;
joinTimestamp = time(raidStartDateTable);
-- if joinTimestamp < raidStart, try raidStart + 24 hours (one day - time around 01:25 is next day)
if (joinTimestamp < raidStart) then
joinTimestamp = joinTimestamp + 86400;
end
end
-- check format of leave time and create leave timestamp
if (leaveTime == "") then
if (raidnum == MRT_NumOfCurrentRaid) then
leaveTimestamp = currentTime - 1;
else
leaveTimestamp = MRT_RaidLog[raidnum]["StopTime"] - 1;
end
else
local leaveHours, leaveMinutes = deformat(leaveTime, "%d:%d");
if (leaveHours == nil or leaveMinutes == nil or leaveHours > 23 or leaveHours < 0 or leaveMinutes > 59 or leaveMinutes < 0) then
MRT_Print(MRT_L.GUI["No valid time entered"]);
return;
end
-- check timeline of chosen raid
local raidStartDateTable = date("*t", raidStart);
raidStartDateTable.hour = leaveHours;
raidStartDateTable.min = leaveMinutes;
leaveTimestamp = time(raidStartDateTable);
-- if leaveTimestamp < raidStart, try raidStart + 24 hours (one day - time around 01:25 is next day)
if (leaveTimestamp < raidStart) then
leaveTimestamp = leaveTimestamp + 86400;
end
end
-- check if timestamps make sense
if not (raidStart < joinTimestamp and joinTimestamp < raidStop and raidStart < leaveTimestamp and leaveTimestamp < raidStop) then
MRT_Print(MRT_L.GUI["Entered time is not between start and end of raid"]);
return;
end
if (joinTimestamp > leaveTimestamp) then
MRT_Print(MRT_L.GUI["Entered join time is not before leave time"]);
MRT_Debug(tostring(joinTimestamp).." > "..tostring(leaveTimestamp));
return;
end
MRT_GUI_HideDialogs();
-- if we reach this point, we should have a valid raidnum, playername, join timestamp and leave timestamp - now add them to the raid attendee list...
local playerInfo = {
["Name"] = playerName,
["Join"] = joinTimestamp,
["Leave"] = leaveTimestamp,
};
tinsert(MRT_RaidLog[raidnum]["Players"], playerInfo);
-- ... and as boss attendee to the relevant bosses
for i, val in ipairs(MRT_RaidLog[raidnum]["Bosskills"]) do
if (joinTimestamp < val["Date"] and val["Date"] < leaveTimestamp) then
local playerList = {};
for j, val2 in ipairs(val["Players"]) do
playerList[val2] = true;
end
if (not playerList[playerName]) then
tinsert(val["Players"], playerName);
end
end
end
-- Do a table update, if the displayed raid was modified
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then return; end
local raidnum_selected = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
if (raidnum_selected == raidnum) then
MRT_GUI_RaidAttendeesTableUpdate(raidnum);
else
return;
end
local boss_select = MRT_GUI_RaidBosskillsTable:GetSelection();
if (boss_select == nil) then return; end
local bossnum = MRT_GUI_RaidBosskillsTable:GetCell(boss_select, 1);
MRT_GUI_BossAttendeesTableUpdate(bossnum);
end
function MRT_GUI_RaidAttendeeDelete()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local attendee_select = MRT_GUI_RaidAttendeesTable:GetSelection();
if (attendee_select == nil) then
MRT_Print(MRT_L.GUI["No raid attendee selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
local attendee = MRT_GUI_RaidAttendeesTable:GetCell(attendee_select, 1);
local attendeeName = MRT_GUI_RaidAttendeesTable:GetCell(attendee_select, 2);
StaticPopupDialogs.MRT_GUI_ZeroRowDialog.text = string.format(MRT_L.GUI["Confirm raid attendee entry deletion"], attendeeName);
StaticPopupDialogs.MRT_GUI_ZeroRowDialog.OnAccept = function() MRT_GUI_RaidAttendeeDeleteAccept(raidnum, attendee); end
StaticPopup_Show("MRT_GUI_ZeroRowDialog");
end
function MRT_GUI_RaidAttendeeDeleteAccept(raidnum, attendee)
local playerInfo = MRT_RaidLog[raidnum]["Players"][attendee];
if (not playerInfo["Leave"]) then
playerInfo["Leave"] = MRT_GetCurrentTime();
end
-- Delete player from the boss attendees lists...
for i, val in ipairs(MRT_RaidLog[raidnum]["Bosskills"]) do
if (playerInfo["Join"] < val["Date"] and val["Date"] < playerInfo["Leave"]) then
local playerPos;
for j, val2 in ipairs(val["Players"]) do
if (val2 == playerInfo["Name"]) then
playerPos = j;
end
end
if (playerPos) then
tremove(val["Players"], playerPos);
end
end
end
-- ...and raid attendees list
MRT_RaidLog[raidnum]["Players"][attendee] = nil;
-- Do a table update, if the displayed raid was modified
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then return; end
local raidnum_selected = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
if (raidnum_selected == raidnum) then
MRT_GUI_RaidAttendeesTableUpdate(raidnum);
else
return;
end
local boss_select = MRT_GUI_RaidBosskillsTable:GetSelection();
if (boss_select == nil) then return; end
local bossnum = MRT_GUI_RaidBosskillsTable:GetCell(boss_select, 1);
MRT_GUI_BossAttendeesTableUpdate(bossnum);
end
function MRT_GUI_LootAdd()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local boss_select = MRT_GUI_RaidBosskillsTable:GetSelection();
if (boss_select == nil) then
MRT_Print(MRT_L.GUI["No boss selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
local bossnum = MRT_GUI_RaidBosskillsTable:GetCell(boss_select, 1);
-- gather playerdata and fill drop down menu
local playerData = {};
for i, val in ipairs(MRT_RaidLog[raidnum]["Bosskills"][bossnum]["Players"]) do
playerData[i] = { val };
end
table.sort(playerData, function(a, b) return (a[1] < b[1]); end );
tinsert(playerData, 1, { "disenchanted" } );
tinsert(playerData, 1, { "bank" } );
MRT_GUI_PlayerDropDownTable:SetData(playerData, true);
if (#playerData < 9) then
MRT_GUI_PlayerDropDownTable:SetDisplayRows(#playerData, 15);
else
MRT_GUI_PlayerDropDownTable:SetDisplayRows(9, 15);
end
MRT_GUI_PlayerDropDownTable.frame:Hide();
-- prepare dialog
MRT_GUI_FourRowDialog_Title:SetText(MRT_L.GUI["Add loot data"]);
MRT_GUI_FourRowDialog_EB1_Text:SetText(MRT_L.GUI["Itemlink"]);
MRT_GUI_FourRowDialog_EB1:SetText("");
MRT_GUI_FourRowDialog_EB2_Text:SetText(MRT_L.GUI["Looter"]);
MRT_GUI_FourRowDialog_EB2:SetText("");
MRT_GUI_FourRowDialog_EB3_Text:SetText(MRT_L.GUI["Value"]);
MRT_GUI_FourRowDialog_EB3:SetText("");
MRT_GUI_FourRowDialog_EB4_Text:SetText(MRT_L.GUI["Note"]);
MRT_GUI_FourRowDialog_EB4:SetText("");
MRT_GUI_FourRowDialog_OKButton:SetText(MRT_L.GUI["Button_Add"]);
MRT_GUI_FourRowDialog_OKButton:SetScript("OnClick", function() MRT_GUI_LootModifyAccept(raidnum, bossnum, nil); end);
MRT_GUI_FourRowDialog_CancelButton:SetText(MRT_L.Core["MB_Cancel"]);
MRT_GUI_FourRowDialog:Show();
end
function MRT_GUI_LootModify()
MRT_GUI_HideDialogs();
local raid_select = MRT_GUI_RaidLogTable:GetSelection();
if (raid_select == nil) then
MRT_Print(MRT_L.GUI["No raid selected"]);
return;
end
local loot_select = MRT_GUI_BossLootTable:GetSelection();
if (loot_select == nil) then
MRT_Print(MRT_L.GUI["No loot selected"]);
return;
end
local raidnum = MRT_GUI_RaidLogTable:GetCell(raid_select, 1);
local lootnum = MRT_GUI_BossLootTable:GetCell(loot_select, 1);
local bossnum = MRT_RaidLog[raidnum]["Loot"][lootnum]["BossNumber"];
local lootnote = MRT_RaidLog[raidnum]["Loot"][lootnum]["Note"];
-- Force item into cache:
GetItemInfo(MRT_RaidLog[raidnum]["Loot"][lootnum]["ItemLink"]);
-- gather playerdata and fill drop down menu
local playerData = {};
for i, val in ipairs(MRT_RaidLog[raidnum]["Bosskills"][bossnum]["Players"]) do
playerData[i] = { val };
end
table.sort(playerData, function(a, b) return (a[1] < b[1]); end );
tinsert(playerData, 1, { "disenchanted" } );
tinsert(playerData, 1, { "bank" } );
MRT_GUI_PlayerDropDownTable:SetData(playerData, true);
if (#playerData < 9) then
MRT_GUI_PlayerDropDownTable:SetDisplayRows(#playerData, 15);
else
MRT_GUI_PlayerDropDownTable:SetDisplayRows(9, 15);
end
MRT_GUI_PlayerDropDownTable.frame:Hide();
-- prepare dialog
MRT_GUI_FourRowDialog_Title:SetText(MRT_L.GUI["Modify loot data"]);
MRT_GUI_FourRowDialog_EB1_Text:SetText(MRT_L.GUI["Itemlink"]);
MRT_GUI_FourRowDialog_EB1:SetText(MRT_RaidLog[raidnum]["Loot"][lootnum]["ItemLink"]);
MRT_GUI_FourRowDialog_EB2_Text:SetText(MRT_L.GUI["Looter"]);
MRT_GUI_FourRowDialog_EB2:SetText(MRT_GUI_BossLootTable:GetCell(loot_select, 4));
MRT_GUI_FourRowDialog_EB3_Text:SetText(MRT_L.GUI["Value"]);
MRT_GUI_FourRowDialog_EB3:SetText(MRT_GUI_BossLootTable:GetCell(loot_select, 5));
MRT_GUI_FourRowDialog_EB4_Text:SetText(MRT_L.GUI["Note"]);
if (lootnote == nil or lootnote == "" or lootnote == " ") then
MRT_GUI_FourRowDialog_EB4:SetText("");
else
MRT_GUI_FourRowDialog_EB4:SetText(lootnote);
end
MRT_GUI_FourRowDialog_OKButton:SetText(MRT_L.GUI["Button_Modify"]);
MRT_GUI_FourRowDialog_OKButton:SetScript("OnClick", function() MRT_GUI_LootModifyAccept(raidnum, bossnum, lootnum); end);
MRT_GUI_FourRowDialog_CancelButton:SetText(MRT_L.Core["MB_Cancel"]);
MRT_GUI_FourRowDialog:Show();
end
function MRT_GUI_PlayerDropDownList_Toggle()
if (MRT_GUI_PlayerDropDownTable.frame:IsShown()) then
MRT_GUI_PlayerDropDownTable.frame:Hide();
else
MRT_GUI_PlayerDropDownTable.frame:Show();
MRT_GUI_PlayerDropDownTable.frame:SetPoint("TOPRIGHT", MRT_GUI_FourRowDialog_DropDownButton, "BOTTOMRIGHT", 0, 0);
end
end
function MRT_GUI_LootModifyAccept(raidnum, bossnum, lootnum)
local itemLink = MRT_GUI_FourRowDialog_EB1:GetText();
local looter = MRT_GUI_FourRowDialog_EB2:GetText();
local cost = MRT_GUI_FourRowDialog_EB3:GetText();
local lootNote = MRT_GUI_FourRowDialog_EB4:GetText();
if (cost == "") then cost = 0; end
cost = tonumber(cost);
if (lootNote == nil or lootNote == "" or lootNote == " ") then lootNote = nil; end
-- sanity-check values here - especially the itemlink / looter is free text / cost has to be a number
local itemName, itemLink, itemId, itemString, itemRarity, itemColor, _, _, _, _, _, _, _, _ = MRT_GetDetailedItemInformation(itemLink);
if (not itemName) then
MRT_Print(MRT_L.GUI["No itemLink found"]);
return;
end
if (not cost) then
MRT_Print(MRT_L.GUI["Item cost invalid"]);
return;
end
MRT_GUI_HideDialogs();
-- insert new values here / if (lootnum == nil) then treat as a newly added item
if (looter == "") then looter = "disenchanted"; end
local MRT_LootInfo = {
["ItemLink"] = itemLink,
["ItemString"] = itemString,
["ItemId"] = itemId,
["ItemName"] = itemName,
["ItemColor"] = itemColor,
["BossNumber"] = bossnum,