Advertisement
Guest User

Powerbar.lua

a guest
Apr 27th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.26 KB | None | 0 0
  1. local MODULE_NAME = "Powerbar"
  2. local ADDON_NAME = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
  3. local MODULE = ADDON_NAME:NewModule(MODULE_NAME, "AceEvent-3.0")
  4. local L = setmetatable({}, { __index = function(t,k)
  5. local v = tostring(k)
  6. rawset(t, k, v)
  7. return v
  8. end })
  9.  
  10. ------------------------------------------------------------------------
  11. -- Module Database
  12. ------------------------------------------------------------------------
  13.  
  14. local BASIC_BACKGROUND = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]]
  15. local BASIC_STATUSBAR = [[Interface\TargetingFrame\UI-StatusBar]]
  16.  
  17. local db
  18. local defaults = {
  19. profile = {
  20. enable = true,
  21. background = BASIC_BACKGROUND,
  22. statusbar = BASIC_STATUSBAR,
  23. position = {
  24. selfAnchor = "CENTER",
  25. frameParent = "UIParent",
  26. offSetX = 0,
  27. offSetY = -100
  28. },
  29. sizeWidth = 200,
  30.  
  31. showCombatRegen = true,
  32.  
  33. activeAlpha = 1,
  34. inactiveAlpha = 0.5,
  35. emptyAlpha = 0,
  36.  
  37. valueAbbrev = true,
  38.  
  39. valueFontSize = 20,
  40. valueFontOutline = true,
  41. valueFontAdjustmentX = 0,
  42.  
  43. showSoulshards = true,
  44. showHolypower = true,
  45. showMana = true,
  46. showFocus = true,
  47. showRage = true,
  48.  
  49. extraFontSize = 16, -- The fontsize for the holypower and soulshard number
  50. extraFontOutline = true,
  51.  
  52.  
  53. energy = {
  54. show = true,
  55. showComboPoints = true,
  56. comboPointsBelow = false,
  57.  
  58. comboFontSize = 16,
  59. comboFontOutline = true,
  60. },
  61.  
  62.  
  63. rune = {
  64. show = true,
  65. showRuneCooldown = true,
  66.  
  67. runeFontSize = 16,
  68. runeFontOutline = true,
  69. },
  70. }
  71. }
  72.  
  73. ------------------------------------------------------------------------
  74. -- Module Functions
  75. ------------------------------------------------------------------------
  76.  
  77. function MODULE:OnInitialize()
  78. self.db = ADDON_NAME.db:RegisterNamespace(MODULE_NAME, defaults)
  79. db = self.db.profile
  80.  
  81. local _, class = UnitClass("player")
  82. classColor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  83.  
  84. self:SetEnabledState(ADDON_NAME:GetModuleEnabled(MODULE_NAME))
  85. end
  86.  
  87.  
  88. function MODULE:OnEnable()
  89. if db.enable ~= true then return end
  90.  
  91. local playerClass = select(2, UnitClass('player'))
  92.  
  93. local format = string.format
  94. local floor = math.floor
  95.  
  96. function FormatValue(self)
  97. if (self >= 10000) then
  98. return ('%.1fk'):format(self / 1e3)
  99. else
  100. return self
  101. end
  102. end
  103.  
  104. function Round(num, idp)
  105. local mult = 10^(idp or 0)
  106. return floor(num * mult + 0.5) / mult
  107. end
  108.  
  109. function Fade(frame, timeToFade, startAlpha, endAlpha)
  110. if (Round(frame:GetAlpha(), 1) ~= endAlpha) then
  111. local mode = startAlpha > endAlpha and 'In' or 'Out'
  112. securecall('UIFrameFade'..mode, frame, timeToFade, startAlpha, endAlpha)
  113. end
  114. end
  115.  
  116. local ComboColor = {
  117. [1] = {r = 1.0, g = 1.0, b = 1.0},
  118. [2] = {r = 1.0, g = 1.0, b = 1.0},
  119. [3] = {r = 1.0, g = 1.0, b = 1.0},
  120. [4] = {r = 0.9, g = 0.7, b = 0.0},
  121. [5] = {r = 1.0, g = 0.0, b = 0.0},
  122. }
  123. local RuneColor = {
  124. [1] = {r = 0.7, g = 0.1, b = 0.1},
  125. [2] = {r = 0.7, g = 0.1, b = 0.1},
  126. [3] = {r = 0.4, g = 0.8, b = 0.2},
  127. [4] = {r = 0.4, g = 0.8, b = 0.2},
  128. [5] = {r = 0.0, g = 0.6, b = 0.8},
  129. [6] = {r = 0.0, g = 0.6, b = 0.8},
  130. }
  131.  
  132. local f = CreateFrame('Frame', nil, UIParent)
  133. f:SetScale(1.4)
  134. f:SetSize(18, 18)
  135. f:SetPoint(db.position.selfAnchor, db.position.frameParent, db.position.offSetX, db.position.offSetY)
  136. f:EnableMouse(false)
  137.  
  138. f:RegisterEvent('PLAYER_REGEN_ENABLED')
  139. f:RegisterEvent('PLAYER_REGEN_DISABLED')
  140. f:RegisterEvent('PLAYER_ENTERING_WORLD')
  141. f:RegisterUnitEvent('UNIT_COMBO_POINTS', 'player')
  142. f:RegisterEvent('PLAYER_TARGET_CHANGED')
  143.  
  144. if (db.rune.showRuneCooldown) then
  145. f:RegisterEvent('RUNE_TYPE_UPDATE')
  146. end
  147.  
  148. f:RegisterUnitEvent('UNIT_DISPLAYPOWER', 'player')
  149. f:RegisterUnitEvent('UNIT_POWER_FREQUENT', 'player')
  150. f:RegisterEvent('UPDATE_SHAPESHIFT_FORM')
  151.  
  152. if (db.showCombatRegen) then
  153. f:RegisterUnitEvent('UNIT_AURA', 'player')
  154. end
  155.  
  156. f:RegisterUnitEvent('UNIT_ENTERED_VEHICLE', 'player')
  157. f:RegisterUnitEvent('UNIT_ENTERING_VEHICLE', 'player')
  158. f:RegisterUnitEvent('UNIT_EXITED_VEHICLE', 'player')
  159. f:RegisterUnitEvent('UNIT_EXITING_VEHICLE', 'player')
  160.  
  161. if (db.energy.showComboPoints) then
  162. f.ComboPoints = {}
  163.  
  164. for i = 1, 5 do
  165. f.ComboPoints[i] = f:CreateFontString(nil, 'ARTWORK')
  166.  
  167. if (db.energy.comboFontOutline) then
  168. f.ComboPoints[i]:SetFont(ADDON_NAME.db.profile.media.fontBold, db.energy.comboFontSize, 'THINOUTLINE')
  169. f.ComboPoints[i]:SetShadowOffset(0, 0)
  170. else
  171. f.ComboPoints[i]:SetFont(ADDON_NAME.db.profile.media.fontBold, db.energy.comboFontSize)
  172. f.ComboPoints[i]:SetShadowOffset(1, -1)
  173. end
  174.  
  175. f.ComboPoints[i]:SetParent(f)
  176. f.ComboPoints[i]:SetText(i)
  177. f.ComboPoints[i]:SetAlpha(0)
  178. end
  179.  
  180. local yOffset = db.energy.comboPointsBelow and -35 or 0
  181. f.ComboPoints[1]:SetPoint('CENTER', -52, yOffset)
  182. f.ComboPoints[2]:SetPoint('CENTER', -26, yOffset)
  183. f.ComboPoints[3]:SetPoint('CENTER', 0, yOffset)
  184. f.ComboPoints[4]:SetPoint('CENTER', 26, yOffset)
  185. f.ComboPoints[5]:SetPoint('CENTER', 52, yOffset)
  186. end
  187.  
  188. if (playerClass == 'MONK') then
  189. f.Chi = {}
  190. f.Chi.maxChi = 4
  191.  
  192. for i = 1, 5 do
  193. f.Chi[i] = f:CreateFontString(nil, 'ARTWORK')
  194.  
  195. f.Chi[i]:SetFont(ADDON_NAME.db.profile.media.fontBold, db.energy.comboFontSize, 'THINOUTLINE')
  196. f.Chi[i]:SetShadowOffset(0, 0)
  197.  
  198. f.Chi[i]:SetParent(f)
  199. f.Chi[i]:SetText(i)
  200. f.Chi[i]:SetAlpha(0)
  201. end
  202.  
  203. local yOffset = db.energy.comboPointsBelow and -35 or 0
  204. f.Chi[1]:SetPoint('CENTER', -39, yOffset)
  205. f.Chi[2]:SetPoint('CENTER', -13, yOffset)
  206. f.Chi[3]:SetPoint('CENTER', 13, yOffset)
  207. f.Chi[4]:SetPoint('CENTER', 39, yOffset)
  208. f.Chi[5]:SetPoint('CENTER', 52, yOffset)
  209. f.Chi[5]:Hide()
  210. end
  211.  
  212. if (playerClass == 'WARLOCK' and db.showSoulshards or playerClass == 'PALADIN' and db.showHolypower or playerClass == 'PRIEST' and db.showShadowOrbs) then
  213. f.extraPoints = f:CreateFontString(nil, 'ARTWORK')
  214.  
  215. if (db.extraFontOutline) then
  216. f.extraPoints:SetFont(ADDON_NAME.db.profile.media.fontBold, db.extraFontSize, 'THINOUTLINE')
  217. f.extraPoints:SetShadowOffset(0, 0)
  218. else
  219. f.extraPoints:SetFont(ADDON_NAME.db.profile.media.fontBold, db.extraFontSize)
  220. f.extraPoints:SetShadowOffset(1, -1)
  221. end
  222.  
  223. f.extraPoints:SetParent(f)
  224. f.extraPoints:SetPoint('CENTER', 0, 0)
  225. end
  226.  
  227. if (playerClass == 'DEATHKNIGHT' and db.rune.showRuneCooldown) then
  228. for i = 1, 6 do
  229. RuneFrame:UnregisterAllEvents()
  230. _G['RuneButtonIndividual'..i]:Hide()
  231. end
  232.  
  233. f.Rune = {}
  234.  
  235. for i = 1, 6 do
  236. f.Rune[i] = f:CreateFontString(nil, 'ARTWORK')
  237.  
  238. if (db.rune.runeFontOutline) then
  239. f.Rune[i]:SetFont(ADDON_NAME.db.profile.media.fontBold, db.rune.runeFontSize, 'THINOUTLINE')
  240. f.Rune[i]:SetShadowOffset(0, 0)
  241. else
  242. f.Rune[i]:SetFont(ADDON_NAME.db.profile.media.fontBold, db.rune.runeFontSize)
  243. f.Rune[i]:SetShadowOffset(1, -1)
  244. end
  245.  
  246. f.Rune[i]:SetShadowOffset(0, 0)
  247. f.Rune[i]:SetParent(f)
  248. end
  249.  
  250. f.Rune[1]:SetPoint('CENTER', -65, 0)
  251. f.Rune[2]:SetPoint('CENTER', -39, 0)
  252. f.Rune[3]:SetPoint('CENTER', 39, 0)
  253. f.Rune[4]:SetPoint('CENTER', 65, 0)
  254. f.Rune[5]:SetPoint('CENTER', -13, 0)
  255. f.Rune[6]:SetPoint('CENTER', 13, 0)
  256. end
  257.  
  258. f.Power = CreateFrame('StatusBar', nil, UIParent)
  259. f.Power:SetScale(UIParent:GetScale())
  260. f.Power:SetSize(db.sizeWidth, 5)
  261. f.Power:SetPoint('CENTER', f, 0, -23)
  262. f.Power:SetStatusBarTexture(db.statusbar)
  263. f.Power:SetAlpha(0)
  264.  
  265. f.Power.Value = f.Power:CreateFontString(nil, 'ARTWORK')
  266.  
  267. if (db.valueFontOutline) then
  268. f.Power.Value:SetFont(ADDON_NAME.db.profile.media.fontNormal, db.valueFontSize, 'THINOUTLINE')
  269. f.Power.Value:SetShadowOffset(0, 0)
  270. else
  271. f.Power.Value:SetFont(ADDON_NAME.db.profile.media.fontNormal, db.valueFontSize)
  272. f.Power.Value:SetShadowOffset(1, -1)
  273. end
  274.  
  275. f.Power.Value:SetPoint('CENTER', f.Power, 0, db.valueFontAdjustmentX)
  276. f.Power.Value:SetVertexColor(1, 1, 1)
  277.  
  278. f.Power.Background = f.Power:CreateTexture(nil, 'BACKGROUND')
  279. f.Power.Background:SetAllPoints(f.Power)
  280. f.Power.Background:SetTexture(db.statusbar)
  281. f.Power.Background:SetVertexColor(0.25, 0.25, 0.25, 1)
  282.  
  283. f.Power.Below = f.Power:CreateTexture(nil, 'BACKGROUND')
  284. f.Power.Below:SetHeight(14)
  285. f.Power.Below:SetWidth(14)
  286. f.Power.Below:SetTexture([[Interface\AddOns\BasicUI\Media\textureArrowBelow]])
  287.  
  288. f.Power.Above = f.Power:CreateTexture(nil, 'BACKGROUND')
  289. f.Power.Above:SetHeight(14)
  290. f.Power.Above:SetWidth(14)
  291. f.Power.Above:SetTexture([[Interface\AddOns\BasicUI\Media\textureArrowAbove]])
  292. f.Power.Above:SetPoint('BOTTOM', f.Power.Below, 'TOP', 0, f.Power:GetHeight())
  293.  
  294. if (db.showCombatRegen) then
  295. f.mpreg = f.Power:CreateFontString(nil, 'ARTWORK')
  296. f.mpreg:SetFont(ADDON_NAME.db.profile.media.fontNormal, 12, 'THINOUTLINE')
  297. f.mpreg:SetShadowOffset(0, 0)
  298. f.mpreg:SetPoint('TOP', f.Power.Below, 'BOTTOM', 0, 4)
  299. f.mpreg:SetParent(f.Power)
  300. f.mpreg:Show()
  301. end
  302.  
  303. local function GetWarlockPower()
  304. local powerType = SPELL_POWER_MANA
  305. local unitPower = 0
  306.  
  307. if (IsPlayerSpell(WARLOCK_SOULBURN)) then
  308. powerType = SPELL_POWER_SOUL_SHARDS
  309. elseif (IsPlayerSpell(WARLOCK_BURNING_EMBERS)) then
  310. powerType = SPELL_POWER_BURNING_EMBERS
  311. elseif (IsPlayerSpell(WARLOCK_METAMORPHOSIS)) then
  312. powerType = SPELL_POWER_DEMONIC_FURY
  313. end
  314.  
  315. if (powerType ~= SPELL_POWER_MANA) then
  316. unitPower = UnitPower('player', powerType)
  317. end
  318.  
  319. return unitPower
  320. end
  321.  
  322. local function GetRealMpFive()
  323. local _, activeRegen = GetPowerRegen()
  324. local realRegen = activeRegen * 5
  325. local _, powerType = UnitPowerType('player')
  326.  
  327. if (powerType == 'MANA' or UnitHasVehicleUI('player')) then
  328. return math.floor(realRegen)
  329. else
  330. return ''
  331. end
  332. end
  333.  
  334. local function SetComboColor(i)
  335. local comboPoints = GetComboPoints('player', 'target') or 0
  336.  
  337. if (i > comboPoints or UnitIsDeadOrGhost('target')) then
  338. return 1, 1, 1
  339. else
  340. return ComboColor[i].r, ComboColor[i].g, ComboColor[i].b
  341. end
  342. end
  343.  
  344. local function SetComboAlpha(i)
  345. local comboPoints = GetComboPoints('player', 'target') or 0
  346.  
  347. if (i == comboPoints) then
  348. return 1
  349. else
  350. return 0
  351. end
  352. end
  353.  
  354. local function UpdateChi()
  355. local chi = UnitPower('player', SPELL_POWER_CHI)
  356. local maxChi = UnitPowerMax('player', SPELL_POWER_CHI)
  357. local yOffset = db.energy.comboPointsBelow and -35 or 0
  358.  
  359. if (f.Chi.maxChi ~= maxChi) then
  360. if (maxChi == 4) then
  361. f.Chi[1]:SetPoint('CENTER', -39, yOffset)
  362. f.Chi[2]:SetPoint('CENTER', -13, yOffset)
  363. f.Chi[3]:SetPoint('CENTER', 13, yOffset)
  364. f.Chi[4]:SetPoint('CENTER', 39, yOffset)
  365. f.Chi[5]:Hide()
  366. f.Chi.maxChi = 4
  367. else
  368. f.Chi[1]:SetPoint('CENTER', -52, yOffset)
  369. f.Chi[2]:SetPoint('CENTER', -26, yOffset)
  370. f.Chi[3]:SetPoint('CENTER', 0, yOffset)
  371. f.Chi[4]:SetPoint('CENTER', 26, yOffset)
  372. f.Chi[5]:Show()
  373. f.Chi.maxChi = 5
  374. end
  375. end
  376.  
  377. for i = 1, maxChi do
  378. if (UnitHasVehicleUI('player')) then
  379. if (f.Chi[i]:IsShown()) then
  380. f.Chi[i]:Hide()
  381. end
  382. else
  383. if (not f.Chi[i]:IsShown()) then
  384. f.Chi[i]:Show()
  385. end
  386. end
  387. f.Chi[i]:SetAlpha(i == chi and 1 or 0)
  388. end
  389. end
  390.  
  391. local function CalcRuneCooldown(self)
  392. local start, duration, runeReady = GetRuneCooldown(self)
  393. local time = floor(GetTime() - start)
  394. local cooldown = ceil(duration - time)
  395.  
  396. if (runeReady or UnitIsDeadOrGhost('player')) then
  397. return '#'
  398. elseif (not UnitIsDeadOrGhost('player') and cooldown) then
  399. return cooldown
  400. end
  401. end
  402.  
  403. local function SetRuneColor(i)
  404. if (f.Rune[i].type == 4) then
  405. return 1, 0, 1
  406. else
  407. return RuneColor[i].r, RuneColor[i].g, RuneColor[i].b
  408. end
  409. end
  410.  
  411. local function UpdateBarVisibility()
  412. local _, powerType = UnitPowerType('player')
  413. local newAlpha = nil
  414.  
  415. if ((not db.energy.show and powerType == 'ENERGY') or (not db.showFocus and powerType == 'FOCUS') or (not db.showRage and powerType == 'RAGE') or (not db.showMana and powerType == 'MANA') or (not db.rune.show and powerType == 'RUNEPOWER') or UnitIsDeadOrGhost('player') or UnitHasVehicleUI('player')) then
  416. f.Power:SetAlpha(0)
  417. elseif (InCombatLockdown()) then
  418. newAlpha = db.activeAlpha
  419. elseif (not InCombatLockdown() and UnitPower('player') > 0) then
  420. newAlpha = db.inactiveAlpha
  421. else
  422. newAlpha = db.emptyAlpha
  423. end
  424.  
  425. if (newAlpha) then
  426. Fade(f.Power, 0.3, f.Power:GetAlpha(), newAlpha)
  427. end
  428. end
  429.  
  430. local function UpdateArrow()
  431. if (UnitPower('player') == 0) then
  432. f.Power.Below:SetAlpha(0.3)
  433. f.Power.Above:SetAlpha(0.3)
  434. else
  435. f.Power.Below:SetAlpha(1)
  436. f.Power.Above:SetAlpha(1)
  437. end
  438.  
  439. local newPosition = UnitPower('player') / UnitPowerMax('player') * f.Power:GetWidth()
  440. f.Power.Below:SetPoint('TOP', f.Power, 'BOTTOMLEFT', newPosition, 0)
  441. end
  442.  
  443. local function UpdateBarValue()
  444. local min = UnitPower('player')
  445. f.Power:SetMinMaxValues(0, UnitPowerMax('player', f))
  446. f.Power:SetValue(min)
  447.  
  448. if (db.valueAbbrev) then
  449. f.Power.Value:SetText(min > 0 and FormatValue(min) or '')
  450. else
  451. f.Power.Value:SetText(min > 0 and min or '')
  452. end
  453. end
  454.  
  455. local function UpdateBarColor()
  456. local _, powerType, altR, altG, altB = UnitPowerType('player')
  457. local unitPower = PowerBarColor[powerType]
  458.  
  459. if (unitPower) then
  460. f.Power:SetStatusBarColor(unitPower.r, unitPower.g, unitPower.b)
  461. else
  462. f.Power:SetStatusBarColor(altR, altG, altB)
  463. end
  464. end
  465.  
  466. local function UpdateBar()
  467. UpdateBarColor()
  468. UpdateBarValue()
  469. UpdateArrow()
  470. end
  471.  
  472. f:SetScript('OnEvent', function(self, event, arg1)
  473. if (f.ComboPoints) then
  474. if (event == 'UNIT_COMBO_POINTS' or event == 'PLAYER_TARGET_CHANGED') then
  475. for i = 1, 5 do
  476. f.ComboPoints[i]:SetTextColor(SetComboColor(i))
  477. f.ComboPoints[i]:SetAlpha(SetComboAlpha(i))
  478. end
  479. end
  480. end
  481.  
  482. if (event == 'RUNE_TYPE_UPDATE' and db.rune.showRuneCooldown) then
  483. f.Rune[arg1].type = GetRuneType(arg1)
  484. end
  485.  
  486. if (f.extraPoints) then
  487. if (UnitHasVehicleUI('player')) then
  488. if (f.extraPoints:IsShown()) then
  489. f.extraPoints:Hide()
  490. end
  491. else
  492. local nump
  493. if (playerClass == 'WARLOCK') then
  494. nump = GetWarlockPower()
  495. elseif (playerClass == 'PALADIN') then
  496. nump = UnitPower('player', SPELL_POWER_HOLY_POWER)
  497. elseif (playerClass == 'PRIEST') then
  498. nump = UnitPower('player', SPELL_POWER_SHADOW_ORBS)
  499. end
  500.  
  501. f.extraPoints:SetText(nump == 0 and '' or nump)
  502.  
  503. if (not f.extraPoints:IsShown()) then
  504. f.extraPoints:Show()
  505. end
  506. end
  507. end
  508.  
  509. if (f.Chi) then
  510. UpdateChi()
  511. end
  512.  
  513. if (f.mpreg and (event == 'UNIT_AURA' or event == 'PLAYER_ENTERING_WORLD')) then
  514. f.mpreg:SetText(GetRealMpFive())
  515. end
  516.  
  517. UpdateBar()
  518. UpdateBarVisibility()
  519.  
  520. if (event == 'PLAYER_ENTERING_WORLD') then
  521. if (InCombatLockdown()) then
  522. securecall('UIFrameFadeIn', f, 0.35, f:GetAlpha(), 1)
  523. else
  524. securecall('UIFrameFadeOut', f, 0.35, f:GetAlpha(), db.inactiveAlpha)
  525. end
  526. end
  527.  
  528. if (event == 'PLAYER_REGEN_DISABLED') then
  529. securecall('UIFrameFadeIn', f, 0.35, f:GetAlpha(), 1)
  530. end
  531.  
  532. if (event == 'PLAYER_REGEN_ENABLED') then
  533. securecall('UIFrameFadeOut', f, 0.35, f:GetAlpha(), db.inactiveAlpha)
  534. end
  535. end)
  536.  
  537. if (f.Rune) then
  538. local updateTimer = 0
  539. f:SetScript('OnUpdate', function(self, elapsed)
  540. updateTimer = updateTimer + elapsed
  541.  
  542. if (updateTimer > 0.1) then
  543. for i = 1, 6 do
  544. if (UnitHasVehicleUI('player')) then
  545. if (f.Rune[i]:IsShown()) then
  546. f.Rune[i]:Hide()
  547. end
  548. else
  549. if (not f.Rune[i]:IsShown()) then
  550. f.Rune[i]:Show()
  551. end
  552. end
  553.  
  554. f.Rune[i]:SetText(CalcRuneCooldown(i))
  555. f.Rune[i]:SetTextColor(SetRuneColor(i))
  556. end
  557.  
  558. updateTimer = 0
  559. end
  560. end)
  561. end
  562. end
  563.  
  564. ------------------------------------------------------------------------
  565. -- Module Options
  566. ------------------------------------------------------------------------
  567.  
  568. local options
  569. function MODULE:GetOptions()
  570. if options then
  571. return options
  572. end
  573.  
  574. local function isModuleDisabled()
  575. return not ADDON_NAME:GetModuleEnabled(MODULE_NAME)
  576. end
  577.  
  578. local regions = {
  579. ['BOTTOM'] = L['Bottom'],
  580. ['BOTTOMLEFT'] = L['Bottom Left'],
  581. ['BOTTOMRIGHT'] = L['Bottom Right'],
  582. ['CENTER'] = L['Center'],
  583. ['LEFT'] = L['Left'],
  584. ['RIGHT'] = L['Right'],
  585. ['TOP'] = L['Top'],
  586. ['TOPLEFT'] = L['Top Left'],
  587. ['TOPRIGHT'] = L['Top Right'],
  588. }
  589.  
  590. options = {
  591. type = "group",
  592. name = L[MODULE_NAME],
  593. get = function(info) return db[ info[#info] ] end,
  594. set = function(info, value) db[ info[#info] ] = value; end,
  595. args = {
  596. ---------------------------
  597. --Option Type Seperators
  598. sep1 = {
  599. type = "description",
  600. order = 2,
  601. name = " ",
  602. },
  603. sep2 = {
  604. type = "description",
  605. order = 3,
  606. name = " ",
  607. },
  608. sep3 = {
  609. type = "description",
  610. order = 4,
  611. name = " ",
  612. },
  613. sep4 = {
  614. type = "description",
  615. order = 5,
  616. name = " ",
  617. },
  618. ---------------------------
  619. reloadUI = {
  620. type = "execute",
  621. name = "Reload UI",
  622. desc = " ",
  623. order = 0,
  624. func = function()
  625. ReloadUI()
  626. end,
  627. },
  628. Text = {
  629. type = "description",
  630. order = 0,
  631. name = "When changes are made a reload of the UI is needed.",
  632. width = "full",
  633. },
  634. Text1 = {
  635. type = "description",
  636. order = 1,
  637. name = " ",
  638. width = "full",
  639. },
  640. enable = {
  641. order = 1,
  642. name = L["Enable Powerbar Module"],
  643. width = "full",
  644. type = "toggle",
  645. },
  646. showCombatRegen = {
  647. order = 2,
  648. name = L["Show Combat Regen"],
  649. type = "toggle",
  650. disabled = function() return isModuleDisabled() or not db.enable end,
  651. },
  652. showSoulshards = {
  653. order = 2,
  654. name = L["Show Soulshards Text"],
  655. type = "toggle",
  656. disabled = function() return isModuleDisabled() or not db.enable end,
  657. },
  658. showHolypower = {
  659. order = 2,
  660. name = L["Show Holypower Text"],
  661. type = "toggle",
  662. disabled = function() return isModuleDisabled() or not db.enable end,
  663. },
  664. showMana = {
  665. order = 2,
  666. name = L["Show Mana Text"],
  667. type = "toggle",
  668. disabled = function() return isModuleDisabled() or not db.enable end,
  669. },
  670. showFocus = {
  671. order = 2,
  672. name = L["Show Focus Text"],
  673. type = "toggle",
  674. disabled = function() return isModuleDisabled() or not db.enable end,
  675. },
  676. showRage = {
  677. order = 2,
  678. name = L["Show Rage Text"],
  679. type = "toggle",
  680. disabled = function() return isModuleDisabled() or not db.enable end,
  681. },
  682. valueAbbrev = {
  683. order = 2,
  684. name = L["Value Abbrev"],
  685. type = "toggle",
  686. disabled = function() return isModuleDisabled() or not db.enable end,
  687. },
  688. valueFontOutline = {
  689. order = 2,
  690. name = L["Value Font Outline"],
  691. type = "toggle",
  692. disabled = function() return isModuleDisabled() or not db.enable end,
  693. },
  694. sizeWidth= {
  695. order = 5,
  696. name = L["Size Width"],
  697. type = "range",
  698. min = 50, max = 350, step = 25,
  699. disabled = function() return isModuleDisabled() or not db.enable end,
  700. },
  701. activeAlpha = {
  702. order = 5,
  703. name = L["Active Alpha"],
  704. type = "range",
  705. min = 0, max = 1, step = 0.1,
  706. disabled = function() return isModuleDisabled() or not db.enable end,
  707. },
  708. inactiveAlpha = {
  709. order = 5,
  710. name = L["In Active Alpha"],
  711. type = "range",
  712. min = 0, max = 1, step = 0.1,
  713. disabled = function() return isModuleDisabled() or not db.enable end,
  714. },
  715. emptyAlpha = {
  716. order = 5,
  717. name = L["Empty Alpha"],
  718. type = "range",
  719. min = 0, max = 1, step = 0.1,
  720. disabled = function() return isModuleDisabled() or not db.enable end,
  721. },
  722. valueFontSize = {
  723. order = 5,
  724. name = L["Value Font Size"],
  725. type = "range",
  726. min = 8, max = 30, step = 1,
  727. disabled = function() return isModuleDisabled() or not db.enable end,
  728. },
  729. valueFontAdjustmentX = {
  730. order = 5,
  731. name = L["Value Font Adjustment X"],
  732. type = "range",
  733. min = -200, max = 200, step = 1,
  734. disabled = function() return isModuleDisabled() or not db.enable end,
  735. },
  736. position = {
  737. type = "group",
  738. order = 6,
  739. guiInline = true,
  740. name = L["Position the Powerbar"],
  741. guiInline = true,
  742. disabled = function() return isModuleDisabled() or not db.enable end,
  743. get = function(info) return db.position[ info[#info] ] end,
  744. set = function(info, value) db.position[ info[#info] ] = value; end,
  745. args = {
  746. ---------------------------
  747. --Option Type Seperators
  748. sep1 = {
  749. type = "description",
  750. order = 2,
  751. name = " ",
  752. },
  753. sep2 = {
  754. type = "description",
  755. order = 3,
  756. name = " ",
  757. },
  758. ---------------------------
  759. selfAnchor = {
  760. order = 1,
  761. name = L["Self Anchor"],
  762. disabled = function() return isModuleDisabled() or not db.enable end,
  763. type = "select",
  764. values = regions;
  765. },
  766. offSetX = {
  767. type = "range",
  768. order = 2,
  769. name = L["X Offset"],
  770. desc = L["Controls the X offset. (Left - Right)"],
  771. min = -250, max = 250, step = 5,
  772. disabled = function() return isModuleDisabled() or not db.enable end,
  773. },
  774. offSetY = {
  775. type = "range",
  776. order = 2,
  777. name = L["Y Offset"],
  778. desc = L["Controls the Y offset. (Up - Down)"],
  779. min = -250, max = 250, step = 5,
  780. disabled = function() return isModuleDisabled() or not db.enable end,
  781. },
  782. },
  783. },
  784. energy = {
  785. type = "group",
  786. order = 5,
  787. guiInline = true,
  788. name = L["Energy"],
  789. disabled = function() return isModuleDisabled() or not db.enable end,
  790. get = function(info) return db.energy[ info[#info] ] end,
  791. set = function(info, value) db.energy[ info[#info] ] = value; end,
  792. args = {
  793. ---------------------------
  794. --Option Type Seperators
  795. sep1 = {
  796. type = "description",
  797. order = 2,
  798. name = " ",
  799. },
  800. sep2 = {
  801. type = "description",
  802. order = 3,
  803. name = " ",
  804. },
  805. sep3 = {
  806. type = "description",
  807. order = 4,
  808. name = " ",
  809. },
  810. sep4 = {
  811. type = "description",
  812. order = 5,
  813. name = " ",
  814. },
  815. ---------------------------
  816. show = {
  817. order = 1,
  818. name = L["Show Energy Text"],
  819. type = "toggle",
  820. disabled = function() return isModuleDisabled() or not db.enable end,
  821. },
  822. Text1 = {
  823. type = "description",
  824. order = 1,
  825. name = " ",
  826. width = "full",
  827. },
  828. showComboPoints = {
  829. order = 2,
  830. name = L["Show Combo Points"],
  831. type = "toggle",
  832. disabled = function() return isModuleDisabled() or not db.enable or not db.energy.show end,
  833. },
  834. comboPointsBelow = {
  835. order = 2,
  836. name = L["Combo Points Below"],
  837. type = "toggle",
  838. disabled = function() return isModuleDisabled() or not db.enable or not db.energy.show end,
  839. },
  840. comboFontOutline = {
  841. order = 2,
  842. name = L["Combo Font Outline"],
  843. type = "toggle",
  844. disabled = function() return isModuleDisabled() or not db.enable or not db.energy.show end,
  845. },
  846. comboFontSize = {
  847. order = 5,
  848. name = L["Combo Font Size"],
  849. type = "range",
  850. min = 8, max = 25, step = 1,
  851. disabled = function() return isModuleDisabled() or not db.enable or not db.energy.show end,
  852. },
  853. },
  854. },
  855. rune = {
  856. type = "group",
  857. order = 5,
  858. guiInline = true,
  859. name = L["Rune"],
  860. disabled = function() return isModuleDisabled() or not db.enable end,
  861. get = function(info) return db.rune[ info[#info] ] end,
  862. set = function(info, value) db.rune[ info[#info] ] = value; end,
  863. args = {
  864. ---------------------------
  865. --Option Type Seperators
  866. sep1 = {
  867. type = "description",
  868. order = 2,
  869. name = " ",
  870. },
  871. sep2 = {
  872. type = "description",
  873. order = 3,
  874. name = " ",
  875. },
  876. sep3 = {
  877. type = "description",
  878. order = 4,
  879. name = " ",
  880. },
  881. sep4 = {
  882. type = "description",
  883. order = 5,
  884. name = " ",
  885. },
  886. ---------------------------
  887. show = {
  888. order = 1,
  889. name = L["Show Rune Text"],
  890. type = "toggle",
  891. disabled = function() return isModuleDisabled() or not db.enable end,
  892. },
  893. Text1 = {
  894. type = "description",
  895. order = 1,
  896. name = " ",
  897. width = "full",
  898. },
  899. showRuneCooldown = {
  900. order = 2,
  901. name = L["Show Rune Cooldown"],
  902. type = "toggle",
  903. disabled = function() return isModuleDisabled() or not db.enable or not db.rune.show end,
  904. },
  905. runeFontOutline = {
  906. order = 2,
  907. name = L["Rune Font Outline"],
  908. type = "toggle",
  909. disabled = function() return isModuleDisabled() or not db.enable or not db.rune.show end,
  910. },
  911. runeFontSize= {
  912. order = 5,
  913. name = L["Rune Font Size"],
  914. type = "range",
  915. min = 8, max = 25, step = 1,
  916. disabled = function() return isModuleDisabled() or not db.enable or not db.rune.show end,
  917. },
  918. },
  919. },
  920. },
  921. }
  922. return options
  923. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement