/Tukui/modules/addonskins/Omen.lua

http://github.com/Asphyxia/Tukui · Lua · 71 lines · 54 code · 10 blank · 7 comment · 5 complexity · bb4e34b310d792b3e37eecfe40db4e98 MD5 · raw file

  1. local T, C, L = unpack(select(2, ...)) -- Import Functions/Constants, Config, Locales
  2. if not IsAddOnLoaded("Omen") or not C["Addon_Skins"].Omen == true then return end
  3. local Omen = LibStub("AceAddon-3.0"):GetAddon("Omen")
  4. local borderWidth = T.Scale(2, 2)
  5. -- Skin Bar Texture
  6. Omen.UpdateBarTextureSettings_ = Omen.UpdateBarTextureSettings
  7. Omen.UpdateBarTextureSettings = function(self)
  8. for i, v in ipairs(self.Bars) do
  9. v.texture:SetTexture(C["media"].normTex)
  10. end
  11. end
  12. -- Skin Bar fonts
  13. Omen.UpdateBarLabelSettings_ = Omen.UpdateBarLabelSettings
  14. Omen.UpdateBarLabelSettings = function(self)
  15. self:UpdateBarLabelSettings_()
  16. for i, v in ipairs(self.Bars) do
  17. v.Text1:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  18. v.Text2:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  19. v.Text3:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  20. end
  21. end
  22. -- Skin Title Bar
  23. Omen.UpdateTitleBar_ = Omen.UpdateTitleBar
  24. Omen.UpdateTitleBar = function(self)
  25. Omen.db.profile.Scale = 1
  26. Omen.db.profile.Background.EdgeSize = 1
  27. Omen.db.profile.Background.BarInset = borderWidth
  28. Omen.db.profile.TitleBar.UseSameBG = true
  29. self:UpdateTitleBar_()
  30. self.TitleText:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  31. self.BarList:SetPoint("TOPLEFT", self.Title, "BOTTOMLEFT",0,-1)
  32. end
  33. --Skin Title/Bars backgrounds
  34. Omen.UpdateBackdrop_ = Omen.UpdateBackdrop
  35. Omen.UpdateBackdrop = function(self)
  36. Omen.db.profile.Scale = 1
  37. Omen.db.profile.Background.EdgeSize = 1
  38. Omen.db.profile.Background.BarInset = borderWidth
  39. self:UpdateBackdrop_()
  40. self.BarList:SetTemplate("Default")
  41. self.Title:SetTemplate("Default")
  42. self.BarList:SetPoint("TOPLEFT", self.Title, "BOTTOMLEFT", 0, -1)
  43. end
  44. -- Hook bar creation to apply settings
  45. local omen_mt = getmetatable(Omen.Bars)
  46. local oldidx = omen_mt.__index
  47. omen_mt.__index = function(self, barID)
  48. local bar = oldidx(self, barID)
  49. Omen:UpdateBarTextureSettings()
  50. Omen:UpdateBarLabelSettings()
  51. return bar
  52. end
  53. -- Option Overrides
  54. Omen.db.profile.Bar.Spacing = 2
  55. -- Force updates
  56. Omen:UpdateBarTextureSettings()
  57. Omen:UpdateBarLabelSettings()
  58. Omen:UpdateTitleBar()
  59. Omen:UpdateBackdrop()
  60. Omen:ReAnchorBars()
  61. Omen:ResizeBars()