Advertisement
Guest User

Untitled

a guest
Jul 16th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.27 KB | None | 0 0
  1. local cData = LibStub("AceAddon-3.0"):NewAddon("cData", "AceEvent-3.0")
  2. --local Adjust = LibStub:GetLibrary("LibJostle-3.0", true)
  3. local L = setmetatable({}, { __index = function(t,k)
  4. local v = tostring(k)
  5. rawset(t, k, v)
  6. return v
  7. end })
  8.  
  9.  
  10. ------------------------------------------------------------------------
  11. -- cData Database
  12. ------------------------------------------------------------------------
  13. local db
  14. local defaults = {
  15. profile = {
  16. enable = true,
  17.  
  18. font = [[Fonts\FRIZQT__.ttf]],
  19. fontSize = 15,
  20.  
  21. battleground = true, -- enable 3 stats in battleground only that replace stat1,stat2,stat3.
  22. bag = false, -- True = Open Backpack; False = Open All bags
  23. classcolor = true,
  24. recountraiddps = false, -- Enables tracking or Recounts Raid DPS
  25.  
  26.  
  27. -- Color Datatext
  28. customcolor = { r = 1, g = 1, b = 1}, -- Color of Text for Datapanel
  29.  
  30. -- Stat Locations
  31. bags = "P9", -- show space used in bags on panel.
  32. system = "P1", -- show total memory and others systems info (FPS/MS) on panel.
  33. guild = "P4", -- show number on guildmate connected on panel.
  34. dur = "P8", -- show your equipment durability on panel.
  35. friends = "P6", -- show number of friends connected.
  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. stats = "P3", -- Stat Based on your Role (Avoidance-Tank, AP-Melee, SP/HP-Caster)
  40. recount = "P2", -- Stat Based on Recount"s DPS
  41. calltoarms = "P0", -- Show Current Call to Arms.
  42. }
  43. }
  44.  
  45. ------------------------------------------------------------------------
  46. -- Variables that point to frames or other objects:
  47. ------------------------------------------------------------------------
  48. local cDataMainPanel, cDataLeftStatPanel, cDataCenterStatPanel, cDataRightStatPanel, cDataBattleGroundStatPanel
  49. local currentFightDPS
  50. local _, class = UnitClass("player")
  51. local ccolor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  52.  
  53. ------------------------------------------------------------------------
  54. -- cData Functions
  55. ------------------------------------------------------------------------
  56.  
  57. function cData:CreatePanels()
  58. if cDataMainPanel then return end -- already done
  59.  
  60. -- Create All Panels
  61. ------------------------------------------------------------------------
  62. cDataMainPanel = CreateFrame("Frame", "cDataMainPanel", UIParent)
  63. cDataLeftStatPanel = CreateFrame("Frame", "cDataLeftStatPanel", cDataMainPanel)
  64. cDataCenterStatPanel = CreateFrame("Frame", "cDataCenterStatPanel", cDataMainPanel)
  65. cDataRightStatPanel = CreateFrame("Frame", "cDataRightStatPanel", cDataMainPanel)
  66. cDataBattleGroundStatPanel = CreateFrame("Frame", "cDataBattleGroundStatPanel", cDataMainPanel)
  67.  
  68.  
  69. -- Multi Panel Settings
  70. ------------------------------------------------------------------------
  71. for _, panelz in pairs({
  72. cDataMainPanel,
  73. cDataLeftStatPanel,
  74. cDataCenterStatPanel,
  75. cDataRightStatPanel,
  76. cDataBattleGroundStatPanel,
  77. }) do
  78. panelz:SetHeight(35)
  79. panelz:SetFrameStrata("LOW")
  80. panelz:SetFrameLevel(1)
  81. end
  82.  
  83. -- Main Panel Settings
  84. ------------------------------------------------------------------------
  85. cDataMainPanel:SetPoint("BOTTOM", UIParent, 0, -4)
  86. cDataMainPanel:SetWidth(1200)
  87. cDataMainPanel:SetBackdrop({
  88. bgFile = [[Interface\ChatFrame\ChatFrameBackground]],
  89. edgeFile = [[Interface\AddOns\cData\Media\UI-DialogBox-Border.blp]],
  90. edgeSize = 25, insets = { left = 5, right = 5, top = 5, bottom = 5 }
  91. })
  92. cDataMainPanel:SetBackdropColor(0, 0, 0, 1)
  93.  
  94.  
  95. -- Left Stat Panel Settings
  96. ------------------------------------------------------------------------
  97. cDataLeftStatPanel:SetPoint("LEFT", cDataMainPanel, 5, 0)
  98. cDataLeftStatPanel:SetWidth(1200 / 3)
  99. cDataLeftStatPanel:RegisterUnitEvent("PLAYER_ENTERING_WORLD")
  100. cDataLeftStatPanel:SetScript("OnEvent", function(self, event, ...)
  101. if event == 'PLAYER_ENTERING_WORLD' then
  102. local inInstance, instanceType = IsInInstance()
  103. if inInstance and (instanceType == 'pvp') then
  104. self:Hide()
  105. else
  106. self:Show()
  107. end
  108. end
  109. end)
  110.  
  111. -- Center Stat Panel Settings
  112. -----------------------------------------------------------------------
  113. cDataCenterStatPanel:SetPoint("CENTER", cDataMainPanel, 0, 0)
  114. cDataCenterStatPanel:SetWidth(1200 / 3)
  115.  
  116. -- Right Stat Panel Settings
  117. -----------------------------------------------------------------------
  118. cDataRightStatPanel:SetPoint("RIGHT", cDataMainPanel, -5, 0)
  119. cDataRightStatPanel:SetWidth(1200 / 3)
  120.  
  121. -- Battleground Stat Panel Settings
  122. -----------------------------------------------------------------------
  123. cDataBattleGroundStatPanel:SetAllPoints(cDataLeftStatPanel)
  124.  
  125. -- Hide Panels When in a Vehicle or Pet Battle
  126. ------------------------------------------------------------------------
  127.  
  128. cDataMainPanel:RegisterEvent("UNIT_ENTERING_VEHICLE")
  129. cDataMainPanel:RegisterEvent("UNIT_ENTERED_VEHICLE")
  130. cDataMainPanel:RegisterEvent("UNIT_EXITING_VEHICLE")
  131. cDataMainPanel:RegisterEvent("UNIT_EXITED_VEHICLE")
  132. cDataMainPanel:RegisterEvent("PET_BATTLE_OPENING_DONE")
  133. cDataMainPanel:RegisterEvent("PET_BATTLE_CLOSE")
  134. cDataMainPanel:RegisterEvent("PLAYER_ENTERING_WORLD")
  135.  
  136. cDataMainPanel:SetScript("OnEvent", function(self, event, ...)
  137. if event == "UNIT_EXITED_VEHICLE" or event == "PET_BATTLE_CLOSE" or event == "PLAYER_ENTERING_WORLD" then
  138. if not InCombatLockdown() then
  139. local cPanelShow = function() end
  140. MainMenuBar:ClearAllPoints()
  141. MainMenuBar:SetPoint("BOTTOM",cDataMainPanel,"TOP",0,-4)
  142. MainMenuBar.ClearAllPoints = cPanelShow
  143. MainMenuBar.SetPoint = cPanelShow
  144.  
  145. OverrideActionBar:ClearAllPoints()
  146. OverrideActionBar:SetPoint("BOTTOM",cDataMainPanel,"TOP",0,8)
  147. OverrideActionBar.ClearAllPoints = cPanelShow
  148. OverrideActionBar.SetPoint = cPanelShow
  149. end
  150. self:Show()
  151. elseif event == "UNIT_ENTERED_VEHICLE" or event == "PET_BATTLE_OPENING_DONE" then
  152. if not InCombatLockdown() then
  153. self:Hide()
  154. end
  155. end
  156. end)
  157.  
  158. if UnitInVehicle("player") then
  159. return OverrideActionBar:SetPoint("BOTTOM",UIParent)
  160. end
  161.  
  162. end
  163.  
  164. function cData:SetBattlegroundPanel()
  165.  
  166. --WoW API / Variables
  167. local GetNumBattlefieldScores = GetNumBattlefieldScores
  168. local GetBattlefieldScore = GetBattlefieldScore
  169. local GetCurrentMapAreaID = GetCurrentMapAreaID
  170. local GetBattlefieldStatInfo = GetBattlefieldStatInfo
  171. local GetBattlefieldStatData = GetBattlefieldStatData
  172.  
  173. --Map IDs
  174. local WSG = 443
  175. local TP = 626
  176. local AV = 401
  177. local SOTA = 512
  178. local IOC = 540
  179. local EOTS = 482
  180. local TBFG = 736
  181. local AB = 461
  182. local TOK = 856
  183. local SSM = 860
  184. local DG = 935
  185.  
  186. cDataBattleGroundStatPanel:SetScript('OnEnter', function(self)
  187.  
  188. local CurrentMapID = GetCurrentMapAreaID()
  189. for index=1, GetNumBattlefieldScores() do
  190. name = GetBattlefieldScore(index)
  191. if name then
  192. GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 0, 4)
  193. GameTooltip:ClearLines()
  194. GameTooltip:SetPoint('BOTTOM', self, 'TOP', 0, 1)
  195. GameTooltip:ClearLines()
  196. GameTooltip:AddLine("Stats for : "..hexa..name..hexb)
  197. GameTooltip:AddLine(" ")
  198.  
  199. --Add extra statistics to watch based on what BG you are in.
  200. if CurrentMapID == WSG or CurrentMapID == TP then
  201. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(1), GetBattlefieldStatData(index, 1),1,1,1)
  202. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(2), GetBattlefieldStatData(index, 2),1,1,1)
  203. elseif CurrentMapID == EOTS then
  204. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(1), GetBattlefieldStatData(index, 1),1,1,1)
  205. elseif CurrentMapID == AV then
  206. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(1), GetBattlefieldStatData(index, 1),1,1,1)
  207. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(2), GetBattlefieldStatData(index, 2),1,1,1)
  208. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(3), GetBattlefieldStatData(index, 3),1,1,1)
  209. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(4), GetBattlefieldStatData(index, 4),1,1,1)
  210. elseif CurrentMapID == SOTA then
  211. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(1), GetBattlefieldStatData(index, 1),1,1,1)
  212. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(2), GetBattlefieldStatData(index, 2),1,1,1)
  213. elseif CurrentMapID == IOC or CurrentMapID == TBFG or CurrentMapID == AB then
  214. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(1), GetBattlefieldStatData(index, 1),1,1,1)
  215. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(2), GetBattlefieldStatData(index, 2),1,1,1)
  216. elseif CurrentMapID == TOK then
  217. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(1), GetBattlefieldStatData(index, 1),1,1,1)
  218. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(2), GetBattlefieldStatData(index, 2),1,1,1)
  219. elseif CurrentMapID == SSM then
  220. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(1), GetBattlefieldStatData(index, 1),1,1,1)
  221. elseif CurrentMapID == DG then
  222. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(1), GetBattlefieldStatData(index, 1),1,1,1)
  223. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(2), GetBattlefieldStatData(index, 2),1,1,1)
  224. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(3), GetBattlefieldStatData(index, 3),1,1,1)
  225. GameTooltip:AddDoubleLine(GetBattlefieldStatInfo(4), GetBattlefieldStatData(index, 4),1,1,1)
  226. end
  227. break
  228. end
  229. end
  230. end)
  231. cDataBattleGroundStatPanel:SetScript('OnLeave', function(self) GameTooltip:Hide() end)
  232.  
  233. local f = CreateFrame('Frame', nil)
  234. f:EnableMouse(true)
  235.  
  236. local Text1 = cDataBattleGroundStatPanel:CreateFontString(nil, 'OVERLAY')
  237. Text1:SetFont(db.font, db.fontSize,'THINOUTLINE')
  238. Text1:SetPoint('LEFT', cDataBattleGroundStatPanel, 30, 0)
  239. Text1:SetHeight(cDataMainPanel:GetHeight())
  240.  
  241. local Text2 = cDataBattleGroundStatPanel:CreateFontString(nil, 'OVERLAY')
  242. Text2:SetFont(db.font, db.fontSize,'THINOUTLINE')
  243. Text2:SetPoint('CENTER', cDataBattleGroundStatPanel, 0, 0)
  244. Text2:SetHeight(cDataMainPanel:GetHeight())
  245.  
  246. local Text3 = cDataBattleGroundStatPanel:CreateFontString(nil, 'OVERLAY')
  247. Text3:SetFont(db.font, db.fontSize,'THINOUTLINE')
  248. Text3:SetPoint('RIGHT', cDataBattleGroundStatPanel, -30, 0)
  249. Text3:SetHeight(cDataMainPanel:GetHeight())
  250.  
  251. local int = 2
  252. local function Update(self, t)
  253. int = int - t
  254. if int < 0 then
  255. local dmgtxt
  256. RequestBattlefieldScoreData()
  257. local numScores = GetNumBattlefieldScores()
  258. for i=1, numScores do
  259. local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange = GetBattlefieldScore(i)
  260. if healingDone > damageDone then
  261. dmgtxt = (hexa.."Healing : "..hexb..healingDone)
  262. else
  263. dmgtxt = (hexa.."Damage : "..hexb..damageDone)
  264. end
  265. if ( name ) then
  266. if ( name == PLAYER_NAME ) then
  267. Text2:SetText(hexa.."Honor : "..hexb..format('%d', honorGained))
  268. Text1:SetText(dmgtxt)
  269. Text3:SetText(hexa.."Killing Blows : "..hexb..killingBlows)
  270. end
  271. end
  272. end
  273. int = 0
  274. end
  275. end
  276.  
  277. --hide text when not in an bg
  278. local function OnEvent(self, event)
  279. if event == 'PLAYER_ENTERING_WORLD' then
  280. local inInstance, instanceType = IsInInstance()
  281. if inInstance and (instanceType == 'pvp') then
  282. cDataBattleGroundStatPanel:Show()
  283. else
  284. Text1:SetText('')
  285. Text2:SetText('')
  286. Text3:SetText('')
  287. cDataBattleGroundStatPanel:Hide()
  288. end
  289. end
  290. end
  291.  
  292. f:RegisterEvent('PLAYER_ENTERING_WORLD')
  293. f:SetScript('OnEvent', OnEvent)
  294. f:SetScript('OnUpdate', Update)
  295. Update(f, 10)
  296. end
  297.  
  298. function cData:PlacePlugin(position, plugin)
  299. local left = cDataLeftStatPanel
  300. local center = cDataCenterStatPanel
  301. local right = cDataRightStatPanel
  302.  
  303. -- Left Panel Data
  304. if position == "P1" then
  305. plugin:SetParent(left)
  306. plugin:SetHeight(left:GetHeight())
  307. plugin:SetPoint('LEFT', left, 30, 0)
  308. plugin:SetPoint('TOP', left)
  309. plugin:SetPoint('BOTTOM', left)
  310. elseif position == "P2" then
  311. plugin:SetParent(left)
  312. plugin:SetHeight(left:GetHeight())
  313. plugin:SetPoint('TOP', left)
  314. plugin:SetPoint('BOTTOM', left)
  315. elseif position == "P3" then
  316. plugin:SetParent(left)
  317. plugin:SetHeight(left:GetHeight())
  318. plugin:SetPoint('RIGHT', left, -30, 0)
  319. plugin:SetPoint('TOP', left)
  320. plugin:SetPoint('BOTTOM', left)
  321.  
  322. -- Center Panel Data
  323. elseif position == "P4" then
  324. plugin:SetParent(center)
  325. plugin:SetHeight(center:GetHeight())
  326. plugin:SetPoint('LEFT', center, 30, 0)
  327. plugin:SetPoint('TOP', center)
  328. plugin:SetPoint('BOTTOM', center)
  329. elseif position == "P5" then
  330. plugin:SetParent(center)
  331. plugin:SetHeight(center:GetHeight())
  332. plugin:SetPoint('TOP', center)
  333. plugin:SetPoint('BOTTOM', center)
  334. elseif position == "P6" then
  335. plugin:SetParent(center)
  336. plugin:SetHeight(center:GetHeight())
  337. plugin:SetPoint('RIGHT', center, -30, 0)
  338. plugin:SetPoint('TOP', center)
  339. plugin:SetPoint('BOTTOM', center)
  340.  
  341. -- Right Panel Data
  342. elseif position == "P7" then
  343. plugin:SetParent(right)
  344. plugin:SetHeight(right:GetHeight())
  345. plugin:SetPoint('LEFT', right, 30, 0)
  346. plugin:SetPoint('TOP', right)
  347. plugin:SetPoint('BOTTOM', right)
  348. elseif position == "P8" then
  349. plugin:SetParent(right)
  350. plugin:SetHeight(right:GetHeight())
  351. plugin:SetPoint('TOP', right)
  352. plugin:SetPoint('BOTTOM', right)
  353. elseif position == "P9" then
  354. plugin:SetParent(right)
  355. plugin:SetHeight(right:GetHeight())
  356. plugin:SetPoint('RIGHT', right, -30, 0)
  357. plugin:SetPoint('TOP', right)
  358. plugin:SetPoint('BOTTOM', right)
  359. elseif position == "P0" then
  360. return
  361. end
  362. end
  363.  
  364. function cData:DataTextTooltipAnchor(self)
  365. local panel = self:GetParent()
  366. local anchor = 'GameTooltip'
  367. local xoff = 1
  368. local yoff = 3
  369.  
  370.  
  371. for _, panel in pairs ({
  372. cDataLeftStatPanel,
  373. cDataCenterStatPanel,
  374. cDataRightStatPanel,
  375. }) do
  376. anchor = 'ANCHOR_TOP'
  377. end
  378. return anchor, panel, xoff, yoff
  379. end
  380.  
  381.  
  382. function cData:OnInitialize()
  383. -- Assuming the .toc says ## SavedVariables: MyAddonDB
  384. self.db = LibStub("AceDB-3.0"):New("cDataDB", defaults, true)
  385. db = self.db.profile
  386.  
  387. if not db.enable then return end
  388.  
  389. self:SetUpOptions();
  390. self:CreatePanels(); -- factor this giant blob out into its own function to keep things clean
  391. self:SetBattlegroundPanel();
  392.  
  393. SlashCmdList['RELOADUI'] = function()
  394. ReloadUI()
  395. end
  396. SLASH_RELOADUI1 = '/rl'
  397. end
  398.  
  399. function cData:OnEnable()
  400.  
  401. local db = self.db.profile
  402. PLAYER_NAME = UnitName("player")
  403.  
  404. if db.classcolor ~= true then
  405. local r, g, b = db.customcolor.r, db.customcolor.g, db.customcolor.b
  406. hexa = ("|cff%.2x%.2x%.2x"):format(r * 255, g * 255, b * 255)
  407. hexb = "|r"
  408. else
  409. hexa = ("|cff%.2x%.2x%.2x"):format(ccolor.r * 255, ccolor.g * 255, ccolor.b * 255)
  410. hexb = "|r"
  411. end
  412.  
  413. -- Rather than hardcode all the possible plugins here just use a nice table that you can add/remove stuff to much more easily. Scroll to the bottom to see it.
  414. self.plugins = {}
  415. for name, constructor in pairs(self.pluginConstructors) do
  416. local position = db[name]
  417. if position then
  418. local plugin = constructor()
  419. self.plugins[name] = plugin
  420. self:PlacePlugin(position, plugin)
  421. end
  422. end
  423.  
  424. -- Move the tooltip above the Actionbar
  425. hooksecurefunc('GameTooltip_SetDefaultAnchor', function(self)
  426. self:SetPoint('BOTTOMRIGHT', UIParent, -95, 135)
  427. end)
  428.  
  429. -- no need to make a separate frame to handle events, your module object already does this!
  430. self:UpdatePlayerRole()
  431. self:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED", "UpdatePlayerRole")
  432. self:Refresh()
  433. end
  434.  
  435. function cData:Refresh()
  436. db = self.db.profile
  437.  
  438. if InCombatLockdown() then
  439. return self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnEnable")
  440. end
  441. self:UnregisterEvent("PLAYER_REGEN_ENABLED")
  442. end
  443.  
  444. function cData:SetFontString(parent, file, size, flags)
  445. local fs = parent:CreateFontString(nil, "OVERLAY")
  446. fs:SetFont(file, size, flags)
  447. fs:SetJustifyH("LEFT")
  448. fs:SetShadowColor(0, 0, 0)
  449. fs:SetShadowOffset(1.25, -1.25)
  450. return fs
  451. end
  452.  
  453. local isCaster = {
  454. -- All Classes are needed as to not cause a error when the table is called.
  455. -- SpecID - Spec - Role
  456. DEATHKNIGHT = {
  457. nil, -- 250 - Blood - (TANK)
  458. nil, -- 251 - Frost - (MELEE_DPS)
  459. nil, -- 252 - Unholy - (MELEE_DPS)
  460. },
  461. DEMONHUNTER = {
  462. nil, -- 577 - Havoc - (TANK)
  463. nil, -- 581 - Vengeance - (MELEE_DPS)
  464. },
  465. DRUID = {
  466. true, -- 102 - Balance - (CASTER_DPS)
  467. nil, -- 103 - Feral - (MELEE_DPS)
  468. nil, -- 104 Guardian - (TANK)
  469. nil, -- 105 Restoration - (HEALER)
  470. },
  471. HUNTER = {
  472. nil, -- 253 - Beast Mastery - (RANGED_DPS)
  473. nil, -- 254 - Marksmanship - (RANGED_DPS)
  474. nil, -- 255 - Survival - (RANGED_DPS)
  475. },
  476. MAGE = {
  477. true, -- 62 - Arcane - (CASTER_DPS)
  478. true, -- 63 - Fire - (CASTER_DPS)
  479. true, -- 64 - Frost - (CASTER_DPS)
  480. },
  481. MONK = {
  482. nil, -- 268 - Brewmaster - (TANK)
  483. nil, -- 269 - Windwalker - (MELEE_DPS)
  484. nil, -- 270 - Mistweaver - (HEALER)
  485. },
  486. PALADIN = {
  487. nil, -- 65 - Holy - (HEALER)
  488. nil, -- 66 - Protection - (TANK)
  489. nil, -- 70 - Retribution - (MELEE_DPS)
  490. },
  491. PRIEST = {
  492. nil, -- 256 - Discipline - (HEALER}
  493. nil, -- 257 - Holy - (HEALER)
  494. true, -- 258 - Shadow - (CASTER_DPS)
  495. },
  496. ROGUE = {
  497. nil, -- 259 - Assassination - (MELEE_DPS)
  498. nil, -- 260 - Combat - (MELEE_DPS)
  499. nil, -- 261 - Subtlety - (MELEE_DPS)
  500. },
  501. SHAMAN = {
  502. true, -- 262 - Elemental - (CASTER_DPS)
  503. nil, -- 263 - Enhancement - (MELEE_DPS)
  504. nil, -- 264 - Restoration - (HEALER)
  505. },
  506. WARLOCK = {
  507. true, -- 265 - Affliction - (CASTER_DPS)
  508. true, -- 266 - Demonology - (CASTER_DPS)
  509. true, -- 267 - Destruction - (CASTER_DPS)
  510. },
  511. WARRIOR = {
  512. nil, -- 71 - Arms - (MELEE_DPS)
  513. nil, -- 72 - Furry - (MELEE_DPS)
  514. nil, -- 73 - Protection - (TANK)
  515. },
  516. }
  517.  
  518. function cData:UpdatePlayerRole()
  519. local spec = GetSpecialization()
  520. if not spec then
  521. self.playerRole = nil
  522. return
  523. end
  524.  
  525. local specRole = GetSpecializationRole(spec)
  526. if specRole == "DAMAGER" then
  527. if isCaster[class][spec] then
  528. self.playerRole = "CASTER"
  529. return
  530. end
  531. end
  532.  
  533. self.playerRole = specRole
  534. end
  535.  
  536. function cData:SetUpOptions()
  537. local options = self:GetOptions()
  538.  
  539. -- @PHANX: add this to your options table instead of registering it separately:
  540. options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
  541.  
  542. LibStub("AceConfig-3.0"):RegisterOptionsTable("cData", options)
  543.  
  544. -- @PHANX: You could write out each subkey but let's be lazy:
  545. local panels = {}
  546.  
  547. local Dialog = LibStub("AceConfigDialog-3.0")
  548.  
  549. -- Use the "welcome" panel as the main one:
  550. self.optionsFrame = Dialog:AddToBlizOptions("cData", "cData", nil, "datatext")
  551.  
  552. -- Add the profile panel last:
  553. Dialog:AddToBlizOptions("cData", options.args.profile.name, "cData", "profile")
  554.  
  555. end
  556.  
  557. ------------------------------------------------------------------------
  558. -- Stat Creation
  559. ------------------------------------------------------------------------
  560. -- This can be simplified hugely by using a table, instead of a bunch of if/end blocks.
  561.  
  562. cData.pluginConstructors = {}
  563.  
  564. ------------------------------------------------------------------------
  565. -- cData Options
  566. ------------------------------------------------------------------------
  567.  
  568. local options
  569. function cData:GetOptions()
  570. if options then
  571. return options
  572. end
  573.  
  574. local statposition = {
  575. ["P0"] = L["Not Shown"],
  576. ["P1"] = L["Position #1"],
  577. ["P2"] = L["Position #2"],
  578. ["P3"] = L["Position #3"],
  579. ["P4"] = L["Position #4"],
  580. ["P5"] = L["Position #5"],
  581. ["P6"] = L["Position #6"],
  582. ["P7"] = L["Position #7"],
  583. ["P8"] = L["Position #8"],
  584. ["P9"] = L["Position #9"],
  585. }
  586.  
  587. options = {
  588. type = "group",
  589. name = L["cData"],
  590. childGroups = "tree",
  591. get = function(info) return db[ info[#info] ] end,
  592. set = function(info, value) db[ info[#info] ] = value; end,
  593. args = {
  594. datatext = {
  595. type = "group",
  596. order = 1,
  597. name = "cData",
  598. args = {
  599. reloadUI = {
  600. type = "execute",
  601. name = "Reload UI",
  602. desc = " ",
  603. order = 0,
  604. func = function()
  605. ReloadUI()
  606. end,
  607. },
  608. Text = {
  609. type = "description",
  610. order = 0,
  611. name = "When changes are made a reload of the UI is needed.",
  612. width = "full",
  613. },
  614. Text1 = {
  615. type = "description",
  616. order = 1,
  617. name = " ",
  618. width = "full",
  619. },
  620. bag = {
  621. type = "toggle",
  622. order = 2,
  623. name = L["Bag Open"],
  624. desc = L["Checked opens Backpack only, Unchecked opens all bags."],
  625. disabled = function() return not db.enable end,
  626. },
  627. battleground = {
  628. type = "toggle",
  629. order = 2,
  630. name = L["Battleground Text"],
  631. desc = L["Display special datapanels when inside a battleground"],
  632. disabled = function() return not db.enable end,
  633. },
  634. recountraiddps = {
  635. type = "toggle",
  636. order = 2,
  637. name = L["Recount Raid DPS"],
  638. desc = L["Display Recount's Raid DPS (RECOUNT MUST BE INSTALLED)"],
  639. disabled = function() return not db.enable end,
  640. },
  641. fontSize = {
  642. type = "range",
  643. order = 5,
  644. name = L["Stat Font Size"],
  645. desc = L["Controls the Size of the Stat Font"],
  646. disabled = function() return not db.enable end,
  647. min = 0, max = 30, step = 1,
  648. },
  649. classcolor = {
  650. type = "toggle",
  651. order = 2,
  652. name = L["Class Color"],
  653. desc = L["Use your classcolor for border and some text color."],
  654. disabled = function() return not db.enable end,
  655. },
  656. DataGroup = {
  657. type = "group",
  658. order = 6,
  659. name = L["Stat Positions"],
  660. guiInline = true,
  661. disabled = function() return not db.enable end,
  662. args = {
  663. bags = {
  664. type = "select",
  665. name = L["Bags"],
  666. desc = L["Display amount of bag space"],
  667. values = statposition;
  668. disabled = function() return not db.enable end,
  669. },
  670. calltoarms = {
  671. type = "select",
  672. name = L["Call to Arms"],
  673. desc = L["Display the active roles that will recieve a reward for completing a random dungeon"],
  674. values = statposition;
  675. disabled = function() return not db.enable end,
  676. },
  677. coords = {
  678. type = "select",
  679. name = L["Coordinates"],
  680. desc = L["Display Player's Coordinates"],
  681. values = statposition;
  682. disabled = function() return not db.enable end,
  683. },
  684. dur = {
  685. type = "select",
  686. name = L["Durability"],
  687. desc = L["Display your current durability"],
  688. values = statposition;
  689. disabled = function() return not db.enable end,
  690. },
  691. friends = {
  692. type = "select",
  693. name = L["Friends"],
  694. desc = L["Display current online friends"],
  695. values = statposition;
  696. disabled = function() return not db.enable end,
  697. },
  698. guild = {
  699. type = "select",
  700. name = L["Guild"],
  701. desc = L["Display current online people in guild"],
  702. values = statposition;
  703. disabled = function() return not db.enable end,
  704. },
  705. pro = {
  706. type = "select",
  707. name = L["Professions"],
  708. desc = L["Display Professions"],
  709. values = statposition;
  710. disabled = function() return not db.enable end,
  711. },
  712. recount = {
  713. type = "select",
  714. name = L["Recount"],
  715. desc = L["Display Recount's DPS (RECOUNT MUST BE INSTALLED)"],
  716. values = statposition;
  717. disabled = function() return not db.enable end,
  718. },
  719. spec = {
  720. type = "select",
  721. name = L["Talent Spec"],
  722. desc = L["Display current spec"],
  723. values = statposition;
  724. disabled = function() return not db.enable end,
  725. },
  726. stats = {
  727. type = "select",
  728. name = L["Statistics"],
  729. desc = L["Display stat based on your role (Avoidance-Tank, AP-Melee, SP/HP-Caster)"],
  730. values = statposition;
  731. disabled = function() return not db.enable end,
  732. },
  733. system = {
  734. type = "select",
  735. name = L["System"],
  736. desc = L["Display FPS and Latency"],
  737. values = statposition;
  738. disabled = function() return not db.enable end,
  739. },
  740. },
  741. },
  742. },
  743. },
  744. },
  745. }
  746. return options
  747. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement