Commit c217d70c authored by Azilroka's avatar Azilroka

Friend Groups - Work

parent 1e314ef1
...@@ -396,9 +396,9 @@ function EFL:Initialize() ...@@ -396,9 +396,9 @@ function EFL:Initialize()
EFL:RegisterEvent("BN_CONNECTED", 'HandleBN') EFL:RegisterEvent("BN_CONNECTED", 'HandleBN')
EFL:RegisterEvent("BN_DISCONNECTED", 'HandleBN') EFL:RegisterEvent("BN_DISCONNECTED", 'HandleBN')
--if PA.db.FG then if PA.db.FriendGroups and PA.db.FriendGroups.Enable then
-- EFL:SecureHook(PA.FG, 'FriendGroups_UpdateFriendButton', function(self, button) EFL:UpdateFriends(button) end) EFL:SecureHook(_G.FriendGroups, 'FriendGroups_UpdateFriendButton', function(_, button) EFL:UpdateFriends(button) end)
--else else
EFL:SecureHook("FriendsFrame_UpdateFriendButton", 'UpdateFriends') EFL:SecureHook("FriendsFrame_UpdateFriendButton", 'UpdateFriends')
--end end
end end
local PA = _G.ProjectAzilroka local PA = _G.ProjectAzilroka
local FG = PA:NewModule('FriendGroup', 'AceEvent-3.0', 'AceTimer-3.0', 'AceHook-3.0') local FG = PA:NewModule('FriendGroups', 'AceEvent-3.0', 'AceTimer-3.0', 'AceHook-3.0')
_G.FriendGroup = FG _G.FriendGroups= FG
FG.Title = PA.ACL['|cFF16C3F2Friend|r |cFFFFFFFFGroups|r'] FG.Title = 'Friend Groups'
FG.Desciption = PA.ACL['Manage Firends List with Groups'] FG.Header = PA.ACL['|cFF16C3F2Friend|r |cFFFFFFFFGroups|r']
FG.Description = PA.ACL['Manage Firends List with Groups']
FG.Authors = 'Azilroka' FG.Authors = 'Azilroka'
FG.Credits = 'Mikeprod frankkkkk' FG.Credits = 'Mikeprod frankkkkk'
local hooks = {}
local function Hook(source, target, secure)
hooks[source] = _G[source]
if secure then
hooksecurefunc(source, target)
else
_G[source] = target
end
end
local FRIENDS_GROUP_NAME_COLOR = NORMAL_FONT_COLOR local FRIENDS_GROUP_NAME_COLOR = NORMAL_FONT_COLOR
local INVITE_RESTRICTION_NO_TOONS = 0
local INVITE_RESTRICTION_CLIENT = 1
local INVITE_RESTRICTION_LEADER = 2
local INVITE_RESTRICTION_FACTION = 3
local INVITE_RESTRICTION_INFO = 4
local INVITE_RESTRICTION_NONE = 5
local ONE_MINUTE = 60 local ONE_MINUTE = 60
local ONE_HOUR = 60 * ONE_MINUTE local ONE_HOUR = 60 * ONE_MINUTE
local ONE_DAY = 24 * ONE_HOUR local ONE_DAY = 24 * ONE_HOUR
local ONE_MONTH = 30 * ONE_DAY local ONE_MONTH = 30 * ONE_DAY
local ONE_YEAR = 12 * ONE_MONTH local ONE_YEAR = 12 * ONE_MONTH
local FriendButtons = { count = 0 } local FriendListEntries = {}
local GroupCount = 0 local GroupCount = 0
local GroupTotal = {} local GroupTotal = {}
local GroupOnline = {} local GroupOnline = {}
local GroupSorted = {} local GroupSorted = {}
local FriendRequestString = string.sub(FRIEND_REQUESTS,1,-5) local FriendRequestString = string.sub(FRIEND_REQUESTS,1,-6)
local OPEN_DROPDOWNMENUS_SAVE = nil local OPEN_DROPDOWNMENUS_SAVE = nil
local friend_popup_menus = { "FRIEND", "FRIEND_OFFLINE", "BN_FRIEND", "BN_FRIEND_OFFLINE" } local friend_popup_menus = { "FRIEND", "FRIEND_OFFLINE", "BN_FRIEND", "BN_FRIEND_OFFLINE" }
UnitPopupButtons["FRIEND_GROUP_NEW"] = { text = "Create new group", dist = 0 }
UnitPopupButtons["FRIEND_GROUP_ADD"] = { text = "Add to group", dist = 0, nested = 1 } UnitPopupButtons["FRIEND_GROUP_NEW"] = { text = "Create new group"}
UnitPopupButtons["FRIEND_GROUP_DEL"] = { text = "Remove from group", dist = 0, nested = 1 } UnitPopupButtons["FRIEND_GROUP_ADD"] = { text = "Add to group", nested = 1}
UnitPopupButtons["FRIEND_GROUP_DEL"] = { text = "Remove from group", nested = 1}
UnitPopupMenus["FRIEND_GROUP_ADD"] = { } UnitPopupMenus["FRIEND_GROUP_ADD"] = { }
UnitPopupMenus["FRIEND_GROUP_DEL"] = { } UnitPopupMenus["FRIEND_GROUP_DEL"] = { }
local function ClassColourCode(class,table) local FriendsScrollFrame
local initialClass = class local FriendButtonTemplate
for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do
if class == v then if FriendsListFrameScrollFrame then
class = k FriendsScrollFrame = FriendsListFrameScrollFrame
break FriendButtonTemplate = "FriendsListButtonTemplate"
end else
end FriendsScrollFrame = FriendsFrameFriendsScrollFrame
if class == initialClass then FriendButtonTemplate = "FriendsFrameButtonTemplate"
for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do
if class == v then
class = k
break
end
end
end
if table then
return RAID_CLASS_COLORS[class]
else
local colour = RAID_CLASS_COLORS[class]
return string.format("|cFF%02x%02x%02x", colour.r*255, colour.g*255, colour.b*255)
end
end end
local function FriendGroups_GetTopButton(offset) function FG:FriendGroups_GetTopButton(offset)
local usedHeight = 0 local usedHeight = 0
for i = 1, FriendButtons.count do for i = 1, #FriendListEntries do
local buttonHeight = FRIENDS_BUTTON_HEIGHTS[FriendButtons[i].buttonType] local buttonHeight = FRIENDS_BUTTON_HEIGHTS[FriendListEntries[i].buttonType]
if ( usedHeight + buttonHeight >= offset ) then if ( usedHeight + buttonHeight >= offset ) then
return i - 1, offset - usedHeight return i - 1, offset - usedHeight
else else
usedHeight = usedHeight + buttonHeight usedHeight = usedHeight + buttonHeight
end end
end end
return 0,0
end end
local function FriendGroups_UpdateFriendButton(button) function FG:GetOnlineInfoText(client, isMobile, rafLinkType, locationText)
if not locationText or locationText == "" then
return UNKNOWN
end
if isMobile then
return LOCATION_MOBILE_APP
end
if (client == BNET_CLIENT_WOW) and (rafLinkType ~= Enum.RafLinkType.None) and not isMobile then
if rafLinkType == Enum.RafLinkType.Recruit then
return RAF_RECRUIT_FRIEND:format(locationText)
else
return RAF_RECRUITER_FRIEND:format(locationText)
end
end
return locationText
end
function FG:FriendGroups_UpdateFriendButton(button)
local index = button.index local index = button.index
button.buttonType = FriendButtons[index].buttonType button.buttonType = FriendListEntries[index].buttonType
button.id = FriendButtons[index].id button.id = FriendListEntries[index].id
local height = FRIENDS_BUTTON_HEIGHTS[button.buttonType] local height = FRIENDS_BUTTON_HEIGHTS[button.buttonType]
local nameText, nameColor, infoText, broadcastText local nameText, nameColor, infoText, broadcastText, isFavoriteFriend
local hasTravelPassButton = false if button.buttonType == FRIENDS_BUTTON_TYPE_WOW then
if ( button.buttonType == FRIENDS_BUTTON_TYPE_WOW ) then local info = C_FriendList.GetFriendInfoByIndex(FriendListEntries[index].id)
local name, level, class, area, connected, status, note, isRaF, guid = GetFriendInfo(FriendButtons[index].id)
broadcastText = nil broadcastText = nil
if ( connected ) then if info.connected then
button.background:SetColorTexture(FRIENDS_WOW_BACKGROUND_COLOR.r, FRIENDS_WOW_BACKGROUND_COLOR.g, FRIENDS_WOW_BACKGROUND_COLOR.b, FRIENDS_WOW_BACKGROUND_COLOR.a) button.background:SetColorTexture(FRIENDS_WOW_BACKGROUND_COLOR.r, FRIENDS_WOW_BACKGROUND_COLOR.g, FRIENDS_WOW_BACKGROUND_COLOR.b, FRIENDS_WOW_BACKGROUND_COLOR.a)
if ( status == "" ) then if info.afk then
button.status:SetTexture(FRIENDS_TEXTURE_ONLINE)
elseif ( status == CHAT_FLAG_AFK ) then
button.status:SetTexture(FRIENDS_TEXTURE_AFK) button.status:SetTexture(FRIENDS_TEXTURE_AFK)
elseif ( status == CHAT_FLAG_DND ) then elseif ( info.dnd ) then
button.status:SetTexture(FRIENDS_TEXTURE_DND) button.status:SetTexture(FRIENDS_TEXTURE_DND)
else
button.status:SetTexture(FRIENDS_TEXTURE_ONLINE)
end end
if FriendGroups_SavedVars.colour_classes then nameColor = PA:ClassColorCode(info.gameAccountInfo.className)
nameColor = ClassColourCode(class,true)
else nameText = info.name..", "..format(FRIENDS_LEVEL_TEMPLATE, info.level, info.className)
nameColor = FRIENDS_WOW_NAME_COLOR if PA.Retail then
infoText = FG:GetOnlineInfoText(BNET_CLIENT_WOW, info.mobile, info.rafLinkType, info.area)
end end
nameText = name..", "..format(FRIENDS_LEVEL_TEMPLATE, level, class)
else else
button.background:SetColorTexture(FRIENDS_OFFLINE_BACKGROUND_COLOR.r, FRIENDS_OFFLINE_BACKGROUND_COLOR.g, FRIENDS_OFFLINE_BACKGROUND_COLOR.b, FRIENDS_OFFLINE_BACKGROUND_COLOR.a) button.background:SetColorTexture(FRIENDS_OFFLINE_BACKGROUND_COLOR.r, FRIENDS_OFFLINE_BACKGROUND_COLOR.g, FRIENDS_OFFLINE_BACKGROUND_COLOR.b, FRIENDS_OFFLINE_BACKGROUND_COLOR.a)
button.status:SetTexture(FRIENDS_TEXTURE_OFFLINE) button.status:SetTexture(FRIENDS_TEXTURE_OFFLINE)
nameText = name nameText = info.name
nameColor = FRIENDS_GRAY_COLOR nameColor = FRIENDS_GRAY_COLOR
infoText = FRIENDS_LIST_OFFLINE
end end
infoText = area
button.gameIcon:Hide() button.gameIcon:Hide()
button.summonButton:ClearAllPoints() button.summonButton:ClearAllPoints()
button.summonButton:SetPoint("TOPRIGHT", button, "TOPRIGHT", 1, -1) button.summonButton:SetPoint("TOPRIGHT", button, "TOPRIGHT", 1, -1)
FriendsFrame_SummonButton_Update(button.summonButton) FriendsFrame_SummonButton_Update(button.summonButton)
elseif ( button.buttonType == FRIENDS_BUTTON_TYPE_BNET ) then elseif button.buttonType == FRIENDS_BUTTON_TYPE_BNET then
local bnetIDAccount, accountName, battleTag, isBattleTag, characterName, bnetIDGameAccount, client, isOnline, lastOnline, isBnetAFK, isBnetDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(FriendButtons[index].id) local accountInfo = PA:GetBattleNetInfo(button.id);
broadcastText = messageText if accountInfo then
-- set up player name and character name nameText = accountInfo.accountName
local characterName = characterName infoText = accountInfo.gameAccountInfo.richPresence
if ( accountName ) then
nameText = accountName if accountInfo.gameAccountInfo.isOnline then
if ( isOnline ) then button.background:SetColorTexture(FRIENDS_BNET_BACKGROUND_COLOR.r, FRIENDS_BNET_BACKGROUND_COLOR.g, FRIENDS_BNET_BACKGROUND_COLOR.b, FRIENDS_BNET_BACKGROUND_COLOR.a)
characterName = BNet_GetValidatedCharacterName(characterName, battleTag, client) if accountInfo.isAFK or accountInfo.gameAccountInfo.isGameAFK then
end button.status:SetTexture(FRIENDS_TEXTURE_AFK)
else elseif accountInfo.isDND or accountInfo.gameAccountInfo.isGameBusy then
nameText = UNKNOWN button.status:SetTexture(FRIENDS_TEXTURE_DND)
end
-- append character name
if ( characterName ) then
if ( client == BNET_CLIENT_WOW and CanCooperateWithGameAccount(bnetIDGameAccount) ) then
local level = select(11, BNGetGameAccountInfo(bnetIDGameAccount))
if FriendGroups_SavedVars.colour_classes then
local class = select(8, BNGetGameAccountInfo(bnetIDGameAccount))
nameText = nameText.." "..ClassColourCode(class).."("..characterName.."-"..level..")"..FONT_COLOR_CODE_CLOSE
else
nameText = nameText.." "..FRIENDS_WOW_NAME_COLOR_CODE.."("..characterName.."-"..level..")"..FONT_COLOR_CODE_CLOSE
end
else
local level = select(11, BNGetGameAccountInfo(bnetIDGameAccount))
if ( ENABLE_COLORBLIND_MODE == "1" ) then
characterName = characterName..CANNOT_COOPERATE_LABEL
end
if level ~= "" then
nameText = nameText.." "..FRIENDS_OTHER_NAME_COLOR_CODE.."("..characterName.."-"..level..")"..FONT_COLOR_CODE_CLOSE
else else
nameText = nameText.." "..FRIENDS_OTHER_NAME_COLOR_CODE.."("..characterName..")"..FONT_COLOR_CODE_CLOSE button.status:SetTexture(FRIENDS_TEXTURE_ONLINE)
end end
end
end
if ( isOnline ) then if accountInfo.gameAccountInfo.clientProgram == BNET_CLIENT_WOW and accountInfo.gameAccountInfo.wowProjectID == WOW_PROJECT_ID then
local _, _, _, realmName, realmID, faction, _, _, _, zoneName, _, gameText, _, _, _, _, _, isGameAFK, isGameBusy, guid = BNGetGameAccountInfo(bnetIDGameAccount) if not accountInfo.gameAccountInfo.areaName or accountInfo.gameAccountInfo.areaName == "" then
button.background:SetColorTexture(FRIENDS_BNET_BACKGROUND_COLOR.r, FRIENDS_BNET_BACKGROUND_COLOR.g, FRIENDS_BNET_BACKGROUND_COLOR.b, FRIENDS_BNET_BACKGROUND_COLOR.a) infoText = UNKNOWN
if ( isBnetAFK or isGameAFK ) then else
button.status:SetTexture(FRIENDS_TEXTURE_AFK) infoText = accountInfo.gameAccountInfo.isWowMobile and LOCATION_MOBILE_APP or info.gameAccountInfo.areaName
elseif ( isBnetDND or isGameBusy ) then end
button.status:SetTexture(FRIENDS_TEXTURE_DND)
else
button.status:SetTexture(FRIENDS_TEXTURE_ONLINE)
end
if ( client == BNET_CLIENT_WOW ) then
if ( not zoneName or zoneName == "" ) then
infoText = UNKNOWN
else
infoText = zoneName
end end
else
infoText = gameText
end
button.gameIcon:SetTexture(BNet_GetClientTexture(client))
nameColor = FRIENDS_BNET_NAME_COLOR
--Note - this logic should match the logic in FriendsFrame_ShouldShowSummonButton button.gameIcon:SetTexture(BNet_GetClientTexture(accountInfo.gameAccountInfo.clientProgram))
nameColor = FRIENDS_BNET_NAME_COLOR
local shouldShowSummonButton = FriendsFrame_ShouldShowSummonButton(button.summonButton) local fadeIcon = (accountInfo.gameAccountInfo.clientProgram == BNET_CLIENT_WOW) and (accountInfo.gameAccountInfo.wowProjectID ~= WOW_PROJECT_ID)
button.gameIcon:SetShown(not shouldShowSummonButton) button.gameIcon:SetAlpha(fadeIcon and .6 or 1)
-- travel pass local shouldShowSummonButton = FriendsFrame_ShouldShowSummonButton(button.summonButton)
hasTravelPassButton = true button.gameIcon:SetShown(not shouldShowSummonButton)
local restriction = FriendsFrame_GetInviteRestriction(button.id)
if ( restriction == INVITE_RESTRICTION_NONE ) then local restriction = FriendsFrame_GetInviteRestriction(button.id)
button.travelPassButton:Enable() button.travelPassButton:SetEnabled(restriction == INVITE_RESTRICTION_NONE)
else button.travelPassButton:SetShown(restriction == INVITE_RESTRICTION_NONE)
button.travelPassButton:Disable()
end
else
button.background:SetColorTexture(FRIENDS_OFFLINE_BACKGROUND_COLOR.r, FRIENDS_OFFLINE_BACKGROUND_COLOR.g, FRIENDS_OFFLINE_BACKGROUND_COLOR.b, FRIENDS_OFFLINE_BACKGROUND_COLOR.a)
button.status:SetTexture(FRIENDS_TEXTURE_OFFLINE)
nameColor = FRIENDS_GRAY_COLOR
button.gameIcon:Hide()
if ( not lastOnline or lastOnline == 0 or time() - lastOnline >= ONE_YEAR ) then
infoText = FRIENDS_LIST_OFFLINE
else else
infoText = string.format(BNET_LAST_ONLINE_TIME, FriendsFrame_GetLastOnline(lastOnline)) button.background:SetColorTexture(FRIENDS_OFFLINE_BACKGROUND_COLOR.r, FRIENDS_OFFLINE_BACKGROUND_COLOR.g, FRIENDS_OFFLINE_BACKGROUND_COLOR.b, FRIENDS_OFFLINE_BACKGROUND_COLOR.a)
button.status:SetTexture(FRIENDS_TEXTURE_OFFLINE)
nameColor = FRIENDS_GRAY_COLOR
button.gameIcon:Hide()
if ( not lastOnline or lastOnline == 0 or time() - lastOnline >= ONE_YEAR ) then
infoText = FRIENDS_LIST_OFFLINE
else
infoText = string.format(BNET_LAST_ONLINE_TIME, FriendsFrame_GetLastOnline(lastOnline))
end
end end
button.summonButton:ClearAllPoints()
button.summonButton:SetPoint("CENTER", button.gameIcon, "CENTER", 1, 0)
FriendsFrame_SummonButton_Update(button.summonButton)
end end
button.summonButton:ClearAllPoints()
button.summonButton:SetPoint("CENTER", button.gameIcon, "CENTER", 1, 0)
FriendsFrame_SummonButton_Update(button.summonButton)
elseif ( button.buttonType == FRIENDS_BUTTON_TYPE_DIVIDER ) then elseif ( button.buttonType == FRIENDS_BUTTON_TYPE_DIVIDER ) then
local title local title
local group = FriendButtons[index].text local group = FriendListEntries[index].text
if group == "" or not group then if group == "" or not group then
title = "[no group]" title = "[no group]"
else else
title = group title = group
end end
button.text:SetText(title)
button.text:Show()
local counts = "(" .. GroupOnline[group] .. "/" .. GroupTotal[group] .. ")" local counts = "(" .. GroupOnline[group] .. "/" .. GroupTotal[group] .. ")"
nameText = counts
nameColor = FRIENDS_GROUP_NAME_COLOR
button.name:SetJustifyH("RIGHT")
if FriendGroups_SavedVars.collapsed[group] then if button["text"] then
button.status:SetTexture("Interface\\Buttons\\UI-PlusButton-UP") button.text:SetText(title)
button.text:Show()
nameText = counts
button.name:SetJustifyH("RIGHT")
else else
button.status:SetTexture("Interface\\Buttons\\UI-MinusButton-UP") nameText = title.." "..counts
button.name:SetJustifyH("CENTER")
end end
nameColor = FRIENDS_GROUP_NAME_COLOR
-- if FriendGroups_SavedVars.collapsed[group] then
-- button.status:SetTexture("Interface\\Buttons\\UI-PlusButton-UP")
-- else
button.status:SetTexture("Interface\\Buttons\\UI-MinusButton-UP")
-- end
infoText = group infoText = group
button.info:Hide() button.info:Hide()
button.gameIcon:Hide() button.gameIcon:Hide()
button.background:SetColorTexture(FRIENDS_OFFLINE_BACKGROUND_COLOR.r, FRIENDS_OFFLINE_BACKGROUND_COLOR.g, FRIENDS_OFFLINE_BACKGROUND_COLOR.b, FRIENDS_OFFLINE_BACKGROUND_COLOR.a) button.background:SetColorTexture(FRIENDS_OFFLINE_BACKGROUND_COLOR.r, FRIENDS_OFFLINE_BACKGROUND_COLOR.g, FRIENDS_OFFLINE_BACKGROUND_COLOR.b, FRIENDS_OFFLINE_BACKGROUND_COLOR.a)
button.background:SetAlpha(0.5) button.background:SetAlpha(0.5)
local scrollFrame = FriendsFrameFriendsScrollFrame local scrollFrame = FriendsScrollFrame
local divider = scrollFrame.dividerPool:Acquire() --[[local divider = scrollFrame.dividerPool:Acquire()
divider:SetParent(scrollFrame.ScrollChild) divider:SetParent(scrollFrame.ScrollChild)
divider:SetAllPoints(button) divider:SetAllPoints(button)
divider:Show() divider:Show()--]]
elseif ( button.buttonType == FRIENDS_BUTTON_TYPE_INVITE_HEADER ) then elseif ( button.buttonType == FRIENDS_BUTTON_TYPE_INVITE_HEADER ) then
local header = FriendsFrameFriendsScrollFrame.PendingInvitesHeaderButton local header = FriendsScrollFrame.PendingInvitesHeaderButton
header:SetPoint("TOPLEFT", button, 1, 0) header:SetPoint("TOPLEFT", button, 1, 0)
header:Show() header:Show()
header:SetFormattedText(FRIEND_REQUESTS, BNGetNumFriendInvites()) header:SetFormattedText(FRIEND_REQUESTS, BNGetNumFriendInvites())
...@@ -255,7 +212,7 @@ local function FriendGroups_UpdateFriendButton(button) ...@@ -255,7 +212,7 @@ local function FriendGroups_UpdateFriendButton(button)
end end
nameText = nil nameText = nil
elseif ( button.buttonType == FRIENDS_BUTTON_TYPE_INVITE ) then elseif ( button.buttonType == FRIENDS_BUTTON_TYPE_INVITE ) then
local scrollFrame = FriendsFrameFriendsScrollFrame local scrollFrame = FriendsScrollFrame
local invite = scrollFrame.invitePool:Acquire() local invite = scrollFrame.invitePool:Acquire()
invite:SetParent(scrollFrame.ScrollChild) invite:SetParent(scrollFrame.ScrollChild)
invite:SetAllPoints(button) invite:SetAllPoints(button)
...@@ -266,14 +223,8 @@ local function FriendGroups_UpdateFriendButton(button) ...@@ -266,14 +223,8 @@ local function FriendGroups_UpdateFriendButton(button)
invite.inviteIndex = button.id invite.inviteIndex = button.id
nameText = nil nameText = nil
end end
-- travel pass?
if ( hasTravelPassButton ) then
button.travelPassButton:Show()
else
button.travelPassButton:Hide()
end
-- selection -- selection
if ( FriendsFrame.selectedFriendType == FriendButtons[index].buttonType and FriendsFrame.selectedFriend == FriendButtons[index].id ) then if ( FriendsFrame.selectedFriendType == FriendListEntries[index].buttonType and FriendsFrame.selectedFriend == FriendListEntries[index].id ) then
button:LockHighlight() button:LockHighlight()
else else
button:UnlockHighlight() button:UnlockHighlight()
...@@ -281,7 +232,9 @@ local function FriendGroups_UpdateFriendButton(button) ...@@ -281,7 +232,9 @@ local function FriendGroups_UpdateFriendButton(button)
-- finish setting up button if it's not a header -- finish setting up button if it's not a header
if ( nameText ) then if ( nameText ) then
if button.buttonType ~= FRIENDS_BUTTON_TYPE_DIVIDER then if button.buttonType ~= FRIENDS_BUTTON_TYPE_DIVIDER then
if button["text"] then
button.text:Hide() button.text:Hide()
end
button.name:SetJustifyH("LEFT") button.name:SetJustifyH("LEFT")
button.background:SetAlpha(1) button.background:SetAlpha(1)
button.info:Show() button.info:Show()
...@@ -290,26 +243,34 @@ local function FriendGroups_UpdateFriendButton(button) ...@@ -290,26 +243,34 @@ local function FriendGroups_UpdateFriendButton(button)
button.name:SetTextColor(nameColor.r, nameColor.g, nameColor.b) button.name:SetTextColor(nameColor.r, nameColor.g, nameColor.b)
button.info:SetText(infoText) button.info:SetText(infoText)
button:Show() button:Show()
if isFavoriteFriend and button.Favorite then
button.Favorite:Show()
button.Favorite:ClearAllPoints()
button.Favorite:SetPoint("TOPLEFT", button.name, "TOPLEFT", button.name:GetStringWidth(), 0)
elseif button.Favorite then
button.Favorite:Hide()
end
else else
button:Hide() button:Hide()
end end
-- update the tooltip if hovering over a button -- update the tooltip if hovering over a button
if ( FriendsTooltip.button == button ) then if ( FriendsTooltip.button == button ) or ( GetMouseFocus() == button ) then
FriendsFrameTooltip_Show(button) if FriendsFrameTooltip_Show then
end FriendsFrameTooltip_Show(button)
if ( GetMouseFocus() == button ) then else
FriendsFrameTooltip_Show(button) button:OnEnter()
end
end end
return height return height
end end
local function FriendGroups_UpdateFriends() function FG:FriendGroups_UpdateFriends()
local scrollFrame = FriendsFrameFriendsScrollFrame local scrollFrame = FriendsScrollFrame
local offset = HybridScrollFrame_GetOffset(scrollFrame) local offset = HybridScrollFrame_GetOffset(scrollFrame)
local buttons = scrollFrame.buttons local buttons = scrollFrame.buttons
local numButtons = #buttons local numButtons = #buttons
local numFriendButtons = FriendButtons.count local numFriendListEntries = #FriendListEntries
local usedHeight = 0 local usedHeight = 0
...@@ -319,9 +280,9 @@ local function FriendGroups_UpdateFriends() ...@@ -319,9 +280,9 @@ local function FriendGroups_UpdateFriends()
for i = 1, numButtons do for i = 1, numButtons do
local button = buttons[i] local button = buttons[i]
local index = offset + i local index = offset + i
if ( index <= numFriendButtons ) then if ( index <= numFriendListEntries ) then
button.index = index button.index = index
local height = FriendGroups_UpdateFriendButton(button) local height = FG:FriendGroups_UpdateFriendButton(button)
button:SetHeight(height) button:SetHeight(height)
usedHeight = usedHeight + height usedHeight = usedHeight + height
else else
...@@ -331,19 +292,16 @@ local function FriendGroups_UpdateFriends() ...@@ -331,19 +292,16 @@ local function FriendGroups_UpdateFriends()
end end
HybridScrollFrame_Update(scrollFrame, scrollFrame.totalFriendListEntriesHeight, usedHeight) HybridScrollFrame_Update(scrollFrame, scrollFrame.totalFriendListEntriesHeight, usedHeight)
if hooks["FriendsFrame_UpdateFriends"] then
hooks["FriendsFrame_UpdateFriends"]()
end
-- Delete unused groups in the collapsed part -- Delete unused groups in the collapsed part
for key,_ in pairs(FriendGroups_SavedVars.collapsed) do --[[ for key,_ in pairs(FriendGroups_SavedVars.collapsed) do
if not GroupTotal[key] then if not GroupTotal[key] then
FriendGroups_SavedVars.collapsed[key] = nil FriendGroups_SavedVars.collapsed[key] = nil
end end
end end
--]]
end end
local function FillGroups(groups, note, ...) function FG:FillGroups(groups, note, ...)
wipe(groups) wipe(groups)
local n = select('#', ...) local n = select('#', ...)
for i = 1, n do for i = 1, n do
...@@ -357,17 +315,17 @@ local function FillGroups(groups, note, ...) ...@@ -357,17 +315,17 @@ local function FillGroups(groups, note, ...)
return note return note
end end
local function NoteAndGroups(note, groups) function FG:NoteAndGroups(note, groups)
if not note then if not note then
return FillGroups(groups, "") return FG:FillGroups(groups, "")
end