Advertisement
Wetxius

Untitled

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