PageRenderTime 51ms CodeModel.GetById 43ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/Tukui/modules/addonskins/Omen.lua

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