-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogFrame.lua
More file actions
1466 lines (1363 loc) · 55.8 KB
/
Copy pathLogFrame.lua
File metadata and controls
1466 lines (1363 loc) · 55.8 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
-- LFGAlert - LogFrame.lua
-- Scrollable applicant log with right-click whisper/invite/decline.
-- Smooth-scrolling list (own row pool + offset, no Blizzard scroll
-- templates), sortable columns, resizable + position/scale-persistent
-- window, class icons, new-row flash, lifecycle status icons.
-- ID-based LFG actions are gated to the current listing session: Blizzard
-- reuses applicantIDs across delist/relist cycles, so acting on a stale ID
-- from an old row could invite/decline the wrong current applicant.
local ADDON_NAME = ...
LFGAlert = LFGAlert or {}
local NS = LFGAlert
local L = NS.L or {}
local function l(key, fallback) return L[key] or fallback end
local ROW_HEIGHT = 22
local ROW_GAP = 6
local ACTW = 72 -- action-button zone at each row's right edge (3 x 20px)
local DEFAULT_W, DEFAULT_H = 860, 480
local MIN_W, MIN_H, MAX_W, MAX_H = 680, 320, 1400, 1000
local NAME_ICON_W = 18 -- class-icon strip inside the Applicant column
local MAX_ROWS = 60 -- visible row pool cap
local SCROLL_ZONE = 30 -- right edge of the list kept clear for the scrollbar
local FLASH_WINDOW = 8 -- seconds a fresh "queued" row keeps pulsing
local logFrame, listArea, searchBox, countLabel, scrollBar
local filterButton, classBtn, keyBtn, resetFiltersBtn
local scrollOffset = 0 -- top visible row index (0-based) into `view`
local updatingBar = false -- suppress slider feedback while we move it
local rows = {} -- visible row pool (index = on-screen slot, 1 = top)
local view = {} -- display-order entries (view[1] = top row)
local headerWidgets = {}
local sortKey, sortDir = "time", "desc"
local selectedEntry
local lastN = 0
local refreshQueued = false
local uiReady = false
-- Forward declarations (assigned below; referenced by scripts/closures).
local RenderRows, ScrollBy, RefreshNow
local ClassColorize = NS.ClassColorize or function(_, text) return text end
local ShortName = NS.ShortName or function(n) return n or "?" end
local function TimeStr(t)
if not t then return "--:--" end
return date("%H:%M:%S", t)
end
-- ---------------------------------------------------------------------------
-- Table columns. ONE definition drives the header, sorting and every row,
-- so values always sit exactly under their heading. Numeric columns are
-- right-aligned; text is truncated (UTF-8 safe) so it can never bleed over.
-- ---------------------------------------------------------------------------
local COLS = {
{ key = "time", label = l("col_time", "Time"), width = 56, justify = "LEFT", sort = true },
{ key = "name", label = l("col_name", "Applicant"), width = 112, justify = "LEFT", sort = true },
{ key = "role", label = l("col_role", "Role"), width = 58, justify = "LEFT" },
{ key = "spec", label = l("col_spec", "Class/Spec"), width = 92, justify = "LEFT" },
{ key = "run", label = l("col_run", "Key"), width = 58, justify = "LEFT", sort = true },
{ key = "ilvl", label = l("col_ilvl", "iLvl"), width = 46, justify = "RIGHT", sort = true },
{ key = "score", label = l("col_score", "M+ Score"), width = 52, justify = "RIGHT", sort = true },
{ key = "status", label = l("col_status", "Status"), width = 112, justify = "LEFT", sort = true },
{ key = "note", label = l("col_note", "Notes"), width = 0, justify = "LEFT" },
}
-- Lifecycle icons for the Status column: queued → invited → accepted, plus
-- ✕ for declined/left. Reached stages render in color, unreached greyed.
local STATUS_ICON_FILES = {
"Interface\\Icons\\INV_Misc_Bell_01", -- queued
"Interface\\RaidFrame\\ReadyCheck-Waiting", -- invited (waiting on answer)
"Interface\\RaidFrame\\ReadyCheck-Ready", -- accepted
"Interface\\RaidFrame\\ReadyCheck-NotReady", -- declined / left
}
local STATUS_ICON_SIZE = 14
local STATUS_ICON_GAP = 5
-- Byte-safe truncation that never splits a UTF-8 sequence.
local function Trunc(s, n)
if not s or s == "" then return "" end
if #s <= n then return s end
local cut = s:sub(1, n - 1)
cut = cut:gsub("[\194-\244][\128-\191]*$", "")
return cut .. "…"
end
-- ---------------------------------------------------------------------------
-- Filter + search (status filter + text search over name/spec/class/note)
-- ---------------------------------------------------------------------------
NS.logFilter = NS.logFilter or { status = "ALL", query = "" }
NS.logFilter.class = NS.logFilter.class or "ALL"
NS.logFilter.minKey = NS.logFilter.minKey or 0
local CLASS_ORDER = { "WARRIOR", "PALADIN", "HUNTER", "ROGUE", "PRIEST", "DEATHKNIGHT",
"SHAMAN", "MAGE", "WARLOCK", "MONK", "DRUID", "DEMONHUNTER", "EVOKER" }
local function ClassLabel(classFile)
if classFile == "ALL" then return l("all_classes", "All Classes") end
local loc = LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[classFile]
return ClassColorize(classFile, loc or (classFile or "?"):lower():gsub("^%l", string.upper))
end
local KEY_OPTIONS = { 0, 2, 4, 6, 8, 10, 12, 15, 20 }
local function KeyLabel(minKey)
if not minKey or minKey <= 0 then return l("filter_all", "All") end
return l("key_label_fmt", "+%d+"):format(minKey)
end
function NS.SetLogClassFilter(class)
local c = (class or "ALL"):upper():gsub("%s+", "")
if c ~= "ALL" and not (RAID_CLASS_COLORS and RAID_CLASS_COLORS[c]) then c = "ALL" end
NS.logFilter.class = c
if NS.RefreshLogUI then NS.RefreshLogUI(true) end
return c
end
function NS.SetLogMinKey(n)
n = math.max(0, math.floor(tonumber(n) or 0))
NS.logFilter.minKey = n
if NS.RefreshLogUI then NS.RefreshLogUI(true) end
return n
end
-- Filter keys shown in the dropdown. Several raw statuses collapse into one key.
local FILTER_OPTIONS = {
{ key = "ALL", label = l("filter_all", "All") },
{ key = "QUEUED", label = l("filter_queued", "Queued") },
{ key = "INVITED", label = l("filter_invited", "Invited") },
{ key = "ACCEPTED", label = l("filter_accepted", "Accepted") },
{ key = "DECLINED", label = l("filter_declined", "Declined") },
{ key = "GONE", label = l("filter_gone", "Cancelled / Timeout") },
}
local DECLINED_SET = {
declined = true, declined_full = true, declined_delisted = true,
invitedeclined = true, failed = true,
}
local function FilterKeyForStatus(status)
if status == "applied" then return "QUEUED" end
if status == "invited" then return "INVITED" end
if status == "inviteaccepted" then return "ACCEPTED" end
if DECLINED_SET[status] then return "DECLINED" end
if status == "cancelled" or status == "timedout" then return "GONE" end
return "OTHER"
end
local function FilterLabel(key)
for _, o in ipairs(FILTER_OPTIONS) do
if o.key == key then return o.label end
end
return key or l("filter_all", "All")
end
function NS.SetLogFilter(status)
local s = (status or "ALL"):upper()
if s == "QUEUE" then s = "QUEUED" end
local valid = false
for _, o in ipairs(FILTER_OPTIONS) do
if o.key == s then valid = true break end
end
NS.logFilter.status = valid and s or "ALL"
if NS.RefreshLogUI then NS.RefreshLogUI(true) end
return NS.logFilter.status
end
function NS.SetLogSearch(q)
NS.logFilter.query = (q or ""):lower()
if NS.RefreshLogUI then NS.RefreshLogUI(true) end
end
function NS.ResetLogFilters()
NS.logFilter.status = "ALL"
NS.logFilter.class = "ALL"
NS.logFilter.minKey = 0
NS.logFilter.query = ""
if searchBox then searchBox:SetText("") end -- fires OnTextChanged -> refresh
if NS.RefreshLogUI then NS.RefreshLogUI(true) end
end
local function EntryMatches(entry)
local f = NS.logFilter
if entry.separator then
-- Separators only make sense in the unfiltered chronological view.
return f.status == "ALL" and (f.class or "ALL") == "ALL"
and (f.minKey or 0) <= 0 and (f.query == nil or f.query == "")
end
if f.status ~= "ALL" and FilterKeyForStatus(entry.status) ~= f.status then
return false
end
local cf = f.class or "ALL"
if cf ~= "ALL" then
local m0 = entry.members and entry.members[1]
if not (m0 and m0.class == cf) then return false end
end
local mk = f.minKey or 0
if mk > 0 and not (entry.key and entry.key >= mk) then
return false
end
local q = f.query
if q and q ~= "" then
local m = entry.members and entry.members[1]
local hay = {}
if m then
hay[#hay + 1] = m.name or ""
hay[#hay + 1] = m.specName or ""
hay[#hay + 1] = m.class or ""
hay[#hay + 1] = m.localizedClass or ""
if NS.ResolveRole and NS.RoleTag then
local _, rolePlain = NS.RoleTag(NS.ResolveRole(m))
hay[#hay + 1] = rolePlain or ""
hay[#hay + 1] = NS.ResolveRole(m) or ""
end
end
hay[#hay + 1] = entry.comment or ""
hay[#hay + 1] = entry.status or ""
hay[#hay + 1] = entry.dungeon or ""
hay[#hay + 1] = entry.dungeonFull or ""
local label = NS.StatusLabel and select(1, NS.StatusLabel(entry.status)) or ""
hay[#hay + 1] = label or ""
local blob = table.concat(hay, " "):lower()
if not blob:find(q, 1, true) then return false end
end
return true
end
-- ---------------------------------------------------------------------------
-- Sorting (click a column header)
-- ---------------------------------------------------------------------------
local SORT_VALUE = {
time = function(e) return e.t or 0 end,
name = function(e)
local m = e.members and e.members[1]
return (m and m.name or ""):lower()
end,
run = function(e) return e.key or 0 end,
ilvl = function(e)
local m = e.members and e.members[1]
return (m and m.itemLevel) or 0
end,
score = function(e)
local m = e.members and e.members[1]
return (m and NS.EffectiveScore and NS.EffectiveScore(m)) or 0
end,
status = function(e) return select(1, NS.StatusLabel(e.status)) end,
}
local function ToggleSort(key)
if not SORT_VALUE[key] then return end
if sortKey == key then
sortDir = (sortDir == "asc") and "desc" or "asc"
else
sortKey = key
sortDir = (key == "name" or key == "status") and "asc" or "desc"
end
selectedEntry = nil
if NS.RefreshLogUI then NS.RefreshLogUI(true) end
end
-- Build the display-order view (view[1] = top row).
local function BuildView()
wipe(view)
local log = (NS.db and NS.db.log) or {}
if sortKey == "time" then
if sortDir == "desc" then
for i = #log, 1, -1 do
local e = log[i]
if EntryMatches(e) then view[#view + 1] = e end
end
else
for i = 1, #log do
local e = log[i]
if EntryMatches(e) then view[#view + 1] = e end
end
end
else
-- Session separators are chronological dividers: hide them in sorted views.
for _, e in ipairs(log) do
if EntryMatches(e) and not e.separator then view[#view + 1] = e end
end
local vf = SORT_VALUE[sortKey]
table.sort(view, function(a, b)
local va, vb = vf(a), vf(b)
if va == vb then return (a.t or 0) > (b.t or 0) end
if sortDir == "asc" then return va < vb end
return va > vb
end)
end
end
-- ---------------------------------------------------------------------------
-- Session guard: applicantIDs reset on relist, so ID-based LFG actions are
-- only valid for entries logged during the CURRENT listing session.
-- ---------------------------------------------------------------------------
local function RowLFGActionsAllowed(entry)
return entry ~= nil and not entry.separator
and entry.applicantID and entry.applicantID ~= 0
and entry.session ~= nil
and NS.CurrentListingSession ~= nil
and entry.session == NS.CurrentListingSession()
end
-- ---------------------------------------------------------------------------
-- Context menu (right-click a row)
-- ---------------------------------------------------------------------------
local function ShowRowMenu(anchor, entry)
if not entry or entry.separator or not entry.members or not entry.members[1] then return end
local mem = entry.members[1]
local fullName = mem.name
local applicantID = entry.applicantID
-- Modern MenuUtil (Dragonflight+) path
if MenuUtil and MenuUtil.CreateContextMenu then
MenuUtil.CreateContextMenu(anchor, function(_, root)
root:CreateTitle(ShortName(fullName))
root:CreateButton(l("m_whisper", "Whisper"), function()
NS.Whisper(fullName)
end)
root:CreateButton(l("m_invite_name", "Invite to group (by name)"), function()
NS.InviteByName(fullName)
end)
if RowLFGActionsAllowed(entry) then
root:CreateButton(l("m_accept", "Accept applicant (LFG invite)"), function()
NS.InviteApplicantByID(applicantID)
end)
root:CreateButton(l("m_decline", "Decline applicant"), function()
NS.DeclineApplicantByID(applicantID)
end)
end
root:CreateDivider()
root:CreateButton(l("m_copy_name", "Copy name"), function()
local eb = ChatEdit_ChooseBoxForSend()
if eb then
eb:Show()
eb:SetText(fullName)
eb:HighlightText()
end
end)
end)
return
end
-- Fallback: classic dropdown
if not LFGAlertDropMenu then
CreateFrame("Frame", "LFGAlertDropMenu", UIParent, "UIDropDownMenuTemplate")
end
local menu = {
{ text = ShortName(fullName), isTitle = true, notCheckable = true },
{ text = l("m_whisper", "Whisper"), notCheckable = true, func = function() NS.Whisper(fullName) end },
{ text = l("m_invite_name", "Invite to group (by name)"), notCheckable = true, func = function()
NS.InviteByName(fullName)
end },
}
if RowLFGActionsAllowed(entry) then
menu[#menu + 1] = { text = l("m_decline", "Decline applicant"), notCheckable = true, func = function() NS.DeclineApplicantByID(applicantID) end }
end
EasyMenu(menu, LFGAlertDropMenu, "cursor", 0, 0, "MENU")
end
-- ---------------------------------------------------------------------------
-- Class icon (graceful degradation: hidden content never errors)
-- ---------------------------------------------------------------------------
local function SetClassIcon(tex, classFile)
if not tex then return end
if not classFile or classFile == "" then tex:SetTexture(nil) return end
if C_Texture and C_Texture.GetClassNameIconAtlas then
local ok, atlas = pcall(C_Texture.GetClassNameIconAtlas, classFile)
if ok and atlas then
local okS = pcall(tex.SetAtlas, tex, atlas)
if okS then return end
end
end
pcall(tex.SetAtlas, tex, "ClassIcon-" .. classFile .. "-Circle")
end
-- ---------------------------------------------------------------------------
-- Rows
-- ---------------------------------------------------------------------------
local function MakeRow(i)
local b = CreateFrame("Button", nil, listArea)
b:SetHeight(ROW_HEIGHT)
b:SetPoint("TOPLEFT", listArea, "TOPLEFT", 4, -(i - 1) * ROW_HEIGHT - 4)
b:SetPoint("TOPRIGHT", listArea, "TOPRIGHT", -(SCROLL_ZONE + 4), -(i - 1) * ROW_HEIGHT - 4)
-- Row background: tinted per status on every refresh (see StatusTint).
local stripe = b:CreateTexture(nil, "BACKGROUND")
stripe:SetAllPoints()
stripe:SetColorTexture(0.5, 0.38, 0.12, 0.2)
b.stripe = stripe
-- Selection highlight (left-click selects; actions stay on buttons/menu):
-- soft wash + a bright gold accent bar on the row's left edge.
local selTex = b:CreateTexture(nil, "ARTWORK")
selTex:SetAllPoints()
selTex:SetColorTexture(1, 0.82, 0, 0.15)
selTex:Hide()
b.selTex = selTex
local accent = b:CreateTexture(nil, "OVERLAY")
accent:SetSize(3, ROW_HEIGHT - 6)
accent:SetPoint("LEFT", b, "LEFT", 0, 0)
accent:SetColorTexture(1, 0.82, 0, 0.95)
accent:Hide()
b.accent = accent
-- New-row flash: brief alpha pulse on freshly queued applicants.
local flash = b:CreateTexture(nil, "ARTWORK")
flash:SetAllPoints()
flash:SetColorTexture(1, 0.82, 0, 0.20)
flash:Hide()
local ag = flash:CreateAnimationGroup()
local alpha = ag:CreateAnimation("Alpha")
alpha:SetFromAlpha(1)
alpha:SetToAlpha(0)
alpha:SetDuration(0.8)
alpha:SetSmoothing("OUT")
b.flash = flash
b.flashAnim = ag
-- Class icon inside the Applicant column.
b.icon = b:CreateTexture(nil, "OVERLAY")
b.icon:SetSize(14, 14)
-- One FontString per column, laid out from the same COLS spec as the header.
-- The note column stops before the action-button zone at the right edge.
b.cols = {}
local x = 2
local statusX = nil
for _, c in ipairs(COLS) do
local fs = b:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
fs:SetJustifyH(c.justify)
fs:SetWordWrap(false)
if c.key == "note" then
fs:SetPoint("LEFT", b, "LEFT", x, 0)
fs:SetPoint("RIGHT", b, "RIGHT", -(2 + ACTW + ROW_GAP), 0)
elseif c.key == "name" then
b.icon:SetPoint("LEFT", b, "LEFT", x + 1, 1)
fs:SetPoint("LEFT", b, "LEFT", x + NAME_ICON_W, 0)
fs:SetWidth(c.width)
x = x + c.width + NAME_ICON_W + ROW_GAP
else
if c.key == "status" then statusX = x end
fs:SetPoint("LEFT", b, "LEFT", x, 0)
fs:SetWidth(c.width)
x = x + c.width + ROW_GAP
end
b.cols[c.key] = fs
end
-- Lifecycle status icons inside the Status column slot.
if statusX then
b.statusIcons = {}
for i, texPath in ipairs(STATUS_ICON_FILES) do
local ic = b:CreateTexture(nil, "OVERLAY")
ic:SetSize(STATUS_ICON_SIZE, STATUS_ICON_SIZE)
ic:SetPoint("TOPLEFT", b, "TOPLEFT", statusX + (i - 1) * (STATUS_ICON_SIZE + STATUS_ICON_GAP), -4)
ic:SetTexture(texPath)
ic:SetDesaturated(true)
ic:SetAlpha(0.3)
ic:Hide()
b.statusIcons[i] = ic
end
end
-- One-click action buttons (whisper / invite / decline), right edge.
-- Decline only appears for CURRENT-session rows with a live applicantID.
b.act = {}
local actDefs = {
{ icon = "Interface\\Buttons\\UI-GuildButton-PublicNote-Up", tip = l("act_whisper", "Whisper") },
{ icon = "Interface\\RaidFrame\\ReadyCheck-Ready", tip = l("act_invite", "Invite to group") },
{ icon = "Interface\\RaidFrame\\ReadyCheck-NotReady", tip = l("act_decline", "Decline applicant") },
}
for i, a in ipairs(actDefs) do
local ab = CreateFrame("Button", nil, b)
ab:SetSize(20, 20)
ab:SetPoint("RIGHT", b, "RIGHT", -2 - (3 - i) * 24, 0)
ab:SetNormalTexture(a.icon)
ab:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square", "ADD")
ab:SetScript("OnClick", function()
local e = b.entry
if not e or e.separator or not e.members or not e.members[1] then return end
local fullName, applicantID = e.members[1].name, e.applicantID
if i == 1 then
NS.Whisper(fullName)
elseif i == 2 then
-- By-name invites are always safe; the ID path only for live IDs.
if RowLFGActionsAllowed(e) then NS.InviteApplicantByID(applicantID) end
NS.InviteByName(fullName)
elseif RowLFGActionsAllowed(e) then
NS.DeclineApplicantByID(applicantID)
end
end)
ab:SetScript("OnEnter", function(self)
local e = b.entry
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
if e and not e.separator and e.members and e.members[1] then
GameTooltip:SetText(a.tip .. ": " .. ShortName(e.members[1].name), 1, 1, 1)
else
GameTooltip:SetText(a.tip, 1, 1, 1)
end
GameTooltip:Show()
end)
ab:SetScript("OnLeave", function() GameTooltip:Hide() end)
b.act[i] = ab
end
b:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD")
b:RegisterForClicks("LeftButtonUp", "RightButtonUp")
b:SetScript("OnClick", function(self, button)
if button == "RightButton" and self.entry then
ShowRowMenu(self, self.entry)
elseif self.entry and not self.entry.separator then
-- Left-click selects (toggle); whisper stays on the button/menu so a
-- stray click can never open a whisper to a stranger.
selectedEntry = (selectedEntry == self.entry) and nil or self.entry
RenderRows()
end
end)
b:SetScript("OnMouseWheel", function(_, delta) ScrollBy(delta) end)
b:SetScript("OnEnter", function(self)
if not self.entry then return end
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
local e = self.entry
if e.separator then
GameTooltip:SetText(e.separator)
GameTooltip:Show()
return
end
local m = e.members and e.members[1]
if not m then return end
GameTooltip:SetText(ShortName(m.name), 1, 1, 1)
if m.class then
local line = (m.specName and (m.specName .. " ") or "") .. (m.class or "")
GameTooltip:AddLine(line, 1, 0.82, 0)
end
if NS.ResolveRole and NS.RoleTag then
local roleTag = NS.RoleTag(NS.ResolveRole(m))
GameTooltip:AddDoubleLine(l("tt_role", "Role"), roleTag, 1, 1, 1, 1, 1, 1)
end
if e.dungeon or e.key then
local runLine = (e.key and ("+" .. e.key .. " ") or "") .. (e.dungeonFull or e.dungeon or "")
if e.keySource == "keystone" then runLine = runLine .. "|cffaaaaaa" .. l("tt_yourkey", " (your key)") .. "|r" end
GameTooltip:AddDoubleLine(l("tt_run", "Run"), runLine, 1, 1, 1, 1, 0.82, 0)
end
if e.listingTitle and e.listingTitle ~= "" then
GameTooltip:AddDoubleLine(l("tt_listing", "Listing"), e.listingTitle, 1, 1, 1, 0.8, 0.8, 0.8)
end
GameTooltip:AddDoubleLine(l("tt_ilvl", "Item level"), tostring(m.itemLevel or "-"), 1, 1, 1, 1, 1, 1)
local blizz = (m.dungeonScore and m.dungeonScore > 0) and tostring(m.dungeonScore) or "-"
local rio = (m.rioScore and m.rioScore > 0) and tostring(m.rioScore) or "-"
GameTooltip:AddDoubleLine(l("tt_blizz", "M+ rating (Blizzard)"), blizz, 1, 1, 1, 1, 1, 1)
GameTooltip:AddDoubleLine(l("tt_rio", "RIO score") .. (_G.RaiderIO and "" or l("tt_rio_install", " (install Raider.IO)")), rio, 1, 1, 1, 1, 1, 1)
if (e.numMembers or 1) > 1 and e.members then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(l("tt_group_fmt", "Group application (%d):"):format(e.numMembers), 0.9, 0.9, 0.9)
for i = 2, math.min(#e.members, 8) do
local o = e.members[i]
GameTooltip:AddDoubleLine(ShortName(o.name), (o.specName or o.class or "") .. " ilvl " .. tostring(o.itemLevel or "-") .. " M+ " .. tostring((o.rioScore and o.rioScore > 0) and o.rioScore or (o.dungeonScore or "-")), 1, 1, 1, 0.9, 0.9, 0.9)
end
end
if e.comment and e.comment ~= "" then
GameTooltip:AddLine(" ")
GameTooltip:AddLine("\"" .. e.comment .. "\"", 0.7, 0.9, 1, true)
end
if e.autoDeclined then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(l("tt_auto_declined", "Auto-declined (%s)"):format(e.declineReason or l("auto_label", "Auto")), 1, 0.4, 0.35)
end
if e.history and #e.history > 1 then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(l("tt_history", "History"), 0.9, 0.9, 0.9)
for hi = math.max(1, #e.history - 5), #e.history do
local hh = e.history[hi]
local hlabel = NS.StatusLabel and select(1, NS.StatusLabel(hh.status)) or tostring(hh.status)
GameTooltip:AddDoubleLine(TimeStr(hh.t), hlabel, 0.7, 0.7, 0.7, 0.85, 0.85, 0.85)
end
end
local label = NS.StatusLabel and select(1, NS.StatusLabel(e.status)) or tostring(e.status)
GameTooltip:AddLine(" ")
GameTooltip:AddLine(l("tt_status_fmt", "Status: %s"):format(label), 0.8, 0.8, 0.8)
GameTooltip:AddLine(string.format("%s > %s > %s • X %s / %s",
l("tt_icon_queued", "Queued"), l("tt_icon_invited", "Invited"), l("tt_icon_accepted", "Accepted"),
l("tt_icon_declined", "Declined"), l("tt_icon_left", "Left / expired")), 0.6, 0.6, 0.6)
GameTooltip:AddLine(l("tt_rc_hint", "Right-click: whisper / invite / decline"), 0.6, 0.6, 0.6)
GameTooltip:Show()
end)
b:SetScript("OnLeave", function() GameTooltip:Hide() end)
return b
end
-- Row tint by status: green invited/accepted, red declined, gold queued, grey gone.
local function StatusTint(status)
if status == "inviteaccepted" then return 0.15, 0.6, 0.2 end
if status == "invited" then return 0.1, 0.45, 0.16 end
if status == "applied" then return 0.5, 0.38, 0.12 end
if status == "cancelled" or status == "timedout" then return 0.35, 0.35, 0.35 end
return 0.55, 0.12, 0.12 -- declined-ish
end
-- Returns one string per COLS key so every value lands under its heading.
local function EntryColumns(entry)
if entry.separator then return nil end
local m = entry.members and entry.members[1]
local cols = {}
cols.time = TimeStr(entry.t)
cols.status = "" -- lifecycle is drawn as status icons in RenderRow
-- Run context is known even when member data isn't (e.g. fresh "?" rows).
if entry.key and entry.dungeon then
cols.run = "|cffffd100+" .. tostring(entry.key) .. " " .. Trunc(entry.dungeon, 5) .. "|r"
elseif entry.key then
cols.run = "|cffffd100+" .. tostring(entry.key) .. "|r"
elseif entry.dungeon then
cols.run = Trunc(entry.dungeon, 7)
else
cols.run = "-"
end
if not m then
cols.name, cols.role, cols.spec, cols.ilvl, cols.score, cols.note = "?", "-", "-", "-", "-", ""
return cols
end
local star = ""
local ilvlTxt, scoreTxt
local thrOn, meetsAll = false, false
if NS.MeetsThresholds and NS.db and (NS.db.minIlvl > 0 or NS.db.minScore > 0) then
thrOn = true
local meetsIlvl, meetsScore, ma = NS.MeetsThresholds(m)
meetsAll = ma and true or false
local ilvlNum = (m.itemLevel and m.itemLevel > 0) and math.floor(m.itemLevel) or nil
local scoreNum = NS.EffectiveScore and NS.EffectiveScore(m) or 0
if ilvlNum then
ilvlTxt = (meetsIlvl and "|cff33cc33" or "|cffff5555") .. tostring(ilvlNum) .. "|r"
else
ilvlTxt = "-"
end
if scoreNum and scoreNum > 0 then
scoreTxt = (meetsScore and "|cff33cc33" or "|cffff5555") .. tostring(math.floor(scoreNum)) .. "|r"
else
scoreTxt = "-"
end
if meetsAll then star = "|cffffd100* |r" end
else
ilvlTxt = (m.itemLevel and m.itemLevel > 0) and tostring(math.floor(m.itemLevel)) or "-"
local scoreNum = (m.rioScore and m.rioScore > 0) and m.rioScore or (m.dungeonScore or 0)
scoreTxt = (scoreNum and scoreNum > 0) and tostring(math.floor(scoreNum)) or "-"
end
local nameTxt = star .. ClassColorize(m.class, Trunc(ShortName(m.name), 18))
if (entry.numMembers or 1) > 1 then
nameTxt = nameTxt .. " |cffaaaaaa+" .. ((entry.numMembers or 1) - 1) .. "|r"
end
cols.name = nameTxt
cols.role = NS.RoleTag(NS.ResolveRole(m))
cols.spec = Trunc(m.specName or m.localizedClass or m.class or "-", 14)
cols.ilvl = ilvlTxt
cols.score = scoreTxt
cols.note = (entry.comment and entry.comment ~= "") and ("|cff88bbff" .. Trunc(entry.comment, 40) .. "|r") or ""
return cols
end
-- ---------------------------------------------------------------------------
-- Render loop (fixed visible row pool, offset into `view`; template-free)
-- ---------------------------------------------------------------------------
-- Color the lifecycle icons for an entry: reached stages full color, the
-- rest desaturated at low alpha. The ✕ has three looks: red lit (declined
-- by you/auto), grey lit (they left/expired), dark grey (nothing negative).
local function StyleStatusIcons(row, entry)
if not row.statusIcons then return end
if not entry or entry.separator then
for _, ic in ipairs(row.statusIcons) do ic:Hide() end
return
end
local st = entry.status
local invitedDone = (st == "invited" or st == "inviteaccepted" or st == "invitedeclined")
local acceptedDone = (st == "inviteaccepted")
local endedKind = "none"
if DECLINED_SET[st] then
endedKind = "declined"
elseif st == "cancelled" or st == "timedout" then
endedKind = "gone"
end
for idx, ic in ipairs(row.statusIcons) do
ic:Show()
ic:SetVertexColor(1, 1, 1)
ic:SetDesaturated(false)
ic:SetAlpha(1)
if idx == 1 then
-- queued: always reached for a real entry
elseif idx == 2 and not invitedDone or idx == 3 and not acceptedDone then
ic:SetDesaturated(true)
ic:SetAlpha(0.30)
elseif idx == 4 then
if endedKind == "none" then
ic:SetDesaturated(true)
ic:SetAlpha(0.30)
elseif endedKind == "gone" then
ic:SetDesaturated(true)
ic:SetVertexColor(0.72, 0.72, 0.85)
ic:SetAlpha(0.85)
end
-- endedKind == "declined": keep full color (red X)
end
end
end
local function RenderRow(row, entry, i)
if not entry then
row:Hide()
row.entry = nil
return
end
row:Show()
row.entry = entry
-- Status tint + soft zebra striping so long histories stay readable.
local tr, tg, tb, ta = 0.2, 0.2, 0.2, 0.12
if not entry.separator then
tr, tg, tb = StatusTint(entry.status)
ta = (i and i % 2 == 0) and 0.13 or 0.24
end
row.stripe:SetColorTexture(tr, tg, tb, ta)
local m0 = (not entry.separator) and entry.members and entry.members[1] or nil
SetClassIcon(row.icon, m0 and m0.class or nil)
StyleStatusIcons(row, entry)
row.act[1]:SetShown(not entry.separator)
row.act[2]:SetShown(not entry.separator)
row.act[3]:SetShown(RowLFGActionsAllowed(entry))
local sel = (entry == selectedEntry)
if sel then
row.selTex:Show()
if row.accent then row.accent:Show() end
else
row.selTex:Hide()
if row.accent then row.accent:Hide() end
end
if not entry.separator and entry.status == "applied" and (time() - (entry.t or 0)) <= FLASH_WINDOW then
row.flash:Show()
if not row.flashAnim:IsPlaying() then row.flashAnim:Play() end
else
row.flashAnim:Stop()
row.flash:Hide()
end
if entry.separator then
for _, c in ipairs(COLS) do
row.cols[c.key]:SetText(c.key == "name" and entry.separator or "")
end
else
local okR, vals = pcall(EntryColumns, entry)
if okR and vals then
for _, c in ipairs(COLS) do
row.cols[c.key]:SetText(vals[c.key] or "")
end
else
NS._lastRenderError = tostring(vals)
for _, c in ipairs(COLS) do
row.cols[c.key]:SetText(c.key == "name" and "|cffff5555Render error — /lfgalert debug|r" or "")
end
end
end
end
local function VisibleRowCount()
if not listArea then return 1 end
local h = (listArea:GetHeight() or 0) - 8 -- 4px padding top/bottom
local visible = math.floor(h / ROW_HEIGHT + 0.5)
if visible < 1 then visible = 1 end
if visible > MAX_ROWS then visible = MAX_ROWS end
return visible
end
RenderRows = function()
if not listArea then return end
local n = #view
local visible = VisibleRowCount()
local maxOff = math.max(0, n - visible)
if scrollOffset > maxOff then scrollOffset = maxOff end
if scrollOffset < 0 then scrollOffset = 0 end
if scrollBar then
updatingBar = true
scrollBar:SetMinMaxValues(0, maxOff * ROW_HEIGHT)
scrollBar:SetValue(scrollOffset * ROW_HEIGHT)
updatingBar = false
scrollBar:SetShown(n > visible)
end
for i = 1, visible do
local row = rows[i]
if not row then
local okR, r = pcall(MakeRow, i)
if okR and r then
row = r
rows[i] = row
NS._rowsBuilt = (NS._rowsBuilt or 0) + 1
else
NS._rowBuildError = "row " .. i .. ": " .. tostring(r)
return
end
end
RenderRow(row, view[scrollOffset + i], i)
end
for i = visible + 1, #rows do
rows[i]:Hide()
rows[i].entry = nil
end
-- Empty state: say WHY it's empty (no data vs. filter hiding everything).
if n == 0 then
local r = rows[1]
if r then
local log = NS.db and NS.db.log or {}
local hint = (#log == 0) and l("empty_none", "No applicants logged yet — new queues will appear here")
or l("empty_filtered", "No match — set Filter: All and clear the search box")
r:Show()
r.entry = nil
for _, c in ipairs(COLS) do
r.cols[c.key]:SetText(c.key == "name" and ("|cffaaaaaa" .. hint .. "|r") or "")
end
r.icon:SetTexture(nil)
r.selTex:Hide()
if r.accent then r.accent:Hide() end
if r.statusIcons then
for _, ic in ipairs(r.statusIcons) do ic:Hide() end
end
r.flash:Hide()
r.act[1]:Hide()
r.act[2]:Hide()
r.act[3]:Hide()
end
end
end
ScrollBy = function(delta)
scrollOffset = scrollOffset + delta * 3 -- RenderRows clamps + updates the bar
RenderRows()
end
-- ---------------------------------------------------------------------------
-- Filter/menu button labels
-- ---------------------------------------------------------------------------
local function SetButtonLabel(btn, text)
if not btn then return end
if btn.Text then btn.Text:SetText(text) else btn:SetText(text) end
end
local function RefreshFilterButtons()
SetButtonLabel(filterButton, l("fmt_status_btn", "Status: %s"):format(FilterLabel(NS.logFilter.status)))
local cf = NS.logFilter.class or "ALL"
local classLabel = cf == "ALL" and l("filter_all", "All")
or ((LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[cf]) or cf)
SetButtonLabel(classBtn, l("fmt_class_btn", "Class: %s"):format(classLabel))
SetButtonLabel(keyBtn, l("fmt_key_btn", "Key: %s"):format(KeyLabel(NS.logFilter.minKey)))
if resetFiltersBtn then
local active = NS.logFilter.status ~= "ALL" or (NS.logFilter.class or "ALL") ~= "ALL"
or (NS.logFilter.minKey or 0) > 0 or (NS.logFilter.query ~= nil and NS.logFilter.query ~= "")
resetFiltersBtn:SetShown(active)
end
end
local function RefreshHeaderWidgets()
for key, w in pairs(headerWidgets) do
if SORT_VALUE[key] and w then
local arrow = ""
if sortKey == key then
arrow = (sortDir == "asc") and " ^" or " v"
end
w:SetText(w.label .. arrow)
end
end
end
local function ShowClassMenu(anchor)
if MenuUtil and MenuUtil.CreateContextMenu then
MenuUtil.CreateContextMenu(anchor, function(_, root)
root:CreateTitle(l("class_filter_title", "Filter by class"))
root:CreateCheckbox(l("all_classes", "All Classes"),
function() return (NS.logFilter.class or "ALL") == "ALL" end,
function() NS.SetLogClassFilter("ALL") end)
for _, classFile in ipairs(CLASS_ORDER) do
local cf = classFile
root:CreateCheckbox(ClassLabel(cf),
function() return NS.logFilter.class == cf end,
function() NS.SetLogClassFilter(cf) end)
end
end)
return
end
if not LFGAlertClassMenu then
CreateFrame("Frame", "LFGAlertClassMenu", UIParent, "UIDropDownMenuTemplate")
end
local menu = { { text = l("class_filter_title", "Filter by class"), isTitle = true, notCheckable = true },
{ text = l("all_classes", "All Classes"), checked = (NS.logFilter.class or "ALL") == "ALL",
func = function() NS.SetLogClassFilter("ALL") end } }
for _, classFile in ipairs(CLASS_ORDER) do
local cf = classFile
menu[#menu + 1] = { text = ClassLabel(cf), checked = NS.logFilter.class == cf, notCheckable = false,
func = function() NS.SetLogClassFilter(cf) end }
end
EasyMenu(menu, LFGAlertClassMenu, "cursor", 0, 0, "MENU")
end
local function ShowKeyMenu(anchor)
if MenuUtil and MenuUtil.CreateContextMenu then
MenuUtil.CreateContextMenu(anchor, function(_, root)
root:CreateTitle(l("key_filter_title", "Minimum key level"))
for _, kv in ipairs(KEY_OPTIONS) do
local label = kv == 0 and l("all_keys", "All Keys") or l("min_key_fmt", "Minimum +%d"):format(kv)
root:CreateCheckbox(label,
function() return (NS.logFilter.minKey or 0) == kv end,
function() NS.SetLogMinKey(kv) end)
end
end)
return
end
if not LFGAlertKeyMenu then
CreateFrame("Frame", "LFGAlertKeyMenu", UIParent, "UIDropDownMenuTemplate")
end
local menu = { { text = l("key_filter_title", "Minimum key level"), isTitle = true, notCheckable = true } }
for _, kv in ipairs(KEY_OPTIONS) do
local label = kv == 0 and l("all_keys", "All Keys") or l("min_key_fmt", "Minimum +%d"):format(kv)
menu[#menu + 1] = { text = label, checked = (NS.logFilter.minKey or 0) == kv, notCheckable = false,
func = function() NS.SetLogMinKey(kv) end }
end
EasyMenu(menu, LFGAlertKeyMenu, "cursor", 0, 0, "MENU")
end
local function ShowFilterMenu(anchor)
if MenuUtil and MenuUtil.CreateContextMenu then
MenuUtil.CreateContextMenu(anchor, function(_, root)
root:CreateTitle(l("status_filter_title", "Filter by status"))
for _, o in ipairs(FILTER_OPTIONS) do
root:CreateCheckbox(o.label, function() return NS.logFilter.status == o.key end, function()
NS.SetLogFilter(o.key)
end)
end
end)
return
end
if not LFGAlertFilterMenu then
CreateFrame("Frame", "LFGAlertFilterMenu", UIParent, "UIDropDownMenuTemplate")
end
local menu = { { text = l("status_filter_title", "Filter by status"), isTitle = true, notCheckable = true } }
for _, o in ipairs(FILTER_OPTIONS) do
menu[#menu + 1] = { text = o.label, checked = NS.logFilter.status == o.key, notCheckable = false,
func = function() NS.SetLogFilter(o.key) end }
end
EasyMenu(menu, LFGAlertFilterMenu, "cursor", 0, 0, "MENU")
end
-- ---------------------------------------------------------------------------
-- Full refresh: rebuild view + labels, then render rows.
-- ---------------------------------------------------------------------------
RefreshNow = function()
if not (logFrame and listArea) then return end
BuildView()
local n = #view
local log = (NS.db and NS.db.log) or {}
if countLabel then
local total = #log
local suffix = ""
if NS.logFilter.status ~= "ALL" then suffix = suffix .. " • " .. FilterLabel(NS.logFilter.status) end
if (NS.logFilter.class or "ALL") ~= "ALL" then
local cf = NS.logFilter.class
suffix = suffix .. " • " .. ((LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[cf]) or cf)
end
if (NS.logFilter.minKey or 0) > 0 then suffix = suffix .. " • " .. KeyLabel(NS.logFilter.minKey) end
if NS.logFilter.query ~= "" then suffix = suffix .. " • \"" .. NS.logFilter.query .. "\"" end
if NS.db and (NS.db.minIlvl > 0 or NS.db.minScore > 0) then
suffix = suffix .. string.format(" • * %s / %s",
NS.db.minIlvl > 0 and tostring(NS.db.minIlvl) or "-",
NS.db.minScore > 0 and tostring(NS.db.minScore) or "-")
end
countLabel:SetText(l("entries_fmt", "%d of %d entries"):format(n, total) .. suffix)
end
RefreshFilterButtons()
RefreshHeaderWidgets()
-- New arrivals snap to top only if the user is already near the top,
-- so reading history is never yanked around.
if n > lastN and scrollOffset <= 2 then
scrollOffset = 0
elseif n < lastN then
scrollOffset = 0
end
lastN = n
RenderRows()
end
-- Public refresh. Coalesces bursts (several applicants arriving at once
-- render once); pass force=true for immediate user-facing updates.
function NS.RefreshLogUI(force)
if not logFrame then return end
if force then
refreshQueued = false
RefreshNow()
return