PageRenderTime 103ms CodeModel.GetById 61ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/TelUI_AddonSkins/skins/DXE.lua

http://github.com/Asphyxia/Tukui
Lua | 130 lines | 96 code | 10 blank | 24 comment | 6 complexity | 635e436f33cb31349213b993b492bc70 MD5 | raw file
  1--[[
  2	DXE skin by Darth Android / Telroth - The Venture Co.
  3	
  4	Skins DXE to look like TelUI.
  5	
  6	Available SKIN functions:
  7	
  8	:SkinDXEBar(bar) -- skins a timer bar for DXE
  9	
 10	File version v91.109
 11	(C)2010 Darth Android / Telroth - The Venture Co.
 12]]
 13
 14if not Mod_AddonSkins or not IsAddOnLoaded("DXE") then return end
 15print("postdxecheck")
 16local DXE = DXE
 17local _G = getfenv(0)
 18
 19--Hide a frame... FOREVER!
 20local function kill(frame)
 21	if frame.dead then return end
 22	frame:Hide()
 23	frame:HookScript("OnShow",frame.Hide)
 24	frame.dead = true
 25end
 26
 27local dummy = dummy or function() end
 28
 29Mod_AddonSkins:RegisterSkin("DXE",function(Skin, skin, Layout, layout, config)
 30	--[[ Kill DXE's skinning ]]
 31	DXE.NotifyBarTextureChanged = dummy
 32	DXE.NotifyBorderChanged = dummy
 33	DXE.NotifyBorderColorChanged = dummy
 34	DXE.NotifyBorderEdgeSizeChanged = dummy
 35	DXE.NotifyBackgroundTextureChanged = dummy
 36	DXE.NotifyBackgroundInsetChanged = dummy
 37	DXE.NotifyBackgroundColorChanged = dummy
 38	--[[ Hook Window Creation ]]
 39	DXE.CreateWindow_ = DXE.CreateWindow
 40	DXE.CreateWindow = function(self, name, width, height)
 41		local win = self:CreateWindow_(name, width, height)
 42		skin:SkinBackgroundFrame(win)
 43		return win
 44	end
 45	-- Skin the pane
 46	skin:SkinFrame(DXE.Pane)
 47	-- Hook Health frames (Skin & spacing)
 48	DXE.LayoutHealthWatchers_ = DXE.LayoutHealthWatchers
 49	DXE.LayoutHealthWatchers = function(self)
 50		self.db.profile.Pane.BarSpacing = config.barSpacing
 51		self:LayoutHealthWatchers_()
 52		for i,hw in ipairs(self.HW) do
 53			if hw:IsShown() then
 54				skin:SkinFrame(hw)
 55				kill(hw.border)
 56				hw.healthbar:SetStatusBarTexture(config.barTexture)
 57			end
 58		end
 59	end
 60	DXE.Alerts.RefreshBars_ = DXE.Alerts.RefreshBars
 61	DXE.Alerts.RefreshBars = function(self)
 62		if self.refreshing then return end
 63		self.refreshing = true
 64		self.db.profile.BarSpacing = config.barSpacing
 65		self.db.profile.IconXOffset = config.barSpacing
 66		self:RefreshBars_()
 67		local i = 1
 68		-- This wastes so much CPU, Please DXE, give us a reference to the bar pool!
 69		while _G["DXEAlertBar"..i] do
 70			local bar = _G["DXEAlertBar"..i]
 71			bar:SetScale(1)
 72			-- F U SCALE!
 73			bar.SetScale = dummy
 74			skin:SkinDXEBar(bar)
 75			i = i + 1
 76		end
 77		self.refreshing = false
 78	end
 79	
 80	DXE.Alerts.Dropdown_ = DXE.Alerts.Dropdown
 81	DXE.Alerts.Dropdown = function(self,...)
 82		self:Dropdown_(...)
 83		self:RefreshBars()
 84	end
 85	
 86	DXE.Alerts.CenterPopup_ = DXE.Alerts.CenterPopup
 87	DXE.Alerts.CenterPopup = function(self,...)
 88		self:CenterPopup_(...)
 89		self:RefreshBars()
 90	end
 91	
 92	DXE.Alerts.Simple_ = DXE.Alerts.Simple
 93	DXE.Alerts.Simple = function(self,...)
 94		self:Simple_(...)
 95		self:RefreshBars()
 96	end
 97	
 98	function Skin:SkinDXEBar(bar)
 99		-- The main bar
100		self:SkinBackgroundFrame(bar)
101		--bar.bg:SetTexture(nil)
102		kill(bar.border)
103		bar.statusbar:SetStatusBarTexture(config.barTexture)
104		bar.statusbar:ClearAllPoints()
105		bar.statusbar:SetPoint("TOPLEFT",config.borderWidth, -config.borderWidth)
106		bar.statusbar:SetPoint("BOTTOMRIGHT",-config.borderWidth, config.borderWidth)
107		-- Right Icon
108		self:SkinBackgroundFrame(bar.righticon)
109		kill(bar.righticon.border)
110		bar.righticon.t:SetTexCoord(unpack(config.buttonZoom))
111		bar.righticon.t:ClearAllPoints()
112		bar.righticon.t:SetPoint("TOPLEFT",config.borderWidth, -config.borderWidth)
113		bar.righticon.t:SetPoint("BOTTOMRIGHT",-config.borderWidth, config.borderWidth)
114		bar.righticon.t:SetDrawLayer("ARTWORK")
115		-- Left Icon
116		self:SkinBackgroundFrame(bar.lefticon)
117		kill(bar.lefticon.border)
118		bar.lefticon.t:SetTexCoord(unpack(config.buttonZoom))
119		bar.lefticon.t:ClearAllPoints()
120		bar.lefticon.t:SetPoint("TOPLEFT",config.borderWidth, -config.borderWidth)
121		bar.lefticon.t:SetPoint("BOTTOMRIGHT",-config.borderWidth, config.borderWidth)
122		bar.lefticon.t:SetDrawLayer("ARTWORK")
123	end
124	
125	-- Force some updates
126	DXE:LayoutHealthWatchers()
127	DXE.Alerts:RefreshBars()
128	kill(DXE.Pane.border)
129end)
130