PageRenderTime 44ms CodeModel.GetById 23ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/Tukui/modules/skins/character.lua

http://github.com/Asphyxia/Tukui
Lua | 312 lines | 255 code | 42 blank | 15 comment | 27 complexity | 06b18b9f428753c47080dff999b3aed8 MD5 | raw file
  1local T, C, L = unpack(select(2, ...))
  2
  3local function LoadSkin()
  4	T.SkinCloseButton(CharacterFrameCloseButton)
  5
  6	T.SkinScrollBar(CharacterStatsPaneScrollBar)
  7	T.SkinScrollBar(ReputationListScrollFrameScrollBar)
  8	local slots = {
  9		"HeadSlot",
 10		"NeckSlot",
 11		"ShoulderSlot",
 12		"BackSlot",
 13		"ChestSlot",
 14		"ShirtSlot",
 15		"TabardSlot",
 16		"WristSlot",
 17		"HandsSlot",
 18		"WaistSlot",
 19		"LegsSlot",
 20		"FeetSlot",
 21		"Finger0Slot",
 22		"Finger1Slot",
 23		"Trinket0Slot",
 24		"Trinket1Slot",
 25		"MainHandSlot",
 26		"SecondaryHandSlot",
 27		"RangedSlot",
 28	}
 29	for _, slot in pairs(slots) do
 30		local icon = _G["Character"..slot.."IconTexture"]
 31		local slot = _G["Character"..slot]
 32		slot:StripTextures()
 33		slot:StyleButton(false)
 34		icon:SetTexCoord(.08, .92, .08, .92)
 35		icon:ClearAllPoints()
 36		icon:Point("TOPLEFT", 2, -2)
 37		icon:Point("BOTTOMRIGHT", -2, 2)
 38		
 39		slot:SetFrameLevel(slot:GetFrameLevel() + 2)
 40		slot:CreateBackdrop("Transparent")
 41		slot.backdrop:SetAllPoints()
 42	end
 43
 44	--Strip Textures
 45	local charframe = {
 46		"CharacterFrame",
 47		"CharacterModelFrame",
 48		"CharacterFrameInset", 
 49		"CharacterStatsPane",
 50		"CharacterFrameInsetRight",
 51		"PaperDollSidebarTabs",
 52		"PaperDollEquipmentManagerPane",
 53		"PaperDollFrameItemFlyout",
 54	}
 55
 56	CharacterFrameExpandButton:Size(CharacterFrameExpandButton:GetWidth() - 7, CharacterFrameExpandButton:GetHeight() - 7)
 57	T.SkinNextPrevButton(CharacterFrameExpandButton)
 58
 59	T.SkinRotateButton(CharacterModelFrameRotateLeftButton)
 60	T.SkinRotateButton(CharacterModelFrameRotateRightButton)
 61	CharacterModelFrameRotateLeftButton:Point("TOPLEFT", CharacterModelFrame, "TOPLEFT", 4, -4)
 62	CharacterModelFrameRotateRightButton:Point("TOPLEFT", CharacterModelFrameRotateLeftButton, "TOPRIGHT", 4, 0)
 63
 64	--Swap item flyout frame (shown when holding alt over a slot)
 65	PaperDollFrameItemFlyout:HookScript("OnShow", function()
 66		PaperDollFrameItemFlyoutButtons:StripTextures()
 67		
 68		for i=1, PDFITEMFLYOUT_MAXITEMS do
 69			local button = _G["PaperDollFrameItemFlyoutButtons"..i]
 70			local icon = _G["PaperDollFrameItemFlyoutButtons"..i.."IconTexture"]
 71			if button then
 72				button:StyleButton(false)
 73				
 74				icon:SetTexCoord(.08, .92, .08, .92)
 75				button:GetNormalTexture():SetTexture(nil)
 76				
 77				icon:ClearAllPoints()
 78				icon:Point("TOPLEFT", 2, -2)
 79				icon:Point("BOTTOMRIGHT", -2, 2)	
 80				button:SetFrameLevel(button:GetFrameLevel() + 2)
 81				if not button.backdrop then
 82					button:CreateBackdrop("Transparent")
 83					button.backdrop:SetAllPoints()			
 84				end
 85			end
 86		end
 87	end)
 88
 89	--Icon in upper right corner of character frame
 90	CharacterFramePortrait:Kill()
 91	CharacterModelFrame:CreateBackdrop("Transparent")
 92
 93	local scrollbars = {
 94		"PaperDollTitlesPaneScrollBar",
 95		"PaperDollEquipmentManagerPaneScrollBar",
 96	}
 97
 98	for _, scrollbar in pairs(scrollbars) do
 99		T.SkinScrollBar(_G[scrollbar])
100	end
101
102	for _, object in pairs(charframe) do
103		_G[object]:StripTextures()
104	end
105
106	--Titles
107	PaperDollTitlesPane:HookScript("OnShow", function(self)
108		for x, object in pairs(PaperDollTitlesPane.buttons) do
109			object.BgTop:SetTexture(nil)
110			object.BgBottom:SetTexture(nil)
111			object.BgMiddle:SetTexture(nil)
112
113			object.Check:SetTexture(nil)
114			object.text:SetFont(C["media"].font,12)
115			object.text.SetFont = T.dummy
116		end
117	end)
118
119	--Equipement Manager
120	T.SkinButton(PaperDollEquipmentManagerPaneEquipSet)
121	T.SkinButton(PaperDollEquipmentManagerPaneSaveSet)
122	PaperDollEquipmentManagerPaneEquipSet:Width(PaperDollEquipmentManagerPaneEquipSet:GetWidth() - 8)
123	PaperDollEquipmentManagerPaneSaveSet:Width(PaperDollEquipmentManagerPaneSaveSet:GetWidth() - 8)
124	PaperDollEquipmentManagerPaneEquipSet:Point("TOPLEFT", PaperDollEquipmentManagerPane, "TOPLEFT", 8, 0)
125	PaperDollEquipmentManagerPaneSaveSet:Point("LEFT", PaperDollEquipmentManagerPaneEquipSet, "RIGHT", 4, 0)
126	PaperDollEquipmentManagerPaneEquipSet.ButtonBackground:SetTexture(nil)
127	PaperDollEquipmentManagerPane:HookScript("OnShow", function(self)
128		for x, object in pairs(PaperDollEquipmentManagerPane.buttons) do
129			object.BgTop:SetTexture(nil)
130			object.BgBottom:SetTexture(nil)
131			object.BgMiddle:SetTexture(nil)
132
133			object.Check:SetTexture(nil)
134			object.icon:SetTexCoord(.08, .92, .08, .92)
135			object:SetTemplate("Transparent")
136			
137		end
138		GearManagerDialogPopup:StripTextures()
139		GearManagerDialogPopup:SetTemplate("Transparent")
140		GearManagerDialogPopup:Point("LEFT", PaperDollFrame, "RIGHT", 4, 0)
141		GearManagerDialogPopupScrollFrame:StripTextures()
142		GearManagerDialogPopupEditBox:StripTextures()
143		GearManagerDialogPopupEditBox:SetTemplate("Transparent")
144		T.SkinButton(GearManagerDialogPopupOkay)
145		T.SkinButton(GearManagerDialogPopupCancel)
146		
147		for i=1, NUM_GEARSET_ICONS_SHOWN do
148			local button = _G["GearManagerDialogPopupButton"..i]
149			local icon = button.icon
150			
151			if button then
152				button:StripTextures()
153				button:StyleButton(true)
154				
155				icon:SetTexCoord(.08, .92, .08, .92)
156				_G["GearManagerDialogPopupButton"..i.."Icon"]:SetTexture(nil)
157				
158				icon:ClearAllPoints()
159				icon:Point("TOPLEFT", 2, -2)
160				icon:Point("BOTTOMRIGHT", -2, 2)	
161				button:SetFrameLevel(button:GetFrameLevel() + 2)
162				if not button.backdrop then
163					button:CreateBackdrop("Transparent")
164					button.backdrop:SetAllPoints()			
165				end
166			end
167		end
168	end)
169
170	--Handle Tabs at bottom of character frame
171	for i=1, 4 do
172		T.SkinTab(_G["CharacterFrameTab"..i])
173	end
174
175	--Buttons used to toggle between equipment manager, titles, and character stats
176	local function FixSidebarTabCoords()
177		for i=1, #PAPERDOLL_SIDEBARS do
178			local tab = _G["PaperDollSidebarTab"..i]
179			if tab then
180				tab.Highlight:SetTexture(1, 1, 1, 0.3)
181				tab.Highlight:Point("TOPLEFT", 3, -4)
182				tab.Highlight:Point("BOTTOMRIGHT", -1, 0)
183				tab.Hider:SetTexture(0.4,0.4,0.4,0.4)
184				tab.Hider:Point("TOPLEFT", 3, -4)
185				tab.Hider:Point("BOTTOMRIGHT", -1, 0)
186				tab.TabBg:Kill()
187				
188				if i == 1 then
189					for i=1, tab:GetNumRegions() do
190						local region = select(i, tab:GetRegions())
191						region:SetTexCoord(0.16, 0.86, 0.16, 0.86)
192						region.SetTexCoord = T.dummy
193					end
194				end
195				tab:CreateBackdrop("Transparent")
196				tab.backdrop:Point("TOPLEFT", 1, -2)
197				tab.backdrop:Point("BOTTOMRIGHT", 1, -2)	
198			end
199		end
200	end
201	hooksecurefunc("PaperDollFrame_UpdateSidebarTabs", FixSidebarTabCoords)
202
203	--Stat panels, atm it looks like 7 is the max
204	for i=1, 7 do
205		_G["CharacterStatsPaneCategory"..i]:StripTextures()
206	end
207
208	--Reputation
209	local function UpdateFactionSkins()
210		ReputationListScrollFrame:StripTextures()
211		ReputationFrame:StripTextures(true)
212		for i=1, GetNumFactions() do
213			local statusbar = _G["ReputationBar"..i.."ReputationBar"]
214
215			if statusbar then
216				statusbar:SetStatusBarTexture(C["media"].normTex)
217				
218				if not statusbar.backdrop then
219					statusbar:CreateBackdrop("Transparent")
220				end
221				
222				_G["ReputationBar"..i.."Background"]:SetTexture(nil)
223				_G["ReputationBar"..i.."LeftLine"]:Kill()
224				_G["ReputationBar"..i.."BottomLine"]:Kill()
225				_G["ReputationBar"..i.."ReputationBarHighlight1"]:SetTexture(nil)
226				_G["ReputationBar"..i.."ReputationBarHighlight2"]:SetTexture(nil)	
227				_G["ReputationBar"..i.."ReputationBarAtWarHighlight1"]:SetTexture(nil)
228				_G["ReputationBar"..i.."ReputationBarAtWarHighlight2"]:SetTexture(nil)
229				_G["ReputationBar"..i.."ReputationBarLeftTexture"]:SetTexture(nil)
230				_G["ReputationBar"..i.."ReputationBarRightTexture"]:SetTexture(nil)
231				
232			end		
233		end
234		ReputationDetailFrame:StripTextures()
235		ReputationDetailFrame:SetTemplate("Transparent")
236		ReputationDetailFrame:Point("TOPLEFT", ReputationFrame, "TOPRIGHT", 4, -28)			
237		T.SkinCheckBox(ReputationDetailAtWarCheckBox)
238		T.SkinCheckBox(ReputationDetailInactiveCheckBox)
239		T.SkinCheckBox(ReputationDetailMainScreenCheckBox)
240		T.SkinCloseButton(ReputationDetailCloseButton)
241	end	
242	ReputationFrame:HookScript("OnShow", UpdateFactionSkins)
243	hooksecurefunc("ReputationFrame_OnEvent", UpdateFactionSkins)
244
245	--Currency
246	TokenFrame:HookScript("OnShow", function()
247		for i=1, GetCurrencyListSize() do
248			local button = _G["TokenFrameContainerButton"..i]
249			
250			if button then
251				button.highlight:Kill()
252				button.categoryMiddle:Kill()	
253				button.categoryLeft:Kill()	
254				button.categoryRight:Kill()
255				
256				if button.icon then
257					button.icon:SetTexCoord(.08, .92, .08, .92)
258				end
259			end
260		end
261		TokenFramePopup:StripTextures()
262		TokenFramePopup:SetTemplate("Transparent")
263		TokenFramePopup:Point("TOPLEFT", TokenFrame, "TOPRIGHT", 4, -28)
264		T.SkinCheckBox(TokenFramePopupInactiveCheckBox)
265		T.SkinCheckBox(TokenFramePopupBackpackCheckBox)
266		T.SkinCloseButton(TokenFramePopupCloseButton)		
267	end)
268
269	--Pet
270	PetModelFrame:CreateBackdrop("Transparent")
271	PetPaperDollFrameExpBar:StripTextures()
272	PetPaperDollFrameExpBar:SetStatusBarTexture(C["media"].normTex)
273	PetPaperDollFrameExpBar:CreateBackdrop("Transparent")
274	T.SkinRotateButton(PetModelFrameRotateRightButton)
275	T.SkinRotateButton(PetModelFrameRotateLeftButton)
276	PetModelFrameRotateRightButton:ClearAllPoints()
277	PetModelFrameRotateRightButton:Point("LEFT", PetModelFrameRotateLeftButton, "RIGHT", 4, 0)
278
279	local xtex = PetPaperDollPetInfo:GetRegions()
280	xtex:SetTexCoord(.12, .63, .15, .55)
281	PetPaperDollPetInfo:CreateBackdrop("Transparent")
282	PetPaperDollPetInfo:Size(24, 24)
283
284	-- a request to color item by rarity on character frame.
285	local function ColorItemBorder()
286		for _, slot in pairs(slots) do
287			-- Colour the equipment slots by rarity
288			local target = _G["Character"..slot]
289			local slotId, _, _ = GetInventorySlotInfo(slot)
290			local itemId = GetInventoryItemID("player", slotId)
291			
292			if itemId then
293				local _, _, rarity, _, _, _, _, _, _, _, _ = GetItemInfo(itemId)
294				if rarity then				
295					target.backdrop:SetBackdropBorderColor(GetItemQualityColor(rarity))
296				end
297			else
298				target.backdrop:SetBackdropBorderColor(unpack(C.media.bordercolor))
299			end
300		end
301	end
302	
303	-- execute item coloring everytime we open character frame
304	CharacterFrame:HookScript("OnShow", ColorItemBorder)
305	
306	-- execute item coloring everytime an item is changed
307	local CheckItemBorderColor = CreateFrame("Frame")
308	CheckItemBorderColor:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
309	CheckItemBorderColor:SetScript("OnEvent", ColorItemBorder)
310end
311
312tinsert(T.SkinFuncs["Tukui"], LoadSkin)