Thread Tools Display Modes
05-21-24, 04:24 AM   #1
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 128
Tips for Premade Groups

Hi all. I was faced with the problem that I needed to add a hint to the name of the group. For example the word "Hello". How to do it?

So that the tooltip is at the very bottom or below the player's name. I did this option (but it didn’t work). Tell me how to make it work?
Lua Code:
  1. local function OnEnter(self)
  2.     if self and self.resultID then
  3.         GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
  4.         GameTooltip:SetText("Hello")
  5.         GameTooltip:Show()
  6.     end
  7. end
  8.  
  9. local function OnLeave(self)
  10.     GameTooltip:Hide()
  11. end
  12.  
  13. local function HookButtons()
  14.     local buttons = LFGListFrame.SearchPanel.ScrollBox:GetChildren()
  15.     for _, button in pairs({buttons:GetChildren()}) do
  16.         button:HookScript("OnEnter", OnEnter)
  17.         button:HookScript("OnLeave", OnLeave)
  18.     end
  19. end
  20.  
  21. local eventFrame = CreateFrame("Frame")
  22. eventFrame:RegisterEvent("ADDON_LOADED")
  23. eventFrame:RegisterEvent("LFG_LIST_SEARCH_RESULTS_RECEIVED")
  24. eventFrame:SetScript("OnEvent", function(self, event, arg1)
  25.     if event == "ADDON_LOADED" and arg1 == "HelloHover" then
  26.         HookButtons()
  27.     elseif event == "LFG_LIST_SEARCH_RESULTS_RECEIVED" then
  28.         HookButtons()
  29.     end
  30. end)
  Reply With Quote
05-22-24, 03:06 AM   #2
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 128
I tried this option. But it didn't work either.
Lua Code:
  1. -- Function to display the tooltip with "Hello"
  2. local function ShowTooltip(self)
  3.     GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
  4.     GameTooltip:SetText("Hello", 1, 1, 1, 1, true)
  5.     GameTooltip:Show()
  6. end
  7.  
  8. -- Function to hide the tooltip
  9. local function HideTooltip(self)
  10.     GameTooltip:Hide()
  11. end
  12.  
  13. -- Function to hook the premade group buttons
  14. local function HookPremadeGroupButtons()
  15.     local LFGListFrame = _G["LFGListFrame"]
  16.     local buttons = LFGListFrame.SearchPanel.ScrollFrame.buttons
  17.  
  18.     for _, button in ipairs(buttons) do
  19.         button:HookScript("OnEnter", ShowTooltip)
  20.         button:HookScript("OnLeave", HideTooltip)
  21.     end
  22. end
  23.  
  24. -- Event frame to wait until LFG UI is loaded
  25. local eventFrame = CreateFrame("Frame")
  26. eventFrame:RegisterEvent("ADDON_LOADED")
  27. eventFrame:SetScript("OnEvent", function(self, event, addonName)
  28.     if addonName == "Blizzard_LookingForGroupUI" then
  29.         HookPremadeGroupButtons()
  30.         self:UnregisterEvent("ADDON_LOADED")
  31.     end
  32. end)
  Reply With Quote
05-22-24, 03:22 AM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,335
I'd suggest taking a look at LFGListUtil_SetSearchEntryTooltip(). This is the function responsible for generating the tooltip for the search result entry. This is called from LFGListSearchEntry_OnEnter().

A few additional notes:
  1. The only legitimate reason to wait for your own ADDON_LOADED event is if you need to process your SavedVariables before the addon can run.
  2. Calling :HookScript() endlessly stacks your hook function on top of itself until it crashes the game.
  3. If you want to make sure your code runs after another function, you need to hook a function/script. Events call registered frames in a completely random order. There's no guarantee your code will run after your intended target.




As for your second post, I don't see Blizzard_LookingForGroupUI existing in any current client.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 05-22-24 at 06:23 AM.
  Reply With Quote
05-22-24, 07:24 AM   #4
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 128
Originally Posted by SDPhantom View Post
I'd suggest taking a look at LFGListUtil_SetSearchEntryTooltip(). This is the function responsible for generating the tooltip for the search result entry. This is called from LFGListSearchEntry_OnEnter().

A few additional notes:
  1. The only legitimate reason to wait for your own ADDON_LOADED event is if you need to process your SavedVariables before the addon can run.
  2. Calling :HookScript() endlessly stacks your hook function on top of itself until it crashes the game.
  3. If you want to make sure your code runs after another function, you need to hook a function/script. Events call registered frames in a completely random order. There's no guarantee your code will run after your intended target.




As for your second post, I don't see Blizzard_LookingForGroupUI existing in any current client.
Thank you very much it worked. But it seems that in order to display the correct number of "threads" you need to see this player. It was not possible to display through pre-assembled groups.


Lua Code:
  1. -- Ensure FACTION_STRINGS is defined
  2. if not FACTION_STRINGS then
  3.     FACTION_STRINGS = {
  4.         [0] = "Neutral",
  5.         [1] = "Alliance",
  6.         [2] = "Horde",
  7.     }
  8. end
  9.  
  10. -- Define the function for formatting numbers
  11. local function formatNumber(num)
  12.     local formattedNum, color
  13.     if num < 1000 then
  14.         formattedNum = tostring(num)
  15.     elseif num < 1000000 then
  16.         formattedNum = string.format("%.2fK", num / 1000)
  17.     else
  18.         formattedNum = string.format("%.2fM", num / 1000000)
  19.     end
  20.    
  21.     if num >= 40000 then
  22.         color = "|cffFF8000" -- Orange
  23.     elseif num >= 20000 then
  24.         color = "|cffA335EE" -- Purple
  25.     elseif num >= 10000 then
  26.         color = "|cff0070FF" -- Blue
  27.     elseif num > 5000 then
  28.         color = "|cff00FF00" -- Green
  29.     else
  30.         color = "|cffFFFFFF" -- White
  31.     end
  32.    
  33.     return formattedNum, color
  34. end
  35.  
  36. local L = {
  37.     ["en"] = {
  38.         ["Threads"] = "Threads",
  39.     },
  40.     ["de"] = {
  41.         ["Threads"] = "Themen",
  42.     },
  43. }
  44.  
  45. function LFGListUtil_SetSearchEntryTooltip(tooltip, resultID, autoAcceptOption)
  46.     local searchResultInfo = C_LFGList.GetSearchResultInfo(resultID)
  47.     local activityInfo = C_LFGList.GetActivityInfoTable(searchResultInfo.activityID, nil, searchResultInfo.isWarMode)
  48.     local categoryInfo = C_LFGList.GetLfgCategoryInfo(activityInfo.categoryID)
  49.     local allowsCrossFaction = (categoryInfo and categoryInfo.allowCrossFaction) and (activityInfo and activityInfo.allowCrossFaction)
  50.  
  51.     local memberCounts = C_LFGList.GetSearchResultMemberCounts(resultID)
  52.     tooltip:SetText(searchResultInfo.name, 1, 1, 1, true)
  53.  
  54.     -- Calculate and format the total threads value
  55.     local totalThreads = 0
  56.     local unit = "player"  -- Default to "player" if no unit is specified
  57.     if resultID then
  58.         unit = C_LFGList.GetSearchResultMemberInfo(resultID, 1)  -- Assuming unit is retrieved this way, adjust if needed
  59.     end
  60.  
  61.     local isPlayer = UnitIsPlayer(unit)
  62.     if isPlayer then
  63.         local aura = C_UnitAuras.GetAuraDataBySpellName(unit, "Timerunner's Advantage")
  64.         if aura then
  65.             for i = 1, 9 do
  66.                 local stat = aura.points[i]
  67.                 totalThreads = totalThreads + stat
  68.             end
  69.         end
  70.     end
  71.  
  72.     local formattedThreads, threadsColor = formatNumber(totalThreads)
  73.     local currentLocale = GetLocale()
  74.     local threadsText = L[currentLocale] and L[currentLocale]["Threads"] or "Threads"
  75.     tooltip:AddLine("\n" .. threadsColor .. threadsText .. " " .. formattedThreads)
  76.  
  77.     tooltip:AddLine(activityName)
  78.  
  79.     if searchResultInfo.playstyle > 0 then
  80.         local playstyleString = C_LFGList.GetPlaystyleString(searchResultInfo.playstyle, activityInfo)
  81.         if not searchResultInfo.crossFactionListing and allowsCrossFaction then
  82.             GameTooltip_AddColoredLine(tooltip, GROUP_FINDER_CROSS_FACTION_LISTING_WITH_PLAYSTLE:format(playstyleString, FACTION_STRINGS[searchResultInfo.leaderFactionGroup]), GREEN_FONT_COLOR)
  83.         else
  84.             GameTooltip_AddColoredLine(tooltip, playstyleString, GREEN_FONT_COLOR)
  85.         end
  86.     elseif not searchResultInfo.crossFactionListing and allowsCrossFaction then
  87.         GameTooltip_AddColoredLine(tooltip, GROUP_FINDER_CROSS_FACTION_LISTING_WITHOUT_PLAYSTLE:format(FACTION_STRINGS[searchResultInfo.leaderFactionGroup]), GREEN_FONT_COLOR)
  88.     end
  89.     if searchResultInfo.comment and searchResultInfo.comment == "" and searchResultInfo.questID then
  90.         searchResultInfo.comment = LFGListUtil_GetQuestDescription(searchResultInfo.questID)
  91.     end
  92.     if searchResultInfo.comment ~= "" then
  93.         tooltip:AddLine(string.format(LFG_LIST_COMMENT_FORMAT, searchResultInfo.comment), LFG_LIST_COMMENT_FONT_COLOR.r, LFG_LIST_COMMENT_FONT_COLOR.g, LFG_LIST_COMMENT_FONT_COLOR.b, true)
  94.     end
  95.     tooltip:AddLine(" ")
  96.     if searchResultInfo.requiredDungeonScore > 0 then
  97.         tooltip:AddLine(GROUP_FINDER_MYTHIC_RATING_REQ_TOOLTIP:format(searchResultInfo.requiredDungeonScore))
  98.     end
  99.     if searchResultInfo.requiredPvpRating > 0 then
  100.         tooltip:AddLine(GROUP_FINDER_PVP_RATING_REQ_TOOLTIP:format(searchResultInfo.requiredPvpRating))
  101.     end
  102.     if searchResultInfo.requiredItemLevel > 0 then
  103.         if activityInfo.isPvpActivity then
  104.             tooltip:AddLine(LFG_LIST_TOOLTIP_ILVL_PVP:format(searchResultInfo.requiredItemLevel))
  105.         else
  106.             tooltip:AddLine(LFG_LIST_TOOLTIP_ILVL:format(searchResultInfo.requiredItemLevel))
  107.         end
  108.     end
  109.     if activityInfo.useHonorLevel and searchResultInfo.requiredHonorLevel > 0 then
  110.         tooltip:AddLine(LFG_LIST_TOOLTIP_HONOR_LEVEL:format(searchResultInfo.requiredHonorLevel))
  111.     end
  112.     if searchResultInfo.voiceChat ~= "" then
  113.         tooltip:AddLine(string.format(LFG_LIST_TOOLTIP_VOICE_CHAT, searchResultInfo.voiceChat), nil, nil, nil, true)
  114.     end
  115.     if searchResultInfo.requiredItemLevel > 0 or (activityInfo.useHonorLevel and searchResultInfo.requiredHonorLevel > 0) or searchResultInfo.voiceChat ~= "" or searchResultInfo.requiredDungeonScore > 0 or searchResultInfo.requiredPvpRating > 0 then
  116.         tooltip:AddLine(" ")
  117.     end
  118.  
  119.     if searchResultInfo.leaderName then
  120.         local factionString = searchResultInfo.leaderFactionGroup and FACTION_STRINGS[searchResultInfo.leaderFactionGroup]
  121.         if factionString and (UnitFactionGroup("player") ~= PLAYER_FACTION_GROUP[searchResultInfo.leaderFactionGroup]) then
  122.             tooltip:AddLine(LFG_LIST_TOOLTIP_LEADER_FACTION:format(searchResultInfo.leaderName, factionString))
  123.         else
  124.             tooltip:AddLine(string.format(LFG_LIST_TOOLTIP_LEADER, searchResultInfo.leaderName))
  125.         end
  126.     end
  127.  
  128.     if activityInfo.isRatedPvpActivity and searchResultInfo.leaderPvpRatingInfo then
  129.         GameTooltip_AddNormalLine(tooltip, PVP_RATING_GROUP_FINDER:format(searchResultInfo.leaderPvpRatingInfo.activityName, searchResultInfo.leaderPvpRatingInfo.rating, PVPUtil.GetTierName(searchResultInfo.leaderPvpRatingInfo.tier)))
  130.     elseif isMythicPlusActivity and searchResultInfo.leaderOverallDungeonScore then
  131.         local color = C_ChallengeMode.GetDungeonScoreRarityColor(searchResultInfo.leaderOverallDungeonScore)
  132.         if not color then
  133.             color = HIGHLIGHT_FONT_COLOR
  134.         end
  135.         GameTooltip_AddNormalLine(tooltip, DUNGEON_SCORE_LEADER:format(color:WrapTextInColorCode(searchResultInfo.leaderOverallDungeonScore)))
  136.     end
  137.  
  138.     if activityInfo.isMythicPlusActivity and searchResultInfo.leaderDungeonScoreInfo then
  139.         local leaderDungeonScoreInfo = searchResultInfo.leaderDungeonScoreInfo
  140.         local color = C_ChallengeMode.GetSpecificDungeonOverallScoreRarityColor(leaderDungeonScoreInfo.mapScore)
  141.         if not color then
  142.             color = HIGHLIGHT_FONT_COLOR
  143.         end
  144.         if leaderDungeonScoreInfo.mapScore == 0 then
  145.             GameTooltip_AddNormalLine(tooltip, DUNGEON_SCORE_PER_DUNGEON_NO_RATING:format(leaderDungeonScoreInfo.mapName, leaderDungeonScoreInfo.mapScore))
  146.         elseif leaderDungeonScoreInfo.finishedSuccess then
  147.             GameTooltip_AddNormalLine(tooltip, DUNGEON_SCORE_DUNGEON_RATING:format(leaderDungeonScoreInfo.mapName, color:WrapTextInColorCode(leaderDungeonScoreInfo.mapScore), leaderDungeonScoreInfo.bestRunLevel))
  148.         else
  149.             GameTooltip_AddNormalLine(tooltip, DUNGEON_SCORE_DUNGEON_RATING_OVERTIME:format(leaderDungeonScoreInfo.mapName, color:WrapTextInColorCode(leaderDungeonScoreInfo.mapScore), leaderDungeonScoreInfo.bestRunLevel))
  150.         end
  151.     end
  152.     if searchResultInfo.age > 0 then
  153.         tooltip:AddLine(string.format(LFG_LIST_TOOLTIP_AGE, SecondsToTime(searchResultInfo.age, false, false, 1, false)))
  154.     end
  155.  
  156.     if searchResultInfo.leaderName or searchResultInfo.age > 0 then
  157.         tooltip:AddLine(" ")
  158.     end
  159.  
  160.     if activityInfo.displayType == Enum.LFGListDisplayType.ClassEnumerate then
  161.         tooltip:AddLine(string.format(LFG_LIST_TOOLTIP_MEMBERS_SIMPLE, searchResultInfo.numMembers))
  162.         for i = 1, searchResultInfo.numMembers do
  163.             local role, class, classLocalized, specLocalized = C_LFGList.GetSearchResultMemberInfo(resultID, i)
  164.             local classColor = RAID_CLASS_COLORS[class] or NORMAL_FONT_COLOR
  165.             tooltip:AddLine(string.format(LFG_LIST_TOOLTIP_CLASS_ROLE, classLocalized, specLocalized), classColor.r, classColor.g, classColor.b)
  166.         end
  167.     else
  168.         tooltip:AddLine(string.format(LFG_LIST_TOOLTIP_MEMBERS, searchResultInfo.numMembers, memberCounts.TANK, memberCounts.HEALER, memberCounts.DAMAGER))
  169.     end
  170.  
  171.     if searchResultInfo.numBNetFriends + searchResultInfo.numCharFriends + searchResultInfo.numGuildMates > 0 then
  172.         tooltip:AddLine(" ")
  173.         tooltip:AddLine(LFG_LIST_TOOLTIP_FRIENDS_IN_GROUP)
  174.         tooltip:AddLine(LFGListSearchEntryUtil_GetFriendList(resultID), 1, 1, 1, true)
  175.     end
  176.  
  177.     local completedEncounters = C_LFGList.GetSearchResultEncounterInfo(resultID)
  178.     if completedEncounters and #completedEncounters > 0 then
  179.         tooltip:AddLine(" ")
  180.         tooltip:AddLine(LFG_LIST_BOSSES_DEFEATED)
  181.         for i = 1, #completedEncounters do
  182.             tooltip:AddLine(completedEncounters[i], RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b)
  183.         end
  184.     end
  185.  
  186.     autoAcceptOption = autoAcceptOption or LFG_LIST_UTIL_ALLOW_AUTO_ACCEPT_LINE
  187.  
  188.     if autoAcceptOption == LFG_LIST_UTIL_ALLOW_AUTO_ACCEPT_LINE and searchResultInfo.autoAccept then
  189.         tooltip:AddLine(" ")
  190.         tooltip:AddLine(LFG_LIST_TOOLTIP_AUTO_ACCEPT, LIGHTBLUE_FONT_COLOR:GetRGB())
  191.     end
  192.  
  193.     if searchResultInfo.isDelisted then
  194.         tooltip:AddLine(" ")
  195.         tooltip:AddLine(LFG_LIST_ENTRY_DELISTED, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, true)
  196.     end
  197.  
  198.     tooltip:Show()
  199. end

  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Tips for Premade Groups


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off