Code:
local AWAY_ICON = "|TInterface\\FriendsFrame\\StatusIcon-Away:20:20:0:-1|t"
local BUSY_ICON = "|TInterface\\FriendsFrame\\StatusIcon-DnD:20:20:0:-1|t"
local MOBILE_ICON = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat:20:20:0:-1:16:16:0:16:0:16:0:255:0|t"
local MOBILE_AWAY = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat:20:20:0:-1:16:16:0:16:0:16:255:204:0|t"
local MOBILE_BUSY = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat:20:20:0:-1:16:16:0:16:0:16:255:0:0|t"
local ONLINE_ICON = "|TInterface\\FriendsFrame\\StatusIcon-Online:20:20:0:-1|t"
local _, class = UnitClass("player")
local color = RAID_CLASS_COLORS[class]
local r,g,b = color.r, color.g, color.b
local Folks = CreateFrame("Frame", "StatBlock_Folks")
local L_FRIENDS = format("|cff%02x%02x%02xFriends: |r",r*255,g*255,b*255)
local L_REALID = format("|cff%02x%02x%02xReal ID:|r",r*255,g*255,b*255)
Folks.friends = LibStub("LibDataBroker-1.1"):NewDataObject("Folks_Friends", {type = "data source", text = L_FRIENDS.. "0 ", value = 0, suffix = L_FRIENDS})
local L_TOOLTIP_F = "\n|cffeda55fClick|r to open the friends panel"
local L_TOOLTIP_G = "\n|cffeda55fClick|r to open the guild panel"
local format = string.format
Folks:RegisterEvent("PLAYER_LOGIN")
Folks:SetScript("OnEvent", function(self, event) self[event](self) end)
function Folks:PLAYER_LOGIN()
if IsInGuild() then GuildRoster() end
ShowFriends()
end
-- System message when a friend or guild member is added/removed
Folks:RegisterEvent("CHAT_MSG_SYSTEM")
Folks.CHAT_MSG_SYSTEM = Folks.PLAYER_LOGIN
local function GetTipAnchor(frame)
local x,y = frame:GetCenter()
if not x or not y then return "TOPLEFT", "BOTTOMLEFT" end
local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or ""
local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM"
return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
end
----------------------------
-- Friends --
----------------------------
Folks:RegisterEvent("FRIENDLIST_UPDATE")
function Folks:FRIENDLIST_UPDATE()
local bnTotal, bnCount = BNGetNumFriends()
local fTotal, fCount = GetNumFriends()
local total = bnCount+fCount
self.friends.text = format(" %s %d/%d", L_FRIENDS,fCount + bnCount, fTotal + bnTotal)
self.friends.value = format(" %s %d/%d", L_FRIENDS, fCount + bnCount, fTotal + bnTotal)
if GameTooltip:IsShown() and GameTooltipTextLeft1:GetText() == L_FRIENDS then
self.friends.OnEnter(nil, "update")
end
end
local function RGB2Hex(c)
return format("%02x%02x%02x", c.r*255, c.g*255, c.b*255)
end
local function Friend2Color(class)
local result
for k,v in pairs(_G["LOCALIZED_CLASS_NAMES_FEMALE"]) do
if v == class then
result = k
end
end
if not result then
for k,v in pairs(_G["LOCALIZED_CLASS_NAMES_MALE"]) do
if v == class then
result = k
end
end
end
local c = _G["CUSTOM_CLASS_COLORS"] and _G["CUSTOM_CLASS_COLORS"][result] or _G["RAID_CLASS_COLORS"][result]
return RGB2Hex(c)
end
local fFrame
function Folks.friends.OnEnter(frame, update)
local bnTotal, bnCount = BNGetNumFriends()
local fTotal, fCount = GetNumFriends()
if frame and not fFrame then
fFrame = frame
end
GameTooltip:SetOwner(fFrame, "ANCHOR_NONE")
GameTooltip:SetPoint(GetTipAnchor(fFrame))
if not update then
GameTooltip:AddDoubleLine(L_FRIENDS, " ")
GameTooltip:Show()
ShowFriends()
return
end
local bnTotal, bnCount = BNGetNumFriends()
local fTotal, fCount = GetNumFriends()
if bnTotal and bnTotal > 0 then
GameTooltip:AddDoubleLine(L_REALID, format("[%d/%d]", bnCount, bnTotal), 1, 1, 1, r, g, b)
for i=1, bnCount do
local _, name, _, _, _, _, _, isOnline, _, isAfk, isDnd = BNGetFriendInfo(i)
if isOnline then
local toon = BNGetNumFriendToons(i)
for j = 1, toon do
local _, toonName, client, _, _, _, class, _, zoneName, level, gametext = BNGetFriendToonInfo(i, j)
local status = ONLINE_ICON
if isAfk then
status = AWAY_ICON
elseif isDnd then
status = BUSY_ICON
end
if client == "WoW" then
local difficultyColor = RGB2Hex(GetQuestDifficultyColor(tonumber(level) or 1))
local classColor = Friend2Color(class)
local groupIndicator = ""
local zoneColor = " |cffffffff"
zoneName = zoneName or _G["UNKNOWN"]
if realmName == GetRealmName() then
if zoneName and (zoneName == GetRealZoneText() or zoneName == GetMapNameByID(GetCurrentMapAreaID())) then
zoneColor = " |cff0fff0f"
else
zoneColor = " |cffffff00"
end
else
zoneColor = " |cff7f7f7f"
end
GameTooltip:AddDoubleLine(
format("%s |cff%s%d|r |cff%s%s|r", status, difficultyColor, level, classColor, toonName),
zoneColor..zoneName.."|r"
)
else
GameTooltip:AddDoubleLine(
name..note, status.."|cffffffff"..client.."("..(gametext or "")..")".."|r"
)
end
end
end
end
if fTotal > 0 then
GameTooltip:AddDoubleLine(" ", " ")
end
end
if fTotal > 0 then
GameTooltip:AddDoubleLine("Friends:", format("[%d/%d]", fCount, fTotal), r, g, b, r, g, b)
for i = 1, fCount do
local name, level, class, zone, _, status = GetFriendInfo(i)
local difficultyColor = RGB2Hex(GetQuestDifficultyColor(level))
local classColor = Friend2Color(class)
local groupIndicator = ""
local zoneColor = " |cffffffff"
if zone and (zone == GetRealZoneText() or zone == GetMapNameByID(GetCurrentMapAreaID())) then
zoneColor = " |cff0fff0f"
else
zoneColor = " |cffffff00"
end
if status == CHAT_FLAG_AFK then
status = AWAY_ICON
elseif status == CHAT_FLAG_DND then
status = BUSY_ICON
else
status = ONLINE_ICON
end
GameTooltip:AddDoubleLine(
format("%s |cff%s%d|r |cff%s%s|r", status, difficultyColor, level, classColor, name),
zoneColor..zone.."|r"
)
end
end
GameTooltip:Show()
end
function Folks.friends.OnLeave()
GameTooltip:Hide()
end
function Folks.friends.OnClick()
ToggleFriendsFrame(1)
end
----------------------------
-- Guild --
----------------------------
local L_GUILD = format("|cff%02x%02x%02x Guild: |r",r*255,g*255,b*255)
Folks.guild = LibStub("LibDataBroker-1.1"):NewDataObject("Folks_Guild", {type = "data source", text = "", value = "", suffix = ""})
Folks:RegisterEvent("PLAYER_GUILD_UPDATE")
Folks:RegisterEvent("GUILD_ROSTER_UPDATE")
function Folks:GUILD_ROSTER_UPDATE()
if not IsInGuild() then return end
local total, _,totalonline = GetNumGuildMembers()
self.guild.text = format("%s/%d", L_GUILD.. totalonline, total)
self.guild.value = format("%s/%d", L_GUILD.. totalonline, total)
if GameTooltip:IsShown() and GameTooltipTextLeft1:GetText() == L_GUILD then
self.guild.OnEnter()
end
end
Folks.PLAYER_GUILD_UPDATE = Folks.GUILD_ROSTER_UPDATE
local function Guild2Color(class)
local c = _G["CUSTOM_CLASS_COLORS"] and _G["CUSTOM_CLASS_COLORS"][class] or _G["RAID_CLASS_COLORS"][class]
return RGB2Hex(c)
end
local gFrame
local GetGuildRosterInfo = GetGuildRosterInfo
function Folks.guild.OnEnter(frame)
if not IsInGuild() then return end
if frame and not gFrame then
gFrame = frame
end
GuildRoster()
GameTooltip:SetOwner(gFrame, "ANCHOR_NONE")
GameTooltip:SetPoint(GetTipAnchor(gFrame))
local total, online = GetNumGuildMembers()
GameTooltip:AddLine(GetGuildRosterMOTD().."\n", 1, 0.8, 0, true)
for i = 1, (GetNumGuildMembers()) do
local name, rank, _, level, _, zone, _, _, online, status, trueClass, _, _, isMobile = GetGuildRosterInfo(i)
if online or isMobile then
local difficultyColor = RGB2Hex(GetQuestDifficultyColor(level))
local classColor = Guild2Color(trueClass)
local zoneColor = " |cffffffff"
if zone and (zone == GetRealZoneText() or zone == GetMapNameByID(GetCurrentMapAreaID())) then
zoneColor = " |cff0fff0f"
else
zoneColor = " |cffffff00"
end
if status == 0 then
status = ONLINE_ICON
elseif status == 1 then
status = AWAY_ICON
elseif status == 2 then
status = BUSY_ICON
end
if isMobile and status == AWAY_ICON then
status = MOBILE_AWAY
zone = "Remote Chat"
end
if isMobile and status == BUSY_ICON then
status = MOBILE_BUSY
zone = "Remote Chat"
end
if isMobile and status == ONLINE_ICON then
status = MOBILE_ICON
zone = "Remote Chat"
end
GameTooltip:AddDoubleLine(
format("%s |cff%s%d|r |cff%s%s|r - |cff1ae6ff[%s]|r", status, difficultyColor, level, classColor, name, rank),
zoneColor..zone.."|r"
)
end
end
GameTooltip:Show()
end
function Folks.guild.OnLeave()
GameTooltip:Hide()
end
function Folks.guild.OnClick()
ToggleGuildFrame()
end
Now with Icons.
I have big dudes....
How can I do for make colums in a tootlip?.
How can I do for add a separator?.