Jonner

frenemy

Jun 11th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.40 KB | None | 0 0
  1. -- ----------------------------------------------------------------------------
  2. -- Localized Lua globals.
  3. -- ----------------------------------------------------------------------------
  4. local _G = getfenv(0)
  5.  
  6. local math = _G.math
  7. local string = _G.string
  8. local table = _G.table
  9.  
  10. local pairs = _G.pairs
  11. local tonumber = _G.tonumber
  12. local type = _G.type
  13.  
  14. -- ----------------------------------------------------------------------------
  15. -- AddOn namespace.
  16. -- ----------------------------------------------------------------------------
  17. local FOLDER_NAME, private = ...
  18.  
  19. local LibStub = _G.LibStub
  20. local Frenemy = LibStub("AceAddon-3.0"):NewAddon(FOLDER_NAME, "AceEvent-3.0")
  21.  
  22. local L = LibStub("AceLocale-3.0"):GetLocale(FOLDER_NAME)
  23. local Dialog = LibStub("LibDialog-1.0")
  24. local HereBeDragons = LibStub("HereBeDragons-1.0")
  25. local LibQTip = LibStub('LibQTip-1.0')
  26.  
  27. local DataObject = LibStub("LibDataBroker-1.1"):NewDataObject(FOLDER_NAME, {
  28. icon = [[Interface\Calendar\MeetingIcon]],
  29. text = " ",
  30. type = "data source",
  31. })
  32.  
  33. local RequestUpdater = _G.CreateFrame("Frame")
  34.  
  35. -- ----------------------------------------------------------------------------
  36. -- Constants
  37. -- ----------------------------------------------------------------------------
  38. local CLIENT_SORT_ORDERS = {
  39. [_G.BNET_CLIENT_WOW] = 1,
  40. [_G.BNET_CLIENT_SC2] = 2,
  41. [_G.BNET_CLIENT_D3] = 3,
  42. [_G.BNET_CLIENT_WTCG] = 4,
  43. [_G.BNET_CLIENT_HEROES] = 5,
  44. [_G.BNET_CLIENT_OVERWATCH] = 6,
  45. [_G.BNET_CLIENT_CLNT] = 7,
  46. [_G.BNET_CLIENT_APP] = 8,
  47. }
  48.  
  49. local FRIENDS_WOW_NAME_COLOR = _G.FRIENDS_WOW_NAME_COLOR_CODE:gsub("|cff", "")
  50.  
  51. local FRIENDS_FRAME_TAB_TOGGLES = {
  52. FRIENDS = 1,
  53. WHO = 2,
  54. CHAT = 3,
  55. RAID = 4,
  56. }
  57.  
  58. local HELP_TIP_DEFINITIONS = {
  59. [_G.DISPLAY] = {
  60. [L.LEFT_CLICK] = _G.BINDING_NAME_TOGGLEFRIENDSTAB,
  61. [L.ALT_KEY .. L.LEFT_CLICK] = _G.BINDING_NAME_TOGGLEGUILDTAB,
  62. [L.RIGHT_CLICK] = _G.INTERFACE_OPTIONS,
  63. },
  64. [_G.NAME] = {
  65. [L.LEFT_CLICK] = _G.WHISPER,
  66. [L.RIGHT_CLICK] = _G.ADVANCED_OPTIONS,
  67. [L.ALT_KEY .. L.LEFT_CLICK] = _G.INVITE,
  68. [L.CONTROL_KEY .. L.LEFT_CLICK] = _G.SET_NOTE,
  69. [L.CONTROL_KEY .. L.RIGHT_CLICK] = _G.GUILD_OFFICER_NOTE,
  70. },
  71. }
  72.  
  73. local PLAYER_FACTION = _G.UnitFactionGroup("player")
  74. local PLAYER_NAME = _G.UnitName("player")
  75. local PLAYER_REALM = _G.GetRealmName()
  76.  
  77. local REQUEST_UPDATE_INTERVAL = 30
  78.  
  79. local SORT_ORDER_ASCENDING = 1
  80. local SORT_ORDER_DESCENDING = 2
  81.  
  82. local SORT_ORDER_NAMES = {
  83. [SORT_ORDER_ASCENDING] = "Ascending",
  84. [SORT_ORDER_DESCENDING] = "Descending",
  85. }
  86.  
  87. -- ----------------------------------------------------------------------------
  88. -- Icons
  89. -- ----------------------------------------------------------------------------
  90. local function CreateIcon(texture_path, icon_size)
  91. return ("|T%s:%d|t"):format(texture_path, icon_size or 0)
  92. end
  93.  
  94. local BROADCAST_ICON = CreateIcon([[Interface\FriendsFrame\BroadcastIcon]])
  95.  
  96. local CLIENT_ICON_TEXTURE_CODES = {}
  97. do
  98. local CLIENT_ICON_SIZE = 18
  99.  
  100. for clientToken in pairs(CLIENT_SORT_ORDERS) do
  101. CLIENT_ICON_TEXTURE_CODES[clientToken] = _G.BNet_GetClientEmbeddedTexture(clientToken, CLIENT_ICON_SIZE, CLIENT_ICON_SIZE)
  102. end
  103. end
  104.  
  105. local CLASS_ICONS = {}
  106. do
  107. local textureFormat = [[|TInterface\TargetingFrame\UI-CLASSES-CIRCLES:0:0:0:0:256:256:%d:%d:%d:%d|t]]
  108. local textureSize = 256
  109. local increment = 64
  110. local left = 0
  111. local right = increment
  112. local top = 0
  113. local bottom = increment
  114.  
  115. -- This is the order in which the icons appear in the UI-CLASSES-CIRCLES image.
  116. local CLASS_ICON_SORT_ORDER = {
  117. "WARRIOR",
  118. "MAGE",
  119. "ROGUE",
  120. "DRUID",
  121. "HUNTER",
  122. "SHAMAN",
  123. "PRIEST",
  124. "WARLOCK",
  125. "PALADIN",
  126. "DEATHKNIGHT",
  127. "MONK",
  128. }
  129.  
  130. for index = 1, #CLASS_ICON_SORT_ORDER do
  131. local class_name = CLASS_ICON_SORT_ORDER[index]
  132. CLASS_ICONS[class_name] = textureFormat:format(left, right, top, bottom)
  133.  
  134. if bottom == textureSize then
  135. break
  136. end
  137.  
  138. if right == textureSize then
  139. left = 0
  140. right = increment
  141. top = top + increment
  142. bottom = bottom + increment
  143. else
  144. left = left + increment
  145. right = right + increment
  146. end
  147. end
  148. end
  149.  
  150. local CLASS_COLORS = {}
  151. local CLASS_TOKEN_FROM_NAME_FEMALE = {}
  152. local CLASS_TOKEN_FROM_NAME_MALE = {}
  153. do
  154. for classToken, localizedName in pairs(_G.LOCALIZED_CLASS_NAMES_FEMALE) do
  155. local color = _G.RAID_CLASS_COLORS[classToken]
  156. CLASS_COLORS[localizedName] = ("%02x%02x%02x"):format(color.r * 255, color.g * 255, color.b * 255)
  157. CLASS_TOKEN_FROM_NAME_FEMALE[localizedName] = classToken
  158. end
  159.  
  160. for classToken, localizedName in pairs(_G.LOCALIZED_CLASS_NAMES_MALE) do
  161. local color = _G.RAID_CLASS_COLORS[classToken]
  162. CLASS_COLORS[localizedName] = ("%02x%02x%02x"):format(color.r * 255, color.g * 255, color.b * 255)
  163. CLASS_TOKEN_FROM_NAME_MALE[localizedName] = classToken
  164. end
  165. end -- do-blcok
  166.  
  167. local COLUMN_ICON_CLASS = CreateIcon([[Interface\GossipFrame\TrainerGossipIcon]])
  168. local COLUMN_ICON_GAME = CreateIcon([[Interface\Buttons\UI-GroupLoot-Dice-Up]])
  169. local COLUMN_ICON_LEVEL = CreateIcon([[Interface\GROUPFRAME\UI-GROUP-MAINASSISTICON]])
  170.  
  171. local FACTION_ICON_SIZE = 18
  172. local FACTION_ICON_ALLIANCE = CreateIcon([[Interface\COMMON\icon-alliance]], FACTION_ICON_SIZE)
  173. local FACTION_ICON_HORDE = CreateIcon([[Interface\COMMON\icon-horde]], FACTION_ICON_SIZE)
  174. local FACTION_ICON_NEUTRAL = CreateIcon([[Interface\COMMON\Indicator-Gray]], FACTION_ICON_SIZE)
  175.  
  176. local HELP_ICON = CreateIcon([[Interface\COMMON\help-i]], 20)
  177.  
  178. local PLAYER_ICON_GROUP = [[|TInterface\Scenarios\ScenarioIcon-Check:0|t]]
  179. local PLAYER_ICON_FACTION = PLAYER_FACTION == "Horde" and FACTION_ICON_HORDE or (PLAYER_FACTION == "Alliance" and FACTION_ICON_ALLIANCE) or FACTION_ICON_NEUTRAL
  180.  
  181. local SECTION_ICON_DISABLED = CreateIcon([[Interface\COMMON\Indicator-Red]])
  182. local SECTION_ICON_ENABLED = CreateIcon([[Interface\COMMON\Indicator-Green]])
  183.  
  184. local SORT_ICON_ASCENDING = CreateIcon([[Interface\Buttons\Arrow-Up-Up]])
  185. local SORT_ICON_DESCENDING = CreateIcon([[Interface\Buttons\Arrow-Down-Up]])
  186.  
  187. local STATUS_ICON_AFK = CreateIcon(_G.FRIENDS_TEXTURE_AFK)
  188. local STATUS_ICON_DND = CreateIcon(_G.FRIENDS_TEXTURE_DND)
  189. local STATUS_ICON_MOBILE_AWAY = CreateIcon([[Interface\ChatFrame\UI-ChatIcon-ArmoryChat-AwayMobile]])
  190. local STATUS_ICON_MOBILE_BUSY = CreateIcon([[Interface\ChatFrame\UI-ChatIcon-ArmoryChat-BusyMobile]])
  191. local STATUS_ICON_MOBILE_ONLINE = CreateIcon([[Interface\ChatFrame\UI-ChatIcon-ArmoryChat]])
  192. local STATUS_ICON_NOTE = CreateIcon(_G.FRIENDS_TEXTURE_OFFLINE)
  193. local STATUS_ICON_ONLINE = CreateIcon(_G.FRIENDS_TEXTURE_ONLINE)
  194.  
  195. -- ----------------------------------------------------------------------------
  196. -- Variables
  197. -- ----------------------------------------------------------------------------
  198. local DB
  199. local HelpTip
  200. local Tooltip
  201.  
  202. -- Statistics: Populated and maintained in UpdateStatistics()
  203. local OnlineBattleNetCount = 0
  204. local OnlineFriendsCount = 0
  205. local OnlineGuildMembersCount = 0
  206.  
  207. local TotalBattleNetCount = 0
  208. local TotalFriendsCount = 0
  209. local TotalGuildMembersCount = 0
  210.  
  211. -- Zone data
  212. local CurrentZoneID
  213.  
  214. -- Populated from SavedVariables and during travel.
  215. local ZoneColorsByName = {
  216. [_G.GARRISON_LOCATION_TOOLTIP] = private.ZonePVPStatusRGB[private.ZonePVPStatus.Normal]
  217. }
  218.  
  219. -- ----------------------------------------------------------------------------
  220. -- Enumerations and data for sorting.
  221. -- ----------------------------------------------------------------------------
  222. --- Changing the order will cause SavedVariables to no longer map appropriately.
  223. local SortFields = {
  224. BattleNetApp = {
  225. "GameText",
  226. "PresenceName",
  227. "ToonName",
  228. "Note",
  229. },
  230. BattleNetGames = {
  231. "ClientIndex",
  232. "GameText",
  233. "PresenceName",
  234. "ToonName",
  235. "Note",
  236. },
  237. Guild = {
  238. "Level",
  239. "RankIndex",
  240. "ToonName",
  241. "ZoneName",
  242. "PublicNote",
  243. "OfficerNote",
  244. "Class",
  245. },
  246. WoWFriends = {
  247. "Level",
  248. "PresenceName",
  249. "RealmName",
  250. "ToonName",
  251. "ZoneName",
  252. "Note",
  253. "Class",
  254. },
  255. }
  256.  
  257. local SortFieldIDs = {}
  258. local SortFieldNames = {}
  259. local SortFunctions = {}
  260.  
  261. for sectionName, fieldNameList in pairs(SortFields) do
  262. local IDList = {}
  263. SortFieldIDs[sectionName] = IDList
  264.  
  265. local nameList = {}
  266. SortFieldNames[sectionName] = nameList
  267.  
  268. for index = 1, #fieldNameList do
  269. IDList[fieldNameList[index]] = index
  270. nameList[index] = fieldNameList[index]
  271.  
  272. local sortFuncName = sectionName .. fieldNameList[index]
  273. SortFunctions[sortFuncName .. SORT_ORDER_NAMES[SORT_ORDER_ASCENDING]] = function(a, b)
  274. local aField = a[fieldNameList[index]] or ""
  275. aField = type(aField) == "string" and aField:lower() or aField
  276.  
  277. local bField = b[fieldNameList[index]] or ""
  278. bField = type(bField) == "string" and bField:lower() or bField
  279.  
  280. if aField == bField then
  281. return a.ToonName:lower() < b.ToonName:lower()
  282. end
  283.  
  284. return aField < bField
  285. end
  286.  
  287. SortFunctions[sortFuncName .. SORT_ORDER_NAMES[SORT_ORDER_DESCENDING]] = function(a, b)
  288. local aField = a[fieldNameList[index]] or ""
  289. aField = type(aField) == "string" and aField:lower() or aField
  290.  
  291. local bField = b[fieldNameList[index]] or ""
  292. bField = type(bField) == "string" and bField:lower() or bField
  293.  
  294. if aField == bField then
  295. return a.ToonName:lower() > b.ToonName:lower()
  296. end
  297.  
  298. return aField > bField
  299. end
  300. end
  301. end
  302.  
  303. -- ----------------------------------------------------------------------------
  304. -- Default settings
  305. -- ----------------------------------------------------------------------------
  306. local DB_DEFAULTS = {
  307. global = {
  308. DataObject = {
  309. MinimapIcon = {
  310. hide = false,
  311. },
  312. },
  313. Tooltip = {
  314. CollapsedSections = {
  315. BattleNetApp = false,
  316. BattleNetGames = false,
  317. Guild = false,
  318. WoWFriends = false,
  319. },
  320. HideDelay = 0.25,
  321. NotesArrangement = {
  322. BattleNetApp = private.NotesArrangementType.Row,
  323. BattleNetGames = private.NotesArrangementType.Row,
  324. Guild = private.NotesArrangementType.Row,
  325. GuildOfficer = private.NotesArrangementType.Row,
  326. WoWFriends = private.NotesArrangementType.Row,
  327. },
  328. SectionDisplayOrders = {
  329. "WoWFriends",
  330. "BattleNetGames",
  331. "BattleNetApp",
  332. "Guild",
  333. },
  334. Scale = 1,
  335. Sorting = {
  336. BattleNetApp = {
  337. Field = SortFieldIDs.BattleNetApp.PresenceName,
  338. Order = SORT_ORDER_ASCENDING,
  339. },
  340. BattleNetGames = {
  341. Field = SortFieldIDs.BattleNetGames.PresenceName,
  342. Order = SORT_ORDER_ASCENDING,
  343. },
  344. Guild = {
  345. Field = SortFieldIDs.Guild.ToonName,
  346. Order = SORT_ORDER_ASCENDING,
  347. },
  348. WoWFriends = {
  349. Field = SortFieldIDs.WoWFriends.ToonName,
  350. Order = SORT_ORDER_ASCENDING,
  351. },
  352. },
  353. },
  354. ZoneData = {}, -- Populated during travel.
  355. }
  356. }
  357.  
  358. -- ----------------------------------------------------------------------------
  359. -- Dialogs
  360. -- ----------------------------------------------------------------------------
  361. Dialog:Register("FrenemySetGuildMOTD", {
  362. editboxes = {
  363. {
  364. on_enter_pressed = function(self)
  365. _G.GuildSetMOTD(self:GetText())
  366. Dialog:Dismiss("FrenemySetGuildMOTD")
  367. end,
  368. on_escape_pressed = function(self)
  369. Dialog:Dismiss("FrenemySetGuildMOTD")
  370. end,
  371. on_show = function(self)
  372. self:SetText(_G.GetGuildRosterMOTD())
  373. end,
  374. auto_focus = true,
  375. label = _G.GREEN_FONT_COLOR_CODE .. _G.GUILDCONTROL_OPTION9 .. "|r",
  376. max_letters = 128,
  377. text = _G.GetGuildRosterMOTD(),
  378. width = 200,
  379. },
  380. },
  381. show_while_dead = true,
  382. hide_on_escape = true,
  383. icon = [[Interface\Calendar\MeetingIcon]],
  384. width = 400,
  385. on_show = function(self, text)
  386. self.text:SetFormattedText("%s%s|r", _G.BATTLENET_FONT_COLOR_CODE, FOLDER_NAME)
  387. end
  388. })
  389.  
  390. -- ----------------------------------------------------------------------------
  391. -- Helpers
  392. -- ----------------------------------------------------------------------------
  393. local function ColorPlayerLevel(level)
  394. if type(level) ~= "number" then
  395. return level
  396. end
  397. local color = _G.GetRelativeDifficultyColor(_G.UnitLevel("player"), level)
  398. return ("|cff%02x%02x%02x%d|r"):format(color.r * 255, color.g * 255, color.b * 255, level)
  399. end
  400.  
  401. local function ColorZoneName(zoneName)
  402. local color = ZoneColorsByName[zoneName:gsub(" %b()", "")] or _G.GRAY_FONT_COLOR
  403. return ("|cff%02x%02x%02x%s|r"):format(color.r * 255, color.g * 255, color.b * 255, zoneName or _G.UNKNOWN)
  404. end
  405.  
  406. local function IsGrouped(name)
  407. return (_G.GetNumSubgroupMembers() > 0 and _G.UnitInParty(name)) or (_G.GetNumGroupMembers() > 0 and _G.UnitInRaid(name))
  408. end
  409.  
  410. local function PercentColorGradient(min, max)
  411. local red_low, green_low, blue_low = 1, 0.10, 0.10
  412. local red_mid, green_mid, blue_mid = 1, 1, 0
  413. local red_high, green_high, blue_high = 0.25, 0.75, 0.25
  414. local percentage = min / max
  415.  
  416. if percentage >= 1 then
  417. return red_high, green_high, blue_high
  418. elseif percentage <= 0 then
  419. return red_low, green_low, blue_low
  420. end
  421. local integral, fractional = math.modf(percentage * 2)
  422.  
  423. if integral == 1 then
  424. red_low, green_low, blue_low, red_mid, green_mid, blue_mid = red_mid, green_mid, blue_mid, red_high, green_high, blue_high
  425. end
  426. return red_low + (red_mid - red_low) * fractional, green_low + (green_mid - green_low) * fractional, blue_low + (blue_mid - blue_low) * fractional
  427. end
  428.  
  429. local function SetZoneNameColors(zoneID, zonePVPStatus)
  430. local mapName = _G.GetMapNameByID(zoneID)
  431. if not mapName then
  432. DB.ZoneData[zoneID] = nil
  433. return
  434. end
  435. ZoneColorsByName[mapName] = private.ZonePVPStatusRGB[zonePVPStatus]
  436. end
  437.  
  438. local function UpdateStatistics()
  439. TotalBattleNetCount, OnlineBattleNetCount = _G.BNGetNumFriends()
  440. TotalFriendsCount, OnlineFriendsCount = _G.GetNumFriends()
  441.  
  442. if _G.IsInGuild() then
  443. local _
  444. TotalGuildMembersCount, _, OnlineGuildMembersCount = _G.GetNumGuildMembers()
  445. end
  446. end
  447.  
  448. -- ----------------------------------------------------------------------------
  449. -- Tooltip.
  450. -- ----------------------------------------------------------------------------
  451. local DrawTooltip
  452. do
  453. local BattleNetColumns = {
  454. Client = 1,
  455. PresenceName = 2,
  456. ToonName = 4,
  457. GameText = 5,
  458. Note = 7,
  459. }
  460.  
  461. local BattleNetColSpans = {
  462. Client = 1,
  463. PresenceName = 2,
  464. ToonName = 1,
  465. GameText = 2,
  466. Note = 2,
  467. }
  468.  
  469. local GuildColumns = {
  470. Level = 1,
  471. Class = 2,
  472. ToonName = 3,
  473. Rank = 4,
  474. ZoneName = 5,
  475. PublicNote = 6,
  476. OfficerNote = 8,
  477. }
  478.  
  479. local GuildColSpans = {
  480. Level = 1,
  481. Class = 1,
  482. ToonName = 1,
  483. Rank = 1,
  484. ZoneName = 1,
  485. PublicNote = 2,
  486. OfficerNote = 2,
  487. }
  488.  
  489. local WoWFriendsColumns = {
  490. Level = 1,
  491. Class = 2,
  492. PresenceName = 3,
  493. ToonName = 4,
  494. ZoneName = 5,
  495. RealmName = 6,
  496. Note = 7,
  497. }
  498.  
  499. local WoWFriendsColSpans = {
  500. Level = 1,
  501. Class = 1,
  502. PresenceName = 1,
  503. ToonName = 1,
  504. ZoneName = 1,
  505. RealmName = 1,
  506. Note = 2,
  507. }
  508.  
  509. local PlayerLists = {
  510. BattleNetApp = {},
  511. BattleNetGames = {},
  512. Guild = {},
  513. WoWFriends = {},
  514. }
  515.  
  516. local NUM_TOOLTIP_COLUMNS = 10
  517.  
  518. local TooltipAnchor
  519.  
  520. -- Used to handle duplication between in-game and RealID friends.
  521. local OnlineFriendsByName = {}
  522. local GuildMemberIndexByName = {}
  523. local WoWFriendIndexByName = {}
  524.  
  525. -- ----------------------------------------------------------------------------
  526. -- Data compilation.
  527. -- ----------------------------------------------------------------------------
  528. local function GenerateTooltipData()
  529. for name, data in pairs(PlayerLists) do
  530. table.wipe(data)
  531. end
  532. table.wipe(OnlineFriendsByName)
  533. table.wipe(GuildMemberIndexByName)
  534. table.wipe(WoWFriendIndexByName)
  535.  
  536. if OnlineFriendsCount > 0 then
  537. for friendIndex = 1, OnlineFriendsCount do
  538. local fullToonName, level, class, zoneName, connected, status, note = _G.GetFriendInfo(friendIndex)
  539. local toonName, realmName = ("-"):split(fullToonName)
  540.  
  541. WoWFriendIndexByName[fullToonName] = friendIndex
  542. WoWFriendIndexByName[toonName] = friendIndex
  543.  
  544. local entry = {
  545. Class = class,
  546. FullToonName = fullToonName,
  547. IsLocalFriend = true,
  548. Level = level,
  549. Note = note,
  550. RealmName = realmName or PLAYER_REALM,
  551. StatusIcon = status == _G.CHAT_FLAG_AFK and STATUS_ICON_AFK or (status == _G.CHAT_FLAG_DND and STATUS_ICON_DND or STATUS_ICON_ONLINE),
  552. ToonName = toonName,
  553. ZoneName = zoneName ~= "" and zoneName or _G.UNKNOWN,
  554. }
  555.  
  556. OnlineFriendsByName[toonName] = entry
  557. table.insert(PlayerLists.WoWFriends, entry)
  558. end
  559. end
  560.  
  561. if OnlineBattleNetCount > 0 then
  562. for battleNetIndex = 1, OnlineBattleNetCount do
  563. local presenceID, presenceName, battleTag, isBattleTagPresence, _, toonID, client, isOnline, _, isAFK, isDND, broadcastText, noteText, isRIDFriend, broadcastTime = _G.BNGetFriendInfo(battleNetIndex)
  564. local numToons = _G.BNGetNumFriendGameAccounts(battleNetIndex)
  565.  
  566. for toonIndex = 1, numToons do
  567. local hasFocus, toonName, client, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = _G.BNGetFriendGameAccountInfo(battleNetIndex, toonIndex)
  568. local characterName = _G.BNet_GetValidatedCharacterName(toonName, battleTag, client)
  569. local entry = {
  570. BroadcastText = (broadcastText and broadcastText ~= "") and BROADCAST_ICON .. _G.FRIENDS_OTHER_NAME_COLOR_CODE .. broadcastText .. "|r" or nil,
  571. Class = class,
  572. Client = client,
  573. ClientIndex = CLIENT_SORT_ORDERS[client],
  574. FactionIcon = faction and faction == "Horde" and FACTION_ICON_HORDE or (faction == "Alliance" and FACTION_ICON_ALLIANCE) or FACTION_ICON_NEUTRAL,
  575. GameText = gameText ~= "" and gameText or _G.UNKNOWN,
  576. Level = level and tonumber(level) or 0,
  577. Note = noteText ~= "" and noteText,
  578. PresenceID = presenceID,
  579. PresenceName = presenceName or _G.UNKNOWN,
  580. RealmName = realmName or "",
  581. StatusIcon = isAFK and STATUS_ICON_AFK or (isDND and STATUS_ICON_DND or STATUS_ICON_ONLINE),
  582. ToonName = characterName,
  583. ZoneName = zoneName ~= "" and zoneName or _G.UNKNOWN,
  584. }
  585.  
  586.  
  587. local PresenceName2 = presenceName or _G.UNKNOWN
  588.  
  589.  
  590. if client == _G.BNET_CLIENT_WOW then
  591. local existingFriend = OnlineFriendsByName[toonName]
  592.  
  593. if realmName == PLAYER_REALM and existingFriend then
  594. for key, value in pairs(entry) do
  595. if not existingFriend[key] then
  596. existingFriend[key] = value
  597. end
  598. end
  599. else
  600.  
  601.  
  602. addFriend = 1
  603. if #PlayerLists.WoWFriends > 0 then
  604. for i=1, #PlayerLists.WoWFriends do
  605. if PlayerLists.WoWFriends[i].PresenceName == PresenceName2 then
  606. addFriend = 0
  607. break
  608. end
  609. end
  610. end
  611. if addFriend == 1 then
  612. table.insert(PlayerLists.WoWFriends, entry)
  613. end
  614.  
  615.  
  616. end
  617. elseif client == _G.BNET_CLIENT_APP or client == _G.BNET_CLIENT_CLNT then
  618.  
  619.  
  620. addFriend = 1
  621. if #PlayerLists.BattleNetApp > 0 then
  622. for i=1, #PlayerLists.BattleNetApp do
  623. if PlayerLists.BattleNetApp[i].PresenceName == PresenceName2 then
  624. addFriend = 0
  625. break
  626. end
  627. end
  628. end
  629. if addFriend == 1 then
  630. table.insert(PlayerLists.BattleNetApp, entry)
  631. end
  632.  
  633.  
  634. elseif toonID then
  635.  
  636.  
  637. addFriend = 1
  638. if #PlayerLists.BattleNetGames > 0 then
  639. for i=1, #PlayerLists.BattleNetGames do
  640. if PlayerLists.BattleNetGames[i].PresenceName == PresenceName2 then
  641. addFriend = 0
  642. break
  643. end
  644. end
  645. end
  646. if addFriend == 1 then
  647. table.insert(PlayerLists.BattleNetGames, entry)
  648. end
  649.  
  650.  
  651. end
  652. end
  653. end
  654. end
  655.  
  656. if _G.IsInGuild() then
  657. for index = 1, _G.GetNumGuildMembers() do
  658. local fullToonName, rank, rankIndex, level, class, zoneName, note, officerNote, isOnline, awayStatus, _, _, _, isMobile = _G.GetGuildRosterInfo(index)
  659.  
  660. if isOnline or isMobile then
  661. local toonName, realmName = ("-"):split(fullToonName)
  662.  
  663. local statusIcon
  664. if awayStatus == 0 then
  665. statusIcon = isOnline and STATUS_ICON_ONLINE or STATUS_ICON_MOBILE_ONLINE
  666. elseif awayStatus == 1 then
  667. statusIcon = isOnline and STATUS_ICON_AFK or STATUS_ICON_MOBILE_AWAY
  668. elseif awayStatus == 2 then
  669. statusIcon = isOnline and STATUS_ICON_DND or STATUS_ICON_MOBILE_BUSY
  670. end
  671.  
  672. -- Don't rely on the zoneName from GetGuildRosterInfo - it can be slow, and the player should see their own zone change instantaneously if
  673. -- traveling with the tooltip showing.
  674. if isOnline and toonName == PLAYER_NAME then
  675. zoneName = CurrentZoneID and _G.GetMapNameByID(CurrentZoneID) or _G.UNKNOWN
  676. end
  677.  
  678. GuildMemberIndexByName[fullToonName] = index
  679. GuildMemberIndexByName[toonName] = index
  680.  
  681. table.insert(PlayerLists.Guild, {
  682. Class = class,
  683. FullToonName = fullToonName,
  684. IsMobile = isMobile,
  685. Level = level,
  686. OfficerNote = officerNote ~= "" and officerNote or nil,
  687. PublicNote = note ~= "" and note or nil,
  688. Rank = rank,
  689. RankIndex = rankIndex,
  690. RealmName = realmName or PLAYER_REALM,
  691. StatusIcon = statusIcon,
  692. ToonName = toonName,
  693. ZoneName = isMobile and (isOnline and ("%s %s"):format(zoneName, _G.PARENS_TEMPLATE:format(_G.REMOTE_CHAT)) or _G.REMOTE_CHAT) or (zoneName or _G.UNKNOWN),
  694. })
  695. end
  696. end
  697. end
  698.  
  699. for listName, list in pairs(PlayerLists) do
  700. local savedSortField = DB.Tooltip.Sorting[listName]
  701. table.sort(list, SortFunctions[listName .. SortFieldNames[listName][savedSortField.Field] .. SORT_ORDER_NAMES[savedSortField.Order]])
  702. end
  703. end
  704.  
  705. -- ----------------------------------------------------------------------------
  706. -- Controls
  707. -- ----------------------------------------------------------------------------
  708. local function BattleNetFriend_OnMouseUp(tooltipCell, playerEntry, button)
  709. _G.PlaySound("igMainMenuOptionCheckBoxOn")
  710.  
  711. if button == "LeftButton" then
  712. if _G.IsAltKeyDown() and playerEntry.RealmName == PLAYER_REALM then
  713. _G.InviteToGroup(playerEntry.ToonName)
  714. elseif _G.IsControlKeyDown() then
  715. _G.FriendsFrame.NotesID = playerEntry.PresenceID
  716. _G.StaticPopup_Show("SET_BNFRIENDNOTE", playerEntry.PresenceName)
  717. elseif not _G.BNIsSelf(playerEntry.PresenceID) then
  718. _G.ChatFrame_SendSmartTell(playerEntry.PresenceName)
  719. end
  720. elseif button == "RightButton" then
  721. Tooltip:SetFrameStrata("DIALOG")
  722. _G.CloseDropDownMenus()
  723. _G.FriendsFrame_ShowBNDropdown(playerEntry.PresenceName, true, nil, nil, nil, true, playerEntry.PresenceID)
  724. end
  725. end
  726.  
  727. local function GuildMember_OnMouseUp(tooltipCell, playerEntry, button)
  728. if not _G.IsAddOnLoaded("Blizzard_GuildUI") then
  729. _G.LoadAddOn("Blizzard_GuildUI")
  730. end
  731.  
  732. _G.PlaySound("igMainMenuOptionCheckBoxOn")
  733.  
  734. local playerName = playerEntry.Realm == PLAYER_REALM and playerEntry.ToonName or playerEntry.FullToonName
  735.  
  736. if button == "LeftButton" then
  737. if _G.IsAltKeyDown() then
  738. _G.InviteToGroup(playerName)
  739. elseif _G.IsControlKeyDown() and _G.CanEditPublicNote() then
  740. _G.SetGuildRosterSelection(GuildMemberIndexByName[playerName])
  741. _G.StaticPopup_Show("SET_GUILDPLAYERNOTE")
  742. else
  743. _G.ChatFrame_SendTell(playerName)
  744. end
  745. elseif button == "RightButton" then
  746. if _G.IsControlKeyDown() and _G.CanEditOfficerNote() then
  747. _G.SetGuildRosterSelection(GuildMemberIndexByName[playerName])
  748. _G.StaticPopup_Show("SET_GUILDOFFICERNOTE")
  749. else
  750. Tooltip:SetFrameStrata("DIALOG")
  751. _G.CloseDropDownMenus()
  752. _G.GuildRoster_ShowMemberDropDown(playerName, true, playerEntry.IsMobile)
  753. end
  754. end
  755. end
  756.  
  757. local function GuildMOTD_OnMouseUp(tooltipCell)
  758. Dialog:Spawn("FrenemySetGuildMOTD")
  759. end
  760.  
  761. local function ToggleColumnSortMethod(tooltipCell, sortFieldData)
  762. local sectionName, fieldName = (":"):split(sortFieldData)
  763.  
  764. if not sectionName or not fieldName then
  765. return
  766. end
  767.  
  768. local savedSortField = DB.Tooltip.Sorting[sectionName]
  769. local columnSortFieldID = SortFieldIDs[sectionName][fieldName]
  770.  
  771. if savedSortField.Field == columnSortFieldID then
  772. savedSortField.Order = savedSortField.Order == SORT_ORDER_ASCENDING and SORT_ORDER_DESCENDING or SORT_ORDER_ASCENDING
  773. else
  774. savedSortField = DB.Tooltip.Sorting[sectionName]
  775. savedSortField.Field = columnSortFieldID
  776. savedSortField.Order = SORT_ORDER_ASCENDING
  777. end
  778.  
  779. table.sort(PlayerLists[sectionName], SortFunctions[sectionName .. fieldName .. SORT_ORDER_NAMES[savedSortField.Order]])
  780. DrawTooltip(TooltipAnchor)
  781. end
  782.  
  783. local SectionDropDown = _G.CreateFrame("Frame", FOLDER_NAME .. "SectionDropDown", _G.UIParent, "UIDropDownMenuTemplate")
  784. SectionDropDown.displayMode = "MENU"
  785. SectionDropDown.info = {}
  786. SectionDropDown.levelAdjust = 0
  787.  
  788. local function ChangeSectionOrder(self, currentPosition, direction)
  789. local sectionEntries = DB.Tooltip.SectionDisplayOrders
  790. local newPosition
  791.  
  792. currentPosition = tonumber(currentPosition)
  793.  
  794. if direction == "up" then
  795. newPosition = currentPosition - 1
  796. elseif direction == "down" then
  797. newPosition = currentPosition + 1
  798. end
  799.  
  800. if not newPosition then
  801. return
  802. end
  803.  
  804. local evictedEntry = sectionEntries[newPosition]
  805. sectionEntries[newPosition] = sectionEntries[currentPosition]
  806. sectionEntries[currentPosition] = evictedEntry
  807. DrawTooltip(TooltipAnchor)
  808. end
  809.  
  810. local function ToggleSectionVisibility(self, sectionName)
  811. DB.Tooltip.CollapsedSections[sectionName] = not DB.Tooltip.CollapsedSections[sectionName]
  812. DrawTooltip(TooltipAnchor)
  813. end
  814.  
  815. local function InitializeSectionDropDown(self, level)
  816. if not level then
  817. return
  818. end
  819. local info = SectionDropDown.info
  820. table.wipe(info)
  821.  
  822. if level == 1 then
  823. local sectionName = _G.UIDROPDOWNMENU_MENU_VALUE
  824.  
  825. info.arg1 = sectionName
  826. info.func = ToggleSectionVisibility
  827. info.notCheckable = true
  828. info.text = DB.Tooltip.CollapsedSections[sectionName] and L.EXPAND_SECTION or L.COLLAPSE_SECTION
  829. _G.UIDropDownMenu_AddButton(info, level)
  830.  
  831. local currentPosition
  832.  
  833. for index = 1, #DB.Tooltip.SectionDisplayOrders do
  834. if DB.Tooltip.SectionDisplayOrders[index] == sectionName then
  835. currentPosition = index
  836. break
  837. end
  838. end
  839.  
  840. if not currentPosition then
  841. return
  842. end
  843.  
  844. info.arg1 = currentPosition
  845. info.func = ChangeSectionOrder
  846.  
  847. if currentPosition ~= 1 then
  848. info.arg2 = "up"
  849. info.text = L.MOVE_SECTION_UP
  850. _G.UIDropDownMenu_AddButton(info, level)
  851. end
  852.  
  853. if currentPosition ~= #DB.Tooltip.SectionDisplayOrders then
  854. info.arg2 = "down"
  855. info.text = L.MOVE_SECTION_DOWN
  856. _G.UIDropDownMenu_AddButton(info, level)
  857. end
  858. end
  859. end
  860. SectionDropDown.initialize = InitializeSectionDropDown
  861.  
  862. local function SectionTitle_OnMouseUp(tooltipCell, sectionName, mouseButton)
  863. if mouseButton == "RightButton" then
  864. Tooltip:SetFrameStrata("DIALOG")
  865. _G.CloseDropDownMenus()
  866. _G.ToggleDropDownMenu(1, sectionName, SectionDropDown, "cursor")
  867. return
  868. end
  869.  
  870. ToggleSectionVisibility(nil, sectionName)
  871. end
  872.  
  873. local function WoWFriend_OnMouseUp(tooltipCell, playerEntry, mouseButton)
  874. _G.PlaySound("igMainMenuOptionCheckBoxOn")
  875.  
  876. local playerName = playerEntry.Realm == PLAYER_REALM and playerEntry.ToonName or playerEntry.FullToonName
  877.  
  878. if mouseButton == "LeftButton" then
  879. if _G.IsAltKeyDown() then
  880. _G.InviteToGroup(playerName)
  881. elseif _G.IsControlKeyDown() then
  882. _G.FriendsFrame.NotesID = WoWFriendIndexByName[playerName]
  883. _G.StaticPopup_Show("SET_FRIENDNOTE", playerName)
  884. else
  885. _G.ChatFrame_SendTell(playerName)
  886. end
  887. elseif mouseButton == "RightButton" then
  888. Tooltip:SetFrameStrata("DIALOG")
  889. _G.CloseDropDownMenus()
  890. _G.FriendsFrame_ShowDropdown(playerEntry.FullToonName, true, nil, nil, nil, true)
  891. end
  892. end
  893.  
  894. -- ----------------------------------------------------------------------------
  895. -- Display rendering
  896. -- ----------------------------------------------------------------------------
  897. local function ColumnLabel(label, data)
  898. local sectionName, fieldName = (":"):split(data)
  899.  
  900. if DB.Tooltip.Sorting[sectionName].Field == SortFieldIDs[sectionName][fieldName] then
  901. return (DB.Tooltip.Sorting[sectionName].Order == SORT_ORDER_ASCENDING and SORT_ICON_ASCENDING or SORT_ICON_DESCENDING) .. label
  902. end
  903.  
  904. return label
  905. end
  906.  
  907. local function HideHelpTip(tooltipCell)
  908. if HelpTip then
  909. HelpTip:Hide()
  910. HelpTip:Release()
  911. HelpTip = nil
  912. end
  913. Tooltip:SetFrameStrata("TOOLTIP")
  914. end
  915.  
  916. local function ShowHelpTip(tooltipCell)
  917. local helpTip = LibQTip:Acquire(FOLDER_NAME .. "HelpTip", 2)
  918. helpTip:SetAutoHideDelay(0.1, tooltipCell)
  919. helpTip:SetBackdropColor(0.05, 0.05, 0.05, 1)
  920. helpTip:SetScale(DB.Tooltip.Scale)
  921. helpTip:SmartAnchorTo(tooltipCell)
  922. helpTip:SetScript("OnLeave", function(self) self:Release() helpTip = nil end)
  923. helpTip:Clear()
  924. helpTip:SetCellMarginH(0)
  925. helpTip:SetCellMarginV(1)
  926.  
  927. local firstEntryType = true
  928.  
  929. for entryType, data in pairs(HELP_TIP_DEFINITIONS) do
  930. local line
  931.  
  932. if not firstEntryType then
  933. line = helpTip:AddLine(" ")
  934. end
  935. line = helpTip:AddLine()
  936. helpTip:SetCell(line, 1, entryType, _G.GameFontNormal, "CENTER", 0)
  937. helpTip:AddSeparator(1, 0.5, 0.5, 0.5)
  938.  
  939. for keyStroke, description in pairs(data) do
  940. line = helpTip:AddLine()
  941. helpTip:SetCell(line, 1, keyStroke)
  942. helpTip:SetCell(line, 2, description)
  943. end
  944. firstEntryType = false
  945. end
  946.  
  947. _G.HideDropDownMenu(1)
  948. Tooltip:SetFrameStrata("DIALOG")
  949. helpTip:Show()
  950. end
  951.  
  952. local function RenderBattleNetLines(sourceListName, headerLine, noteArrangement)
  953. Tooltip:SetLineColor(headerLine, 0, 0, 0, 1)
  954. Tooltip:SetCell(headerLine, BattleNetColumns.PresenceName, ColumnLabel(_G.BATTLENET_FRIEND, sourceListName .. ":PresenceName"), BattleNetColSpans.PresenceName)
  955. Tooltip:SetCellScript(headerLine, BattleNetColumns.PresenceName, "OnMouseUp", ToggleColumnSortMethod, sourceListName .. ":PresenceName")
  956.  
  957. Tooltip:SetCell(headerLine, BattleNetColumns.ToonName, ColumnLabel(_G.NAME, sourceListName .. ":ToonName"), BattleNetColSpans.ToonName)
  958. Tooltip:SetCellScript(headerLine, BattleNetColumns.ToonName, "OnMouseUp", ToggleColumnSortMethod, sourceListName .. ":ToonName")
  959.  
  960. Tooltip:SetCell(headerLine, BattleNetColumns.GameText, ColumnLabel(_G.INFO, sourceListName .. ":GameText"), BattleNetColSpans.GameText)
  961. Tooltip:SetCellScript(headerLine, BattleNetColumns.GameText, "OnMouseUp", ToggleColumnSortMethod, sourceListName .. ":GameText")
  962.  
  963. local addedNoteColumn
  964.  
  965. Tooltip:AddSeparator(1, 0.5, 0.5, 0.5)
  966.  
  967. for index = 1, #PlayerLists[sourceListName] do
  968. local player = PlayerLists[sourceListName][index]
  969. local line = Tooltip:AddLine()
  970. Tooltip:SetCell(line, BattleNetColumns.Client, CLIENT_ICON_TEXTURE_CODES[player.Client], BattleNetColSpans.Client)
  971. Tooltip:SetCell(line, BattleNetColumns.PresenceName, ("%s%s%s|r"):format(player.StatusIcon, _G.FRIENDS_BNET_NAME_COLOR_CODE, player.PresenceName), BattleNetColSpans.PresenceName)
  972. Tooltip:SetCell(line, BattleNetColumns.ToonName, ("%s%s|r"):format(_G.FRIENDS_OTHER_NAME_COLOR_CODE, player.ToonName), BattleNetColSpans.ToonName)
  973. Tooltip:SetCell(line, BattleNetColumns.GameText, player.GameText, BattleNetColSpans.GameText)
  974.  
  975. Tooltip:SetCellScript(line, BattleNetColumns.PresenceName, "OnMouseUp", BattleNetFriend_OnMouseUp, player)
  976.  
  977. if player.Note then
  978. local noteText = _G.FRIENDS_OTHER_NAME_COLOR_CODE .. player.Note .. "|r"
  979.  
  980. if noteArrangement == private.NotesArrangementType.Column then
  981. if not addedNoteColumn then
  982. Tooltip:SetCell(headerLine, BattleNetColumns.Note, ColumnLabel(_G.LABEL_NOTE, sourceListName .. ":Note"), BattleNetColSpans.Note)
  983. Tooltip:SetCellScript(headerLine, BattleNetColumns.Note, "OnMouseUp", ToggleColumnSortMethod, sourceListName .. ":Note")
  984.  
  985. addedNoteColumn = true
  986. end
  987. Tooltip:SetCell(line, BattleNetColumns.Note, noteText, BattleNetColSpans.Note)
  988. else
  989. Tooltip:SetCell(Tooltip:AddLine(), BattleNetColumns.Client, STATUS_ICON_NOTE .. noteText, "GameTooltipTextSmall", 0)
  990. end
  991. end
  992.  
  993. if player.BroadcastText then
  994. Tooltip:SetCell(Tooltip:AddLine(), BattleNetColumns.Client, player.BroadcastText, "GameTooltipTextSmall", 0)
  995. end
  996. end
  997.  
  998. Tooltip:AddLine(" ")
  999. end
  1000.  
  1001. local function Tooltip_OnRelease(self)
  1002. _G.HideDropDownMenu(1)
  1003.  
  1004. if HelpTip then
  1005. HelpTip:Release()
  1006. HelpTip = nil
  1007. end
  1008.  
  1009. Tooltip:SetFrameStrata("TOOLTIP") -- This can be set to DIALOG by various functions.
  1010. Tooltip = nil
  1011. TooltipAnchor = nil
  1012. end
  1013.  
  1014. local TitleFont = _G.CreateFont("FrenemyTitleFont")
  1015. TitleFont:SetTextColor(0.510, 0.773, 1.0)
  1016. TitleFont:SetFontObject("QuestTitleFont")
  1017.  
  1018. -- ----------------------------------------------------------------------------
  1019. -- WoW Friends
  1020. -- ----------------------------------------------------------------------------
  1021. local function DisplaySectionWoWFriends()
  1022. if #PlayerLists.WoWFriends > 0 then
  1023. local line = Tooltip:AddLine()
  1024.  
  1025. if not DB.Tooltip.CollapsedSections.WoWFriends then
  1026. Tooltip:SetCell(line, 1, ("%s%s%s"):format(SECTION_ICON_ENABLED, _G.FRIENDS, SECTION_ICON_ENABLED), _G.GameFontNormal, "CENTER", 0)
  1027. Tooltip:SetCellScript(line, 1, "OnMouseUp", SectionTitle_OnMouseUp, "WoWFriends")
  1028.  
  1029. Tooltip:AddSeparator(1, 0.5, 0.5, 0.5)
  1030.  
  1031. local headerLine = Tooltip:AddLine()
  1032. Tooltip:SetLineColor(headerLine, 0, 0, 0, 1)
  1033. Tooltip:SetCell(headerLine, WoWFriendsColumns.Level, ColumnLabel(COLUMN_ICON_LEVEL, "WoWFriends:Level"), WoWFriendsColSpans.Level)
  1034. Tooltip:SetCellScript(headerLine, WoWFriendsColumns.Level, "OnMouseUp", ToggleColumnSortMethod, "WoWFriends:Level")
  1035.  
  1036. Tooltip:SetCell(headerLine, WoWFriendsColumns.Class, ColumnLabel(COLUMN_ICON_CLASS, "WoWFriends:Class"), WoWFriendsColSpans.Class)
  1037. Tooltip:SetCellScript(headerLine, WoWFriendsColumns.Class, "OnMouseUp", ToggleColumnSortMethod, "WoWFriends:Class")
  1038.  
  1039. Tooltip:SetCell(headerLine, WoWFriendsColumns.PresenceName, ColumnLabel(_G.BATTLENET_FRIEND, "WoWFriends:PresenceName"), WoWFriendsColSpans.PresenceName)
  1040. Tooltip:SetCellScript(headerLine, WoWFriendsColumns.PresenceName, "OnMouseUp", ToggleColumnSortMethod, "WoWFriends:PresenceName")
  1041.  
  1042. Tooltip:SetCell(headerLine, WoWFriendsColumns.ToonName, ColumnLabel(_G.NAME, "WoWFriends:ToonName"), WoWFriendsColSpans.ToonName)
  1043. Tooltip:SetCellScript(headerLine, WoWFriendsColumns.ToonName, "OnMouseUp", ToggleColumnSortMethod, "WoWFriends:ToonName")
  1044.  
  1045. Tooltip:SetCell(headerLine, WoWFriendsColumns.ZoneName, ColumnLabel(_G.ZONE, "WoWFriends:ZoneName"), WoWFriendsColSpans.ZoneName)
  1046. Tooltip:SetCellScript(headerLine, WoWFriendsColumns.ZoneName, "OnMouseUp", ToggleColumnSortMethod, "WoWFriends:ZoneName")
  1047.  
  1048. Tooltip:SetCell(headerLine, WoWFriendsColumns.RealmName, ColumnLabel(L.COLUMN_LABEL_REALM, "WoWFriends:RealmName"), WoWFriendsColSpans.RealmName)
  1049. Tooltip:SetCellScript(headerLine, WoWFriendsColumns.RealmName, "OnMouseUp", ToggleColumnSortMethod, "WoWFriends:RealmName")
  1050.  
  1051. local addedNoteColumn
  1052.  
  1053. Tooltip:AddSeparator(1, 0.5, 0.5, 0.5)
  1054.  
  1055. for index = 1, #PlayerLists.WoWFriends do
  1056. local player = PlayerLists.WoWFriends[index]
  1057. local groupIndicator = IsGrouped(player.ToonName) and PLAYER_ICON_GROUP or ""
  1058. local nameColor = CLASS_COLORS[player.Class] or FRIENDS_WOW_NAME_COLOR
  1059. local presenceName = player.PresenceName and ("%s%s|r"):format(_G.FRIENDS_BNET_NAME_COLOR_CODE, player.PresenceName) or _G.NOT_APPLICABLE
  1060.  
  1061. line = Tooltip:AddLine()
  1062. Tooltip:SetCell(line, WoWFriendsColumns.Level, ColorPlayerLevel(player.Level), WoWFriendsColSpans.Level)
  1063. Tooltip:SetCell(line, WoWFriendsColumns.Class, CLASS_ICONS[CLASS_TOKEN_FROM_NAME_FEMALE[player.Class] or CLASS_TOKEN_FROM_NAME_MALE[player.Class]], WoWFriendsColSpans.Class)
  1064. Tooltip:SetCell(line, WoWFriendsColumns.PresenceName, ("%s%s"):format(player.StatusIcon, presenceName), WoWFriendsColSpans.PresenceName)
  1065. Tooltip:SetCell(line, WoWFriendsColumns.ToonName, ("%s|cff%s%s|r%s"):format(player.FactionIcon or PLAYER_ICON_FACTION, nameColor, player.ToonName, groupIndicator), WoWFriendsColSpans.ToonName)
  1066. Tooltip:SetCell(line, WoWFriendsColumns.ZoneName, ColorZoneName(player.ZoneName), WoWFriendsColSpans.ZoneName)
  1067. Tooltip:SetCell(line, WoWFriendsColumns.RealmName, player.RealmName, WoWFriendsColSpans.RealmName)
  1068.  
  1069. if player.PresenceID then
  1070. Tooltip:SetCellScript(line, WoWFriendsColumns.PresenceName, "OnMouseUp", BattleNetFriend_OnMouseUp, player)
  1071. end
  1072.  
  1073. if player.IsLocalFriend then
  1074. Tooltip:SetCellScript(line, WoWFriendsColumns.ToonName, "OnMouseUp", WoWFriend_OnMouseUp, player)
  1075. end
  1076.  
  1077. if player.Note then
  1078. local noteText = _G.FRIENDS_OTHER_NAME_COLOR_CODE .. player.Note .. "|r"
  1079.  
  1080. if DB.Tooltip.NotesArrangement.WoWFriends == private.NotesArrangementType.Column then
  1081. if not addedNoteColumn then
  1082. Tooltip:SetCell(headerLine, WoWFriendsColumns.Note, ColumnLabel(_G.LABEL_NOTE, "WoWFriends:Note"), WoWFriendsColSpans.Note)
  1083. Tooltip:SetCellScript(headerLine, WoWFriendsColumns.Note, "OnMouseUp", ToggleColumnSortMethod, "WoWFriends:Note")
  1084.  
  1085. addedNoteColumn = true
  1086. end
  1087. Tooltip:SetCell(line, WoWFriendsColumns.Note, noteText, WoWFriendsColSpans.Note)
  1088. else
  1089. Tooltip:SetCell(Tooltip:AddLine(), WoWFriendsColumns.Level, STATUS_ICON_NOTE .. noteText, "GameTooltipTextSmall", 0)
  1090. end
  1091. end
  1092.  
  1093. if player.BroadcastText then
  1094. Tooltip:SetCell(Tooltip:AddLine(), WoWFriendsColumns.Level, player.BroadcastText, "GameTooltipTextSmall", 0)
  1095. end
  1096. end
  1097.  
  1098. Tooltip:AddLine(" ")
  1099. else
  1100. Tooltip:SetCell(line, 1, ("%s%s%s"):format(SECTION_ICON_DISABLED, _G.FRIENDS, SECTION_ICON_DISABLED), _G.GameFontDisable, "CENTER", 0)
  1101. Tooltip:SetCellScript(line, 1, "OnMouseUp", SectionTitle_OnMouseUp, "WoWFriends")
  1102. end
  1103. end
  1104. end
  1105.  
  1106. -- ----------------------------------------------------------------------------
  1107. -- BattleNet In-Game Friends
  1108. -- ----------------------------------------------------------------------------
  1109. local function DisplaySectionBattleNetGames()
  1110. if #PlayerLists.BattleNetGames > 0 then
  1111. local line = Tooltip:AddLine()
  1112.  
  1113. if not DB.Tooltip.CollapsedSections.BattleNetGames then
  1114. Tooltip:SetCell(line, 1, ("%s%s%s"):format(SECTION_ICON_ENABLED, ("%s %s"):format(_G.BATTLENET_OPTIONS_LABEL, _G.PARENS_TEMPLATE:format(_G.GAME)), SECTION_ICON_ENABLED), _G.GameFontNormal, "CENTER", 0)
  1115. Tooltip:SetCellScript(line, 1, "OnMouseUp", SectionTitle_OnMouseUp, "BattleNetGames")
  1116.  
  1117. Tooltip:AddSeparator(1, 0.5, 0.5, 0.5)
  1118.  
  1119. line = Tooltip:AddLine()
  1120. Tooltip:SetCell(line, BattleNetColumns.Client, ColumnLabel(COLUMN_ICON_GAME, "BattleNetGames:ClientIndex"))
  1121.  
  1122. Tooltip:SetCellScript(line, BattleNetColumns.Client, "OnMouseUp", ToggleColumnSortMethod, "BattleNetGames:ClientIndex")
  1123.  
  1124. RenderBattleNetLines("BattleNetGames", line, DB.Tooltip.NotesArrangement.BattleNetGames)
  1125. else
  1126. Tooltip:SetCell(line, 1, ("%s%s%s"):format(SECTION_ICON_DISABLED, ("%s %s"):format(_G.BATTLENET_OPTIONS_LABEL, _G.PARENS_TEMPLATE:format(_G.GAME)), SECTION_ICON_DISABLED), _G.GameFontDisable, "CENTER", 0)
  1127. Tooltip:SetCellScript(line, 1, "OnMouseUp", SectionTitle_OnMouseUp, "BattleNetGames")
  1128. end
  1129. end
  1130. end
  1131.  
  1132. -- ----------------------------------------------------------------------------
  1133. -- BattleNet Friends
  1134. -- ----------------------------------------------------------------------------
  1135. local function DisplaySectionBattleNetApp()
  1136. if #PlayerLists.BattleNetApp > 0 then
  1137. local line = Tooltip:AddLine()
  1138.  
  1139. if not DB.Tooltip.CollapsedSections.BattleNetApp then
  1140. Tooltip:SetCell(line, 1, ("%s%s%s"):format(SECTION_ICON_ENABLED, _G.BATTLENET_OPTIONS_LABEL, SECTION_ICON_ENABLED), _G.GameFontNormal, "CENTER", 0)
  1141. Tooltip:SetCellScript(line, 1, "OnMouseUp", SectionTitle_OnMouseUp, "BattleNetApp")
  1142.  
  1143. Tooltip:AddSeparator(1, 0.5, 0.5, 0.5)
  1144.  
  1145. RenderBattleNetLines("BattleNetApp", Tooltip:AddLine(), DB.Tooltip.NotesArrangement.BattleNetApp)
  1146. else
  1147. Tooltip:SetCell(line, 1, ("%s%s%s"):format(SECTION_ICON_DISABLED, _G.BATTLENET_OPTIONS_LABEL, SECTION_ICON_DISABLED), _G.GameFontDisable, "CENTER", 0)
  1148. Tooltip:SetCellScript(line, 1, "OnMouseUp", SectionTitle_OnMouseUp, "BattleNetApp")
  1149. end
  1150. end
  1151. end
  1152.  
  1153. -- ----------------------------------------------------------------------------
  1154. -- Guild
  1155. -- ----------------------------------------------------------------------------
  1156. local GuildMOTDText
  1157. local GuildMOTDLine
  1158.  
  1159. local function DisplaySectionGuild()
  1160. if #PlayerLists.Guild > 0 then
  1161. local line = Tooltip:AddLine()
  1162.  
  1163. if not DB.Tooltip.CollapsedSections.Guild then
  1164. Tooltip:SetCell(line, 1, ("%s%s%s"):format(SECTION_ICON_ENABLED, _G.GetGuildInfo("player"), SECTION_ICON_ENABLED), "GameFontNormal", "CENTER", 0)
  1165. Tooltip:SetCellScript(line, 1, "OnMouseUp", SectionTitle_OnMouseUp, "Guild")
  1166.  
  1167. Tooltip:AddSeparator(1, 0.5, 0.5, 0.5)
  1168.  
  1169. local headerLine = Tooltip:AddLine()
  1170. Tooltip:SetLineColor(headerLine, 0, 0, 0, 1)
  1171. Tooltip:SetCell(headerLine, GuildColumns.Level, ColumnLabel(COLUMN_ICON_LEVEL, "Guild:Level"), GuildColSpans.Level)
  1172. Tooltip:SetCellScript(headerLine, GuildColumns.Level, "OnMouseUp", ToggleColumnSortMethod, "Guild:Level")
  1173.  
  1174. Tooltip:SetCell(headerLine, GuildColumns.Class, ColumnLabel(COLUMN_ICON_CLASS, "Guild:Class"), GuildColSpans.Class)
  1175. Tooltip:SetCellScript(headerLine, GuildColumns.Class, "OnMouseUp", ToggleColumnSortMethod, "Guild:Class")
  1176.  
  1177. Tooltip:SetCell(headerLine, GuildColumns.ToonName, ColumnLabel(_G.NAME, "Guild:ToonName"), GuildColSpans.ToonName)
  1178. Tooltip:SetCellScript(headerLine, GuildColumns.ToonName, "OnMouseUp", ToggleColumnSortMethod, "Guild:ToonName")
  1179.  
  1180. Tooltip:SetCell(headerLine, GuildColumns.Rank, ColumnLabel(_G.RANK, "Guild:RankIndex"), GuildColSpans.Rank)
  1181. Tooltip:SetCellScript(headerLine, GuildColumns.Rank, "OnMouseUp", ToggleColumnSortMethod, "Guild:RankIndex")
  1182.  
  1183. Tooltip:SetCell(headerLine, GuildColumns.ZoneName, ColumnLabel(_G.ZONE, "Guild:ZoneName"), GuildColSpans.ZoneName)
  1184. Tooltip:SetCellScript(headerLine, GuildColumns.ZoneName, "OnMouseUp", ToggleColumnSortMethod, "Guild:ZoneName")
  1185.  
  1186. local addedPublicNoteColumn
  1187. local addedOfficerNoteColumn
  1188.  
  1189. Tooltip:AddSeparator(1, 0.5, 0.5, 0.5)
  1190.  
  1191. local numGuildRanks = _G.GuildControlGetNumRanks()
  1192.  
  1193. for index = 1, #PlayerLists.Guild do
  1194. local player = PlayerLists.Guild[index]
  1195.  
  1196. line = Tooltip:AddLine()
  1197. Tooltip:SetCell(line, GuildColumns.Level, ColorPlayerLevel(player.Level), GuildColSpans.Level)
  1198. Tooltip:SetCell(line, GuildColumns.Class, CLASS_ICONS[CLASS_TOKEN_FROM_NAME_FEMALE[player.Class] or CLASS_TOKEN_FROM_NAME_MALE[player.Class]], GuildColSpans.Class)
  1199.  
  1200. Tooltip:SetCell(line, GuildColumns.ToonName, ("%s|cff%s%s|r%s"):format(player.StatusIcon, CLASS_COLORS[player.Class] or "ffffff", player.ToonName, IsGrouped(player.ToonName) and PLAYER_ICON_GROUP or ""), GuildColSpans.ToonName)
  1201. Tooltip:SetCellScript(line, GuildColumns.ToonName, "OnMouseUp", GuildMember_OnMouseUp, player)
  1202.  
  1203. -- The higher the rank index, the lower the priviledge; guild leader is rank 1.
  1204. local r, g, b = PercentColorGradient(player.RankIndex, numGuildRanks)
  1205. Tooltip:SetCell(line, GuildColumns.Rank, ("|cff%02x%02x%02x%s|r"):format(r * 255, g * 255, b * 255, player.Rank), GuildColSpans.Rank)
  1206. Tooltip:SetCell(line, GuildColumns.ZoneName, ColorZoneName(player.ZoneName), GuildColSpans.ZoneName)
  1207.  
  1208. if player.PublicNote then
  1209. local noteText = _G.FRIENDS_OTHER_NAME_COLOR_CODE .. player.PublicNote .. "|r"
  1210.  
  1211. if DB.Tooltip.NotesArrangement.Guild == private.NotesArrangementType.Column then
  1212. if not addedPublicNoteColumn then
  1213. Tooltip:SetCell(headerLine, GuildColumns.PublicNote, ColumnLabel(_G.NOTE, "Guild:PublicNote"), GuildColSpans.PublicNote)
  1214. Tooltip:SetCellScript(headerLine, GuildColumns.PublicNote, "OnMouseUp", ToggleColumnSortMethod, "Guild:PublicNote")
  1215.  
  1216. addedPublicNoteColumn = true
  1217. end
  1218. Tooltip:SetCell(line, GuildColumns.PublicNote, noteText, GuildColSpans.PublicNote)
  1219. else
  1220. Tooltip:SetCell(Tooltip:AddLine(), GuildColumns.Level, STATUS_ICON_NOTE .. noteText, "GameTooltipTextSmall", 0)
  1221. end
  1222. end
  1223.  
  1224. if player.OfficerNote then
  1225. local noteText = _G.ORANGE_FONT_COLOR_CODE .. player.OfficerNote .. "|r"
  1226.  
  1227. if DB.Tooltip.NotesArrangement.GuildOfficer == private.NotesArrangementType.Column then
  1228. if not addedOfficerNoteColumn then
  1229. Tooltip:SetCell(headerLine, GuildColumns.OfficerNote, ColumnLabel(_G.GUILD_OFFICERNOTES_LABEL, "Guild:OfficerNote"), GuildColSpans.OfficerNote)
  1230. Tooltip:SetCellScript(headerLine, GuildColumns.OfficerNote, "OnMouseUp", ToggleColumnSortMethod, "Guild:OfficerNote")
  1231.  
  1232. addedOfficerNoteColumn = true
  1233. end
  1234. Tooltip:SetCell(line, GuildColumns.OfficerNote, noteText, GuildColSpans.OfficerNote)
  1235. else
  1236. Tooltip:SetCell(Tooltip:AddLine(), GuildColumns.Level, STATUS_ICON_NOTE .. noteText, "GameTooltipTextSmall", 0)
  1237. end
  1238. end
  1239. end
  1240. GuildMOTDText = _G.GetGuildRosterMOTD()
  1241.  
  1242. if GuildMOTDText and GuildMOTDText ~= "" then
  1243. GuildMOTDLine = Tooltip:AddLine()
  1244.  
  1245. if _G.CanEditMOTD() then
  1246. Tooltip:SetCellScript(GuildMOTDLine, 1, "OnMouseUp", GuildMOTD_OnMouseUp)
  1247. end
  1248.  
  1249. Tooltip:AddLine(" ")
  1250. end
  1251. else
  1252. Tooltip:SetCell(line, 1, ("%s%s%s"):format(SECTION_ICON_DISABLED, _G.GetGuildInfo("player"), SECTION_ICON_DISABLED), "GameFontDisable", "CENTER", 0)
  1253. Tooltip:SetCellScript(line, 1, "OnMouseUp", SectionTitle_OnMouseUp, "Guild")
  1254. end
  1255. end
  1256. end
  1257.  
  1258. local SECTION_NAME_TO_DISPLAY_FUNCTION = {
  1259. WoWFriends = DisplaySectionWoWFriends,
  1260. BattleNetGames = DisplaySectionBattleNetGames,
  1261. BattleNetApp = DisplaySectionBattleNetApp,
  1262. Guild = DisplaySectionGuild,
  1263. }
  1264.  
  1265. function DrawTooltip(anchorFrame)
  1266. if not anchorFrame then
  1267. return
  1268. end
  1269.  
  1270. TooltipAnchor = anchorFrame
  1271. GenerateTooltipData()
  1272.  
  1273. if not Tooltip then
  1274. Tooltip = LibQTip:Acquire(FOLDER_NAME, NUM_TOOLTIP_COLUMNS)
  1275. Tooltip:SetAutoHideDelay(DB.Tooltip.HideDelay, anchorFrame)
  1276. Tooltip:SetBackdropColor(0.05, 0.05, 0.05, 1)
  1277. Tooltip:SetScale(DB.Tooltip.Scale)
  1278. Tooltip:SmartAnchorTo(anchorFrame)
  1279. Tooltip:SetHighlightTexture([[Interface\ClassTrainerFrame\TrainerTextures]])
  1280. Tooltip:SetHighlightTexCoord(0.00195313, 0.57421875, 0.75390625, 0.84570313)
  1281.  
  1282. Tooltip.OnRelease = Tooltip_OnRelease
  1283. end
  1284.  
  1285. Tooltip:Clear()
  1286. Tooltip:SetCellMarginH(0)
  1287. Tooltip:SetCellMarginV(1)
  1288.  
  1289. Tooltip:SetCell(Tooltip:AddLine(), 1, FOLDER_NAME, TitleFont, "CENTER", 0)
  1290. Tooltip:AddSeparator(1, 0.510, 0.773, 1.0)
  1291.  
  1292. GuildMOTDLine = nil
  1293. GuildMOTDText = nil
  1294.  
  1295. for index = 1, #DB.Tooltip.SectionDisplayOrders do
  1296. SECTION_NAME_TO_DISPLAY_FUNCTION[DB.Tooltip.SectionDisplayOrders[index]]()
  1297. end
  1298. Tooltip:Show()
  1299.  
  1300. -- This must be done after everything else has been added to the tooltip in order to have an accurate width.
  1301. if GuildMOTDLine and GuildMOTDText then
  1302. Tooltip:SetCell(GuildMOTDLine, 1, _G.GUILD_MOTD_TEMPLATE:format(_G.GREEN_FONT_COLOR_CODE .. GuildMOTDText .. "|r"), 0, 0, 0, Tooltip:GetWidth() - 20)
  1303. end
  1304.  
  1305. Tooltip:AddSeparator(1, 0.510, 0.773, 1.0)
  1306.  
  1307. local line = Tooltip:AddLine()
  1308. Tooltip:SetCell(line, NUM_TOOLTIP_COLUMNS, HELP_ICON, "RIGHT", 0)
  1309. Tooltip:SetCellScript(line, NUM_TOOLTIP_COLUMNS, "OnEnter", ShowHelpTip)
  1310. Tooltip:SetCellScript(line, NUM_TOOLTIP_COLUMNS, "OnLeave", HideHelpTip)
  1311.  
  1312. Tooltip:UpdateScrolling()
  1313. end
  1314. end -- do-block
  1315.  
  1316. -- ----------------------------------------------------------------------------
  1317. -- DataObject methods.
  1318. -- ----------------------------------------------------------------------------
  1319. function DataObject:OnClick(button)
  1320. if button == "LeftButton" then
  1321. if _G.IsAltKeyDown() then
  1322. _G.ToggleGuildFrame()
  1323. else
  1324. _G.ToggleFriendsFrame(FRIENDS_FRAME_TAB_TOGGLES.FRIENDS)
  1325. end
  1326. else
  1327. _G.InterfaceOptionsFrame_OpenToCategory(Frenemy.optionsFrame)
  1328. end
  1329. end
  1330.  
  1331. function DataObject:OnEnter()
  1332. DrawTooltip(self)
  1333. end
  1334.  
  1335. function DataObject.OnLeave()
  1336. -- Null operation: Some LDB displays get cranky if this method is missing.
  1337. end
  1338.  
  1339. function DataObject:UpdateDisplay()
  1340. local output = ("%s%s: %d|r, "):format(_G.NORMAL_FONT_COLOR_CODE, _G.FRIENDS, OnlineFriendsCount)
  1341. output = ("%s%s%s: %d|r"):format(output, _G.BATTLENET_FONT_COLOR_CODE, _G.BATTLENET_FRIEND, OnlineBattleNetCount)
  1342.  
  1343. if _G.IsInGuild() then
  1344. output = ("%s, %s%s: %d|r"):format(output, _G.GREEN_FONT_COLOR_CODE, _G.GUILD, OnlineGuildMembersCount)
  1345. end
  1346.  
  1347. self.text = output
  1348. end
  1349.  
  1350. -- ----------------------------------------------------------------------------
  1351. -- Events.
  1352. -- ----------------------------------------------------------------------------
  1353. local function UpdateAndDisplay()
  1354. UpdateStatistics()
  1355. DataObject:UpdateDisplay()
  1356.  
  1357. if Tooltip and Tooltip:IsShown() then
  1358. DrawTooltip(DataObject)
  1359. end
  1360. end
  1361.  
  1362. Frenemy.BN_TOON_NAME_UPDATED = UpdateAndDisplay
  1363. Frenemy.BN_FRIEND_INFO_CHANGED = UpdateAndDisplay
  1364. Frenemy.FRIENDLIST_UPDATE = UpdateAndDisplay
  1365. Frenemy.GUILD_RANKS_UPDATE = UpdateAndDisplay
  1366. Frenemy.GUILD_ROSTER_UPDATE = UpdateAndDisplay
  1367.  
  1368. function Frenemy:PLAYER_REGEN_DISABLED(eventName)
  1369. private.inCombat = true
  1370. end
  1371.  
  1372.  
  1373. function Frenemy:PLAYER_REGEN_ENABLED(eventName)
  1374. private.inCombat = nil
  1375.  
  1376. if private.needsAreaID then
  1377. self:HandleZoneChange(eventName)
  1378. private.needsAreaID = nil
  1379. end
  1380. end
  1381.  
  1382. -- Contains a dirty hack due to Blizzard's strange handling of Micro Dungeons; GetMapInfo() will not return correct information
  1383. -- unless the WorldMapFrame is shown.
  1384. -- MapFileName = MapAreaID
  1385. local MICRO_DUNGEON_IDS = {
  1386. ShrineofTwoMoons = 903,
  1387. ShrineofSevenStars = 905,
  1388. }
  1389.  
  1390. function Frenemy:HandleZoneChange(eventName)
  1391. if private.inCombat then
  1392. private.needsAreaID = true
  1393. return
  1394. end
  1395.  
  1396. local mapZoneID = HereBeDragons:GetPlayerZone()
  1397. local needDisplayUpdate = CurrentZoneID ~= mapZoneID
  1398. CurrentZoneID = mapZoneID
  1399.  
  1400. if CurrentZoneID and CurrentZoneID > 0 then
  1401. local pvpType, _, factionName = _G.GetZonePVPInfo()
  1402.  
  1403. if pvpType == "hostile" or pvpType == "friendly" then
  1404. pvpType = factionName
  1405. elseif not pvpType or pvpType == "" then
  1406. pvpType = "normal"
  1407. end
  1408.  
  1409. local zonePVPStatus = private.ZonePVPStatusByLabel[pvpType:upper()]
  1410. DB.ZoneData[CurrentZoneID] = zonePVPStatus
  1411. SetZoneNameColors(CurrentZoneID, zonePVPStatus)
  1412.  
  1413. if needDisplayUpdate then
  1414. UpdateAndDisplay()
  1415. end
  1416. end
  1417. end
  1418.  
  1419. -- ----------------------------------------------------------------------------
  1420. -- Framework.
  1421. -- ----------------------------------------------------------------------------
  1422. local function CreateUpdater(parent_frame, interval, loop_func)
  1423. local updater = parent_frame:CreateAnimationGroup()
  1424. updater:CreateAnimation("Animation"):SetDuration(interval)
  1425. updater:SetScript("OnLoop", loop_func)
  1426. updater:SetLooping("REPEAT")
  1427.  
  1428. return updater
  1429. end
  1430.  
  1431. local function RequestUpdates()
  1432. _G.ShowFriends()
  1433.  
  1434. if _G.IsInGuild() then
  1435. _G.GuildRoster()
  1436. end
  1437. end
  1438.  
  1439. function Frenemy:OnEnable()
  1440. self:RegisterEvent("BN_FRIEND_INFO_CHANGED")
  1441. self:RegisterEvent("BN_TOON_NAME_UPDATED")
  1442. self:RegisterEvent("FRIENDLIST_UPDATE")
  1443. self:RegisterEvent("GUILD_RANKS_UPDATE")
  1444. self:RegisterEvent("GUILD_ROSTER_UPDATE")
  1445. self:RegisterEvent("ZONE_CHANGED", "HandleZoneChange")
  1446. self:RegisterEvent("ZONE_CHANGED_INDOORS", "HandleZoneChange")
  1447. self:RegisterEvent("ZONE_CHANGED_NEW_AREA", "HandleZoneChange")
  1448.  
  1449. self:HandleZoneChange("OnEnable")
  1450.  
  1451. RequestUpdates()
  1452. self.RequestUpdater = CreateUpdater(RequestUpdater, REQUEST_UPDATE_INTERVAL, RequestUpdates)
  1453. self.RequestUpdater:Play()
  1454. end
  1455.  
  1456. function Frenemy:OnInitialize()
  1457. DB = LibStub("AceDB-3.0"):New(FOLDER_NAME .. "DB", DB_DEFAULTS, true).global
  1458. private.DB = DB
  1459.  
  1460. local LDBIcon = LibStub("LibDBIcon-1.0")
  1461. if LDBIcon then
  1462. LDBIcon:Register(FOLDER_NAME, DataObject, DB.DataObject.MinimapIcon)
  1463. end
  1464. private.SetupOptions()
  1465.  
  1466. for zoneID, zonePVPStatus in pairs(DB.ZoneData) do
  1467. SetZoneNameColors(zoneID, zonePVPStatus)
  1468. end
  1469. end
Add Comment
Please, Sign In to add comment