@@ -8,6 +8,8 @@ local ipairs = ipairs
88
99local C_AddOns_IsAddOnLoaded = C_AddOns .IsAddOnLoaded
1010
11+ local ROLE_ICON_PATTERN = " ^|A:groupfinder%-icon%-role%-micro"
12+
1113local function GetIconString (role , mode )
1214 local template
1315 if mode == " NORMAL" then
@@ -19,6 +21,66 @@ local function GetIconString(role, mode)
1921 return format (template , UF .RoleIconTextures [role ])
2022end
2123
24+ -- Clean empty or whitespace-only text from tooltip line
25+ --- @param line FontString The tooltip line to check
26+ local function clearEmptyTooltipLine (line )
27+ if line then
28+ local raw = line :GetText ()
29+ if raw and gsub (raw , " %s+$" , " " ) == " " then
30+ line :SetText (" " )
31+ end
32+ end
33+ end
34+
35+ -- Cleanup all Blizzard Group Info
36+ --- @param tooltip GameTooltip The tooltip to clean up
37+ local function cleanupBlizzardGroupInfo (tooltip )
38+ local delistedFound = false
39+ local titleFound = false
40+
41+ for i = 5 , tooltip :NumLines () do
42+ local line = _G [" GameTooltipTextLeft" .. i ] --- @type FontString ?
43+ local raw = line and line :GetText ()
44+ --- @cast line FontString
45+ if raw then
46+ if raw == _G .MEMBERS_COLON then
47+ line :SetText (" " )
48+ clearEmptyTooltipLine (_G [" GameTooltipTextLeft" .. (i - 1 )])
49+ clearEmptyTooltipLine (_G [" GameTooltipTextLeft" .. (i - 2 )])
50+ titleFound = true
51+ elseif raw == _G .LFG_LIST_ENTRY_DELISTED then
52+ delistedFound = true
53+ elseif titleFound then
54+ if strfind (raw , ROLE_ICON_PATTERN ) then
55+ line :SetText (" " )
56+ else
57+ clearEmptyTooltipLine (line )
58+ end
59+ end
60+ end
61+ end
62+
63+ return delistedFound
64+ end
65+
66+ -- Helper function to add role information with proper spacing
67+ local function addRoleInformation (tooltip , data , config )
68+ for _ , role in ipairs (LFGPI :GetRoleOrder ()) do
69+ local roleData = data [role ]
70+ if # roleData > 0 then
71+ if config .mode == " NORMAL" then
72+ tooltip :AddLine (" " )
73+ tooltip :AddLine (GetIconString (role , " NORMAL" ) .. " " .. LFGPI .GetColoredRoleName (role ))
74+ end
75+
76+ for _ , line in ipairs (roleData ) do
77+ local icon = config .mode == " COMPACT" and GetIconString (role , " COMPACT" ) or " "
78+ tooltip :AddLine (icon .. " " .. line )
79+ end
80+ end
81+ end
82+ end
83+
2284function T :AddGroupInfo (tooltip , resultID )
2385 local config = E .db .WT .tooltips .groupInfo
2486 if not config or not config .enable then
@@ -29,48 +91,27 @@ function T:AddGroupInfo(tooltip, resultID)
2991 return
3092 end
3193
32- if config .hideBlizzard then
33- local titleFound = false
34- for i = 5 , tooltip :NumLines () do
35- local text = _G [" GameTooltipTextLeft" .. i ]
36- local raw = text and text :GetText ()
37-
38- if raw == _G .MEMBERS_COLON then
39- text :SetText (" " )
40- titleFound = true
41- elseif titleFound and raw and strfind (raw , " ^|A:groupfinder%-icon%-role%-micro" ) then
42- text :SetText (" " )
43- end
44- end
45- end
46-
4794 LFGPI :SetClassIconStyle (config .classIconStyle )
4895 LFGPI :Update (resultID )
4996
50- -- split line
51- if config .title then
52- tooltip :AddLine (" " )
53- tooltip :AddLine (W .Title .. " " .. L [" Party Info" ])
54- end
55-
56- -- compact Mode
57- if config .mode == " COMPACT" then
97+ local foundDelisted = false
98+ if config .hideBlizzard then
99+ foundDelisted = cleanupBlizzardGroupInfo (tooltip )
100+ else
58101 tooltip :AddLine (" " )
59102 end
60103
61- -- add info
62- local data = LFGPI :GetPartyInfo (config .template )
63-
64- for order , role in ipairs (LFGPI :GetRoleOrder ()) do
65- if # data [role ] > 0 and config .mode == " NORMAL" then
104+ if config .title then
105+ if foundDelisted then
106+ -- If the line already exists (we need to add a separator)
66107 tooltip :AddLine (" " )
67- tooltip :AddLine (GetIconString (role , " NORMAL" ) .. " " .. LFGPI .GetColoredRoleName (role ))
68108 end
109+ tooltip :AddLine (W .Title .. " " .. L [" Party Info" ])
110+ end
69111
70- for _ , line in ipairs (data [role ]) do
71- local icon = config .mode == " COMPACT" and GetIconString (role , " COMPACT" ) or " "
72- tooltip :AddLine (icon .. " " .. line )
73- end
112+ local data = LFGPI :GetPartyInfo (config .template )
113+ if data then
114+ addRoleInformation (tooltip , data , config )
74115 end
75116
76117 tooltip :Show ()
0 commit comments