Advertisement
Wetxius

Untitled

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