PageRenderTime 205ms CodeModel.GetById 81ms app.highlight 10ms RepoModel.GetById 111ms app.codeStats 0ms

/Tukui/modules/skins/spellbook.lua

http://github.com/Asphyxia/Tukui
Lua | 224 lines | 183 code | 36 blank | 5 comment | 26 complexity | 8c27105b8da59963c9c74b205dd7103a MD5 | raw file
  1local T, C, L = unpack(select(2, ...))
  2local function LoadSkin()
  3	T.SkinCloseButton(SpellBookFrameCloseButton)
  4
  5	local StripAllTextures = {
  6		"SpellBookFrame",
  7		"SpellBookFrameInset",
  8		"SpellBookSpellIconsFrame",
  9		"SpellBookSideTabsFrame",
 10		"SpellBookPageNavigationFrame",
 11	}
 12
 13	local KillTextures = {
 14		"SpellBookPage1",
 15		"SpellBookPage2",
 16	}
 17
 18	for _, object in pairs(StripAllTextures) do
 19		_G[object]:StripTextures()
 20	end
 21
 22	for _, texture in pairs(KillTextures) do
 23		_G[texture]:Kill()
 24	end
 25
 26	local pagebackdrop = CreateFrame("Frame", nil, SpellBookPage1:GetParent())
 27	pagebackdrop:Point("TOPLEFT", SpellBookFrame, "TOPLEFT", 50, -50)
 28	pagebackdrop:Point("BOTTOMRIGHT", SpellBookPage1, "BOTTOMRIGHT", 15, 35)
 29
 30	T.SkinNextPrevButton(SpellBookPrevPageButton)
 31	T.SkinNextPrevButton(SpellBookNextPageButton)
 32
 33	--Skin SpellButtons
 34	local function SpellButtons(self, first)
 35		for i=1, SPELLS_PER_PAGE do
 36			local button = _G["SpellButton"..i]
 37			local icon = _G["SpellButton"..i.."IconTexture"]
 38			
 39			if first then
 40				for i=1, button:GetNumRegions() do
 41					local region = select(i, button:GetRegions())
 42					if region:GetObjectType() == "Texture" then
 43						if region:GetTexture() ~= "Interface\\Buttons\\ActionBarFlyoutButton" then
 44							region:SetTexture(nil)
 45						end
 46					end
 47				end
 48			end
 49			
 50			if _G["SpellButton"..i.."Highlight"] then
 51				_G["SpellButton"..i.."Highlight"]:SetTexture(1, 1, 1, 0.3)
 52				_G["SpellButton"..i.."Highlight"]:ClearAllPoints()
 53				_G["SpellButton"..i.."Highlight"]:SetAllPoints(icon)
 54			end
 55
 56			if icon then
 57				icon:SetTexCoord(.08, .92, .08, .92)
 58				icon:ClearAllPoints()
 59				icon:SetAllPoints()
 60
 61				if not button.backdrop then
 62					button:CreateBackdrop("Transparent", true)	
 63				end
 64			end	
 65			
 66			local r, g, b = _G["SpellButton"..i.."SpellName"]:GetTextColor()
 67
 68			if r < 0.8 then
 69				_G["SpellButton"..i.."SpellName"]:SetTextColor(0.6, 0.6, 0.6)
 70			end
 71			_G["SpellButton"..i.."SubSpellName"]:SetTextColor(0.6, 0.6, 0.6)
 72			_G["SpellButton"..i.."RequiredLevelString"]:SetTextColor(0.6, 0.6, 0.6)
 73		end
 74	end
 75	SpellButtons(nil, true)
 76	hooksecurefunc("SpellButton_UpdateButton", SpellButtons)
 77
 78	SpellBookPageText:SetTextColor(0.6, 0.6, 0.6)
 79
 80	--Skill Line Tabs
 81	for i=1, MAX_SKILLLINE_TABS do
 82		local tab = _G["SpellBookSkillLineTab"..i]
 83		_G["SpellBookSkillLineTab"..i.."Flash"]:Kill()
 84		if tab then
 85			tab:StripTextures()
 86			tab:GetNormalTexture():SetTexCoord(.08, .92, .08, .92)
 87			tab:GetNormalTexture():ClearAllPoints()
 88
 89			tab:GetNormalTexture():Point("TOPLEFT", 2, -2)
 90			tab:GetNormalTexture():Point("BOTTOMRIGHT", -2, 2)
 91			
 92			tab:CreateBackdrop("Transparent")
 93			tab.backdrop:SetAllPoints()
 94			tab:StyleButton(true)				
 95			
 96			local point, relatedTo, point2, x, y = tab:GetPoint()
 97			tab:Point(point, relatedTo, point2, 1, y)
 98		end
 99	end
100
101	local function SkinSkillLine()
102		for i=1, MAX_SKILLLINE_TABS do
103			local tab = _G["SpellBookSkillLineTab"..i]
104			local _, _, _, _, isGuild = GetSpellTabInfo(i)
105			if isGuild then
106				tab:GetNormalTexture():ClearAllPoints()
107				tab:GetNormalTexture():Point("TOPLEFT", 2, -2)
108				tab:GetNormalTexture():Point("BOTTOMRIGHT", -2, 2)	
109				tab:GetNormalTexture():SetTexCoord(.08, .92, .08, .92)					
110			end
111		end
112	end
113	hooksecurefunc("SpellBookFrame_UpdateSkillLineTabs", SkinSkillLine)			
114	SpellBookFrame:SetTemplate("Transparent")
115	SpellBookFrame:CreateShadow("Transparent")
116
117	--Profession Tab
118	local professionbuttons = {
119		"PrimaryProfession1SpellButtonTop",
120		"PrimaryProfession1SpellButtonBottom",
121		"PrimaryProfession2SpellButtonTop",
122		"PrimaryProfession2SpellButtonBottom",
123		"SecondaryProfession1SpellButtonLeft",
124		"SecondaryProfession1SpellButtonRight",
125		"SecondaryProfession2SpellButtonLeft",
126		"SecondaryProfession2SpellButtonRight",
127		"SecondaryProfession3SpellButtonLeft",
128		"SecondaryProfession3SpellButtonRight",
129		"SecondaryProfession4SpellButtonLeft",
130		"SecondaryProfession4SpellButtonRight",		
131	}
132
133	local professionheaders = {
134		"PrimaryProfession1",
135		"PrimaryProfession2",
136		"SecondaryProfession1",
137		"SecondaryProfession2",
138		"SecondaryProfession3",
139		"SecondaryProfession4",
140	}
141
142	for _, header in pairs(professionheaders) do
143		_G[header.."Missing"]:SetTextColor(1, 1, 0)
144		_G[header].missingText:SetTextColor(0.6, 0.6, 0.6)
145	end
146
147	for _, button in pairs(professionbuttons) do
148		local icon = _G[button.."IconTexture"]
149		local rank = _G[button.."SubSpellName"]
150		local button = _G[button]
151		button:StripTextures()
152
153		if rank then rank:SetTextColor(1, 1, 1) end
154		if icon then
155			icon:SetTexCoord(.08, .92, .08, .92)
156			icon:ClearAllPoints()
157			icon:Point("TOPLEFT", 2, -2)
158			icon:Point("BOTTOMRIGHT", -2, 2)
159
160			if not button.backdrop then
161				button:CreateBackdrop("Transparent", true)	
162				button.backdrop:SetAllPoints()
163			end
164		end					
165	end
166
167	local professionstatusbars = {
168		"PrimaryProfession1StatusBar",	
169		"PrimaryProfession2StatusBar",	
170		"SecondaryProfession1StatusBar",	
171		"SecondaryProfession2StatusBar",	
172		"SecondaryProfession3StatusBar",	
173		"SecondaryProfession4StatusBar",
174	}
175
176	for _, statusbar in pairs(professionstatusbars) do
177		local statusbar = _G[statusbar]
178		statusbar:StripTextures()
179		statusbar:SetStatusBarTexture(C["media"].normTex)
180		statusbar:SetStatusBarColor(0, 220/255, 0)
181		statusbar:CreateBackdrop("Transparent")
182		
183		statusbar.rankText:ClearAllPoints()
184		statusbar.rankText:SetPoint("CENTER")
185	end
186
187	--Mounts/Companions
188	for i = 1, NUM_COMPANIONS_PER_PAGE do
189		local button = _G["SpellBookCompanionButton"..i]
190		local icon = _G["SpellBookCompanionButton"..i.."IconTexture"]
191		button:StripTextures()
192		button:StyleButton(false)
193		
194		if icon then
195			icon:SetTexCoord(.08, .92, .08, .92)
196			icon:ClearAllPoints()
197			icon:Point("TOPLEFT", 2, -2)
198			icon:Point("BOTTOMRIGHT", -2, 2)
199
200			if not button.backdrop then
201				button:CreateBackdrop("Transparent", true)	
202				button.backdrop:SetAllPoints()
203			end
204		end					
205	end
206
207	T.SkinButton(SpellBookCompanionSummonButton)
208	SpellBookCompanionModelFrame:StripTextures()
209	SpellBookCompanionModelFrameShadowOverlay:StripTextures()
210	SpellBookCompanionsModelFrame:Kill()
211	SpellBookCompanionModelFrame:SetTemplate("Transparent")
212
213	T.SkinRotateButton(SpellBookCompanionModelFrameRotateRightButton)
214	T.SkinRotateButton(SpellBookCompanionModelFrameRotateLeftButton)
215	SpellBookCompanionModelFrameRotateRightButton:Point("TOPLEFT", SpellBookCompanionModelFrameRotateLeftButton, "TOPRIGHT", 3, 0)
216
217
218	--Bottom Tabs
219	for i=1, 5 do
220		T.SkinTab(_G["SpellBookFrameTabButton"..i])
221	end
222end
223
224tinsert(T.SkinFuncs["Tukui"], LoadSkin)