BNet.lua

BNet.lua (9.1.5.40906; unchanged since 9.1.5.40871)
  1. local BN_TOAST_TYPE_ONLINE = 1;
  2. local BN_TOAST_TYPE_OFFLINE = 2;
  3. local BN_TOAST_TYPE_BROADCAST = 3;
  4. local BN_TOAST_TYPE_PENDING_INVITES = 4;
  5. local BN_TOAST_TYPE_NEW_INVITE = 5;
  6. local BN_TOAST_TYPE_CLUB_INVITATION = 6;
  7. local BN_TOAST_TYPE_CLUB_FINDER_INVITATION = 7;
  8. BNET_CLIENT_WOW = "WoW";
  9. BNET_CLIENT_SC2 = "S2";
  10. BNET_CLIENT_D3 = "D3";
  11. BNET_CLIENT_WTCG = "WTCG";
  12. BNET_CLIENT_APP = "App";
  13. BNET_CLIENT_HEROES = "Hero";
  14. BNET_CLIENT_OVERWATCH = "Pro";
  15. BNET_CLIENT_CLNT = "CLNT";
  16. BNET_CLIENT_SC = "S1";
  17. BNET_CLIENT_DESTINY2 = "DST2";
  18. BNET_CLIENT_COD = "VIPR";
  19. BNET_CLIENT_COD_MW = "ODIN";
  20. BNET_CLIENT_COD_MW2 = "LAZR";
  21. BNET_CLIENT_COD_BOCW = "ZEUS";
  22. BNET_CLIENT_WC3 = "W3";
  23. BNET_CLIENT_ARCADE = "RTRO";
  24. BNET_CLIENT_CRASH4 = "WLBY";
  25. BNET_CLIENT_D2 = "OSI";
  26. BNET_CLIENT_COD_VANGUARD = "FORE";
  27. WOW_PROJECT_MAINLINE = 1;
  28. WOW_PROJECT_CLASSIC = 2;
  29. WOW_PROJECT_ID = WOW_PROJECT_MAINLINE;
  30. --Name can be a realID or plain battletag with no 4 digit number (e.g. Murky McGrill or LichKing).
  31. function BNet_GetBNetIDAccount(name)
  32. return GetAutoCompletePresenceID(name);
  33. end
  34. function BNet_GetBNetAccountName(accountInfo)
  35. if not accountInfo then
  36. return;
  37. end
  38. local name = accountInfo.accountName;
  39. if name == "" then
  40. name = BNet_GetTruncatedBattleTag(accountInfo.battleTag);
  41. end
  42. return name;
  43. end
  44. --Name must be a character name from your friends list.
  45. function BNet_GetBNetIDAccountFromCharacterName(name)
  46. local _, numBNetOnline = BNGetNumFriends();
  47. for i = 1, numBNetOnline do
  48. local accountInfo = C_BattleNet.GetFriendAccountInfo(i);
  49. if accountInfo and accountInfo.gameAccountInfo.characterName and (strcmputf8i(name, accountInfo.gameAccountInfo.characterName) == 0) then
  50. return accountInfo.bnetAccountID;
  51. end
  52. end
  53. end
  54. -- BNET toast
  55. BNToastMixin = {}
  56. function BNToastMixin:OnLoad()
  57. self.BNToastEvents = {
  58. showToastOnline = { "BN_FRIEND_ACCOUNT_ONLINE" },
  59. showToastOffline = { "BN_FRIEND_ACCOUNT_OFFLINE" },
  60. showToastClubInvitation = { "CLUB_INVITATION_ADDED_FOR_SELF" },
  61. showToastBroadcast = { "BN_CUSTOM_MESSAGE_CHANGED" },
  62. showToastFriendRequest = { "BN_FRIEND_INVITE_ADDED", "BN_FRIEND_INVITE_LIST_INITIALIZED" },
  63. };
  64. self.BNToasts = {};
  65. self.DoubleLine:SetSpacing(3);
  66. self:RegisterEvent("VARIABLES_LOADED");
  67. self:RegisterEvent("BN_DISCONNECTED");
  68. self:RegisterEvent("BN_BLOCK_FAILED_TOO_MANY");
  69. self:RegisterEvent("CLUB_FINDER_APPLICANT_INVITE_RECIEVED");
  70. local alertSystem = ChatAlertFrame:AddAutoAnchoredSubSystem(self);
  71. ChatAlertFrame:SetSubSystemAnchorPriority(alertSystem, 1);
  72. end
  73. function BNToastMixin:OnEvent(event, ...)
  74. if ( event == "BN_DISCONNECTED" ) then
  75. self:ClearToasts();
  76. elseif ( event == "BN_BLOCK_FAILED_TOO_MANY" ) then
  77. self:BlockFailed(...);
  78. elseif ( event == "BN_FRIEND_ACCOUNT_ONLINE" ) then
  79. local friendId, isCompanionApp = ...;
  80. if not isCompanionApp then
  81. self:AddToast(BN_TOAST_TYPE_ONLINE, friendId);
  82. end
  83. elseif ( event == "BN_FRIEND_ACCOUNT_OFFLINE" ) then
  84. local friendId, isCompanionApp = ...;
  85. if not isCompanionApp then
  86. self:AddToast(BN_TOAST_TYPE_OFFLINE, friendId);
  87. end
  88. elseif ( event == "BN_CUSTOM_MESSAGE_CHANGED" ) then
  89. self:OnCustomMessageChanged(...);
  90. elseif ( event == "BN_FRIEND_INVITE_ADDED" ) then
  91. self:AddToast(BN_TOAST_TYPE_NEW_INVITE);
  92. elseif ( event == "CLUB_INVITATION_ADDED_FOR_SELF" ) then
  93. self:AddToast(BN_TOAST_TYPE_CLUB_INVITATION, ...);
  94. elseif ( event == "BN_FRIEND_INVITE_LIST_INITIALIZED" ) then
  95. self:AddToast(BN_TOAST_TYPE_PENDING_INVITES, ...);
  96. elseif (event == "CLUB_FINDER_APPLICANT_INVITE_RECIEVED") then
  97. local clubFinderGUIDS = ...;
  98. for _, clubFinderGUID in ipairs(clubFinderGUIDS) do
  99. if (not C_ClubFinder.DoesPlayerBelongToClubFromClubGUID(clubFinderGUID)) then
  100. local recruitingClubInfo = C_ClubFinder.GetRecruitingClubInfoFromFinderGUID(clubFinderGUID);
  101. local clubStatus = C_ClubFinder.GetPlayerClubApplicationStatus(recruitingClubInfo.clubFinderGUID);
  102. if(clubStatus and clubStatus == Enum.PlayerClubRequestStatus.Approved) then
  103. self:AddToast(BN_TOAST_TYPE_CLUB_FINDER_INVITATION, recruitingClubInfo);
  104. end
  105. end
  106. end
  107. elseif( event == "VARIABLES_LOADED" ) then
  108. self:OnVariablesLoaded();
  109. end
  110. end
  111. function BNToastMixin:OnHide()
  112. self:CheckShowToast();
  113. end
  114. function BNToastMixin:OnEnter()
  115. AlertFrame_PauseOutAnimation(self);
  116. if self.toastType == BN_TOAST_TYPE_BROADCAST and self.BottomLine:IsTruncated() then
  117. self.TooltipFrame.Text:SetText(self.BottomLine:GetText());
  118. self.TooltipFrame:Show();
  119. end
  120. end
  121. function BNToastMixin:OnLeave()
  122. AlertFrame_ResumeOutAnimation(self);
  123. self.TooltipFrame:Hide();
  124. end
  125. function BNToastMixin:OnClick()
  126. local toastType = self.toastType;
  127. local toastData = self.toastData;
  128. self:Hide(); -- will trigger next toast
  129. if toastType == BN_TOAST_TYPE_NEW_INVITE or toastType == BN_TOAST_TYPE_PENDING_INVITES then
  130. if not FriendsFrame:IsShown() then
  131. ToggleFriendsFrame(FRIEND_TAB_FRIENDS);
  132. end
  133. if GetCVarBool("friendInvitesCollapsed") then
  134. FriendsListFrame_ToggleInvites();
  135. end
  136. FriendsTabHeaderTab1:Click();
  137. elseif toastType == BN_TOAST_TYPE_ONLINE or toastType == BN_TOAST_TYPE_BROADCAST then
  138. local accountInfo = C_BattleNet.GetAccountInfoByID(toastData);
  139. if accountInfo then --This player may have been removed from our friends list, so we may not have a name.
  140. ChatFrame_SendBNetTell(accountInfo.accountName);
  141. end
  142. elseif toastType == BN_TOAST_TYPE_CLUB_INVITATION then
  143. Communities_LoadUI();
  144. ShowUIPanel(CommunitiesFrame);
  145. CommunitiesFrame:SelectClub(toastData.club.clubId);
  146. end
  147. end
  148. function BNToastMixin:ClearToasts()
  149. table.wipe(self.BNToasts);
  150. end
  151. function BNToastMixin:BlockFailed(blockType)
  152. if ( blockType == "RID" ) then
  153. StaticPopup_Show("BN_BLOCK_FAILED_TOO_MANY_RID");
  154. elseif ( blockType == "CID" ) then
  155. StaticPopup_Show("BN_BLOCK_FAILED_TOO_MANY_CID");
  156. end
  157. end
  158. function BNToastMixin:OnCustomMessageChanged(toastData)
  159. if toastData then
  160. self:AddToast(BN_TOAST_TYPE_BROADCAST, toastData);
  161. end
  162. end
  163. function BNToastMixin:OnVariablesLoaded()
  164. self:SetToastDuration(GetCVar("toastDuration"));
  165. self:SetToastsEnabled(GetCVarBool("showToastWindow"));
  166. end
  167. function BNToastMixin:EnableToasts()
  168. for cvar, events in pairs(self.BNToastEvents) do
  169. if GetCVarBool(cvar) then
  170. for eventIndex, event in ipairs(events) do
  171. self:RegisterEvent(event);
  172. end
  173. end
  174. end
  175. end
  176. function BNToastMixin:DisableToasts()
  177. self:ClearToasts();
  178. self:Hide();
  179. for cvar, events in pairs(self.BNToastEvents) do
  180. for eventIndex, event in ipairs(events) do
  181. self:UnregisterEvent(event);
  182. end
  183. end
  184. end
  185. function BNToastMixin:UpdateToastEvent(cvar, value)
  186. if GetCVarBool("showToastWindow") then
  187. local events = self.BNToastEvents[cvar];
  188. if events and value == "1" then
  189. for eventIndex, event in pairs(events) do
  190. self:RegisterEvent(event);
  191. end
  192. else
  193. for eventIndex, event in pairs(events) do
  194. self:UnregisterEvent(event);
  195. end
  196. end
  197. end
  198. end
  199. function BNToastMixin:SetToastsEnabled(enabled)
  200. if enabled then
  201. self:EnableToasts();
  202. else
  203. self:DisableToasts();
  204. end
  205. end
  206. function BNToastMixin:SetToastDuration(duration)
  207. self.duration = duration;
  208. end
  209. function BNToastMixin:ShowToast()
  210. local toast = tremove(self.BNToasts, 1);
  211. local toastType, toastData = toast.toastType, toast.toastData;
  212. local self = BNToastFrame;
  213. local topLine = self.TopLine;
  214. local middleLine = self.MiddleLine;
  215. local bottomLine = self.BottomLine;
  216. local doubleLine = self.DoubleLine;
  217. topLine:Hide();
  218. middleLine:Hide();
  219. bottomLine:Hide();
  220. doubleLine:Hide();
  221. if ( toastType == BN_TOAST_TYPE_NEW_INVITE ) then
  222. self.IconTexture:SetTexCoord(0.75, 1, 0, 0.5);
  223. doubleLine:Show();
  224. doubleLine:SetText(BN_TOAST_NEW_INVITE);
  225. doubleLine:SetMaxLines(0);
  226. elseif ( toastType == BN_TOAST_TYPE_PENDING_INVITES ) then
  227. self.IconTexture:SetTexCoord(0.75, 1, 0, 0.5);
  228. doubleLine:Show();
  229. doubleLine:SetFormattedText(BN_TOAST_PENDING_INVITES, toastData);
  230. elseif ( toastType == BN_TOAST_TYPE_ONLINE ) then
  231. local accountInfo = C_BattleNet.GetAccountInfoByID(toastData);
  232. -- don't display a toast if we didn't get the data in time
  233. if not accountInfo then
  234. return;
  235. end
  236. local characterName = BNet_GetValidatedCharacterNameWithClientEmbeddedTexture(accountInfo.gameAccountInfo.characterName, accountInfo.battleTag, accountInfo.gameAccountInfo.clientProgram, 14, 14, 0, -1);
  237. middleLine:SetFormattedText(characterName);
  238. middleLine:SetTextColor(FRIENDS_BNET_NAME_COLOR.r, FRIENDS_BNET_NAME_COLOR.g, FRIENDS_BNET_NAME_COLOR.b);
  239. middleLine:Show();
  240. self.IconTexture:SetTexCoord(0, 0.25, 0.5, 1);
  241. topLine:Show();
  242. topLine:SetText(FRIENDS_BNET_NAME_COLOR:WrapTextInColorCode(accountInfo.accountName));
  243. bottomLine:Show();
  244. bottomLine:SetText(FRIENDS_GRAY_COLOR:WrapTextInColorCode(BN_TOAST_ONLINE));
  245. elseif ( toastType == BN_TOAST_TYPE_OFFLINE ) then
  246. local accountInfo = C_BattleNet.GetAccountInfoByID(toastData);
  247. -- don't display a toast if we didn't get the data in time
  248. if not accountInfo then
  249. return;
  250. end
  251. self.IconTexture:SetTexCoord(0, 0.25, 0.5, 1);
  252. topLine:Show();
  253. topLine:SetFormattedText(FRIENDS_BNET_NAME_COLOR:WrapTextInColorCode(accountInfo.accountName));
  254. bottomLine:Show();
  255. bottomLine:SetText(BN_TOAST_OFFLINE);
  256. bottomLine:SetTextColor(FRIENDS_GRAY_COLOR.r, FRIENDS_GRAY_COLOR.g, FRIENDS_GRAY_COLOR.b);
  257. doubleLine:Hide();
  258. middleLine:Hide();
  259. elseif ( toastType == BN_TOAST_TYPE_BROADCAST ) then
  260. local accountInfo = C_BattleNet.GetAccountInfoByID(toastData);
  261. if not accountInfo or accountInfo.customMessage == "" then
  262. return;
  263. end
  264. BNToastFrameIconTexture:SetTexCoord(0, 0.25, 0, 0.5);
  265. topLine:Show();
  266. topLine:SetText(accountInfo.accountName);
  267. topLine:SetTextColor(FRIENDS_BNET_NAME_COLOR.r, FRIENDS_BNET_NAME_COLOR.g, FRIENDS_BNET_NAME_COLOR.b);
  268. bottomLine:Show();
  269. bottomLine:SetText(accountInfo.customMessage);
  270. bottomLine:SetTextColor(FRIENDS_GRAY_COLOR.r, FRIENDS_GRAY_COLOR.g, FRIENDS_GRAY_COLOR.b);
  271. doubleLine:Hide();
  272. middleLine:Hide();
  273. elseif ( toastType == BN_TOAST_TYPE_CLUB_INVITATION ) then
  274. self.IconTexture:SetTexCoord(0.5, 0.75, 0, 0.5);
  275. doubleLine:Show();
  276. local clubName = "";
  277. if toastData.club.clubType == Enum.ClubType.BattleNet then
  278. clubName = BATTLENET_FONT_COLOR:WrapTextInColorCode(toastData.club.name);
  279. else
  280. clubName = NORMAL_FONT_COLOR:WrapTextInColorCode(toastData.club.name);
  281. end
  282. doubleLine:SetText(BN_TOAST_NEW_CLUB_INVITATION:format(clubName));
  283. doubleLine:SetMaxLines(2);
  284. elseif (toastType == BN_TOAST_TYPE_CLUB_FINDER_INVITATION) then
  285. self.IconTexture:SetTexCoord(0.5, 0.75, 0, 0.5);
  286. doubleLine:Show();
  287. local clubName = "";
  288. clubName = NORMAL_FONT_COLOR:WrapTextInColorCode(toastData.name);
  289. doubleLine:SetText(BN_TOAST_NEW_CLUB_INVITATION:format(clubName));
  290. doubleLine:SetMaxLines(2);
  291. end
  292. if (middleLine:IsShown() and bottomLine:IsShown()) then
  293. bottomLine:SetPoint("TOPLEFT", middleLine, "BOTTOMLEFT", 0, -4);
  294. self:SetHeight(63);
  295. else
  296. bottomLine:SetPoint("TOPLEFT", topLine, "BOTTOMLEFT", 0, -4);
  297. self:SetHeight(50);
  298. end
  299. PlaySound(SOUNDKIT.UI_BNET_TOAST);
  300. self.toastType = toastType;
  301. self.toastData = toastData;
  302. AlertFrame_ShowNewAlert(self);
  303. end
  304. function BNToastMixin:CheckShowToast()
  305. if #self.BNToasts > 0 then
  306. self:ShowToast();
  307. end
  308. end
  309. function BNToastMixin:AddToast(toastType, toastData)
  310. self:RemoveToast(toastType, toastData);
  311. tinsert(self.BNToasts, { toastType = toastType, toastData = toastData });
  312. self:ShowToast();
  313. end
  314. function BNToastMixin:RemoveToast(toastType, toastData)
  315. for toastIndex, toast in ipairs(self.BNToasts) do
  316. if toast.toastType == toastType and toast.toastData == toastData then
  317. tremove(self.BNToasts, toastIndex);
  318. break;
  319. end
  320. end
  321. end
  322. --This is used to track time played for an alert in Korea
  323. BNetTimeAlertMixin = {};
  324. function BNetTimeAlertMixin:OnLoad()
  325. self:RegisterEvent("SESSION_TIME_ALERT");
  326. local alertSystem = ChatAlertFrame:AddAutoAnchoredSubSystem(self);
  327. ChatAlertFrame:SetSubSystemAnchorPriority(alertSystem, 2);
  328. end
  329. function BNetTimeAlertMixin:OnEvent(event, ...)
  330. if not self:IsShown() then
  331. self:Start(...);
  332. end
  333. end
  334. function BNetTimeAlertMixin:Start(time)
  335. self:SetExternallyManagedOutroAnimation(true); -- Initially this needs to display for a set amount of time, after which the alert system takes over and fades it out.
  336. AlertFrame_ShowNewAlert(self);
  337. self.timer = time / 1000;
  338. end
  339. function BNetTimeAlertMixin:OnUpdate(elapsed)
  340. if self.timer then
  341. self.timer = self.timer - elapsed;
  342. if self.timer < 0 then
  343. self:SetExternallyManagedOutroAnimation(false);
  344. AlertFrame_PlayOutroAnimation(self);
  345. self.timer = nil;
  346. end
  347. end
  348. -- As long as this frame is shown, continue to update
  349. self.Text:SetFormattedText(TIME_PLAYED_ALERT, SecondsToTime(GetSessionTime(), true, true));
  350. self:SetHeight(self.Text:GetStringHeight() + 20);
  351. end
  352. function BNet_GetClientEmbeddedTexture(client, width, height, xOffset, yOffset)
  353. width = width or 0;
  354. height = height or width;
  355. xOffset = xOffset or 0;
  356. yOffset = yOffset or 0;
  357. local textureString;
  358. if ( client == BNET_CLIENT_WOW ) then
  359. textureString = "Interface\\ChatFrame\\UI-ChatIcon-WOW";
  360. elseif ( client == BNET_CLIENT_SC2 ) then
  361. textureString = "Interface\\ChatFrame\\UI-ChatIcon-SC2";
  362. elseif ( client == BNET_CLIENT_D3 ) then
  363. textureString = "Interface\\ChatFrame\\UI-ChatIcon-D3";
  364. elseif ( client == BNET_CLIENT_WTCG ) then
  365. textureString = "Interface\\ChatFrame\\UI-ChatIcon-WTCG";
  366. elseif ( client == BNET_CLIENT_HEROES ) then
  367. textureString = "Interface\\ChatFrame\\UI-ChatIcon-HotS";
  368. elseif ( client == BNET_CLIENT_OVERWATCH ) then
  369. textureString = "Interface\\ChatFrame\\UI-ChatIcon-Overwatch";
  370. elseif ( client == BNET_CLIENT_SC ) then
  371. textureString = "Interface\\ChatFrame\\UI-ChatIcon-SC";
  372. elseif ( client == BNET_CLIENT_DESTINY2 ) then
  373. textureString = "Interface\\ChatFrame\\UI-ChatIcon-Destiny2";
  374. elseif ( client == BNET_CLIENT_COD ) then
  375. textureString = "Interface\\ChatFrame\\UI-ChatIcon-CallOfDutyBlackOps4";
  376. elseif ( client == BNET_CLIENT_COD_MW ) then
  377. textureString = "Interface\\ChatFrame\\UI-ChatIcon-CallOfDutyMWicon";
  378. elseif ( client == BNET_CLIENT_COD_MW2 ) then
  379. textureString = "Interface\\ChatFrame\\UI-ChatIcon-CallOfDutyMW2icon";
  380. elseif ( client == BNET_CLIENT_COD_BOCW ) then
  381. textureString = "Interface\\ChatFrame\\UI-ChatIcon-CallOfDutyBlackOpsColdWaricon";
  382. elseif ( client == BNET_CLIENT_WC3 ) then
  383. textureString = "Interface\\ChatFrame\\UI-ChatIcon-Warcraft3Reforged";
  384. elseif ( client == BNET_CLIENT_ARCADE ) then
  385. textureString = "Interface\\ChatFrame\\UI-ChatIcon-BlizzardArcadeCollection";
  386. elseif ( client == BNET_CLIENT_CRASH4 ) then
  387. textureString = "Interface\\ChatFrame\\UI-ChatIcon-CrashBandicoot4";
  388. elseif ( client == BNET_CLIENT_D2 ) then
  389. textureString = "Interface\\ChatFrame\\UI-ChatIcon-DiabloIIResurrected";
  390. elseif ( client == BNET_CLIENT_COD_VANGUARD ) then
  391. textureString = "Interface\\ChatFrame\\UI-ChatIcon-CallOfDutyVanguard";
  392. else
  393. textureString = "Interface\\ChatFrame\\UI-ChatIcon-Battlenet";
  394. end
  395. return string.format("|T%s:%d:%d:%d:%d|t", textureString, width, height, xOffset, yOffset);
  396. end
  397. function BNet_GetClientTexture(client)
  398. if ( client == BNET_CLIENT_WOW ) then
  399. return "Interface\\FriendsFrame\\Battlenet-WoWicon";
  400. elseif ( client == BNET_CLIENT_SC2 ) then
  401. return "Interface\\FriendsFrame\\Battlenet-Sc2icon";
  402. elseif ( client == BNET_CLIENT_D3 ) then
  403. return "Interface\\FriendsFrame\\Battlenet-D3icon";
  404. elseif ( client == BNET_CLIENT_WTCG ) then
  405. return "Interface\\FriendsFrame\\Battlenet-WTCGicon";
  406. elseif ( client == BNET_CLIENT_HEROES ) then
  407. return "Interface\\FriendsFrame\\Battlenet-HotSicon";
  408. elseif ( client == BNET_CLIENT_OVERWATCH ) then
  409. return "Interface\\FriendsFrame\\Battlenet-Overwatchicon";
  410. elseif ( client == BNET_CLIENT_SC ) then
  411. return "Interface\\FriendsFrame\\Battlenet-SCicon";
  412. elseif ( client == BNET_CLIENT_DESTINY2 ) then
  413. return "Interface\\FriendsFrame\\Battlenet-Destiny2icon";
  414. elseif ( client == BNET_CLIENT_COD ) then
  415. return "Interface\\FriendsFrame\\Battlenet-CallOfDutyBlackOps4icon";
  416. elseif ( client == BNET_CLIENT_COD_MW ) then
  417. return "Interface\\FriendsFrame\\Battlenet-CallOfDutyMWicon";
  418. elseif ( client == BNET_CLIENT_COD_MW2 ) then
  419. return "Interface\\FriendsFrame\\Battlenet-CallOfDutyMW2icon";
  420. elseif ( client == BNET_CLIENT_COD_BOCW ) then
  421. return "Interface\\FriendsFrame\\Battlenet-CallOfDutyBlackOpsColdWaricon";
  422. elseif ( client == BNET_CLIENT_WC3 ) then
  423. return "Interface\\FriendsFrame\\Battlenet-Warcraft3Reforged";
  424. elseif ( client == BNET_CLIENT_ARCADE ) then
  425. return "Interface\\FriendsFrame\\Battlenet-BlizzardArcadeCollectionicon";
  426. elseif ( client == BNET_CLIENT_CRASH4 ) then
  427. return "Interface\\FriendsFrame\\Battlenet-CrashBandicoot4icon";
  428. elseif ( client == BNET_CLIENT_D2 ) then
  429. return "Interface\\FriendsFrame\\Battlenet-DiabloIIResurrectedicon";
  430. elseif ( client == BNET_CLIENT_COD_VANGUARD ) then
  431. return "Interface\\FriendsFrame\\Battlenet-CallOfDutyVanguardicon";
  432. else
  433. return "Interface\\FriendsFrame\\Battlenet-Battleneticon";
  434. end
  435. end
  436. function BNet_GetTruncatedBattleTag(battleTag)
  437. if battleTag then
  438. local symbol = string.find(battleTag, "#");
  439. if ( symbol ) then
  440. return string.sub(battleTag, 1, symbol - 1);
  441. else
  442. return battleTag;
  443. end
  444. else
  445. return "";
  446. end
  447. end
  448. -- if we don't have a character name or it's for a game that doesn't have toons like Heroes, use the battletag
  449. function BNet_GetValidatedCharacterName(characterName, battleTag, client, clientTextureSize)
  450. if (not characterName) or (characterName == "") or (client == BNET_CLIENT_HEROES) then
  451. return BNet_GetTruncatedBattleTag(battleTag);
  452. end
  453. return characterName;
  454. end
  455. function BNet_GetValidatedCharacterNameWithClientEmbeddedTexture(characterName, battleTag, client, texWidth, texHeight, texXOffset, texYOffset)
  456. return BNet_GetClientEmbeddedTexture(client, texWidth, texHeight, texXOffset, texYOffset)..BNet_GetValidatedCharacterName(characterName, battleTag, client);
  457. end