Cokedriver

Datatext

Apr 28th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 97.84 KB | None | 0 0
  1. local MODULE_NAME = "Datatext"
  2. local BasicUI = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
  3. local Datatext = BasicUI:NewModule(MODULE_NAME, "AceEvent-3.0")
  4. local jostle = LibStub:GetLibrary("LibJostle-3.0", true)
  5. local L = setmetatable({}, { __index = function(t,k)
  6. local v = tostring(k)
  7. rawset(t, k, v)
  8. return v
  9. end })
  10.  
  11. ------------------------------------------------------------------------
  12. -- Module Database
  13. ------------------------------------------------------------------------
  14.  
  15. local db
  16. local defaults = {
  17. profile = {
  18. enable = true,
  19. battleground = true, -- enable 3 stats in battleground only that replace stat1,stat2,stat3.
  20. bag = false, -- True = Open Backpack; False = Open All bags
  21.  
  22. -- Color Datatext
  23. customcolor = { r = 1, g = 1, b = 1}, -- Color of Text for Datapanel
  24.  
  25. location = "bottom", -- 3 Choices for panel placement = "top", "bottom", or "shortbar". Shortbar is to match nMainbar shortbar.
  26. armor = "P0", -- show your armor value against the level mob you are currently targeting.
  27. avd = "P0", -- show your current avoidance against the level of the mob your targeting
  28. bags = "P9", -- show space used in bags on panel.
  29. haste = "P0", -- show your haste rating on panels.
  30. system = "P0", -- show total memory and others systems info (FPS/MS) on panel.
  31. guild = "P4", -- show number on guildmate connected on panel.
  32. dur = "P8", -- show your equipment durability on panel.
  33. friends = "P6", -- show number of friends connected.
  34. dps_text = "P0", -- show a dps meter on panel.
  35. hps_text = "P0", -- show a heal meter on panel.
  36. spec = "P5", -- show your current spec on panel.
  37. coords = "P0", -- show your current coords on panel.
  38. pro = "P7", -- shows your professions and tradeskills
  39. stat1 = "P1", -- Stat Based on your Role (Avoidance-Tank, AP-Melee, SP/HP-Caster)
  40. stat2 = "P3", -- Stat Based on your Role (Armor-Tank, Crit-Melee, Crit-Caster)
  41. recount = "P2", -- Stat Based on Recount"s DPS
  42. recountraiddps = false, -- Enables tracking or Recounts Raid DPS
  43. calltoarms = "P0", -- Show Current Call to Arms.
  44. }
  45. }
  46.  
  47. ------------------------------------------------------------------------
  48. -- Local Module Functions
  49. ------------------------------------------------------------------------
  50. -- Variables that point to frames or other objects:
  51. local Datapanel, StatPanelLeft, StatPanelCenter, StatPanelRight, BGPanel
  52. local currentFightDPS
  53. local PLAYER_CLASS = UnitClass("player")
  54. local PLAYER_NAME = UnitName("player")
  55. local PLAYER_REALM = GetRealmName()
  56. local SCREEN_WIDTH = tonumber(string.match(({GetScreenResolutions()})[GetCurrentResolution()], "(%d+)x+%d"))
  57. local TOC_VERSION = select(4, GetBuildInfo())
  58. local GAME_LOCALE = GetLocale()
  59. local classColor
  60.  
  61. local function RGBToHex(r, g, b)
  62. if r > 1 then r = 1 elseif r < 0 then r = 0 end
  63. if g > 1 then g = 1 elseif g < 0 then g = 0 end
  64. if b > 1 then b = 1 elseif b < 0 then b = 0 end
  65. return format("|cff%02x%02x%02x", r*255, g*255, b*255)
  66. end
  67.  
  68. local function HexToRGB(hex)
  69. local rhex, ghex, bhex = strsub(hex, 1, 2), strsub(hex, 3, 4), strsub(hex, 5, 6)
  70. return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
  71. end
  72.  
  73. local function ShortValue(v)
  74. if v >= 1e6 then
  75. return format("%.1fm", v / 1e6):gsub("%.?0+([km])$", "%1")
  76. elseif v >= 1e3 or v <= -1e3 then
  77. return format("%.1fk", v / 1e3):gsub("%.?0+([km])$", "%1")
  78. else
  79. return v
  80. end
  81. end
  82.  
  83. --Check Player's Role
  84.  
  85. local classRoles = {
  86. PALADIN = {
  87. [1] = "Caster",
  88. [2] = "Tank",
  89. [3] = "Melee",
  90. },
  91. PRIEST = "Caster",
  92. WARLOCK = "Caster",
  93. WARRIOR = {
  94. [1] = "Melee",
  95. [2] = "Melee",
  96. [3] = "Tank",
  97. },
  98. HUNTER = "Melee",
  99. SHAMAN = {
  100. [1] = "Caster",
  101. [2] = "Melee",
  102. [3] = "Caster",
  103. },
  104. ROGUE = "Melee",
  105. MAGE = "Caster",
  106. DEATHKNIGHT = {
  107. [1] = "Tank",
  108. [2] = "Melee",
  109. [3] = "Melee",
  110. },
  111. DRUID = {
  112. [1] = "Caster",
  113. [2] = "Melee",
  114. [3] = "Tank",
  115. [4] = "Caster"
  116. },
  117. MONK = {
  118. [1] = "Tank",
  119. [2] = "Caster",
  120. [3] = "Melee",
  121. },
  122. }
  123.  
  124. local _, playerClass = UnitClass("player")
  125. local Role
  126. local function CheckRole()
  127. local talentTree = GetSpecialization()
  128.  
  129. if(type(classRoles[playerClass]) == "string") then
  130. Role = classRoles[playerClass]
  131. elseif(talentTree) then
  132. Role = classRoles[playerClass][talentTree]
  133. end
  134. end
  135.  
  136. local eventHandler = CreateFrame("Frame")
  137. eventHandler:RegisterEvent("PLAYER_ENTERING_WORLD")
  138. eventHandler:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  139. eventHandler:RegisterEvent("PLAYER_TALENT_UPDATE")
  140. eventHandler:RegisterEvent("CHARACTER_POINTS_CHANGED")
  141. eventHandler:SetScript("OnEvent", CheckRole)
  142.  
  143.  
  144. ------------------------------------------------------------------------
  145. -- Module Functions
  146. ------------------------------------------------------------------------
  147.  
  148. function Datatext:SetDataPanel()
  149.  
  150. if jostle then
  151. jostle:Unregister(Datapanel)
  152. if db.location ~= "top" then
  153. Datapanel:SetPoint("BOTTOM", UIParent, 0, 0)
  154. Datapanel:SetWidth(1200)
  155. jostle:RegisterBottom(Datapanel)
  156. else
  157. Datapanel:SetPoint("TOP", UIParent, 0, 0)
  158. Datapanel:SetWidth(SCREEN_WIDTH)
  159. jostle:RegisterTop(Datapanel)
  160.  
  161. end
  162. end
  163. end
  164.  
  165. function Datatext:SetStatPanelLeft()
  166.  
  167. if db.location ~= "top" then
  168. StatPanelLeft:SetPoint("LEFT", Datapanel, 5, 0)
  169. StatPanelLeft:SetHeight(35)
  170. StatPanelLeft:SetWidth(1200 / 3)
  171. StatPanelLeft:SetFrameStrata("MEDIUM")
  172. StatPanelLeft:SetFrameLevel(2)
  173. else
  174. StatPanelLeft:SetPoint("LEFT", Datapanel, 5, 0)
  175. StatPanelLeft:SetHeight(35)
  176. StatPanelLeft:SetWidth(SCREEN_WIDTH / 3)
  177. StatPanelLeft:SetFrameStrata("LOW")
  178. StatPanelLeft:SetFrameLevel(1)
  179. end
  180. end
  181.  
  182. function Datatext:SetStatPanelCenter()
  183.  
  184. if db.location ~= "top" then
  185. StatPanelCenter:SetPoint("CENTER", Datapanel, 0, 0)
  186. StatPanelCenter:SetHeight(35)
  187. StatPanelCenter:SetWidth(1200 / 3)
  188. StatPanelCenter:SetFrameStrata("MEDIUM")
  189. StatPanelCenter:SetFrameLevel(1)
  190. else
  191. StatPanelCenter:SetPoint("CENTER", Datapanel, 0, 0)
  192. StatPanelCenter:SetHeight(35)
  193. StatPanelCenter:SetWidth(SCREEN_WIDTH / 3)
  194. StatPanelCenter:SetFrameStrata("LOW")
  195. StatPanelCenter:SetFrameLevel(1)
  196. end
  197. end
  198.  
  199. function Datatext:SetStatPanelRight()
  200.  
  201. if db.location ~= "top" then
  202. StatPanelRight:SetPoint("RIGHT", Datapanel, -5, 0)
  203. StatPanelRight:SetHeight(35)
  204. StatPanelRight:SetWidth(1200 / 3)
  205. StatPanelRight:SetFrameStrata("MEDIUM")
  206. StatPanelRight:SetFrameLevel(1)
  207. else
  208. StatPanelRight:SetPoint("RIGHT", Datapanel, -5, 0)
  209. StatPanelRight:SetHeight(35)
  210. StatPanelRight:SetWidth(SCREEN_WIDTH / 3)
  211. StatPanelRight:SetFrameStrata("LOW")
  212. StatPanelRight:SetFrameLevel(1)
  213. end
  214. end
  215.  
  216. function Datatext:MoveObjects()
  217.  
  218. if db.location ~= "top" then
  219.  
  220. -- Move the tooltip above the Actionbar
  221. hooksecurefunc('GameTooltip_SetDefaultAnchor', function(self)
  222. self:SetPoint('BOTTOMRIGHT', UIParent, -95, 135)
  223. end)
  224.  
  225. -- Move the Bags above the Actionbar
  226. CONTAINER_WIDTH = 192;
  227. CONTAINER_SPACING = 5;
  228. VISIBLE_CONTAINER_SPACING = 3;
  229. CONTAINER_OFFSET_Y = 70;
  230. CONTAINER_OFFSET_X = 0;
  231.  
  232.  
  233. function UpdateContainerFrameAnchors()
  234. local _, xOffset, yOffset, _, _, _, _;
  235. local containerScale = 1;
  236. screenHeight = GetScreenHeight() / containerScale;
  237. -- Adjust the start anchor for bags depending on the multibars
  238. xOffset = CONTAINER_OFFSET_X / containerScale;
  239. yOffset = CONTAINER_OFFSET_Y / containerScale + 35;
  240. -- freeScreenHeight determines when to start a new column of bags
  241. freeScreenHeight = screenHeight - yOffset;
  242. column = 0;
  243. for index, frameName in ipairs(ContainerFrame1.bags) do
  244. frame = _G[frameName];
  245. frame:SetScale(containerScale);
  246. if ( index == 1 ) then
  247. -- First bag
  248. frame:SetPoint('BOTTOMRIGHT', frame:GetParent(), 'BOTTOMRIGHT', -xOffset, yOffset );
  249. elseif ( freeScreenHeight < frame:GetHeight() ) then
  250. -- Start a new column
  251. column = column + 1;
  252. freeScreenHeight = screenHeight - yOffset;
  253. frame:SetPoint('BOTTOMRIGHT', frame:GetParent(), 'BOTTOMRIGHT', -(column * CONTAINER_WIDTH) - xOffset, yOffset );
  254. else
  255. -- Anchor to the previous bag
  256. frame:SetPoint('BOTTOMRIGHT', ContainerFrame1.bags[index - 1], 'TOPRIGHT', 0, CONTAINER_SPACING);
  257. end
  258. freeScreenHeight = freeScreenHeight - frame:GetHeight() - VISIBLE_CONTAINER_SPACING;
  259. end
  260. end
  261. else
  262. return
  263. end
  264. end
  265.  
  266. function Datatext:PlacePlugin(position, plugin)
  267. local left = StatPanelLeft
  268. local center = StatPanelCenter
  269. local right = StatPanelRight
  270.  
  271. -- Left Panel Data
  272. if position == "P1" then
  273. plugin:SetParent(left)
  274. plugin:SetHeight(left:GetHeight())
  275. plugin:SetPoint('LEFT', left, 30, 0)
  276. plugin:SetPoint('TOP', left)
  277. plugin:SetPoint('BOTTOM', left)
  278. elseif position == "P2" then
  279. plugin:SetParent(left)
  280. plugin:SetHeight(left:GetHeight())
  281. plugin:SetPoint('TOP', left)
  282. plugin:SetPoint('BOTTOM', left)
  283. elseif position == "P3" then
  284. plugin:SetParent(left)
  285. plugin:SetHeight(left:GetHeight())
  286. plugin:SetPoint('RIGHT', left, -30, 0)
  287. plugin:SetPoint('TOP', left)
  288. plugin:SetPoint('BOTTOM', left)
  289.  
  290. -- Center Panel Data
  291. elseif position == "P4" then
  292. plugin:SetParent(center)
  293. plugin:SetHeight(center:GetHeight())
  294. plugin:SetPoint('LEFT', center, 30, 0)
  295. plugin:SetPoint('TOP', center)
  296. plugin:SetPoint('BOTTOM', center)
  297. elseif position == "P5" then
  298. plugin:SetParent(center)
  299. plugin:SetHeight(center:GetHeight())
  300. plugin:SetPoint('TOP', center)
  301. plugin:SetPoint('BOTTOM', center)
  302. elseif position == "P6" then
  303. plugin:SetParent(center)
  304. plugin:SetHeight(center:GetHeight())
  305. plugin:SetPoint('RIGHT', center, -30, 0)
  306. plugin:SetPoint('TOP', center)
  307. plugin:SetPoint('BOTTOM', center)
  308.  
  309. -- Right Panel Data
  310. elseif position == "P7" then
  311. plugin:SetParent(right)
  312. plugin:SetHeight(right:GetHeight())
  313. plugin:SetPoint('LEFT', right, 30, 0)
  314. plugin:SetPoint('TOP', right)
  315. plugin:SetPoint('BOTTOM', right)
  316. elseif position == "P8" then
  317. plugin:SetParent(right)
  318. plugin:SetHeight(right:GetHeight())
  319. plugin:SetPoint('TOP', right)
  320. plugin:SetPoint('BOTTOM', right)
  321. elseif position == "P9" then
  322. plugin:SetParent(right)
  323. plugin:SetHeight(right:GetHeight())
  324. plugin:SetPoint('RIGHT', right, -30, 0)
  325. plugin:SetPoint('TOP', right)
  326. plugin:SetPoint('BOTTOM', right)
  327. elseif position == "P0" then
  328. return
  329. end
  330. end
  331.  
  332. function Datatext:CreateStats()
  333.  
  334. local function DataTextTooltipAnchor(self)
  335. local panel = self:GetParent()
  336. local anchor = 'GameTooltip'
  337. local xoff = 1
  338. local yoff = 3
  339.  
  340.  
  341. for _, panel in pairs ({
  342. StatPanelLeft,
  343. StatPanelCenter,
  344. StatPanelRight,
  345. }) do
  346. if db.top == true then
  347. anchor = 'ANCHOR_BOTTOM'
  348. else
  349. anchor = 'ANCHOR_TOP'
  350. end
  351. end
  352. return anchor, panel, xoff, yoff
  353. end
  354.  
  355. if BasicUI.db.profile.general.classcolor ~= true then
  356. local r, g, b = db.customcolor.r, db.customcolor.g, db.customcolor.b
  357. hexa = ("|cff%.2x%.2x%.2x"):format(r * 255, g * 255, b * 255)
  358. hexb = "|r"
  359. else
  360. hexa = ("|cff%.2x%.2x%.2x"):format(classColor.r * 255, classColor.g * 255, classColor.b * 255)
  361. hexb = "|r"
  362. end
  363.  
  364. ----------------
  365. -- Player Armor
  366. ----------------
  367. if db.armor then
  368. local effectiveArmor
  369.  
  370. local Stat = CreateFrame('Frame', nil, Datapanel)
  371. Stat:EnableMouse(true)
  372. Stat:SetFrameStrata('BACKGROUND')
  373. Stat:SetFrameLevel(3)
  374.  
  375. local Text = Stat:CreateFontString(nil, 'OVERLAY')
  376. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  377. self:PlacePlugin(db.armor, Text)
  378.  
  379. local function Update(self)
  380. effectiveArmor = select(2, UnitArmor("player"))
  381. Text:SetText(hexa.."Armor: "..hexb..(effectiveArmor))
  382. --Setup Armor Tooltip
  383. self:SetAllPoints(Text)
  384. end
  385.  
  386. Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
  387. Stat:RegisterEvent("UNIT_AURA")
  388. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  389. Stat:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
  390. Stat:SetScript("OnEvent", Update)
  391. Stat:SetScript("OnEnter", function(self)
  392. if not InCombatLockdown() then
  393. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  394. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  395. GameTooltip:ClearLines()
  396. GameTooltip:AddLine("Mitigation By Level: ")
  397. local lv = 83
  398. local mitigation = (effectiveArmor/(effectiveArmor+(467.5*lv-22167.5)))
  399. for i = 1, 4 do
  400. local format = string.format
  401. if mitigation > .75 then
  402. mitigation = .75
  403. end
  404. GameTooltip:AddDoubleLine(lv,format("%.2f", mitigation*100) .. "%",1,1,1)
  405. lv = lv - 1
  406. end
  407. if UnitLevel("target") > 0 and UnitLevel("target") < UnitLevel("player") then
  408. if mitigation > .75 then
  409. mitigation = .75
  410. end
  411. GameTooltip:AddDoubleLine(UnitLevel("target"),format("%.2f", mitigation*100) .. "%",1,1,1)
  412. end
  413. GameTooltip:Show()
  414. end
  415. end)
  416. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  417. end
  418.  
  419. --------------------
  420. -- Player Avoidance
  421. --------------------
  422. if db.avd then
  423. local dodge, parry, block, avoidance, targetlv, playerlv, basemisschance, leveldifference
  424. local Stat = CreateFrame('Frame', nil, Datapanel)
  425. Stat:EnableMouse(true)
  426. Stat:SetFrameStrata('BACKGROUND')
  427. Stat:SetFrameLevel(3)
  428.  
  429. local Text = Stat:CreateFontString(nil, 'OVERLAY')
  430. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  431. self:PlacePlugin(db.avd, Text)
  432.  
  433. local targetlv, playerlv
  434.  
  435. local function Update(self)
  436. local format = string.format
  437. targetlv, playerlv = UnitLevel("target"), UnitLevel("player")
  438. local basemisschance, leveldifference, avoidance
  439.  
  440. if targetlv == -1 then
  441. basemisschance = (5 - (3*.2)) --Boss Value
  442. leveldifference = 3
  443. elseif targetlv > playerlv then
  444. basemisschance = (5 - ((targetlv - playerlv)*.2)) --Mobs above player level
  445. leveldifference = (targetlv - playerlv)
  446. elseif targetlv < playerlv and targetlv > 0 then
  447. basemisschance = (5 + ((playerlv - targetlv)*.2)) --Mobs below player level
  448. leveldifference = (targetlv - playerlv)
  449. else
  450. basemisschance = 5 --Sets miss chance of attacker level if no target exists, lv80=5, 81=4.2, 82=3.4, 83=2.6
  451. leveldifference = 0
  452. end
  453.  
  454. if myrace == "NightElf" then
  455. basemisschance = basemisschance + 2
  456. end
  457.  
  458. if leveldifference >= 0 then
  459. dodge = (GetDodgeChance()-leveldifference*.2)
  460. parry = (GetParryChance()-leveldifference*.2)
  461. block = (GetBlockChance()-leveldifference*.2)
  462. avoidance = (dodge+parry+block)
  463. Text:SetText(hexa.."Avd: "..hexb..format("%.2f", avoidance).."|r")
  464. else
  465. dodge = (GetDodgeChance()+abs(leveldifference*.2))
  466. parry = (GetParryChance()+abs(leveldifference*.2))
  467. block = (GetBlockChance()+abs(leveldifference*.2))
  468. avoidance = (dodge+parry+block)
  469. Text:SetText(hexa.."Avd: "..hexb..format("%.2f", avoidance).."|r")
  470. end
  471.  
  472. --Setup Avoidance Tooltip
  473. self:SetAllPoints(Text)
  474. end
  475.  
  476.  
  477. Stat:RegisterEvent("UNIT_AURA")
  478. Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
  479. Stat:RegisterEvent("PLAYER_TARGET_CHANGED")
  480. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  481. Stat:SetScript("OnEvent", Update)
  482. Stat:SetScript("OnEnter", function(self)
  483. if not InCombatLockdown() then
  484. local anchor, yoff = DataTextTooltipAnchor(Text)
  485. GameTooltip:SetOwner(self, anchor, 0, yoff)
  486. GameTooltip:ClearAllPoints()
  487. GameTooltip:ClearLines()
  488. if targetlv > 1 then
  489. GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."lvl".." "..targetlv..")")
  490. elseif targetlv == -1 then
  491. GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."Boss"..")")
  492. else
  493. GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."lvl".." "..targetlv..")")
  494. end
  495. GameTooltip:AddDoubleLine("Dodge",format("%.2f",dodge) .. "%",1,1,1, 1,1,1)
  496. GameTooltip:AddDoubleLine("Parry",format("%.2f",parry) .. "%",1,1,1, 1,1,1)
  497. GameTooltip:AddDoubleLine("Block",format("%.2f",block) .. "%",1,1,1, 1,1,1)
  498. GameTooltip:Show()
  499. end
  500. end)
  501. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  502. end
  503.  
  504. --------
  505. -- Bags
  506. --------
  507.  
  508. if db.bags then
  509. local Stat = CreateFrame('Frame', nil, Datapanel)
  510. Stat:EnableMouse(true)
  511. Stat:SetFrameStrata('BACKGROUND')
  512. Stat:SetFrameLevel(3)
  513.  
  514. local Text = Stat:CreateFontString(nil, 'OVERLAY')
  515. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  516. self:PlacePlugin(db.bags, Text)
  517.  
  518. local Profit = 0
  519. local Spent = 0
  520. local OldMoney = 0
  521. local myPlayerRealm = GetRealmName();
  522.  
  523.  
  524. local function formatMoney(c)
  525. local str = ""
  526. if not c or c < 0 then
  527. return str
  528. end
  529.  
  530. if c >= 10000 then
  531. local g = math.floor(c/10000)
  532. c = c - g*10000
  533. str = str..BreakUpLargeNumbers(g).."|cFFFFD800g|r "
  534. end
  535. if c >= 100 then
  536. local s = math.floor(c/100)
  537. c = c - s*100
  538. str = str..s.."|cFFC7C7C7s|r "
  539. end
  540. if c >= 0 then
  541. str = str..c.."|cFFEEA55Fc|r"
  542. end
  543.  
  544. return str
  545. end
  546.  
  547. local function OnEvent(self, event)
  548. local totalSlots, freeSlots = 0, 0
  549. local itemLink, subtype, isBag
  550. for i = 0,NUM_BAG_SLOTS do
  551. isBag = true
  552. if i > 0 then
  553. itemLink = GetInventoryItemLink('player', ContainerIDToInventoryID(i))
  554. if itemLink then
  555. subtype = select(7, GetItemInfo(itemLink))
  556. if (subtype == 'Mining Bag') or (subtype == 'Gem Bag') or (subtype == 'Engineering Bag') or (subtype == 'Enchanting Bag') or (subtype == 'Herb Bag') or (subtype == 'Inscription Bag') or (subtype == 'Leatherworking Bag') or (subtype == 'Fishing Bag')then
  557. isBag = false
  558. end
  559. end
  560. end
  561. if isBag then
  562. totalSlots = totalSlots + GetContainerNumSlots(i)
  563. freeSlots = freeSlots + GetContainerNumFreeSlots(i)
  564. end
  565. Text:SetText(hexa.."Bags: "..hexb.. freeSlots.. '/' ..totalSlots)
  566. if freeSlots < 6 then
  567. Text:SetTextColor(1,0,0)
  568. elseif freeSlots < 10 then
  569. Text:SetTextColor(1,0,0)
  570. elseif freeSlots > 10 then
  571. Text:SetTextColor(1,1,1)
  572. end
  573. self:SetAllPoints(Text)
  574.  
  575. end
  576. if event == "PLAYER_ENTERING_WORLD" then
  577. OldMoney = GetMoney()
  578. end
  579.  
  580. local NewMoney = GetMoney()
  581. local Change = NewMoney-OldMoney -- Positive if we gain money
  582.  
  583. if OldMoney>NewMoney then -- Lost Money
  584. Spent = Spent - Change
  585. else -- Gained Money
  586. Profit = Profit + Change
  587. end
  588.  
  589. self:SetAllPoints(Text)
  590.  
  591. local myPlayerName = UnitName("player")
  592. if not BasicDB then BasicDB = {} end
  593. if not BasicDB.gold then BasicDB.gold = {} end
  594. if not BasicDB.gold[myPlayerRealm] then BasicDB.gold[myPlayerRealm]={} end
  595. BasicDB.gold[myPlayerRealm][myPlayerName] = GetMoney()
  596.  
  597. OldMoney = NewMoney
  598.  
  599. end
  600.  
  601. Stat:RegisterEvent("PLAYER_MONEY")
  602. Stat:RegisterEvent("SEND_MAIL_MONEY_CHANGED")
  603. Stat:RegisterEvent("SEND_MAIL_COD_CHANGED")
  604. Stat:RegisterEvent("PLAYER_TRADE_MONEY")
  605. Stat:RegisterEvent("TRADE_MONEY_CHANGED")
  606. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  607. Stat:RegisterEvent("BAG_UPDATE")
  608.  
  609. Stat:SetScript('OnMouseDown',
  610. function()
  611. if db.bag ~= true then
  612. ToggleAllBags()
  613. else
  614. ToggleBag(0)
  615. end
  616. end
  617. )
  618. Stat:SetScript('OnEvent', OnEvent)
  619. Stat:SetScript("OnEnter", function(self)
  620. if not InCombatLockdown() then
  621. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  622. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  623. GameTooltip:ClearLines()
  624. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Gold")
  625. GameTooltip:AddLine' '
  626. GameTooltip:AddLine("This Session: ")
  627. GameTooltip:AddDoubleLine("Earned:", formatMoney(Profit), 1, 1, 1, 1, 1, 1)
  628. GameTooltip:AddDoubleLine("Spent:", formatMoney(Spent), 1, 1, 1, 1, 1, 1)
  629. if Profit < Spent then
  630. GameTooltip:AddDoubleLine("Deficit:", formatMoney(Profit-Spent), 1, 0, 0, 1, 1, 1)
  631. elseif (Profit-Spent)>0 then
  632. GameTooltip:AddDoubleLine("Profit:", formatMoney(Profit-Spent), 0, 1, 0, 1, 1, 1)
  633. end
  634. GameTooltip:AddDoubleLine("Total:", formatMoney(OldMoney), 1, 1, 1, 1, 1, 1)
  635. GameTooltip:AddLine' '
  636.  
  637. local totalGold = 0
  638. GameTooltip:AddLine("Character's: ")
  639. local thisRealmList = BasicDB.gold[myPlayerRealm];
  640. for k,v in pairs(thisRealmList) do
  641. GameTooltip:AddDoubleLine(k, formatMoney(v), 1, 1, 1, 1, 1, 1)
  642. totalGold=totalGold+v;
  643. end
  644. GameTooltip:AddLine' '
  645. GameTooltip:AddLine("Server:")
  646. GameTooltip:AddDoubleLine("Total: ", formatMoney(totalGold), 1, 1, 1, 1, 1, 1)
  647.  
  648. for i = 1, GetNumWatchedTokens() do
  649. local name, count, extraCurrencyType, icon, itemID = GetBackpackCurrencyInfo(i)
  650. if name and i == 1 then
  651. GameTooltip:AddLine(" ")
  652. GameTooltip:AddLine(CURRENCY..":")
  653. end
  654. local r, g, b = 1,1,1
  655. if itemID then r, g, b = GetItemQualityColor(select(3, GetItemInfo(itemID))) end
  656. if name and count then GameTooltip:AddDoubleLine(name, count, r, g, b, 1, 1, 1) end
  657. end
  658. GameTooltip:AddLine' '
  659. GameTooltip:AddLine("|cffeda55fClick|r to Open Bags")
  660. GameTooltip:Show()
  661. end
  662. end)
  663.  
  664. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  665. -- reset gold data
  666. local function RESETGOLD()
  667. local myPlayerRealm = GetRealmName();
  668. local myPlayerName = UnitName("player");
  669.  
  670. BasicDB.gold = {}
  671. BasicDB.gold[myPlayerRealm]={}
  672. BasicDB.gold[myPlayerRealm][myPlayerName] = GetMoney();
  673. end
  674. SLASH_RESETGOLD1 = "/resetgold"
  675. SlashCmdList["RESETGOLD"] = RESETGOLD
  676.  
  677. end
  678.  
  679. ----------------
  680. -- Battleground
  681. ----------------
  682. if db.battleground == true then
  683.  
  684. --Map IDs
  685. local WSG = 443
  686. local TP = 626
  687. local AV = 401
  688. local SOTA = 512
  689. local IOC = 540
  690. local EOTS = 482
  691. local TBFG = 736
  692. local AB = 461
  693.  
  694. local bgframe = BGPanel
  695. bgframe:SetScript('OnEnter', function(self)
  696. local numScores = GetNumBattlefieldScores()
  697. for i=1, numScores do
  698. local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange = GetBattlefieldScore(i)
  699. if ( name ) then
  700. if ( name == UnitName('player') ) then
  701. GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 0, 4)
  702. GameTooltip:ClearLines()
  703. GameTooltip:SetPoint('BOTTOM', self, 'TOP', 0, 1)
  704. GameTooltip:ClearLines()
  705. GameTooltip:AddLine("Stats for : "..hexa..name..hexb)
  706. GameTooltip:AddLine' '
  707. GameTooltip:AddDoubleLine("Killing Blows:", killingBlows,1,1,1)
  708. GameTooltip:AddDoubleLine("Honorable Kills:", honorableKills,1,1,1)
  709. GameTooltip:AddDoubleLine("Deaths:", deaths,1,1,1)
  710. GameTooltip:AddDoubleLine("Honor Gained:", format('%d', honorGained),1,1,1)
  711. GameTooltip:AddDoubleLine("Damage Done:", damageDone,1,1,1)
  712. GameTooltip:AddDoubleLine("Healing Done:", healingDone,1,1,1)
  713. --Add extra statistics to watch based on what BG you are in.
  714. if curmapid == WSG or curmapid == TP then
  715. GameTooltip:AddDoubleLine("Flags Captured:",GetBattlefieldStatData(i, 1),1,1,1)
  716. GameTooltip:AddDoubleLine("Flags Returned:",GetBattlefieldStatData(i, 2),1,1,1)
  717. elseif curmapid == EOTS then
  718. GameTooltip:AddDoubleLine("Flags Captured:",GetBattlefieldStatData(i, 1),1,1,1)
  719. elseif curmapid == AV then
  720. GameTooltip:AddDoubleLine("Graveyards Assaulted:",GetBattlefieldStatData(i, 1),1,1,1)
  721. GameTooltip:AddDoubleLine("Graveyards Defended:",GetBattlefieldStatData(i, 2),1,1,1)
  722. GameTooltip:AddDoubleLine("Towers Assaulted:",GetBattlefieldStatData(i, 3),1,1,1)
  723. GameTooltip:AddDoubleLine("Towers Defended:",GetBattlefieldStatData(i, 4),1,1,1)
  724. elseif curmapid == SOTA then
  725. GameTooltip:AddDoubleLine("Demolishers Destroyed:",GetBattlefieldStatData(i, 1),1,1,1)
  726. GameTooltip:AddDoubleLine("Gates Destroyed:",GetBattlefieldStatData(i, 2),1,1,1)
  727. elseif curmapid == IOC or curmapid == TBFG or curmapid == AB then
  728. GameTooltip:AddDoubleLine("Bases Assaulted:",GetBattlefieldStatData(i, 1),1,1,1)
  729. GameTooltip:AddDoubleLine("Bases Defended:",GetBattlefieldStatData(i, 2),1,1,1)
  730. end
  731. GameTooltip:Show()
  732. end
  733. end
  734. end
  735. end)
  736. bgframe:SetScript('OnLeave', function(self) GameTooltip:Hide() end)
  737.  
  738. local Stat = CreateFrame('Frame', nil, Datapanel)
  739. Stat:EnableMouse(true)
  740.  
  741. local Text1 = BGPanel:CreateFontString(nil, 'OVERLAY')
  742. Text1:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  743. Text1:SetPoint('LEFT', BGPanel, 30, 0)
  744. Text1:SetHeight(Datapanel:GetHeight())
  745.  
  746. local Text2 = BGPanel:CreateFontString(nil, 'OVERLAY')
  747. Text2:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  748. Text2:SetPoint('CENTER', BGPanel, 0, 0)
  749. Text2:SetHeight(Datapanel:GetHeight())
  750.  
  751. local Text3 = BGPanel:CreateFontString(nil, 'OVERLAY')
  752. Text3:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  753. Text3:SetPoint('RIGHT', BGPanel, -30, 0)
  754. Text3:SetHeight(Datapanel:GetHeight())
  755.  
  756. local int = 2
  757. local function Update(self, t)
  758. int = int - t
  759. if int < 0 then
  760. local dmgtxt
  761. RequestBattlefieldScoreData()
  762. local numScores = GetNumBattlefieldScores()
  763. for i=1, numScores do
  764. local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange = GetBattlefieldScore(i)
  765. if healingDone > damageDone then
  766. dmgtxt = ("Healing : "..hexa..healingDone..hexb)
  767. else
  768. dmgtxt = ("Damage : "..hexa..damageDone..hexb)
  769. end
  770. if ( name ) then
  771. if ( name == PLAYER_NAME ) then
  772. Text2:SetText("Honor : "..hexa..format('%d', honorGained)..hexb)
  773. Text1:SetText(dmgtxt)
  774. Text3:SetText("Killing Blows : "..hexa..killingBlows..hexb)
  775. end
  776. end
  777. end
  778. int = 0
  779. end
  780. end
  781.  
  782. --hide text when not in an bg
  783. local function OnEvent(self, event)
  784. if event == 'PLAYER_ENTERING_WORLD' then
  785. local inInstance, instanceType = IsInInstance()
  786. if inInstance and (instanceType == 'pvp') then
  787. bgframe:Show()
  788. StatPanelLeft:Hide()
  789. else
  790. Text1:SetText('')
  791. Text2:SetText('')
  792. Text3:SetText('')
  793. bgframe:Hide()
  794. StatPanelLeft:Show()
  795. end
  796. end
  797. end
  798.  
  799. Stat:RegisterEvent('PLAYER_ENTERING_WORLD')
  800. Stat:SetScript('OnEvent', OnEvent)
  801. Stat:SetScript('OnUpdate', Update)
  802. Update(Stat, 10)
  803. end
  804.  
  805. ----------------
  806. -- Call To Arms
  807. ----------------
  808. if db.calltoarms then
  809. local Stat = CreateFrame('Frame', nil, Datapanel)
  810. Stat:EnableMouse(true)
  811. Stat:SetFrameStrata("MEDIUM")
  812. Stat:SetFrameLevel(3)
  813.  
  814. local Text = Stat:CreateFontString(nil, "OVERLAY")
  815. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  816. self:PlacePlugin(db.calltoarms, Text)
  817.  
  818. local function MakeIconString(tank, healer, damage)
  819. local str = ""
  820. if tank then
  821. str = str..'T'
  822. end
  823. if healer then
  824. str = str..', H'
  825. end
  826. if damage then
  827. str = str..', D'
  828. end
  829.  
  830. return str
  831. end
  832.  
  833. local function MakeString(tank, healer, damage)
  834. local str = ""
  835. if tank then
  836. str = str..'Tank'
  837. end
  838. if healer then
  839. str = str..', Healer'
  840. end
  841. if damage then
  842. str = str..', DPS'
  843. end
  844.  
  845. return str
  846. end
  847.  
  848. local function OnEvent(self, event, ...)
  849. local tankReward = false
  850. local healerReward = false
  851. local dpsReward = false
  852. local unavailable = true
  853. for i=1, GetNumRandomDungeons() do
  854. local id, name = GetLFGRandomDungeonInfo(i)
  855. for x = 1,LFG_ROLE_NUM_SHORTAGE_TYPES do
  856. local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
  857. if eligible then unavailable = false end
  858. if eligible and forTank and itemCount > 0 then tankReward = true end
  859. if eligible and forHealer and itemCount > 0 then healerReward = true end
  860. if eligible and forDamage and itemCount > 0 then dpsReward = true end
  861. end
  862. end
  863.  
  864. if unavailable then
  865. Text:SetText(QUEUE_TIME_UNAVAILABLE)
  866. else
  867. Text:SetText(hexa..'C to A'..hexb.." : "..MakeIconString(tankReward, healerReward, dpsReward).." ")
  868. end
  869.  
  870. self:SetAllPoints(Text)
  871. end
  872.  
  873. local function OnEnter(self)
  874. if InCombatLockdown() then return end
  875.  
  876. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  877. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  878. GameTooltip:ClearLines()
  879. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Call to Arms")
  880. GameTooltip:AddLine(' ')
  881.  
  882. local allUnavailable = true
  883. local numCTA = 0
  884. for i=1, GetNumRandomDungeons() do
  885. local id, name = GetLFGRandomDungeonInfo(i)
  886. local tankReward = false
  887. local healerReward = false
  888. local dpsReward = false
  889. local unavailable = true
  890. for x=1, LFG_ROLE_NUM_SHORTAGE_TYPES do
  891. local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
  892. if eligible then unavailable = false end
  893. if eligible and forTank and itemCount > 0 then tankReward = true end
  894. if eligible and forHealer and itemCount > 0 then healerReward = true end
  895. if eligible and forDamage and itemCount > 0 then dpsReward = true end
  896. end
  897. if not unavailable then
  898. allUnavailable = false
  899. local rolesString = MakeString(tankReward, healerReward, dpsReward)
  900. if rolesString ~= "" then
  901. GameTooltip:AddDoubleLine(name.." : ", rolesString..' ', 1, 1, 1)
  902. end
  903. if tankReward or healerReward or dpsReward then numCTA = numCTA + 1 end
  904. end
  905. end
  906.  
  907. if allUnavailable then
  908. GameTooltip:AddLine("Could not get Call To Arms information.")
  909. elseif numCTA == 0 then
  910. GameTooltip:AddLine("Could not get Call To Arms information.")
  911. end
  912. GameTooltip:AddLine' '
  913. GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Dungeon Finder")
  914. GameTooltip:AddLine("|cffeda55fRight Click|r to Open PvP Finder")
  915. GameTooltip:Show()
  916. end
  917.  
  918. Stat:RegisterEvent("LFG_UPDATE_RANDOM_INFO")
  919. Stat:RegisterEvent("PLAYER_LOGIN")
  920. Stat:SetScript("OnEvent", OnEvent)
  921. Stat:SetScript("OnMouseDown", function(self, btn)
  922. if btn == "LeftButton" then
  923. ToggleLFDParentFrame(1)
  924. elseif btn == "RightButton" then
  925. TogglePVPUI(1)
  926. end
  927. end)
  928. Stat:SetScript("OnEnter", OnEnter)
  929. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  930. end
  931.  
  932. ---------------
  933. -- Coordinates
  934. ---------------
  935. if db.coords then
  936. local Stat = CreateFrame('Frame', nil, Datapanel)
  937. Stat:EnableMouse(true)
  938. Stat:SetFrameStrata('BACKGROUND')
  939. Stat:SetFrameLevel(3)
  940.  
  941. local Text = Stat:CreateFontString(nil, "OVERLAY")
  942. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  943. self:PlacePlugin(db.coords, Text)
  944.  
  945. local function Update(self)
  946. local px,py=GetPlayerMapPosition("player")
  947. Text:SetText(format(hexa.."Loc: "..hexb.."%i , %i",px*100,py*100))
  948. end
  949.  
  950. Stat:SetScript("OnUpdate", Update)
  951. Update(Stat, 10)
  952. end
  953.  
  954. ---------------------
  955. -- Damage Per Second
  956. ---------------------
  957. if db.dps_text then
  958. local events = {SWING_DAMAGE = true, RANGE_DAMAGE = true, SPELL_DAMAGE = true, SPELL_PERIODIC_DAMAGE = true, DAMAGE_SHIELD = true, DAMAGE_SPLIT = true, SPELL_EXTRA_ATTACKS = true}
  959. local DPS_FEED = CreateFrame('Frame', nil, Datapanel)
  960. local player_id = UnitGUID('player')
  961. local dmg_total, last_dmg_amount = 0, 0
  962. local cmbt_time = 0
  963.  
  964. local pet_id = UnitGUID('pet')
  965.  
  966. local dText = DPS_FEED:CreateFontString(nil, 'OVERLAY')
  967. dText:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  968. dText:SetText("DPS: ", '0')
  969.  
  970. self:PlacePlugin(db.dps_text, dText)
  971.  
  972. DPS_FEED:EnableMouse(true)
  973. DPS_FEED:SetFrameStrata('BACKGROUND')
  974. DPS_FEED:SetFrameLevel(3)
  975. DPS_FEED:SetHeight(20)
  976. DPS_FEED:SetWidth(100)
  977. DPS_FEED:SetAllPoints(dText)
  978.  
  979. DPS_FEED:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end)
  980. DPS_FEED:RegisterEvent('PLAYER_LOGIN')
  981.  
  982. DPS_FEED:SetScript('OnUpdate', function(self, elap)
  983. if UnitAffectingCombat('player') then
  984. cmbt_time = cmbt_time + elap
  985. end
  986.  
  987. dText:SetText(getDPS())
  988. end)
  989.  
  990. function DPS_FEED:PLAYER_LOGIN()
  991. DPS_FEED:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  992. DPS_FEED:RegisterEvent('PLAYER_REGEN_ENABLED')
  993. DPS_FEED:RegisterEvent('PLAYER_REGEN_DISABLED')
  994. DPS_FEED:RegisterEvent('UNIT_PET')
  995. player_id = UnitGUID('player')
  996. DPS_FEED:UnregisterEvent('PLAYER_LOGIN')
  997. end
  998.  
  999. function DPS_FEED:UNIT_PET(unit)
  1000. if unit == 'player' then
  1001. pet_id = UnitGUID('pet')
  1002. end
  1003. end
  1004.  
  1005. -- handler for the combat log. used http://www.wowwiki.com/API_COMBAT_LOG_EVENT for api
  1006. function DPS_FEED:COMBAT_LOG_EVENT_UNFILTERED(...)
  1007. -- filter for events we only care about. i.e heals
  1008. if not events[select(2, ...)] then return end
  1009.  
  1010. -- only use events from the player
  1011. local id = select(4, ...)
  1012.  
  1013. if id == player_id or id == pet_id then
  1014. if select(2, ...) == "SWING_DAMAGE" then
  1015. if TOC_VERSION < 40200 then
  1016. last_dmg_amount = select(10, ...)
  1017. else
  1018. last_dmg_amount = select(12, ...)
  1019. end
  1020. else
  1021. if TOC_VERSION < 40200 then
  1022. last_dmg_amount = select(13, ...)
  1023. else
  1024. last_dmg_amount = select(15, ...)
  1025. end
  1026. end
  1027. dmg_total = dmg_total + last_dmg_amount
  1028. end
  1029. end
  1030.  
  1031. function getDPS()
  1032. if (dmg_total == 0) then
  1033. return (hexa.."DPS"..hexb..' 0')
  1034. else
  1035. return string.format(hexa.."DPS: "..hexb..'%.1f ', (dmg_total or 0) / (cmbt_time or 1))
  1036. end
  1037. end
  1038.  
  1039. function DPS_FEED:PLAYER_REGEN_ENABLED()
  1040. dText:SetText(getDPS())
  1041. end
  1042.  
  1043. function DPS_FEED:PLAYER_REGEN_DISABLED()
  1044. cmbt_time = 0
  1045. dmg_total = 0
  1046. last_dmg_amount = 0
  1047. end
  1048.  
  1049. DPS_FEED:SetScript('OnMouseDown', function (self, button, down)
  1050. cmbt_time = 0
  1051. dmg_total = 0
  1052. last_dmg_amount = 0
  1053. end)
  1054. end
  1055.  
  1056. --------------
  1057. -- Durability
  1058. --------------
  1059. if db.dur then
  1060.  
  1061. Slots = {
  1062. [1] = {1, "Head", 1000},
  1063. [2] = {3, "Shoulder", 1000},
  1064. [3] = {5, "Chest", 1000},
  1065. [4] = {6, "Waist", 1000},
  1066. [5] = {9, "Wrist", 1000},
  1067. [6] = {10, "Hands", 1000},
  1068. [7] = {7, "Legs", 1000},
  1069. [8] = {8, "Feet", 1000},
  1070. [9] = {16, "Main Hand", 1000},
  1071. [10] = {17, "Off Hand", 1000},
  1072. [11] = {18, "Ranged", 1000}
  1073. }
  1074.  
  1075.  
  1076. local Stat = CreateFrame('Frame', nil, Datapanel)
  1077. Stat:EnableMouse(true)
  1078. Stat:SetFrameStrata("MEDIUM")
  1079. Stat:SetFrameLevel(3)
  1080.  
  1081. local Text = Stat:CreateFontString(nil, "OVERLAY")
  1082. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  1083. self:PlacePlugin(db.dur, Text)
  1084.  
  1085. local function OnEvent(self)
  1086. local Total = 0
  1087. local current, max
  1088.  
  1089. for i = 1, 11 do
  1090. if GetInventoryItemLink("player", Slots[i][1]) ~= nil then
  1091. current, max = GetInventoryItemDurability(Slots[i][1])
  1092. if current then
  1093. Slots[i][3] = current/max
  1094. Total = Total + 1
  1095. end
  1096. end
  1097. end
  1098. table.sort(Slots, function(a, b) return a[3] < b[3] end)
  1099.  
  1100. if Total > 0 then
  1101. Text:SetText(hexa.."Armor: "..hexb..floor(Slots[1][3]*100).."% |r")
  1102. else
  1103. Text:SetText(hexa.."Armor: "..hexb.."100% |r")
  1104. end
  1105. -- Setup Durability Tooltip
  1106. self:SetAllPoints(Text)
  1107. Total = 0
  1108. end
  1109.  
  1110. Stat:RegisterEvent("UPDATE_INVENTORY_DURABILITY")
  1111. Stat:RegisterEvent("MERCHANT_SHOW")
  1112. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  1113. Stat:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
  1114. Stat:SetScript("OnEvent", OnEvent)
  1115. Stat:SetScript("OnEnter", function(self)
  1116. if not InCombatLockdown() then
  1117. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1118. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1119. GameTooltip:ClearLines()
  1120. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Durability")
  1121. GameTooltip:AddLine' '
  1122. for i = 1, 11 do
  1123. if Slots[i][3] ~= 1000 then
  1124. local green, red
  1125. green = Slots[i][3]*2
  1126. red = 1 - green
  1127. GameTooltip:AddDoubleLine(Slots[i][2], floor(Slots[i][3]*100).."%",1 ,1 , 1, red + 1, green, 0)
  1128. end
  1129. end
  1130. GameTooltip:AddLine(" ")
  1131. GameTooltip:AddLine("|cffeda55fClick|r to Show Character Panel")
  1132. GameTooltip:Show()
  1133. end
  1134. end)
  1135. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  1136.  
  1137. end
  1138.  
  1139. -----------
  1140. -- FRIEND
  1141. -----------
  1142.  
  1143. if db.friends then
  1144.  
  1145.  
  1146. local _, _, _, broadcastText = BNGetInfo();
  1147.  
  1148. StaticPopupDialogs["SET_BN_BROADCAST"] = {
  1149. preferredIndex = STATICPOPUP_NUMDIALOGS,
  1150. text = BN_BROADCAST_TOOLTIP,
  1151. button1 = ACCEPT,
  1152. button2 = CANCEL,
  1153. hasEditBox = 1,
  1154. editBoxWidth = 350,
  1155. maxLetters = 127,
  1156. OnAccept = function(self)
  1157. BNSetCustomMessage(self.editBox:GetText())
  1158. end,
  1159. OnShow = function(self)
  1160. self.editBox:SetText(broadcastText)
  1161. self.editBox:SetFocus()
  1162. end,
  1163. OnHide = ChatEdit_FocusActiveWindow,
  1164. EditBoxOnEnterPressed = function(self)
  1165. BNSetCustomMessage(self:GetText())
  1166. self:GetParent():Hide()
  1167. end,
  1168. EditBoxOnEscapePressed = function(self)
  1169. self:GetParent():Hide()
  1170. end,
  1171. timeout = 0,
  1172. exclusive = 1,
  1173. whileDead = 1,
  1174. hideOnEscape = 1
  1175. }
  1176.  
  1177. local Stat = CreateFrame('Frame', nil, Datapanel)
  1178. Stat:EnableMouse(true)
  1179. Stat:SetFrameStrata("MEDIUM")
  1180. Stat:SetFrameLevel(3)
  1181.  
  1182. local Text = Stat:CreateFontString(nil, "OVERLAY")
  1183. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  1184. self:PlacePlugin(db.friends, Text)
  1185.  
  1186. local menuFrame = CreateFrame("Frame", "FriendRightClickMenu", UIParent, "UIDropDownMenuTemplate")
  1187. local menuList = {
  1188. { text = OPTIONS_MENU, isTitle = true,notCheckable=true},
  1189. { text = INVITE, hasArrow = true,notCheckable=true, },
  1190. { text = CHAT_MSG_WHISPER_INFORM, hasArrow = true,notCheckable=true, },
  1191. { text = PLAYER_STATUS, hasArrow = true, notCheckable=true,
  1192. menuList = {
  1193. { text = "|cff2BC226"..AVAILABLE.."|r", notCheckable=true, func = function() if IsChatAFK() then SendChatMessage("", "AFK") elseif IsChatDND() then SendChatMessage("", "DND") end end },
  1194. { text = "|cffE7E716"..DND.."|r", notCheckable=true, func = function() if not IsChatDND() then SendChatMessage("", "DND") end end },
  1195. { text = "|cffFF0000"..AFK.."|r", notCheckable=true, func = function() if not IsChatAFK() then SendChatMessage("", "AFK") end end },
  1196. },
  1197. },
  1198. { text = BN_BROADCAST_TOOLTIP, notCheckable=true, func = function() StaticPopup_Show("SET_BN_BROADCAST") end },
  1199. }
  1200.  
  1201. local function GetTableIndex(table, fieldIndex, value)
  1202. for k,v in ipairs(table) do
  1203. if v[fieldIndex] == value then return k end
  1204. end
  1205. return -1
  1206. end
  1207.  
  1208. local function inviteClick(self, arg1, arg2, checked)
  1209. menuFrame:Hide()
  1210. if type(arg1) ~= 'number' then
  1211. InviteUnit(arg1)
  1212. else
  1213. BNInviteFriend(arg1);
  1214. end
  1215. end
  1216.  
  1217. local function whisperClick(self,name,bnet)
  1218. menuFrame:Hide()
  1219. if bnet then
  1220. ChatFrame_SendSmartTell(name)
  1221. else
  1222. SetItemRef( "player:"..name, ("|Hplayer:%1$s|h[%1$s]|h"):format(name), "LeftButton" )
  1223. end
  1224. end
  1225.  
  1226.  
  1227. local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r"
  1228. local clientLevelNameString = "%s (|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r%s) |cff%02x%02x%02x%s|r"
  1229. local levelNameClassString = "|cff%02x%02x%02x%d|r %s%s%s"
  1230. local worldOfWarcraftString = "World of Warcraft"
  1231. local battleNetString = "Battle.NET"
  1232. local wowString = "WoW"
  1233. local totalOnlineString = "Online: " .. "%s/%s"
  1234. local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
  1235. local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
  1236. local displayString = string.join("", hexa.."%s "..hexb, "|cffffffff", "%d|r")
  1237. local statusTable = { "|cffff0000[AFK]|r", "|cffff0000[DND]|r", "" }
  1238. local groupedTable = { "|cffaaaaaa*|r", "" }
  1239. local friendTable, BNTable = {}, {}
  1240. local totalOnline, BNTotalOnline = 0, 0
  1241.  
  1242. local function BuildFriendTable(total)
  1243. totalOnline = 0
  1244. wipe(friendTable)
  1245. local name, level, class, area, connected, status, note
  1246. for i = 1, total do
  1247. name, level, class, area, connected, status, note = GetFriendInfo(i)
  1248. for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1249.  
  1250. if status == "<"..AFK..">" then
  1251. status = "|cffff0000[AFK]|r"
  1252. elseif status == "<"..DND..">" then
  1253. status = "|cffff0000[DND]|r"
  1254. end
  1255.  
  1256. friendTable[i] = { name, level, class, area, connected, status, note }
  1257. if connected then totalOnline = totalOnline + 1 end
  1258. end
  1259. end
  1260.  
  1261. local function UpdateFriendTable(total)
  1262. totalOnline = 0
  1263. local name, level, class, area, connected, status, note
  1264. for i = 1, #friendTable do
  1265. name, level, class, area, connected, status, note = GetFriendInfo(i)
  1266. for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1267.  
  1268. -- get the correct index in our table
  1269. local index = GetTableIndex(friendTable, 1, name)
  1270. -- we cannot find a friend in our table, so rebuild it
  1271. if index == -1 then
  1272. BuildFriendTable(total)
  1273. break
  1274. end
  1275. -- update on-line status for all members
  1276. friendTable[index][5] = connected
  1277. -- update information only for on-line members
  1278. if connected then
  1279. friendTable[index][2] = level
  1280. friendTable[index][3] = class
  1281. friendTable[index][4] = area
  1282. friendTable[index][6] = status
  1283. friendTable[index][7] = note
  1284. totalOnline = totalOnline + 1
  1285. end
  1286. end
  1287. end
  1288.  
  1289. local function BuildBNTable(total)
  1290. BNTotalOnline = 0
  1291. wipe(BNTable)
  1292.  
  1293. for i = 1, total do
  1294. local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i)
  1295. local hasFocus, _, _, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetToonInfo(presenceID)
  1296.  
  1297. for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1298.  
  1299. BNTable[i] = { presenceID, presenceName, battleTag, toonName, toonID, client, isOnline, isAFK, isDND, noteText, realmName, faction, race, class, zoneName, level }
  1300. if isOnline then BNTotalOnline = BNTotalOnline + 1 end
  1301. end
  1302. end
  1303.  
  1304. local function UpdateBNTable(total)
  1305. BNTotalOnline = 0
  1306. for i = 1, #BNTable do
  1307. -- get guild roster information
  1308. local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i)
  1309. local hasFocus, _, _, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetToonInfo(presenceID)
  1310.  
  1311. for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  1312.  
  1313. -- get the correct index in our table
  1314. local index = GetTableIndex(BNTable, 1, presenceID)
  1315. -- we cannot find a BN member in our table, so rebuild it
  1316. if index == -1 then
  1317. BuildBNTable(total)
  1318. return
  1319. end
  1320. -- update on-line status for all members
  1321. BNTable[index][7] = isOnline
  1322. -- update information only for on-line members
  1323. if isOnline then
  1324. BNTable[index][2] = presenceName
  1325. BNTable[index][3] = battleTag
  1326. BNTable[index][4] = toonName
  1327. BNTable[index][5] = toonID
  1328. BNTable[index][6] = client
  1329. BNTable[index][8] = isAFK
  1330. BNTable[index][9] = isDND
  1331. BNTable[index][10] = noteText
  1332. BNTable[index][11] = realmName
  1333. BNTable[index][12] = faction
  1334. BNTable[index][13] = race
  1335. BNTable[index][14] = class
  1336. BNTable[index][15] = zoneName
  1337. BNTable[index][16] = level
  1338.  
  1339. BNTotalOnline = BNTotalOnline + 1
  1340. end
  1341. end
  1342. end
  1343.  
  1344. Stat:SetScript("OnMouseUp", function(self, btn)
  1345. if btn ~= "RightButton" then return end
  1346.  
  1347. GameTooltip:Hide()
  1348.  
  1349. local menuCountWhispers = 0
  1350. local menuCountInvites = 0
  1351. local classc, levelc
  1352.  
  1353. menuList[2].menuList = {}
  1354. menuList[3].menuList = {}
  1355.  
  1356. if totalOnline > 0 then
  1357. for i = 1, #friendTable do
  1358. if (friendTable[i][5]) then
  1359. menuCountInvites = menuCountInvites + 1
  1360. menuCountWhispers = menuCountWhispers + 1
  1361.  
  1362. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]], GetQuestDifficultyColor(friendTable[i][2])
  1363. if classc == nil then classc = GetQuestDifficultyColor(friendTable[i][2]) end
  1364.  
  1365. menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],classc.r*255,classc.g*255,classc.b*255,friendTable[i][1]), arg1 = friendTable[i][1],notCheckable=true, func = inviteClick}
  1366. menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],classc.r*255,classc.g*255,classc.b*255,friendTable[i][1]), arg1 = friendTable[i][1],notCheckable=true, func = whisperClick}
  1367. end
  1368. end
  1369. end
  1370.  
  1371. if BNTotalOnline > 0 then
  1372. local realID, grouped
  1373. for i = 1, #BNTable do
  1374. if (BNTable[i][7]) then
  1375. realID = BNTable[i][2]
  1376. menuCountWhispers = menuCountWhispers + 1
  1377. menuList[3].menuList[menuCountWhispers] = {text = realID, arg1 = realID, arg2 = true, notCheckable=true, func = whisperClick}
  1378.  
  1379. if BNTable[i][6] == wowString and UnitFactionGroup("player") == BNTable[i][12] then
  1380. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[BNTable[i][14]], GetQuestDifficultyColor(90)
  1381. if classc == nil then classc = GetQuestDifficultyColor(90) end
  1382.  
  1383. if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then grouped = 1 else grouped = 2 end
  1384. menuCountInvites = menuCountInvites + 1
  1385. menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,BNTable[i][16],classc.r*255,classc.g*255,classc.b*255,BNTable[i][4]), arg1 = BNTable[i][5],notCheckable=true, func = inviteClick}
  1386. end
  1387. end
  1388. end
  1389. end
  1390.  
  1391. EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
  1392. end)
  1393.  
  1394. local function Update(self, event)
  1395. if event == "BN_FRIEND_INFO_CHANGED" or "BN_FRIEND_ACCOUNT_ONLINE" or "BN_FRIEND_ACCOUNT_OFFLINE" or "BN_TOON_NAME_UPDATED"
  1396. or "BN_FRIEND_TOON_ONLINE" or "BN_FRIEND_TOON_OFFLINE" or "PLAYER_ENTERING_WORLD" then
  1397. local BNTotal = BNGetNumFriends()
  1398. if BNTotal == #BNTable then
  1399. UpdateBNTable(BNTotal)
  1400. else
  1401. BuildBNTable(BNTotal)
  1402. end
  1403. end
  1404.  
  1405. if event == "FRIENDLIST_UPDATE" or "PLAYER_ENTERING_WORLD" then
  1406. local total = GetNumFriends()
  1407. if total == #friendTable then
  1408. UpdateFriendTable(total)
  1409. else
  1410. BuildFriendTable(total)
  1411. end
  1412. end
  1413.  
  1414. Text:SetFormattedText(displayString, "Friends:", totalOnline + BNTotalOnline)
  1415. self:SetAllPoints(Text)
  1416. end
  1417.  
  1418. Stat:SetScript("OnMouseDown", function(self, btn) if btn == "LeftButton" then ToggleFriendsFrame() end end)
  1419. Stat:SetScript("OnEnter", function(self)
  1420. if InCombatLockdown() then return end
  1421.  
  1422. local totalonline = totalOnline + BNTotalOnline
  1423. local totalfriends = #friendTable + #BNTable
  1424. local zonec, classc, levelc, realmc, grouped
  1425. if totalonline > 0 then
  1426. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1427. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1428. GameTooltip:ClearLines()
  1429. GameTooltip:AddDoubleLine(hexa..PLAYER_NAME.."'s"..hexb.." Friends", format(totalOnlineString, totalonline, totalfriends))
  1430. if totalOnline > 0 then
  1431. GameTooltip:AddLine(' ')
  1432. GameTooltip:AddLine(worldOfWarcraftString)
  1433. for i = 1, #friendTable do
  1434. if friendTable[i][5] then
  1435. if GetRealZoneText() == friendTable[i][4] then zonec = activezone else zonec = inactivezone end
  1436. classc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]]
  1437. if classc == nil then classc = GetQuestDifficultyColor(friendTable[i][2]) end
  1438.  
  1439. if friendTable[i][2] ~= '' then
  1440. levelc = GetQuestDifficultyColor(friendTable[i][2])
  1441. else
  1442. levelc = RAID_CLASS_COLORS["PRIEST"]
  1443. classc = RAID_CLASS_COLORS["PRIEST"]
  1444. end
  1445.  
  1446. if UnitInParty(friendTable[i][1]) or UnitInRaid(friendTable[i][1]) then grouped = 1 else grouped = 2 end
  1447. GameTooltip:AddDoubleLine(format(levelNameClassString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],friendTable[i][1],groupedTable[grouped]," "..friendTable[i][6]),friendTable[i][4],classc.r,classc.g,classc.b,zonec.r,zonec.g,zonec.b)
  1448. end
  1449. end
  1450. end
  1451. if BNTotalOnline > 0 then
  1452. GameTooltip:AddLine(' ')
  1453. GameTooltip:AddLine(battleNetString)
  1454.  
  1455. local status = 0
  1456. for i = 1, #BNTable do
  1457. if BNTable[i][7] then
  1458. if BNTable[i][6] == wowString then
  1459. if (BNTable[i][8] == true) then status = 1 elseif (BNTable[i][9] == true) then status = 2 else status = 3 end
  1460.  
  1461. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[BNTable[i][14]], GetQuestDifficultyColor(90)
  1462. if classc == nil then classc = GetQuestDifficultyColor(90) end
  1463.  
  1464. if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then grouped = 1 else grouped = 2 end
  1465. GameTooltip:AddDoubleLine(format(clientLevelNameString, BNTable[i][6],levelc.r*255,levelc.g*255,levelc.b*255,BNTable[i][16],classc.r*255,classc.g*255,classc.b*255,BNTable[i][4],groupedTable[grouped], 255, 0, 0, statusTable[status]),BNTable[i][2],238,238,238,238,238,238)
  1466. if IsShiftKeyDown() then
  1467. if GetRealZoneText() == BNTable[i][15] then zonec = activezone else zonec = inactivezone end
  1468. if GetRealmName() == BNTable[i][11] then realmc = activezone else realmc = inactivezone end
  1469. GameTooltip:AddDoubleLine(" "..BNTable[i][15], BNTable[i][11], zonec.r, zonec.g, zonec.b, realmc.r, realmc.g, realmc.b)
  1470. end
  1471. else
  1472. GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][6].." ("..BNTable[i][4]..")|r", "|cffeeeeee"..BNTable[i][2].."|r")
  1473. end
  1474. end
  1475. end
  1476. end
  1477. GameTooltip:Show()
  1478. else
  1479. GameTooltip:Hide()
  1480. end
  1481. end)
  1482.  
  1483. Stat:RegisterEvent("BN_FRIEND_ACCOUNT_ONLINE")
  1484. Stat:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
  1485. Stat:RegisterEvent("BN_FRIEND_INFO_CHANGED")
  1486. Stat:RegisterEvent("BN_FRIEND_TOON_ONLINE")
  1487. Stat:RegisterEvent("BN_FRIEND_TOON_OFFLINE")
  1488. Stat:RegisterEvent("BN_TOON_NAME_UPDATED")
  1489. Stat:RegisterEvent("FRIENDLIST_UPDATE")
  1490. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  1491.  
  1492. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  1493. Stat:SetScript("OnEvent", Update)
  1494. end
  1495.  
  1496.  
  1497. ---------
  1498. -- Guild
  1499. ---------
  1500. if db.guild then
  1501.  
  1502. local Stat = CreateFrame('Frame', nil, Datapanel)
  1503. Stat:EnableMouse(true)
  1504. Stat:SetFrameStrata("MEDIUM")
  1505. Stat:SetFrameLevel(3)
  1506.  
  1507. local Text = Stat:CreateFontString(nil, "OVERLAY")
  1508. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  1509. self:PlacePlugin(db.guild, Text)
  1510.  
  1511. local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
  1512. local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
  1513. local displayString = string.join("", hexa.."%s: "..hexb, "|cffffffff", "%d|r")
  1514. local guildInfoString0 = "%s"
  1515. local guildInfoString1 = "%s [%d]"
  1516. local guildInfoString2 = "%s: %d/%d"
  1517. local guildMotDString = "%s |cffaaaaaa- |cffffffff%s"
  1518. local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
  1519. local levelNameStatusString = "|cff%02x%02x%02x%d|r %s %s"
  1520. local nameRankString = "%s |cff999999-|cffffffff %s"
  1521. local noteString = " '%s'"
  1522. local officerNoteString = " o: '%s'"
  1523.  
  1524. local guildTable, guildXP, guildMotD = {}, {}, ""
  1525. local totalOnline = 0
  1526.  
  1527.  
  1528. local function BuildGuildTable()
  1529. totalOnline = 0
  1530. wipe(guildTable)
  1531. local _, name, rank, level, zone, note, officernote, connected, status, class, isMobile
  1532. for i = 1, GetNumGuildMembers() do
  1533. name, rank, _, level, _, zone, note, officernote, connected, status, class, _, _, isMobile = GetGuildRosterInfo(i)
  1534.  
  1535. if status == 1 then
  1536. status = "|cffff0000["..AFK.."]|r"
  1537. elseif status == 2 then
  1538. status = "|cffff0000["..DND.."]|r"
  1539. else
  1540. status = ""
  1541. end
  1542.  
  1543. guildTable[i] = { name, rank, level, zone, note, officernote, connected, status, class, isMobile }
  1544. if connected then totalOnline = totalOnline + 1 end
  1545. end
  1546. table.sort(guildTable, function(a, b)
  1547. if a and b then
  1548. return a[1] < b[1]
  1549. end
  1550. end)
  1551. end
  1552.  
  1553. local function UpdateGuildXP()
  1554. local currentXP, remainingXP = UnitGetGuildXP("player")
  1555. local nextLevelXP = currentXP + remainingXP
  1556.  
  1557. -- prevent 4.3 division / 0
  1558. if nextLevelXP == 0 or maxDailyXP == 0 then return end
  1559.  
  1560. local percentTotal = tostring(math.ceil((currentXP / nextLevelXP) * 100))
  1561.  
  1562. guildXP[0] = { currentXP, nextLevelXP, percentTotal }
  1563. end
  1564.  
  1565. local function UpdateGuildMessage()
  1566. guildMotD = GetGuildRosterMOTD()
  1567. end
  1568.  
  1569. local function Update(self, event, ...)
  1570. if event == "PLAYER_ENTERING_WORLD" then
  1571. self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  1572. if IsInGuild() and not GuildFrame then LoadAddOn("Blizzard_GuildUI") end
  1573. end
  1574.  
  1575. if IsInGuild() then
  1576. totalOnline = 0
  1577. local name, rank, level, zone, note, officernote, connected, status, class
  1578. for i = 1, GetNumGuildMembers() do
  1579. local connected = select(9, GetGuildRosterInfo(i))
  1580. if connected then totalOnline = totalOnline + 1 end
  1581. end
  1582. Text:SetFormattedText(displayString, "Guild", totalOnline)
  1583. else
  1584. Text:SetText("No Guild")
  1585. end
  1586.  
  1587. self:SetAllPoints(Text)
  1588. end
  1589.  
  1590. local menuFrame = CreateFrame("Frame", "GuildRightClickMenu", UIParent, "UIDropDownMenuTemplate")
  1591. local menuList = {
  1592. { text = OPTIONS_MENU, isTitle = true,notCheckable=true},
  1593. { text = INVITE, hasArrow = true,notCheckable=true,},
  1594. { text = CHAT_MSG_WHISPER_INFORM, hasArrow = true,notCheckable=true,}
  1595. }
  1596.  
  1597. local function inviteClick(self, arg1, arg2, checked)
  1598. menuFrame:Hide()
  1599. InviteUnit(arg1)
  1600. end
  1601.  
  1602. local function whisperClick(self,arg1,arg2,checked)
  1603. menuFrame:Hide()
  1604. SetItemRef( "player:"..arg1, ("|Hplayer:%1$s|h[%1$s]|h"):format(arg1), "LeftButton" )
  1605. end
  1606.  
  1607. local function ToggleGuildFrame()
  1608. if IsInGuild() then
  1609. if not GuildFrame then LoadAddOn("Blizzard_GuildUI") end
  1610. GuildFrame_Toggle()
  1611. GuildFrame_TabClicked(GuildFrameTab2)
  1612. else
  1613. if not LookingForGuildFrame then LoadAddOn("Blizzard_LookingForGuildUI") end
  1614. LookingForGuildFrame_Toggle()
  1615. end
  1616. end
  1617.  
  1618. Stat:SetScript("OnMouseUp", function(self, btn)
  1619. if btn ~= "RightButton" or not IsInGuild() then return end
  1620.  
  1621. GameTooltip:Hide()
  1622.  
  1623. local classc, levelc, grouped
  1624. local menuCountWhispers = 0
  1625. local menuCountInvites = 0
  1626.  
  1627. menuList[2].menuList = {}
  1628. menuList[3].menuList = {}
  1629.  
  1630. for i = 1, #guildTable do
  1631. if (guildTable[i][7] and guildTable[i][1] ~= nDatamyname) then
  1632. local classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[guildTable[i][9]], GetQuestDifficultyColor(guildTable[i][3])
  1633.  
  1634. if UnitInParty(guildTable[i][1]) or UnitInRaid(guildTable[i][1]) then
  1635. grouped = "|cffaaaaaa*|r"
  1636. else
  1637. grouped = ""
  1638. if not guildTable[i][10] then
  1639. menuCountInvites = menuCountInvites + 1
  1640. menuList[2].menuList[menuCountInvites] = {text = string.format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, guildTable[i][3], classc.r*255,classc.g*255,classc.b*255, guildTable[i][1], ""), arg1 = guildTable[i][1],notCheckable=true, func = inviteClick}
  1641. end
  1642. end
  1643. menuCountWhispers = menuCountWhispers + 1
  1644. menuList[3].menuList[menuCountWhispers] = {text = string.format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, guildTable[i][3], classc.r*255,classc.g*255,classc.b*255, guildTable[i][1], grouped), arg1 = guildTable[i][1],notCheckable=true, func = whisperClick}
  1645. end
  1646. end
  1647.  
  1648. EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
  1649. end)
  1650.  
  1651. Stat:SetScript("OnEnter", function(self)
  1652. if InCombatLockdown() or not IsInGuild() then return end
  1653.  
  1654. GuildRoster()
  1655. UpdateGuildMessage()
  1656. BuildGuildTable()
  1657.  
  1658. local name, rank, level, zone, note, officernote, connected, status, class, isMobile
  1659. local zonec, classc, levelc
  1660. local online = totalOnline
  1661. local guildName, guildRankName, guildRankIndex = GetGuildInfo("player");
  1662. local GuildInfo = GetGuildInfo('player')
  1663. local GuildLevel = GetGuildLevel()
  1664.  
  1665. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1666. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1667. GameTooltip:ClearLines()
  1668. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Guild")
  1669. if GuildInfo then
  1670. GameTooltip:AddDoubleLine(string.format(guildInfoString0, GuildInfo), string.format(guildInfoString1, "Guild Level:", GuildLevel),tthead.r,tthead.g,tthead.b,tthead.r,tthead.g,tthead.b)
  1671. end
  1672. GameTooltip:AddLine' '
  1673. if GuildLevel then
  1674. GameTooltip:AddLine( string.format(guildInfoString2, "Member's Online", online, #guildTable),tthead.r,tthead.g,tthead.b)
  1675. end
  1676.  
  1677. if guildMotD ~= "" then GameTooltip:AddLine(' ')
  1678. GameTooltip:AddLine(string.format(guildMotDString, GUILD_MOTD, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
  1679. end
  1680.  
  1681. local col = RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b)
  1682. GameTooltip:AddLine' '
  1683. if GuildLevel and GuildLevel ~= 25 then
  1684.  
  1685. if guildXP[0] then
  1686. local currentXP, nextLevelXP, percentTotal = unpack(guildXP[0])
  1687.  
  1688. GameTooltip:AddLine(string.format(col..GUILD_EXPERIENCE_CURRENT, "|r |cFFFFFFFF"..ShortValue(currentXP), ShortValue(nextLevelXP), percentTotal))
  1689. end
  1690. end
  1691.  
  1692. local _, _, standingID, barMin, barMax, barValue = GetGuildFactionInfo()
  1693. if standingID ~= 8 then -- Not Max Rep
  1694. barMax = barMax - barMin
  1695. barValue = barValue - barMin
  1696. barMin = 0
  1697. GameTooltip:AddLine(string.format("%s:|r |cFFFFFFFF%s/%s (%s%%)",col..COMBAT_FACTION_CHANGE, ShortValue(barValue), ShortValue(barMax), math.ceil((barValue / barMax) * 100)))
  1698. end
  1699.  
  1700. if online > 1 then
  1701. GameTooltip:AddLine(' ')
  1702. for i = 1, #guildTable do
  1703. if online <= 1 then
  1704. if online > 1 then GameTooltip:AddLine(format("+ %d More...", online - modules.Guild.maxguild),ttsubh.r,ttsubh.g,ttsubh.b) end
  1705. break
  1706. end
  1707.  
  1708. name, rank, level, zone, note, officernote, connected, status, class, isMobile = unpack(guildTable[i])
  1709. if connected and name ~= nDatamyname then
  1710. if GetRealZoneText() == zone then zonec = activezone else zonec = inactivezone end
  1711. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
  1712.  
  1713. if isMobile then zone = "" end
  1714.  
  1715. if IsShiftKeyDown() then
  1716. GameTooltip:AddDoubleLine(string.format(nameRankString, name, rank), zone, classc.r, classc.g, classc.b, zonec.r, zonec.g, zonec.b)
  1717. if note ~= "" then GameTooltip:AddLine(string.format(noteString, note), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  1718. if officernote ~= "" then GameTooltip:AddLine(string.format(officerNoteString, officernote), ttoff.r, ttoff.g, ttoff.b ,1) end
  1719. else
  1720. GameTooltip:AddDoubleLine(string.format(levelNameStatusString, levelc.r*255, levelc.g*255, levelc.b*255, level, name, status), zone, classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
  1721. end
  1722. end
  1723. end
  1724. end
  1725. GameTooltip:AddLine' '
  1726. GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Guild Roster")
  1727. GameTooltip:AddLine("|cffeda55fHold Shift & Mouseover|r to See Guild and Officer Note's")
  1728. GameTooltip:AddLine("|cffeda55fRight Click|r to open Options Menu")
  1729. GameTooltip:Show()
  1730. end)
  1731.  
  1732. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  1733. Stat:SetScript("OnMouseDown", function(self, btn)
  1734. if btn ~= "LeftButton" then return end
  1735. ToggleGuildFrame()
  1736. end)
  1737.  
  1738. Stat:RegisterEvent("GUILD_ROSTER_SHOW")
  1739. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  1740. Stat:RegisterEvent("GUILD_ROSTER_UPDATE")
  1741. Stat:RegisterEvent("PLAYER_GUILD_UPDATE")
  1742. Stat:SetScript("OnEvent", Update)
  1743. end
  1744.  
  1745. ----------------
  1746. -- Player Haste
  1747. ----------------
  1748. if db.haste then
  1749. local Stat = CreateFrame('Frame', nil, Datapanel)
  1750. Stat:EnableMouse(true)
  1751. Stat:SetFrameStrata('BACKGROUND')
  1752. Stat:SetFrameLevel(3)
  1753.  
  1754. local Text = Stat:CreateFontString(nil, 'OVERLAY')
  1755. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  1756. self:PlacePlugin(db.haste, Text)
  1757.  
  1758. local int = 1
  1759.  
  1760. local function Update(self, t)
  1761. local spellhaste = GetCombatRating(CR_HASTE_SPELL)
  1762. local rangedhaste = GetCombatRating(CR_HASTE_RANGED)
  1763. local attackhaste = GetCombatRating(CR_HASTE_MELEE)
  1764.  
  1765. if attackhaste > spellhaste and select(2, UnitClass("Player")) ~= "HUNTER" then
  1766. haste = attackhaste
  1767. elseif select(2, UnitClass("Player")) == "HUNTER" then
  1768. haste = rangedhaste
  1769. else
  1770. haste = spellhaste
  1771. end
  1772.  
  1773. int = int - t
  1774. if int < 0 then
  1775. Text:SetText(hexa.."Haste: "..hexb..haste)
  1776. int = 1
  1777. end
  1778. end
  1779.  
  1780. Stat:SetScript("OnUpdate", Update)
  1781. Update(Stat, 10)
  1782. end
  1783.  
  1784. ---------------
  1785. -- Professions
  1786. ---------------
  1787. if db.pro then
  1788.  
  1789. local Stat = CreateFrame('Button', nil, Datapanel)
  1790. Stat:RegisterEvent('PLAYER_ENTERING_WORLD')
  1791. Stat:SetFrameStrata('BACKGROUND')
  1792. Stat:SetFrameLevel(3)
  1793. Stat:EnableMouse(true)
  1794. Stat.tooltip = false
  1795.  
  1796. local Text = Stat:CreateFontString(nil, 'OVERLAY')
  1797. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  1798. self:PlacePlugin(db.pro, Text)
  1799.  
  1800. local function Update(self)
  1801. for i = 1, select("#", GetProfessions()) do
  1802. local v = select(i, GetProfessions());
  1803. if v ~= nil then
  1804. local name, texture, rank, maxRank = GetProfessionInfo(v)
  1805. Text:SetFormattedText(hexa.."Professions"..hexb)
  1806. end
  1807. end
  1808. self:SetAllPoints(Text)
  1809. end
  1810.  
  1811. Stat:SetScript('OnEnter', function()
  1812. if InCombatLockdown() then return end
  1813. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1814. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1815. GameTooltip:ClearLines()
  1816. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Professions")
  1817. GameTooltip:AddLine' '
  1818. for i = 1, select("#", GetProfessions()) do
  1819. local v = select(i, GetProfessions());
  1820. if v ~= nil then
  1821. local name, texture, rank, maxRank = GetProfessionInfo(v)
  1822. GameTooltip:AddDoubleLine(name, rank..' / '..maxRank,.75,.9,1,.3,1,.3)
  1823. end
  1824. end
  1825. GameTooltip:AddLine' '
  1826. GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Profession #1")
  1827. GameTooltip:AddLine("|cffeda55fMiddle Click|r to Open Spell Book")
  1828. GameTooltip:AddLine("|cffeda55fRight Click|r to Open Profession #2")
  1829.  
  1830. GameTooltip:Show()
  1831. end)
  1832.  
  1833.  
  1834. Stat:SetScript("OnClick",function(self,btn)
  1835. local prof1, prof2 = GetProfessions()
  1836. if btn == "LeftButton" then
  1837. if prof1 then
  1838. if (GetProfessionInfo(prof1) == ('Herbalism')) then
  1839. print('|cff00B4FFBasic|rUI: |cffFF0000Herbalism has no options!|r')
  1840. elseif(GetProfessionInfo(prof1) == ('Skinning')) then
  1841. print('|cff00B4FFBasic|rUI: |cffFF0000Skinning has no options!|r')
  1842. elseif(GetProfessionInfo(prof1) == ('Mining')) then
  1843. CastSpellByName("Smelting")
  1844. else
  1845. CastSpellByName((GetProfessionInfo(prof1)))
  1846. end
  1847. else
  1848. print('|cff00B4FFBasic|rUI: |cffFF0000No Profession Found!|r')
  1849. end
  1850. elseif btn == 'MiddleButton' then
  1851. ToggleSpellBook(BOOKTYPE_PROFESSION);
  1852. elseif btn == "RightButton" then
  1853. if prof2 then
  1854. if (GetProfessionInfo(prof2) == ('Herbalism')) then
  1855. print('|cff00B4FFBasic|rUI: |cffFF0000Herbalism has no options!|r')
  1856. elseif(GetProfessionInfo(prof2) == ('Skinning')) then
  1857. print('|cff00B4FFBasic|rUI: |cffFF0000Skinning has no options!|r')
  1858. elseif(GetProfessionInfo(prof2) == ('Mining')) then
  1859. CastSpellByName("Smelting")
  1860. else
  1861. CastSpellByName((GetProfessionInfo(prof2)))
  1862. end
  1863. else
  1864. print('|cff00B4FFBasic|rUI: |cffFF0000No Profession Found!|r')
  1865. end
  1866. end
  1867. end)
  1868.  
  1869.  
  1870. Stat:RegisterForClicks("AnyUp")
  1871. Stat:SetScript('OnUpdate', Update)
  1872. Stat:SetScript('OnLeave', function() GameTooltip:Hide() end)
  1873. end
  1874.  
  1875.  
  1876. -----------
  1877. -- Recount
  1878. -----------
  1879. if db.recount then
  1880.  
  1881. local RecountDPS = CreateFrame('Frame', nil, Datapanel)
  1882. RecountDPS:EnableMouse(true)
  1883. RecountDPS:SetFrameStrata("MEDIUM")
  1884. RecountDPS:SetFrameLevel(3)
  1885.  
  1886. local Text = RecountDPS:CreateFontString(nil, "OVERLAY")
  1887. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  1888. self:PlacePlugin(db.recount, Text)
  1889. RecountDPS:SetAllPoints(Text)
  1890.  
  1891. function OnEvent(self, event, ...)
  1892. if event == "PLAYER_LOGIN" then
  1893. if IsAddOnLoaded("Recount") then
  1894. RecountDPS:RegisterEvent("PLAYER_REGEN_ENABLED")
  1895. RecountDPS:RegisterEvent("PLAYER_REGEN_DISABLED")
  1896. PLAYER_NAME = UnitName("player")
  1897. currentFightDPS = 0
  1898. else
  1899. return
  1900. end
  1901. RecountDPS:UnregisterEvent("PLAYER_LOGIN")
  1902. elseif event == "PLAYER_ENTERING_WORLD" then
  1903. self.updateDPS()
  1904. RecountDPS:UnregisterEvent("PLAYER_ENTERING_WORLD")
  1905. end
  1906. end
  1907.  
  1908. function RecountDPS:RecountHook_UpdateText()
  1909. self:updateDPS()
  1910. end
  1911.  
  1912. function RecountDPS:updateDPS()
  1913. Text:SetText(hexa.."DPS: "..hexb.. RecountDPS.getDPS() .. "|r")
  1914. end
  1915.  
  1916. function RecountDPS:getDPS()
  1917. if not IsAddOnLoaded("Recount") then return "N/A" end
  1918. if db.recountraiddps == true then
  1919. -- show raid dps
  1920. _, dps = RecountDPS:getRaidValuePerSecond(Recount.db.profile.CurDataSet)
  1921. return dps
  1922. else
  1923. return RecountDPS.getValuePerSecond()
  1924. end
  1925. end
  1926.  
  1927. -- quick dps calculation from recount's data
  1928. function RecountDPS:getValuePerSecond()
  1929. local _, dps = Recount:MergedPetDamageDPS(Recount.db2.combatants[PLAYER_NAME], Recount.db.profile.CurDataSet)
  1930. return math.floor(10 * dps + 0.5) / 10
  1931. end
  1932.  
  1933. function RecountDPS:getRaidValuePerSecond(tablename)
  1934. local dps, curdps, data, damage, temp = 0, 0, nil, 0, 0
  1935. for _,data in pairs(Recount.db2.combatants) do
  1936. if data.Fights and data.Fights[tablename] and (data.type=="Self" or data.type=="Grouped" or data.type=="Pet" or data.type=="Ungrouped") then
  1937. temp, curdps = Recount:MergedPetDamageDPS(data,tablename)
  1938. if data.type ~= "Pet" or (not Recount.db.profile.MergePets and data.Owner and (Recount.db2.combatants[data.Owner].type=="Self" or Recount.db2.combatants[data.Owner].type=="Grouped" or Recount.db2.combatants[data.Owner].type=="Ungrouped")) or (not Recount.db.profile.MergePets and data.Name and data.GUID and self:matchUnitGUID(data.Name, data.GUID)) then
  1939. dps = dps + 10 * curdps
  1940. damage = damage + temp
  1941. end
  1942. end
  1943. end
  1944. return math.floor(damage + 0.5) / 10, math.floor(dps + 0.5)/10
  1945. end
  1946.  
  1947. -- tracked events
  1948. RecountDPS:RegisterEvent("PLAYER_LOGIN")
  1949. RecountDPS:RegisterEvent("PLAYER_ENTERING_WORLD")
  1950.  
  1951. -- scripts
  1952. RecountDPS:SetScript("OnEnter", function(self)
  1953. if InCombatLockdown() then return end
  1954.  
  1955. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1956. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1957. GameTooltip:ClearLines()
  1958. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Damage")
  1959. GameTooltip:AddLine' '
  1960. if IsAddOnLoaded("Recount") then
  1961. local damage, dps = Recount:MergedPetDamageDPS(Recount.db2.combatants[PLAYER_NAME], Recount.db.profile.CurDataSet)
  1962. local raid_damage, raid_dps = RecountDPS:getRaidValuePerSecond(Recount.db.profile.CurDataSet)
  1963. -- format the number
  1964. dps = math.floor(10 * dps + 0.5) / 10
  1965. GameTooltip:AddLine("Recount")
  1966. GameTooltip:AddDoubleLine("Personal Damage:", damage, 1, 1, 1, 0.8, 0.8, 0.8)
  1967. GameTooltip:AddDoubleLine("Personal DPS:", dps, 1, 1, 1, 0.8, 0.8, 0.8)
  1968. GameTooltip:AddLine(" ")
  1969. GameTooltip:AddDoubleLine("Raid Damage:", raid_damage, 1, 1, 1, 0.8, 0.8, 0.8)
  1970. GameTooltip:AddDoubleLine("Raid DPS:", raid_dps, 1, 1, 1, 0.8, 0.8, 0.8)
  1971. GameTooltip:AddLine(" ")
  1972. GameTooltip:AddLine("|cffeda55fLeft Click|r to toggle Recount")
  1973. GameTooltip:AddLine("|cffeda55fRight Click|r to reset data")
  1974. GameTooltip:AddLine("|cffeda55fShift + Right Click|r to open config")
  1975. else
  1976. GameTooltip:AddLine("Recount is not loaded.", 255, 0, 0)
  1977. GameTooltip:AddLine("Enable Recount and reload your UI.")
  1978. end
  1979. GameTooltip:Show()
  1980. end)
  1981. RecountDPS:SetScript("OnMouseUp", function(self, button)
  1982. if button == "RightButton" then
  1983. if not IsShiftKeyDown() then
  1984. Recount:ShowReset()
  1985. else
  1986. Recount:ShowConfig()
  1987. end
  1988. elseif button == "LeftButton" then
  1989. if Recount.MainWindow:IsShown() then
  1990. Recount.MainWindow:Hide()
  1991. else
  1992. Recount.MainWindow:Show()
  1993. Recount:RefreshMainWindow()
  1994. end
  1995. end
  1996. end)
  1997. RecountDPS:SetScript("OnEvent", OnEvent)
  1998. RecountDPS:SetScript("OnLeave", function() GameTooltip:Hide() end)
  1999. RecountDPS:SetScript("OnUpdate", function(self, t)
  2000. local int = -1
  2001. int = int - t
  2002. if int < 0 then
  2003. self.updateDPS()
  2004. int = 1
  2005. end
  2006. end)
  2007. end
  2008.  
  2009. --------------------
  2010. -- Talent Spec Swap
  2011. --------------------
  2012. if db.spec then
  2013.  
  2014. local Stat = CreateFrame('Frame', nil, Datapanel)
  2015. Stat:EnableMouse(true)
  2016. Stat:SetFrameStrata('BACKGROUND')
  2017. Stat:SetFrameLevel(3)
  2018.  
  2019. local Text = Stat:CreateFontString(nil, 'OVERLAY')
  2020. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  2021. self:PlacePlugin(db.spec, Text)
  2022.  
  2023. local talent = {}
  2024. local active
  2025. local talentString = string.join('', '|cffFFFFFF%s|r ')
  2026. local activeString = string.join('', '|cff00FF00' , ACTIVE_PETS, '|r')
  2027. local inactiveString = string.join('', '|cffFF0000', FACTION_INACTIVE, '|r')
  2028.  
  2029.  
  2030.  
  2031. local function LoadTalentTrees()
  2032. for i = 1, GetNumSpecGroups(false, false) do
  2033. talent[i] = {} -- init talent group table
  2034. for j = 1, GetNumSpecializations(false, false) do
  2035. talent[i][j] = select(5, GetSpecializationInfo(j, false, false, i))
  2036. end
  2037. end
  2038. end
  2039.  
  2040. local int = 1
  2041. local function Update(self, t)
  2042. int = int - t
  2043. if int > 0 or not GetSpecialization() then return end
  2044.  
  2045. active = GetActiveSpecGroup(false, false)
  2046. Text:SetFormattedText(talentString, hexa..select(2, GetSpecializationInfo(GetSpecialization(false, false, active)))..hexb)
  2047. int = 1
  2048.  
  2049. -- disable script
  2050. self:SetScript('OnUpdate', nil)
  2051. end
  2052.  
  2053.  
  2054. Stat:SetScript('OnEnter', function(self)
  2055. if InCombatLockdown() then return end
  2056.  
  2057. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2058. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2059.  
  2060. GameTooltip:ClearLines()
  2061. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Spec")
  2062. GameTooltip:AddLine' '
  2063. for i = 1, GetNumSpecGroups() do
  2064. if GetSpecialization(false, false, i) then
  2065. GameTooltip:AddLine(string.join('- ', string.format(talentString, select(2, GetSpecializationInfo(GetSpecialization(false, false, i)))), (i == active and activeString or inactiveString)),1,1,1)
  2066. end
  2067. end
  2068.  
  2069. GameTooltip:AddLine' '
  2070. GameTooltip:AddLine("|cffeda55fLeft Click|r to Switch Spec's")
  2071. GameTooltip:AddLine("|cffeda55fRight Click|r to Open Talent Tree")
  2072. GameTooltip:Show()
  2073. end)
  2074.  
  2075. Stat:SetScript('OnLeave', function() GameTooltip:Hide() end)
  2076.  
  2077. local function OnEvent(self, event, ...)
  2078. if event == 'PLAYER_ENTERING_WORLD' then
  2079. self:UnregisterEvent('PLAYER_ENTERING_WORLD')
  2080. end
  2081.  
  2082. -- load talent information
  2083. LoadTalentTrees()
  2084.  
  2085. -- Setup Talents Tooltip
  2086. self:SetAllPoints(Text)
  2087.  
  2088. -- update datatext
  2089. if event ~= 'PLAYER_ENTERING_WORLD' then
  2090. self:SetScript('OnUpdate', Update)
  2091. end
  2092. end
  2093.  
  2094.  
  2095.  
  2096. Stat:RegisterEvent('PLAYER_ENTERING_WORLD');
  2097. Stat:RegisterEvent('CHARACTER_POINTS_CHANGED');
  2098. Stat:RegisterEvent('PLAYER_TALENT_UPDATE');
  2099. Stat:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
  2100. Stat:RegisterEvent("EQUIPMENT_SETS_CHANGED")
  2101. Stat:SetScript('OnEvent', OnEvent)
  2102. Stat:SetScript('OnUpdate', Update)
  2103.  
  2104. Stat:SetScript("OnMouseDown", function(self, button)
  2105. if button == "LeftButton" then
  2106. SetActiveSpecGroup (active == 1 and 2 or 1)
  2107. elseif button == "RightButton" then
  2108. ToggleTalentFrame()
  2109. end
  2110. end)
  2111. end
  2112.  
  2113. -----------------
  2114. -- Statistics #1
  2115. -----------------
  2116. if db.stat1 then
  2117.  
  2118. local Stat = CreateFrame('Frame', nil, Datapanel)
  2119. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  2120. Stat:SetFrameStrata("BACKGROUND")
  2121. Stat:SetFrameLevel(3)
  2122. Stat:EnableMouse(true)
  2123.  
  2124. local Text = Stat:CreateFontString(nil, "OVERLAY")
  2125. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  2126. self:PlacePlugin(db.stat1, Text)
  2127.  
  2128. local format = string.format
  2129. local targetlv, playerlv = UnitLevel("target"), UnitLevel("player")
  2130. local basemisschance, leveldifference, dodge, parry, block
  2131. local chanceString = "%.2f%%"
  2132. local modifierString = string.join("", "%d (+", chanceString, ")")
  2133. local manaRegenString = "%d / %d"
  2134. local displayNumberString = string.join("", "%s", "%d|r")
  2135. local displayFloatString = string.join("", "%s", "%.2f%%|r")
  2136. local spellpwr, avoidance, pwr
  2137. local haste, hasteBonus
  2138. local level = UnitLevel("player")
  2139.  
  2140. local function ShowTooltip(self)
  2141. if InCombatLockdown() then return end
  2142.  
  2143. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2144. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2145. GameTooltip:ClearLines()
  2146. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Statistics")
  2147. GameTooltip:AddLine' '
  2148.  
  2149. if Role == "Tank" then
  2150. if targetlv > 1 then
  2151. GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "lvl", " ", targetlv, ")"))
  2152. elseif targetlv == -1 then
  2153. GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "Boss", ")"))
  2154. else
  2155. GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "lvl", " ", playerlv, ")"))
  2156. end
  2157. GameTooltip:AddLine' '
  2158. GameTooltip:AddDoubleLine(DODGE_CHANCE, format(chanceString, dodge),1,1,1)
  2159. GameTooltip:AddDoubleLine(PARRY_CHANCE, format(chanceString, parry),1,1,1)
  2160. GameTooltip:AddDoubleLine(BLOCK_CHANCE, format(chanceString, block),1,1,1)
  2161. GameTooltip:AddDoubleLine(MISS_CHANCE, format(chanceString, basemisschance),1,1,1)
  2162. elseif Role == "Caster" then
  2163. GameTooltip:AddDoubleLine(STAT_HIT_CHANCE, format(modifierString, GetCombatRating(CR_HIT_SPELL), GetCombatRatingBonus(CR_HIT_SPELL)), 1, 1, 1)
  2164. GameTooltip:AddDoubleLine(STAT_HASTE, format(modifierString, GetCombatRating(CR_HASTE_SPELL), GetCombatRatingBonus(CR_HASTE_SPELL)), 1, 1, 1)
  2165. local base, combat = GetManaRegen()
  2166. GameTooltip:AddDoubleLine(MANA_REGEN, format(manaRegenString, base * 5, combat * 5), 1, 1, 1)
  2167. elseif Role == "Melee" then
  2168. local hit = UNIT_CLASS == "HUNTER" and GetCombatRating(CR_HIT_RANGED) or GetCombatRating(CR_HIT_MELEE)
  2169. local hitBonus = UNIT_CLASS == "HUNTER" and GetCombatRatingBonus(CR_HIT_RANGED) or GetCombatRatingBonus(CR_HIT_MELEE)
  2170.  
  2171. GameTooltip:AddDoubleLine(STAT_HIT_CHANCE, format(modifierString, hit, hitBonus), 1, 1, 1)
  2172.  
  2173. local haste = UNIT_CLASS == "HUNTER" and GetCombatRating(CR_HASTE_RANGED) or GetCombatRating(CR_HASTE_MELEE)
  2174. local hasteBonus = UNIT_CLASS == "HUNTER" and GetCombatRatingBonus(CR_HASTE_RANGED) or GetCombatRatingBonus(CR_HASTE_MELEE)
  2175.  
  2176. GameTooltip:AddDoubleLine(STAT_HASTE, format(modifierString, haste, hasteBonus), 1, 1, 1)
  2177. end
  2178.  
  2179. local masteryspell
  2180. if GetCombatRating(CR_MASTERY) ~= 0 and GetSpecialization() then
  2181. if UNIT_CLASS == "DRUID" then
  2182. if Role == "Melee" then
  2183. masteryspell = select(2, GetSpecializationMasterySpells(GetSpecialization()))
  2184. elseif Role == "Tank" then
  2185. masteryspell = select(1, GetSpecializationMasterySpells(GetSpecialization()))
  2186. else
  2187. masteryspell = GetSpecializationMasterySpells(GetSpecialization())
  2188. end
  2189. else
  2190. masteryspell = GetSpecializationMasterySpells(GetSpecialization())
  2191. end
  2192.  
  2193.  
  2194.  
  2195. local masteryName, _, _, _, _, _, _, _, _ = GetSpellInfo(masteryspell)
  2196. if masteryName then
  2197. GameTooltip:AddLine' '
  2198. GameTooltip:AddDoubleLine(masteryName, format(modifierString, GetCombatRating(CR_MASTERY), GetCombatRatingBonus(CR_MASTERY)), 1, 1, 1)
  2199. end
  2200. end
  2201.  
  2202. GameTooltip:Show()
  2203. end
  2204.  
  2205. local function UpdateTank(self)
  2206.  
  2207. -- the 5 is for base miss chance
  2208. if targetlv == -1 then
  2209. basemisschance = (5 - (3*.2))
  2210. leveldifference = 3
  2211. elseif targetlv > playerlv then
  2212. basemisschance = (5 - ((targetlv - playerlv)*.2))
  2213. leveldifference = (targetlv - playerlv)
  2214. elseif targetlv < playerlv and targetlv > 0 then
  2215. basemisschance = (5 + ((playerlv - targetlv)*.2))
  2216. leveldifference = (targetlv - playerlv)
  2217. else
  2218. basemisschance = 5
  2219. leveldifference = 0
  2220. end
  2221.  
  2222. if select(2, UnitRace("player")) == "NightElf" then basemisschance = basemisschance + 2 end
  2223.  
  2224. if leveldifference >= 0 then
  2225. dodge = (GetDodgeChance()-leveldifference*.2)
  2226. parry = (GetParryChance()-leveldifference*.2)
  2227. block = (GetBlockChance()-leveldifference*.2)
  2228. else
  2229. dodge = (GetDodgeChance()+abs(leveldifference*.2))
  2230. parry = (GetParryChance()+abs(leveldifference*.2))
  2231. block = (GetBlockChance()+abs(leveldifference*.2))
  2232. end
  2233.  
  2234. if dodge <= 0 then dodge = 0 end
  2235. if parry <= 0 then parry = 0 end
  2236. if block <= 0 then block = 0 end
  2237.  
  2238. if UNIT_CLASS == "DRUID" then
  2239. parry = 0
  2240. block = 0
  2241. elseif UNIT_CLASS == "DEATHKNIGHT" then
  2242. block = 0
  2243. end
  2244. avoidance = (dodge+parry+block+basemisschance)
  2245.  
  2246. Text:SetFormattedText(displayFloatString, hexa.."AVD: "..hexb, avoidance)
  2247. --Setup Tooltip
  2248. self:SetAllPoints(Text)
  2249. end
  2250.  
  2251. local function UpdateCaster(self)
  2252. if GetSpellBonusHealing() > GetSpellBonusDamage(7) then
  2253. spellpwr = GetSpellBonusHealing()
  2254. else
  2255. spellpwr = GetSpellBonusDamage(7)
  2256. end
  2257.  
  2258. Text:SetFormattedText(displayNumberString, hexa.."SP: "..hexb, spellpwr)
  2259. --Setup Tooltip
  2260. self:SetAllPoints(Text)
  2261. end
  2262.  
  2263. local function UpdateMelee(self)
  2264. local base, posBuff, negBuff = UnitAttackPower("player");
  2265. local effective = base + posBuff + negBuff;
  2266. local Rbase, RposBuff, RnegBuff = UnitRangedAttackPower("player");
  2267. local Reffective = Rbase + RposBuff + RnegBuff;
  2268.  
  2269. if UNIT_CLASS == "HUNTER" then
  2270. pwr = Reffective
  2271. else
  2272. pwr = effective
  2273. end
  2274.  
  2275. Text:SetFormattedText(displayNumberString, hexa.."AP: "..hexb, pwr)
  2276. --Setup Tooltip
  2277. self:SetAllPoints(Text)
  2278. end
  2279.  
  2280. -- initial delay for update (let the ui load)
  2281. local int = 5
  2282. local function Update(self, t)
  2283. int = int - t
  2284. if int > 0 then return end
  2285. if Role == "Tank" then
  2286. UpdateTank(self)
  2287. elseif Role == "Caster" then
  2288. UpdateCaster(self)
  2289. elseif Role == "Melee" then
  2290. UpdateMelee(self)
  2291. end
  2292. int = 2
  2293. end
  2294.  
  2295. Stat:SetScript("OnEnter", function() ShowTooltip(Stat) end)
  2296. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2297. Stat:SetScript("OnUpdate", Update)
  2298. Update(Stat, 10)
  2299. end
  2300.  
  2301. -----------------
  2302. -- Statistics #2
  2303. -----------------
  2304. if db.stat2 then
  2305.  
  2306. local Stat = CreateFrame('Frame', nil, Datapanel)
  2307. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  2308. Stat:SetFrameStrata("BACKGROUND")
  2309. Stat:SetFrameLevel(3)
  2310. Stat:EnableMouse(true)
  2311.  
  2312. local Text = Stat:CreateFontString(nil, "OVERLAY")
  2313. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  2314. self:PlacePlugin(db.stat2, Text)
  2315.  
  2316. local _G = getfenv(0)
  2317. local format = string.format
  2318. local chanceString = "%.2f%%"
  2319. local armorString = hexa..ARMOR..hexb..": "
  2320. local modifierString = string.join("", "%d (+", chanceString, ")")
  2321. local baseArmor, effectiveArmor, armor, posBuff, negBuff
  2322. local displayNumberString = string.join("", "%s", "%d|r")
  2323. local displayFloatString = string.join("", "%s", "%.2f%%|r")
  2324. local level = UnitLevel("player")
  2325.  
  2326.  
  2327. local function CalculateMitigation(level, effective)
  2328. local mitigation
  2329.  
  2330. if not effective then
  2331. _, effective, _, _, _ = UnitArmor("player")
  2332. end
  2333.  
  2334. if level < 60 then
  2335. mitigation = (effective/(effective + 400 + (85 * level)));
  2336. else
  2337. mitigation = (effective/(effective + (467.5 * level - 22167.5)));
  2338. end
  2339. if mitigation > .75 then
  2340. mitigation = .75
  2341. end
  2342. return mitigation
  2343. end
  2344.  
  2345. local function AddTooltipHeader(description)
  2346. GameTooltip:AddLine(description)
  2347. GameTooltip:AddLine(' ')
  2348. end
  2349.  
  2350. local function ShowTooltip(self)
  2351. if InCombatLockdown() then return end
  2352.  
  2353. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2354. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2355. GameTooltip:ClearLines()
  2356. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Statistics")
  2357. GameTooltip:AddLine' '
  2358.  
  2359. if Role == "Tank" then
  2360. AddTooltipHeader("Mitigation By Level: ")
  2361. local lv = level +3
  2362. for i = 1, 4 do
  2363. GameTooltip:AddDoubleLine(lv,format(chanceString, CalculateMitigation(lv, effectiveArmor) * 100),1,1,1)
  2364. lv = lv - 1
  2365. end
  2366. lv = UnitLevel("target")
  2367. if lv and lv > 0 and (lv > level + 3 or lv < level) then
  2368. GameTooltip:AddDoubleLine(lv, format(chanceString, CalculateMitigation(lv, effectiveArmor) * 100),1,1,1)
  2369. end
  2370. elseif Role == "Caster" or Role == "Melee" then
  2371. AddTooltipHeader(MAGIC_RESISTANCES_COLON)
  2372.  
  2373. local base, total, bonus, minus
  2374. for i = 2, 6 do
  2375. base, total, bonus, minus = UnitResistance("player", i)
  2376. GameTooltip:AddDoubleLine(_G["DAMAGE_SCHOOL"..(i+1)], format(chanceString, (total / (total + (500 + level + 2.5))) * 100),1,1,1)
  2377. end
  2378.  
  2379. local spellpen = GetSpellPenetration()
  2380. if (UNIT_CLASS == "SHAMAN" or Role == "Caster") and spellpen > 0 then
  2381. GameTooltip:AddLine' '
  2382. GameTooltip:AddDoubleLine(ITEM_MOD_SPELL_PENETRATION_SHORT, spellpen,1,1,1)
  2383. end
  2384. end
  2385. GameTooltip:Show()
  2386. end
  2387.  
  2388. local function UpdateTank(self)
  2389. baseArmor, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
  2390.  
  2391. Text:SetFormattedText(displayNumberString, armorString, effectiveArmor)
  2392. --Setup Tooltip
  2393. self:SetAllPoints(Text)
  2394. end
  2395.  
  2396. local function UpdateCaster(self)
  2397. local spellcrit = GetSpellCritChance(1)
  2398.  
  2399. Text:SetFormattedText(displayFloatString, hexa.."Crit: "..hexb, spellcrit)
  2400. --Setup Tooltip
  2401. self:SetAllPoints(Text)
  2402. end
  2403.  
  2404. local function UpdateMelee(self)
  2405. local meleecrit = GetCritChance()
  2406. local rangedcrit = GetRangedCritChance()
  2407. local critChance
  2408.  
  2409. if UNIT_CLASS == "HUNTER" then
  2410. critChance = rangedcrit
  2411. else
  2412. critChance = meleecrit
  2413. end
  2414.  
  2415. Text:SetFormattedText(displayFloatString, hexa.."Crit: "..hexb, critChance)
  2416. --Setup Tooltip
  2417. self:SetAllPoints(Text)
  2418. end
  2419.  
  2420. -- initial delay for update (let the ui load)
  2421. local int = 5
  2422. local function Update(self, t)
  2423. int = int - t
  2424. if int > 0 then return end
  2425.  
  2426. if Role == "Tank" then
  2427. UpdateTank(self)
  2428. elseif Role == "Caster" then
  2429. UpdateCaster(self)
  2430. elseif Role == "Melee" then
  2431. UpdateMelee(self)
  2432. end
  2433. int = 2
  2434. end
  2435.  
  2436. Stat:SetScript("OnEnter", function() ShowTooltip(Stat) end)
  2437. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2438. Stat:SetScript("OnUpdate", Update)
  2439. Update(Stat, 10)
  2440. end
  2441.  
  2442. -------------------
  2443. -- System Settings
  2444. -------------------
  2445. if db.system then
  2446.  
  2447. local Stat = CreateFrame('Frame', nil, Datapanel)
  2448. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  2449. Stat:SetFrameStrata("BACKGROUND")
  2450. Stat:SetFrameLevel(3)
  2451. Stat:EnableMouse(true)
  2452. Stat.tooltip = false
  2453.  
  2454. local Text = Stat:CreateFontString(nil, "OVERLAY")
  2455. Text:SetFont(BasicUI.media.fontNormal, BasicUI.db.profile.general.fontSize,'THINOUTLINE')
  2456. self:PlacePlugin(db.system, Text)
  2457.  
  2458. local bandwidthString = "%.2f Mbps"
  2459. local percentageString = "%.2f%%"
  2460. local homeLatencyString = "%d ms"
  2461. local worldLatencyString = "%d ms"
  2462. local kiloByteString = "%d kb"
  2463. local megaByteString = "%.2f mb"
  2464.  
  2465. local function formatMem(memory)
  2466. local mult = 10^1
  2467. if memory > 999 then
  2468. local mem = ((memory/1024) * mult) / mult
  2469. return string.format(megaByteString, mem)
  2470. else
  2471. local mem = (memory * mult) / mult
  2472. return string.format(kiloByteString, mem)
  2473. end
  2474. end
  2475.  
  2476. local memoryTable = {}
  2477.  
  2478. local function RebuildAddonList(self)
  2479. local addOnCount = GetNumAddOns()
  2480. if (addOnCount == #memoryTable) or self.tooltip == true then return end
  2481.  
  2482. -- Number of loaded addons changed, create new memoryTable for all addons
  2483. memoryTable = {}
  2484. for i = 1, addOnCount do
  2485. memoryTable[i] = { i, select(2, GetAddOnInfo(i)), 0, IsAddOnLoaded(i) }
  2486. end
  2487. self:SetAllPoints(Text)
  2488. end
  2489.  
  2490. local function UpdateMemory()
  2491. -- Update the memory usages of the addons
  2492. UpdateAddOnMemoryUsage()
  2493. -- Load memory usage in table
  2494. local addOnMem = 0
  2495. local totalMemory = 0
  2496. for i = 1, #memoryTable do
  2497. addOnMem = GetAddOnMemoryUsage(memoryTable[i][1])
  2498. memoryTable[i][3] = addOnMem
  2499. totalMemory = totalMemory + addOnMem
  2500. end
  2501. -- Sort the table to put the largest addon on top
  2502. table.sort(memoryTable, function(a, b)
  2503. if a and b then
  2504. return a[3] > b[3]
  2505. end
  2506. end)
  2507.  
  2508. return totalMemory
  2509. end
  2510.  
  2511. -- initial delay for update (let the ui load)
  2512. local int, int2 = 6, 5
  2513. local statusColors = {
  2514. "|cff0CD809",
  2515. "|cffE8DA0F",
  2516. "|cffFF9000",
  2517. "|cffD80909"
  2518. }
  2519.  
  2520. local function Update(self, t)
  2521. int = int - t
  2522. int2 = int2 - t
  2523.  
  2524. if int < 0 then
  2525. RebuildAddonList(self)
  2526. int = 10
  2527. end
  2528. if int2 < 0 then
  2529. local framerate = floor(GetFramerate())
  2530. local fpscolor = 4
  2531. local latency = select(4, GetNetStats())
  2532. local latencycolor = 4
  2533.  
  2534. if latency < 150 then
  2535. latencycolor = 1
  2536. elseif latency >= 150 and latency < 300 then
  2537. latencycolor = 2
  2538. elseif latency >= 300 and latency < 500 then
  2539. latencycolor = 3
  2540. end
  2541. if framerate >= 30 then
  2542. fpscolor = 1
  2543. elseif framerate >= 20 and framerate < 30 then
  2544. fpscolor = 2
  2545. elseif framerate >= 10 and framerate < 20 then
  2546. fpscolor = 3
  2547. end
  2548. local displayFormat = string.join("", hexa.."FPS: "..hexb, statusColors[fpscolor], "%d|r", hexa.." MS: "..hexb, statusColors[latencycolor], "%d|r")
  2549. Text:SetFormattedText(displayFormat, framerate, latency)
  2550. int2 = 1
  2551. end
  2552. end
  2553. Stat:SetScript("OnMouseDown", function () collectgarbage("collect") Update(Stat, 20) end)
  2554. Stat:SetScript("OnEnter", function(self)
  2555. if InCombatLockdown() then return end
  2556. local bandwidth = GetAvailableBandwidth()
  2557. local _, _, latencyHome, latencyWorld = GetNetStats()
  2558. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2559. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2560. GameTooltip:ClearLines()
  2561. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Latency")
  2562. GameTooltip:AddLine' '
  2563. GameTooltip:AddDoubleLine("Home Latency: ", string.format(homeLatencyString, latencyHome), 0.80, 0.31, 0.31,0.84, 0.75, 0.65)
  2564. GameTooltip:AddDoubleLine("World Latency: ", string.format(worldLatencyString, latencyWorld), 0.80, 0.31, 0.31,0.84, 0.75, 0.65)
  2565.  
  2566. if bandwidth ~= 0 then
  2567. GameTooltip:AddDoubleLine(L.datatext_bandwidth , string.format(bandwidthString, bandwidth),0.69, 0.31, 0.31,0.84, 0.75, 0.65)
  2568. GameTooltip:AddDoubleLine("Download: " , string.format(percentageString, GetDownloadedPercentage() *100),0.69, 0.31, 0.31, 0.84, 0.75, 0.65)
  2569. GameTooltip:AddLine(" ")
  2570. end
  2571. local totalMemory = UpdateMemory()
  2572. GameTooltip:AddDoubleLine("Total Memory Usage:", formatMem(totalMemory), 0.69, 0.31, 0.31,0.84, 0.75, 0.65)
  2573. GameTooltip:AddLine(" ")
  2574. for i = 1, #memoryTable do
  2575. if (memoryTable[i][4]) then
  2576. local red = memoryTable[i][3] / totalMemory
  2577. local green = 1 - red
  2578. GameTooltip:AddDoubleLine(memoryTable[i][2], formatMem(memoryTable[i][3]), 1, 1, 1, red, green + .5, 0)
  2579. end
  2580. end
  2581. GameTooltip:Show()
  2582. end)
  2583. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2584. Stat:SetScript("OnUpdate", Update)
  2585. Update(Stat, 10)
  2586. end
  2587. end
  2588.  
  2589. function Datatext:OnInitialize()
  2590. self.db = BasicUI.db:RegisterNamespace(MODULE_NAME, defaults)
  2591. db = self.db.profile
  2592.  
  2593. local _, class = UnitClass("player")
  2594. classColor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  2595.  
  2596. self:SetEnabledState(BasicUI:GetModuleEnabled(MODULE_NAME))
  2597. end
  2598.  
  2599.  
  2600. function Datatext:OnEnable()
  2601. -- This line should not be needed if you're using modules correctly:
  2602. if not db.enable then return end
  2603.  
  2604. if db.enable then -- How is this different than "enable" ? If the panel is not enabled, what's the point of doing anything else?
  2605. self:CreatePanel() -- factor this giant blob out into its own function to keep things clean
  2606. self:Refresh()
  2607. end
  2608. end
  2609.  
  2610. function Datatext:Refresh()
  2611. if InCombatLockdown() then
  2612. return self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnEnable")
  2613. end
  2614. self:UnregisterEvent("PLAYER_REGEN_ENABLED")
  2615.  
  2616. self:CreateStats()
  2617. end
  2618.  
  2619. function Datatext:SetFontString(parent, file, size, flags)
  2620. local fs = parent:CreateFontString(nil, "OVERLAY")
  2621. fs:SetFont(file, size, flags)
  2622. fs:SetJustifyH("LEFT")
  2623. fs:SetShadowColor(0, 0, 0)
  2624. fs:SetShadowOffset(1.25, -1.25)
  2625. return fs
  2626. end
  2627.  
  2628. function Datatext:CreatePanel()
  2629.  
  2630. if Datapanel then return end -- already done
  2631.  
  2632. -- These are not "local" here because they're already "local" at the top of the file.
  2633. Datapanel = CreateFrame("Frame", "Datapanel", UIParent)
  2634. StatPanelLeft = CreateFrame("Frame", nil, Datapanel)
  2635. StatPanelCenter = CreateFrame("Frame", nil, Datapanel)
  2636. StatPanelRight = CreateFrame("Frame", nil, Datapanel)
  2637. BGPanel = CreateFrame("Frame", nil, Datapanel)
  2638.  
  2639.  
  2640. -- These are common to all panel styles, so don't duplicate code.
  2641. Datapanel:SetFrameLevel(1)
  2642. Datapanel:SetHeight(35)
  2643. Datapanel:SetFrameStrata("LOW")
  2644. Datapanel:SetBackdrop({ bgFile = BasicUI.media.background, edgeFile = BasicUI.media.panelborder, edgeSize = 25, insets = { left = 5, right = 5, top = 5, bottom = 5 } })
  2645. Datapanel:SetBackdropColor(0, 0, 0, 1)
  2646.  
  2647.  
  2648. -- Setup the Panels
  2649. self:SetDataPanel()
  2650. self:SetStatPanelLeft()
  2651. self:SetStatPanelCenter()
  2652. self:SetStatPanelRight()
  2653.  
  2654. -- No Need for function it always sets it self on the PanelLeft
  2655. BGPanel:SetAllPoints(StatPanelLeft)
  2656. BGPanel:SetFrameStrata("LOW")
  2657. BGPanel:SetFrameLevel(1)
  2658.  
  2659. -- Move some Objects for the Datapanel
  2660. --self:MoveObjects()
  2661.  
  2662. end
  2663.  
  2664.  
  2665. ------------------------------------------------------------------------
  2666. -- Module Options
  2667. ------------------------------------------------------------------------
  2668.  
  2669. local options
  2670. function Datatext:GetOptions()
  2671. if options then
  2672. return options
  2673. end
  2674.  
  2675. local function isModuleDisabled()
  2676. return not BasicUI:GetModuleEnabled(MODULE_NAME)
  2677. end
  2678.  
  2679. local statposition = {
  2680. ["P0"] = L["Not Shown"],
  2681. ["P1"] = L["Position #1"],
  2682. ["P2"] = L["Position #2"],
  2683. ["P3"] = L["Position #3"],
  2684. ["P4"] = L["Position #4"],
  2685. ["P5"] = L["Position #5"],
  2686. ["P6"] = L["Position #6"],
  2687. ["P7"] = L["Position #7"],
  2688. ["P8"] = L["Position #8"],
  2689. ["P9"] = L["Position #9"],
  2690. }
  2691.  
  2692. local locate = {
  2693. ['top'] = L['Top'],
  2694. ['bottom'] = L['Bottom'],
  2695. }
  2696.  
  2697. options = {
  2698. type = "group",
  2699. name = L[MODULE_NAME],
  2700. childGroups = "tree",
  2701. get = function(info) return db[ info[#info] ] end,
  2702. set = function(info, value) db[ info[#info] ] = value; end,
  2703. disabled = isModuleDisabled(),
  2704. args = {
  2705. ---------------------------
  2706. --Option Type Seperators
  2707. sep1 = {
  2708. type = "description",
  2709. order = 2,
  2710. name = " ",
  2711. },
  2712. sep2 = {
  2713. type = "description",
  2714. order = 3,
  2715. name = " ",
  2716. },
  2717. sep3 = {
  2718. type = "description",
  2719. order = 4,
  2720. name = " ",
  2721. },
  2722. sep4 = {
  2723. type = "description",
  2724. order = 5,
  2725. name = " ",
  2726. },
  2727. ---------------------------
  2728. reloadUI = {
  2729. type = "execute",
  2730. name = "Reload UI",
  2731. desc = " ",
  2732. order = 0,
  2733. func = function()
  2734. ReloadUI()
  2735. end,
  2736. },
  2737. Text = {
  2738. type = "description",
  2739. order = 0,
  2740. name = "When changes are made a reload of the UI is needed.",
  2741. width = "full",
  2742. },
  2743. Text1 = {
  2744. type = "description",
  2745. order = 1,
  2746. name = " ",
  2747. width = "full",
  2748. },
  2749. enable = {
  2750. type = "toggle",
  2751. order = 1,
  2752. name = L["Enable Datapanel Module"],
  2753. width = "full"
  2754. },
  2755. location = {
  2756. order = 3,
  2757. name = L["Location"],
  2758. desc = L["Choose the location of the datapanel."],
  2759. disabled = function() return isModuleDisabled() or not db.enable end,
  2760. type = "select",
  2761. values = locate;
  2762. },
  2763. time24 = {
  2764. type = "toggle",
  2765. order = 2,
  2766. name = L["24-Hour Time"],
  2767. desc = L["Display time datapanel on a 24 hour time scale"],
  2768. disabled = function() return isModuleDisabled() or not db.enable end,
  2769. },
  2770. bag = {
  2771. type = "toggle",
  2772. order = 2,
  2773. name = L["Bag Open"],
  2774. desc = L["Checked opens Backpack only, Unchecked opens all bags."],
  2775. disabled = function() return isModuleDisabled() or not db.enable end,
  2776. },
  2777. battleground = {
  2778. type = "toggle",
  2779. order = 2,
  2780. name = L["Battleground Text"],
  2781. desc = L["Display special datapanels when inside a battleground"],
  2782. disabled = function() return isModuleDisabled() or not db.enable end,
  2783. },
  2784. recountraiddps = {
  2785. type = "toggle",
  2786. order = 2,
  2787. name = L["Recount Raid DPS"],
  2788. desc = L["Display Recount's Raid DPS (RECOUNT MUST BE INSTALLED)"],
  2789. disabled = function() return isModuleDisabled() or not db.enable end,
  2790. },
  2791. DataGroup = {
  2792. type = "group",
  2793. order = 6,
  2794. name = L["Text Positions"],
  2795. guiInline = true,
  2796. disabled = function() return isModuleDisabled() or not db.enable end,
  2797. args = {
  2798. ---------------------------
  2799. --Option Type Seperators
  2800. sep1 = {
  2801. type = "description",
  2802. order = 2,
  2803. name = " ",
  2804. },
  2805. sep2 = {
  2806. type = "description",
  2807. order = 3,
  2808. name = " ",
  2809. },
  2810. sep3 = {
  2811. type = "description",
  2812. order = 4,
  2813. name = " ",
  2814. },
  2815. sep4 = {
  2816. type = "description",
  2817. order = 5,
  2818. name = " ",
  2819. },
  2820. ---------------------------
  2821. bags = {
  2822. type = "select",
  2823. order = 5,
  2824. name = L["Bags"],
  2825. desc = L["Display amount of bag space"],
  2826. values = statposition;
  2827. disabled = function() return isModuleDisabled() or not db.enable end,
  2828. },
  2829. calltoarms = {
  2830. type = "select",
  2831. order = 5,
  2832. name = L["Call to Arms"],
  2833. desc = L["Display the active roles that will recieve a reward for completing a random dungeon"],
  2834. values = statposition;
  2835. disabled = function() return isModuleDisabled() or not db.enable end,
  2836. },
  2837. coords = {
  2838. type = "select",
  2839. order = 5,
  2840. name = L["Coordinates"],
  2841. desc = L["Display Player's Coordinates"],
  2842. values = statposition;
  2843. disabled = function() return isModuleDisabled() or not db.enable end,
  2844. },
  2845. dps_text = {
  2846. type = "select",
  2847. order = 5,
  2848. name = L["DPS"],
  2849. desc = L["Display amount of DPS"],
  2850. values = statposition;
  2851. disabled = function() return isModuleDisabled() or not db.enable end,
  2852. },
  2853. dur = {
  2854. type = "select",
  2855. order = 5,
  2856. name = L["Durability"],
  2857. desc = L["Display your current durability"],
  2858. values = statposition;
  2859. disabled = function() return isModuleDisabled() or not db.enable end,
  2860. },
  2861. friends = {
  2862. type = "select",
  2863. order = 5,
  2864. name = L["Friends"],
  2865. desc = L["Display current online friends"],
  2866. values = statposition;
  2867. disabled = function() return isModuleDisabled() or not db.enable end,
  2868. },
  2869. guild = {
  2870. type = "select",
  2871. order = 5,
  2872. name = L["Guild"],
  2873. desc = L["Display current online people in guild"],
  2874. values = statposition;
  2875. disabled = function() return isModuleDisabled() or not db.enable end,
  2876. },
  2877. hps_text = {
  2878. type = "select",
  2879. order = 5,
  2880. name = L["HPS"],
  2881. desc = L["Display amount of HPS"],
  2882. values = statposition;
  2883. disabled = function() return isModuleDisabled() or not db.enable end,
  2884. },
  2885. pro = {
  2886. type = "select",
  2887. order = 5,
  2888. name = L["Professions"],
  2889. desc = L["Display Professions"],
  2890. values = statposition;
  2891. disabled = function() return isModuleDisabled() or not db.enable end,
  2892. },
  2893. recount = {
  2894. type = "select",
  2895. order = 5,
  2896. name = L["Recount"],
  2897. desc = L["Display Recount's DPS (RECOUNT MUST BE INSTALLED)"],
  2898. values = statposition;
  2899. disabled = function() return isModuleDisabled() or not db.enable end,
  2900. },
  2901. spec = {
  2902. type = "select",
  2903. order = 5,
  2904. name = L["Talent Spec"],
  2905. desc = L["Display current spec"],
  2906. values = statposition;
  2907. disabled = function() return isModuleDisabled() or not db.enable end,
  2908. },
  2909. stat1 = {
  2910. type = "select",
  2911. order = 5,
  2912. name = L["Stat #1"],
  2913. desc = L["Display stat based on your role (Avoidance-Tank, AP-Melee, SP/HP-Caster)"],
  2914. values = statposition;
  2915. disabled = function() return isModuleDisabled() or not db.enable end,
  2916. },
  2917. stat2 = {
  2918. type = "select",
  2919. order = 5,
  2920. name = L["Stat #2"],
  2921. desc = L["Display stat based on your role (Armor-Tank, Crit-Melee, Crit-Caster)"],
  2922. values = statposition;
  2923. disabled = function() return isModuleDisabled() or not db.enable end,
  2924. },
  2925. system = {
  2926. type = "select",
  2927. order = 5,
  2928. name = L["System"],
  2929. desc = L["Display FPS and Latency"],
  2930. values = statposition;
  2931. disabled = function() return isModuleDisabled() or not db.enable end,
  2932. },
  2933. },
  2934. },
  2935. },
  2936. }
  2937. return options
  2938. end
Add Comment
Please, Sign In to add comment