Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Azilroka
ProjectAzilroka
Commits
c217d70c
Commit
c217d70c
authored
Oct 17, 2020
by
Azilroka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Friend Groups - Work
parent
1e314ef1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
475 additions
and
400 deletions
+475
-400
Modules/EnhancedFriendsList.lua
Modules/EnhancedFriendsList.lua
+4
-4
Modules/FriendGroups.lua
Modules/FriendGroups.lua
+471
-396
No files found.
Modules/EnhancedFriendsList.lua
View file @
c217d70c
...
...
@@ -396,9 +396,9 @@ function EFL:Initialize()
EFL
:
RegisterEvent
(
"BN_CONNECTED"
,
'HandleBN'
)
EFL
:
RegisterEvent
(
"BN_DISCONNECTED"
,
'HandleBN'
)
--
if PA.db.F
G
then
--
EFL:SecureHook(
PA.FG
, 'FriendGroups_UpdateFriendButton', function(
self
, button) EFL:UpdateFriends(button) end)
--
else
if
PA
.
db
.
F
riendGroups
and
PA
.
db
.
FriendGroups
.
Enable
then
EFL
:
SecureHook
(
_G
.
FriendGroups
,
'FriendGroups_UpdateFriendButton'
,
function
(
_
,
button
)
EFL
:
UpdateFriends
(
button
)
end
)
else
EFL
:
SecureHook
(
"FriendsFrame_UpdateFriendButton"
,
'UpdateFriends'
)
--
end
end
end
Modules/FriendGroups.lua
View file @
c217d70c
local
PA
=
_G
.
ProjectAzilroka
local
FG
=
PA
:
NewModule
(
'FriendGroup'
,
'AceEvent-3.0'
,
'AceTimer-3.0'
,
'AceHook-3.0'
)
_G
.
FriendGroup
=
FG
local
FG
=
PA
:
NewModule
(
'FriendGroup
s
'
,
'AceEvent-3.0'
,
'AceTimer-3.0'
,
'AceHook-3.0'
)
_G
.
FriendGroup
s
=
FG
FG
.
Title
=
PA
.
ACL
[
'|cFF16C3F2Friend|r |cFFFFFFFFGroups|r'
]
FG
.
Desciption
=
PA
.
ACL
[
'Manage Firends List with Groups'
]
FG
.
Title
=
'Friend Groups'
FG
.
Header
=
PA
.
ACL
[
'|cFF16C3F2Friend|r |cFFFFFFFFGroups|r'
]
FG
.
Description
=
PA
.
ACL
[
'Manage Firends List with Groups'
]
FG
.
Authors
=
'Azilroka'
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
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_HOUR
=
60
*
ONE_MINUTE
local
ONE_DAY
=
24
*
ONE_HOUR
local
ONE_MONTH
=
30
*
ONE_DAY
local
ONE_YEAR
=
12
*
ONE_MONTH
local
Friend
Buttons
=
{
count
=
0
}
local
Friend
ListEntries
=
{
}
local
GroupCount
=
0
local
GroupTotal
=
{}
local
GroupOnline
=
{}
local
GroupSorted
=
{}
local
FriendRequestString
=
string.sub
(
FRIEND_REQUESTS
,
1
,
-
5
)
local
FriendRequestString
=
string.sub
(
FRIEND_REQUESTS
,
1
,
-
6
)
local
OPEN_DROPDOWNMENUS_SAVE
=
nil
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_DEL"
]
=
{
text
=
"Remove from group"
,
dist
=
0
,
nested
=
1
}
UnitPopupButtons
[
"FRIEND_GROUP_NEW"
]
=
{
text
=
"Create new group"
}
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_DEL"
]
=
{
}
local
function
ClassColourCode
(
class
,
table
)
local
initialClass
=
class
for
k
,
v
in
pairs
(
LOCALIZED_CLASS_NAMES_FEMALE
)
do
if
class
==
v
then
class
=
k
break
end
end
if
class
==
initialClass
then
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
local
FriendsScrollFrame
local
FriendButtonTemplate
if
FriendsListFrameScrollFrame
then
FriendsScrollFrame
=
FriendsListFrameScrollFrame
FriendButtonTemplate
=
"FriendsListButtonTemplate"
else
FriendsScrollFrame
=
FriendsFrameFriendsScrollFrame
FriendButtonTemplate
=
"FriendsFrameButtonTemplate"
end
local
function
FriendGroups_GetTopButton
(
offset
)
function
FG
:
FriendGroups_GetTopButton
(
offset
)
local
usedHeight
=
0
for
i
=
1
,
Friend
Buttons
.
count
do
local
buttonHeight
=
FRIENDS_BUTTON_HEIGHTS
[
Friend
Button
s
[
i
].
buttonType
]
for
i
=
1
,
#
Friend
ListEntries
do
local
buttonHeight
=
FRIENDS_BUTTON_HEIGHTS
[
Friend
ListEntrie
s
[
i
].
buttonType
]
if
(
usedHeight
+
buttonHeight
>=
offset
)
then
return
i
-
1
,
offset
-
usedHeight
else
usedHeight
=
usedHeight
+
buttonHeight
end
end
return
0
,
0
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
button
.
buttonType
=
Friend
Button
s
[
index
].
buttonType
button
.
id
=
Friend
Button
s
[
index
].
id
button
.
buttonType
=
Friend
ListEntrie
s
[
index
].
buttonType
button
.
id
=
Friend
ListEntrie
s
[
index
].
id
local
height
=
FRIENDS_BUTTON_HEIGHTS
[
button
.
buttonType
]
local
nameText
,
nameColor
,
infoText
,
broadcastText
local
hasTravelPassButton
=
false
if
(
button
.
buttonType
==
FRIENDS_BUTTON_TYPE_WOW
)
then
local
name
,
level
,
class
,
area
,
connected
,
status
,
note
,
isRaF
,
guid
=
GetFriendInfo
(
FriendButtons
[
index
].
id
)
local
nameText
,
nameColor
,
infoText
,
broadcastText
,
isFavoriteFriend
if
button
.
buttonType
==
FRIENDS_BUTTON_TYPE_WOW
then
local
info
=
C_FriendList
.
GetFriendInfoByIndex
(
FriendListEntries
[
index
].
id
)
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
)
if
(
status
==
""
)
then
button
.
status
:
SetTexture
(
FRIENDS_TEXTURE_ONLINE
)
elseif
(
status
==
CHAT_FLAG_AFK
)
then
if
info
.
afk
then
button
.
status
:
SetTexture
(
FRIENDS_TEXTURE_AFK
)
elseif
(
status
==
CHAT_FLAG_DND
)
then
elseif
(
info
.
dnd
)
then
button
.
status
:
SetTexture
(
FRIENDS_TEXTURE_DND
)
else
button
.
status
:
SetTexture
(
FRIENDS_TEXTURE_ONLINE
)
end
if
FriendGroups_SavedVars
.
colour_classes
then
nameColor
=
ClassColourCode
(
class
,
true
)
else
nameColor
=
FRIENDS_WOW_NAME_COLOR
nameColor
=
PA
:
ClassColorCode
(
info
.
gameAccountInfo
.
className
)
nameText
=
info
.
name
..
", "
..
format
(
FRIENDS_LEVEL_TEMPLATE
,
info
.
level
,
info
.
className
)
if
PA
.
Retail
then
infoText
=
FG
:
GetOnlineInfoText
(
BNET_CLIENT_WOW
,
info
.
mobile
,
info
.
rafLinkType
,
info
.
area
)
end
nameText
=
name
..
", "
..
format
(
FRIENDS_LEVEL_TEMPLATE
,
level
,
class
)
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
)
nameText
=
name
nameText
=
info
.
name
nameColor
=
FRIENDS_GRAY_COLOR
infoText
=
FRIENDS_LIST_OFFLINE
end
infoText
=
area
button
.
gameIcon
:
Hide
()
button
.
summonButton
:
ClearAllPoints
()
button
.
summonButton
:
SetPoint
(
"TOPRIGHT"
,
button
,
"TOPRIGHT"
,
1
,
-
1
)
FriendsFrame_SummonButton_Update
(
button
.
summonButton
)
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
)
broadcastText
=
messageText
-- set up player name and character name
local
characterName
=
characterName
if
(
accountName
)
then
nameText
=
accountName
if
(
isOnline
)
then
characterName
=
BNet_GetValidatedCharacterName
(
characterName
,
battleTag
,
client
)
end
else
nameText
=
UNKNOWN
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
elseif
button
.
buttonType
==
FRIENDS_BUTTON_TYPE_BNET
then
local
accountInfo
=
PA
:
GetBattleNetInfo
(
button
.
id
);
if
accountInfo
then
nameText
=
accountInfo
.
accountName
infoText
=
accountInfo
.
gameAccountInfo
.
richPresence
if
accountInfo
.
gameAccountInfo
.
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
)
if
accountInfo
.
isAFK
or
accountInfo
.
gameAccountInfo
.
isGameAFK
then
button
.
status
:
SetTexture
(
FRIENDS_TEXTURE_AFK
)
elseif
accountInfo
.
isDND
or
accountInfo
.
gameAccountInfo
.
isGameBusy
then
button
.
status
:
SetTexture
(
FRIENDS_TEXTURE_DND
)
else
nameText
=
nameText
..
" "
..
FRIENDS_OTHER_NAME_COLOR_CODE
..
"("
..
characterName
..
")"
..
FONT_COLOR_CODE_CLOSE
button
.
status
:
SetTexture
(
FRIENDS_TEXTURE_ONLINE
)
end
end
end
if
(
isOnline
)
then
local
_
,
_
,
_
,
realmName
,
realmID
,
faction
,
_
,
_
,
_
,
zoneName
,
_
,
gameText
,
_
,
_
,
_
,
_
,
_
,
isGameAFK
,
isGameBusy
,
guid
=
BNGetGameAccountInfo
(
bnetIDGameAccount
)
button
.
background
:
SetColorTexture
(
FRIENDS_BNET_BACKGROUND_COLOR
.
r
,
FRIENDS_BNET_BACKGROUND_COLOR
.
g
,
FRIENDS_BNET_BACKGROUND_COLOR
.
b
,
FRIENDS_BNET_BACKGROUND_COLOR
.
a
)
if
(
isBnetAFK
or
isGameAFK
)
then
button
.
status
:
SetTexture
(
FRIENDS_TEXTURE_AFK
)
elseif
(
isBnetDND
or
isGameBusy
)
then
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
if
accountInfo
.
gameAccountInfo
.
clientProgram
==
BNET_CLIENT_WOW
and
accountInfo
.
gameAccountInfo
.
wowProjectID
==
WOW_PROJECT_ID
then
if
not
accountInfo
.
gameAccountInfo
.
areaName
or
accountInfo
.
gameAccountInfo
.
areaName
==
""
then
infoText
=
UNKNOWN
else
infoText
=
accountInfo
.
gameAccountInfo
.
isWowMobile
and
LOCATION_MOBILE_APP
or
info
.
gameAccountInfo
.
areaName
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
)
button
.
gameIcon
:
Set
Shown
(
not
shouldShowSummonButton
)
local
fadeIcon
=
(
accountInfo
.
gameAccountInfo
.
clientProgram
==
BNET_CLIENT_WOW
)
and
(
accountInfo
.
gameAccountInfo
.
wowProjectID
~=
WOW_PROJECT_ID
)
button
.
gameIcon
:
Set
Alpha
(
fadeIcon
and
.
6
or
1
)
-- travel pass
hasTravelPassButton
=
true
local
restriction
=
FriendsFrame_GetInviteRestriction
(
button
.
id
)
if
(
restriction
==
INVITE_RESTRICTION_NONE
)
then
button
.
travelPassButton
:
Enable
()
else
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
local
shouldShowSummonButton
=
FriendsFrame_ShouldShowSummonButton
(
button
.
summonButton
)
button
.
gameIcon
:
SetShown
(
not
shouldShowSummonButton
)
local
restriction
=
FriendsFrame_GetInviteRestriction
(
button
.
id
)
button
.
travelPassButton
:
SetEnabled
(
restriction
==
INVITE_RESTRICTION_NONE
)
button
.
travelPassButton
:
SetShown
(
restriction
==
INVITE_RESTRICTION_NONE
)
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
button
.
summonButton
:
ClearAllPoints
()
button
.
summonButton
:
SetPoint
(
"CENTER"
,
button
.
gameIcon
,
"CENTER"
,
1
,
0
)
FriendsFrame_SummonButton_Update
(
button
.
summonButton
)
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
local
title
local
group
=
Friend
Button
s
[
index
].
text
local
group
=
Friend
ListEntrie
s
[
index
].
text
if
group
==
""
or
not
group
then
title
=
"[no group]"
else
title
=
group
end
button
.
text
:
SetText
(
title
)
button
.
text
:
Show
()
local
counts
=
"("
..
GroupOnline
[
group
]
..
"/"
..
GroupTotal
[
group
]
..
")"
nameText
=
counts
nameColor
=
FRIENDS_GROUP_NAME_COLOR
button
.
name
:
SetJustifyH
(
"RIGHT"
)
if
FriendGroups_SavedVars
.
collapsed
[
group
]
then
button
.
status
:
SetTexture
(
"Interface\\Buttons\\UI-PlusButton-UP"
)
if
button
[
"text"
]
then
button
.
text
:
SetText
(
title
)
button
.
text
:
Show
()
nameText
=
counts
button
.
name
:
SetJustifyH
(
"RIGHT"
)
else
button
.
status
:
SetTexture
(
"Interface\\Buttons\\UI-MinusButton-UP"
)
nameText
=
title
..
" "
..
counts
button
.
name
:
SetJustifyH
(
"CENTER"
)
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
button
.
info
:
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
:
SetAlpha
(
0
.
5
)
local
scrollFrame
=
FriendsFrame
FriendsScrollFrame
local
divider
=
scrollFrame
.
dividerPool
:
Acquire
()
local
scrollFrame
=
FriendsScrollFrame
--[[
local divider = scrollFrame.dividerPool:Acquire()
divider:SetParent(scrollFrame.ScrollChild)
divider:SetAllPoints(button)
divider
:
Show
()
divider:Show()
--]]
elseif
(
button
.
buttonType
==
FRIENDS_BUTTON_TYPE_INVITE_HEADER
)
then
local
header
=
FriendsFrame
FriendsScrollFrame
.
PendingInvitesHeaderButton
local
header
=
FriendsScrollFrame
.
PendingInvitesHeaderButton
header
:
SetPoint
(
"TOPLEFT"
,
button
,
1
,
0
)
header
:
Show
()
header
:
SetFormattedText
(
FRIEND_REQUESTS
,
BNGetNumFriendInvites
())
...
...
@@ -255,7 +212,7 @@ local function FriendGroups_UpdateFriendButton(button)
end
nameText
=
nil
elseif
(
button
.
buttonType
==
FRIENDS_BUTTON_TYPE_INVITE
)
then
local
scrollFrame
=
FriendsFrame
FriendsScrollFrame
local
scrollFrame
=
FriendsScrollFrame
local
invite
=
scrollFrame
.
invitePool
:
Acquire
()
invite
:
SetParent
(
scrollFrame
.
ScrollChild
)
invite
:
SetAllPoints
(
button
)
...
...
@@ -266,14 +223,8 @@ local function FriendGroups_UpdateFriendButton(button)
invite
.
inviteIndex
=
button
.
id
nameText
=
nil
end
-- travel pass?
if
(
hasTravelPassButton
)
then
button
.
travelPassButton
:
Show
()
else
button
.
travelPassButton
:
Hide
()
end
-- selection
if
(
FriendsFrame
.
selectedFriendType
==
Friend
Button
s
[
index
].
buttonType
and
FriendsFrame
.
selectedFriend
==
Friend
Button
s
[
index
].
id
)
then
if
(
FriendsFrame
.
selectedFriendType
==
Friend
ListEntrie
s
[
index
].
buttonType
and
FriendsFrame
.
selectedFriend
==
Friend
ListEntrie
s
[
index
].
id
)
then
button
:
LockHighlight
()
else
button
:
UnlockHighlight
()
...
...
@@ -281,7 +232,9 @@ local function FriendGroups_UpdateFriendButton(button)
-- finish setting up button if it's not a header
if
(
nameText
)
then
if
button
.
buttonType
~=
FRIENDS_BUTTON_TYPE_DIVIDER
then
if
button
[
"text"
]
then
button
.
text
:
Hide
()
end
button
.
name
:
SetJustifyH
(
"LEFT"
)
button
.
background
:
SetAlpha
(
1
)
button
.
info
:
Show
()
...
...
@@ -290,26 +243,34 @@ local function FriendGroups_UpdateFriendButton(button)
button
.
name
:
SetTextColor
(
nameColor
.
r
,
nameColor
.
g
,
nameColor
.
b
)
button
.
info
:
SetText
(
infoText
)
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
button
:
Hide
()
end
-- update the tooltip if hovering over a button
if
(
FriendsTooltip
.
button
==
button
)
then
FriendsFrameTooltip_Show
(
button
)
end
if
(
GetMouseFocus
()
==
button
)
then
FriendsFrameTooltip_Show
(
button
)
if
(
FriendsTooltip
.
button
==
button
)
or
(
GetMouseFocus
()
==
button
)
then
if
FriendsFrameTooltip_Show
then
FriendsFrameTooltip_Show
(
button
)
else
button
:
OnEnter
()
end
end
return
height
end
local
function
FriendGroups_UpdateFriends
()
local
scrollFrame
=
FriendsFrame
FriendsScrollFrame
function
FG
:
FriendGroups_UpdateFriends
()
local
scrollFrame
=
FriendsScrollFrame
local
offset
=
HybridScrollFrame_GetOffset
(
scrollFrame
)
local
buttons
=
scrollFrame
.
buttons
local
numButtons
=
#
buttons
local
numFriend
Button
s
=
Friend
Buttons
.
count
local
numFriend
ListEntrie
s
=
#
Friend
ListEntries
local
usedHeight
=
0
...
...
@@ -319,9 +280,9 @@ local function FriendGroups_UpdateFriends()
for
i
=
1
,
numButtons
do
local
button
=
buttons
[
i
]
local
index
=
offset
+
i
if
(
index
<=
numFriend
Button
s
)
then
if
(
index
<=
numFriend
ListEntrie
s
)
then
button
.
index
=
index
local
height
=
FriendGroups_UpdateFriendButton
(
button
)
local
height
=
FG
:
FriendGroups_UpdateFriendButton
(
button
)
button
:
SetHeight
(
height
)
usedHeight
=
usedHeight
+
height
else
...
...
@@ -331,19 +292,16 @@ local function FriendGroups_UpdateFriends()
end
HybridScrollFrame_Update
(
scrollFrame
,
scrollFrame
.
totalFriendListEntriesHeight
,
usedHeight
)
if
hooks
[
"FriendsFrame_UpdateFriends"
]
then
hooks
[
"FriendsFrame_UpdateFriends"
]()
end
-- 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
FriendGroups_SavedVars.collapsed[key] = nil
end
end
--]]
end
local
function
FillGroups
(
groups
,
note
,
...
)
function
FG
:
FillGroups
(
groups
,
note
,
...
)
wipe
(
groups
)
local
n
=
select
(
'#'
,
...
)
for
i
=
1
,
n
do
...
...
@@ -357,17 +315,17 @@ local function FillGroups(groups, note, ...)
return
note
end
local
function
NoteAndGroups
(
note
,
groups
)
function
FG
:
NoteAndGroups
(
note
,
groups
)
if
not
note
then
return
FillGroups
(
groups
,
""
)
return
FG
:
FillGroups
(
groups
,
""
)
end
if
groups
then
return
FillGroups
(
groups
,
strsplit
(
"#"
,
note
))
return
FG
:
FillGroups
(
groups
,
strsplit
(
"#"
,
note
))
end
return
strsplit
(
"#"
,
note
)
end
local
function
CreateNote
(
note
,
groups
)
function
FG
:
CreateNote
(
note
,
groups
)
local
value
=
""
if
note
then
value
=
note
...
...
@@ -378,23 +336,23 @@ local function CreateNote(note, groups)
return
value
end
local
function
AddGroup
(
note
,
group
)
function
FG
:
AddGroup
(
note
,
group
)
local
groups
=
{}
note
=
NoteAndGroups
(
note
,
groups
)
note
=
FG
:
NoteAndGroups
(
note
,
groups
)
groups
[
""
]
=
nil
--ew
groups
[
group
]
=
true
return
CreateNote
(
note
,
groups
)
return
FG
:
CreateNote
(
note
,
groups
)
end
local
function
RemoveGroup
(
note
,
group
)
function
FG
:
RemoveGroup
(
note
,
group
)
local
groups
=
{}
note
=
NoteAndGroups
(
note
,
groups
)
note
=
FG
:
NoteAndGroups
(
note
,
groups
)
groups
[
""
]
=
nil
--ew
groups
[
group
]
=
nil
return
CreateNote
(
note
,
groups
)
return
FG
:
CreateNote
(
note
,
groups
)
end
local
function
IncrementGroup
(
group
,
online
)
function
FG
:
IncrementGroup
(
group
,
online
)
if
not
GroupTotal
[
group
]
then
GroupCount
=
GroupCount
+
1
GroupTotal
[
group
]
=
0
...
...
@@ -406,18 +364,24 @@ local function IncrementGroup(group, online)
end
end
local
function
FriendGroups_Update
(
forceUpdate
)
local
numBNetTotal
,
numBNetOnline
=
BNGetNumFriends
()
function
FG
:
FriendGroups_Update
(
forceUpdate
)
local
numBNetTotal
,
numBNetOnline
,
numBNetFavorite
,
numBNetFavoriteOnline
=
BNGetNumFriends
()
numBNetFavorite
=
numBNetFavorite
or
0
numBNetFavoriteOnline
=
numBNetFavoriteOnline
or
0
local
numBNetOffline
=
numBNetTotal
-
numBNetOnline
local
numWoWTotal
,
numWoWOnline
=
GetNumFriends
()
local
numBNetFavoriteOffline
=
numBNetFavorite
-
numBNetFavoriteOnline
local
numWoWTotal
=
C_FriendList
.
GetNumFriends
()
local
numWoWOnline
=
C_FriendList
.
GetNumOnlineFriends
()
local
numWoWOffline
=
numWoWTotal
-
numWoWOnline
QuickJoinToastButton
:
UpdateDisplayedFriendCount
()
if
QuickJoinToastButton
then
QuickJoinToastButton
:
UpdateDisplayedFriendCount
()
end
if
(
not
FriendsListFrame
:
IsShown
()
and
not
forceUpdate
)
then
return
end
wipe
(
Friend
Button
s
)
wipe
(
Friend
ListEntrie
s
)
wipe
(
GroupTotal
)
wipe
(
GroupOnline
)
wipe
(
GroupSorted
)
...
...
@@ -429,17 +393,17 @@ local function FriendGroups_Update(forceUpdate)
local
buttonCount
=
0
Friend
Button
s
.
count
=
0
Friend
ListEntrie
s
.
count
=
0
local
addButtonIndex
=
0
local
totalButtonHeight
=
0
local
function
AddButtonInfo
(
buttonType
,
id
)
addButtonIndex
=
addButtonIndex
+
1
if
(
not
Friend
Button
s
[
addButtonIndex
]
)
then
Friend
Button
s
[
addButtonIndex
]
=
{
}
if
(
not
Friend
ListEntrie
s
[
addButtonIndex
]
)
then
Friend
ListEntrie
s
[
addButtonIndex
]
=
{
}
end
Friend
Button
s
[
addButtonIndex
].
buttonType
=
buttonType
Friend
Button
s
[
addButtonIndex
].
id
=
id
Friend
Button
s
.
count
=
Friend
Button
s
.
count
+
1
Friend
ListEntrie
s
[
addButtonIndex
].
buttonType
=
buttonType
Friend
ListEntrie
s
[
addButtonIndex
].
id
=
id
Friend
ListEntrie
s
.
count
=
Friend
ListEntrie
s
.
count
+
1
totalButtonHeight
=
totalButtonHeight
+
FRIENDS_BUTTON_HEIGHTS
[
buttonType
]
end
...
...
@@ -450,61 +414,91 @@ local function FriendGroups_Update(forceUpdate)
if
not
FriendReqGroup
[
i
]
then
FriendReqGroup
[
i
]
=
{}
end
IncrementGroup
(
FriendRequestString
,
true
)
NoteAndGroups
(
_
,
FriendReqGroup
[
i
])
if
not
FriendGroups_SavedVars
.
collapsed
[
group
]
then
FG
:
IncrementGroup
(
FriendRequestString
,
true
)
FG
:
NoteAndGroups
(
nil
,
FriendReqGroup
[
i
])
--
if not FriendGroups_SavedVars.collapsed[group] then