Advertisement
Wetxius

Untitled

Oct 5th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 80.71 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.  
  728. local titleName
  729. for i = 1, GetNumSavedInstances() do
  730. local name, _, reset, difficulty, locked, extended, _, isRaid, maxPlayers, _, numEncounters, encounterProgress = GetSavedInstanceInfo(i)
  731. if isRaid and (locked or extended) or maxPlayers == 5 and difficulty == 23 and (locked or extended) then
  732. local tr, tg, tb, diff
  733. if not titleName then
  734. GameTooltip:AddLine(" ")
  735. GameTooltip:AddLine(CALENDAR_FILTER_RAID_LOCKOUTS.." / "..DUNGEONS, ttsubh.r, ttsubh.g, ttsubh.b)
  736. titleName = true
  737. end
  738. if extended then tr, tg, tb = 0.3, 1, 0.3 else tr, tg, tb = 1, 1, 1 end
  739.  
  740. local _, _, isHeroic, _, displayHeroic, displayMythic = GetDifficultyInfo(difficulty)
  741. if displayMythic then
  742. diff = "M"
  743. elseif isHeroic or displayHeroic then
  744. diff = "H"
  745. end
  746.  
  747. if (numEncounters and numEncounters > 0) and (encounterProgress and encounterProgress > 0) then
  748. GameTooltip:AddDoubleLine(format("%s |cffaaaaaa[%s%s] (%s/%s)", name, maxPlayers, diff or "", encounterProgress, numEncounters), fmttime(reset), 1, 1, 1, tr, tg, tb)
  749. else
  750. GameTooltip:AddDoubleLine(format("%s |cffaaaaaa[%s%s]", name, maxPlayers, diff or ""), fmttime(reset), 1, 1, 1, tr, tg, tb)
  751. end
  752. end
  753. end
  754. local addedLine
  755. for i = 1, GetNumSavedWorldBosses() do
  756. local name, _, reset = GetSavedWorldBossInfo(i)
  757. if reset then
  758. if not addedLine then
  759. GameTooltip:AddLine(" ")
  760. GameTooltip:AddLine(RAID_INFO_WORLD_BOSS, ttsubh.r, ttsubh.g, ttsubh.b)
  761. addedLine = true
  762. end
  763. GameTooltip:AddDoubleLine(name, fmttime(reset), 1, 1, 1, 1, 1, 1)
  764. end
  765. end
  766. --BETA if T.level >= 100 then
  767. -- local c = 0
  768. -- for _, q in ipairs({36054, 36055, 36056, 36057, 36058, 36060, 37453, 37452, 37454, 37455, 37456, 37457, 37458, 37459}) do
  769. -- if IsQuestFlaggedCompleted(q) then
  770. -- c = c + 1
  771. -- end
  772. -- end
  773. -- GameTooltip:AddLine(" ")
  774. -- GameTooltip:AddLine(MISCELLANEOUS, ttsubh.r, ttsubh.g, ttsubh.b)
  775. -- GameTooltip:AddDoubleLine(L_STATS_SEALS..": ", c, 1, 1, 1, 1, 1, 1)
  776. -- end
  777. GameTooltip:Show()
  778. end,
  779. OnClick = function(_, b) (b == "RightButton" and ToggleTimeManager or ToggleCalendar)() end
  780. })
  781. end
  782.  
  783. ----------------------------------------------------------------------------------------
  784. -- Location
  785. ----------------------------------------------------------------------------------------
  786. if location.enabled then
  787. Inject("Location", {
  788. OnLoad = function(self)
  789. RegEvents(self, "ZONE_CHANGED ZONE_CHANGED_INDOORS ZONE_CHANGED_NEW_AREA PLAYER_ENTERING_WORLD")
  790. self.sanctuary = {SANCTUARY_TERRITORY, {0.41, 0.8, 0.94}}
  791. self.arena = {FREE_FOR_ALL_TERRITORY, {1, 0.1, 0.1}}
  792. self.friendly = {FACTION_CONTROLLED_TERRITORY, {0.1, 1, 0.1}}
  793. self.hostile = {FACTION_CONTROLLED_TERRITORY, {1, 0.1, 0.1}}
  794. self.contested = {CONTESTED_TERRITORY, {1, 0.7, 0}}
  795. self.combat = {COMBAT_ZONE, {1, 0.1, 0.1}}
  796. self.neutral = {format(FACTION_CONTROLLED_TERRITORY, FACTION_STANDING_LABEL4), {1, 0.93, 0.76}}
  797. end,
  798. OnEvent = function(self)
  799. self.subzone, self.zone, self.pvp = GetSubZoneText(), GetZoneText(), {GetZonePVPInfo()}
  800. if not self.pvp[1] then self.pvp[1] = "neutral" end
  801. local label = (self.subzone ~= "" and location.subzone) and self.subzone or self.zone
  802. local r, g, b = unpack(self.pvp[1] and (self[self.pvp[1]][2] or self.other) or self.other)
  803. self.text:SetText(location.truncate == 0 and label or strtrim(strsub(label, 1, location.truncate)))
  804. self.text:SetTextColor(r, g, b, font.alpha)
  805. end,
  806. OnUpdate = function(self,u)
  807. if self.hovered then
  808. self.elapsed = self.elapsed + u
  809. if self.elapsed > 1 or self.init then
  810. GameTooltip:ClearLines()
  811. GameTooltip:AddLine(format("%s |cffffffff(%s)", self.zone, Coords()), tthead.r, tthead.g, tthead.b, 1, 1, 1)
  812. if self.pvp[1] and not IsInInstance() then
  813. local r, g, b = unpack(self[self.pvp[1]][2])
  814. if self.subzone and self.subzone ~= self.zone then GameTooltip:AddLine(self.subzone, r, g, b) end
  815. GameTooltip:AddLine(format(self[self.pvp[1]][1], self.pvp[3] or ""), r, g, b)
  816. end
  817. GameTooltip:Show()
  818. self.elapsed, self.init = 0, false
  819. end
  820. end
  821. end,
  822. OnEnter = function(self)
  823. self.hovered, self.init = true, true
  824. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  825. GameTooltip:ClearAllPoints()
  826. GameTooltip:SetPoint(modules.Location.tip_anchor, modules.Location.tip_frame, modules.Location.tip_x, modules.Location.tip_y)
  827. end,
  828. OnClick = function(self,button)
  829. if IsShiftKeyDown() then
  830. ChatEdit_ActivateChat(ChatEdit_ChooseBoxForSend())
  831. ChatEdit_ChooseBoxForSend():Insert(format(" (%s: %s)", self.zone, Coords()))
  832. else
  833. ToggleFrame(WorldMapFrame)
  834. end
  835. end
  836. })
  837. end
  838.  
  839. ----------------------------------------------------------------------------------------
  840. -- Coordinates
  841. ----------------------------------------------------------------------------------------
  842. if coords.enabled then
  843. Inject("Coords", {
  844. text = {string = Coords},
  845. OnClick = function(_, button)
  846. if button == "LeftButton" then
  847. ToggleFrame(WorldMapFrame)
  848. else
  849. ChatEdit_ActivateChat(ChatEdit_ChooseBoxForSend())
  850. ChatEdit_ChooseBoxForSend():Insert(format(" (%s: %s)", GetZoneText(), Coords()))
  851. end
  852. end
  853. })
  854. end
  855.  
  856. ----------------------------------------------------------------------------------------
  857. -- Ping
  858. ----------------------------------------------------------------------------------------
  859. if ping.enabled then
  860. Inject("Ping", {
  861. OnLoad = function(self)
  862. self:RegisterEvent("MINIMAP_PING")
  863. self.animGroup = self.text:CreateAnimationGroup()
  864. self.anim = self.animGroup:CreateAnimation("Alpha")
  865. self.animGroup:SetScript("OnFinished", function() self.text:Hide() end)
  866. self.anim:SetFromAlpha(1)
  867. self.anim:SetToAlpha(0)
  868. self.anim:SetDuration(2.8)
  869. self.anim:SetStartDelay(5)
  870. end,
  871. OnEvent = function(self, event, unit)
  872. if unit == P and ping.hide_self then return end
  873. local class = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[select(2, UnitClass(unit))]
  874. self.text:SetText(format(ping.fmt, UnitName(unit)))
  875. if class then
  876. self.text:SetTextColor(class.r, class.g, class.b, 1)
  877. else
  878. self.text:SetTextColor(1, 1, 1, 1)
  879. end
  880. self.animGroup:Stop()
  881. self.text:Show()
  882. self.animGroup:Play()
  883. end
  884. })
  885. end
  886.  
  887. ----------------------------------------------------------------------------------------
  888. -- Guild
  889. ----------------------------------------------------------------------------------------
  890. if guild.enabled then
  891. local guildTable = {}
  892. local function BuildGuildTable()
  893. wipe(guildTable)
  894. for i = 1, GetNumGuildMembers() do
  895. local name, rank, _, level, _, zone, note, officernote, connected, status, class, _, _, mobile = GetGuildRosterInfo(i)
  896. name = Ambiguate(name, "none")
  897. guildTable[i] = {name, rank, level, zone, note, officernote, connected, status, class, mobile}
  898. end
  899. table.sort(guildTable, function(a, b)
  900. if (a and b) then
  901. return a[1] < b[1]
  902. end
  903. end)
  904. end
  905. hooksecurefunc("SortGuildRoster", function(type) CURRENT_GUILD_SORTING = type end)
  906. Inject("Guild", {
  907. text = {
  908. string = function()
  909. if IsInGuild() then
  910. local total, _, online = GetNumGuildMembers()
  911. return format(guild.fmt, online, total)
  912. else return LOOKINGFORGUILD end
  913. end, update = 5
  914. },
  915. OnLoad = function(self)
  916. GuildRoster()
  917. SortGuildRoster(guild.sorting == "note" and "rank" or "note")
  918. SortGuildRoster(guild.sorting)
  919. self:RegisterEvent("GROUP_ROSTER_UPDATE")
  920. self:RegisterEvent("GUILD_ROSTER_UPDATE")
  921. end,
  922. OnEvent = function(self, event)
  923. if self.hovered then
  924. self:GetScript("OnEnter")(self)
  925. end
  926. if IsInGuild() then
  927. BuildGuildTable()
  928. end
  929. end,
  930. OnUpdate = function(self, u)
  931. if IsInGuild() then
  932. AltUpdate(self)
  933. if not self.gmotd then
  934. if self.elapsed > 1 then GuildRoster(); self.elapsed = 0 end
  935. if GetGuildRosterMOTD() ~= "" then self.gmotd = true; if self.hovered then self:GetScript("OnEnter")(self) end end
  936. self.elapsed = self.elapsed + u
  937. end
  938. end
  939. end,
  940. OnClick = function(self, b)
  941. if b == "LeftButton" then
  942. ToggleGuildFrame()
  943. if IsInGuild() then
  944. GuildFrame_TabClicked(GuildFrameTab2)
  945. end
  946. elseif b == "MiddleButton" and IsInGuild() then
  947. local s = CURRENT_GUILD_SORTING
  948. 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"))
  949. self:GetScript("OnEnter")(self)
  950. elseif b == "RightButton" and IsInGuild() then
  951. HideTT(self)
  952.  
  953. local classc, levelc, grouped
  954. local menuCountWhispers = 0
  955. local menuCountInvites = 0
  956.  
  957. menuList[2].menuList = {}
  958. menuList[3].menuList = {}
  959.  
  960. for i = 1, #guildTable do
  961. if (guildTable[i][7] or guildTable[i][10]) and guildTable[i][1] ~= T.name then
  962. local classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[guildTable[i][9]], GetQuestDifficultyColor(guildTable[i][3])
  963. if UnitInParty(guildTable[i][1]) or UnitInRaid(guildTable[i][1]) then
  964. grouped = "|cffaaaaaa*|r"
  965. else
  966. grouped = ""
  967. if not guildTable[i][10] then
  968. menuCountInvites = menuCountInvites + 1
  969. menuList[2].menuList[menuCountInvites] = {
  970. 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"), ""),
  971. arg1 = guildTable[i][1],
  972. notCheckable = true,
  973. func = function(self, arg1)
  974. menuFrame:Hide()
  975. InviteUnit(arg1)
  976. end
  977. }
  978. end
  979. end
  980. menuCountWhispers = menuCountWhispers + 1
  981. menuList[3].menuList[menuCountWhispers] = {
  982. 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),
  983. arg1 = guildTable[i][1],
  984. notCheckable = true,
  985. func = function(self, arg1)
  986. menuFrame:Hide()
  987. SetItemRef("player:"..arg1, ("|Hplayer:%1$s|h[%1$s]|h"):format(arg1), "LeftButton")
  988. end
  989. }
  990. end
  991. end
  992.  
  993. EasyMenu(menuList, menuFrame, self, 0, 0, "MENU")
  994. end
  995. end,
  996. OnEnter = function(self)
  997. if IsInGuild() then
  998. self.hovered = true
  999. GuildRoster()
  1000. local name, rank, level, zone, note, officernote, connected, status, class, isMobile, zone_r, zone_g, zone_b, classc, levelc, grouped
  1001. local total, _, online = GetNumGuildMembers()
  1002. local gmotd = GetGuildRosterMOTD()
  1003. local _, _, standingID, barMin, barMax, barValue = GetGuildFactionInfo()
  1004. local col = T.RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b)
  1005.  
  1006. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  1007. GameTooltip:ClearAllPoints()
  1008. GameTooltip:SetPoint(modules.Guild.tip_anchor, modules.Guild.tip_frame, modules.Guild.tip_x, modules.Guild.tip_y)
  1009. GameTooltip:ClearLines()
  1010. 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)
  1011. if gmotd ~= "" then GameTooltip:AddLine(format("%s |cffaaaaaa- |cffffffff%s", GUILD_MOTD, gmotd), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  1012. if guild.maxguild ~= 0 and online >= 1 then
  1013. GameTooltip:AddLine(" ")
  1014. for i = 1, total do
  1015. if guild.maxguild and i > guild.maxguild then
  1016. 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
  1017. break
  1018. end
  1019. name, rank, _, level, _, zone, note, officernote, connected, status, class, _, _, isMobile = GetGuildRosterInfo(i)
  1020. if (connected or isMobile) and level >= guild.threshold then
  1021. name = Ambiguate(name, "all")
  1022. 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
  1023. if isMobile then zone = "|cffa5a5a5"..REMOTE_CHAT.."|r" end
  1024. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
  1025. grouped = (UnitInParty(name) or UnitInRaid(name)) and (GetRealZoneText() == zone and " |cff7fff00*|r" or " |cffff7f00*|r") or ""
  1026. if self.altdown then
  1027. GameTooltip:AddDoubleLine(format("%s%s |cff999999- |cffffffff%s", grouped, name, rank), zone, classc.r, classc.g, classc.b, zone_r, zone_g, zone_b)
  1028. if note ~= "" then GameTooltip:AddLine(" "..NOTE_COLON.." "..note, ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  1029. if officernote ~= "" and EPGP then
  1030. local ep, gp = EPGP:GetEPGP(name)
  1031. if ep then
  1032. officernote = " EP: "..ep.." GP: "..gp.." PR: "..string.format("%.3f", ep / gp)
  1033. else
  1034. officernote = " O."..NOTE_COLON.." "..officernote
  1035. end
  1036. elseif officernote ~= "" then
  1037. officernote = " O."..NOTE_COLON.." "..officernote
  1038. end
  1039. if officernote ~= "" then GameTooltip:AddLine(officernote, 0.3, 1, 0.3, 1) end
  1040. else
  1041. if status == 1 then
  1042. status = " |cffE7E716"..L_CHAT_AFK.."|r"
  1043. elseif status == 2 then
  1044. status = " |cffff0000"..L_CHAT_DND.."|r"
  1045. else
  1046. status = ""
  1047. end
  1048. 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)
  1049. end
  1050. end
  1051. end
  1052. GameTooltip:AddLine(" ")
  1053. GameTooltip:AddDoubleLine(" ", format("%s %s", L_STATS_SORTING_BY, CURRENT_GUILD_SORTING), 1, 1, 1, ttsubh.r, ttsubh.g, ttsubh.b)
  1054. end
  1055. GameTooltip:Show()
  1056. end
  1057. end
  1058. })
  1059. end
  1060.  
  1061. ----------------------------------------------------------------------------------------
  1062. -- Friends
  1063. ----------------------------------------------------------------------------------------
  1064. if friends.enabled then
  1065. local totalFriendsOnline = 0
  1066. local totalBattleNetOnline = 0
  1067. local BNTable = {}
  1068. local friendTable = {}
  1069. local function BuildFriendTable(total)
  1070. totalFriendsOnline = 0
  1071. wipe(friendTable)
  1072.  
  1073. for i = 1, total do
  1074. local name, level, class, area, connected, status, note = GetFriendInfo(i)
  1075. for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1076. if GetLocale() ~= "enUS" then
  1077. for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  1078. end
  1079. friendTable[i] = {name, level, class, area, connected, status, note}
  1080. if connected then
  1081. totalFriendsOnline = totalFriendsOnline + 1
  1082. end
  1083. end
  1084.  
  1085. table.sort(friendTable, function(a, b)
  1086. if a[1] and b[1] then
  1087. return a[1] < b[1]
  1088. end
  1089. end)
  1090. end
  1091. local function BuildBNTable(total)
  1092. totalBattleNetOnline = 0
  1093. wipe(BNTable)
  1094.  
  1095. for i = 1, total do
  1096. local presenceID, presenceName, battleTag, _, toonName, toonID, client, isOnline, _, isAFK, isDND, _, noteText = BNGetFriendInfo(i)
  1097. local _, _, _, realmName, _, faction, race, class, _, zoneName, level = BNGetGameAccountInfo(toonID or presenceID)
  1098. for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1099. if GetLocale() ~= "enUS" then
  1100. for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  1101. end
  1102. BNTable[i] = {presenceID, presenceName, battleTag, toonName, toonID, client, isOnline, isAFK, isDND, noteText, realmName, faction, race, class, zoneName, level}
  1103. if isOnline then
  1104. totalBattleNetOnline = totalBattleNetOnline + 1
  1105. end
  1106. end
  1107.  
  1108. table.sort(BNTable, function(a, b)
  1109. if a[2] and b[2] and a[3] and b[3] then
  1110. if a[2] == b[2] then return a[3] < b[3] end
  1111. return a[2] < b[2]
  1112. end
  1113. end)
  1114. end
  1115. Inject("Friends", {
  1116. 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,
  1117. OnEvent = function(self, event)
  1118. if event ~= "GROUP_ROSTER_UPDATE" then
  1119. local numBNetTotal, numBNetOnline = BNGetNumFriends()
  1120. local online, total = 0, GetNumFriends()
  1121. for i = 0, total do if select(5, GetFriendInfo(i)) then online = online + 1 end end
  1122. online = online + numBNetOnline
  1123. total = total + numBNetTotal
  1124. self.text:SetText(format(friends.fmt, online, total))
  1125. end
  1126. if self.hovered then self:GetScript("OnEnter")(self) end
  1127. end,
  1128. OnUpdate = AltUpdate,
  1129. OnClick = function(self, b)
  1130. if b == "MiddleButton" then
  1131. ToggleIgnorePanel()
  1132. elseif b == "LeftButton" then
  1133. ToggleFriendsFrame()
  1134. elseif b == "RightButton" then
  1135. HideTT(self)
  1136.  
  1137. local BNTotal = BNGetNumFriends()
  1138. local total = GetNumFriends()
  1139. BuildBNTable(BNTotal)
  1140. BuildFriendTable(total)
  1141.  
  1142. local classc, levelc, grouped
  1143. local menuCountWhispers = 0
  1144. local menuCountInvites = 0
  1145.  
  1146. menuList[2].menuList = {}
  1147. menuList[3].menuList = {}
  1148.  
  1149. if totalFriendsOnline > 0 then
  1150. for i = 1, #friendTable do
  1151. if friendTable[i][5] then
  1152. if UnitInParty(friendTable[i][1]) or UnitInRaid(friendTable[i][1]) then
  1153. grouped = " |cffaaaaaa*|r"
  1154. else
  1155. grouped = ""
  1156. end
  1157.  
  1158. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]], GetQuestDifficultyColor(friendTable[i][2])
  1159. if classc == nil then
  1160. classc = GetQuestDifficultyColor(friendTable[i][2])
  1161. end
  1162.  
  1163. menuCountWhispers = menuCountWhispers + 1
  1164. menuList[3].menuList[menuCountWhispers] = {
  1165. 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),
  1166. arg1 = friendTable[i][1],
  1167. notCheckable = true,
  1168. func = function(self, arg1)
  1169. menuFrame:Hide()
  1170. SetItemRef("player:"..arg1, ("|Hplayer:%1$s|h[%1$s]|h"):format(arg1), "LeftButton")
  1171. end
  1172. }
  1173.  
  1174. if not (UnitInParty(friendTable[i][1]) or UnitInRaid(friendTable[i][1])) then
  1175. menuCountInvites = menuCountInvites + 1
  1176. menuList[2].menuList[menuCountInvites] = {
  1177. 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]),
  1178. arg1 = friendTable[i][1],
  1179. notCheckable = true,
  1180. func = function(self, arg1)
  1181. menuFrame:Hide()
  1182. InviteUnit(arg1)
  1183. end
  1184. }
  1185. end
  1186. end
  1187. end
  1188. end
  1189.  
  1190. if totalBattleNetOnline > 0 then
  1191. for i = 1, #BNTable do
  1192. if BNTable[i][7] then
  1193. if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then
  1194. grouped = " |cffaaaaaa*|r"
  1195. else
  1196. grouped = ""
  1197. end
  1198.  
  1199. menuCountWhispers = menuCountWhispers + 1
  1200. menuList[3].menuList[menuCountWhispers] = {
  1201. text = BNTable[i][2]..grouped,
  1202. arg1 = BNTable[i][2],
  1203. notCheckable = true,
  1204. func = function(self, arg1)
  1205. menuFrame:Hide()
  1206. ChatFrame_SendSmartTell(arg1)
  1207. end
  1208. }
  1209.  
  1210. if BNTable[i][6] == BNET_CLIENT_WOW and UnitFactionGroup("player") == BNTable[i][12] then
  1211. if not (UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4])) then
  1212. menuCountInvites = menuCountInvites + 1
  1213. menuList[2].menuList[menuCountInvites] = {
  1214. text = BNTable[i][2],
  1215. arg1 = BNTable[i][5],
  1216. notCheckable = true,
  1217. func = function(self, arg1)
  1218. menuFrame:Hide()
  1219. BNInviteFriend(arg1)
  1220. end
  1221. }
  1222. end
  1223. end
  1224. end
  1225. end
  1226. end
  1227.  
  1228. EasyMenu(menuList, menuFrame, self, 0, 0, "MENU")
  1229. end
  1230. end,
  1231. OnEnter = function(self)
  1232. ShowFriends()
  1233. self.hovered = true
  1234. local online, total = 0, GetNumFriends()
  1235. local name, level, class, zone, connected, status, note, classc, levelc, zone_r, zone_g, zone_b, grouped
  1236. for i = 0, total do if select(5, GetFriendInfo(i)) then online = online + 1 end end
  1237. local BNonline, BNtotal = 0, BNGetNumFriends()
  1238. local presenceID, presenceName, toonName, toonID, client, isOnline
  1239. if BNtotal > 0 then
  1240. for i = 1, BNtotal do if select(8, BNGetFriendInfo(i)) then BNonline = BNonline + 1 end end
  1241. end
  1242. local totalonline = online + BNonline
  1243. local totalfriends = total + BNtotal
  1244. if online > 0 or BNonline > 0 then
  1245. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  1246. GameTooltip:ClearAllPoints()
  1247. GameTooltip:SetPoint(modules.Friends.tip_anchor, modules.Friends.tip_frame, modules.Friends.tip_x, modules.Friends.tip_y)
  1248. GameTooltip:ClearLines()
  1249. 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)
  1250. if online > 0 then
  1251. GameTooltip:AddLine(" ")
  1252. GameTooltip:AddLine(WOW_FRIEND)
  1253. for i = 1, total do
  1254. name, level, class, zone, connected, status, note = GetFriendInfo(i)
  1255. if not connected then break end
  1256. 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
  1257. for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1258. if GetLocale() ~= "enUS" then
  1259. for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  1260. end
  1261. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
  1262. grouped = (UnitInParty(name) or UnitInRaid(name)) and (GetRealZoneText() == zone and " |cff7fff00*|r" or " |cffff7f00*|r") or ""
  1263. 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)
  1264. if self.altdown and note then GameTooltip:AddLine(" "..note, ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  1265. end
  1266. end
  1267. if BNonline > 0 then
  1268. GameTooltip:AddLine(" ")
  1269. GameTooltip:AddLine(BATTLENET_FRIEND)
  1270. for i = 1, BNtotal do
  1271. _, presenceName, battleTag, _, toonName, toonID, client, isOnline, _, isAFK, isDND = BNGetFriendInfo(i)
  1272. toonName = BNet_GetValidatedCharacterName(toonName, battleTag, client) or ""
  1273. if not isOnline then break end
  1274. if isAFK then
  1275. status = "|cffE7E716"..L_CHAT_AFK.."|r"
  1276. else
  1277. if isDND then
  1278. status = "|cffff0000"..L_CHAT_DND.."|r"
  1279. else
  1280. status = ""
  1281. end
  1282. end
  1283. if client == BNET_CLIENT_WOW then
  1284. local _, toonName, client, realmName, _, _, _, class, _, zoneName, level = BNGetGameAccountInfo(toonID)
  1285. for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1286. if GetLocale() ~= "enUS" then
  1287. for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  1288. end
  1289. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
  1290. if UnitInParty(toonName) or UnitInRaid(toonName) then grouped = " |cffaaaaaa*|r" else grouped = "" end
  1291. 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)
  1292. if self.altdown then
  1293. 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
  1294. 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
  1295. GameTooltip:AddDoubleLine(" "..zoneName, realmName, zone_r, zone_g, zone_b, realm_r, realm_g, realm_b)
  1296. end
  1297. else
  1298. GameTooltip:AddDoubleLine("|cffeeeeee"..client.." ("..toonName..")|r", "|cffeeeeee"..presenceName.."|r")
  1299. end
  1300. end
  1301. end
  1302. GameTooltip:Show()
  1303. else
  1304. HideTT(self)
  1305. end
  1306. end
  1307. })
  1308. end
  1309.  
  1310. ----------------------------------------------------------------------------------------
  1311. -- Bags
  1312. ----------------------------------------------------------------------------------------
  1313. if bags.enabled then
  1314. Inject("Bags", {
  1315. OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN BAG_UPDATE") end,
  1316. OnEvent = function(self)
  1317. local free, total = 0, 0
  1318. for i = 0, NUM_BAG_SLOTS do
  1319. free, total = free + GetContainerNumFreeSlots(i), total + GetContainerNumSlots(i)
  1320. end
  1321. self.text:SetText(format(bags.fmt, free, total))
  1322. end,
  1323. OnClick = function() ToggleAllBags() end,
  1324. OnEnter = function(self)
  1325. local free, total = 0, 0
  1326. for i = 0, NUM_BAG_SLOTS do
  1327. free, total = free + GetContainerNumFreeSlots(i), total + GetContainerNumSlots(i)
  1328. end
  1329. GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1330. GameTooltip:ClearLines()
  1331. if GetBindingKey("TOGGLEBACKPACK") then
  1332. GameTooltip:AddLine(BACKPACK_TOOLTIP.." ("..GetBindingKey("TOGGLEBACKPACK")..")", tthead.r, tthead.g, tthead.b)
  1333. else
  1334. GameTooltip:AddLine(BACKPACK_TOOLTIP, tthead.r, tthead.g, tthead.b)
  1335. end
  1336. GameTooltip:AddLine(" ")
  1337. GameTooltip:AddLine(format(NUM_FREE_SLOTS, free, total), 1, 1, 1)
  1338. GameTooltip:Show()
  1339. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1340. TopPanel:SetAlpha(1)
  1341. end
  1342. end,
  1343. OnLeave = function()
  1344. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1345. TopPanel:SetAlpha(0)
  1346. end
  1347. end,
  1348. })
  1349. end
  1350.  
  1351. ----------------------------------------------------------------------------------------
  1352. -- Talents
  1353. ----------------------------------------------------------------------------------------
  1354. if talents.enabled then
  1355. Inject("Talents", {
  1356. OnLoad = function(self)
  1357. RegEvents(self, "PLAYER_LOGIN PLAYER_TALENT_UPDATE PLAYER_ENTERING_WORLD PLAYER_LEAVING_WORLD")
  1358. end,
  1359. OnEvent = function(self, event, ...)
  1360. if event == "PLAYER_ENTERING_WORLD" then
  1361. self:RegisterEvent("PLAYER_TALENT_UPDATE")
  1362. elseif event == "PLAYER_LEAVING_WORLD" then
  1363. self:UnregisterEvent("PLAYER_TALENT_UPDATE")
  1364. elseif event == "UNIT_SPELLCAST_START" then
  1365. local unit, spell = ...
  1366. if unit == P and (spell == GetSpellInfo(63645) or spell == GetSpellInfo(63644)) then timer = GetTime() end
  1367. else
  1368. if UnitLevel(P) < 10 then
  1369. self.text:SetText(format("%s %s", NO, SPECIALIZATION))
  1370. else
  1371. local active = GetActiveSpecGroup()
  1372. if GetSpecialization(false, false, active) then
  1373. self.text:SetText(select(2, GetSpecializationInfo(GetSpecialization(false, false, active))))
  1374. else
  1375. self.text:SetText(format("%s %s", NO, SPECIALIZATION))
  1376. end
  1377. if self.hovered then self:GetScript("OnEnter")(self) end
  1378. end
  1379. end
  1380. end,
  1381. OnUpdate = function(self)
  1382. if GetNumSpecGroups() > 1 then
  1383. self:SetScript("OnUpdate", nil)
  1384. self:GetScript("OnEvent")(self)
  1385. end
  1386. end,
  1387. OnEnter = function(self)
  1388. self.hovered = true
  1389. if UnitLevel(P) >= 10 then
  1390. GameTooltip:SetOwner(self, talents.tip_anchor, talents.tip_x, talents.tip_y)
  1391. GameTooltip:ClearLines()
  1392. GameTooltip:AddLine(SPECIALIZATION, tthead.r, tthead.g, tthead.b)
  1393. GameTooltip:AddLine(" ")
  1394. for i = 1, GetNumSpecGroups() do
  1395. if GetSpecialization(false, false, i) then
  1396. 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)
  1397. end
  1398. end
  1399. GameTooltip:Show()
  1400. end
  1401. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1402. TopPanel:SetAlpha(1)
  1403. end
  1404. end,
  1405. OnLeave = function(self)
  1406. self.hovered = false
  1407. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1408. TopPanel:SetAlpha(0)
  1409. end
  1410. end,
  1411. OnClick = function(_, b)
  1412. if b == "RightButton" and GetNumSpecGroups() > 1 then
  1413. SetActiveSpecGroup(3 - GetActiveSpecGroup())
  1414. elseif b == "LeftButton" then
  1415. if not PlayerTalentFrame then
  1416. LoadAddOn("Blizzard_TalentUI")
  1417. end
  1418. if not GlyphFrame then
  1419. LoadAddOn("Blizzard_GlyphUI")
  1420. end
  1421. if T.level >= SHOW_TALENT_LEVEL then
  1422. PlayerTalentFrame_Toggle()
  1423. else
  1424. print("|cffffff00"..format(FEATURE_BECOMES_AVAILABLE_AT_LEVEL, SHOW_TALENT_LEVEL).."|r")
  1425. end
  1426. end
  1427. end
  1428. })
  1429. end
  1430.  
  1431. ----------------------------------------------------------------------------------------
  1432. -- Character Stats
  1433. ----------------------------------------------------------------------------------------
  1434. if stats.enabled then
  1435. local function tags(sub)
  1436. local percent, string = true
  1437. if sub == "power" then
  1438. local value, power
  1439. local Base, PosBuff, NegBuff = UnitAttackPower("player")
  1440. local Effective = Base + PosBuff + NegBuff
  1441. local RangedBase, RangedPosBuff, RangedNegBuff = UnitRangedAttackPower("player")
  1442. local range = RangedBase + RangedPosBuff + RangedNegBuff
  1443. heal = GetSpellBonusHealing()
  1444. spell = GetSpellBonusDamage(7)
  1445. attack = Effective
  1446. if heal > spell then
  1447. power = heal
  1448. else
  1449. power = spell
  1450. end
  1451. if attack > power and T.class ~= "HUNTER" then
  1452. value = attack
  1453. elseif T.class == "HUNTER" then
  1454. value = range
  1455. else
  1456. value = power
  1457. end
  1458. string = value
  1459. elseif sub == "mastery" then
  1460. string = GetMasteryEffect()
  1461. elseif sub == "haste" then
  1462. string = GetHaste()
  1463. elseif sub == "resilience" then
  1464. string, percent = GetCombatRating(16)
  1465. elseif sub == "crit" then
  1466. string = GetCritChance()
  1467. elseif sub == "dodge" then
  1468. string = GetDodgeChance()
  1469. elseif sub == "parry" then
  1470. string = GetParryChance()
  1471. elseif sub == "block" then
  1472. string = GetBlockChance()
  1473. elseif sub == "avoidance" then
  1474. string = GetDodgeChance() + GetParryChance()
  1475. elseif sub == "manaregen" then
  1476. local I5SR = true
  1477. if T.class == "ROGUE" or T.class == "WARRIOR" or T.class == "DEATHKNIGHT" then
  1478. string, percent = "??"
  1479. else
  1480. local base, cast = GetManaRegen()
  1481. string, percent = floor((I5SR and cast or base) * 5)
  1482. end
  1483. elseif sub == "armor" then
  1484. local _, eff = UnitArmor(P)
  1485. string, percent = eff
  1486. elseif sub == "versatility" then
  1487. string = GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_DONE) + GetVersatilityBonus(CR_VERSATILITY_DAMAGE_DONE)
  1488. elseif sub == "leech" then
  1489. string = GetCombatRating(17)
  1490. else
  1491. string, percent = format("[%s]", sub)
  1492. end
  1493. if not percent then return string end
  1494. return format("%.1f", string)
  1495. end
  1496. Inject("Stats", {
  1497. OnLoad = function(self)
  1498. RegEvents(self, "PLAYER_LOGIN UNIT_STATS UNIT_DAMAGE UNIT_RANGEDDAMAGE PLAYER_DAMAGE_DONE_MODS UNIT_ATTACK_SPEED UNIT_ATTACK_POWER UNIT_RANGED_ATTACK_POWER")
  1499. end,
  1500. OnEvent = function(self) self.fired = true end,
  1501. OnUpdate = function(self, u)
  1502. self.elapsed = self.elapsed + u
  1503. if self.fired and self.elapsed > 2.5 then
  1504. self.text:SetText(gsub(stats[format("spec%dfmt", GetSpecialization() and GetSpecialization() or 1)], "%[(%w-)%]", tags))
  1505. self.elapsed, self.fired = 0, false
  1506. end
  1507. end
  1508. })
  1509. end
  1510.  
  1511. ----------------------------------------------------------------------------------------
  1512. -- Experience/Played/Rep
  1513. ----------------------------------------------------------------------------------------
  1514. if experience.enabled then
  1515. local logintime, playedtotal, playedlevel, playedmsg, gained, lastkill, lastquest = GetTime(), 0, 0, 0, 0
  1516. local repname, repcolor, standingname, currep, minrep, maxrep, reppercent
  1517. local mobxp = gsub(COMBATLOG_XPGAIN_FIRSTPERSON, "%%[sd]", "(.*)")
  1518. local questxp = gsub(COMBATLOG_XPGAIN_FIRSTPERSON_UNNAMED, "%%[sd]", "(.*)")
  1519. local artifactXP, xpForNextPoint, numPointsAvailableToSpend, artifactTotalXP, artifactName, artifactPointsSpent = 0, 0, 0, 0
  1520. local function short(num, tt)
  1521. if short or tt then
  1522. num = tonumber(num)
  1523. if num >= 1e6 then
  1524. return gsub(format("%.2f%s", num / 1e6, experience.million or "m"), "%.0", "")
  1525. elseif num >= 1e5 then
  1526. return gsub(format("%.0f%s", num / 1e3, experience.thousand or "k"), "%.0", "")
  1527. elseif num >= 1e3 then
  1528. return gsub(format("%.1f%s", num / 1e3, experience.thousand or "k"), "%.0", "")
  1529. end
  1530. end
  1531. return floor(tonumber(num))
  1532. end
  1533. local function tags(sub,tt)
  1534. local t = experience
  1535. -- exp tags
  1536. return sub == "level" and UnitLevel(P)
  1537. or sub == "curxp" and short(UnitXP(P),tt)
  1538. or sub == "remainingxp" and short(UnitXPMax(P) - UnitXP(P), tt)
  1539. or sub == "totalxp" and short(UnitXPMax(P), tt)
  1540. or sub == "cur%" and floor(UnitXP(P) / UnitXPMax(P) * 100)
  1541. or sub == "remaining%" and 100 - floor(UnitXP(P) / UnitXPMax(P) * 100)
  1542. or sub == "restxp" and short(GetXPExhaustion() or 0,tt)
  1543. or sub == "rest%" and min(150, floor((GetXPExhaustion() or 0) / UnitXPMax(P) * 100))
  1544. or sub == "sessiongained" and short(gained,tt)
  1545. or sub == "sessionrate" and short(gained / (GetTime() - playedmsg) * 3600, tt)
  1546. or sub == "levelrate" and short(UnitXP(P) / (playedlevel + GetTime() - playedmsg) * 3600, tt)
  1547. or sub == "sessionttl" and (gained ~= 0 and fmttime((UnitXPMax(P) - UnitXP(P)) / (gained / (GetTime() - playedmsg)), t) or L_STATS_INF)
  1548. or sub == "levelttl" and (UnitXP(P) ~= 0 and fmttime((UnitXPMax(P) - UnitXP(P)) / (UnitXP(P) / (playedlevel + GetTime() - playedmsg)), t) or L_STATS_INF)
  1549. or sub == "questsleft" and (lastquest and ceil((UnitXPMax(P) - UnitXP(P)) / tonumber(lastquest)) or "??")
  1550. or sub == "killsleft" and (lastkill and ceil((UnitXPMax(P) - UnitXP(P)) / tonumber(lastkill)) or "??")
  1551. -- time played tags
  1552. or sub == "playedtotal" and fmttime(playedtotal + GetTime() - playedmsg, t)
  1553. or sub == "playedlevel" and fmttime(playedlevel + GetTime() - playedmsg, t)
  1554. or sub == "playedsession" and fmttime(GetTime() - logintime,t)
  1555. -- rep tags
  1556. or sub == "repname" and (t.faction_subs[repname] or repname)
  1557. or sub == "repcolor" and "|cff"..repcolor
  1558. or sub == "standing" and standingname
  1559. or sub == "currep" and abs(currep - minrep)
  1560. or sub == "repleft" and abs(maxrep - currep)
  1561. or sub == "maxrep" and abs(maxrep - minrep)
  1562. or sub == "rep%" and (currep ~= 0 and floor(abs(currep - minrep) / abs(maxrep - minrep) * 100) or 0)
  1563. -- artifact tags
  1564. or sub == "curart" and short(artifactXP, tt)
  1565. or sub == "curart%" and floor(artifactXP / xpForNextPoint * 100)
  1566. or sub == "totalart" and short(xpForNextPoint, tt)
  1567. or sub == "remainingart" and short(xpForNextPoint - artifactXP, tt)
  1568. or sub == "remainingart%" and 100 - floor(artifactXP / xpForNextPoint * 100)
  1569. or format("[%s]", sub)
  1570. end
  1571. Inject("Experience", {
  1572. text = {
  1573. string = function(self)
  1574. if conf.ExpMode == "rep" then
  1575. return self:GetText()
  1576. elseif conf.ExpMode == "played" then
  1577. return gsub(experience.played_fmt, "%[([%w%%]-)%]", tags)
  1578. elseif conf.ExpMode == "xp" then
  1579. return gsub(experience[format("xp_%s_fmt", (GetXPExhaustion() or 0) > 0 and "rested" or "normal")], "%[([%w%%]-)%]", tags) or " "
  1580. elseif conf.ExpMode == "art" then
  1581. return self:GetText()
  1582. end
  1583. end
  1584. },
  1585. OnLoad = function(self)
  1586. 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")
  1587. -- Filter first time played message
  1588. local ofunc = ChatFrame_DisplayTimePlayed
  1589. function ChatFrame_DisplayTimePlayed() ChatFrame_DisplayTimePlayed = ofunc end
  1590. RequestTimePlayed()
  1591. if not conf.ExpMode or conf.ExpMode == "xp" then
  1592. conf.ExpMode = UnitLevel(P) ~= MAX_PLAYER_LEVEL and "xp" or "played"
  1593. -- elseif conf.ExpMode == "art" then
  1594. -- conf.ExpMode = HasArtifactEquipped() and "art" or "played"
  1595. end
  1596. end,
  1597. OnEvent = function(self, event, ...)
  1598. if event == "CHAT_MSG_COMBAT_XP_GAIN" then
  1599. local msg = ...
  1600. if msg:find(mobxp) then
  1601. _, lastkill = strmatch(msg, mobxp)
  1602. lastkill = strmatch(lastkill, "%d+")
  1603. gained = gained + lastkill
  1604. elseif msg:find(questxp) then
  1605. lastquest = strmatch(msg, questxp)
  1606. lastquest = strmatch(lastquest, "%d+")
  1607. gained = gained + lastquest
  1608. end
  1609. elseif event == "PLAYER_LEVEL_UP" then
  1610. playedlevel, playedmsg = 0, GetTime()
  1611. elseif event == "TIME_PLAYED_MSG" then
  1612. playedtotal, playedlevel = ...
  1613. playedmsg = GetTime()
  1614. elseif (event == "UPDATE_FACTION" or event == "PLAYER_LOGIN") and conf.ExpMode == "rep" then
  1615. local standing
  1616. repname, standing, minrep, maxrep, currep = GetWatchedFactionInfo()
  1617. if not repname then repname = NONE end
  1618. local color = {}
  1619. if standing == 0 then
  1620. color.r, color.g, color.b = GetItemQualityColor(0)
  1621. elseif standing == 7 then
  1622. color.r, color.g, color.b = GetItemQualityColor(3)
  1623. elseif standing == 8 then
  1624. color.r, color.g, color.b = GetItemQualityColor(4)
  1625. else
  1626. color = FACTION_BAR_COLORS[standing]
  1627. end
  1628. standingname = _G[format("FACTION_STANDING_LABEL%s%s", standing, UnitSex(P) == 3 and "_FEMALE" or "")]
  1629. if not standingname then standingname = UNKNOWN end
  1630. repcolor = format("%02x%02x%02x", min(color.r * 255 + 40, 255), min(color.g * 255 + 40, 255), min(color.b * 255 + 40, 255))
  1631. self.text:SetText(gsub(experience.faction_fmt, "%[([%w%%]-)%]", tags))
  1632. end
  1633. if event == "PLAYER_LOGOUT" or event == "TIME_PLAYED_MSG" then
  1634. conf.Played = floor(playedtotal + GetTime() - playedmsg)
  1635. end
  1636. if (event == "ARTIFACT_XP_UPDATE" or event == "PLAYER_LOGIN" or event == "UNIT_INVENTORY_CHANGED") and conf.ExpMode == "art" then
  1637. _, _, artifactName, _, artifactTotalXP, artifactPointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  1638. numPointsAvailableToSpend, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(artifactPointsSpent, artifactTotalXP)
  1639. self.text:SetText(gsub(experience.artifact_fmt, "%[([%w%%]-)%]", tags))
  1640. end
  1641. if event == "UNIT_INVENTORY_CHANGED" and conf.ExpMode == "art" then
  1642. if not HasArtifactEquipped() then
  1643. conf.ExpMode = "played"
  1644. end
  1645. end
  1646. end,
  1647. OnEnter = function(self)
  1648. self.hovered = true
  1649. GameTooltip:SetOwner(self, "ANCHOR_NONE")
  1650. GameTooltip:ClearAllPoints()
  1651. GameTooltip:SetPoint(modules.Experience.tip_anchor, modules.Experience.tip_frame, modules.Experience.tip_x, modules.Experience.tip_y)
  1652. GameTooltip:ClearLines()
  1653. if conf.ExpMode == "played" then
  1654. GameTooltip:AddLine(TIME_PLAYED_MSG, tthead.r, tthead.g, tthead.b)
  1655. GameTooltip:AddLine(" ")
  1656. GameTooltip:AddDoubleLine(L_STATS_PLAYED_SESSION, tags("playedsession", 1), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1657. GameTooltip:AddDoubleLine(L_STATS_PLAYED_LEVEL, tags("playedlevel", 1), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1658. GameTooltip:AddLine(" ")
  1659. GameTooltip:AddLine(L_STATS_ACC_PLAYED, ttsubh.r, ttsubh.g, ttsubh.b)
  1660. local total = 0
  1661. for realm, t in pairs(SavedStats) do
  1662. for name, conf in pairs(t) do
  1663. if conf.Played then
  1664. local r, g, b, player = 1, 1, 1
  1665. if name == UnitName(P) and realm == GetRealmName() then
  1666. conf.Played, player, r, g, b = floor(playedtotal + GetTime() - playedmsg), true, 0.5, 1, 0.5
  1667. end
  1668. if conf.Played > 3600 or player then -- 1hr threshold displayed
  1669. GameTooltip:AddDoubleLine(format("%s-%s", name, realm), fmttime(conf.Played), r, g, b, 1, 1, 1)
  1670. end
  1671. total = total + conf.Played
  1672. end
  1673. end
  1674. end
  1675. GameTooltip:AddDoubleLine(" ", "------------------", 1, 1, 1, 0.5, 0.5, 0.5)
  1676. GameTooltip:AddDoubleLine(TOTAL, fmttime(total), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1677. elseif conf.ExpMode == "xp" then
  1678. GameTooltip:AddDoubleLine(COMBAT_XP_GAIN, format(LEVEL_GAINED, UnitLevel(P)), tthead.r, tthead.g, tthead.b, tthead.r, tthead.g, tthead.b)
  1679. GameTooltip:AddLine(" ")
  1680. 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)
  1681. GameTooltip:AddDoubleLine(L_STATS_REMAINING_XP, format("%s (%s%%)", tags"remainingxp", tags"remaining%"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1682. if GetXPExhaustion() and GetXPExhaustion() ~= 0 then
  1683. GameTooltip:AddDoubleLine(L_STATS_RESTED_XP, format("%s (%s%%)", tags"restxp", tags"rest%"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1684. end
  1685. GameTooltip:AddLine(" ")
  1686. 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)
  1687. 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)
  1688. 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)
  1689. GameTooltip:AddLine(" ")
  1690. GameTooltip:AddDoubleLine(L_STATS_PLAYED_SESSION, tags"playedsession", ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1691. GameTooltip:AddDoubleLine(L_STATS_PLAYED_LEVEL, tags"playedlevel", ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1692. GameTooltip:AddDoubleLine(L_STATS_PLAYED_TOTAL, tags"playedtotal", ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1693. elseif conf.ExpMode == "rep" then
  1694. local desc, war, watched
  1695. for i = 1, GetNumFactions() do
  1696. _, desc, _, _, _, _, war, _, _, _, _, watched = GetFactionInfo(i)
  1697. if watched then break end
  1698. end
  1699. GameTooltip:AddLine(repname, tthead.r, tthead.g, tthead.b)
  1700. GameTooltip:AddLine(desc, ttsubh.r, ttsubh.g, ttsubh.b, 1)
  1701. GameTooltip:AddLine(" ")
  1702. GameTooltip:AddDoubleLine(format("%s%s", tags"repcolor", tags"standing"), war and format("|cffff5555%s", AT_WAR))
  1703. 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)
  1704. elseif conf.ExpMode == "art" then
  1705. _, _, artifactName, _, artifactTotalXP, artifactPointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  1706. numPointsAvailableToSpend, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(artifactPointsSpent, artifactTotalXP)
  1707. GameTooltip:AddLine(ARTIFACT_POWER..": "..artifactName, tthead.r, tthead.g, tthead.b)
  1708. GameTooltip:AddLine(" ")
  1709. 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)
  1710. GameTooltip:AddDoubleLine(L_STATS_REMAINING_XP, format("%s (%s%%)", tags"remainingart", tags"remainingart%"), ttsubh.r, ttsubh.g, ttsubh.b, 1, 1, 1)
  1711. if numPointsAvailableToSpend and numPointsAvailableToSpend > 0 then
  1712. GameTooltip:AddLine(ARTIFACT_POWER_TOOLTIP_BODY:format(numPointsAvailableToSpend), ttsubh.r, ttsubh.g, ttsubh.b, 1)
  1713. end
  1714. end
  1715. GameTooltip:Show()
  1716. end,
  1717. OnClick = function(self, button)
  1718. if button == "RightButton" then
  1719. conf.ExpMode = conf.ExpMode == "xp" and "played"
  1720. or (conf.ExpMode == "played" and HasArtifactEquipped()) and "art"
  1721. or conf.ExpMode == "played" and "rep"
  1722. or conf.ExpMode == "art" and "rep"
  1723. or (conf.ExpMode == "rep" and UnitLevel(P) ~= MAX_PLAYER_LEVEL) and "xp"
  1724. or conf.ExpMode == "rep" and "played"
  1725. if conf.ExpMode == "rep" then
  1726. self:GetScript("OnEvent")(self,"UPDATE_FACTION")
  1727. else
  1728. self:GetScript("OnUpdate")(self, 5)
  1729. end
  1730. if conf.ExpMode == "art" then
  1731. self:GetScript("OnEvent")(self,"UNIT_INVENTORY_CHANGED")
  1732. end
  1733. self:GetScript("OnEnter")(self)
  1734. elseif button == "LeftButton" and conf.ExpMode == "rep" then
  1735. ToggleCharacter("ReputationFrame")
  1736. elseif button == "LeftButton" and conf.ExpMode == "art" then
  1737. if not ArtifactFrame or not ArtifactFrame:IsShown() then
  1738. ShowUIPanel(SocketInventoryItem(16))
  1739. elseif ArtifactFrame and ArtifactFrame:IsShown() then
  1740. HideUIPanel(ArtifactFrame)
  1741. end
  1742. end
  1743. end
  1744. })
  1745. end
  1746.  
  1747. ----------------------------------------------------------------------------------------
  1748. -- Loot
  1749. ----------------------------------------------------------------------------------------
  1750. if loot.enabled then
  1751. Inject("Loot", {
  1752. OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN CVAR_UPDATE") end,
  1753. OnEvent = function(self)
  1754. if GetCVarBool("AutoLootDefault") then
  1755. self.text:SetText(format(loot.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1756. else
  1757. self.text:SetText(format(loot.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1758. end
  1759. end,
  1760. OnClick = function(self, button)
  1761. if button == "RightButton" or button == "LeftButton" then
  1762. if GetCVarBool("AutoLootDefault") then
  1763. SetCVar("AutoLootDefault", 0)
  1764. self.text:SetText(format(loot.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1765. else
  1766. SetCVar("AutoLootDefault", 1)
  1767. self.text:SetText(format(loot.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1768. end
  1769. end
  1770. end,
  1771. OnEnter = function(self)
  1772. GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1773. GameTooltip:ClearLines()
  1774. GameTooltip:AddLine(AUTO_LOOT_DEFAULT_TEXT, tthead.r, tthead.g, tthead.b)
  1775. GameTooltip:AddLine(" ")
  1776. GameTooltip:AddLine(OPTION_TOOLTIP_AUTO_LOOT_DEFAULT, 1, 1, 1, 1)
  1777. GameTooltip:Show()
  1778. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1779. TopPanel:SetAlpha(1)
  1780. end
  1781. end,
  1782. OnLeave = function()
  1783. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1784. TopPanel:SetAlpha(0)
  1785. end
  1786. end,
  1787. })
  1788. end
  1789.  
  1790. ----------------------------------------------------------------------------------------
  1791. -- Helm
  1792. ----------------------------------------------------------------------------------------
  1793. --BETA if helm.enabled then
  1794. -- Inject("Helm", {
  1795. -- OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN CVAR_UPDATE") end,
  1796. -- OnEvent = function(self)
  1797. -- if ShowingHelm() then
  1798. -- self.text:SetText(format(helm.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1799. -- else
  1800. -- self.text:SetText(format(helm.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1801. -- end
  1802. -- end,
  1803. -- OnClick = function(self, button)
  1804. -- if button == "RightButton" or button == "LeftButton" then
  1805. -- if ShowingHelm() then
  1806. -- ShowHelm(false)
  1807. -- self.text:SetText(format(helm.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1808. -- else
  1809. -- ShowHelm(true)
  1810. -- self.text:SetText(format(helm.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1811. -- end
  1812. -- end
  1813. -- end,
  1814. -- OnEnter = function(self)
  1815. -- GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1816. -- GameTooltip:ClearLines()
  1817. -- GameTooltip:AddLine(SHOW_HELM, tthead.r, tthead.g, tthead.b)
  1818. -- GameTooltip:AddLine(" ")
  1819. -- GameTooltip:AddLine(OPTION_TOOLTIP_SHOW_HELM, 1, 1, 1)
  1820. -- GameTooltip:Show()
  1821. -- if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1822. -- TopPanel:SetAlpha(1)
  1823. -- end
  1824. -- end,
  1825. -- OnLeave = function()
  1826. -- if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1827. -- TopPanel:SetAlpha(0)
  1828. -- end
  1829. -- end,
  1830. -- })
  1831. -- end
  1832.  
  1833. ----------------------------------------------------------------------------------------
  1834. -- Cloak
  1835. ----------------------------------------------------------------------------------------
  1836. --BETA if cloak.enabled then
  1837. -- Inject("Cloak", {
  1838. -- OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN CVAR_UPDATE") end,
  1839. -- OnEvent = function(self)
  1840. -- if ShowingCloak() then
  1841. -- self.text:SetText(format(cloak.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1842. -- else
  1843. -- self.text:SetText(format(cloak.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1844. -- end
  1845. -- end,
  1846. -- OnClick = function(self, button)
  1847. -- if button == "RightButton" or button == "LeftButton" then
  1848. -- if ShowingCloak() then
  1849. -- ShowCloak(false)
  1850. -- self.text:SetText(format(cloak.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1851. -- else
  1852. -- ShowCloak(true)
  1853. -- self.text:SetText(format(cloak.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1854. -- end
  1855. -- end
  1856. -- end,
  1857. -- OnEnter = function(self)
  1858. -- GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1859. -- GameTooltip:ClearLines()
  1860. -- GameTooltip:AddLine(SHOW_CLOAK, tthead.r, tthead.g, tthead.b)
  1861. -- GameTooltip:AddLine(" ")
  1862. -- GameTooltip:AddLine(OPTION_TOOLTIP_SHOW_CLOAK, 1, 1, 1)
  1863. -- GameTooltip:Show()
  1864. -- if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1865. -- TopPanel:SetAlpha(1)
  1866. -- end
  1867. -- end,
  1868. -- OnLeave = function()
  1869. -- if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1870. -- TopPanel:SetAlpha(0)
  1871. -- end
  1872. -- end,
  1873. -- })
  1874. -- end
  1875.  
  1876. ----------------------------------------------------------------------------------------
  1877. -- Nameplates
  1878. ----------------------------------------------------------------------------------------
  1879. if nameplates.enabled then
  1880. Inject("Nameplates", {
  1881. OnLoad = function(self) RegEvents(self, "PLAYER_LOGIN CVAR_UPDATE") end,
  1882. OnEvent = function(self)
  1883. if GetCVar("nameplateMotion") == "0" then
  1884. self.text:SetText(format(nameplates.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1885. else
  1886. self.text:SetText(format(nameplates.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1887. end
  1888. end,
  1889. OnClick = function(self, button)
  1890. if button == "RightButton" or button == "LeftButton" then
  1891. if GetCVar("nameplateMotion") == "0" then
  1892. SetCVar("nameplateMotion", "2")
  1893. self.text:SetText(format(nameplates.fmt, "|cffff5555"..strupper(OFF).."|r"))
  1894. else
  1895. SetCVar("nameplateMotion", "0")
  1896. self.text:SetText(format(nameplates.fmt, "|cff55ff55"..L_STATS_ON.."|r"))
  1897. end
  1898. end
  1899. end,
  1900. OnEnter = function(self)
  1901. GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT", -3, 26)
  1902. GameTooltip:ClearLines()
  1903. GameTooltip:AddLine(UNIT_NAMEPLATES_ALLOW_OVERLAP, tthead.r, tthead.g, tthead.b)
  1904. GameTooltip:AddLine(" ")
  1905. GameTooltip:AddLine(OPTION_TOOLTIP_UNIT_NAMEPLATES_ALLOW_OVERLAP, 1, 1, 1, 1)
  1906. GameTooltip:Show()
  1907. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1908. TopPanel:SetAlpha(1)
  1909. end
  1910. end,
  1911. OnLeave = function()
  1912. if C.toppanel.enable == true and C.toppanel.mouseover == true then
  1913. TopPanel:SetAlpha(0)
  1914. end
  1915. end,
  1916. })
  1917. end
  1918.  
  1919. ----------------------------------------------------------------------------------------
  1920. -- Applying modules
  1921. ----------------------------------------------------------------------------------------
  1922. lpanels:CreateLayout("LiteStats", layout)
  1923. lpanels:ApplyLayout(nil, "LiteStats")
  1924.  
  1925. Inject = nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement