From b041d981efd37c6001259c35fd99c6824370424f Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 1 Dec 2020 16:36:35 +0100 Subject: [PATCH] panel: show online friends on mouse over --- modules/panel.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/panel.lua b/modules/panel.lua index 56dec8d0..f1acf200 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -306,6 +306,26 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function() local widget = CreateFrame("Frame", "pfPanelWidgetFriends", UIParent) widget:RegisterEvent("PLAYER_ENTERING_WORLD") widget:RegisterEvent("FRIENDLIST_UPDATE") + widget.Tooltip = function() + GameTooltip_SetDefaultAnchor(GameTooltip, this) + GameTooltip:ClearLines() + GameTooltip:AddLine("|cff555555" .. T["Friends Online"]) + + local all = GetNumFriends() + local playerzone = GetRealZoneText() + + for friendIndex=1, all do + local friend_name, friend_level, friend_class, friend_area, friend_connected = GetFriendInfo(friendIndex) + if friend_connected and friend_class and friend_level then + local ccolor = RAID_CLASS_COLORS[L["class"][friend_class]] or { 1, 1, 1 } + local lcolor = GetDifficultyColor(tonumber(friend_level)) or { 1, 1, 1 } + local zcolor = friend_area == playerzone and "|cff33ffcc" or "|cffcccccc" + GameTooltip:AddDoubleLine(rgbhex(ccolor) .. friend_name .. rgbhex(lcolor) .. " [" .. friend_level .. "]", zcolor .. friend_area) + end + end + + GameTooltip:Show() + end widget.Click = function() ToggleFriendsFrame(1) end widget:SetScript("OnEvent", function() local online = 0 @@ -317,7 +337,7 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function() end end - pfUI.panel:OutputPanel("friends", FRIENDS .. ": " .. online, nil, widget.Click) + pfUI.panel:OutputPanel("friends", FRIENDS .. ": " .. online, widget.Tooltip, widget.Click) end) end