Advertisement
Wetxius

Untitled

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