PageRenderTime 63ms CodeModel.GetById 33ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 0ms

/Tukui/modules/skins/achievement.lua

http://github.com/Asphyxia/Tukui
Lua | 385 lines | 323 code | 57 blank | 5 comment | 24 complexity | 681f651aaf0b29ed11bdbf3715878d6f MD5 | raw file
  1local T, C, L = unpack(select(2, ...))
  2
  3local function LoadSkin()
  4	local frames = {
  5		"AchievementFrame",
  6		"AchievementFrameCategories",
  7		"AchievementFrameSummary",
  8		"AchievementFrameHeader",
  9		"AchievementFrameSummaryCategoriesHeader",
 10		"AchievementFrameSummaryAchievementsHeader",
 11		"AchievementFrameStatsBG",
 12		"AchievementFrameAchievements",
 13		"AchievementFrameComparison",
 14		"AchievementFrameComparisonHeader",
 15		"AchievementFrameComparisonSummaryPlayer",
 16		"AchievementFrameComparisonSummaryFriend",
 17	}
 18	
 19	for _, frame in pairs(frames) do
 20		_G[frame]:StripTextures(true)
 21	end
 22	
 23	local noname_frames = {
 24		"AchievementFrameStats",
 25		"AchievementFrameSummary",
 26		"AchievementFrameAchievements",
 27		"AchievementFrameComparison"
 28	}
 29	
 30	for _, frame in pairs(noname_frames) do
 31		for i=1, _G[frame]:GetNumChildren() do
 32			local child = select(i, _G[frame]:GetChildren())
 33			if child and not child:GetName() then
 34				child:SetBackdrop(nil)
 35			end
 36		end
 37	end
 38	
 39	AchievementFrame:CreateBackdrop("Transparent")
 40	AchievementFrame.backdrop:Point("TOPLEFT", 0, 6)
 41	AchievementFrame.backdrop:SetPoint("BOTTOMRIGHT")
 42	AchievementFrameHeaderTitle:ClearAllPoints()
 43	AchievementFrameHeaderTitle:Point("TOPLEFT", AchievementFrame.backdrop, "TOPLEFT", -30, -8)
 44	AchievementFrameHeaderPoints:ClearAllPoints()
 45	AchievementFrameHeaderPoints:Point("LEFT", AchievementFrameHeaderTitle, "RIGHT", 2, 0)
 46	
 47	--Backdrops
 48	AchievementFrameCategoriesContainer:CreateBackdrop("Transparent")
 49	AchievementFrameCategoriesContainer.backdrop:Point("TOPLEFT", 0, 4)
 50	AchievementFrameCategoriesContainer.backdrop:Point("BOTTOMRIGHT", -2, -3)
 51	AchievementFrameAchievementsContainer:CreateBackdrop("Transparent")
 52	AchievementFrameAchievementsContainer.backdrop:Point("TOPLEFT", 0, 2)
 53	AchievementFrameAchievementsContainer.backdrop:Point("BOTTOMRIGHT", -3, -3)
 54	
 55	T.SkinCloseButton(AchievementFrameCloseButton, AchievementFrame.backdrop)
 56	T.SkinDropDownBox(AchievementFrameFilterDropDown)
 57	AchievementFrameFilterDropDown:Point("TOPRIGHT", AchievementFrame, "TOPRIGHT", -44, 5)
 58	
 59	-- ScrollBars
 60	T.SkinScrollBar(AchievementFrameCategoriesContainerScrollBar, 5)
 61	T.SkinScrollBar(AchievementFrameAchievementsContainerScrollBar, 5)
 62	T.SkinScrollBar(AchievementFrameStatsContainerScrollBar, 5)
 63	T.SkinScrollBar(AchievementFrameComparisonContainerScrollBar, 5)
 64	T.SkinScrollBar(AchievementFrameComparisonStatsContainerScrollBar, 5)
 65	
 66	--Tabs
 67	for i = 1, 3 do
 68		T.SkinTab(_G["AchievementFrameTab"..i])
 69		_G["AchievementFrameTab"..i]:SetFrameLevel(_G["AchievementFrameTab"..i]:GetFrameLevel() + 2)
 70	end
 71	
 72	local function SkinStatusBar(bar)
 73		bar:StripTextures()
 74		bar:SetStatusBarTexture(C["media"].normTex)
 75		bar:SetStatusBarColor(4/255, 179/255, 30/255)
 76		bar:CreateBackdrop("Transparent")
 77		
 78		if _G[bar:GetName().."Title"] then
 79			_G[bar:GetName().."Title"]:SetPoint("LEFT", 4, 0)
 80		end
 81
 82		if _G[bar:GetName().."Label"] then
 83			_G[bar:GetName().."Label"]:SetPoint("LEFT", 4, 0)
 84		end
 85		
 86		if _G[bar:GetName().."Text"] then
 87			_G[bar:GetName().."Text"]:SetPoint("RIGHT", -4, 0)
 88		end
 89	end
 90
 91	SkinStatusBar(AchievementFrameSummaryCategoriesStatusBar)
 92	SkinStatusBar(AchievementFrameComparisonSummaryPlayerStatusBar)
 93	SkinStatusBar(AchievementFrameComparisonSummaryFriendStatusBar)
 94	AchievementFrameComparisonSummaryFriendStatusBar.text:ClearAllPoints()
 95	AchievementFrameComparisonSummaryFriendStatusBar.text:SetPoint("CENTER")
 96	AchievementFrameComparisonHeader:Point("BOTTOMRIGHT", AchievementFrameComparison, "TOPRIGHT", 45, -20)
 97	
 98	for i=1, 8 do
 99		local frame = _G["AchievementFrameSummaryCategoriesCategory"..i]
100		local button = _G["AchievementFrameSummaryCategoriesCategory"..i.."Button"]
101		local highlight = _G["AchievementFrameSummaryCategoriesCategory"..i.."ButtonHighlight"]
102		SkinStatusBar(frame)
103		button:StripTextures()
104		highlight:StripTextures()
105		
106		_G[highlight:GetName().."Middle"]:SetTexture(1, 1, 1, 0.3)
107		_G[highlight:GetName().."Middle"]:SetAllPoints(frame)
108	end
109	
110	AchievementFrame:HookScript("OnShow", function()
111		for i=1, 20 do
112			local frame = _G["AchievementFrameCategoriesContainerButton"..i]
113			local lastframe = _G["AchievementFrameCategoriesContainerButton"..i-1]
114			
115			frame:StripTextures()
116			frame:StyleButton()				
117		end	
118	end)
119	
120	hooksecurefunc("AchievementFrameSummary_UpdateAchievements", function()
121		for i=1, ACHIEVEMENTUI_MAX_SUMMARY_ACHIEVEMENTS do
122			local frame = _G["AchievementFrameSummaryAchievement"..i]
123			_G["AchievementFrameSummaryAchievement"..i.."Highlight"]:Kill()
124			frame:StripTextures()
125			
126			
127			_G["AchievementFrameSummaryAchievement"..i.."Description"]:SetTextColor(0.6, 0.6, 0.6)
128			
129			if not frame.backdrop then
130				frame:CreateBackdrop("Transparent", true)
131				frame.backdrop:Point("TOPLEFT", 2, -2)
132				frame.backdrop:Point("BOTTOMRIGHT", -2, 2)
133
134				_G["AchievementFrameSummaryAchievement"..i.."IconBling"]:Kill()
135				_G["AchievementFrameSummaryAchievement"..i.."IconOverlay"]:Kill()
136				_G["AchievementFrameSummaryAchievement"..i.."Icon"]:SetTemplate("Transparent")
137				_G["AchievementFrameSummaryAchievement"..i.."Icon"]:Height(_G["AchievementFrameSummaryAchievement"..i.."Icon"]:GetHeight() - 14)
138				_G["AchievementFrameSummaryAchievement"..i.."Icon"]:Width(_G["AchievementFrameSummaryAchievement"..i.."Icon"]:GetWidth() - 14)
139				_G["AchievementFrameSummaryAchievement"..i.."Icon"]:ClearAllPoints()
140				_G["AchievementFrameSummaryAchievement"..i.."Icon"]:Point("LEFT", 6, 0)
141				_G["AchievementFrameSummaryAchievement"..i.."IconTexture"]:SetTexCoord(.08, .92, .08, .92)
142				_G["AchievementFrameSummaryAchievement"..i.."IconTexture"]:ClearAllPoints()
143				_G["AchievementFrameSummaryAchievement"..i.."IconTexture"]:Point("TOPLEFT", 2, -2)
144				_G["AchievementFrameSummaryAchievement"..i.."IconTexture"]:Point("BOTTOMRIGHT", -2, 2)
145			end
146		end				
147	end)
148	
149	for i=1, 7 do
150		local frame = _G["AchievementFrameAchievementsContainerButton"..i]
151		_G["AchievementFrameAchievementsContainerButton"..i.."Highlight"]:Kill()
152		frame:StripTextures(true)
153		frame.SetBackdropBorderColor = T.dummy
154
155		--Initiate fucked up method of creating a backdrop
156		frame.bg1 = frame:CreateTexture(nil, "BACKGROUND")
157		frame.bg1:SetDrawLayer("BACKGROUND", 4)
158		frame.bg1:SetTexture(C["media"].normTex) --Default TukUI users this is normTex, glossTex doesn't exist
159		frame.bg1:SetVertexColor(unpack(C["media"].backdropcolor))
160		frame.bg1:Point("TOPLEFT", T.mult*4, -T.mult*4)
161		frame.bg1:Point("BOTTOMRIGHT", -T.mult*4, T.mult*4)				
162		
163		frame.bg2 = frame:CreateTexture(nil, "BACKGROUND")
164		frame.bg2:SetDrawLayer("BACKGROUND", 3)
165		frame.bg2:SetTexture(0,0,0)
166		frame.bg2:Point("TOPLEFT", T.mult*3, -T.mult*3)
167		frame.bg2:Point("BOTTOMRIGHT", -T.mult*3, T.mult*3)
168		
169		frame.bg3 = frame:CreateTexture(nil, "BACKGROUND")
170		frame.bg3:SetDrawLayer("BACKGROUND", 2)
171		frame.bg3:SetTexture(unpack(C["media"].bordercolor))
172		frame.bg3:Point("TOPLEFT", T.mult*2, -T.mult*2)
173		frame.bg3:Point("BOTTOMRIGHT", -T.mult*2, T.mult*2)			
174
175		frame.bg4 = frame:CreateTexture(nil, "BACKGROUND")
176		frame.bg4:SetDrawLayer("BACKGROUND", 1)
177		frame.bg4:SetTexture(0,0,0)
178		frame.bg4:Point("TOPLEFT", T.mult, -T.mult)
179		frame.bg4:Point("BOTTOMRIGHT", -T.mult, T.mult)					
180
181
182		
183		_G["AchievementFrameAchievementsContainerButton"..i.."Description"]:SetTextColor(0.6, 0.6, 0.6)
184		_G["AchievementFrameAchievementsContainerButton"..i.."Description"].SetTextColor = T.dummy
185		_G["AchievementFrameAchievementsContainerButton"..i.."HiddenDescription"]:SetTextColor(1, 1, 1)
186		_G["AchievementFrameAchievementsContainerButton"..i.."HiddenDescription"].SetTextColor = T.dummy
187		
188		_G["AchievementFrameAchievementsContainerButton"..i.."IconBling"]:Kill()
189		_G["AchievementFrameAchievementsContainerButton"..i.."IconOverlay"]:Kill()
190		_G["AchievementFrameAchievementsContainerButton"..i.."Icon"]:SetTemplate("Transparent")
191		_G["AchievementFrameAchievementsContainerButton"..i.."Icon"]:Height(_G["AchievementFrameAchievementsContainerButton"..i.."Icon"]:GetHeight() - 14)
192		_G["AchievementFrameAchievementsContainerButton"..i.."Icon"]:Width(_G["AchievementFrameAchievementsContainerButton"..i.."Icon"]:GetWidth() - 14)
193		_G["AchievementFrameAchievementsContainerButton"..i.."Icon"]:ClearAllPoints()
194		_G["AchievementFrameAchievementsContainerButton"..i.."Icon"]:Point("LEFT", 6, 0)
195		_G["AchievementFrameAchievementsContainerButton"..i.."IconTexture"]:SetTexCoord(.08, .92, .08, .92)
196		_G["AchievementFrameAchievementsContainerButton"..i.."IconTexture"]:ClearAllPoints()
197		_G["AchievementFrameAchievementsContainerButton"..i.."IconTexture"]:Point("TOPLEFT", 2, -2)
198		_G["AchievementFrameAchievementsContainerButton"..i.."IconTexture"]:Point("BOTTOMRIGHT", -2, 2)		
199		
200		
201		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"].oborder = "Don't use sharp border" --Needed for ElvUI only
202		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"]:StripTextures()
203		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"]:SetTemplate("Transparent")
204		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"]:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check")
205		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"]:Size(12, 12)
206		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"]:GetCheckedTexture():Point("TOPLEFT", -4, 4)
207		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"]:GetCheckedTexture():Point("BOTTOMRIGHT", 4, -4)
208		
209		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"]:ClearAllPoints()
210		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"]:Point("BOTTOMLEFT", frame, "BOTTOMLEFT", 5, 5)
211		
212		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"].ClearAllPoints = T.dummy
213		_G["AchievementFrameAchievementsContainerButton"..i.."Tracked"].SetPoint = T.dummy
214	end
215
216	
217	local compares = {
218		"Player",
219		"Friend"
220	}
221	
222	for _, compare in pairs(compares) do
223		for i=1, 9 do
224			local frame = "AchievementFrameComparisonContainerButton"..i..compare
225			
226			_G[frame]:StripTextures()
227			_G[frame.."Background"]:Kill()
228			
229			_G[frame].SetBackdropBorderColor = T.dummy		
230			
231			if _G[frame.."Description"] then
232				_G[frame.."Description"]:SetTextColor(0.6, 0.6, 0.6)
233				_G[frame.."Description"].SetTextColor = T.dummy
234			end
235
236			--Initiate fucked up method of creating a backdrop
237			_G[frame].bg1 = _G[frame]:CreateTexture(nil, "BACKGROUND")
238			_G[frame].bg1:SetDrawLayer("BACKGROUND", 4)
239			_G[frame].bg1:SetTexture(C["media"].glossTex) --Default TukUI users this is normTex, glossTex doesn't exist
240			_G[frame].bg1:SetVertexColor(unpack(C["media"].backdropcolor))
241			_G[frame].bg1:Point("TOPLEFT", T.mult*4, -T.mult*4)
242			_G[frame].bg1:Point("BOTTOMRIGHT", -T.mult*4, T.mult*4)				
243			
244			_G[frame].bg2 = _G[frame]:CreateTexture(nil, "BACKGROUND")
245			_G[frame].bg2:SetDrawLayer("BACKGROUND", 3)
246			_G[frame].bg2:SetTexture(0,0,0)
247			_G[frame].bg2:Point("TOPLEFT", T.mult*3, -T.mult*3)
248			_G[frame].bg2:Point("BOTTOMRIGHT", -T.mult*3, T.mult*3)
249			
250			_G[frame].bg3 = _G[frame]:CreateTexture(nil, "BACKGROUND")
251			_G[frame].bg3:SetDrawLayer("BACKGROUND", 2)
252			_G[frame].bg3:SetTexture(unpack(C["media"].bordercolor))
253			_G[frame].bg3:Point("TOPLEFT", T.mult*2, -T.mult*2)
254			_G[frame].bg3:Point("BOTTOMRIGHT", -T.mult*2, T.mult*2)			
255
256			_G[frame].bg4 = _G[frame]:CreateTexture(nil, "BACKGROUND")
257			_G[frame].bg4:SetDrawLayer("BACKGROUND", 1)
258			_G[frame].bg4:SetTexture(0,0,0)
259			_G[frame].bg4:Point("TOPLEFT", T.mult, -T.mult)
260			_G[frame].bg4:Point("BOTTOMRIGHT", -T.mult, T.mult)	
261			
262			
263			if compare == "Friend" then
264				_G[frame.."Shield"]:Point("TOPRIGHT", _G["AchievementFrameComparisonContainerButton"..i.."Friend"], "TOPRIGHT", -20, -3)
265			end
266							
267			_G[frame.."IconBling"]:Kill()
268			_G[frame.."IconOverlay"]:Kill()
269			_G[frame.."Icon"]:SetTemplate("Transparent")
270			_G[frame.."Icon"]:Height(_G[frame.."Icon"]:GetHeight() - 14)
271			_G[frame.."Icon"]:Width(_G[frame.."Icon"]:GetWidth() - 14)
272			_G[frame.."Icon"]:ClearAllPoints()
273			_G[frame.."Icon"]:Point("LEFT", 6, 0)
274			_G[frame.."IconTexture"]:SetTexCoord(.08, .92, .08, .92)
275			_G[frame.."IconTexture"]:ClearAllPoints()
276			_G[frame.."IconTexture"]:Point("TOPLEFT", 2, -2)
277			_G[frame.."IconTexture"]:Point("BOTTOMRIGHT", -2, 2)					
278		end
279	end
280	
281	for i=1, 20 do
282		local frame = _G["AchievementFrameStatsContainerButton"..i]
283		frame:StyleButton()
284		
285		_G["AchievementFrameStatsContainerButton"..i.."BG"]:SetTexture(1, 1, 1, 0.2)
286		_G["AchievementFrameStatsContainerButton"..i.."HeaderLeft"]:Kill()
287		_G["AchievementFrameStatsContainerButton"..i.."HeaderRight"]:Kill()
288		_G["AchievementFrameStatsContainerButton"..i.."HeaderMiddle"]:Kill()
289		
290		local frame = "AchievementFrameComparisonStatsContainerButton"..i
291		_G[frame]:StripTextures()
292		_G[frame]:StyleButton()
293	
294		_G[frame.."BG"]:SetTexture(1, 1, 1, 0.2)
295		_G[frame.."HeaderLeft"]:Kill()
296		_G[frame.."HeaderRight"]:Kill()
297		_G[frame.."HeaderMiddle"]:Kill()			
298	end
299	
300	
301	hooksecurefunc("AchievementButton_GetProgressBar", function(index)
302		local frame = _G["AchievementFrameProgressBar"..index]
303		if frame then
304			if not frame.skinned then
305				frame:StripTextures()
306				frame:SetStatusBarTexture(C["media"].normTex)
307				frame:SetStatusBarColor(4/255, 179/255, 30/255)
308				frame:SetFrameLevel(frame:GetFrameLevel() + 3)
309				
310				frame:Height(frame:GetHeight() - 2)
311				
312				--Initiate fucked up method of creating a backdrop
313				frame.bg1 = frame:CreateTexture(nil, "BACKGROUND")
314				frame.bg1:SetDrawLayer("BACKGROUND", -7)
315				frame.bg1:SetTexture(unpack(C["media"].backdropcolor))
316				frame.bg1:Point("TOPLEFT", -T.mult*3, T.mult*3)
317				frame.bg1:Point("BOTTOMRIGHT", T.mult*3, -T.mult*3)
318				
319				frame.bg2 = frame:CreateTexture(nil, "BACKGROUND")
320				frame.bg2:SetDrawLayer("BACKGROUND", -6)
321				frame.bg2:SetTexture(unpack(C["media"].bordercolor))
322				frame.bg2:Point("TOPLEFT", -T.mult*2, T.mult*2)
323				frame.bg2:Point("BOTTOMRIGHT", T.mult*2, -T.mult*2)					
324
325				frame.bg3 = frame:CreateTexture(nil, "BACKGROUND")
326				frame.bg3:SetDrawLayer("BACKGROUND", -5)
327				frame.bg3:SetTexture(unpack(C["media"].backdropcolor))
328				frame.bg3:Point("TOPLEFT", -T.mult, T.mult)
329				frame.bg3:Point("BOTTOMRIGHT", T.mult, -T.mult)		
330				
331				frame.text:ClearAllPoints()
332				frame.text:SetPoint("CENTER", frame, "CENTER", 0, -1)
333				frame.text:SetJustifyH("CENTER")
334				
335				if index > 1 then
336					frame:ClearAllPoints()
337					frame:Point("TOP", _G["AchievementFrameProgressBar"..index-1], "BOTTOM", 0, -5)
338					frame.SetPoint = T.dummy
339					frame.ClearAllPoints = T.dummy
340				end
341				
342				frame.skinned = true
343			end
344
345		end
346	end)
347	
348	hooksecurefunc("AchievementObjectives_DisplayCriteria", function(objectivesFrame, id)
349		local numCriteria = GetAchievementNumCriteria(id)
350		local textStrings, metas = 0, 0
351		for i = 1, numCriteria do	
352			local criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString = GetAchievementCriteriaInfo(id, i)
353			
354			if ( criteriaType == CRITERIA_TYPE_ACHIEVEMENT and assetID ) then
355				metas = metas + 1;
356				local metaCriteria = AchievementButton_GetMeta(metas);				
357				if ( objectivesFrame.completed and completed ) then
358					metaCriteria.label:SetShadowOffset(0, 0)
359					metaCriteria.label:SetTextColor(1, 1, 1, 1);
360				elseif ( completed ) then
361					metaCriteria.label:SetShadowOffset(1, -1)
362					metaCriteria.label:SetTextColor(0, 1, 0, 1);
363				else
364					metaCriteria.label:SetShadowOffset(1, -1)
365					metaCriteria.label:SetTextColor(.6, .6, .6, 1);
366				end				
367			elseif criteriaType ~= 1 then
368				textStrings = textStrings + 1;
369				local criteria = AchievementButton_GetCriteria(textStrings);				
370				if ( objectivesFrame.completed and completed ) then
371					criteria.name:SetTextColor(1, 1, 1, 1);
372					criteria.name:SetShadowOffset(0, 0);
373				elseif ( completed ) then
374					criteria.name:SetTextColor(0, 1, 0, 1);
375					criteria.name:SetShadowOffset(1, -1);
376				else
377					criteria.name:SetTextColor(.6, .6, .6, 1);
378					criteria.name:SetShadowOffset(1, -1);
379				end		
380			end
381		end
382	end)
383end
384
385T.SkinFuncs["Blizzard_AchievementUI"] = LoadSkin