/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

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