This commit is contained in:
Robin 2021-01-13 16:14:31 +01:00
commit cb42d6e48d
7 changed files with 162 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Common"]
path = Common
url = https://git.grml.de/rilgamon/Common.git

1
Common Submodule

@ -0,0 +1 @@
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed

135
core.lua Normal file
View File

@ -0,0 +1,135 @@
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = "zz_Friends"
local crealm = GetRealmName()
local defaults = {
}
local options = {
}
local roster,friendroster,bnetroster = {}, {}, {}
local GuildRoster = GuildRoster
if(C_GuildInfo) then
if(C_GuildInfo.GuildRoster) then
GuildRoster = C_GuildInfo.GuildRoster
end
end
local updateDelay = 15
local fmt = "|c0000ff00%s|r |c00ffffff%s|r"
local db = {}
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local function anymod()
return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown()
end
local function ldbOnClick(self, button)
if(IsInGuild() and not anymod() and button == "LeftButton") then
ToggleGuildFrame()
elseif(not anymod() and (button == "LeftButton" or button == "RightButton")) then
ToggleFriendsFrame()
elseif(IsShiftKeyDown() and button == "LeftButton") then
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
if(ldbicon) then
if(addon['db']['global']['ldbicons'][childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
end
end
local function OnTooltipShow(tip)
tip:AddLine(childName)
tip:AddLine("")
tip:AddLine(format(fmt,"Leftclick","Toggles Guild or Friendframe"))
tip:AddLine(format(fmt,"Rightclick","Toggles Friendframe"))
tip:AddLine(format(fmt,"Shift+Leftclick","Toggles minimap icon"))
end
local function OnText(message)
addon:OnText(childName, message)
end
local function count(v)
local c = 0
for _ in pairs(v) do
c = c + 1
end
return c
end
local function checkRoster(self, event, ...)
local newroster = {}
local rostername, online, _
local dontShow = false
if(event == "GUILD_ROSTER_UPDATE") then
for i=1,GetNumGuildMembers() do
rostername, _, _, _, _, _, _, _, online = GetGuildRosterInfo(i)
if(online and rostername) then
newroster[rostername]=true
end
end
roster = newroster
elseif(event == "FRIENDLIST_UPDATE") then
for i = 1, C_FriendList.GetNumFriends() do
local res = C_FriendList.GetFriendInfoByIndex(i)
if(res) then
if(res['connected'] and res['name']) then
newroster[res['name']] = true
end
end
end
friendroster = newroster
elseif(event == "BN_FRIEND_INFO_CHANGED") then
local _, numOnline = BNGetNumFriends()
local presenceID, isFriend,client,accid
for i = 1, numOnline do
local res = C_BattleNet.GetFriendAccountInfo(i)
if(res) then
local aci = res['gameAccountInfo']
dontShow = false
if(aci) then
if(aci['clientProgram'] == BNET_CLIENT_WOW) then
if(aci['realmName'] == crealm and friendroster[aci['characterName']]) then
dontShow = true
end
end
if(aci['isOnline'] and aci['characterName'] and not dontShow) then
newroster[aci['characterName']] = true
end
end
end
end
bnetroster = newroster
end
local afkmsg = ""
if(UnitIsAFK("player")) then
afkmsg = " AFK"
elseif(UnitIsDND("player")) then
afkmsg = " DND"
end
OnText(format("|c0000ff00%i|r/|c0000ffff%i|r|c00ff0000%s|r", count(roster),count(friendroster)+count(bnetroster),afkmsg))
end
local function OnUpdate()
GuildRoster()
checkRoster(nil, "FRIENDLIST_UPDATE")
checkRoster(nil, "BN_FRIEND_INFO_CHANGED")
C_Timer.After(updateDelay, OnUpdate)
end
local function init()
options = addon:InitConfig(childName, true, {
['name'] = childName,
['type'] = "data source",
['OnTooltipShow'] = OnTooltipShow,
['OnClick'] = ldbOnClick,
})
db = addon['db']['profile'][childName]
crealm = GetRealmName()
addon:RegisterFunc({"GUILD_ROSTER_UPDATE","FRIENDLIST_UPDATE","CHAT_MSG_CHANNEL_JOIN","CHAT_MSG_CHANNEL_LEAVE","PLAYER_FLAGS_CHANGED","UNIT_FLAGS","BN_FRIEND_INFO_CHANGED"},"OnEvent", checkRoster)
C_Timer.After(updateDelay, OnUpdate)
C_FriendList.ShowFriends()
end
addon:startup(name, childName, init, true, defaults)

BIN
icon2.tga Normal file

Binary file not shown.

6
license.txt Normal file
View File

@ -0,0 +1,6 @@
The following license excludes the libraries (Libs) included. See the libraries directory or website.
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
If you use/offer this addon on another website please remove my name.
If you want to give me credit you can replace it with a link to my profile on WoWInterface.com.

3
pack.xml Normal file
View File

@ -0,0 +1,3 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="core.lua"/>
</Ui>

14
zz_Friends.toc Normal file
View File

@ -0,0 +1,14 @@
## Interface: 90002
## X-Repository: https://svn.grml.de/zz_Friends
## X-WoWI-ID: 18761
## X-Curse-Project-ID: 39075
## X-TOC-Classic: 11302
## Title: Friends Broker
## Notes: Displays friends and guildmembers online
## Notes-deDE: Zeigt Freunde und Gildenmitglieder, die online sind
## Author: Rilgamon
## SavedVariables: zz_FriendsDB
## OptionalDeps: Ace3,BrokerPack,zzLibCommon
Common\common.xml
pack.xml