PageRenderTime 357ms CodeModel.GetById 239ms app.highlight 8ms RepoModel.GetById 92ms app.codeStats 0ms

/TelUI_AddonSkins/skins/SexyCooldown.lua

http://github.com/Asphyxia/Tukui
Lua | 176 lines | 116 code | 17 blank | 43 comment | 5 complexity | 9c035d5337692b6aa325926d8138bcb2 MD5 | raw file
  1--[[
  2	SexyCooldown Skin by Darth Android / Telroth - The Venture Co.
  3	
  4	Skins SexyCooldown to look like TelUI.
  5	
  6	Available SKIN methods:
  7	
  8	:SCDStripSkinSettings(bar) -- removes skin-related settings from the bar's option table
  9	
 10	:SkinSexyCooldownBar(bar) -- Applies skinning to a specific SexyCooldown bar.
 11	
 12	:SkinSexyCooldownIcon(bar, icon) -- Skins one of the icons on a bar.
 13	
 14	Available LAYOUT methods:
 15	
 16	:SCDStripLayoutSettings(bar) -- removes layout-related settings from the bar's option table
 17	
 18	:PositionSexyCooldownBar(bar) -- positions the SexyCooldown bar "bar" on screen
 19	 
 20	(C)2010 Darth Android / Telroth - The Venture Co.
 21	File version v91.109
 22]]
 23
 24if not Mod_AddonSkins or not SexyCooldown then return end
 25local scd = SexyCooldown
 26local L = LibStub("AceLocale-3.0"):GetLocale("SexyCooldown")
 27
 28Mod_AddonSkins:RegisterSkin("SexyCooldown",function(Skin,skin,Layout,layout,config)
 29	
 30	
 31	--[[ Skinning and Layout functions ]]
 32	-- Strip skinning settings from in-game GUI
 33	function Skin:SCDStripSkinSettings(bar)
 34		-- Remove conflicting options
 35		bar.optionsTable.args.icon.args.borderheader = nil
 36		bar.optionsTable.args.icon.args.border = nil
 37		bar.optionsTable.args.icon.args.borderColor = nil
 38		bar.optionsTable.args.icon.args.borderSize = nil
 39		bar.optionsTable.args.icon.args.borderInset = nil
 40		--bar.optionsTable.args.icon.args.sizeOffset = nil
 41		bar.optionsTable.args.bar.args.bnbheader = nil
 42		bar.optionsTable.args.bar.args.texture = nil
 43		bar.optionsTable.args.bar.args.backgroundColor = nil
 44		bar.optionsTable.args.bar.args.border = nil
 45		bar.optionsTable.args.bar.args.borderColor = nil
 46		bar.optionsTable.args.bar.args.borderSize = nil
 47		bar.optionsTable.args.bar.args.borderInset = nil
 48	end
 49	-- Strip positioning settings from in-game GUI
 50	function Layout:SCDStripLayoutSettings(bar)
 51		-- Override variables
 52		bar.settings.bar.lock = true
 53		--remove settings which are no longer relavent for this bar
 54		bar.optionsTable.args.copy = nil
 55		bar.optionsTable.args.bar.args.lock = nil
 56		bar.optionsTable.args.bar.args.orientation.values = {
 57			LEFT_TO_RIGHT = L["Left to Right"],
 58			RIGHT_TO_LEFT = L["Right to Left"]
 59		}
 60		bar.optionsTable.args.bar.args.positioning = nil
 61		bar.optionsTable.args.bar.args.height = nil
 62		bar.optionsTable.args.bar.args.width = nil
 63		bar.optionsTable.args.bar.args.x = nil
 64		bar.optionsTable.args.bar.args.y = nil
 65		bar.optionsTable.args.bar.args.inactiveAlpha = nil
 66	end
 67	-- Don't move the bars, but a layout could integrate them
 68	Layout.PositionSexyCooldownBar = dummy
 69	
 70	-- Skin Bars
 71	function Skin:SkinSexyCooldownBar(bar)
 72		self:SCDStripSkinSettings(bar)
 73		self:SkinFrame(bar)
 74	end
 75	
 76	
 77	-- Skin Icons
 78	function Skin:SkinSexyCooldownIcon(bar, icon)
 79		self:SkinFrame(icon)
 80		self:SkinFrame(icon.overlay)
 81		icon.tex:SetTexCoord(unpack(config.buttonZoom))
 82		icon.overlay:SetBackdropColor(0,0,0,0)
 83		-- Default no background/border
 84		icon:SetBackdropColor(0,0,0,0)
 85		icon:SetBackdropBorderColor(0,0,0,0)
 86		icon.overlay:SetBackdropBorderColor(0,0,0,0)
 87	end
 88
 89	--[[ Hook bar creation to add skinning ]]
 90	
 91	local function HookSCDBar(bar)
 92		-- Hook bar skinning & layout
 93		bar.UpdateBarLook_ = bar.UpdateBarLook
 94		bar.UpdateBarLook = function(self)
 95			self:UpdateBarLook_()
 96			skin:SkinSexyCooldownBar(self)
 97			layout:PositionSexyCooldownBar(self)
 98		end
 99		-- Hook icon skinning
100		bar.UpdateSingleIconLook_ = bar.UpdateSingleIconLook
101		bar.UpdateSingleIconLook = function(self,icon)
102			self:UpdateSingleIconLook_(icon)
103			skin:SkinSexyCooldownIcon(bar,icon)
104		end
105		-- Static skinning
106		bar.settings.icon.borderInset = config.borderWidth
107	end
108	
109	scd.CreateBar_ = scd.CreateBar
110	scd.CreateBar = function(self, settings, name)
111		local bar = scd:CreateBar_(settings,name)
112		HookSCDBar(bar)
113		return bar
114	end
115	-- Skin Pre-existing bars
116	for _,bar in ipairs(scd.bars) do
117		HookSCDBar(bar)
118		-- Force a bar update
119		bar:UpdateBarLook()
120	end
121end)
122
123local function SkinBar(frame)
124	-- Override bar skinning
125	frame.UpdateBarBackdrop = function(self)
126		self:SetBackdrop({
127			bgFile = TukuiDB["media"].blank, 
128			edgeFile = TukuiDB["media"].blank, 
129			tile = false, tileSize = 0, edgeSize = TukuiDB.mult, 
130			insets = { left = -TukuiDB.mult, right = -TukuiDB.mult, top = -TukuiDB.mult, bottom = -TukuiDB.mult}
131		})
132		if frame.skin and frame.skin.nobackground then
133			self:SetBackdropColor(0,0,0,0)
134		else
135			self:SetBackdropColor(unpack(TukuiDB["media"].backdropcolor))
136		end
137		if frame.skin and frame.skin.noborder then
138			self:SetBackdropBorderColor(0,0,0,0)
139		else
140			self:SetBackdropBorderColor(unpack(TukuiDB["media"].bordercolor))
141		end
142	end
143	-- Override cooldown skinning
144	frame.UpdateSingleIconLook_ = frame.UpdateSingleIconLook
145	frame.UpdateSingleIconLook = function(self, icon)
146		frame:UpdateSingleIconLook_(icon)
147		if frame.skin and frame.skin.noiconborder then
148			icon:SetBackdrop({
149				bgFile = TukuiDB["media"].blank, 
150				edgeFile = TukuiDB["media"].blank, 
151				tile = false, tileSize = 0, edgeSize = 0, 
152				insets = { left = 0, right = 0, top = 0, bottom = 0}
153			})
154			icon:SetBackdropBorderColor(0,0,0,0)
155		else
156			icon:SetBackdrop({
157				bgFile = TukuiDB["media"].blank, 
158				edgeFile = TukuiDB["media"].blank, 
159				tile = false, tileSize = 0, edgeSize = TukuiDB.mult, 
160				--insets = { left = -TukuiDB.mult, right = -TukuiDB.mult, top = -TukuiDB.mult, bottom = -TukuiDB.mult}
161				insets = { left = 0, right = 0, top = 0, bottom = 0}
162			})
163			icon:SetBackdropBorderColor(unpack(TukuiDB["media"].bordercolor))
164		end
165		icon:SetBackdropColor(0,0,0,0)
166	end
167	-- Skinning options
168	frame.settings.icon.borderInset = 2
169
170	frame:UpdateBarLook()
171end
172
173
174
175
176