Advertisement
Wetxius

Untitled

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