PageRenderTime 46ms CodeModel.GetById 30ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

/Tukui/modules/skins/talent.lua

http://github.com/Asphyxia/Tukui
Lua | 357 lines | 303 code | 50 blank | 4 comment | 34 complexity | a5ab70a34b047c44dfc735f42d516fc9 MD5 | raw file
  1local T, C, L = unpack(select(2, ...))
  2
  3local function LoadSkin()
  4	--PLAYER TALENTS
  5	local buttons = {
  6		"PlayerTalentFrameToggleSummariesButton",
  7		"PlayerTalentFrameActivateButton",
  8	}
  9	PlayerTalentFrameToggleSummariesButton:Point("BOTTOM", PlayerTalentFrame, "BOTTOM",0,5)
 10
 11	for i = 1, #buttons do
 12		_G[buttons[i]]:StripTextures()
 13		T.SkinButton(_G[buttons[i]])
 14	end
 15
 16	local StripAllTextures = {
 17		"PlayerTalentFrame",
 18		"PlayerTalentFrameInset",
 19		"PlayerTalentFrameTalents",
 20		"PlayerTalentFramePanel1HeaderIcon",
 21		"PlayerTalentFramePanel2HeaderIcon",
 22		"PlayerTalentFramePanel3HeaderIcon",
 23		"PlayerTalentFramePetTalents",
 24	}
 25
 26	for _, object in pairs(StripAllTextures) do
 27		_G[object]:StripTextures()
 28	end
 29	
 30	local function StripTalentFramePanelTextures(object)
 31		for i=1, object:GetNumRegions() do
 32			local region = select(i, object:GetRegions())
 33			if region:GetObjectType() == "Texture" then
 34				if region:GetName():find("Branch") then
 35					region:SetDrawLayer("OVERLAY")
 36				else
 37					region:SetTexture(nil)
 38				end
 39			end
 40		end
 41	end
 42	
 43	StripTalentFramePanelTextures(PlayerTalentFramePanel1)
 44	StripTalentFramePanelTextures(PlayerTalentFramePanel2)
 45	StripTalentFramePanelTextures(PlayerTalentFramePanel3)
 46	StripTalentFramePanelTextures(PlayerTalentFramePetPanel)
 47	
 48	for i=1, 3 do
 49		_G["PlayerTalentFramePanel"..i.."SelectTreeButton"]:SetFrameLevel(_G["PlayerTalentFramePanel"..i.."SelectTreeButton"]:GetFrameLevel() + 5)
 50		_G["PlayerTalentFramePanel"..i.."SelectTreeButton"]:StripTextures(true)
 51		T.SkinButton(_G["PlayerTalentFramePanel"..i.."SelectTreeButton"])
 52	end
 53
 54	local KillTextures = {
 55		"PlayerTalentFramePanel1InactiveShadow",
 56		"PlayerTalentFramePanel2InactiveShadow",
 57		"PlayerTalentFramePanel3InactiveShadow",
 58		"PlayerTalentFramePanel1SummaryRoleIcon",
 59		"PlayerTalentFramePanel2SummaryRoleIcon",
 60		"PlayerTalentFramePanel3SummaryRoleIcon",
 61		"PlayerTalentFramePetShadowOverlay",
 62		"PlayerTalentFrameHeaderHelpBox",
 63	}
 64
 65	for _, texture in pairs(KillTextures) do
 66		_G[texture]:Kill()
 67	end
 68	
 69	for i=1, 3 do
 70		_G["PlayerTalentFramePanel"..i.."Arrow"]:SetFrameLevel(_G["PlayerTalentFramePanel"..i.."Arrow"]:GetFrameLevel() + 2)
 71	end
 72	PlayerTalentFramePetPanelArrow:SetFrameStrata("HIGH")
 73	
 74
 75	PlayerTalentFrame:SetTemplate("Transparent")
 76	PlayerTalentFramePanel1:CreateBackdrop("Transparent")
 77	PlayerTalentFramePanel1.backdrop:Point( "TOPLEFT", PlayerTalentFramePanel1, "TOPLEFT", 3, -3 )
 78	PlayerTalentFramePanel1.backdrop:Point( "BOTTOMRIGHT", PlayerTalentFramePanel1, "BOTTOMRIGHT", -3, 3 )
 79	PlayerTalentFramePanel2:CreateBackdrop("Transparent")
 80	PlayerTalentFramePanel2.backdrop:Point( "TOPLEFT", PlayerTalentFramePanel2, "TOPLEFT", 3, -3 )
 81	PlayerTalentFramePanel2.backdrop:Point( "BOTTOMRIGHT", PlayerTalentFramePanel2, "BOTTOMRIGHT", -3, 3 )
 82	PlayerTalentFramePanel3:CreateBackdrop("Transparent")
 83	PlayerTalentFramePanel3.backdrop:Point( "TOPLEFT", PlayerTalentFramePanel3, "TOPLEFT", 3, -3 )
 84	PlayerTalentFramePanel3.backdrop:Point( "BOTTOMRIGHT", PlayerTalentFramePanel3, "BOTTOMRIGHT", -3, 3 )
 85	PlayerTalentFrame:CreateShadow("Transparent")
 86	T.SkinCloseButton(PlayerTalentFrameCloseButton)
 87
 88	function talentpairs(inspect,pet)
 89	   local tab,tal=1,0
 90	   return function()
 91		  tal=tal+1
 92		  if tal>GetNumTalents(tab,inspect,pet) then
 93			 tal=1
 94			 tab=tab+1
 95		  end
 96		  if tab<=GetNumTalentTabs(inspect,pet) then
 97			 return tab,tal
 98		  end
 99	   end
100	end
101
102	--Skin TalentButtons
103	local function TalentButtons(self, first, i, j)
104		local button = _G["PlayerTalentFramePanel"..i.."Talent"..j]
105		local icon = _G["PlayerTalentFramePanel"..i.."Talent"..j.."IconTexture"]
106
107		if first then
108			button:StripTextures()
109		end
110		
111		if button.Rank then
112			button.Rank:SetFont(C.media.font, 12, "THINOUTLINE")
113			button.Rank:ClearAllPoints()
114			button.Rank:SetPoint("BOTTOMRIGHT")
115		end
116		
117		if icon then
118			icon:SetTexCoord(.08, .92, .08, .92)
119			button:StyleButton()
120			button.SetHighlightTexture = T.dummy
121			button.SetPushedTexture = T.dummy
122			button:GetNormalTexture():SetTexCoord(.08, .92, .08, .92)
123			button:GetPushedTexture():SetTexCoord(.08, .92, .08, .92)
124			button:GetHighlightTexture():SetAllPoints(icon)
125			button:GetPushedTexture():SetAllPoints(icon)
126			
127			icon:ClearAllPoints()
128			icon:SetAllPoints()
129			button:SetFrameLevel(button:GetFrameLevel() +1)
130			button:CreateBackdrop("Transparent", true)
131		end
132	end
133
134	local function TalentSummaryButtons(self, first, active, i, j)
135		if active then
136			button = _G["PlayerTalentFramePanel"..i.."SummaryActiveBonus1"]
137			icon = _G["PlayerTalentFramePanel"..i.."SummaryActiveBonus1Icon"]
138		else
139			button = _G["PlayerTalentFramePanel"..i.."SummaryBonus"..j]
140			icon = _G["PlayerTalentFramePanel"..i.."SummaryBonus"..j.."Icon"]
141		end
142
143		if first then
144			button:StripTextures()
145		end
146
147		if icon then
148			icon:SetTexCoord(.08, .92, .08, .92)
149			button:SetFrameLevel(button:GetFrameLevel() +1)
150			local frame = CreateFrame("Frame",nil, button)
151			frame:CreateBackdrop("Transparent", true)
152			frame:SetFrameLevel(button:GetFrameLevel() -1)
153			frame:ClearAllPoints()
154			frame:Point( "TOPLEFT", icon, "TOPLEFT", 0, 0 )
155			frame:Point( "BOTTOMRIGHT", icon, "BOTTOMRIGHT", 0, 0 )
156		end
157	end
158
159	for i=1, 2 do
160		local tab = _G["PlayerSpecTab"..i]
161		if tab then
162			local a = tab:GetRegions()
163			a:Hide()
164			tab:StripTextures()
165			tab:GetNormalTexture():SetTexCoord(.08, .92, .08, .92)
166			
167			tab:GetNormalTexture():ClearAllPoints()
168			tab:GetNormalTexture():Point("TOPLEFT", 2, -2)
169			tab:GetNormalTexture():Point("BOTTOMRIGHT", -2, 2)
170
171			tab:CreateBackdrop("Transparent")
172			tab.backdrop:SetAllPoints()
173			tab:StyleButton(true)
174		end
175	end
176
177	--Reposition tabs
178	PlayerSpecTab1:ClearAllPoints()
179	PlayerSpecTab1:SetPoint("TOPLEFT", PlayerTalentFrame, "TOPRIGHT", 2, -32)
180	PlayerSpecTab1.SetPoint = T.dummy
181	
182	local function TalentSummaryClean(i)
183		local frame = _G["PlayerTalentFramePanel"..i.."Summary"]
184		frame:SetFrameLevel(frame:GetFrameLevel() + 2)
185		frame:CreateBackdrop("Transparent")
186		frame:SetFrameLevel(frame:GetFrameLevel() +1)
187		local a,b,_,d,_,_,_,_,_,_,_,_,m,_ = frame:GetRegions()
188		a:Hide()
189		b:Hide()
190		d:Hide()
191		m:Hide()
192		
193		_G["PlayerTalentFramePanel"..i.."SummaryIcon"]:SetTexCoord(.08, .92, .08, .92)
194	end
195
196	local function TalentHeaderIcon(self, first, i)
197		local button = _G["PlayerTalentFramePanel"..i.."HeaderIcon"]
198		local icon = _G["PlayerTalentFramePanel"..i.."HeaderIconIcon"]
199		local panel = _G["PlayerTalentFramePanel"..i]
200		local text = _G["PlayerTalentFramePanel"..i.."HeaderIconPointsSpent"]
201
202		if first then
203			button:StripTextures()
204		end
205		
206		_G["PlayerTalentFramePanel"..i.."HeaderIconPointsSpent"]:SetFont(C.media.font, 12, "THINOUTLINE")
207
208		if icon then
209			icon:SetTexCoord(.08, .92, .08, .92)
210			button:SetFrameLevel(button:GetFrameLevel() +1)
211			button:ClearAllPoints()
212			button:Point("TOPLEFT",panel,"TOPLEFT", 4, -4)
213			text:SetFont(C.media.font, 12, "THINOUTLINE")
214			text:Point("BOTTOMRIGHT",button, "BOTTOMRIGHT", -1, 2)
215			local frame = CreateFrame("Frame",nil, button)
216			frame:CreateBackdrop("Transparent", true)
217			frame:SetFrameLevel(button:GetFrameLevel() +1)
218			frame:ClearAllPoints()
219			frame:Point( "TOPLEFT", icon, "TOPLEFT", 0, 0 )
220			frame:Point( "BOTTOMRIGHT", icon, "BOTTOMRIGHT", 0, 0 )
221		end
222	end		
223
224	for i=1, 3 do
225		TalentSummaryClean(i)
226		TalentHeaderIcon(nil, true, i)
227		for j=1, NUM_TALENT_COLUMNS do
228			TalentSummaryButtons(nil, true, true, i, j)
229			TalentSummaryButtons(nil, true, false, i, j)
230		end
231	end
232
233	for tab,talent in talentpairs() do
234		TalentButtons(nil, true, tab, talent)
235	end
236
237	for i=1, 3 do
238		T.SkinTab(_G["PlayerTalentFrameTab"..i])
239	end
240
241	--PET TALENTS
242	T.SkinRotateButton(PlayerTalentFramePetModelRotateLeftButton)
243	T.SkinRotateButton(PlayerTalentFramePetModelRotateRightButton)
244	PlayerTalentFramePetModelRotateLeftButton:Point("BOTTOM", PlayerTalentFramePetModel, "BOTTOM", -4, 4)
245	PlayerTalentFramePetModelRotateRightButton:Point("TOPLEFT", PlayerTalentFramePetModelRotateLeftButton, "TOPRIGHT", 4, 0)
246	PlayerTalentFramePetPanel:CreateBackdrop("Transparent")
247	PlayerTalentFramePetPanel.backdrop:Point( "TOPLEFT", PlayerTalentFramePetPanel, "TOPLEFT", 3, -3 )
248	PlayerTalentFramePetPanel.backdrop:Point( "BOTTOMRIGHT", PlayerTalentFramePetPanel, "BOTTOMRIGHT", -3, 3 )
249	PlayerTalentFramePetModel:CreateBackdrop("Transparent")
250	PlayerTalentFramePetModel.backdrop:Point( "TOPLEFT", PlayerTalentFramePetModel, "TOPLEFT")
251	PlayerTalentFramePetModel.backdrop:Point( "BOTTOMRIGHT", PlayerTalentFramePetModel, "BOTTOMRIGHT")
252	T.SkinButton(PlayerTalentFrameLearnButton, true)
253	T.SkinButton(PlayerTalentFrameResetButton, true)
254	
255	local function PetHeaderIcon(self, first)
256		local button = _G["PlayerTalentFramePetPanelHeaderIcon"]
257		local icon = _G["PlayerTalentFramePetPanelHeaderIconIcon"]
258		local panel = _G["PlayerTalentFramePetPanel"]
259		local d = select(4, button:GetRegions())
260
261		if first then
262			button:StripTextures()
263		end
264
265		if icon then
266			d:ClearAllPoints()
267			pointsSpent = select(5,GetTalentTabInfo( 1, Partycheck, true, 1 ))
268			icon:SetTexCoord(.08, .92, .08, .92)
269			button:SetFrameLevel(button:GetFrameLevel() +1)
270			button:ClearAllPoints()
271			button:Point("TOPLEFT",panel,"TOPLEFT", 5, -5)
272			local text = button:FontString(nil, C.media.font, 12, "THINOUTLINE")
273			text:Point("BOTTOMRIGHT",button, "BOTTOMRIGHT", -1, 2)
274			text:SetText(pointsSpent)
275			local frame = CreateFrame("Frame",nil, button)
276			frame:CreateBackdrop("Transparent", true)
277			frame:SetFrameLevel(button:GetFrameLevel() +1)
278			frame:ClearAllPoints()
279			frame:Point( "TOPLEFT", icon, "TOPLEFT", 0, 0 )
280			frame:Point( "BOTTOMRIGHT", icon, "BOTTOMRIGHT", 0, 0 )
281		end
282	end
283
284	local function PetInfoIcon(self, first)
285		local button = _G["PlayerTalentFramePetInfo"]
286		local icon = _G["PlayerTalentFramePetIcon"]
287		local panel = _G["PlayerTalentFramePetModel"]
288
289		PlayerTalentFramePetDiet:Hide();
290
291		local petFoodList = { GetPetFoodTypes() };
292		if #petFoodList > 0 then
293			diet = petFoodList[1]
294		else
295			diet = "None"
296		end
297
298		if first then
299			button:StripTextures()
300		end
301
302		if icon then
303			icon:SetTexCoord(.08, .92, .08, .92)
304			button:SetFrameLevel(button:GetFrameLevel() +1)
305			button:ClearAllPoints()
306			button:Point("BOTTOMLEFT",panel,"TOPLEFT", 0, 10)
307			local text = button:FontString(nil, C.media.font, 12, "THINOUTLINE")
308			text:Point("TOPRIGHT",button, "TOPRIGHT", 0, -10)
309			text:SetText(diet)
310			local frame = CreateFrame("Frame",nil, button)
311			frame:CreateBackdrop("Transparent", true)
312			frame:SetFrameLevel(button:GetFrameLevel() +1)
313			frame:ClearAllPoints()
314			frame:Point( "TOPLEFT", icon, "TOPLEFT", 0, 0 )
315			frame:Point( "BOTTOMRIGHT", icon, "BOTTOMRIGHT", 0, 0 )
316		end
317	end	
318
319	local function PetTalentButtons(self, first, i)
320		local button = _G["PlayerTalentFramePetPanelTalent"..i]
321		local icon = _G["PlayerTalentFramePetPanelTalent"..i.."IconTexture"]
322
323		if first then
324			button:StripTextures()
325		end
326		
327		if button.Rank then
328			button.Rank:SetFont(C.media.font, 12, "THINOUTLINE")
329			button.Rank:ClearAllPoints()
330			button.Rank:SetPoint("BOTTOMRIGHT")
331		end
332		
333		if icon then
334			button:StyleButton()
335			button.SetHighlightTexture = T.dummy
336			button.SetPushedTexture = T.dummy
337			button:GetNormalTexture():SetTexCoord(.08, .92, .08, .92)
338			button:GetPushedTexture():SetTexCoord(.08, .92, .08, .92)
339			button:GetHighlightTexture():SetAllPoints(icon)
340			button:GetPushedTexture():SetAllPoints(icon)
341			
342			icon:SetTexCoord(.08, .92, .08, .92)
343			icon:ClearAllPoints()
344			icon:SetAllPoints()
345			button:SetFrameLevel(button:GetFrameLevel() +1)
346			button:CreateBackdrop("Transparent", true)
347		end
348	end	
349
350	PetInfoIcon(nil, true)
351	PetHeaderIcon(nil, true)
352	for i=1,GetNumTalents(1,false,true) do
353		PetTalentButtons(nil,true,i)
354	end
355end
356
357T.SkinFuncs["Blizzard_TalentUI"] = LoadSkin