Advertisement
Wetxius

Untitled

Sep 30th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 82.14 KB | None | 0 0
  1. local T, C, L, _ = unpack(select(2, ...))
  2.  
  3. ----------------------------------------------------------------------------------------
  4. -- Based on LiteStats(by Katae)
  5. ----------------------------------------------------------------------------------------
  6. local P = "player"
  7. local realm, char, class, layout = GetRealmName(), UnitName(P), select(2, UnitClass(P)), {}
  8.  
  9. -- Tooltip text colors
  10. local tthead = {r = 0.40, g = 0.78, b = 1} -- Headers
  11. local ttsubh = {r = 0.75, g = 0.90, b = 1} -- Subheaders
  12.  
  13. -- Strata/Level for text objects
  14. local strata, level = "DIALOG", 20
  15.  
  16. -- Globals
  17. local profiles = LPSTAT_PROFILES
  18. local font = LPSTAT_FONT
  19. local t_icon = LTIPICONSIZE or 20
  20. local IsAltKeyDown = IsAltKeyDown
  21. local UpdateMemUse = UpdateAddOnMemoryUsage
  22. local format = string.format
  23. local strmatch = string.match
  24. local strfind = string.find
  25. local strtrim = strtrim
  26. local unpack = unpack
  27. local pairs = pairs
  28. local ipairs = ipairs
  29. local floor = math.floor
  30. local select = select
  31. local max = max
  32. local gsub = gsub
  33.  
  34. -- Config
  35. local modules = LPSTAT_CONFIG
  36. local fps = modules.FPS
  37. local latency = modules.Latency
  38. local memory = modules.Memory
  39. local durability = modules.Durability
  40. local gold = modules.Gold
  41. local clock = modules.Clock
  42. local location = modules.Location
  43. local coords = modules.Coords
  44. local ping = modules.Ping
  45. local guild = modules.Guild
  46. local friends = modules.Friends
  47. local bags = modules.Bags
  48. local talents = modules.Talents
  49. local stats = modules.Stats
  50. local experience = modules.Experience
  51. local loot = modules.Loot
  52. local cloak = modules.Cloak
  53. local helm = modules.Helm
  54. local nameplates = modules.Nameplates
  55.  
  56. -- Events Reg
  57. local function RegEvents(f, l) for _, e in ipairs{strsplit(" ", l)} do f:RegisterEvent(e) end end
  58.  
  59. ------------------------------------------
  60. -- Saved Vars Init / Coords
  61. local ls, coordX, coordY, conf, Coords = CreateFrame("Frame"), 0, 0, {}
  62. RegEvents(ls, "ADDON_LOADED PLAYER_REGEN_DISABLED PLAYER_REGEN_ENABLED")
  63. ls:SetScript("OnEvent", function(_, event, addon)
  64. if event == "ADDON_LOADED" and addon == "ShestakUI" then
  65. if not SavedStats then SavedStats = {} end
  66. if not SavedStats[realm] then SavedStats[realm] = {} end
  67. if not SavedStats[realm][char] then SavedStats[realm][char] = {} end
  68. conf = SavedStats[realm][char]
  69.  
  70. -- true/false defaults for autosell and autorepair
  71. if conf.AutoSell == nil then conf.AutoSell = true end
  72. if conf.AutoRepair == nil then conf.AutoRepair = true end
  73. if conf.AutoGuildRepair == nil then conf.AutoGuildRepair = true end
  74. end
  75. if event == "ZONE_CHANGED_NEW_AREA" and not WorldMapFrame:IsShown() then
  76. SetMapToCurrentZone()
  77. end
  78. end)
  79.  
  80. -- Config missing?
  81. if not modules then return end
  82.  
  83. if modules and ((coords and coords.enabled) or (location and location.enabled)) then
  84. ls:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  85. ls:SetScript("OnUpdate", function(self, elapsed)
  86. self.elapsed = (self.elapsed or 0) + elapsed
  87. if self.elapsed >= 0.2 then
  88. coordX, coordY = GetPlayerMapPosition(P)
  89. self.elapsed = 0
  90. end
  91. end)
  92. WorldMapDetailFrame:HookScript("OnHide", SetMapToCurrentZone)
  93. function Coords() return format(coords and coords.fmt or "%d, %d", coordX * 100, coordY * 100) end
  94. end
  95.  
  96. -- Set profile
  97. if profiles then for _, p in ipairs{class,format("%s - %s", char, realm)} do
  98. if profiles[p] then for k, v in pairs(profiles[p]) do
  99. for _k, _v in pairs(v) do modules[k][_k] = _v end
  100. end end
  101. end profiles = nil end
  102.  
  103.  
  104. ------------------------------------------
  105. local function comma_value(n) -- credit http://richard.warburton.it
  106. local left, num, right = string.match(n,"^([^%d]*%d)(%d*)(.-)$")
  107. return left..(num:reverse():gsub("(%d%d%d)","%1,"):reverse())..right
  108. end
  109.  
  110. local function formatgold(style, amount)
  111. local gold, silver, copper = floor(amount * 0.0001), floor(mod(amount * 0.01, 100)), floor(mod(amount, 100))
  112. if style == 1 then
  113. return (gold > 0 and format("%s|cffffd700%s|r ", comma_value(gold), GOLD_AMOUNT_SYMBOL) or "")
  114. .. (silver > 0 and format("%s|cffc7c7cf%s|r ", silver, SILVER_AMOUNT_SYMBOL) or "")
  115. .. ((copper > 0 or (gold == 0 and silver == 0)) and format("%s|cffeda55f%s|r", copper, COPPER_AMOUNT_SYMBOL) or "")
  116. elseif style == 2 or not style then
  117. return format("%.1f|cffffd700%s|r", amount * 0.0001, GOLD_AMOUNT_SYMBOL)
  118. elseif style == 3 then
  119. return format("|cffffd700%s|r.|cffc7c7cf%s|r.|cffeda55f%s|r", gold, silver, copper)
  120. elseif style == 4 then
  121. return (gold > 0 and format(GOLD_AMOUNT_TEXTURE, gold, 12, 12) or "") .. (silver > 0 and format(SILVER_AMOUNT_TEXTURE, silver, 12, 12) or "")
  122. .. ((copper > 0 or (gold == 0 and silver == 0)) and format(COPPER_AMOUNT_TEXTURE, copper, 12, 12) or "") .. " "
  123. end
  124. end
  125.  
  126. local function zsub(s, ...) local t = {...} for i = 1, #t, 2 do s = gsub(s, t[i], t[i + 1]) end return s end
  127. local function abbr(t, s) return t[s] or zsub(_G[strupper(s).."_ONELETTER_ABBR"], "%%d", "", "^%s*", "") end
  128. local function fmttime(sec, t)
  129. local t = t or {}
  130. local d, h, m, s = ChatFrame_TimeBreakDown(floor(sec))
  131. local string = zsub(format(" %dd %dh %dm "..((d == 0 and h == 0) and "%ds" or ""), d, h, m, s), " 0[dhms]", " ", "%s+", " ")
  132. string = strtrim(gsub(string, "([dhms])", {d = abbr(t, "day"), h = abbr(t, "hour"), m = abbr(t, "minute"), s = abbr(t, "second")}), " ")
  133. return strmatch(string, "^%s*$") and "0"..abbr(t, "second") or string
  134. end
  135.  
  136. function gradient(perc)
  137. perc = perc > 1 and 1 or perc < 0 and 0 or perc -- Stay between 0-1
  138. local seg, relperc = math.modf(perc*2)
  139. local r1, g1, b1, r2, g2, b2 = select(seg * 3 + 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0) -- R -> Y -> G
  140. local r, g, b = r1 + (r2 - r1) * relperc, g1 + (g2 - g1) * relperc, b1 + (b2 - b1) * relperc
  141. return format("|cff%02x%02x%02x", r * 255, g * 255, b * 255), r, g, b
  142. end
  143.  
  144. local function HideTT(self) GameTooltip:Hide() self.hovered = false end
  145.  
  146. local pxpx = {height = 1, width = 1}
  147. local function Inject(name, stat)
  148. if not name then return end
  149. if not stat then stat = pxpx end
  150.  
  151. local m = modules[name]
  152. for k, v in pairs{ -- retrieving config variables from LPSTAT_CONFIG
  153. --name = name, anchor_frame = m.anchor_frame,
  154. name = name, parent = m.anchor_frame,
  155. anchor_to = m.anchor_to, anchor_from = m.anchor_from,
  156. x_off = m.x_off, y_off = m.y_off,
  157. height = m.height, width = m.width,
  158. strata = strata, level = level
  159. } do if not stat[k] then stat[k] = v end end
  160. if not stat.text then stat.text = {} end
  161.  
  162. -- retrieve font variables and insert them into text table
  163. for k,v in pairs(font) do
  164. if not stat.text[k] then
  165. stat.text[k] = m[k] or v
  166. end
  167. end
  168.  
  169. if stat.OnEnter then if stat.OnLeave then hooksecurefunc(stat, "OnLeave", HideTT) else stat.OnLeave = HideTT end end
  170. tinsert(layout, stat)
  171. end
  172.  
  173. -- Inject dummy frames for disabled modules
  174. for name, conf in pairs(modules) do
  175. if not conf.enabled then Inject(name) end
  176. end
  177.  
  178. local function AltUpdate(self)
  179. if not self.hovered then return end
  180. if IsAltKeyDown() and not self.altdown then self.altdown = true self:GetScript("OnEnter")(self)
  181. elseif not IsAltKeyDown() and self.altdown then self.altdown = false self:GetScript("OnEnter")(self) end
  182. end
  183.  
  184. local function GetTableIndex(table, fieldIndex, value)
  185. for k, v in ipairs(table) do
  186. if (v[fieldIndex] == value) then
  187. return k
  188. end
  189. end
  190. return -1
  191. end
  192.  
  193. local menuFrame = CreateFrame("Frame", "ContactDropDownMenu", UIParent, "UIDropDownMenuTemplate")
  194. local menuList = {
  195. {text = OPTIONS_MENU, isTitle = true, notCheckable = true},
  196. {text = INVITE, hasArrow = true, notCheckable = true},
  197. {text = CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable = true}
  198. }
  199.  
  200. SLASH_LSTATS1, SLASH_LSTATS2, SLASH_LSTATS3 = "/ls", "/lstats", "/litestats"
  201. local function slprint(...)
  202. local m, l = "|cffbcee68", "|cffff9912 -|r"
  203. local t = {...} print(m, t[1])
  204. for i = 2, #t do print(l, t[i]) end
  205. end
  206. function SlashCmdList.LSTATS()
  207. print("Lite|cff66C6FFStats|r "..L_STATS_TIPS)
  208. if memory.enabled then
  209. slprint(L_STATS_MEMORY, L_STATS_RC_COLLECTS_GARBAGE)
  210. end
  211. if gold.enabled then
  212. slprint(strtrim(gsub(MONEY, "%%d", "")), L_STATS_OPEN_CURRENCY, L_STATS_RC_AUTO_SELLING, L_STATS_NOT_TO_SELL, L_STATS_WATCH_CURRENCY)
  213. end
  214. if durability.enabled then
  215. slprint(DURABILITY, L_STATS_OPEN_CHARACTER, L_STATS_RC_AUTO_REPAIRING, L_STATS_EQUIPMENT_CHANGER)
  216. end
  217. if location.enabled or coords.enabled then
  218. slprint(L_STATS_LOCATION, L_STATS_WORLD_MAP, L_STATS_INSERTS_COORDS)
  219. end
  220. if clock.enabled then
  221. slprint(TIMEMANAGER_TITLE, L_STATS_OPEN_CALENDAR, L_STATS_RC_TIME_MANAGER, L_STATS_TOGGLE_TIME)
  222. end
  223. if friends.enabled or guild.enabled then
  224. slprint(format("%s/%s", FRIENDS,GUILD), L_STATS_VIEW_NOTES, L_STATS_CHANGE_SORTING)
  225. end
  226. if talents.enabled then
  227. slprint(TALENTS, L_STATS_OPEN_TALENT, L_STATS_RC_TALENT)
  228. end
  229. if experience.enabled then
  230. slprint(format("%s/%s/%s", COMBAT_XP_GAIN, TIME_PLAYED_MSG, FACTION), L_STATS_RC_EXPERIENCE, L_STATS_WATCH_FACTIONS)
  231. end
  232. print("|cffBCEE68", format(L_STATS_OTHER_OPTIONS, "|cff66C6FFShestakUI\\Config\\DataText.lua").."|r")
  233. end
  234.  
  235. CreateFrame("Frame", "LSMenus", UIParent, "UIDropDownMenuTemplate")
  236.  
  237. ----------------------------------------------------------------------------------------
  238. -- FPS
  239. ----------------------------------------------------------------------------------------
  240. if fps.enabled then
  241. Inject("FPS", {
  242. text = {
  243. string = function()
  244. return format(fps.fmt, floor(GetFramerate()))
  245. end
  246. },
  247. })
  248. end
  249.  
  250. ----------------------------------------------------------------------------------------
  251. -- Latency
  252. ----------------------------------------------------------------------------------------
  253. if latency.enabled then
  254. Inject("Latency", {
  255. text = {
  256. string = function()
  257. local _, _, latencyHome, latencyWorld = GetNetStats()
  258. local lat = math.max(latencyHome, latencyWorld)
  259. return format(gsub(latency.fmt, "%[color%]", (gradient(1 - lat / 750))), lat)
  260. end
  261. },
  262. OnEnter = function(self)
  263. local _, _, latencyHome, latencyWorld = GetNetStats()
  264. local latency = format(MAINMENUBAR_LATENCY_LABEL, latencyHome, latencyWorld)
  265. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  266. GameTooltip:ClearAllPoints()
  267. GameTooltip:SetPoint(modules.Latency.tip_anchor, modules.Latency.tip_frame, modules.Latency.tip_x, modules.Latency.tip_y)
  268. GameTooltip:ClearLines()
  269. GameTooltip:AddLine(latency, tthead.r, tthead.g, tthead.b)
  270. GameTooltip:Show()
  271. end,
  272. })
  273. end
  274.  
  275. ----------------------------------------------------------------------------------------
  276. -- Memory
  277. ----------------------------------------------------------------------------------------
  278. if memory.enabled then
  279. local function sortdesc(a, b) return a[2] > b[2] end
  280. local function formatmem(val,dec)
  281. return format(format("%%.%df %s", dec or 1, val > 1024 and "MB" or "KB"), val / (val > 1024 and 1024 or 1))
  282. end
  283. local memoryt = {}
  284. Inject("Memory", {
  285. text = {
  286. string = function(self)
  287. self.total = 0
  288. UpdateMemUse()
  289. local parent = self:GetParent()
  290. for i = 1, GetNumAddOns() do self.total = self.total + GetAddOnMemoryUsage(i) end
  291. if parent.hovered then self:GetParent():GetScript("OnEnter")(parent) end
  292. return self.total >= 1024 and format(memory.fmt_mb, self.total / 1024) or format(memory.fmt_kb, self.total)
  293. end, update = 5,
  294. },
  295. OnEnter = function(self)
  296. collectgarbage()
  297. self.hovered = true
  298. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  299. GameTooltip:ClearAllPoints()
  300. GameTooltip:SetPoint(modules.Memory.tip_anchor, modules.Memory.tip_frame, modules.Memory.tip_x, modules.Memory.tip_y)
  301. GameTooltip:ClearLines()
  302. local lat, r = select(4, GetNetStats()), 750
  303. GameTooltip:AddDoubleLine(
  304. format("|cffffffff%s|r %s, %s%s|r %s", floor(GetFramerate()), FPS_ABBR, gradient(1 - lat / r), lat,MILLISECONDS_ABBR),
  305. format("%s: |cffffffff%s", ADDONS, formatmem(self.text.total)), tthead.r, tthead.g, tthead.b, tthead.r, tthead.g,tthead.b)
  306. GameTooltip:AddLine(" ")
  307. if memory.max_addons ~= 0 or IsAltKeyDown() then
  308. if not self.timer or self.timer + 5 < time() then
  309. self.timer = time()
  310. UpdateMemUse()
  311. for i = 1, #memoryt do memoryt[i] = nil end
  312. for i = 1, GetNumAddOns() do
  313. local addon, name = GetAddOnInfo(i)
  314. if IsAddOnLoaded(i) then tinsert(memoryt, {name or addon, GetAddOnMemoryUsage(i)}) end
  315. end
  316. table.sort(memoryt, sortdesc)
  317. end
  318. local exmem = 0
  319. for i,t in ipairs(memoryt) do
  320. if memory.max_addons and i > memory.max_addons and not IsAltKeyDown() then
  321. exmem = exmem + t[2]
  322. else
  323. local color = t[2] <= 102.4 and {0,1} -- 0 - 100
  324. or t[2] <= 512 and {0.75,1} -- 100 - 512
  325. or t[2] <= 1024 and {1,1} -- 512 - 1mb
  326. or t[2] <= 2560 and {1,0.75} -- 1mb - 2.5mb
  327. or t[2] <= 5120 and {1,0.5} -- 2.5mb - 5mb
  328. or {1,0.1} -- 5mb +
  329. GameTooltip:AddDoubleLine(t[1], formatmem(t[2]), 1, 1, 1, color[1], color[2], 0)
  330. end
  331. end
  332. if exmem > 0 and not IsAltKeyDown() then
  333. local more = #memoryt - memory.max_addons
  334. GameTooltip:AddDoubleLine(format("%d %s (%s)", more, L_STATS_HIDDEN, ALT_KEY), formatmem(exmem), ttsubh.r, ttsubh.g, ttsubh.b, ttsubh.r, ttsubh.g, ttsubh.b)
  335. end
  336. GameTooltip:AddDoubleLine(" ", "--------------", 1, 1, 1, 0.5, 0.5, 0.5)
  337. end
  338. local bandwidth = GetAvailableBandwidth()
  339. if bandwidth ~= 0 then
  340. GameTooltip:AddDoubleLine(L_STATS_BANDWIDTH, format("%s ".."Mbps", T.Round(bandwidth, 2)), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  341. GameTooltip:AddDoubleLine(L_STATS_DOWNLOAD, format("%s%%", floor(GetDownloadedPercentage() * 100 + 0.5)), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  342. GameTooltip:AddLine(" ")
  343. end
  344. GameTooltip:AddDoubleLine(L_STATS_MEMORY_USAGE, formatmem(gcinfo() - self.text.total), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  345. GameTooltip:AddDoubleLine(L_STATS_TOTAL_MEMORY_USAGE, formatmem(collectgarbage"count"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  346. GameTooltip:Show()
  347. end,
  348. --OnUpdate = AltUpdate,
  349. OnLeave = function(self) self.hovered = false end,
  350. OnClick = function(self, button)
  351. if button == "RightButton" then
  352. UpdateMemUse()
  353. local before = gcinfo()
  354. collectgarbage()
  355. UpdateMemUse()
  356. print(format("|cff66C6FF%s:|r %s", L_STATS_GARBAGE_COLLECTED, formatmem(before - gcinfo())))
  357. self.timer, self.text.elapsed = nil, 5
  358. self:GetScript("OnEnter")(self)
  359. elseif button == "LeftButton" then
  360. if AddonList:IsShown() then
  361. AddonList_OnCancel()
  362. else
  363. PlaySound("igMainMenuOption")
  364. ShowUIPanel(AddonList)
  365. end
  366. end
  367. end
  368. })
  369. end
  370.  
  371. ----------------------------------------------------------------------------------------
  372. -- Durability
  373. ----------------------------------------------------------------------------------------
  374. if durability.enabled then
  375. Inject("Durability", {
  376. OnLoad = function(self)
  377. CreateFrame("GameTooltip", "LPDURA")
  378. LPDURA:SetOwner(WorldFrame, "ANCHOR_NONE")
  379. if durability.man then DurabilityFrame.Show = DurabilityFrame.Hide end
  380. RegEvents(self, "UPDATE_INVENTORY_DURABILITY MERCHANT_SHOW PLAYER_LOGIN")
  381. end,
  382. OnEvent = function(self, event, ...)
  383. if event == "UPDATE_INVENTORY_DURABILITY" or event == "PLAYER_LOGIN" then
  384. local dmin = 100
  385. for id = 1, 18 do
  386. local dur, dmax = GetInventoryItemDurability(id)
  387. if dur ~= dmax then dmin = floor(min(dmin, dur / dmax * 100)) end
  388. end
  389. self.text:SetText(format(gsub(durability.fmt, "%[color%]", (gradient(dmin / 100))), dmin))
  390. elseif event == "MERCHANT_SHOW" and not (IsAltKeyDown() or IsShiftKeyDown()) then
  391. if conf.AutoRepair and CanMerchantRepair() then
  392. local cost, total = GetRepairAllCost(), 0
  393. if cost > 0 then
  394. if conf.AutoGuildRepair and CanGuildBankRepair() then RepairAllItems(1) total = cost end
  395. if GetRepairAllCost() > 0 then
  396. if not durability.ignore_inventory and GetRepairAllCost() <= GetMoney() then
  397. total = GetRepairAllCost(); RepairAllItems()
  398. else
  399. for id = 1, 18 do
  400. local cost = select(3, LPDURA:SetInventoryItem(P, id))
  401. if cost ~= 0 and cost <= GetMoney() then
  402. if not InRepairMode() then ShowRepairCursor() end
  403. PickupInventoryItem(id)
  404. total = total + cost
  405. end
  406. end
  407. end
  408. HideRepairCursor()
  409. end
  410. if total > 0 then print(format("|cff66C6FF%s |cffFFFFFF%s", REPAIR_COST, formatgold(1, total))) end
  411. end
  412. end
  413. end
  414. end,
  415. OnEnter = function(self)
  416. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  417. GameTooltip:ClearAllPoints()
  418. GameTooltip:SetPoint(modules.Durability.tip_anchor, modules.Durability.tip_frame, modules.Durability.tip_x, modules.Durability.tip_y)
  419. GameTooltip:ClearLines()
  420. if C.tooltip.average_lvl == true then
  421. local avgItemLevel, avgItemLevelEquipped = GetAverageItemLevel()
  422. avgItemLevel = floor(avgItemLevel)
  423. avgItemLevelEquipped = floor(avgItemLevelEquipped)
  424. GameTooltip:AddDoubleLine(DURABILITY, STAT_AVERAGE_ITEM_LEVEL..": "..avgItemLevelEquipped.." / "..avgItemLevel, tthead.r, tthead.g, tthead.b, tthead.r, tthead.g, tthead.b)
  425. else
  426. GameTooltip:AddLine(DURABILITY, tthead.r, tthead.g, tthead.b)
  427. end
  428. GameTooltip:AddLine(" ")
  429. local nodur, totalcost = true, 0
  430. for slot, string in gmatch("1HEAD3SHOULDER5CHEST6WAIST7LEGS8FEET9WRIST10HANDS16MAINHAND17SECONDARYHAND", "(%d+)([^%d]+)") do
  431. local dur, dmax = GetInventoryItemDurability(slot)
  432. local string = _G[string.."SLOT"]
  433. if dur ~= dmax then
  434. local perc = dur ~= 0 and dur/dmax or 0
  435. local hex = gradient(perc)
  436. GameTooltip:AddDoubleLine(durability.gear_icons and format("|T%s:"..t_icon..":"..t_icon..":0:0:64:64:5:59:5:59:%d|t %s", GetInventoryItemTexture(P, slot), t_icon, string) or string,format("|cffaaaaaa%s/%s | %s%s%%", dur, dmax, hex, floor(perc * 100)), 1, 1, 1)
  437. totalcost, nodur = totalcost + select(3, LPDURA:SetInventoryItem(P, slot))
  438. end
  439. end
  440. if nodur then
  441. GameTooltip:AddLine("100%", 0.1, 1, 0.1)
  442. else
  443. GameTooltip:AddDoubleLine(" ", "--------------", 1, 1, 1, 0.5, 0.5, 0.5)
  444. GameTooltip:AddDoubleLine(REPAIR_COST, formatgold(1, totalcost), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  445. end
  446. GameTooltip:AddLine(" ")
  447. GameTooltip:AddDoubleLine(" ", L_STATS_AUTO_REPAIR..": "..(conf.AutoRepair and "|cff55ff55"..L_STATS_ON or "|cffff5555"..strupper(OFF)), 1, 1, 1, ttsubh.r, ttsubh.g, ttsubh.b)
  448. GameTooltip:AddDoubleLine(" ", L_STATS_GUILD_REPAIR..": "..(conf.AutoGuildRepair and "|cff55ff55"..L_STATS_ON or "|cffff5555"..strupper(OFF)), 1, 1, 1, ttsubh.r, ttsubh.g, ttsubh.b)
  449. GameTooltip:Show()
  450. end,
  451. OnClick = function(self, button)
  452. if button == "RightButton" then
  453. conf.AutoRepair = not conf.AutoRepair
  454. self:GetScript("OnEnter")(self)
  455. elseif button == "MiddleButton" then
  456. conf.AutoGuildRepair = not conf.AutoGuildRepair
  457. self:GetScript("OnEnter")(self)
  458. elseif GetNumEquipmentSets() > 0 and button == "LeftButton" and (IsAltKeyDown() or IsShiftKeyDown()) then
  459. local menulist = {{isTitle = true, notCheckable = 1, text = format(gsub(EQUIPMENT_SETS, ":", ""), "")}}
  460. if GetNumEquipmentSets() == 0 then
  461. tinsert(menulist, {text = NONE, notCheckable = 1, disabled = true})
  462. else
  463. for i = 1, GetNumEquipmentSets() do
  464. local name, icon = GetEquipmentSetInfo(i)
  465. tinsert(menulist, {text = format("|T%s:"..t_icon..":"..t_icon..":0:0:64:64:5:59:5:59:%d|t %s", icon, t_icon, name), notCheckable = 1, func = function() if InCombatLockdown() then print("|cffffff00"..ERR_NOT_IN_COMBAT.."|r") return end UseEquipmentSet(name) end})
  466. end
  467. end
  468. EasyMenu(menulist, LSMenus, "cursor", 0, 0, "MENU")
  469. elseif button == "LeftButton" then
  470. ToggleCharacter("PaperDollFrame")
  471. end
  472. end
  473. })
  474. end
  475.  
  476. ----------------------------------------------------------------------------------------
  477. -- Gold
  478. ----------------------------------------------------------------------------------------
  479. if gold.enabled then
  480. local IsSubTitle = 0
  481. local function Currency(id, weekly, capped)
  482. local name, amount, tex, week, weekmax, maxed, discovered = GetCurrencyInfo(id)
  483. if amount == 0 then return end
  484. if IsSubTitle == 1 then
  485. GameTooltip:AddLine(" ")
  486. GameTooltip:AddLine(PROFESSIONS_ARCHAEOLOGY, ttsubh.r, ttsubh.g, ttsubh.b)
  487. elseif IsSubTitle == 2 then
  488. GameTooltip:AddLine(" ")
  489. GameTooltip:AddLine(PROFESSIONS_COOKING, ttsubh.r, ttsubh.g, ttsubh.b)
  490. elseif IsSubTitle == 3 then
  491. GameTooltip:AddLine(" ")
  492. GameTooltip:AddLine(TRADE_SKILLS, ttsubh.r, ttsubh.g, ttsubh.b)
  493. elseif IsSubTitle == 4 then
  494. GameTooltip:AddLine(" ")
  495. GameTooltip:AddLine(L_STATS_CURRENCY_RAID, ttsubh.r, ttsubh.g, ttsubh.b)
  496. elseif IsSubTitle == 5 then
  497. GameTooltip:AddLine(" ")
  498. GameTooltip:AddLine(PVP_FLAG, ttsubh.r, ttsubh.g, ttsubh.b)
  499. elseif IsSubTitle == 6 then
  500. GameTooltip:AddLine(" ")
  501. GameTooltip:AddLine(MISCELLANEOUS, ttsubh.r, ttsubh.g, ttsubh.b)
  502. end
  503. IsSubTitle = 0
  504. if weekly then
  505. if discovered then GameTooltip:AddDoubleLine(name, format("%s |T%s:"..t_icon..":"..t_icon..":0:0:64:64:5:59:5:59:%d|t", REFORGE_CURRENT..": ".. amount.." - "..WEEKLY..": "..week.." / "..weekmax, tex, t_icon), 1, 1, 1, 1, 1, 1) end
  506. elseif capped then
  507. if id == 392 then maxed = 4000 end
  508. if discovered then GameTooltip:AddDoubleLine(name, format("%s |T%s:"..t_icon..":"..t_icon..":0:0:64:64:5:59:5:59:%d|t", amount.." / "..maxed, tex, t_icon), 1, 1, 1, 1, 1, 1) end
  509. else
  510. if discovered then GameTooltip:AddDoubleLine(name, format("%s |T%s:"..t_icon..":"..t_icon..":0:0:64:64:5:59:5:59:%d|t", amount, tex, t_icon), 1, 1, 1, 1, 1, 1) end
  511. end
  512. end
  513. Inject("Gold", {
  514. OnLoad = function(self)
  515. self.started = GetMoney()
  516. RegEvents(self, "PLAYER_LOGIN PLAYER_MONEY MERCHANT_SHOW")
  517. if not SavedStats.JunkIgnore then SavedStats.JunkIgnore = {} end
  518. end,
  519. OnEvent = function(self, event)
  520. conf.Gold = GetMoney()
  521. if event == "MERCHANT_SHOW" then
  522. if conf.AutoSell and not (IsAltKeyDown() or IsShiftKeyDown()) then
  523. local profit = 0
  524. for bag = 0, NUM_BAG_SLOTS do for slot = 0, GetContainerNumSlots(bag) do
  525. local link = GetContainerItemLink(bag, slot)
  526. if link then
  527. local itemstring, ignore = strmatch(link, "|Hitem:(%d-):"), false
  528. for _, exception in pairs(SavedStats.JunkIgnore) do
  529. if exception == itemstring then ignore = true break end
  530. end
  531. if (select(3, GetItemInfo(link)) == 0 and not ignore) or (ignore and select(3, GetItemInfo(link)) ~= 0) then
  532. profit = profit + select(11, GetItemInfo(link)) * select(2, GetContainerItemInfo(bag, slot))
  533. UseContainerItem(bag, slot)
  534. end
  535. end
  536. end end
  537. if profit > 0 then print(format("|cff66C6FF%s: |cffFFFFFF%s", L_STATS_JUNK_PROFIT, formatgold(1, profit))) end
  538. end
  539. return
  540. end
  541. self.text:SetText(formatgold(gold.style, conf.Gold))
  542. end,
  543. OnEnter = function(self)
  544. local curgold = GetMoney()
  545. local _, _, archaeology, _, cooking = GetProfessions()
  546. conf.Gold = curgold
  547. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  548. GameTooltip:ClearAllPoints()
  549. GameTooltip:SetPoint(gold.tip_anchor, gold.tip_frame, gold.tip_x, gold.tip_y)
  550. GameTooltip:ClearLines()
  551. GameTooltip:AddLine(CURRENCY, tthead.r, tthead.g, tthead.b)
  552. GameTooltip:AddLine(" ")
  553. if self.started ~= curgold then
  554. local gained = curgold > self.started
  555. local color = gained and "|cff55ff55" or "|cffff5555"
  556. GameTooltip:AddDoubleLine(L_STATS_SESSION_GAIN, format("%s$|r %s %s$|r", color, formatgold(1, abs(self.started - curgold)), color), 1, 1, 1, 1, 1, 1)
  557. GameTooltip:AddLine(" ")
  558. end
  559. GameTooltip:AddLine(L_STATS_SERVER_GOLD, ttsubh.r, ttsubh.g, ttsubh.b)
  560. local total = 0
  561. for char, conf in pairs(SavedStats[realm]) do
  562. if conf.Gold and conf.Gold > 99 then
  563. GameTooltip:AddDoubleLine(char, formatgold(1, conf.Gold), 1, 1, 1, 1, 1, 1)
  564. total = total + conf.Gold
  565. end
  566. end
  567. GameTooltip:AddDoubleLine(" ", "-----------------", 1, 1, 1, 0.5, 0.5, 0.5)
  568. GameTooltip:AddDoubleLine(TOTAL, formatgold(1, total), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  569. GameTooltip:AddLine(" ")
  570.  
  571. local currencies = 0
  572. for i = 1, GetCurrencyListSize() do
  573. local name, _, _, _, watched, count, icon = GetCurrencyListInfo(i)
  574. if watched then
  575. if currencies == 0 then GameTooltip:AddLine(TRACKING, ttsubh.r, ttsubh.g, ttsubh.b) end
  576. local r, g, b
  577. if count > 0 then r, g, b = 1, 1, 1 else r, g, b = 0.5, 0.5, 0.5 end
  578. GameTooltip:AddDoubleLine(name, format("%d |T%s:"..t_icon..":"..t_icon..":0:0:64:64:5:59:5:59:%d|t", count, icon, t_icon), r, g, b, r, g, b)
  579. currencies = currencies + 1
  580. end
  581. end
  582. if archaeology and C.stats.currency_archaeology then
  583. IsSubTitle = 1
  584. Currency(384) -- Dwarf Archaeology Fragment
  585. Currency(385) -- Troll Archaeology Fragment
  586. Currency(393) -- Fossil Archaeology Fragment
  587. Currency(394) -- Night Elf Archaeology Fragment
  588. Currency(397) -- Orc Archaeology Fragment
  589. Currency(398) -- Draenei Archaeology Fragment
  590. Currency(399) -- Vrykul Archaeology Fragment
  591. Currency(400) -- Nerubian Archaeology Fragment
  592. Currency(401) -- Tol'vir Archaeology Fragment
  593. Currency(676) -- Pandaren Archaeology Fragment
  594. Currency(677) -- Mogu Archaeology Fragment
  595. Currency(754) -- Mantid Archaeology Fragment
  596. Currency(821) -- Draenor Clans Archaeology Fragment
  597. Currency(828) -- Ogre Archaeology Fragment
  598. Currency(829) -- Arakkoa Archaeology Fragment
  599. Currency(1172) -- Highborne Archaeology Fragment
  600. Currency(1173) -- Highmountain Tauren Archaeology Fragment
  601. Currency(1174) -- Demonic Archaeology Fragment
  602. end
  603.  
  604. if cooking and C.stats.currency_cooking then
  605. IsSubTitle = 2
  606. Currency(81) -- Epicurean's Award
  607. Currency(402) -- Ironpaw Token
  608. end
  609.  
  610. if C.stats.currency_professions then
  611. IsSubTitle = 3
  612. Currency(910) -- Secret of Draenor Alchemy
  613. Currency(999) -- Secret of Draenor Tailoring
  614. Currency(1008) -- Secret of Draenor Jewelcrafting
  615. Currency(1017) -- Secret of Draenor Leatherworking
  616. Currency(1020) -- Secret of Draenor Blacksmithing
  617. end
  618.  
  619. if C.stats.currency_raid and T.level >= 110 then
  620. IsSubTitle = 4
  621. Currency(1273, false, true) -- Seal of Broken Fate
  622. end
  623.  
  624. if C.stats.currency_pvp then
  625. IsSubTitle = 5
  626. -- Currency(390, true) -- Conquest Points
  627. -- Currency(392, false, true) -- Honor Points
  628. end
  629.  
  630. if C.stats.currency_misc then
  631. IsSubTitle = 6
  632. Currency(515) -- Darkmoon Prize Ticket
  633. Currency(1155, false, true) -- Ancient Mana
  634. Currency(1220) -- Order Resources
  635. end
  636.  
  637. GameTooltip:AddLine(" ")
  638. GameTooltip:AddDoubleLine(" ", L_STATS_AUTO_SELL..": "..(conf.AutoSell and "|cff55ff55"..L_STATS_ON or "|cffff5555"..strupper(OFF)), 1, 1, 1, ttsubh.r, ttsubh.g, ttsubh.b)
  639. GameTooltip:Show()
  640. end,
  641. OnClick = function(self, button)
  642. if button == "LeftButton" then
  643. ToggleCharacter("TokenFrame")
  644. elseif button == "RightButton" then
  645. conf.AutoSell = not conf.AutoSell
  646. self:GetScript("OnEnter")(self)
  647. end
  648. end
  649. })
  650. SLASH_KJUNK1 = "/junk"
  651. function SlashCmdList.KJUNK(s)
  652. local action = strsplit(" ", s)
  653. if action == "list" then
  654. print(format("|cff66C6FF%s:|r %s", L_STATS_JUNK_EXCEPTIONS, (#SavedStats.JunkIgnore == 0 and NONE or "")))
  655. for i, id in pairs(SavedStats.JunkIgnore) do
  656. local _, link = GetItemInfo(id)
  657. print("- ["..i.."]", link)
  658. end
  659. elseif action == "clear" then
  660. SavedStats.JunkIgnore = {}
  661. print("|cff66C6FF"..L_STATS_CLEARED_JUNK.."|r")
  662. elseif action == "add" or strfind(action, "^del") or strfind(action, "^rem") then
  663. local _, mouselink = GameTooltip:GetItem()
  664. for id in s:gmatch("|Hitem:(%d-):") do
  665. mouselink = nil
  666. local _, link = GetItemInfo(id)
  667. if action == "add" then
  668. if not tContains(SavedStats.JunkIgnore,id) then
  669. tinsert(SavedStats.JunkIgnore, id)
  670. print(format("|cff66C6FF%s:|r %s", L_STATS_ADDED_JUNK, link))
  671. else
  672. print(format("%s |cff66C6FF%s|r", link, L_STATS_ALREADY_EXCEPTIONS))
  673. end
  674. elseif strfind(action, "^del") or strfind(action, "^rem") then
  675. tDeleteItem(SavedStats.JunkIgnore, id)
  676. print(format("|cff66C6FF%s:|r %s", L_STATS_REMOVED_JUNK, link))
  677. end
  678. end
  679. if mouselink then
  680. for id in mouselink:gmatch("|Hitem:(%d-):") do
  681. if action == "add" then
  682. if not tContains(SavedStats.JunkIgnore,id) then
  683. tinsert(SavedStats.JunkIgnore, id)
  684. print(format("|cff66C6FF%s:|r %s", L_STATS_ADDED_JUNK, mouselink))
  685. else
  686. print(format("%s |cff66C6FF%s|r", mouselink, L_STATS_ALREADY_EXCEPTIONS))
  687. end
  688. elseif strfind(action, "^del") or strfind(action, "^rem") then
  689. tDeleteItem(SavedStats.JunkIgnore, id)
  690. print(format("|cff66C6FF%s:|r %s", L_STATS_REMOVED_JUNK, mouselink))
  691. end
  692. end
  693. end
  694. else
  695. print("|Lite|cff66C6FFStats|r: "..L_STATS_JUNK_LIST)
  696. print(format("/junk <add||rem(ove)> [%s] - %s", L_STATS_ITEMLINK, L_STATS_REMOVE_EXCEPTION))
  697. print("/junk list - "..L_STATS_IGNORED_ITEMS)
  698. print("/junk clear - "..L_STATS_CLEAR_EXCEPTIONS)
  699. end
  700. end
  701. end
  702.  
  703. ----------------------------------------------------------------------------------------
  704. -- Clock
  705. ----------------------------------------------------------------------------------------
  706. if clock.enabled then
  707. Inject("Clock", {
  708. text = {
  709. string = function()
  710. return zsub(GameTime_GetTime(true), "%s*AM", clock.AM, "%s*PM", clock.PM, ":", clock.colon)
  711. end
  712. },
  713. OnLoad = function(self) RequestRaidInfo() RegEvents(self, "UPDATE_INSTANCE_INFO") end,
  714. OnEvent = function(self) if self.hovered then self:GetScript("OnEnter")(self) end end,
  715. OnEnter = function(self)
  716. if not self.hovered then RequestRaidInfo() self.hovered = true end
  717. local weekday = select(date"%w"+1, CalendarGetWeekdayNames())
  718. local month = select(date"%m", CalendarGetMonthNames())
  719. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  720. GameTooltip:ClearAllPoints()
  721. GameTooltip:SetPoint(clock.tip_anchor, clock.tip_frame, clock.tip_x, clock.tip_y)
  722. GameTooltip:ClearLines()
  723. GameTooltip:AddLine(format("%s, %s %s", weekday, month, date"%d %Y"), tthead.r, tthead.g, tthead.b)
  724. GameTooltip:AddLine(" ")
  725. GameTooltip:AddDoubleLine(gsub(TIMEMANAGER_TOOLTIP_LOCALTIME, ":", ""), zsub(GameTime_GetLocalTime(true), "%s*AM", "am", "%s*PM", "pm"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  726. GameTooltip:AddDoubleLine(gsub(TIMEMANAGER_TOOLTIP_REALMTIME, ":", ""), zsub(GameTime_GetGameTime(true), "%s*AM", "am", "%s*PM", "pm"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  727. GameTooltip:AddLine(" ")
  728. for i = 1, 2 do
  729. local _, localizedName, isActive, _, startTime = GetWorldPVPAreaInfo(i)
  730. local r, g, b = 1, 1, 1
  731. if i == 1 then
  732. SetMapByID(485)
  733. for i = 1, GetNumMapLandmarks() do
  734. local index = select(3, GetMapLandmarkInfo(i))
  735. if index == 46 then
  736. r, g, b = 0.4, 0.8, 0.94
  737. elseif index == 48 then
  738. r, g, b = 1, 0.2, 0.2
  739. end
  740. end
  741. GameTooltip:AddDoubleLine(localizedName, isActive and WINTERGRASP_IN_PROGRESS or fmttime(startTime), ttsubh.r, ttsubh.g, ttsubh.b, r, g, b)
  742. elseif i == 2 then
  743. SetMapByID(708)
  744. for i = 1, GetNumMapLandmarks() do
  745. local index = select(3, GetMapLandmarkInfo(i))
  746. if index == 46 then
  747. r, g, b = 0.4, 0.8, 0.94
  748. elseif index == 48 then
  749. r, g, b = 1, 0.2, 0.2
  750. end
  751. end
  752. GameTooltip:AddDoubleLine(localizedName, isActive and WINTERGRASP_IN_PROGRESS or fmttime(startTime), ttsubh.r, ttsubh.g, ttsubh.b, r, g, b)
  753. end
  754. end
  755.  
  756. local oneraid
  757. local heroicDifficulty = {DUNGEON_DIFFICULTY2, DUNGEON_DIFFICULTY_5PLAYER_HEROIC, RAID_DIFFICULTY3, RAID_DIFFICULTY4, RAID_DIFFICULTY_10PLAYER_HEROIC, RAID_DIFFICULTY_25PLAYER_HEROIC}
  758. for i = 1, GetNumSavedInstances() do
  759. local name, _, reset, difficulty, locked, extended, _, isRaid, maxPlayers, _, numEncounters, encounterProgress = GetSavedInstanceInfo(i)
  760. if isRaid and (locked or extended) or maxPlayers == 5 and difficulty == 23 and (locked or extended) then
  761. local tr, tg, tb, diff
  762. if not oneraid then
  763. GameTooltip:AddLine(" ")
  764. GameTooltip:AddLine(CALENDAR_FILTER_RAID_LOCKOUTS.." / "..DUNGEONS, ttsubh.r, ttsubh.g, ttsubh.b)
  765. oneraid = true
  766. end
  767. if extended then tr, tg, tb = 0.3, 1, 0.3 else tr, tg, tb = 1, 1, 1 end
  768. for _, value in pairs(heroicDifficulty) do
  769. if value == difficulty then
  770. diff = "H"
  771. break
  772. end
  773. end
  774. if (numEncounters and numEncounters > 0) and (encounterProgress and encounterProgress > 0) then
  775. if maxPlayers == 5 and difficulty == 23 then
  776. GameTooltip:AddDoubleLine(format("%s |cffaaaaaa[%s%s] (%s/%s)", "M: "..name, maxPlayers, diff or "", encounterProgress, numEncounters), fmttime(reset), 1, 1, 1, tr, tg, tb)
  777. else
  778. GameTooltip:AddDoubleLine(format("%s |cffaaaaaa[%s%s] (%s/%s)", name, maxPlayers, diff or "", encounterProgress, numEncounters), fmttime(reset), 1, 1, 1, tr, tg, tb)
  779. end
  780. else
  781. GameTooltip:AddDoubleLine(format("%s |cffaaaaaa[%s%s]", name, maxPlayers, diff or ""), fmttime(reset), 1, 1, 1, tr, tg, tb)
  782. end
  783. end
  784. end
  785. local addedLine
  786. for i = 1, GetNumSavedWorldBosses() do
  787. local name, _, reset = GetSavedWorldBossInfo(i)
  788. if reset then
  789. if not addedLine then
  790. GameTooltip:AddLine(" ")
  791. GameTooltip:AddLine(RAID_INFO_WORLD_BOSS, ttsubh.r, ttsubh.g, ttsubh.b)
  792. addedLine = true
  793. end
  794. GameTooltip:AddDoubleLine(name, fmttime(reset), 1, 1, 1, 1, 1, 1)
  795. end
  796. end
  797. --BETA if T.level >= 100 then
  798. -- local c = 0
  799. -- for _, q in ipairs({36054, 36055, 36056, 36057, 36058, 36060, 37453, 37452, 37454, 37455, 37456, 37457, 37458, 37459}) do
  800. -- if IsQuestFlaggedCompleted(q) then
  801. -- c = c + 1
  802. -- end
  803. -- end
  804. -- GameTooltip:AddLine(" ")
  805. -- GameTooltip:AddLine(MISCELLANEOUS, ttsubh.r, ttsubh.g, ttsubh.b)
  806. -- GameTooltip:AddDoubleLine(L_STATS_SEALS..": ", c, 1, 1, 1, 1, 1, 1)
  807. -- end
  808. GameTooltip:Show()
  809. end,
  810. OnClick = function(_, b) (b == "RightButton" and ToggleTimeManager or ToggleCalendar)() end
  811. })
  812. end
  813.  
  814. ----------------------------------------------------------------------------------------
  815. -- Location
  816. ----------------------------------------------------------------------------------------
  817. if location.enabled then
  818. Inject("Location", {
  819. OnLoad = function(self)
  820. RegEvents(self, "ZONE_CHANGED ZONE_CHANGED_INDOORS ZONE_CHANGED_NEW_AREA PLAYER_ENTERING_WORLD")
  821. self.sanctuary = {SANCTUARY_TERRITORY, {0.41, 0.8, 0.94}}
  822. self.arena = {FREE_FOR_ALL_TERRITORY, {1, 0.1, 0.1}}
  823. self.friendly = {FACTION_CONTROLLED_TERRITORY, {0.1, 1, 0.1}}
  824. self.hostile = {FACTION_CONTROLLED_TERRITORY, {1, 0.1, 0.1}}
  825. self.contested = {CONTESTED_TERRITORY, {1, 0.7, 0}}
  826. self.combat = {COMBAT_ZONE, {1, 0.1, 0.1}}
  827. self.neutral = {format(FACTION_CONTROLLED_TERRITORY, FACTION_STANDING_LABEL4), {1, 0.93, 0.76}}
  828. end,
  829. OnEvent = function(self)
  830. self.subzone, self.zone, self.pvp = GetSubZoneText(), GetZoneText(), {GetZonePVPInfo()}
  831. if not self.pvp[1] then self.pvp[1] = "neutral" end
  832. local label = (self.subzone ~= "" and location.subzone) and self.subzone or self.zone
  833. local r, g, b = unpack(self.pvp[1] and (self[self.pvp[1]][2] or self.other) or self.other)
  834. self.text:SetText(location.truncate == 0 and label or strtrim(strsub(label, 1, location.truncate)))
  835. self.text:SetTextColor(r, g, b, font.alpha)
  836. end,
  837. OnUpdate = function(self,u)
  838. if self.hovered then
  839. self.elapsed = self.elapsed + u
  840. if self.elapsed > 1 or self.init then
  841. GameTooltip:ClearLines()
  842. GameTooltip:AddLine(format("%s |cffffffff(%s)", self.zone, Coords()), tthead.r, tthead.g, tthead.b, 1, 1, 1)
  843. if self.pvp[1] and not IsInInstance() then
  844. local r, g, b = unpack(self[self.pvp[1]][2])
  845. if self.subzone and self.subzone ~= self.zone then GameTooltip:AddLine(self.subzone, r, g, b) end
  846. GameTooltip:AddLine(format(self[self.pvp[1]][1], self.pvp[3] or ""), r, g, b)
  847. end
  848. GameTooltip:Show()
  849. self.elapsed, self.init = 0, false
  850. end
  851. end
  852. end,
  853. OnEnter = function(self)
  854. self.hovered, self.init = true, true
  855. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  856. GameTooltip:ClearAllPoints()
  857. GameTooltip:SetPoint(modules.Location.tip_anchor, modules.Location.tip_frame, modules.Location.tip_x, modules.Location.tip_y)
  858. end,
  859. OnClick = function(self,button)
  860. if IsShiftKeyDown() then
  861. ChatEdit_ActivateChat(ChatEdit_ChooseBoxForSend())
  862. ChatEdit_ChooseBoxForSend():Insert(format(" (%s: %s)", self.zone, Coords()))
  863. else
  864. ToggleFrame(WorldMapFrame)
  865. end
  866. end
  867. })
  868. end
  869.  
  870. ----------------------------------------------------------------------------------------
  871. -- Coordinates
  872. ----------------------------------------------------------------------------------------
  873. if coords.enabled then
  874. Inject("Coords", {
  875. text = {string = Coords},
  876. OnClick = function(_, button)
  877. if button == "LeftButton" then
  878. ToggleFrame(WorldMapFrame)
  879. else
  880. ChatEdit_ActivateChat(ChatEdit_ChooseBoxForSend())
  881. ChatEdit_ChooseBoxForSend():Insert(format(" (%s: %s)", GetZoneText(), Coords()))
  882. end
  883. end
  884. })
  885. end
  886.  
  887. ----------------------------------------------------------------------------------------
  888. -- Ping
  889. ----------------------------------------------------------------------------------------
  890. if ping.enabled then
  891. Inject("Ping", {
  892. OnLoad = function(self)
  893. self:RegisterEvent("MINIMAP_PING")
  894. self.animGroup = self.text:CreateAnimationGroup()
  895. self.anim = self.animGroup:CreateAnimation("Alpha")
  896. self.animGroup:SetScript("OnFinished", function() self.text:Hide() end)
  897. self.anim:SetFromAlpha(1)
  898. self.anim:SetToAlpha(0)
  899. self.anim:SetDuration(2.8)
  900. self.anim:SetStartDelay(5)
  901. end,
  902. OnEvent = function(self, event, unit)
  903. if unit == P and ping.hide_self then return end
  904. local class = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[select(2, UnitClass(unit))]
  905. self.text:SetText(format(ping.fmt, UnitName(unit)))
  906. if class then
  907. self.text:SetTextColor(class.r, class.g, class.b, 1)
  908. else
  909. self.text:SetTextColor(1, 1, 1, 1)
  910. end
  911. self.animGroup:Stop()
  912. self.text:Show()
  913. self.animGroup:Play()
  914. end
  915. })
  916. end
  917.  
  918. ----------------------------------------------------------------------------------------
  919. -- Guild
  920. ----------------------------------------------------------------------------------------
  921. if guild.enabled then
  922. local guildTable = {}
  923. local function BuildGuildTable()
  924. wipe(guildTable)
  925. for i = 1, GetNumGuildMembers() do
  926. local name, rank, _, level, _, zone, note, officernote, connected, status, class, _, _, mobile = GetGuildRosterInfo(i)
  927. name = Ambiguate(name, "none")
  928. guildTable[i] = {name, rank, level, zone, note, officernote, connected, status, class, mobile}
  929. end
  930. table.sort(guildTable, function(a, b)
  931. if (a and b) then
  932. return a[1] < b[1]
  933. end
  934. end)
  935. end
  936. hooksecurefunc("SortGuildRoster", function(type) CURRENT_GUILD_SORTING = type end)
  937. Inject("Guild", {
  938. text = {
  939. string = function()
  940. if IsInGuild() then
  941. local total, _, online = GetNumGuildMembers()
  942. return format(guild.fmt, online, total)
  943. else return LOOKINGFORGUILD end
  944. end, update = 5
  945. },
  946. OnLoad = function(self)
  947. GuildRoster()
  948. SortGuildRoster(guild.sorting == "note" and "rank" or "note")
  949. SortGuildRoster(guild.sorting)
  950. self:RegisterEvent("GROUP_ROSTER_UPDATE")
  951. self:RegisterEvent("GUILD_ROSTER_UPDATE")
  952. end,
  953. OnEvent = function(self, event)
  954. if self.hovered then
  955. self:GetScript("OnEnter")(self)
  956. end
  957. if IsInGuild() then
  958. BuildGuildTable()
  959. end
  960. end,
  961. OnUpdate = function(self, u)
  962. if IsInGuild() then
  963. AltUpdate(self)
  964. if not self.gmotd then
  965. if self.elapsed > 1 then GuildRoster(); self.elapsed = 0 end
  966. if GetGuildRosterMOTD() ~= "" then self.gmotd = true; if self.hovered then self:GetScript("OnEnter")(self) end end
  967. self.elapsed = self.elapsed + u
  968. end
  969. end
  970. end,
  971. OnClick = function(self, b)
  972. if b == "LeftButton" then
  973. ToggleGuildFrame()
  974. if IsInGuild() then
  975. GuildFrame_TabClicked(GuildFrameTab2)
  976. end
  977. elseif b == "MiddleButton" and IsInGuild() then
  978. local s = CURRENT_GUILD_SORTING
  979. SortGuildRoster(IsShiftKeyDown() and s or (IsAltKeyDown() and (s == "rank" and "note" or "rank") or s == "class" and "name" or s == "name" and "level" or s == "level" and "zone" or "class"))
  980. self:GetScript("OnEnter")(self)
  981. elseif b == "RightButton" and IsInGuild() then
  982. HideTT(self)
  983.  
  984. local classc, levelc, grouped
  985. local menuCountWhispers = 0
  986. local menuCountInvites = 0
  987.  
  988. menuList[2].menuList = {}
  989. menuList[3].menuList = {}
  990.  
  991. for i = 1, #guildTable do
  992. if (guildTable[i][7] or guildTable[i][10]) and guildTable[i][1] ~= T.name then
  993. local classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[guildTable[i][9]], GetQuestDifficultyColor(guildTable[i][3])
  994. if UnitInParty(guildTable[i][1]) or UnitInRaid(guildTable[i][1]) then
  995. grouped = "|cffaaaaaa*|r"
  996. else
  997. grouped = ""
  998. if not guildTable[i][10] then
  999. menuCountInvites = menuCountInvites + 1
  1000. menuList[2].menuList[menuCountInvites] = {
  1001. text = string.format("|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s", levelc.r * 255, levelc.g * 255, levelc.b * 255, guildTable[i][3], classc.r * 255, classc.g * 255, classc.b * 255, Ambiguate(guildTable[i][1], "all"), ""),
  1002. arg1 = guildTable[i][1],
  1003. notCheckable = true,
  1004. func = function(self, arg1)
  1005. menuFrame:Hide()
  1006. InviteUnit(arg1)
  1007. end
  1008. }
  1009. end
  1010. end
  1011. menuCountWhispers = menuCountWhispers + 1
  1012. menuList[3].menuList[menuCountWhispers] = {
  1013. text = string.format("|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s", levelc.r * 255, levelc.g * 255, levelc.b * 255, guildTable[i][3], classc.r * 255, classc.g * 255, classc.b * 255, Ambiguate(guildTable[i][1], "all"), grouped),
  1014. arg1 = guildTable[i][1],
  1015. notCheckable = true,
  1016. func = function(self, arg1)
  1017. menuFrame:Hide()
  1018. SetItemRef("player:"..arg1, ("|Hplayer:%1$s|h[%1$s]|h"):format(arg1), "LeftButton")
  1019. end
  1020. }
  1021. end
  1022. end
  1023.  
  1024. EasyMenu(menuList, menuFrame, self, 0, 0, "MENU")
  1025. end
  1026. end,
  1027. OnEnter = function(self)
  1028. if IsInGuild() then
  1029. self.hovered = true
  1030. GuildRoster()
  1031. local name, rank, level, zone, note, officernote, connected, status, class, isMobile, zone_r, zone_g, zone_b, classc, levelc, grouped
  1032. local total, _, online = GetNumGuildMembers()
  1033. local gmotd = GetGuildRosterMOTD()
  1034. local _, _, standingID, barMin, barMax, barValue = GetGuildFactionInfo()
  1035. local col = T.RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b)
  1036.  
  1037. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  1038. GameTooltip:ClearAllPoints()
  1039. GameTooltip:SetPoint(modules.Guild.tip_anchor, modules.Guild.tip_frame, modules.Guild.tip_x, modules.Guild.tip_y)
  1040. GameTooltip:ClearLines()
  1041. GameTooltip:AddDoubleLine(GetGuildInfo(P),format("%s: %d/%d", GUILD_ONLINE_LABEL, online, total), tthead.r, tthead.g, tthead.b, tthead.r, tthead.g, tthead.b)
  1042. if gmotd ~= "" then GameTooltip:AddLine(format("%s |cffaaaaaa- |cffffffff%s", GUILD_MOTD, gmotd), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  1043. if guild.maxguild ~= 0 and online >= 1 then
  1044. GameTooltip:AddLine(" ")
  1045. for i = 1, total do
  1046. if guild.maxguild and i > guild.maxguild then
  1047. if online > 2 then GameTooltip:AddLine(format("%d %s (%s)", online - guild.maxguild, L_STATS_HIDDEN, ALT_KEY), ttsubh.r, ttsubh.g, ttsubh.b) end
  1048. break
  1049. end
  1050. name, rank, _, level, _, zone, note, officernote, connected, status, class, _, _, isMobile = GetGuildRosterInfo(i)
  1051. if (connected or isMobile) and level >= guild.threshold then
  1052. name = Ambiguate(name, "all")
  1053. if GetRealZoneText() == zone then zone_r, zone_g, zone_b = 0.3, 1, 0.3 else zone_r, zone_g, zone_b = 1, 1, 1 end
  1054. if isMobile then zone = "|cffa5a5a5"..REMOTE_CHAT.."|r" end
  1055. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
  1056. grouped = (UnitInParty(name) or UnitInRaid(name)) and (GetRealZoneText() == zone and " |cff7fff00*|r" or " |cffff7f00*|r") or ""
  1057. if self.altdown then
  1058. GameTooltip:AddDoubleLine(format("%s%s |cff999999- |cffffffff%s", grouped, name, rank), zone, classc.r, classc.g, classc.b, zone_r, zone_g, zone_b)
  1059. if note ~= "" then GameTooltip:AddLine(" "..NOTE_COLON.." "..note, ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  1060. if officernote ~= "" and EPGP then
  1061. local ep, gp = EPGP:GetEPGP(name)
  1062. if ep then
  1063. officernote = " EP: "..ep.." GP: "..gp.." PR: "..string.format("%.3f", ep / gp)
  1064. else
  1065. officernote = " O."..NOTE_COLON.." "..officernote
  1066. end
  1067. elseif officernote ~= "" then
  1068. officernote = " O."..NOTE_COLON.." "..officernote
  1069. end
  1070. if officernote ~= "" then GameTooltip:AddLine(officernote, 0.3, 1, 0.3, 1) end
  1071. else
  1072. if status == 1 then
  1073. status = " |cffE7E716"..L_CHAT_AFK.."|r"
  1074. elseif status == 2 then
  1075. status = " |cffff0000"..L_CHAT_DND.."|r"
  1076. else
  1077. status = ""
  1078. end
  1079. GameTooltip:AddDoubleLine(format("|cff%02x%02x%02x%d|r %s%s%s", levelc.r * 255, levelc.g * 255, levelc.b * 255, level, name, status, grouped), zone, classc.r, classc.g, classc.b, zone_r, zone_g, zone_b)
  1080. end
  1081. end
  1082. end
  1083. GameTooltip:AddLine(" ")
  1084. GameTooltip:AddDoubleLine(" ", format("%s %s", L_STATS_SORTING_BY, CURRENT_GUILD_SORTING), 1, 1, 1, ttsubh.r, ttsubh.g, ttsubh.b)
  1085. end
  1086. GameTooltip:Show()
  1087. end
  1088. end
  1089. })
  1090. end
  1091.  
  1092. ----------------------------------------------------------------------------------------
  1093. -- Friends
  1094. ----------------------------------------------------------------------------------------
  1095. if friends.enabled then
  1096. local totalFriendsOnline = 0
  1097. local totalBattleNetOnline = 0
  1098. local BNTable = {}
  1099. local friendTable = {}
  1100. local function BuildFriendTable(total)
  1101. totalFriendsOnline = 0
  1102. wipe(friendTable)
  1103.  
  1104. for i = 1, total do
  1105. local name, level, class, area, connected, status, note = GetFriendInfo(i)
  1106. for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1107. if GetLocale() ~= "enUS" then
  1108. for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  1109. end
  1110. friendTable[i] = {name, level, class, area, connected, status, note}
  1111. if connected then
  1112. totalFriendsOnline = totalFriendsOnline + 1
  1113. end
  1114. end
  1115.  
  1116. table.sort(friendTable, function(a, b)
  1117. if a[1] and b[1] then
  1118. return a[1] < b[1]
  1119. end
  1120. end)
  1121. end
  1122. local function BuildBNTable(total)
  1123. totalBattleNetOnline = 0
  1124. wipe(BNTable)
  1125.  
  1126. for i = 1, total do
  1127. local presenceID, presenceName, battleTag, _, toonName, toonID, client, isOnline, _, isAFK, isDND, _, noteText = BNGetFriendInfo(i)
  1128. local _, _, _, realmName, _, faction, race, class, _, zoneName, level = BNGetGameAccountInfo(toonID or presenceID)
  1129. for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1130. if GetLocale() ~= "enUS" then
  1131. for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  1132. end
  1133. BNTable[i] = {presenceID, presenceName, battleTag, toonName, toonID, client, isOnline, isAFK, isDND, noteText, realmName, faction, race, class, zoneName, level}
  1134. if isOnline then
  1135. totalBattleNetOnline = totalBattleNetOnline + 1
  1136. end
  1137. end
  1138.  
  1139. table.sort(BNTable, function(a, b)
  1140. if a[2] and b[2] and a[3] and b[3] then
  1141. if a[2] == b[2] then return a[3] < b[3] end
  1142. return a[2] < b[2]
  1143. end
  1144. end)
  1145. end
  1146. Inject("Friends", {
  1147. OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN PLAYER_ENTERING_WORLD GROUP_ROSTER_UPDATE FRIENDLIST_UPDATE BN_FRIEND_LIST_SIZE_CHANGED BN_FRIEND_ACCOUNT_ONLINE BN_FRIEND_ACCOUNT_OFFLINE BN_FRIEND_INFO_CHANGED BN_FRIEND_TOON_ONLINE BN_FRIEND_TOON_OFFLINE BN_TOON_NAME_UPDATED") end,
  1148. OnEvent = function(self, event)
  1149. if event ~= "GROUP_ROSTER_UPDATE" then
  1150. local numBNetTotal, numBNetOnline = BNGetNumFriends()
  1151. local online, total = 0, GetNumFriends()
  1152. for i = 0, total do if select(5, GetFriendInfo(i)) then online = online + 1 end end
  1153. online = online + numBNetOnline
  1154. total = total + numBNetTotal
  1155. self.text:SetText(format(friends.fmt, online, total))
  1156. end
  1157. if self.hovered then self:GetScript("OnEnter")(self) end
  1158. end,
  1159. OnUpdate = AltUpdate,
  1160. OnClick = function(self, b)
  1161. if b == "MiddleButton" then
  1162. ToggleIgnorePanel()
  1163. elseif b == "LeftButton" then
  1164. ToggleFriendsFrame()
  1165. elseif b == "RightButton" then
  1166. HideTT(self)
  1167.  
  1168. local BNTotal = BNGetNumFriends()
  1169. local total = GetNumFriends()
  1170. BuildBNTable(BNTotal)
  1171. BuildFriendTable(total)
  1172.  
  1173. local classc, levelc, grouped
  1174. local menuCountWhispers = 0
  1175. local menuCountInvites = 0
  1176.  
  1177. menuList[2].menuList = {}
  1178. menuList[3].menuList = {}
  1179.  
  1180. if totalFriendsOnline > 0 then
  1181. for i = 1, #friendTable do
  1182. if friendTable[i][5] then
  1183. if UnitInParty(friendTable[i][1]) or UnitInRaid(friendTable[i][1]) then
  1184. grouped = " |cffaaaaaa*|r"
  1185. else
  1186. grouped = ""
  1187. end
  1188.  
  1189. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]], GetQuestDifficultyColor(friendTable[i][2])
  1190. if classc == nil then
  1191. classc = GetQuestDifficultyColor(friendTable[i][2])
  1192. end
  1193.  
  1194. menuCountWhispers = menuCountWhispers + 1
  1195. menuList[3].menuList[menuCountWhispers] = {
  1196. text = format("|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r%s", levelc.r * 255, levelc.g * 255, levelc.b * 255, friendTable[i][2], classc.r * 255, classc.g * 255, classc.b * 255, friendTable[i][1], grouped),
  1197. arg1 = friendTable[i][1],
  1198. notCheckable = true,
  1199. func = function(self, arg1)
  1200. menuFrame:Hide()
  1201. SetItemRef("player:"..arg1, ("|Hplayer:%1$s|h[%1$s]|h"):format(arg1), "LeftButton")
  1202. end
  1203. }
  1204.  
  1205. if not (UnitInParty(friendTable[i][1]) or UnitInRaid(friendTable[i][1])) then
  1206. menuCountInvites = menuCountInvites + 1
  1207. menuList[2].menuList[menuCountInvites] = {
  1208. text = format("|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r", levelc.r * 255, levelc.g * 255, levelc.b * 255, friendTable[i][2], classc.r * 255, classc.g * 255, classc.b * 255, friendTable[i][1]),
  1209. arg1 = friendTable[i][1],
  1210. notCheckable = true,
  1211. func = function(self, arg1)
  1212. menuFrame:Hide()
  1213. InviteUnit(arg1)
  1214. end
  1215. }
  1216. end
  1217. end
  1218. end
  1219. end
  1220.  
  1221. if totalBattleNetOnline > 0 then
  1222. for i = 1, #BNTable do
  1223. if BNTable[i][7] then
  1224. if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then
  1225. grouped = " |cffaaaaaa*|r"
  1226. else
  1227. grouped = ""
  1228. end
  1229.  
  1230. menuCountWhispers = menuCountWhispers + 1
  1231. menuList[3].menuList[menuCountWhispers] = {
  1232. text = BNTable[i][2]..grouped,
  1233. arg1 = BNTable[i][2],
  1234. notCheckable = true,
  1235. func = function(self, arg1)
  1236. menuFrame:Hide()
  1237. ChatFrame_SendSmartTell(arg1)
  1238. end
  1239. }
  1240.  
  1241. if BNTable[i][6] == BNET_CLIENT_WOW and UnitFactionGroup("player") == BNTable[i][12] then
  1242. if not (UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4])) then
  1243. menuCountInvites = menuCountInvites + 1
  1244. menuList[2].menuList[menuCountInvites] = {
  1245. text = BNTable[i][2],
  1246. arg1 = BNTable[i][5],
  1247. notCheckable = true,
  1248. func = function(self, arg1)
  1249. menuFrame:Hide()
  1250. BNInviteFriend(arg1)
  1251. end
  1252. }
  1253. end
  1254. end
  1255. end
  1256. end
  1257. end
  1258.  
  1259. EasyMenu(menuList, menuFrame, self, 0, 0, "MENU")
  1260. end
  1261. end,
  1262. OnEnter = function(self)
  1263. ShowFriends()
  1264. self.hovered = true
  1265. local online, total = 0, GetNumFriends()
  1266. local name, level, class, zone, connected, status, note, classc, levelc, zone_r, zone_g, zone_b, grouped
  1267. for i = 0, total do if select(5, GetFriendInfo(i)) then online = online + 1 end end
  1268. local BNonline, BNtotal = 0, BNGetNumFriends()
  1269. local presenceID, presenceName, toonName, toonID, client, isOnline
  1270. if BNtotal > 0 then
  1271. for i = 1, BNtotal do if select(8, BNGetFriendInfo(i)) then BNonline = BNonline + 1 end end
  1272. end
  1273. local totalonline = online + BNonline
  1274. local totalfriends = total + BNtotal
  1275. if online > 0 or BNonline > 0 then
  1276. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  1277. GameTooltip:ClearAllPoints()
  1278. GameTooltip:SetPoint(modules.Friends.tip_anchor, modules.Friends.tip_frame, modules.Friends.tip_x, modules.Friends.tip_y)
  1279. GameTooltip:ClearLines()
  1280. GameTooltip:AddDoubleLine(FRIENDS_LIST, format("%s: %s/%s", GUILD_ONLINE_LABEL, totalonline, totalfriends), tthead.r, tthead.g, tthead.b, tthead.r, tthead.g, tthead.b)
  1281. if online > 0 then
  1282. GameTooltip:AddLine(" ")
  1283. GameTooltip:AddLine(WOW_FRIEND)
  1284. for i = 1, total do
  1285. name, level, class, zone, connected, status, note = GetFriendInfo(i)
  1286. if not connected then break end
  1287. if GetRealZoneText() == zone then zone_r, zone_g, zone_b = 0.3, 1.0, 0.3 else zone_r, zone_g, zone_b = 0.65, 0.65, 0.65 end
  1288. for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1289. if GetLocale() ~= "enUS" then
  1290. for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  1291. end
  1292. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
  1293. grouped = (UnitInParty(name) or UnitInRaid(name)) and (GetRealZoneText() == zone and " |cff7fff00*|r" or " |cffff7f00*|r") or ""
  1294. GameTooltip:AddDoubleLine(format("|cff%02x%02x%02x%d|r %s%s%s", levelc.r * 255, levelc.g * 255, levelc.b * 255, level, name, grouped, " "..status), zone, classc.r, classc.g, classc.b, zone_r, zone_g, zone_b)
  1295. if self.altdown and note then GameTooltip:AddLine(" "..note, ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  1296. end
  1297. end
  1298. if BNonline > 0 then
  1299. GameTooltip:AddLine(" ")
  1300. GameTooltip:AddLine(BATTLENET_FRIEND)
  1301. for i = 1, BNtotal do
  1302. _, presenceName, battleTag, _, toonName, toonID, client, isOnline, _, isAFK, isDND = BNGetFriendInfo(i)
  1303. toonName = BNet_GetValidatedCharacterName(toonName, battleTag, client) or ""
  1304. if not isOnline then break end
  1305. if isAFK then
  1306. status = "|cffE7E716"..L_CHAT_AFK.."|r"
  1307. else
  1308. if isDND then
  1309. status = "|cffff0000"..L_CHAT_DND.."|r"
  1310. else
  1311. status = ""
  1312. end
  1313. end
  1314. if client == BNET_CLIENT_WOW then
  1315. local _, toonName, client, realmName, _, _, _, class, _, zoneName, level = BNGetGameAccountInfo(toonID)
  1316. for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1317. if GetLocale() ~= "enUS" then
  1318. for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  1319. end
  1320. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
  1321. if UnitInParty(toonName) or UnitInRaid(toonName) then grouped = " |cffaaaaaa*|r" else grouped = "" end
  1322. GameTooltip:AddDoubleLine(format("%s (|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r%s) |cff%02x%02x%02x%s|r", client, levelc.r * 255, levelc.g * 255, levelc.b * 255, level, classc.r * 255, classc.g * 255, classc.b * 255, toonName, grouped, 255, 0, 0, status), presenceName, 238, 238, 238, 238, 238, 238)
  1323. if self.altdown then
  1324. if GetRealZoneText() == zone then zone_r, zone_g, zone_b = 0.3, 1.0, 0.3 else zone_r, zone_g, zone_b = 0.65, 0.65, 0.65 end
  1325. if GetRealmName() == realmName then realm_r, realm_g, realm_b = 0.3, 1.0, 0.3 else realm_r, realm_g, realm_b = 0.65, 0.65, 0.65 end
  1326. GameTooltip:AddDoubleLine(" "..zoneName, realmName, zone_r, zone_g, zone_b, realm_r, realm_g, realm_b)
  1327. end
  1328. else
  1329. GameTooltip:AddDoubleLine("|cffeeeeee"..client.." ("..toonName..")|r", "|cffeeeeee"..presenceName.."|r")
  1330. end
  1331. end
  1332. end
  1333. GameTooltip:Show()
  1334. else
  1335. HideTT(self)
  1336. end
  1337. end
  1338. })
  1339. end
  1340.  
  1341. ----------------------------------------------------------------------------------------
  1342. -- Bags
  1343. ----------------------------------------------------------------------------------------
  1344. if bags.enabled then
  1345. Inject("Bags", {
  1346. OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN BAG_UPDATE") end,
  1347. OnEvent = function(self)
  1348. local free, total = 0, 0
  1349. for i = 0, NUM_BAG_SLOTS do
  1350. free, total = free + GetContainerNumFreeSlots(i), total + GetContainerNumSlots(i)
  1351. end
  1352. self.text:SetText(format(bags.fmt, free, total))
  1353. end,
  1354. OnClick = function() ToggleAllBags() end,
  1355. OnEnter = function(self)
  1356. local free, total = 0, 0
  1357. for i = 0, NUM_BAG_SLOTS do
  1358. free, total = free + GetContainerNumFreeSlots(i), total + GetContainerNumSlots(i)
  1359. end
  1360. GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1361. GameTooltip:ClearLines()
  1362. if GetBindingKey("TOGGLEBACKPACK") then
  1363. GameTooltip:AddLine(BACKPACK_TOOLTIP.." ("..GetBindingKey("TOGGLEBACKPACK")..")", tthead.r, tthead.g, tthead.b)
  1364. else
  1365. GameTooltip:AddLine(BACKPACK_TOOLTIP, tthead.r, tthead.g, tthead.b)
  1366. end
  1367. GameTooltip:AddLine(" ")
  1368. GameTooltip:AddLine(format(NUM_FREE_SLOTS, free, total), 1, 1, 1)
  1369. GameTooltip:Show()
  1370. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1371. TopPanel:SetAlpha(1)
  1372. end
  1373. end,
  1374. OnLeave = function()
  1375. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1376. TopPanel:SetAlpha(0)
  1377. end
  1378. end,
  1379. })
  1380. end
  1381.  
  1382. ----------------------------------------------------------------------------------------
  1383. -- Talents
  1384. ----------------------------------------------------------------------------------------
  1385. if talents.enabled then
  1386. Inject("Talents", {
  1387. OnLoad = function(self)
  1388. RegEvents(self, "PLAYER_LOGIN PLAYER_TALENT_UPDATE PLAYER_ENTERING_WORLD PLAYER_LEAVING_WORLD")
  1389. end,
  1390. OnEvent = function(self, event, ...)
  1391. if event == "PLAYER_ENTERING_WORLD" then
  1392. self:RegisterEvent("PLAYER_TALENT_UPDATE")
  1393. elseif event == "PLAYER_LEAVING_WORLD" then
  1394. self:UnregisterEvent("PLAYER_TALENT_UPDATE")
  1395. elseif event == "UNIT_SPELLCAST_START" then
  1396. local unit, spell = ...
  1397. if unit == P and (spell == GetSpellInfo(63645) or spell == GetSpellInfo(63644)) then timer = GetTime() end
  1398. else
  1399. if UnitLevel(P) < 10 then
  1400. self.text:SetText(format("%s %s", NO, SPECIALIZATION))
  1401. else
  1402. local active = GetActiveSpecGroup()
  1403. if GetSpecialization(false, false, active) then
  1404. self.text:SetText(select(2, GetSpecializationInfo(GetSpecialization(false, false, active))))
  1405. else
  1406. self.text:SetText(format("%s %s", NO, SPECIALIZATION))
  1407. end
  1408. if self.hovered then self:GetScript("OnEnter")(self) end
  1409. end
  1410. end
  1411. end,
  1412. OnUpdate = function(self)
  1413. if GetNumSpecGroups() > 1 then
  1414. self:SetScript("OnUpdate", nil)
  1415. self:GetScript("OnEvent")(self)
  1416. end
  1417. end,
  1418. OnEnter = function(self)
  1419. self.hovered = true
  1420. if UnitLevel(P) >= 10 then
  1421. GameTooltip:SetOwner(self, talents.tip_anchor, talents.tip_x, talents.tip_y)
  1422. GameTooltip:ClearLines()
  1423. GameTooltip:AddLine(SPECIALIZATION, tthead.r, tthead.g, tthead.b)
  1424. GameTooltip:AddLine(" ")
  1425. for i = 1, GetNumSpecGroups() do
  1426. if GetSpecialization(false, false, i) then
  1427. GameTooltip:AddLine(string.join(" ", string.format("", select(2, GetSpecializationInfo(GetSpecialization(false, false, i)))), (i == GetActiveSpecGroup() and string.join("", "|cff00FF00" , TALENT_ACTIVE_SPEC_STATUS, "|r") or string.join("", "|cffFF0000", FACTION_INACTIVE, "|r"))), 1, 1, 1)
  1428. end
  1429. end
  1430. GameTooltip:Show()
  1431. end
  1432. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1433. TopPanel:SetAlpha(1)
  1434. end
  1435. end,
  1436. OnLeave = function(self)
  1437. self.hovered = false
  1438. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1439. TopPanel:SetAlpha(0)
  1440. end
  1441. end,
  1442. OnClick = function(_, b)
  1443. if b == "RightButton" and GetNumSpecGroups() > 1 then
  1444. SetActiveSpecGroup(3 - GetActiveSpecGroup())
  1445. elseif b == "LeftButton" then
  1446. if not PlayerTalentFrame then
  1447. LoadAddOn("Blizzard_TalentUI")
  1448. end
  1449. if not GlyphFrame then
  1450. LoadAddOn("Blizzard_GlyphUI")
  1451. end
  1452. if T.level >= SHOW_TALENT_LEVEL then
  1453. PlayerTalentFrame_Toggle()
  1454. else
  1455. print("|cffffff00"..format(FEATURE_BECOMES_AVAILABLE_AT_LEVEL, SHOW_TALENT_LEVEL).."|r")
  1456. end
  1457. end
  1458. end
  1459. })
  1460. end
  1461.  
  1462. ----------------------------------------------------------------------------------------
  1463. -- Character Stats
  1464. ----------------------------------------------------------------------------------------
  1465. if stats.enabled then
  1466. local function tags(sub)
  1467. local percent, string = true
  1468. if sub == "power" then
  1469. local value, power
  1470. local Base, PosBuff, NegBuff = UnitAttackPower("player")
  1471. local Effective = Base + PosBuff + NegBuff
  1472. local RangedBase, RangedPosBuff, RangedNegBuff = UnitRangedAttackPower("player")
  1473. local range = RangedBase + RangedPosBuff + RangedNegBuff
  1474. heal = GetSpellBonusHealing()
  1475. spell = GetSpellBonusDamage(7)
  1476. attack = Effective
  1477. if heal > spell then
  1478. power = heal
  1479. else
  1480. power = spell
  1481. end
  1482. if attack > power and T.class ~= "HUNTER" then
  1483. value = attack
  1484. elseif T.class == "HUNTER" then
  1485. value = range
  1486. else
  1487. value = power
  1488. end
  1489. string = value
  1490. elseif sub == "mastery" then
  1491. string = GetMasteryEffect()
  1492. elseif sub == "haste" then
  1493. string = GetHaste()
  1494. elseif sub == "resilience" then
  1495. string, percent = GetCombatRating(16)
  1496. elseif sub == "crit" then
  1497. string = GetCritChance()
  1498. elseif sub == "dodge" then
  1499. string = GetDodgeChance()
  1500. elseif sub == "parry" then
  1501. string = GetParryChance()
  1502. elseif sub == "block" then
  1503. string = GetBlockChance()
  1504. elseif sub == "avoidance" then
  1505. string = GetDodgeChance() + GetParryChance()
  1506. elseif sub == "manaregen" then
  1507. local I5SR = true
  1508. if T.class == "ROGUE" or T.class == "WARRIOR" or T.class == "DEATHKNIGHT" then
  1509. string, percent = "??"
  1510. else
  1511. local base, cast = GetManaRegen()
  1512. string, percent = floor((I5SR and cast or base) * 5)
  1513. end
  1514. elseif sub == "armor" then
  1515. local _, eff = UnitArmor(P)
  1516. string, percent = eff
  1517. elseif sub == "versatility" then
  1518. string = GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_DONE) + GetVersatilityBonus(CR_VERSATILITY_DAMAGE_DONE)
  1519. elseif sub == "leech" then
  1520. string = GetCombatRating(17)
  1521. else
  1522. string, percent = format("[%s]", sub)
  1523. end
  1524. if not percent then return string end
  1525. return format("%.1f", string)
  1526. end
  1527. Inject("Stats", {
  1528. OnLoad = function(self)
  1529. RegEvents(self, "PLAYER_LOGIN UNIT_STATS UNIT_DAMAGE UNIT_RANGEDDAMAGE PLAYER_DAMAGE_DONE_MODS UNIT_ATTACK_SPEED UNIT_ATTACK_POWER UNIT_RANGED_ATTACK_POWER")
  1530. end,
  1531. OnEvent = function(self) self.fired = true end,
  1532. OnUpdate = function(self, u)
  1533. self.elapsed = self.elapsed + u
  1534. if self.fired and self.elapsed > 2.5 then
  1535. self.text:SetText(gsub(stats[format("spec%dfmt", GetSpecialization() and GetSpecialization() or 1)], "%[(%w-)%]", tags))
  1536. self.elapsed, self.fired = 0, false
  1537. end
  1538. end
  1539. })
  1540. end
  1541.  
  1542. ----------------------------------------------------------------------------------------
  1543. -- Experience/Played/Rep
  1544. ----------------------------------------------------------------------------------------
  1545. if experience.enabled then
  1546. local logintime, playedtotal, playedlevel, playedmsg, gained, lastkill, lastquest = GetTime(), 0, 0, 0, 0
  1547. local repname, repcolor, standingname, currep, minrep, maxrep, reppercent
  1548. local mobxp = gsub(COMBATLOG_XPGAIN_FIRSTPERSON, "%%[sd]", "(.*)")
  1549. local questxp = gsub(COMBATLOG_XPGAIN_FIRSTPERSON_UNNAMED, "%%[sd]", "(.*)")
  1550. local artifactXP, xpForNextPoint, numPointsAvailableToSpend, artifactTotalXP, artifactName, artifactPointsSpent = 0, 0, 0, 0
  1551. local function short(num, tt)
  1552. if short or tt then
  1553. num = tonumber(num)
  1554. if num >= 1e6 then
  1555. return gsub(format("%.2f%s", num / 1e6, experience.million or "m"), "%.0", "")
  1556. elseif num >= 1e5 then
  1557. return gsub(format("%.0f%s", num / 1e3, experience.thousand or "k"), "%.0", "")
  1558. elseif num >= 1e3 then
  1559. return gsub(format("%.1f%s", num / 1e3, experience.thousand or "k"), "%.0", "")
  1560. end
  1561. end
  1562. return floor(tonumber(num))
  1563. end
  1564. local function tags(sub,tt)
  1565. local t = experience
  1566. -- exp tags
  1567. return sub == "level" and UnitLevel(P)
  1568. or sub == "curxp" and short(UnitXP(P),tt)
  1569. or sub == "remainingxp" and short(UnitXPMax(P) - UnitXP(P), tt)
  1570. or sub == "totalxp" and short(UnitXPMax(P), tt)
  1571. or sub == "cur%" and floor(UnitXP(P) / UnitXPMax(P) * 100)
  1572. or sub == "remaining%" and 100 - floor(UnitXP(P) / UnitXPMax(P) * 100)
  1573. or sub == "restxp" and short(GetXPExhaustion() or 0,tt)
  1574. or sub == "rest%" and min(150, floor((GetXPExhaustion() or 0) / UnitXPMax(P) * 100))
  1575. or sub == "sessiongained" and short(gained,tt)
  1576. or sub == "sessionrate" and short(gained / (GetTime() - playedmsg) * 3600, tt)
  1577. or sub == "levelrate" and short(UnitXP(P) / (playedlevel + GetTime() - playedmsg) * 3600, tt)
  1578. or sub == "sessionttl" and (gained ~= 0 and fmttime((UnitXPMax(P) - UnitXP(P)) / (gained / (GetTime() - playedmsg)), t) or L_STATS_INF)
  1579. or sub == "levelttl" and (UnitXP(P) ~= 0 and fmttime((UnitXPMax(P) - UnitXP(P)) / (UnitXP(P) / (playedlevel + GetTime() - playedmsg)), t) or L_STATS_INF)
  1580. or sub == "questsleft" and (lastquest and ceil((UnitXPMax(P) - UnitXP(P)) / tonumber(lastquest)) or "??")
  1581. or sub == "killsleft" and (lastkill and ceil((UnitXPMax(P) - UnitXP(P)) / tonumber(lastkill)) or "??")
  1582. -- time played tags
  1583. or sub == "playedtotal" and fmttime(playedtotal + GetTime() - playedmsg, t)
  1584. or sub == "playedlevel" and fmttime(playedlevel + GetTime() - playedmsg, t)
  1585. or sub == "playedsession" and fmttime(GetTime() - logintime,t)
  1586. -- rep tags
  1587. or sub == "repname" and (t.faction_subs[repname] or repname)
  1588. or sub == "repcolor" and "|cff"..repcolor
  1589. or sub == "standing" and standingname
  1590. or sub == "currep" and abs(currep - minrep)
  1591. or sub == "repleft" and abs(maxrep - currep)
  1592. or sub == "maxrep" and abs(maxrep - minrep)
  1593. or sub == "rep%" and (currep ~= 0 and floor(abs(currep - minrep) / abs(maxrep - minrep) * 100) or 0)
  1594. -- artifact tags
  1595. or sub == "curart" and short(artifactXP, tt)
  1596. or sub == "curart%" and floor(artifactXP / xpForNextPoint * 100)
  1597. or sub == "totalart" and short(xpForNextPoint, tt)
  1598. or sub == "remainingart" and short(xpForNextPoint - artifactXP, tt)
  1599. or sub == "remainingart%" and 100 - floor(artifactXP / xpForNextPoint * 100)
  1600. or format("[%s]", sub)
  1601. end
  1602. Inject("Experience", {
  1603. text = {
  1604. string = function(self)
  1605. if conf.ExpMode == "rep" then
  1606. return self:GetText()
  1607. elseif conf.ExpMode == "played" then
  1608. return gsub(experience.played_fmt, "%[([%w%%]-)%]", tags)
  1609. elseif conf.ExpMode == "xp" then
  1610. return gsub(experience[format("xp_%s_fmt", (GetXPExhaustion() or 0) > 0 and "rested" or "normal")], "%[([%w%%]-)%]", tags) or " "
  1611. elseif conf.ExpMode == "art" then
  1612. return self:GetText()
  1613. end
  1614. end
  1615. },
  1616. OnLoad = function(self)
  1617. RegEvents(self, "TIME_PLAYED_MSG PLAYER_LOGOUT PLAYER_LOGIN UPDATE_FACTION CHAT_MSG_COMBAT_XP_GAIN PLAYER_LEVEL_UP ARTIFACT_XP_UPDATE UNIT_INVENTORY_CHANGED")
  1618. -- Filter first time played message
  1619. local ofunc = ChatFrame_DisplayTimePlayed
  1620. function ChatFrame_DisplayTimePlayed() ChatFrame_DisplayTimePlayed = ofunc end
  1621. RequestTimePlayed()
  1622. if not conf.ExpMode or conf.ExpMode == "xp" then
  1623. conf.ExpMode = UnitLevel(P) ~= MAX_PLAYER_LEVEL and "xp" or "played"
  1624. elseif conf.ExpMode == "art" then
  1625. print("Load "..HasArtifactEquipped())
  1626. conf.ExpMode = HasArtifactEquipped() and "art" or "played"
  1627. end
  1628. end,
  1629. OnEvent = function(self, event, ...)
  1630. if event == "CHAT_MSG_COMBAT_XP_GAIN" then
  1631. local msg = ...
  1632. if msg:find(mobxp) then
  1633. _, lastkill = strmatch(msg, mobxp)
  1634. lastkill = strmatch(lastkill, "%d+")
  1635. gained = gained + lastkill
  1636. elseif msg:find(questxp) then
  1637. lastquest = strmatch(msg, questxp)
  1638. lastquest = strmatch(lastquest, "%d+")
  1639. gained = gained + lastquest
  1640. end
  1641. elseif event == "PLAYER_LEVEL_UP" then
  1642. playedlevel, playedmsg = 0, GetTime()
  1643. elseif event == "TIME_PLAYED_MSG" then
  1644. playedtotal, playedlevel = ...
  1645. playedmsg = GetTime()
  1646. elseif (event == "UPDATE_FACTION" or event == "PLAYER_LOGIN") and conf.ExpMode == "rep" then
  1647. local standing
  1648. repname, standing, minrep, maxrep, currep = GetWatchedFactionInfo()
  1649. if not repname then repname = NONE end
  1650. local color = {}
  1651. if standing == 0 then
  1652. color.r, color.g, color.b = GetItemQualityColor(0)
  1653. elseif standing == 7 then
  1654. color.r, color.g, color.b = GetItemQualityColor(3)
  1655. elseif standing == 8 then
  1656. color.r, color.g, color.b = GetItemQualityColor(4)
  1657. else
  1658. color = FACTION_BAR_COLORS[standing]
  1659. end
  1660. standingname = _G[format("FACTION_STANDING_LABEL%s%s", standing, UnitSex(P) == 3 and "_FEMALE" or "")]
  1661. if not standingname then standingname = UNKNOWN end
  1662. repcolor = format("%02x%02x%02x", min(color.r * 255 + 40, 255), min(color.g * 255 + 40, 255), min(color.b * 255 + 40, 255))
  1663. self.text:SetText(gsub(experience.faction_fmt, "%[([%w%%]-)%]", tags))
  1664. elseif event == "ARTIFACT_XP_UPDATE" or event == "UNIT_INVENTORY_CHANGED" or event == "PLAYER_LOGIN" then
  1665. print(event.." "..HasArtifactEquipped())
  1666. if HasArtifactEquipped() then
  1667. _, _, artifactName, _, artifactTotalXP, artifactPointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  1668. numPointsAvailableToSpend, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(artifactPointsSpent, artifactTotalXP)
  1669. if conf.ExpMode == "art" then
  1670. self.text:SetText(gsub(experience.artifact_fmt, "%[([%w%%]-)%]", tags))
  1671. end
  1672. else
  1673. if conf.ExpMode == "art" then
  1674. conf.ExpMode = "played"
  1675. end
  1676. end
  1677. end
  1678. if event == "PLAYER_LOGOUT" or event == "TIME_PLAYED_MSG" then
  1679. conf.Played = floor(playedtotal + GetTime() - playedmsg)
  1680. end
  1681. end,
  1682. OnEnter = function(self)
  1683. self.hovered = true
  1684. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  1685. GameTooltip:ClearAllPoints()
  1686. GameTooltip:SetPoint(modules.Experience.tip_anchor, modules.Experience.tip_frame, modules.Experience.tip_x, modules.Experience.tip_y)
  1687. GameTooltip:ClearLines()
  1688. if conf.ExpMode == "played" then
  1689. GameTooltip:AddLine(TIME_PLAYED_MSG, tthead.r, tthead.g, tthead.b)
  1690. GameTooltip:AddLine(" ")
  1691. GameTooltip:AddDoubleLine(L_STATS_PLAYED_SESSION, tags("playedsession", 1), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1692. GameTooltip:AddDoubleLine(L_STATS_PLAYED_LEVEL, tags("playedlevel", 1), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1693. GameTooltip:AddLine(" ")
  1694. GameTooltip:AddLine(L_STATS_ACC_PLAYED, ttsubh.r, ttsubh.g, ttsubh.b)
  1695. local total = 0
  1696. for realm, t in pairs(SavedStats) do
  1697. for name, conf in pairs(t) do
  1698. if conf.Played then
  1699. local r, g, b, player = 1, 1, 1
  1700. if name == UnitName(P) and realm == GetRealmName() then
  1701. conf.Played, player, r, g, b = floor(playedtotal + GetTime() - playedmsg), true, 0.5, 1, 0.5
  1702. end
  1703. if conf.Played > 3600 or player then -- 1hr threshold displayed
  1704. GameTooltip:AddDoubleLine(format("%s-%s", name, realm), fmttime(conf.Played), r, g, b, 1, 1, 1)
  1705. end
  1706. total = total + conf.Played
  1707. end
  1708. end
  1709. end
  1710. GameTooltip:AddDoubleLine(" ", "------------------", 1, 1, 1, 0.5, 0.5, 0.5)
  1711. GameTooltip:AddDoubleLine(TOTAL, fmttime(total), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1712. elseif conf.ExpMode == "xp" then
  1713. GameTooltip:AddDoubleLine(COMBAT_XP_GAIN, format(LEVEL_GAINED, UnitLevel(P)), tthead.r, tthead.g, tthead.b, tthead.r, tthead.g, tthead.b)
  1714. GameTooltip:AddLine(" ")
  1715. GameTooltip:AddDoubleLine(L_STATS_CURRENT_XP, format("%s/%s (%s%%)", tags"curxp", tags"totalxp", tags"cur%"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1716. GameTooltip:AddDoubleLine(L_STATS_REMAINING_XP, format("%s (%s%%)", tags"remainingxp", tags"remaining%"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1717. if GetXPExhaustion() and GetXPExhaustion() ~= 0 then
  1718. GameTooltip:AddDoubleLine(L_STATS_RESTED_XP, format("%s (%s%%)", tags"restxp", tags"rest%"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1719. end
  1720. GameTooltip:AddLine(" ")
  1721. GameTooltip:AddDoubleLine(L_STATS_SESSION_XP, format("%s/%s (%s)", tags"sessionrate", L_STATS_HR, tags"sessionttl"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1722. GameTooltip:AddDoubleLine(L_STATS_XP_RATE, format("%s/%s (%s)", tags"levelrate", L_STATS_HR, tags"levelttl"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1723. GameTooltip:AddDoubleLine(format(L_STATS_QUESTS_TO, UnitLevel(P) + 1), format("%s:%s %s:%s", L_STATS_QUEST, tags"questsleft", L_STATS_KILLS, tags"killsleft"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1724. GameTooltip:AddLine(" ")
  1725. GameTooltip:AddDoubleLine(L_STATS_PLAYED_SESSION, tags"playedsession", ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1726. GameTooltip:AddDoubleLine(L_STATS_PLAYED_LEVEL, tags"playedlevel", ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1727. GameTooltip:AddDoubleLine(L_STATS_PLAYED_TOTAL, tags"playedtotal", ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1728. elseif conf.ExpMode == "rep" then
  1729. local desc, war, watched
  1730. for i = 1, GetNumFactions() do
  1731. _, desc, _, _, _, _, war, _, _, _, _, watched = GetFactionInfo(i)
  1732. if watched then break end
  1733. end
  1734. GameTooltip:AddLine(repname, tthead.r, tthead.g, tthead.b)
  1735. GameTooltip:AddLine(desc, ttsubh.r, ttsubh.g, ttsubh.b, 1)
  1736. GameTooltip:AddLine(" ")
  1737. GameTooltip:AddDoubleLine(format("%s%s", tags"repcolor", tags"standing"), war and format("|cffff5555%s", AT_WAR))
  1738. GameTooltip:AddDoubleLine(format("%s%% | %s/%s", tags"rep%", tags"currep", tags"maxrep"), -tags"repleft", ttsubh.r, ttsubh.g, ttsubh.b, 1, 0.33, 0.33)
  1739. elseif conf.ExpMode == "art" then
  1740. _, _, artifactName, _, artifactTotalXP, artifactPointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  1741. numPointsAvailableToSpend, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(artifactPointsSpent, artifactTotalXP)
  1742. GameTooltip:AddLine(ARTIFACT_POWER..": "..artifactName, tthead.r, tthead.g, tthead.b)
  1743. GameTooltip:AddLine(" ")
  1744. GameTooltip:AddDoubleLine(L_STATS_CURRENT_XP, format("%s/%s (%s%%)", tags"curart", tags"totalart", tags"curart%"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1745. GameTooltip:AddDoubleLine(L_STATS_REMAINING_XP, format("%s (%s%%)", tags"remainingart", tags"remainingart%"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1746. if numPointsAvailableToSpend and numPointsAvailableToSpend > 0 then
  1747. GameTooltip:AddLine(ARTIFACT_POWER_TOOLTIP_BODY:format(numPointsAvailableToSpend), ttsubh.r, ttsubh.g, ttsubh.b, 1)
  1748. end
  1749. end
  1750. GameTooltip:Show()
  1751. end,
  1752. OnClick = function(self, button)
  1753. if button == "RightButton" then
  1754. conf.ExpMode = conf.ExpMode == "xp" and "played"
  1755. or (conf.ExpMode == "played" and HasArtifactEquipped()) and "art"
  1756. or conf.ExpMode == "played" and "rep"
  1757. or conf.ExpMode == "art" and "rep"
  1758. or (conf.ExpMode == "rep" and UnitLevel(P) ~= MAX_PLAYER_LEVEL) and "xp"
  1759. or conf.ExpMode == "rep" and "played"
  1760. if conf.ExpMode == "rep" then
  1761. self:GetScript("OnEvent")(self,"UPDATE_FACTION")
  1762. else
  1763. self:GetScript("OnUpdate")(self, 5)
  1764. end
  1765. if conf.ExpMode == "art" then
  1766. self:GetScript("OnEvent")(self,"UNIT_INVENTORY_CHANGED")
  1767. end
  1768. self:GetScript("OnEnter")(self)
  1769. elseif button == "LeftButton" and conf.ExpMode == "rep" then
  1770. ToggleCharacter("ReputationFrame")
  1771. elseif button == "LeftButton" and conf.ExpMode == "art" then
  1772. if not ArtifactFrame or not ArtifactFrame:IsShown() then
  1773. ShowUIPanel(SocketInventoryItem(16))
  1774. elseif ArtifactFrame and ArtifactFrame:IsShown() then
  1775. HideUIPanel(ArtifactFrame)
  1776. end
  1777. end
  1778. end
  1779. })
  1780. end
  1781.  
  1782. ----------------------------------------------------------------------------------------
  1783. -- Loot
  1784. ----------------------------------------------------------------------------------------
  1785. if loot.enabled then
  1786. Inject("Loot", {
  1787. OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN CVAR_UPDATE") end,
  1788. OnEvent = function(self)
  1789. if GetCVarBool("AutoLootDefault") then
  1790. self.text:SetText(format(loot.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1791. else
  1792. self.text:SetText(format(loot.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1793. end
  1794. end,
  1795. OnClick = function(self, button)
  1796. if button == "RightButton" or button == "LeftButton" then
  1797. if GetCVarBool("AutoLootDefault") then
  1798. SetCVar("AutoLootDefault", 0)
  1799. self.text:SetText(format(loot.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1800. else
  1801. SetCVar("AutoLootDefault", 1)
  1802. self.text:SetText(format(loot.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1803. end
  1804. end
  1805. end,
  1806. OnEnter = function(self)
  1807. GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1808. GameTooltip:ClearLines()
  1809. GameTooltip:AddLine(AUTO_LOOT_DEFAULT_TEXT, tthead.r, tthead.g, tthead.b)
  1810. GameTooltip:AddLine(" ")
  1811. GameTooltip:AddLine(OPTION_TOOLTIP_AUTO_LOOT_DEFAULT, 1, 1, 1, 1)
  1812. GameTooltip:Show()
  1813. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1814. TopPanel:SetAlpha(1)
  1815. end
  1816. end,
  1817. OnLeave = function()
  1818. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1819. TopPanel:SetAlpha(0)
  1820. end
  1821. end,
  1822. })
  1823. end
  1824.  
  1825. ----------------------------------------------------------------------------------------
  1826. -- Helm
  1827. ----------------------------------------------------------------------------------------
  1828. --BETA if helm.enabled then
  1829. -- Inject("Helm", {
  1830. -- OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN CVAR_UPDATE") end,
  1831. -- OnEvent = function(self)
  1832. -- if ShowingHelm() then
  1833. -- self.text:SetText(format(helm.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1834. -- else
  1835. -- self.text:SetText(format(helm.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1836. -- end
  1837. -- end,
  1838. -- OnClick = function(self, button)
  1839. -- if button == "RightButton" or button == "LeftButton" then
  1840. -- if ShowingHelm() then
  1841. -- ShowHelm(false)
  1842. -- self.text:SetText(format(helm.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1843. -- else
  1844. -- ShowHelm(true)
  1845. -- self.text:SetText(format(helm.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1846. -- end
  1847. -- end
  1848. -- end,
  1849. -- OnEnter = function(self)
  1850. -- GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1851. -- GameTooltip:ClearLines()
  1852. -- GameTooltip:AddLine(SHOW_HELM, tthead.r, tthead.g, tthead.b)
  1853. -- GameTooltip:AddLine(" ")
  1854. -- GameTooltip:AddLine(OPTION_TOOLTIP_SHOW_HELM, 1, 1, 1)
  1855. -- GameTooltip:Show()
  1856. -- if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1857. -- TopPanel:SetAlpha(1)
  1858. -- end
  1859. -- end,
  1860. -- OnLeave = function()
  1861. -- if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1862. -- TopPanel:SetAlpha(0)
  1863. -- end
  1864. -- end,
  1865. -- })
  1866. -- end
  1867.  
  1868. ----------------------------------------------------------------------------------------
  1869. -- Cloak
  1870. ----------------------------------------------------------------------------------------
  1871. --BETA if cloak.enabled then
  1872. -- Inject("Cloak", {
  1873. -- OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN CVAR_UPDATE") end,
  1874. -- OnEvent = function(self)
  1875. -- if ShowingCloak() then
  1876. -- self.text:SetText(format(cloak.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1877. -- else
  1878. -- self.text:SetText(format(cloak.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1879. -- end
  1880. -- end,
  1881. -- OnClick = function(self, button)
  1882. -- if button == "RightButton" or button == "LeftButton" then
  1883. -- if ShowingCloak() then
  1884. -- ShowCloak(false)
  1885. -- self.text:SetText(format(cloak.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1886. -- else
  1887. -- ShowCloak(true)
  1888. -- self.text:SetText(format(cloak.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1889. -- end
  1890. -- end
  1891. -- end,
  1892. -- OnEnter = function(self)
  1893. -- GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1894. -- GameTooltip:ClearLines()
  1895. -- GameTooltip:AddLine(SHOW_CLOAK, tthead.r, tthead.g, tthead.b)
  1896. -- GameTooltip:AddLine(" ")
  1897. -- GameTooltip:AddLine(OPTION_TOOLTIP_SHOW_CLOAK, 1, 1, 1)
  1898. -- GameTooltip:Show()
  1899. -- if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1900. -- TopPanel:SetAlpha(1)
  1901. -- end
  1902. -- end,
  1903. -- OnLeave = function()
  1904. -- if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1905. -- TopPanel:SetAlpha(0)
  1906. -- end
  1907. -- end,
  1908. -- })
  1909. -- end
  1910.  
  1911. ----------------------------------------------------------------------------------------
  1912. -- Nameplates
  1913. ----------------------------------------------------------------------------------------
  1914. if nameplates.enabled then
  1915. Inject("Nameplates", {
  1916. OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN CVAR_UPDATE") end,
  1917. OnEvent = function(self)
  1918. if GetCVar("nameplateMotion") == "0" then
  1919. self.text:SetText(format(nameplates.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1920. else
  1921. self.text:SetText(format(nameplates.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1922. end
  1923. end,
  1924. OnClick = function(self, button)
  1925. if button == "RightButton" or button == "LeftButton" then
  1926. if GetCVar("nameplateMotion") == "0" then
  1927. SetCVar("nameplateMotion", "2")
  1928. self.text:SetText(format(nameplates.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1929. else
  1930. SetCVar("nameplateMotion", "0")
  1931. self.text:SetText(format(nameplates.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1932. end
  1933. end
  1934. end,
  1935. OnEnter = function(self)
  1936. GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1937. GameTooltip:ClearLines()
  1938. GameTooltip:AddLine(UNIT_NAMEPLATES_ALLOW_OVERLAP, tthead.r, tthead.g, tthead.b)
  1939. GameTooltip:AddLine(" ")
  1940. GameTooltip:AddLine(OPTION_TOOLTIP_UNIT_NAMEPLATES_ALLOW_OVERLAP, 1, 1, 1, 1)
  1941. GameTooltip:Show()
  1942. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1943. TopPanel:SetAlpha(1)
  1944. end
  1945. end,
  1946. OnLeave = function()
  1947. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1948. TopPanel:SetAlpha(0)
  1949. end
  1950. end,
  1951. })
  1952. end
  1953.  
  1954. ----------------------------------------------------------------------------------------
  1955. -- Applying modules
  1956. ----------------------------------------------------------------------------------------
  1957. lpanels:CreateLayout("LiteStats", layout)
  1958. lpanels:ApplyLayout(nil, "LiteStats")
  1959.  
  1960. Inject = nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement