EnhancedFriendsList.lua 17.3 KB
Newer Older
Azilroka's avatar
Azilroka committed
1
local PA = _G.ProjectAzilroka
Azilroka's avatar
Azilroka committed
2
local EFL = PA:NewModule('EnhancedFriendsList', 'AceEvent-3.0', 'AceHook-3.0', 'AceTimer-3.0')
Azilroka's avatar
Azilroka committed
3
PA.EFL, _G.EnhancedFriendsList = EFL, EFL
Azilroka's avatar
Azilroka committed
4

Azilroka's avatar
Azilroka committed
5 6
EFL.Title = 'Enhanced Friends List'
EFL.Header = PA.ACL['|cFF16C3F2Enhanced|r |cFFFFFFFFFriends List|r']
7
EFL.Description = PA.ACL['Provides Friends List Customization']
Azilroka's avatar
Azilroka committed
8
EFL.Authors = 'Azilroka'
Azilroka's avatar
Azilroka committed
9
EFL.Credits = 'Marotheit    Merathilis'
Azilroka's avatar
Azilroka committed
10
EFL.isEnabled = false
Azilroka's avatar
Azilroka committed
11

Azilroka's avatar
Azilroka committed
12 13 14 15 16 17 18 19 20
local pairs = pairs
local format = format
local unpack = unpack
local time = time
local CLASS_ICON_TCOORDS = CLASS_ICON_TCOORDS

local GetQuestDifficultyColor = GetQuestDifficultyColor
local WrapTextInColorCode = WrapTextInColorCode
local _G = _G
Azilroka's avatar
Azilroka committed
21

Azilroka's avatar
Cleanup  
Azilroka committed
22
local MediaPath = 'Interface/AddOns/ProjectAzilroka/Media/EnhancedFriendsList/'
Azilroka's avatar
Maths  
Azilroka committed
23 24 25 26 27
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;
Azilroka's avatar
Azilroka committed
28

Azilroka's avatar
Azilroka committed
29 30
local isBNConnected = _G.BNConnected()
local LEVEL = LEVEL
Azilroka's avatar
Azilroka committed
31

Azilroka's avatar
1.67  
Azilroka committed
32 33 34 35
--[[
/run for i,v in pairs(_G) do if type(v)=="string" and v:match("Honorable") then print(i,"=",v) end end
]]

Azilroka's avatar
Azilroka committed
36 37 38
EFL.Icons = {
	Game = {
		Alliance = {
Azilroka's avatar
Azilroka committed
39
			Name = _G.FACTION_ALLIANCE,
Azilroka's avatar
Azilroka committed
40
			Order = 1,
Azilroka's avatar
Azilroka committed
41 42
			Default = "Interface/FriendsFrame/Battlenet-WoWicon",
			Launcher = MediaPath..'GameIcons/Launcher/Alliance',
Azilroka's avatar
Azilroka committed
43 44
		},
		Horde = {
Azilroka's avatar
Azilroka committed
45
			Name = _G.FACTION_HORDE,
Azilroka's avatar
Azilroka committed
46
			Order = 2,
Azilroka's avatar
Azilroka committed
47 48
			Default = 'Interface/FriendsFrame/Battlenet-WoWicon',
			Launcher = MediaPath..'GameIcons/Launcher/Horde',
Azilroka's avatar
Azilroka committed
49 50
		},
		Neutral = {
Azilroka's avatar
Azilroka committed
51
			Name = _G.FACTION_STANDING_LABEL4,
Azilroka's avatar
Azilroka committed
52
			Order = 3,
Azilroka's avatar
Azilroka committed
53 54
			Default = 'Interface/FriendsFrame/Battlenet-WoWicon',
			Launcher = MediaPath..'GameIcons/Launcher/WoW',
Azilroka's avatar
Azilroka committed
55
		},
Azilroka's avatar
Azilroka committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69
		App = {
			Name = PA.ACL['App'],
			Order = 4,
			Color = '82C5FF',
			Default = 'Interface/FriendsFrame/Battlenet-Battleneticon',
			Launcher = MediaPath..'GameIcons/Launcher/BattleNet',
		},
		BSAp = {
			Name = PA.ACL['Mobile'],
			Order = 5,
			Color = '82C5FF',
			Default = 'Interface/FriendsFrame/Battlenet-Battleneticon',
			Launcher = MediaPath..'GameIcons/Launcher/BattleNet',
		},
Azilroka's avatar
Azilroka committed
70
		[_G.BNET_CLIENT_D3 or 'D3'] = {
Azilroka's avatar
Azilroka committed
71 72
			Name = PA.ACL['Diablo 3'],
			Color = 'C41F3B',
Azilroka's avatar
Azilroka committed
73 74
			Default = 'Interface/FriendsFrame/Battlenet-D3icon',
			Launcher = MediaPath..'GameIcons/Launcher/D3',
Azilroka's avatar
Azilroka committed
75
		},
Azilroka's avatar
Azilroka committed
76
		[_G.BNET_CLIENT_WTCG or 'WTCG'] = {
Azilroka's avatar
Azilroka committed
77 78
			Name = PA.ACL['Hearthstone'],
			Color = 'FFB100',
Azilroka's avatar
Azilroka committed
79 80
			Default = 'Interface/FriendsFrame/Battlenet-WTCGicon',
			Launcher = MediaPath..'GameIcons/Launcher/Hearthstone',
Azilroka's avatar
Azilroka committed
81
		},
Azilroka's avatar
Azilroka committed
82
		[_G.BNET_CLIENT_SC or 'S1'] = {
Azilroka's avatar
Azilroka committed
83 84
			Name = PA.ACL['Starcraft'],
			Color = 'C495DD',
Azilroka's avatar
Azilroka committed
85 86
			Default = 'Interface/FriendsFrame/Battlenet-Sc2icon',
			Launcher = MediaPath..'GameIcons/Launcher/SC',
Azilroka's avatar
Azilroka committed
87
		},
Azilroka's avatar
Azilroka committed
88
		[_G.BNET_CLIENT_SC2 or 'S2'] = {
Azilroka's avatar
Azilroka committed
89 90
			Name = PA.ACL['Starcraft 2'],
			Color = 'C495DD',
Azilroka's avatar
Azilroka committed
91 92
			Default = "Interface/ChatFrame/UI-ChatIcon-SC2",
			Launcher = MediaPath..'GameIcons/Launcher/SC2',
Azilroka's avatar
Azilroka committed
93
		},
Azilroka's avatar
Azilroka committed
94
		[_G.BNET_CLIENT_HEROES or 'Hero'] = {
Azilroka's avatar
Azilroka committed
95 96
			Name = PA.ACL['Hero of the Storm'],
			Color = '00CCFF',
Azilroka's avatar
Azilroka committed
97 98
			Default = 'Interface/FriendsFrame/Battlenet-HotSicon',
			Launcher = MediaPath..'GameIcons/Launcher/Heroes',
Azilroka's avatar
Azilroka committed
99
		},
Azilroka's avatar
Azilroka committed
100
		[_G.BNET_CLIENT_OVERWATCH or 'Pro'] = {
Azilroka's avatar
Azilroka committed
101 102
			Name = PA.ACL['Overwatch'],
			Color = 'FFFFFF',
Azilroka's avatar
Azilroka committed
103 104
			Default = 'Interface/FriendsFrame/Battlenet-Overwatchicon',
			Launcher = MediaPath..'GameIcons/Launcher/Overwatch',
Azilroka's avatar
Azilroka committed
105
		},
Azilroka's avatar
Azilroka committed
106
		[_G.BNET_CLIENT_COD or 'VIPR'] = {
Azilroka's avatar
Azilroka committed
107 108
			Name = PA.ACL['Call of Duty 4'],
			Color = 'FFFFFF',
Azilroka's avatar
Azilroka committed
109 110
			Default = 'Interface/FriendsFrame/Battlenet-CallOfDutyBlackOps4icon',
			Launcher = MediaPath..'GameIcons/Launcher/COD4',
Azilroka's avatar
Azilroka committed
111
		},
Azilroka's avatar
Azilroka committed
112
		[_G.BNET_CLIENT_COD_MW or 'ODIN'] = {
Azilroka's avatar
CODMW  
Azilroka committed
113 114
			Name = PA.ACL['Call of Duty Modern Warfare'],
			Color = 'FFFFFF',
Azilroka's avatar
Azilroka committed
115 116 117 118 119 120 121 122
			Default = 'Interface/FriendsFrame/Battlenet-CallOfDutyMWicon',
			Launcher = MediaPath..'GameIcons/Launcher/CODMW',
		},
		[_G.BNET_CLIENT_WC3 or 'W3'] = {
			Name = PA.ACL['Warcraft 3 Reforged'],
			Color = 'FFFFFF',
			Default = "Interface/FriendsFrame/Battlenet-Warcraft3Reforged",
			Launcher = MediaPath..'GameIcons/Launcher/WC3R',
Azilroka's avatar
CODMW  
Azilroka committed
123
		},
Azilroka's avatar
Azilroka committed
124
	},
Azilroka's avatar
Azilroka committed
125 126
	Status = {
		Online = {
Azilroka's avatar
Azilroka committed
127
			Name = _G.FRIENDS_LIST_ONLINE,
Azilroka's avatar
Azilroka committed
128
			Order = 1,
Azilroka's avatar
Azilroka committed
129 130 131
			Default = _G.FRIENDS_TEXTURE_ONLINE,
			Square = MediaPath..'StatusIcons/Square/Online',
			D3 = MediaPath..'StatusIcons/D3/Online',
Azilroka's avatar
Cleanup  
Azilroka committed
132
			Color = {.243, .57, 1},
Azilroka's avatar
Azilroka committed
133 134
		},
		Offline = {
Azilroka's avatar
Azilroka committed
135
			Name = _G.FRIENDS_LIST_OFFLINE,
Azilroka's avatar
Azilroka committed
136
			Order = 2,
Azilroka's avatar
Azilroka committed
137 138 139
			Default = _G.FRIENDS_TEXTURE_OFFLINE,
			Square = MediaPath..'StatusIcons/Square/Offline',
			D3 = MediaPath..'StatusIcons/D3/Offline',
Azilroka's avatar
Cleanup  
Azilroka committed
140
			Color = {.486, .518, .541},
Azilroka's avatar
Azilroka committed
141 142
		},
		DND = {
Azilroka's avatar
Azilroka committed
143
			Name = _G.DEFAULT_DND_MESSAGE,
Azilroka's avatar
Azilroka committed
144
			Order = 3,
Azilroka's avatar
Azilroka committed
145 146 147
			Default = _G.FRIENDS_TEXTURE_DND,
			Square = MediaPath..'StatusIcons/Square/DND',
			D3 = MediaPath..'StatusIcons/D3/DND',
Azilroka's avatar
Cleanup  
Azilroka committed
148
			Color = {1, 0, 0},
Azilroka's avatar
Azilroka committed
149 150
		},
		AFK = {
Azilroka's avatar
Azilroka committed
151
			Name = _G.DEFAULT_AFK_MESSAGE,
Azilroka's avatar
Azilroka committed
152
			Order = 4,
Azilroka's avatar
Azilroka committed
153 154 155
			Default = _G.FRIENDS_TEXTURE_AFK,
			Square = MediaPath..'StatusIcons/Square/AFK',
			D3 = MediaPath..'StatusIcons/D3/AFK',
Azilroka's avatar
Cleanup  
Azilroka committed
156
			Color = {1, 1, 0},
Azilroka's avatar
Azilroka committed
157 158
		},
	}
Azilroka's avatar
Azilroka committed
159 160
}

Azilroka's avatar
Cleanup  
Azilroka committed
161
function EFL:CreateTexture(button, type, layer)
Azilroka's avatar
Azilroka committed
162 163 164 165 166
	if button.efl and button.efl[type] then
		button.efl[type].Left:SetTexture(PA.LSM:Fetch('statusbar', self.db['Texture']))
		button.efl[type].Right:SetTexture(PA.LSM:Fetch('statusbar', self.db['Texture']))
		return
	end
Azilroka's avatar
Cleanup  
Azilroka committed
167 168 169 170 171 172 173 174

	button.efl = button.efl or {}
	button.efl[type] = {}

	button.efl[type].Left = button:CreateTexture(nil, layer)
	button.efl[type].Left:SetWidth(button:GetWidth() / 2)
	button.efl[type].Left:SetHeight(32)
	button.efl[type].Left:SetPoint("LEFT", button, "CENTER")
Azilroka's avatar
Azilroka committed
175
	button.efl[type].Left:SetTexture('Interface/Buttons/WHITE8X8')
Azilroka's avatar
Cleanup  
Azilroka committed
176 177 178 179 180

	button.efl[type].Right = button:CreateTexture(nil, layer)
	button.efl[type].Right:SetWidth(button:GetWidth() / 2)
	button.efl[type].Right:SetHeight(32)
	button.efl[type].Right:SetPoint("RIGHT", button, "CENTER")
Azilroka's avatar
Azilroka committed
181
	button.efl[type].Right:SetTexture('Interface/Buttons/WHITE8X8')
Azilroka's avatar
Cleanup  
Azilroka committed
182 183
end

Azilroka's avatar
Azilroka committed
184
function EFL:UpdateFriends(button)
Azilroka's avatar
Cleanup  
Azilroka committed
185 186
	local nameText, infoText
	local status = 'Offline'
Azilroka's avatar
Azilroka committed
187 188
	if button.buttonType == _G.FRIENDS_BUTTON_TYPE_WOW then
		local info = _G.C_FriendList.GetFriendInfoByIndex(button.id)
Azilroka's avatar
Cleanup  
Azilroka committed
189 190
		if info.connected then
			local name, level, class = info.name, info.level, info.className
Azilroka's avatar
Azilroka committed
191
			local classcolor = PA:ClassColorCode(class)
Azilroka's avatar
Cleanup  
Azilroka committed
192
			status = info.dnd and 'DND' or info.afk and 'AFK' or 'Online'
Azilroka's avatar
Azilroka committed
193 194 195 196 197 198 199 200 201 202
			if EFL.db.ShowLevel then
				if EFL.db.DiffLevel then
					local diff = level ~= 0 and format('FF%02x%02x%02x', GetQuestDifficultyColor(level).r * 255, GetQuestDifficultyColor(level).g * 255, GetQuestDifficultyColor(level).b * 255) or 'FFFFFFFF'
					nameText = format('%s |cFFFFFFFF(|r%s - %s %s|cFFFFFFFF)|r', WrapTextInColorCode(name, classcolor), class, LEVEL, WrapTextInColorCode(level, diff))
				else
					nameText = format('%s |cFFFFFFFF(|r%s - %s %s|cFFFFFFFF)|r', WrapTextInColorCode(name, classcolor), class, LEVEL, WrapTextInColorCode(level, 'FFFFE519'))
				end
			else
				nameText = format('%s |cFFFFFFFF(|r%s|cFFFFFFFF)|r', WrapTextInColorCode(name, classcolor), class)
			end
Azilroka's avatar
Cleanup  
Azilroka committed
203 204 205 206 207
			infoText = info.area

			button.gameIcon:Show()
			button.gameIcon:SetTexture('Interface/WorldStateFrame/Icons-Classes')
			button.gameIcon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[PA:GetClassName(class)]))
Azilroka's avatar
Azilroka committed
208
		else
Azilroka's avatar
Cleanup  
Azilroka committed
209
			nameText = info.name
Azilroka's avatar
Azilroka committed
210
		end
Azilroka's avatar
Cleanup  
Azilroka committed
211
		button.status:SetTexture(EFL.Icons.Status[status][EFL.db.StatusIconPack])
Azilroka's avatar
Azilroka committed
212
	elseif button.buttonType == _G.FRIENDS_BUTTON_TYPE_BNET and isBNConnected then
Azilroka's avatar
Azilroka committed
213
		local info = PA:GetBattleNetInfo(button.id);
Azilroka's avatar
Azilroka committed
214 215
		if info then
			nameText = info.accountName
Azilroka's avatar
Azilroka committed
216
			infoText = info.gameAccountInfo.richPresence
Azilroka's avatar
Azilroka committed
217 218
			if info.gameAccountInfo.isOnline then
				local client = info.gameAccountInfo.clientProgram
Azilroka's avatar
Cleanup  
Azilroka committed
219
				status = info.isDND and 'DND' or info.isAFK and 'AFK' or 'Online'
Azilroka's avatar
Azilroka committed
220

Azilroka's avatar
Azilroka committed
221
				if client == _G.BNET_CLIENT_WOW then
Azilroka's avatar
Azilroka committed
222 223 224
					local level = info.gameAccountInfo.characterLevel
					local characterName = info.gameAccountInfo.characterName
					local classcolor = PA:ClassColorCode(info.gameAccountInfo.className)
Azilroka's avatar
Azilroka committed
225 226 227 228
					if characterName then
						if EFL.db.ShowLevel then
							if EFL.db.DiffLevel then
								local diff = level ~= 0 and format('FF%02x%02x%02x', GetQuestDifficultyColor(level).r * 255, GetQuestDifficultyColor(level).g * 255, GetQuestDifficultyColor(level).b * 255) or 'FFFFFFFF'
Azilroka's avatar
Cleanup  
Azilroka committed
229
								nameText = format('%s (%s - %s %s)', nameText, WrapTextInColorCode(characterName, classcolor), LEVEL, WrapTextInColorCode(level, diff))
Azilroka's avatar
Azilroka committed
230
							else
Azilroka's avatar
Cleanup  
Azilroka committed
231
								nameText = format('%s (%s - %s %s)', nameText, WrapTextInColorCode(characterName, classcolor), LEVEL, WrapTextInColorCode(level, 'FFFFE519'))
Azilroka's avatar
Azilroka committed
232
							end
Azilroka's avatar
Azilroka committed
233
						else
Azilroka's avatar
Cleanup  
Azilroka committed
234
							nameText = format('%s (%s)', nameText, WrapTextInColorCode(characterName, classcolor))
Azilroka's avatar
Azilroka committed
235
						end
Azilroka's avatar
EFL  
Azilroka committed
236
					end
Azilroka's avatar
Azilroka committed
237

Azilroka's avatar
Azilroka committed
238
					if info.gameAccountInfo.wowProjectID == _G.WOW_PROJECT_CLASSIC and info.gameAccountInfo.realmDisplayName ~= PA.MyRealm then
Azilroka's avatar
Azilroka committed
239
						infoText = format('%s - %s - %s', info.gameAccountInfo.areaName or UNKNOWN, info.gameAccountInfo.realmDisplayName, infoText)
Azilroka's avatar
Azilroka committed
240 241 242
					elseif info.gameAccountInfo.realmDisplayName == PA.MyRealm then
						infoText = info.gameAccountInfo.areaName
					end
Azilroka's avatar
Azilroka committed
243

Azilroka's avatar
EFL  
Azilroka committed
244
					local faction = info.gameAccountInfo.factionName
Azilroka's avatar
Azilroka committed
245
					button.gameIcon:SetTexture(faction and EFL.Icons.Game[faction][EFL.db.GameIconPack or 'Default'] or EFL.Icons.Game.Neutral.Launcher)
Azilroka's avatar
Azilroka committed
246
				else
247
					if not EFL.Icons.Game[client] then client = 'BSAp' end
Azilroka's avatar
Azilroka committed
248
					nameText = format('|cFF%s%s|r', EFL.Icons.Game[client].Color or 'FFFFFF', nameText)
Azilroka's avatar
Azilroka committed
249
					button.gameIcon:SetTexture(EFL.Icons.Game[client][EFL.db.GameIconPack or 'Default'])
Azilroka's avatar
Azilroka committed
250
				end
Azilroka's avatar
EFL  
Azilroka committed
251

Azilroka's avatar
Azilroka committed
252
				button.gameIcon:SetTexCoord(0, 1, 0, 1)
Azilroka's avatar
1.56  
Azilroka committed
253
				button.gameIcon:SetDrawLayer('ARTWORK')
Azilroka's avatar
Azilroka committed
254
				button.gameIcon:SetAlpha(1)
Azilroka's avatar
Azilroka committed
255
			else
Azilroka's avatar
Azilroka committed
256
				local lastOnline = info.lastOnlineTime
Azilroka's avatar
Azilroka committed
257
				infoText = (not lastOnline or lastOnline == 0 or time() - lastOnline >= ONE_YEAR) and _G.FRIENDS_LIST_OFFLINE or format(_G.BNET_LAST_ONLINE_TIME, _G.FriendsFrame_GetLastOnline(lastOnline))
Azilroka's avatar
Azilroka committed
258
			end
Azilroka's avatar
Cleanup  
Azilroka committed
259
			button.status:SetTexture(EFL.Icons.Status[status][EFL.db.StatusIconPack])
Azilroka's avatar
Azilroka committed
260 261 262 263 264 265 266 267 268
		end
	end

	if button.summonButton:IsShown() then
		button.gameIcon:SetPoint('TOPRIGHT', -50, -2)
	else
		button.gameIcon:SetPoint('TOPRIGHT', -21, -2)
	end

Azilroka's avatar
Cleanup  
Azilroka committed
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
	if nameText then button.name:SetText(nameText) end
	if infoText then button.info:SetText(infoText) end

	local r, g, b = unpack(EFL.Icons.Status[status].Color)
	if EFL.db.ShowStatusBackground then
		EFL:CreateTexture(button, 'background', 'BACKGROUND')

		button.efl.background.Left:SetGradientAlpha("Horizontal", r, g, b, .15, r, g, b, 0)
		button.efl.background.Right:SetGradientAlpha("Horizontal", r, g, b, .0, r, g, b, .15)

		button.background:Hide()
	end

	if EFL.db.ShowStatusHighlight then
		EFL:CreateTexture(button, 'highlight', 'HIGHLIGHT')

		button.efl.highlight.Left:SetGradientAlpha("Horizontal", r, g, b, .25, r, g, b, 0)
		button.efl.highlight.Right:SetGradientAlpha("Horizontal", r, g, b, .0, r, g, b, .25)

		button.highlight:SetVertexColor(0, 0, 0, 0)
	end

	button.name:SetFont(PA.LSM:Fetch('font', EFL.db.NameFont), EFL.db.NameFontSize, EFL.db.NameFontFlag)
	button.info:SetFont(PA.LSM:Fetch('font', EFL.db.InfoFont), EFL.db.InfoFontSize, EFL.db.InfoFontFlag)

	if button.Favorite and button.Favorite:IsShown() then
		button.Favorite:ClearAllPoints()
		button.Favorite:SetPoint("TOPLEFT", button.name, "TOPLEFT", button.name:GetStringWidth(), 0);
Azilroka's avatar
Azilroka committed
297 298 299
	end
end

Azilroka's avatar
Azilroka committed
300
function EFL:GetOptions()
Azilroka's avatar
Azilroka committed
301 302 303 304 305
	PA.Options.args.EnhancedFriendsList = PA.ACH:Group(EFL.Title, EFL.Description, nil, nil, function(info) return EFL.db[info[#info]] end, function(info, value) EFL.db[info[#info]] = value _G.FriendsFrame_Update() end)
	PA.Options.args.EnhancedFriendsList.args.Header = PA.ACH:Header(EFL.Header, 0)
	PA.Options.args.EnhancedFriendsList.args.Enable = PA.ACH:Toggle(PA.ACL['Enable'], nil, 1, nil, nil, nil, nil, function(info, value) EFL.db[info[#info]] = value if not EFL.isEnabled then EFL:Initialize() else _G.StaticPopup_Show('PROJECTAZILROKA_RL') end end)

	PA.Options.args.EnhancedFriendsList.args.General = PA.ACH:Group(PA.ACL['General'], nil, 2)
Azilroka's avatar
Azilroka committed
306
	PA.Options.args.EnhancedFriendsList.args.General.inline = true
Azilroka's avatar
Azilroka committed
307 308

	PA.Options.args.EnhancedFriendsList.args.General.args.NameSettings = PA.ACH:Group(PA.ACL['Name Settings'], nil, 1)
Azilroka's avatar
Azilroka committed
309
	PA.Options.args.EnhancedFriendsList.args.General.args.NameSettings.inline = true
Azilroka's avatar
Azilroka committed
310 311
	PA.Options.args.EnhancedFriendsList.args.General.args.NameSettings.args.NameFont = PA.ACH:SharedMediaFont(PA.ACL['Name Font'], PA.ACL['The font that the RealID / Character Name / Level uses.'], 1)
	PA.Options.args.EnhancedFriendsList.args.General.args.NameSettings.args.NameFontSize = PA.ACH:Range(PA.ACL['Name Font Size'], PA.ACL['The font that the RealID / Character Name / Level uses.'], 2, { min = 6, max = 22, step = 1 })
Azilroka's avatar
Azilroka committed
312
	PA.Options.args.EnhancedFriendsList.args.General.args.NameSettings.args.NameFontFlag = PA.ACH:FontFlags(PA.ACL['Name Font Flag'], PA.ACL['The font that the RealID / Character Name / Level uses.'], 3)
Azilroka's avatar
Azilroka committed
313 314 315 316
	PA.Options.args.EnhancedFriendsList.args.General.args.NameSettings.args.ShowLevel = PA.ACH:Toggle(PA.ACL['Show Level'], nil, 4)
	PA.Options.args.EnhancedFriendsList.args.General.args.NameSettings.args.DiffLevel = PA.ACH:Toggle(PA.ACL['Level by Difficulty'], nil, 5, nil, nil, nil, nil, nil, function() return (not EFL.db.ShowLevel) end)

	PA.Options.args.EnhancedFriendsList.args.General.args.InfoSettings = PA.ACH:Group(PA.ACL['Info Settings'], nil, 2)
Azilroka's avatar
Azilroka committed
317
	PA.Options.args.EnhancedFriendsList.args.General.args.InfoSettings.inline = true
Azilroka's avatar
Azilroka committed
318 319
	PA.Options.args.EnhancedFriendsList.args.General.args.InfoSettings.args.InfoFont = PA.ACH:SharedMediaFont(PA.ACL['Info Font'], PA.ACL['The font that the Zone / Server uses.'], 1)
	PA.Options.args.EnhancedFriendsList.args.General.args.InfoSettings.args.InfoFontSize = PA.ACH:Range(PA.ACL['Info Font Size'], PA.ACL['The font size that the Zone / Server uses.'], 2, { min = 6, max = 22, step = 1 })
Azilroka's avatar
Azilroka committed
320
	PA.Options.args.EnhancedFriendsList.args.General.args.InfoSettings.args.InfoFontFlag = PA.ACH:FontFlags(PA.ACL['Info Font Outline'], PA.ACL['The font flag that the Zone / Server uses.'], 3)
Azilroka's avatar
Azilroka committed
321 322 323
	PA.Options.args.EnhancedFriendsList.args.General.args.InfoSettings.args.ShowStatusBackground = PA.ACH:Toggle(PA.ACL['Show Status Background'], nil, 4)
	PA.Options.args.EnhancedFriendsList.args.General.args.InfoSettings.args.ShowStatusHighlight = PA.ACH:Toggle(PA.ACL['Show Status Highlight'], nil, 5)
	PA.Options.args.EnhancedFriendsList.args.General.args.InfoSettings.args.Texture = PA.ACH:SharedMediaStatusbar(PA.ACL['Texture'], nil, 6)
Azilroka's avatar
Azilroka committed
324

Azilroka's avatar
Azilroka committed
325 326 327 328
	PA.Options.args.EnhancedFriendsList.args.General.args.IconSettings = PA.ACH:Group(PA.ACL['Icon Settings'], nil, 3)
	PA.Options.args.EnhancedFriendsList.args.General.args.IconSettings.inline = true
	PA.Options.args.EnhancedFriendsList.args.General.args.IconSettings.args.GameIconPack = PA.ACH:Select(PA.ACL['Game Icon Pack'], nil, 1, { Default = 'Default', Launcher = 'Launcher' })
	PA.Options.args.EnhancedFriendsList.args.General.args.IconSettings.args.StatusIconPack = PA.ACH:Select(PA.ACL['Status Icon Pack'], PA.ACL['Different Status Icons.'], 2, { Default = 'Default', Square = 'Square', D3 = 'Diablo 3' })
Azilroka's avatar
Azilroka committed
329 330

	PA.Options.args.EnhancedFriendsList.args.GameIconsPreview = PA.ACH:Group(PA.ACL['Game Icon Preview'], nil, 4)
Azilroka's avatar
Azilroka committed
331
	PA.Options.args.EnhancedFriendsList.args.GameIconsPreview.inline = true
Azilroka's avatar
Azilroka committed
332 333

	PA.Options.args.EnhancedFriendsList.args.StatusIcons = PA.ACH:Group(PA.ACL['Status Icon Preview'], nil, 5)
Azilroka's avatar
Azilroka committed
334
	PA.Options.args.EnhancedFriendsList.args.StatusIcons.inline = true
Azilroka's avatar
Azilroka committed
335

Azilroka's avatar
Azilroka committed
336
	for Key, Value in pairs(EFL.Icons.Game) do
Azilroka's avatar
Azilroka committed
337
		PA.Options.args.EnhancedFriendsList.args.GameIconsPreview.args[Key] = PA.ACH:Execute(Value.Name, nil, Value.Order, nil, function(info) return EFL.Icons.Game[info[#info]][EFL.db.GameIconPack], 32, 32 end)
Azilroka's avatar
Azilroka committed
338
	end
Azilroka's avatar
Azilroka committed
339

Azilroka's avatar
Azilroka committed
340
	for Key, Value in pairs(EFL.Icons.Status) do
Azilroka's avatar
Azilroka committed
341
		PA.Options.args.EnhancedFriendsList.args.StatusIcons.args[Key] = PA.ACH:Execute(Value.Name, nil, Value.Order, nil, function(info) return EFL.Icons.Status[info[#info]][EFL.db.StatusIconPack], 16, 16 end)
Azilroka's avatar
Azilroka committed
342 343
	end

Azilroka's avatar
Azilroka committed
344 345 346 347
	PA.Options.args.EnhancedFriendsList.args.AuthorHeader = PA.ACH:Header(PA.ACL['Authors:'], -4)
	PA.Options.args.EnhancedFriendsList.args.Authors = PA.ACH:Description(EFL.Authors, -3, 'large')
	PA.Options.args.EnhancedFriendsList.args.CreditsHeader = PA.ACH:Header(PA.ACL['Image Credits:'], -2)
	PA.Options.args.EnhancedFriendsList.args.Credits = PA.ACH:Description(EFL.Credits, -1, 'large')
Azilroka's avatar
Azilroka committed
348 349
end

Azilroka's avatar
Azilroka committed
350
function EFL:BuildProfile()
Azilroka's avatar
Azilroka committed
351 352 353 354 355 356 357 358 359 360 361 362 363 364
	PA.Defaults.profile.EnhancedFriendsList = {
		Enable = true,
		NameFont = 'Arial Narrow',
		NameFontSize = 12,
		NameFontFlag = 'OUTLINE',
		InfoFont = 'Arial Narrow',
		InfoFontSize = 12,
		InfoFontFlag = 'OUTLINE',
		StatusIconPack = 'Default',
		ShowLevel = true,
		DiffLevel = true,
		ShowStatusHighlight = true,
		ShowStatusBackground = false,
		Texture = 'Solid',
Azilroka's avatar
Azilroka committed
365
		GameIconPack = 'Launcher'
Azilroka's avatar
Azilroka committed
366
	}
Azilroka's avatar
Azilroka committed
367

Azilroka's avatar
Azilroka committed
368
	if PA.ElvUI then
Azilroka's avatar
Azilroka committed
369 370
		PA.Defaults.profile.EnhancedFriendsList.NameFont = _G.ElvUI[1].db.general.font
		PA.Defaults.profile.EnhancedFriendsList.InfoFont = _G.ElvUI[1].db.general.font
Azilroka's avatar
Azilroka committed
371
	elseif PA.Tukui then
Azilroka's avatar
Azilroka committed
372 373 374 375
		PA.Defaults.profile.EnhancedFriendsList.NameFont = 'Tukui Pixel'
		PA.Defaults.profile.EnhancedFriendsList.InfoFont = 'Tukui Pixel'
		PA.Defaults.profile.EnhancedFriendsList.NameFontFlag = 'MONOCHROMEOUTLINE'
		PA.Defaults.profile.EnhancedFriendsList.InfoFontFlag = 'MONOCHROMEOUTLINE'
Azilroka's avatar
Azilroka committed
376
	end
Azilroka's avatar
Azilroka committed
377 378
end

Azilroka's avatar
Azilroka committed
379
function EFL:HandleBN()
Azilroka's avatar
Azilroka committed
380
	isBNConnected = _G.BNConnected()
Azilroka's avatar
Azilroka committed
381 382
end

Azilroka's avatar
Cleanup  
Azilroka committed
383
function EFL:UpdateSettings()
Azilroka's avatar
Azilroka committed
384
	EFL.db = PA.db.EnhancedFriendsList
Azilroka's avatar
Cleanup  
Azilroka committed
385 386 387 388
end

function EFL:Initialize()
	EFL:UpdateSettings()
Azilroka's avatar
Azilroka committed
389

Azilroka's avatar
Azilroka committed
390 391 392 393
	if EFL.db.Enable ~= true then
		return
	end

Azilroka's avatar
Azilroka committed
394 395
	EFL.isEnabled = true

Azilroka's avatar
Azilroka committed
396 397 398
	EFL:RegisterEvent("BN_CONNECTED", 'HandleBN')
	EFL:RegisterEvent("BN_DISCONNECTED", 'HandleBN')

Azilroka's avatar
Azilroka committed
399 400 401
	if PA.db.FriendGroups and PA.db.FriendGroups.Enable then
		EFL:SecureHook(_G.FriendGroups, 'FriendGroups_UpdateFriendButton', function(_, button) EFL:UpdateFriends(button) end)
	else
Azilroka's avatar
Azilroka committed
402
		EFL:SecureHook("FriendsFrame_UpdateFriendButton", 'UpdateFriends')
Azilroka's avatar
Azilroka committed
403
	end
Azilroka's avatar
Azilroka committed
404
end