-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmenu.lua
More file actions
executable file
·2202 lines (2002 loc) · 75.7 KB
/
menu.lua
File metadata and controls
executable file
·2202 lines (2002 loc) · 75.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
--[[
Copyright 2026 Yazpad & Deathwing
The Deathlog AddOn is distributed under the terms of the GNU General Public License (or the Lesser GPL).
This file is part of Hardcore.
The Deathlog AddOn 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.
The Deathlog AddOn 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 the Deathlog AddOn. If not, see <http://www.gnu.org/licenses/>.
--]]
--
local id_to_npc = DeathNotificationLib.ID_TO_NPC
local instance_to_id = DeathNotificationLib.INSTANCE_TO_ID
local id_to_instance = DeathNotificationLib.ID_TO_INSTANCE
local zone_to_id = DeathNotificationLib.ZONE_TO_ID
local deathlog_environment_damage = DeathNotificationLib.ENVIRONMENT_DAMAGE
local instance_categories = DeathNotificationLib.INSTANCE_CATEGORIES
local zone_categories = DeathNotificationLib.ZONE_CATEGORIES
local deathlog_class_colors = DeathNotificationLib.CLASS_ID_TO_COLOR
local _menu_width = 1100
local _inner_menu_width = 800
local _menu_height = 600
local current_map_id = nil
local max_rows = 25
local page_number = 1
local total_pages = 1
local main_font = Deathlog_L.main_font
local deathlog_tabcontainer = nil
local deathlog_cta_banner = nil
local class_tbl = deathlog_class_tbl
local race_tbl = deathlog_race_tbl
-- Cached sorted results for pagination (avoids re-filtering/re-sorting on page changes)
local cached_sorted_results = nil
local cached_filter_version = 0 -- Incremented when filters change
local deathlog_menu = nil
local WorldMapButton = WorldMapFrame:GetCanvas()
local death_tomb_frame = CreateFrame("frame", nil, WorldMapButton)
death_tomb_frame:SetAllPoints()
death_tomb_frame:SetFrameLevel(15000)
local death_tomb_frame_tex = death_tomb_frame:CreateTexture(nil, "OVERLAY")
death_tomb_frame_tex:SetTexture("Interface\\TARGETINGFRAME\\UI-TargetingFrame-Skull")
death_tomb_frame_tex:SetDrawLayer("OVERLAY", 4)
death_tomb_frame_tex:SetHeight(25)
death_tomb_frame_tex:SetWidth(25)
death_tomb_frame_tex:Hide()
local death_tomb_frame_tex_glow = death_tomb_frame:CreateTexture(nil, "OVERLAY")
death_tomb_frame_tex_glow:SetTexture("Interface\\Glues/Models/UI_HUMAN/GenericGlow64")
death_tomb_frame_tex_glow:SetDrawLayer("OVERLAY", 3)
death_tomb_frame_tex_glow:SetHeight(55)
death_tomb_frame_tex_glow:SetWidth(55)
death_tomb_frame_tex_glow:Hide()
local function WPDropDownDemo_Menu(frame, level, menuList)
local info = UIDropDownMenu_CreateInfo()
local function canOpenWorldMap()
if not (death_tomb_frame.map_id and death_tomb_frame.coordinates) then
return false
end
if C_Map.GetMapInfo(death_tomb_frame["map_id"]) == nil then
return false
end
if tonumber(death_tomb_frame.coordinates[1]) == nil or tonumber(death_tomb_frame.coordinates[2]) == nil then
return false
end
return true
end
local function openWorldMap()
if not canOpenWorldMap() then
return
end
WorldMapFrame:SetShown(not WorldMapFrame:IsShown())
WorldMapFrame:SetMapID(death_tomb_frame.map_id)
WorldMapFrame:GetCanvas()
local mWidth, mHeight = WorldMapFrame:GetCanvas():GetSize()
death_tomb_frame_tex:SetPoint(
"CENTER",
WorldMapButton,
"TOPLEFT",
mWidth * death_tomb_frame.coordinates[1],
-mHeight * death_tomb_frame.coordinates[2]
)
death_tomb_frame_tex:Show()
death_tomb_frame_tex_glow:SetPoint(
"CENTER",
WorldMapButton,
"TOPLEFT",
mWidth * death_tomb_frame.coordinates[1],
-mHeight * death_tomb_frame.coordinates[2]
)
death_tomb_frame_tex_glow:Show()
death_tomb_frame:Show()
deathlog_menu:Hide()
end
local function canBlockUser()
if not death_tomb_frame.clicked_name then
return false
end
if C_FriendList.GetNumIgnores() >= 50 then
return false
end
return true
end
local function blockUser()
if canBlockUser() then
local added = C_FriendList.AddIgnore(death_tomb_frame.clicked_name)
end
end
local function canWhisperPlayer()
if not death_tomb_frame.clicked_name then
return false
end
return true
end
local function whisperPlayer()
if canWhisperPlayer() then
ChatFrame_OpenChat("/w " .. death_tomb_frame.clicked_name .. " ")
end
end
if level == 1 then
info.text, info.hasArrow, info.func, info.disabled = "Whisper player", false, whisperPlayer, not canWhisperPlayer()
UIDropDownMenu_AddButton(info)
info.text, info.hasArrow, info.func, info.disabled = "Show death location", false, openWorldMap, not canOpenWorldMap()
UIDropDownMenu_AddButton(info)
info.text, info.hasArrow, info.func, info.disabled = "Block user", false, blockUser, not canBlockUser()
UIDropDownMenu_AddButton(info)
end
end
hooksecurefunc(WorldMapFrame, "OnMapChanged", function()
death_tomb_frame:Hide()
end)
local subtitle_data = {
{
"Date",
105,
function(_entry, _server_name)
return date("%m/%d/%y, %H:%M", _entry["date"]) or ""
end,
},
{
"Lvl",
30,
function(_entry, _server_name)
return _entry["level"] or ""
end,
},
{
"Name",
90,
function(_entry, _server_name)
return _entry["name"] or ""
end,
},
{
"Class",
60,
function(_entry, _server_name)
if _entry["class_id"] == nil then
return ""
end
local class_id = _entry["class_id"]
local class_str, _, _ = GetClassInfo(class_id)
if class_id then
if deathlog_class_colors[class_id] then
return "|c"
.. deathlog_class_colors[class_id].colorStr
.. class_str
.. "|r"
end
end
return class_str or ""
end,
},
{
"Race",
60,
function(_entry, _server_name)
if _entry["race_id"] == nil then
return ""
end
local race_info = C_CreatureInfo.GetRaceInfo(_entry["race_id"])
if race_info then
return race_info.raceName or ""
end
return ""
end,
},
{
"Guild",
120,
function(_entry, _server_name)
return _entry["guild"] or ""
end,
},
{
"Zone/Instance",
100,
function(_entry, _server_name)
if _entry["map_id"] == nil then
if _entry["instance_id"] ~= nil then
return id_to_instance[_entry["instance_id"]] or _entry["instance_id"]
else
return "-----------"
end
end
local map_info = C_Map.GetMapInfo(_entry["map_id"])
if map_info then
return map_info.name
end
return "-----------"
end,
},
{
"Death Source",
140,
function(_entry, _server_name)
return deathlogGetCachedSource(_entry)
end,
},
{
"Playtime",
70,
function(_entry, _server_name)
return DeathNotificationLib.FormatPlaytime(_entry["played"]) or ""
end,
},
{
"Last Words",
200,
function(_entry, _server_name)
return _entry["last_words"] or ""
end,
},
}
local AceGUI = LibStub("AceGUI-3.0")
local font_container = CreateFrame("Frame")
font_container:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
font_container:SetSize(100, 100)
font_container:Show()
local row_entry = {}
local font_strings = {} -- idx/columns
local header_strings = {} -- columns
local row_backgrounds = {} --idx
local last_font_string = nil
for idx, v in ipairs(subtitle_data) do
header_strings[v[1]] = font_container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
if idx == 1 then
header_strings[v[1]]:SetPoint("LEFT", font_container, "LEFT", 0, 0)
else
header_strings[v[1]]:SetPoint("LEFT", last_font_string, "RIGHT", 0, 0)
end
last_font_string = header_strings[v[1]]
header_strings[v[1]]:SetJustifyH("LEFT")
header_strings[v[1]]:SetWordWrap(false)
if idx + 1 <= #subtitle_data then
header_strings[v[1]]:SetWidth(v[2])
end
header_strings[v[1]]:SetTextColor(0.7, 0.7, 0.7)
header_strings[v[1]]:SetFont(main_font, 12, "")
end
for i = 1, max_rows do
font_strings[i] = {}
local last_font_string = nil
for idx, v in ipairs(subtitle_data) do
font_strings[i][v[1]] = font_container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
if idx == 1 then
font_strings[i][v[1]]:SetPoint("LEFT", font_container, "LEFT", 0, 0)
else
font_strings[i][v[1]]:SetPoint("LEFT", last_font_string, "RIGHT", 0, 0)
end
last_font_string = font_strings[i][v[1]]
font_strings[i][v[1]]:SetJustifyH("LEFT")
font_strings[i][v[1]]:SetWordWrap(false)
if idx + 1 <= #subtitle_data then
font_strings[i][v[1]]:SetWidth(v[2])
end
font_strings[i][v[1]]:SetTextColor(1, 1, 1)
font_strings[i][v[1]]:SetFont(main_font, 10, "")
end
row_backgrounds[i] = font_container:CreateTexture(nil, "OVERLAY")
row_backgrounds[i]:SetDrawLayer("OVERLAY", 2)
row_backgrounds[i]:SetVertexColor(0.5, 0.5, 0.5, (i % 2) / 10)
row_backgrounds[i]:SetHeight(16)
row_backgrounds[i]:SetWidth(1600)
row_backgrounds[i]:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
end
local function clearDeathlogMenuLogData(skipPageReset)
if not skipPageReset then
page_number = 1
if font_container.page_str then
font_container.page_str:SetText("Page " .. page_number)
end
end
for i, v in ipairs(font_strings) do
for _, col in ipairs(subtitle_data) do
v[col[1]]:SetText("")
end
end
-- Hide pagination when clearing (will be shown again if data is available)
if not skipPageReset then
if font_container.page_str then font_container.page_str:Hide() end
if font_container.prev_button then font_container.prev_button:Hide() end
if font_container.next_button then font_container.next_button:Hide() end
end
end
-- Display a page from pre-sorted results (used for pagination)
local function displayPageFromCache()
if not cached_sorted_results then return end
local ordered = cached_sorted_results
for i = 1, max_rows do
local idx = (i + (page_number - 1) * max_rows)
if idx > #ordered then
break
end
for _, col in ipairs(subtitle_data) do
font_strings[i][col[1]]:SetText(col[3](ordered[idx], ""))
end
if ordered[idx] and ordered[idx].map_id then
font_strings[i].map_id = ordered[idx].map_id
end
if ordered[idx] and ordered[idx].map_pos then
local x, y = strsplit(",", ordered[idx].map_pos, 2)
font_strings[i].map_id_coords_x = x
font_strings[i].map_id_coords_y = y
end
end
-- Update pagination visibility
total_pages = math.max(1, math.ceil(#ordered / max_rows))
if font_container.page_str then
if #ordered == 0 or total_pages <= 1 then
font_container.page_str:Hide()
if font_container.prev_button then font_container.prev_button:Hide() end
if font_container.next_button then font_container.next_button:Hide() end
else
font_container.page_str:SetText("Page " .. page_number .. " / " .. total_pages)
font_container.page_str:Show()
if font_container.prev_button then
if page_number <= 1 then
font_container.prev_button:Hide()
else
font_container.prev_button:Show()
end
end
if font_container.next_button then
if page_number >= total_pages then
font_container.next_button:Hide()
else
font_container.next_button:Show()
end
end
end
end
end
local function setDeathlogMenuLogData(data)
-- Sort and cache the filtered results
local ordered = deathlogOrderByFast(data)
cached_sorted_results = ordered
cached_filter_version = cached_filter_version + 1
for i = 1, max_rows do
local idx = (i + (page_number - 1) * max_rows)
if idx > #ordered then
break
end
for _, col in ipairs(subtitle_data) do
font_strings[i][col[1]]:SetText(col[3](ordered[idx], ""))
end
if ordered[idx] and ordered[idx].map_id then
font_strings[i].map_id = ordered[idx].map_id
end
if ordered[idx] and ordered[idx].map_pos then
local x, y = strsplit(",", ordered[idx].map_pos, 2)
font_strings[i].map_id_coords_x = x
font_strings[i].map_id_coords_y = y
end
end
-- Update pagination visibility based on data
total_pages = math.max(1, math.ceil(#ordered / max_rows))
if font_container.page_str then
if #ordered == 0 or total_pages <= 1 then
-- Hide pagination entirely if no data or only one page
font_container.page_str:Hide()
if font_container.prev_button then font_container.prev_button:Hide() end
if font_container.next_button then font_container.next_button:Hide() end
else
font_container.page_str:SetText("Page " .. page_number .. " / " .. total_pages)
font_container.page_str:Show()
-- Show/hide prev button based on current page
if font_container.prev_button then
if page_number <= 1 then
font_container.prev_button:Hide()
else
font_container.prev_button:Show()
end
end
-- Show/hide next button based on current page
if font_container.next_button then
if page_number >= total_pages then
font_container.next_button:Hide()
else
font_container.next_button:Show()
end
end
end
end
if #ordered == 1 then
local total_str = (precomputed_general_stats and precomputed_general_stats["all"] and precomputed_general_stats["all"]["all"] and precomputed_general_stats["all"]["all"]["all"] and precomputed_general_stats["all"]["all"]["all"]["all"] and precomputed_general_stats["all"]["all"]["all"]["all"]["num_entries"]) or "?"
deathlog_menu:SetStatusText(
#ordered
.. " search result/"
.. total_str
.. " preprocessed"
)
else
local total_str = (precomputed_general_stats and precomputed_general_stats["all"] and precomputed_general_stats["all"]["all"] and precomputed_general_stats["all"]["all"]["all"] and precomputed_general_stats["all"]["all"]["all"]["all"] and precomputed_general_stats["all"]["all"]["all"]["all"]["num_entries"]) or "?"
deathlog_menu:SetStatusText(
#ordered
.. " search results/"
.. total_str
.. " preprocessed"
)
end
end
local _deathlog_data = {}
local _stats = {}
local _log_normal_params = {}
local initialized = false
local function drawLogTab(container)
local scroll_container = AceGUI:Create("SimpleGroup")
scroll_container:SetFullWidth(true)
scroll_container:SetFullHeight(true)
scroll_container:SetLayout("Fill")
deathlog_tabcontainer:AddChild(scroll_container)
local scroll_frame = AceGUI:Create("ScrollFrame")
scroll_frame:SetLayout("Flow")
scroll_container:AddChild(scroll_frame)
local server_filter = nil
local name_filter = nil
local class_filter = nil
local race_filter = nil
local zone_filter = nil
local min_level_filter = nil
local max_level_filter = nil
local death_source_filter = nil
local last_words_filter = nil
local filter = function(server_name, _entry)
if server_filter ~= nil then
if server_filter(server_name, _entry) == false then
return false
end
end
if name_filter ~= nil then
if name_filter(server_name, _entry) == false then
return false
end
end
if min_level_filter ~= nil then
if min_level_filter(server_name, _entry) == false then
return false
end
end
if max_level_filter ~= nil then
if max_level_filter(server_name, _entry) == false then
return false
end
end
if death_source_filter ~= nil then
if death_source_filter(server_name, _entry) == false then
return false
end
end
if class_filter ~= nil then
if class_filter(server_name, _entry) == false then
return false
end
end
if race_filter ~= nil then
if race_filter(server_name, _entry) == false then
return false
end
end
if zone_filter ~= nil then
if zone_filter(server_name, _entry) == false then
return false
end
end
if guild_filter ~= nil then
if guild_filter(server_name, _entry) == false then
return false
end
end
if last_words_filter ~= nil then
if last_words_filter(server_name, _entry) == false then
return false
end
end
return true
end
local class_search_box = AceGUI:Create("Icon")
class_search_box:SetWidth(50)
class_search_box:SetHeight(50)
class_search_box:SetDisabled(true)
scroll_frame:AddChild(class_search_box)
--- Server dropdown
if font_container.server_dd == nil then
font_container.server_dd = CreateFrame("Frame", nil, font_container, "UIDropDownMenuTemplate")
font_container.server_dd.val = ""
end
local function serverDD(frame, level, menuList)
local info = UIDropDownMenu_CreateInfo()
local function setFilter()
local key = font_container.server_dd.val
if key ~= "" then
server_filter = function(server_name, _entry)
if server_name == key then
return true
else
return false
end
end
clearDeathlogMenuLogData()
setDeathlogMenuLogData(deathlogFilter(_deathlog_data, filter))
else
server_filter = nil
clearDeathlogMenuLogData()
setDeathlogMenuLogData(deathlogFilter(_deathlog_data, filter))
end
end
info.text, info.checked, info.func =
"All", font_container.server_dd.val == "", function()
font_container.server_dd.val = ""
UIDropDownMenu_SetText(font_container.server_dd, "All")
setFilter()
end
UIDropDownMenu_AddButton(info)
-- Track which servers we've added to avoid duplicates
local added_servers = {}
-- Always add current realm first
local current_realm = GetRealmName()
if current_realm and current_realm ~= "" then
info.text, info.checked, info.func =
current_realm, font_container.server_dd.val == current_realm, function()
font_container.server_dd.val = current_realm
UIDropDownMenu_SetText(font_container.server_dd, font_container.server_dd.val)
setFilter()
end
UIDropDownMenu_AddButton(info)
added_servers[current_realm] = true
end
-- Add other servers from death data
for server_name, _ in pairs(_deathlog_data) do
if not added_servers[server_name] then
info.text, info.checked, info.func =
server_name, font_container.server_dd.val == server_name, function()
font_container.server_dd.val = server_name
UIDropDownMenu_SetText(font_container.server_dd, font_container.server_dd.val)
setFilter()
end
UIDropDownMenu_AddButton(info)
added_servers[server_name] = true
end
end
end
font_container.server_dd:SetPoint("TOPLEFT", scroll_container.frame, "TOPLEFT", -5, -20)
UIDropDownMenu_SetText(font_container.server_dd, font_container.server_dd.val ~= "" and font_container.server_dd.val or "All")
UIDropDownMenu_SetWidth(font_container.server_dd, 80)
UIDropDownMenu_Initialize(font_container.server_dd, serverDD)
UIDropDownMenu_JustifyText(font_container.server_dd, "LEFT")
if font_container.server_dd.text == nil then
font_container.server_dd.text = font_container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
end
font_container.server_dd.text:SetPoint("LEFT", font_container.server_dd, "LEFT", 20, 20)
font_container.server_dd.text:SetFont(Deathlog_L.menu_font, 12, "")
font_container.server_dd.text:SetTextColor(255 / 255, 215 / 255, 0)
font_container.server_dd.text:SetText("Server")
font_container.server_dd.text:Show()
--- Race dropdown
if font_container.race_dd == nil then
font_container.race_dd = CreateFrame("Frame", nil, font_container, "UIDropDownMenuTemplate")
font_container.race_dd.val = ""
end
local function raceDD(frame, level, menuList)
local info = UIDropDownMenu_CreateInfo()
local function setFilter()
local key = font_container.race_dd.val
if key ~= "" then
race_filter = function(_, _entry)
if race_tbl[key] == tonumber(_entry["race_id"]) then
return true
else
return false
end
end
clearDeathlogMenuLogData()
setDeathlogMenuLogData(deathlogFilter(_deathlog_data, filter))
else
race_filter = nil
clearDeathlogMenuLogData()
setDeathlogMenuLogData(deathlogFilter(_deathlog_data, filter))
end
end
info.text, info.checked, info.func =
"All", font_container.race_dd.val == "", function()
font_container.race_dd.val = ""
UIDropDownMenu_SetText(font_container.race_dd, "All")
setFilter()
end
UIDropDownMenu_AddButton(info)
for race_name, _ in pairs(race_tbl) do
info.text, info.checked, info.func =
race_name, font_container.race_dd.val == race_name, function()
font_container.race_dd.val = race_name
UIDropDownMenu_SetText(font_container.race_dd, font_container.race_dd.val)
setFilter()
end
UIDropDownMenu_AddButton(info)
end
end
font_container.race_dd:SetPoint("TOPLEFT", scroll_container.frame, "TOPLEFT", 90, -20)
UIDropDownMenu_SetText(font_container.race_dd, font_container.race_dd.val ~= "" and font_container.race_dd.val or "All")
UIDropDownMenu_SetWidth(font_container.race_dd, 80)
UIDropDownMenu_Initialize(font_container.race_dd, raceDD)
UIDropDownMenu_JustifyText(font_container.race_dd, "LEFT")
if font_container.race_dd.text == nil then
font_container.race_dd.text = font_container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
end
font_container.race_dd.text:SetPoint("LEFT", font_container.race_dd, "LEFT", 20, 20)
font_container.race_dd.text:SetFont(Deathlog_L.menu_font, 12, "")
font_container.race_dd.text:SetTextColor(255 / 255, 215 / 255, 0)
font_container.race_dd.text:SetText("Race")
font_container.race_dd.text:Show()
--- Race dropdown
if font_container.class_dd == nil then
font_container.class_dd = CreateFrame("Frame", nil, font_container, "UIDropDownMenuTemplate")
font_container.class_dd.val = ""
end
local function classDD(frame, level, menuList)
local info = UIDropDownMenu_CreateInfo()
local function setFilter()
local key = font_container.class_dd.val
if key ~= "" then
class_filter = function(_, _entry)
if class_tbl[key] == tonumber(_entry["class_id"]) then
return true
else
return false
end
end
clearDeathlogMenuLogData()
setDeathlogMenuLogData(deathlogFilter(_deathlog_data, filter))
else
class_filter = nil
clearDeathlogMenuLogData()
setDeathlogMenuLogData(deathlogFilter(_deathlog_data, filter))
end
end
info.text, info.checked, info.func =
"All", font_container.class_dd.val == "", function()
font_container.class_dd.val = ""
UIDropDownMenu_SetText(font_container.class_dd, "All")
setFilter()
end
UIDropDownMenu_AddButton(info)
for class_name, _ in pairs(class_tbl) do
info.text, info.checked, info.func =
class_name, font_container.class_dd.val == class_name, function()
font_container.class_dd.val = class_name
UIDropDownMenu_SetText(font_container.class_dd, font_container.class_dd.val)
setFilter()
end
UIDropDownMenu_AddButton(info)
end
end
font_container.class_dd:SetPoint("TOPLEFT", scroll_container.frame, "TOPLEFT", 185, -20)
UIDropDownMenu_SetText(font_container.class_dd, font_container.class_dd.val ~= "" and font_container.class_dd.val or "All")
UIDropDownMenu_SetWidth(font_container.class_dd, 80)
UIDropDownMenu_Initialize(font_container.class_dd, classDD)
UIDropDownMenu_JustifyText(font_container.class_dd, "LEFT")
if font_container.class_dd.text == nil then
font_container.class_dd.text = font_container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
end
font_container.class_dd.text:SetPoint("LEFT", font_container.class_dd, "LEFT", 20, 20)
font_container.class_dd.text:SetFont(Deathlog_L.menu_font, 12, "")
font_container.class_dd.text:SetTextColor(255 / 255, 215 / 255, 0)
font_container.class_dd.text:SetText("Class")
font_container.class_dd.text:Show()
--- Zone dropdown
if font_container.zone_dd == nil then
font_container.zone_dd = CreateFrame("Frame", nil, font_container, "UIDropDownMenuTemplate")
font_container.zone_dd.val = ""
end
-- Helper: get zone IDs from a category that exist in a specific expansion
local function getZoneCategoryForExpansion(category_name, expansion_id)
local category_ids = zone_categories and zone_categories[category_name]
if not category_ids then return {} end
local expansion_zones = zone_to_id[expansion_id]
if not expansion_zones then return {} end
-- Build reverse lookup: zone_id -> true for this expansion
local expansion_zone_ids = {}
for _, zone_id in pairs(expansion_zones) do
expansion_zone_ids[zone_id] = true
end
-- Filter category IDs to only those in this expansion
local filtered = {}
for _, zone_id in ipairs(category_ids) do
if expansion_zone_ids[zone_id] then
table.insert(filtered, zone_id)
end
end
return filtered
end
local function zoneDD(frame, level, menuList)
local info = UIDropDownMenu_CreateInfo()
local function setFilter()
local key = font_container.zone_dd.val
if key ~= "" then
zone_filter = function(_, _entry)
-- Look up zone in all expansions
for _, zones in pairs(zone_to_id) do
if zones[key] and zones[key] == tonumber(_entry["map_id"]) then
return true
end
end
-- Look up instance in all expansions
for _, instances in pairs(instance_to_id) do
if instances[key] and instances[key] == tonumber(_entry["instance_id"]) then
return true
end
end
return false
end
clearDeathlogMenuLogData()
setDeathlogMenuLogData(deathlogFilter(_deathlog_data, filter))
else
zone_filter = nil
clearDeathlogMenuLogData()
setDeathlogMenuLogData(deathlogFilter(_deathlog_data, filter))
end
end
-- Count how many expansions we have for zones
local zone_expansion_count = 0
local single_zone_expansion_id = nil
for expansion_id, _ in pairs(zone_to_id) do
zone_expansion_count = zone_expansion_count + 1
single_zone_expansion_id = expansion_id
end
local skip_zone_expansion_layer = (zone_expansion_count == 1)
if level == 1 or level == nil then
-- "All" option at top level
info.text, info.checked, info.func =
"All", font_container.zone_dd.val == "", function()
font_container.zone_dd.val = ""
UIDropDownMenu_SetText(font_container.zone_dd, "All")
setFilter()
end
UIDropDownMenu_AddButton(info, level)
if skip_zone_expansion_layer then
-- Only one expansion: show continent submenus directly at level 1
if zone_categories then
local sorted_categories = {}
for category_name, _ in pairs(zone_categories) do
local filtered_zones = getZoneCategoryForExpansion(category_name, single_zone_expansion_id)
if #filtered_zones > 0 then
table.insert(sorted_categories, { name = category_name, zones = filtered_zones })
end
end
table.sort(sorted_categories, function(a, b) return a.name < b.name end)
for _, category in ipairs(sorted_categories) do
info = UIDropDownMenu_CreateInfo()
info.text = category.name
info.hasArrow = true
info.notCheckable = true
info.menuList = { type = "continent", expansion_id = single_zone_expansion_id, category_name = category.name, zones = category.zones }
UIDropDownMenu_AddButton(info, level)
end
else
-- No categories: show all zones directly
local zones = zone_to_id[single_zone_expansion_id]
if zones then
local sorted_zones = {}
for zone_name, zone_id in pairs(zones) do
table.insert(sorted_zones, { name = zone_name, id = zone_id })
end
table.sort(sorted_zones, function(a, b) return a.name < b.name end)
for _, zone in ipairs(sorted_zones) do
info = UIDropDownMenu_CreateInfo()
info.text = zone.name
info.checked = font_container.zone_dd.val == zone.name
info.func = function()
font_container.zone_dd.val = zone.name
UIDropDownMenu_SetText(font_container.zone_dd, font_container.zone_dd.val)
setFilter()
CloseDropDownMenus()
end
UIDropDownMenu_AddButton(info, level)
end
end
end
else
-- Multiple expansions: show expansion submenus (sorted by expansion_id)
local sorted_expansion_ids = {}
for expansion_id, _ in pairs(zone_to_id) do
table.insert(sorted_expansion_ids, expansion_id)
end
table.sort(sorted_expansion_ids)
for _, expansion_id in ipairs(sorted_expansion_ids) do
info = UIDropDownMenu_CreateInfo()
info.text = _G["EXPANSION_NAME" .. expansion_id]
info.hasArrow = true
info.notCheckable = true
info.menuList = { type = "expansion", id = expansion_id }
UIDropDownMenu_AddButton(info, level)
end
end
elseif level == 2 then
local menu_type = menuList and menuList.type
if menu_type == "continent" then
-- Coming from either: single-expansion level 1, or multi-expansion level 2
-- Show individual zones for selected continent/category
local category_zones = menuList.zones
local expansion_id = menuList.expansion_id
if category_zones and expansion_id then
local zones = zone_to_id[expansion_id]
if zones then
local category_zone_ids = {}
for _, zone_id in ipairs(category_zones) do
category_zone_ids[zone_id] = true
end
local sorted_zones = {}
for zone_name, zone_id in pairs(zones) do
if category_zone_ids[zone_id] then
table.insert(sorted_zones, { name = zone_name, id = zone_id })
end
end
table.sort(sorted_zones, function(a, b) return a.name < b.name end)
for _, zone in ipairs(sorted_zones) do
info = UIDropDownMenu_CreateInfo()
info.text = zone.name
info.checked = font_container.zone_dd.val == zone.name
info.func = function()
font_container.zone_dd.val = zone.name
UIDropDownMenu_SetText(font_container.zone_dd, font_container.zone_dd.val)
setFilter()
CloseDropDownMenus()
end
UIDropDownMenu_AddButton(info, level)
end
end
end
elseif menu_type == "expansion" then
-- Multi-expansion path: show continent submenus
local expansion_id = menuList.id
if zone_categories then
local sorted_categories = {}
for category_name, _ in pairs(zone_categories) do
local filtered_zones = getZoneCategoryForExpansion(category_name, expansion_id)
if #filtered_zones > 0 then
table.insert(sorted_categories, { name = category_name, zones = filtered_zones })
end
end
table.sort(sorted_categories, function(a, b) return a.name < b.name end)
for _, category in ipairs(sorted_categories) do
info = UIDropDownMenu_CreateInfo()
info.text = category.name
info.hasArrow = true
info.notCheckable = true
info.menuList = { type = "continent", expansion_id = expansion_id, category_name = category.name, zones = category.zones }
UIDropDownMenu_AddButton(info, level)
end
end
-- Fallback if no categories or empty: show all zones directly
if not zone_categories then
local zones = zone_to_id[expansion_id]
if zones then
local sorted_zones = {}
for zone_name, zone_id in pairs(zones) do
table.insert(sorted_zones, { name = zone_name, id = zone_id })
end
table.sort(sorted_zones, function(a, b) return a.name < b.name end)
for _, zone in ipairs(sorted_zones) do
info = UIDropDownMenu_CreateInfo()
info.text = zone.name
info.checked = font_container.zone_dd.val == zone.name
info.func = function()
font_container.zone_dd.val = zone.name
UIDropDownMenu_SetText(font_container.zone_dd, font_container.zone_dd.val)
setFilter()
CloseDropDownMenus()
end
UIDropDownMenu_AddButton(info, level)
end
end
end
end
elseif level == 3 then
-- Zones for selected continent/category (multi-expansion path only)
local category_zones = menuList and menuList.zones
local expansion_id = menuList and menuList.expansion_id
if category_zones and expansion_id then
local zones = zone_to_id[expansion_id]
if zones then
-- Build lookup of zone IDs in this category
local category_zone_ids = {}
for _, zone_id in ipairs(category_zones) do
category_zone_ids[zone_id] = true
end
-- Collect zones that belong to this category
local sorted_zones = {}
for zone_name, zone_id in pairs(zones) do
if category_zone_ids[zone_id] then
table.insert(sorted_zones, { name = zone_name, id = zone_id })
end
end
table.sort(sorted_zones, function(a, b) return a.name < b.name end)
for _, zone in ipairs(sorted_zones) do