Go to Page... |
Thread Tools | Display Modes |
10-18-13, 05:38 PM | #1 |
Question about status in "GetFriendInfo"
Hi I explain:
I am using a data broker to do that. The part or BNGetFriendInfo(i) its ok for "isAfk, isDnd" but the part of normal friends with GetFriendInfo(i) dont work as I want. I just want put a text [+] before the name of the char, in my friends list and real ID friends. The text is colored depends of the status of the player, for example red for DND and yelow for AFK and green for online. Anyone know how can I do it?. Thanks. I am working with a base of statblock_Folks. The code is: Code:
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" do local L = GetLocale() if L == "zhTW" then L_TOOLTIP_F = "\n|cffeda55f點擊|r 開啟好友名單" L_TOOLTIP_G = "\n|cffeda55f點擊|r 開啟公會名單" elseif L == "zhCN" then L_TOOLTIP_F = "\n|cffeda55f点击|r 开启好友名单" L_TOOLTIP_G = "\n|cffeda55f点击|r 开启公会名单" end end 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 local GetFriendInfo = GetFriendInfo local BNGetFriendInfo = BNGetFriendInfo function Folks.friends.OnEnter(frame, update) 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 _, class = UnitClass("player") local color = RAID_CLASS_COLORS[class] local r,g,b = color.r, color.g, color.b 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, _, note = BNGetFriendInfo(i) if isOnline then local toon = BNGetNumFriendToons(i) for j = 1, toon do local _, toonName, client, realmName, _, _, _, class, _, zoneName, level, gametext = BNGetFriendToonInfo(i, j) local status = "|cff00ff00[+]|r" if note and note ~= "" then note = " [|cffffffff"..note.."|r]" else note = "" end if isAfk then status = "|cffffcc00[+]|r" elseif isDnd then status = "|cffff1a1a[+]|r" 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 UnitInParty(toonName) or UnitInRaid(toonName) then groupIndicator = "|cff0fff0f+|r" end 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(L_FRIENDS, format("[%d/%d]", fCount, fTotal), 1, 1, 1, r, g, b) for i = 1, fCount do local name, level, class, zone, _, status, note = GetFriendInfo(i) local difficultyColor = RGB2Hex(GetQuestDifficultyColor(level)) local classColor = Friend2Color(class) local groupIndicator = "" local zoneColor = " |cffffffff" if UnitInParty(name) or UnitInRaid(name) then groupIndicator = "|cff0fff0f+|r" end note = note or "" zone = zone or _G["UNKNOWN"] if note ~= "" then note = " [|cffffffff"..note.."|r]" end if zone and (zone == GetRealZoneText() or zone == GetMapNameByID(GetCurrentMapAreaID())) then zoneColor = " |cff0fff0f" else zoneColor = " |cffffff00" end if status == 0 then status = "|cff00ff00[+]|r" elseif status == 1 then status = "|cffffcc00[+]|r" elseif status == 2 then status = "|cffff1a1a[+]|r" 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 _, class = UnitClass("player") local color = RAID_CLASS_COLORS[class] local r,g,b = color.r, color.g, color.b local total = GetNumGuildMembers() 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 =L_GUILD.. "0 ", value = L_GUILD.. "0", suffix = ""}) Folks:RegisterEvent("PLAYER_GUILD_UPDATE") Folks:RegisterEvent("GUILD_ROSTER_UPDATE") function Folks:GUILD_ROSTER_UPDATE() if not IsInGuild() then return end local _, online = GetNumGuildMembers() self.guild.text = format("%d %s", online, L_GUILD) self.guild.value = format("%s/%d", L_GUILD.. online, 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, online do local name, rank, _, level, _, zone, note, officernote, online, status, trueClass = GetGuildRosterInfo(i) if online then local difficultyColor = RGB2Hex(GetQuestDifficultyColor(level)) local guildRankNoteText = " |cff1ae6ff["..rank.."]|r" local classColor = Guild2Color(trueClass) local groupIndicator = "" local zoneColor = " |cffffffff" if UnitInParty(name) or UnitInRaid(name) then groupIndicator = "|cff0fff0f+|r" end if note ~= "" and not CanViewOfficerNote() then guildRankNoteText = guildRankNoteText.."[|cffffffff"..note.."|r]" end if CanViewOfficerNote() and officernote ~= "" then guildRankNoteText = guildRankNoteText.."[|cffffffff"..officernote.."|r]" end if zone and (zone == GetRealZoneText() or zone == GetMapNameByID(GetCurrentMapAreaID())) then zoneColor = " |cff0fff0f" else zoneColor = " |cffffffff" end if status == 0 then status = "|cff00ff00[+]|r" elseif status == 1 then status = "|cffffcc00[+]|r" elseif status == 2 then status = "|cffff1a1a[+]|r" end GameTooltip:AddDoubleLine( format("%s |cff%s%d|r |cff%s%s|r - %s", status, difficultyColor, level, classColor, name, guildRankNoteText), zoneColor..(zone or _G["UNKNOWN"]).."|r" ) end end GameTooltip:Show() end function Folks.guild.OnLeave() GameTooltip:Hide() end function Folks.guild.OnClick() ToggleGuildFrame() end Last edited by Akatosh : 10-19-13 at 12:21 AM. |
|
10-19-13, 03:59 PM | #2 |
Ok I found the solution:
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 I have big dudes.... How can I do for make colums in a tootlip?. How can I do for add a separator?. Last edited by Akatosh : 10-20-13 at 08:05 AM. |
|
10-20-13, 04:21 AM | #3 |
For a simple separator, you can simply add a line full of "separator" characters to the tooltip:
Code:
GameTooltip:AddLine("---------------------------------")
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
10-20-13, 08:53 AM | #4 | |
Thanks for the reply!! I think that make tooltips with LibQTip is very difficult, atleast for me..., I see the code of brokers like MicroMenu or Arabroker, and I dont understand nothing.... For the part of separartor I have a dude. Imagine that the tooltip is smaller than the "separators", the most secure that thy add and intro and take a Ugly appareance, or the opposite case, the "separator" dont be enought to fill the space. I put 2 examples: 1st example: ________________________ |Text | |--------------------------| | --------<- (Separator) | |Text | |_______________________| 2nd example: _______________________________________ |Text | |--------------------------------- <-(separator) | | |Text | |______________________________________| How can I do to fix that? Thanks!!. |
||
10-20-13, 05:18 PM | #5 |
Now I get that error when a Real ID is on
Now I have a big problem, When A Real ID friend is online get that error:
When? When I mouseover the element of friends, and when I have a real ID friend ON. Code:
Message: Interface\AddOns\StatBlock_Folks\StatBlock_Folks.lua:55: attempt to index local 'c' (a nil value) Time: 10/21/13 01:14:43 Count: 1 Stack: Interface\AddOns\StatBlock_Folks\StatBlock_Folks.lua:55: in function <Interface\AddOns\StatBlock_Folks\StatBlock_Folks.lua:54> (tail call): ? Interface\AddOns\StatBlock_Folks\StatBlock_Folks.lua:115: in function `OnEnter' Interface\AddOns\StatBlock_Folks\StatBlock_Folks.lua:50: in function `?' Interface\AddOns\StatBlock_Folks\StatBlock_Folks.lua:19: in function <Interface\AddOns\StatBlock_Folks\StatBlock_Folks.lua:19> Locals: c = nil (*temporary) = <function> defined =[C]:-1 (*temporary) = "%02x%02x%02x" (*temporary) = nil (*temporary) = nil (*temporary) = nil (*temporary) = "attempt to index local 'c' (a nil value)" format = <function> defined =[C]:-1[/b] The code what I am using, is a base of statblockcore folks, a little modified: 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) local L_UPDATE = format("|cff%02x%02x%02xUpdating ... |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 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_UPDATE 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_UPDATE, " ") 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 Thanks. Update: I rewrite all and and dont understand nothing, I just Copy - Paste lines and with no reason now works. The only what I do is hold a few of original lines, that I dont use for nothing, but now works ok... I dont understand nothing.... Code:
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) local L_UPDATE = format("|cff%02x%02x%02xUpdating ... |r",r*255,g*255,b*255) 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" Folks.friends = LibStub("LibDataBroker-1.1"):NewDataObject("Folks_Friends", {type = "data source", text = "0 "..L_FRIENDS, 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_UPDATE 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 GetFriendInfo = GetFriendInfo local BNGetFriendInfo = BNGetFriendInfo 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_UPDATE, " ") 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), r, g, b, r, g, b) for i=1, bnCount do local _, name, _, _, _, _, _, isOnline, _, isAfk, isDnd, _, note = BNGetFriendInfo(i) if isOnline then local toon = BNGetNumFriendToons(i) for j = 1, toon do local _, toonName, client, realmName, _, _, _, class, _, zoneName, level, gametext = BNGetFriendToonInfo(i, j) local status = ONLINE_ICON if note and note ~= "" then note = " [|cffffffff"..note.."|r]" else note = "" end 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 UnitInParty(toonName) or UnitInRaid(toonName) then groupIndicator = "|cff0fff0f+|r" end 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, note = GetFriendInfo(i) local difficultyColor = RGB2Hex(GetQuestDifficultyColor(level)) local classColor = Friend2Color(class) local groupIndicator = "" local zoneColor = " |cffffffff" if UnitInParty(name) or UnitInRaid(name) then groupIndicator = "|cff0fff0f+|r" end note = note or "" zone = zone or _G["UNKNOWN"] if note ~= "" then note = " [|cffffffff"..note.."|r]" end 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 = "0 "..L_GUILD, value = 0, suffix = L_GUILD}) 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, note, officernote, online, status, trueClass, _, _, isMobile = GetGuildRosterInfo(i) if online or isMobile then local difficultyColor = RGB2Hex(GetQuestDifficultyColor(level)) local guildRankNoteText = " [|cffffffff"..rank.."|r]" local classColor = Guild2Color(trueClass) local groupIndicator = "" local zoneColor = " |cffffffff" if UnitInParty(name) or UnitInRaid(name) then groupIndicator = "|cff0fff0f+|r" end if note ~= "" and not CanViewOfficerNote() then guildRankNoteText = guildRankNoteText.."[|cffffffff"..note.."|r]" end if CanViewOfficerNote() and officernote ~= "" then guildRankNoteText = guildRankNoteText.."[|cffffffff"..officernote.."|r]" end 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 Last edited by Akatosh : 10-21-13 at 01:36 AM. |
|
WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Question about Ara_Broker Guild Friends. |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|