main.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. local E, L, V, P, G = unpack(ElvUI)
  2. local _G = _G
  3. local UF = E:GetModule("UnitFrames")
  4. local hooksecurefunc = hooksecurefunc
  5. local MAX_COMBO_POINTS = MAX_COMBO_POINTS
  6. local color = {
  7. r = 1,
  8. g = 1,
  9. b = 1
  10. }
  11. local bgColor = {
  12. r = 0.1,
  13. g = 0.1,
  14. b = 0.1
  15. }
  16. -- PowerBar & AdditionalPowerBar
  17. local function hook_PostUpdatePower(self)
  18. self:SetStatusBarColor(color.r, color.g, color.b)
  19. self.bg:SetVertexColor(bgColor.r, bgColor.g, bgColor.b)
  20. end
  21. local function hook_PostUpdateAdditionalPower(self)
  22. self:Hide()
  23. end
  24. local f = CreateFrame("Frame")
  25. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  26. f:SetScript("OnEvent", function(self)
  27. self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  28. local unitframe = _G["ElvUF_Player"]
  29. local power = unitframe and unitframe.Power
  30. if power then
  31. hooksecurefunc(power, "PostUpdate", hook_PostUpdatePower)
  32. end
  33. local apower = unitframe and unitframe.AdditionalPower
  34. if apower then
  35. hooksecurefunc(apower, "PostUpdate", hook_PostUpdateAdditionalPower)
  36. end
  37. end)
  38. -- ClassBar
  39. local function hook_Configure_ClassBar(self, frame)
  40. local bars = frame[frame.ClassBar]
  41. if not bars then return end
  42. if (frame.ClassBar == 'ClassPower' or frame.ClassBar == 'Runes') then
  43. local maxClassBarButtons = max(UF.classMaxResourceBar[E.myclass] or 0, MAX_COMBO_POINTS)
  44. for i = 1, maxClassBarButtons do
  45. if i <= frame.MAX_CLASS_BAR and bars[i].bg then
  46. bars[i]:SetStatusBarColor(color.r, color.g, color.b)
  47. bars[i].bg:SetVertexColor(bgColor.r, bgColor.g, bgColor.b)
  48. end
  49. end
  50. end
  51. end
  52. hooksecurefunc(UF, "Configure_ClassBar", hook_Configure_ClassBar)