commit cb42d6e48db13655a78a3a880292e1620226a2b9 Author: Robin Date: Wed Jan 13 16:14:31 2021 +0100 Init diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..34950ac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Common"] + path = Common + url = https://git.grml.de/rilgamon/Common.git diff --git a/Common b/Common new file mode 160000 index 0000000..762c59c --- /dev/null +++ b/Common @@ -0,0 +1 @@ +Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed diff --git a/core.lua b/core.lua new file mode 100644 index 0000000..1f2074c --- /dev/null +++ b/core.lua @@ -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) diff --git a/icon2.tga b/icon2.tga new file mode 100644 index 0000000..0a4689d Binary files /dev/null and b/icon2.tga differ diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..6d2e364 --- /dev/null +++ b/license.txt @@ -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. \ No newline at end of file diff --git a/pack.xml b/pack.xml new file mode 100644 index 0000000..0f7eacc --- /dev/null +++ b/pack.xml @@ -0,0 +1,3 @@ + +