Advertisement
pr0fite

API

Jun 17th, 2017
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.51 KB | None | 0 0
  1. local AS = unpack(AddOnSkins)
  2.  
  3. local Color = RAID_CLASS_COLORS[AS.MyClass]
  4.  
  5. function AS:SetTemplate(Frame, Template, UseTexture, TextureFile)
  6. local Texture = AS.Blank
  7.  
  8. if UseTexture then
  9. Texture = TextureFile or AS.NormTex
  10. end
  11.  
  12. if AS.PixelPerfect then
  13. Frame:SetBackdrop({
  14. bgFile = Texture,
  15. edgeFile = AS.Blank,
  16. tile = false, tileSize = 0, edgeSize = 1,
  17. insets = {left = 0, right = 0, top = 0, bottom = 0},
  18. })
  19. else
  20. Frame:SetBackdrop({
  21. bgFile = Texture,
  22. edgeFile = AS.Blank,
  23. tile = false, tileSize = 0, edgeSize = 1,
  24. insets = { left = -0, right = -0, top = -0, bottom = -0},
  25. })
  26.  
  27. if not Frame.isInsetDone then
  28. Frame.InsetTop = Frame:CreateTexture(nil, "BORDER")
  29. Frame.InsetTop:Point("TOPLEFT", Frame, "TOPLEFT", -0, 0)
  30. Frame.InsetTop:Point("TOPRIGHT", Frame, "TOPRIGHT", 0, -0)
  31. Frame.InsetTop:Height(2)
  32. Frame.InsetTop:SetColorTexture(0,0,0)
  33. Frame.InsetTop:SetDrawLayer("BORDER", -7)
  34.  
  35. Frame.InsetBottom = Frame:CreateTexture(nil, "BORDER")
  36. Frame.InsetBottom:Point("BOTTOMLEFT", Frame, "BOTTOMLEFT", -0, -0)
  37. Frame.InsetBottom:Point("BOTTOMRIGHT", Frame, "BOTTOMRIGHT", 0, -0)
  38. Frame.InsetBottom:Height(2)
  39. Frame.InsetBottom:SetColorTexture(0,0,0)
  40. Frame.InsetBottom:SetDrawLayer("BORDER", -7)
  41.  
  42. Frame.InsetLeft = Frame:CreateTexture(nil, "BORDER")
  43. Frame.InsetLeft:Point("TOPLEFT", Frame, "TOPLEFT", -0, 0)
  44. Frame.InsetLeft:Point("BOTTOMLEFT", Frame, "BOTTOMLEFT", 0, -0)
  45. Frame.InsetLeft:Width(2)
  46. Frame.InsetLeft:SetColorTexture(0,0,0)
  47. Frame.InsetLeft:SetDrawLayer("BORDER", -7)
  48.  
  49. Frame.InsetRight = Frame:CreateTexture(nil, "BORDER")
  50. Frame.InsetRight:Point("TOPRIGHT", Frame, "TOPRIGHT", 0, 0)
  51. Frame.InsetRight:Point("BOTTOMRIGHT", Frame, "BOTTOMRIGHT", -0, -0)
  52. Frame.InsetRight:Width(2)
  53. Frame.InsetRight:SetColorTexture(0,0,0)
  54. Frame.InsetRight:SetDrawLayer("BORDER", -7)
  55.  
  56. Frame.InsetInsideTop = Frame:CreateTexture(nil, "BORDER")
  57. Frame.InsetInsideTop:Point("TOPLEFT", Frame, "TOPLEFT", 0, -0)
  58. Frame.InsetInsideTop:Point("TOPRIGHT", Frame, "TOPRIGHT", -0, 0)
  59. Frame.InsetInsideTop:Height(2)
  60. Frame.InsetInsideTop:SetColorTexture(0,0,0)
  61. Frame.InsetInsideTop:SetDrawLayer("BORDER", -7)
  62.  
  63. Frame.InsetInsideBottom = Frame:CreateTexture(nil, "BORDER")
  64. Frame.InsetInsideBottom:Point("BOTTOMLEFT", Frame, "BOTTOMLEFT", 0, 0)
  65. Frame.InsetInsideBottom:Point("BOTTOMRIGHT", Frame, "BOTTOMRIGHT", -0, 0)
  66. Frame.InsetInsideBottom:Height(2)
  67. Frame.InsetInsideBottom:SetColorTexture(0,0,0)
  68. Frame.InsetInsideBottom:SetDrawLayer("BORDER", -7)
  69.  
  70. Frame.InsetInsideLeft = Frame:CreateTexture(nil, "BORDER")
  71. Frame.InsetInsideLeft:Point("TOPLEFT", Frame, "TOPLEFT", 0, -0)
  72. Frame.InsetInsideLeft:Point("BOTTOMLEFT", Frame, "BOTTOMLEFT", -0, 0)
  73. Frame.InsetInsideLeft:Width(2)
  74. Frame.InsetInsideLeft:SetColorTexture(0,0,0)
  75. Frame.InsetInsideLeft:SetDrawLayer("BORDER", -7)
  76.  
  77. Frame.InsetInsideRight = Frame:CreateTexture(nil, "BORDER")
  78. Frame.InsetInsideRight:Point("TOPRIGHT", Frame, "TOPRIGHT", -0, -0)
  79. Frame.InsetInsideRight:Point("BOTTOMRIGHT", Frame, "BOTTOMRIGHT", 0, 0)
  80. Frame.InsetInsideRight:Width(2)
  81. Frame.InsetInsideRight:SetColorTexture(0,0,0)
  82. Frame.InsetInsideRight:SetDrawLayer("BORDER", -7)
  83.  
  84. Frame.isInsetDone = true
  85. end
  86. end
  87. local R, G, B = unpack(AS.BackdropColor)
  88. local Alpha = (Template == "Transparent" and .8 or 1)
  89.  
  90. if AS:CheckAddOn('ElvUI') then
  91. if Template == "Transparent" then
  92. R, G, B, Alpha = unpack(ElvUI[1]["media"].backdropfadecolor)
  93. else
  94. R, G, B = unpack(ElvUI[1]["media"].backdropcolor)
  95. end
  96.  
  97. Frame.template = Template
  98. ElvUI[1]["frames"][Frame] = true
  99. end
  100.  
  101. Frame:SetBackdropBorderColor(unpack(AS.BorderColor))
  102. Frame:SetBackdropColor(R, G, B, Alpha)
  103. end
  104.  
  105. local Insets = {
  106. InsetTop,
  107. InsetBottom,
  108. InsetLeft,
  109. InsetRight,
  110. InsetInsideTop,
  111. InsetInsideBottom,
  112. InsetInsideLeft,
  113. InsetInsideRight,
  114. }
  115.  
  116. function AS:HideInset(Frame)
  117. for _, Inset in pairs(Insets) do
  118. Frame[Inset]:Hide()
  119. end
  120. end
  121.  
  122. function AS:CreateBackdrop(Frame, Template, UseTexture, TextureFile)
  123. if Frame.Backdrop then return end
  124. if not Template then Template = AS:CheckOption('SkinTemplate') end
  125.  
  126. local Backdrop = CreateFrame("Frame", nil, Frame)
  127. Backdrop:SetOutside()
  128. AS:SetTemplate(Backdrop, Template, UseTexture, TextureFile)
  129.  
  130. if Frame:GetFrameLevel() - 1 >= 0 then
  131. Backdrop:SetFrameLevel(Frame:GetFrameLevel() - 1)
  132. else
  133. Backdrop:SetFrameLevel(0)
  134. end
  135.  
  136. Frame.Backdrop = Backdrop
  137. end
  138.  
  139. function AS:StripTextures(Object, Kill, Alpha)
  140. for i = 1, Object:GetNumRegions() do
  141. local Region = select(i, Object:GetRegions())
  142. if Region and Region:GetObjectType() == "Texture" then
  143. if Kill then
  144. Region:Kill()
  145. --Region:SetParent(AS.Hider)
  146. elseif Alpha then
  147. Region:SetAlpha(0)
  148. else
  149. Region:SetTexture(nil)
  150. end
  151. end
  152. end
  153. end
  154.  
  155. local BlizzardRegions = {
  156. 'Left',
  157. 'Middle',
  158. 'Right',
  159. 'Mid',
  160. 'LeftDisabled',
  161. 'MiddleDisabled',
  162. 'RightDisabled',
  163. }
  164.  
  165. function AS:SkinButton(Button, Strip)
  166. if Button.isSkinned then return end
  167.  
  168. local ButtonName = Button:GetName()
  169.  
  170. if ButtonName then
  171. for _, Region in pairs(BlizzardRegions) do
  172. if _G[ButtonName..Region] then
  173. _G[ButtonName..Region]:SetAlpha(0)
  174. end
  175. end
  176. end
  177.  
  178. for _, Region in pairs(BlizzardRegions) do
  179. if Button[Region] then
  180. Button[Region]:SetAlpha(0)
  181. end
  182. end
  183.  
  184. if Button.SetNormalTexture then Button:SetNormalTexture("") end
  185. if Button.SetHighlightTexture then Button:SetHighlightTexture("") end
  186. if Button.SetPushedTexture then Button:SetPushedTexture("") end
  187. if Button.SetDisabledTexture then Button:SetDisabledTexture("") end
  188.  
  189. AS:SkinFrame(Button, nil, not Strip)
  190.  
  191. if AS:CheckAddOn('ElvUI') and AS:CheckOption('ElvUISkinModule') then
  192. AS:SetTemplate(Button, 'Default', true)
  193. end
  194.  
  195. Button:HookScript("OnEnter", function(self)
  196. if AS.ValueColor then
  197. self:SetBackdropBorderColor(unpack(AS.ValueColor))
  198. else
  199. self:SetBackdropBorderColor(Color.r, Color.g, Color.b)
  200. end
  201. end)
  202.  
  203. Button:HookScript("OnLeave", function(self)
  204. self:SetBackdropBorderColor(unpack(AS.BorderColor))
  205. end)
  206.  
  207. if Button.Flash then
  208. Button.Flash:SetTexture(0, 0, 0, 0)
  209. --[[
  210. AS:CreateBackdrop(Button)
  211. Button.Backdrop:SetAllPoints()
  212. Button.Backdrop:SetBackdropBorderColor(1, 0, 0, 1)
  213. Button.Backdrop:SetBackdropColor(0, 0, 0, 0)
  214. Button.Backdrop:SetFrameStrata(Button:GetFrameStrata())
  215. Button.Backdrop:SetFrameLevel(Button:GetFrameLevel() + 4)
  216.  
  217. Button.Backdrop:SetScript('OnUpdate', function(self)
  218. if Button.Flash:IsShown() then
  219. self:SetAlpha(Button.Flash:GetAlpha())
  220. else
  221. self:SetAlpha(0)
  222. end
  223. end)
  224. ]]
  225. end
  226. end
  227.  
  228. function AS:CreateShadow(Frame)
  229. if Frame.Shadow then return end
  230.  
  231. local Shadow = CreateFrame("Frame", nil, Frame)
  232. Shadow:SetFrameLevel(1)
  233. Shadow:SetFrameStrata(Frame:GetFrameStrata())
  234. Shadow:Point("TOPLEFT", -3, 3)
  235. Shadow:Point("BOTTOMLEFT", -3, -3)
  236. Shadow:Point("TOPRIGHT", 3, 3)
  237. Shadow:Point("BOTTOMRIGHT", 3, -3)
  238.  
  239. Shadow:SetBackdrop({
  240. edgeFile = [[Interface\AddOns\AddOnSkins\Media\Textures\Shadows]], edgeSize = AS:Scale(3),
  241. insets = {left = AS:Scale(5), right = AS:Scale(5), top = AS:Scale(5), bottom = AS:Scale(5)},
  242. })
  243.  
  244. Shadow:SetBackdropColor(0, 0, 0, 0)
  245. Shadow:SetBackdropBorderColor(0, 0, 0, 0.8)
  246. Frame.Shadow = Shadow
  247. end
  248.  
  249. function AS:StyleButton(Button)
  250. if Button.HasStyle then return end
  251.  
  252. if Button.SetHighlightTexture then
  253. local Hover = Button:CreateTexture()
  254. Hover:SetColorTexture(1, 1, 1, 0.3)
  255. Hover:SetInside()
  256.  
  257. Button:SetHighlightTexture(Hover)
  258. end
  259.  
  260. if Button.SetPushedTexture then
  261. local Pushed = Button:CreateTexture()
  262. Pushed:SetColorTexture(0.9, 0.8, 0.1, 0.3)
  263. Pushed:SetInside()
  264.  
  265. Button:SetPushedTexture(Pushed)
  266. end
  267.  
  268. if Button.SetCheckedTexture then
  269. local Checked = Button:CreateTexture()
  270. Checked:SetColorTexture(0,1,0,.3)
  271. Checked:SetInside()
  272.  
  273. Button:SetCheckedTexture(Checked)
  274. end
  275.  
  276. local Cooldown = Button:GetName() and _G[Button:GetName().."Cooldown"]
  277.  
  278. if Cooldown then
  279. Cooldown:ClearAllPoints()
  280. Cooldown:SetInside()
  281. Cooldown:SetSwipeColor(0, 0, 0, 1)
  282. end
  283.  
  284. Button.HasStyle = true
  285. end
  286.  
  287. function AS:SkinCloseButton(CloseButton, Reposition)
  288. if CloseButton.isSkinned then return end
  289.  
  290. AS:SkinBackdropFrame(CloseButton)
  291.  
  292. CloseButton.Backdrop:Point('TOPLEFT', 7, -8)
  293. CloseButton.Backdrop:Point('BOTTOMRIGHT', -8, 8)
  294.  
  295. CloseButton:HookScript("OnEnter", function(self)
  296. self.Text:SetTextColor(1, .2, .2)
  297. if AS:CheckAddOn('ElvUI') and AS:CheckOption('ElvUISkinModule') then
  298. self.Backdrop:SetBackdropBorderColor(unpack(ElvUI[1]["media"].rgbvaluecolor))
  299. else
  300. self.Backdrop:SetBackdropBorderColor(1, .2, .2)
  301. end
  302. end)
  303.  
  304. CloseButton:HookScript("OnLeave", function(self)
  305. self.Text:SetTextColor(1, 1, 1)
  306. self.Backdrop:SetBackdropBorderColor(unpack(AS.BorderColor))
  307. end)
  308.  
  309. CloseButton.Text = CloseButton:CreateFontString(nil, "OVERLAY")
  310. CloseButton.Text:SetFont([[Interface\AddOns\AddOnSkins\Media\Fonts\PTSansNarrow.TTF]], 16, AS:CheckAddOn('ElvUI') and AS:CheckOption('ElvUISkinModule') and 'OUTLINE' or nil)
  311. CloseButton.Text:SetPoint("CENTER", CloseButton, 'CENTER')
  312. CloseButton.Text:SetJustifyH('CENTER')
  313. CloseButton.Text:SetJustifyV('MIDDLE')
  314. CloseButton.Text:SetText('x')
  315.  
  316. if Reposition then
  317. CloseButton:Point("TOPRIGHT", Reposition, "TOPRIGHT", 2, 2)
  318. end
  319.  
  320. CloseButton.isSkinned = true
  321. end
  322.  
  323. function AS:SkinEditBox(EditBox, Width, Height)
  324. if EditBox.isSkinned then return end
  325.  
  326. local EditBoxName = EditBox:GetName()
  327. if EditBoxName then
  328. for _, Region in pairs(BlizzardRegions) do
  329. if _G[EditBoxName..Region] then
  330. _G[EditBoxName..Region]:Kill()
  331. end
  332. end
  333. end
  334.  
  335. for _, Region in pairs(BlizzardRegions) do
  336. if EditBox[Region] then
  337. EditBox[Region]:Kill()
  338. end
  339. end
  340.  
  341. AS:CreateBackdrop(EditBox)
  342.  
  343. if AS:CheckAddOn('ElvUI') and AS:CheckOption('ElvUISkinModule') then
  344. AS:SetTemplate(EditBox.Backdrop, 'Default')
  345. end
  346.  
  347. if Width then EditBox:Width(Width) end
  348. if Height then EditBox:Height(Height) end
  349.  
  350. if EditBoxName and (EditBoxName:find("Silver") or EditBoxName:find("Copper")) then
  351. EditBox.Backdrop:Point("BOTTOMRIGHT", -12, -2)
  352. end
  353.  
  354. EditBox.isSkinned = true
  355. end
  356.  
  357. function AS:SkinCheckBox(CheckBox)
  358. if CheckBox.isSkinned then return end
  359. AS:StripTextures(CheckBox)
  360. AS:CreateBackdrop(CheckBox)
  361.  
  362. if AS:CheckAddOn('ElvUI') and AS:CheckOption('ElvUISkinModule') then
  363. AS:SetTemplate(CheckBox.Backdrop, 'Default')
  364. end
  365.  
  366. CheckBox.Backdrop:SetInside(CheckBox, 4, 4)
  367.  
  368. if CheckBox.SetCheckedTexture then
  369. CheckBox:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check")
  370. end
  371.  
  372. if CheckBox.SetDisabledCheckedTexture then
  373. CheckBox:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
  374. end
  375.  
  376. CheckBox:HookScript("OnDisable", function(self)
  377. if not self.SetDisabledTexture then return end
  378.  
  379. if self:GetChecked() then
  380. self:SetDisabledTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
  381. else
  382. self:SetDisabledTexture("")
  383. end
  384. end)
  385.  
  386. CheckBox.SetNormalTexture = AS.Noop
  387. CheckBox.SetPushedTexture = AS.Noop
  388. CheckBox.SetHighlightTexture = AS.Noop
  389. CheckBox.isSkinned = true
  390. end
  391.  
  392. function AS:SkinTab(Tab, Strip)
  393. if Tab.isSkinned then return end
  394. local TabName = Tab:GetName()
  395.  
  396. if TabName then
  397. for _, Region in pairs(BlizzardRegions) do
  398. if _G[TabName..Region] then
  399. _G[TabName..Region]:SetTexture(nil)
  400. end
  401. end
  402. end
  403.  
  404. for _, Region in pairs(BlizzardRegions) do
  405. if Tab[Region] then
  406. Tab[Region]:SetAlpha(0)
  407. end
  408. end
  409.  
  410. if Tab.GetHighlightTexture and Tab:GetHighlightTexture() then
  411. Tab:GetHighlightTexture():SetTexture(nil)
  412. else
  413. Strip = true
  414. end
  415.  
  416. if Strip then
  417. AS:StripTextures(Tab)
  418. end
  419.  
  420. AS:CreateBackdrop(Tab)
  421.  
  422. if AS:CheckAddOn('ElvUI') and AS:CheckOption('ElvUISkinModule') then
  423. AS:SetTemplate(Tab.Backdrop, 'Default')
  424. end
  425.  
  426. Tab.Backdrop:Point("TOPLEFT", 10, AS.PixelPerfect and -1 or -3)
  427. Tab.Backdrop:Point("BOTTOMRIGHT", -10, 3)
  428.  
  429. Tab.isSkinned = true
  430. end
  431.  
  432. local ScrollBarElements = {
  433. 'BG',
  434. 'Track',
  435. 'Top',
  436. 'Bottom',
  437. 'Middle',
  438. }
  439.  
  440. function AS:SkinScrollBar(Frame)
  441. local ScrollUpButton = Frame:GetName() and _G[Frame:GetName().."ScrollUpButton"] or Frame.ScrollUpButton
  442. local ScrollDownButton = Frame:GetName() and _G[Frame:GetName().."ScrollDownButton"] or Frame.ScrollDownButton
  443.  
  444. for _, object in pairs(ScrollBarElements) do
  445. if Frame:GetName() and _G[Frame:GetName()..object] then
  446. _G[Frame:GetName()..object]:SetTexture(nil)
  447. end
  448. end
  449.  
  450. if ScrollUpButton and ScrollDownButton then
  451. AS:StripTextures(ScrollUpButton)
  452. AS:SetTemplate(ScrollUpButton, "Default", true)
  453.  
  454. AS:StripTextures(ScrollDownButton)
  455. AS:SetTemplate(ScrollDownButton, "Default", true)
  456.  
  457. if not ScrollUpButton.Text then
  458. ScrollUpButton.Text = ScrollUpButton:CreateFontString(nil, "OVERLAY")
  459. ScrollUpButton.Text:SetFont([[Interface\AddOns\AddOnSkins\Media\Fonts\Arial.TTF]], 12)
  460. ScrollUpButton.Text:SetText("▲")
  461. ScrollUpButton.Text:SetPoint("CENTER", 0, 0)
  462.  
  463. ScrollUpButton:HookScript('OnShow', function(self)
  464. if not self:IsEnabled() then
  465. self.Text:SetTextColor(.3, .3, .3)
  466. end
  467. end)
  468.  
  469. ScrollUpButton:HookScript('OnDisable', function(self)
  470. self.Text:SetTextColor(.3, .3, .3)
  471. end)
  472.  
  473. ScrollUpButton:HookScript('OnEnable', function(self)
  474. self.Text:SetTextColor(1, 1, 1)
  475. end)
  476.  
  477. ScrollUpButton:HookScript('OnEnter', function(self)
  478. self:SetBackdropBorderColor(Color.r, Color.g, Color.b)
  479. self.Text:SetTextColor(Color.r, Color.g, Color.b)
  480. end)
  481. ScrollUpButton:HookScript('OnLeave', function(self)
  482. self:SetBackdropBorderColor(unpack(AS.BorderColor))
  483. self.Text:SetTextColor(1, 1, 1)
  484. end)
  485. end
  486.  
  487. if not ScrollDownButton.Text then
  488. ScrollDownButton.Text = ScrollDownButton:CreateFontString(nil, "OVERLAY")
  489. ScrollDownButton.Text:SetFont([[Interface\AddOns\AddOnSkins\Media\Fonts\Arial.TTF]], 12)
  490. ScrollDownButton.Text:SetText("▼")
  491. ScrollDownButton.Text:SetPoint("CENTER", 0, 0)
  492.  
  493. ScrollDownButton:HookScript('OnShow', function(self)
  494. if not self:IsEnabled() then
  495. self.Text:SetTextColor(.3, .3, .3)
  496. end
  497. end)
  498.  
  499. ScrollDownButton:HookScript('OnDisable', function(self)
  500. self.Text:SetTextColor(.3, .3, .3)
  501. end)
  502.  
  503. ScrollDownButton:HookScript('OnEnable', function(self)
  504. self.Text:SetTextColor(1, 1, 1)
  505. end)
  506.  
  507. ScrollDownButton:HookScript('OnEnter', function(self)
  508. self:SetBackdropBorderColor(Color.r, Color.g, Color.b)
  509. self.Text:SetTextColor(Color.r, Color.g, Color.b)
  510. end)
  511.  
  512. ScrollDownButton:HookScript('OnLeave', function(self)
  513. self:SetBackdropBorderColor(unpack(AS.BorderColor))
  514. self.Text:SetTextColor(1, 1, 1)
  515. end)
  516. end
  517.  
  518. if not Frame.TrackBG then
  519. Frame.TrackBG = CreateFrame("Frame", nil, Frame)
  520. Frame.TrackBG:Point("TOPLEFT", ScrollUpButton, "BOTTOMLEFT", 0, -1)
  521. Frame.TrackBG:Point("BOTTOMRIGHT", ScrollDownButton, "TOPRIGHT", 0, 1)
  522. AS:SetTemplate(Frame.TrackBG, "Transparent")
  523. end
  524.  
  525. if Frame:GetThumbTexture() then
  526. Frame:GetThumbTexture():SetTexture(nil)
  527. if not Frame.ThumbBG then
  528. Frame.ThumbBG = CreateFrame("Frame", nil, Frame)
  529. Frame.ThumbBG:Point("TOPLEFT", Frame:GetThumbTexture(), "TOPLEFT", 2, -3)
  530. Frame.ThumbBG:Point("BOTTOMRIGHT", Frame:GetThumbTexture(), "BOTTOMRIGHT", -2, 3)
  531. AS:SetTemplate(Frame.ThumbBG, "Default")
  532. if IsAddOnLoaded('ElvUI') then
  533. Frame.ThumbBG:SetBackdropColor(0.6, 0.6, 0.6)
  534. else
  535. Frame.ThumbBG:SetBackdropColor(unpack(AS.BorderColor))
  536. end
  537.  
  538. if Frame.ThumbBG then
  539. Frame.ThumbBG:SetFrameLevel(Frame.TrackBG:GetFrameLevel())
  540. end
  541. end
  542. end
  543. end
  544. end
  545.  
  546. function AS:SkinNextPrevButton(Button, Vertical)
  547. if Button.isSkinned then return end
  548. AS:SetTemplate(Button)
  549. Button:Size(Button:GetWidth() - 7, Button:GetHeight() - 7)
  550.  
  551. for i = 1, Button:GetNumRegions() do
  552. local region = select(i, Button:GetRegions())
  553. if region and region:GetObjectType() == "Texture" and region:GetTexture() == "Interface\\Buttons\\UI-PageButton-Background" then
  554. region:SetTexture('')
  555. end
  556. end
  557.  
  558. if Vertical then
  559. Button:GetNormalTexture():SetTexCoord(0.3, 0.29, 0.3, 0.72, 0.65, 0.29, 0.65, 0.72)
  560.  
  561. if Button:GetPushedTexture() then
  562. Button:GetPushedTexture():SetTexCoord(0.3, 0.35, 0.3, 0.8, 0.65, 0.35, 0.65, 0.8)
  563. end
  564.  
  565. if Button:GetDisabledTexture() then
  566. Button:GetDisabledTexture():SetTexCoord(0.3, 0.29, 0.3, 0.75, 0.65, 0.29, 0.65, 0.75)
  567. end
  568. else
  569. Button:GetNormalTexture():SetTexCoord(0.3, 0.29, 0.3, 0.81, 0.65, 0.29, 0.65, 0.81)
  570.  
  571. if Button:GetPushedTexture() then
  572. Button:GetPushedTexture():SetTexCoord(0.3, 0.35, 0.3, 0.81, 0.65, 0.35, 0.65, 0.81)
  573. end
  574.  
  575. if Button:GetDisabledTexture() then
  576. Button:GetDisabledTexture():SetTexCoord(0.3, 0.29, 0.3, 0.75, 0.65, 0.29, 0.65, 0.75)
  577. end
  578. end
  579.  
  580. Button:GetNormalTexture():ClearAllPoints()
  581. Button:GetNormalTexture():SetInside()
  582.  
  583. if Button:GetDisabledTexture() then
  584. Button:GetDisabledTexture():SetAllPoints(Button:GetNormalTexture())
  585. end
  586.  
  587. if Button:GetPushedTexture() then
  588. Button:GetPushedTexture():SetAllPoints(Button:GetNormalTexture())
  589. end
  590.  
  591. Button:GetHighlightTexture():SetColorTexture(1, 1, 1, 0.3)
  592. Button:GetHighlightTexture():SetAllPoints(Button:GetNormalTexture())
  593.  
  594. Button.isSkinned = true
  595. end
  596.  
  597. function AS:SkinRotateButton(Button)
  598. if Button.isSkinned then return end
  599.  
  600. AS:SetTemplate(Button, "Default")
  601. Button:Size(Button:GetWidth() - 14, Button:GetHeight() - 14)
  602.  
  603. Button:GetNormalTexture():SetTexCoord(0.3, 0.29, 0.3, 0.65, 0.69, 0.29, 0.69, 0.65)
  604. Button:GetPushedTexture():SetTexCoord(0.3, 0.29, 0.3, 0.65, 0.69, 0.29, 0.69, 0.65)
  605.  
  606. Button:GetHighlightTexture():SetColorTexture(1, 1, 1, 0.3)
  607.  
  608. Button:GetNormalTexture():ClearAllPoints()
  609. Button:GetNormalTexture():SetInside()
  610. Button:GetPushedTexture():SetAllPoints(Button:GetNormalTexture())
  611. Button:GetHighlightTexture():SetAllPoints(Button:GetNormalTexture())
  612.  
  613. Button.isSkinned = true
  614. end
  615.  
  616. function AS:SkinDropDownBox(Frame, Width)
  617. local Button, Text
  618. local FrameName = Frame:GetName()
  619.  
  620. if FrameName then
  621. Button = _G[Frame:GetName().."Button"]
  622. Text = _G[Frame:GetName().."Text"]
  623. else
  624. Button = Frame.Button
  625. Text = Frame.Text
  626. end
  627.  
  628. if Button and Text then
  629. AS:StripTextures(Frame)
  630. Frame:Width(Width or 155)
  631.  
  632. Text:ClearAllPoints()
  633. Text:Point("RIGHT", Button, "LEFT", -2, 0)
  634.  
  635. Button:ClearAllPoints()
  636. Button:Point("RIGHT", Frame, "RIGHT", -10, 3)
  637. Button.SetPoint = AS.Noop
  638.  
  639. AS:SkinNextPrevButton(Button, true)
  640.  
  641. AS:CreateBackdrop(Frame)
  642.  
  643. if AS:CheckAddOn('ElvUI') and AS:CheckOption('ElvUISkinModule') then
  644. AS:SetTemplate(Frame.Backdrop, 'Default')
  645. end
  646.  
  647. Frame.Backdrop:Point("TOPLEFT", 20, -2)
  648. Frame.Backdrop:Point("BOTTOMRIGHT", Button, "BOTTOMRIGHT", 2, -2)
  649. end
  650. end
  651.  
  652. function AS:SkinSlideBar(Frame, Height, MoveText)
  653. AS:StripTextures(Frame)
  654. AS:CreateBackdrop(Frame)
  655. Frame.Backdrop:SetAllPoints()
  656.  
  657. if AS:CheckAddOn('ElvUI') and AS:CheckOption('ElvUISkinModule') then
  658. AS:SetTemplate(Frame.Backdrop, 'Default')
  659. end
  660.  
  661. if not Height then
  662. Height = Frame:GetHeight()
  663. end
  664.  
  665. if MoveText then
  666. for i = 1, Frame:GetNumRegions() do
  667. local Region = select(i, Frame:GetRegions())
  668. if Region:IsObjectType('FontString') then
  669. local a, b, c, d, e = Region:GetPoint()
  670. Region:SetPoint(a, b, c, d, e - 6)
  671. end
  672. end
  673. if _G[Frame:GetName().."Text"] then _G[Frame:GetName().."Text"]:Point("TOP", 0, 19) end
  674. end
  675.  
  676. Frame.ThumbBG = CreateFrame("Frame", nil, Frame)
  677. Frame.ThumbBG:Point("TOPLEFT", Frame:GetThumbTexture(), "TOPLEFT", 2, -3)
  678. Frame.ThumbBG:Point("BOTTOMRIGHT", Frame:GetThumbTexture(), "BOTTOMRIGHT", -2, 3)
  679. AS:SetTemplate(Frame.ThumbBG, "Default", true)
  680.  
  681. if (Frame:GetWidth() < Frame:GetHeight()) then
  682. Frame:Width(Height)
  683. Frame:GetThumbTexture():Size(Frame:GetWidth(), Frame:GetWidth() + 4)
  684. else
  685. Frame:Height(Height)
  686. Frame:GetThumbTexture():Size(Height + 4, Height)
  687. end
  688. end
  689.  
  690. function AS:SkinIconButton(Button, ShrinkIcon)
  691. if Button.isSkinned then return end
  692.  
  693. local Icon, Texture
  694. local ButtonName = Button:GetName()
  695.  
  696. if Button.icon then
  697. Icon = Button.icon
  698. Texture = Button.icon:GetTexture()
  699. elseif Button.Icon then
  700. Icon = Button.Icon
  701. Texture = Button.Icon:GetTexture()
  702. elseif ButtonName then
  703. if _G[ButtonName.."IconTexture"] then
  704. Icon = _G[ButtonName.."IconTexture"]
  705. Texture = _G[ButtonName.."IconTexture"]:GetTexture()
  706. elseif _G[ButtonName.."Icon"] then
  707. Icon = _G[ButtonName.."Icon"]
  708. Texture = _G[ButtonName.."Icon"]:GetTexture()
  709. end
  710. end
  711.  
  712. if Icon then
  713. AS:SkinFrame(Button)
  714. AS:StyleButton(Button)
  715. Icon:SetTexture(Texture)
  716. AS:SkinTexture(Icon)
  717. Icon:SetInside(Button)
  718. Button.isSkinned = true
  719. end
  720. end
  721.  
  722. function AS:SkinFrame(frame, template, override, kill)
  723. if not template then template = AS:CheckOption('SkinTemplate') end
  724. if not override then AS:StripTextures(frame, kill) end
  725. AS:SetTemplate(frame, template)
  726. end
  727.  
  728. function AS:SkinBackdropFrame(frame, template, override, kill, setpoints)
  729. if not template then template = AS:CheckOption('SkinTemplate') end
  730. if not override then AS:StripTextures(frame, kill) end
  731. AS:CreateBackdrop(frame, template)
  732. if setpoints then
  733. frame.Backdrop:SetAllPoints()
  734. end
  735. end
  736.  
  737. function AS:SkinTitleBar(frame, template, override, kill)
  738. if not template then template = AS:CheckOption('SkinTemplate') end
  739. if not override then AS:StripTextures(frame, kill) end
  740. AS:SetTemplate(frame, template, true)
  741. end
  742.  
  743. function AS:SkinStatusBar(frame, ClassColor)
  744. AS:SkinBackdropFrame(frame)
  745. frame:SetStatusBarTexture(AS.NormTex)
  746. if ClassColor then
  747. local color = RAID_CLASS_COLORS[AS.MyClass]
  748. frame:SetStatusBarColor(color.r, color.g, color.b)
  749. end
  750. if AS:CheckAddOn('ElvUI') then
  751. ElvUI[1]:RegisterStatusBar(Frame)
  752. end
  753. end
  754.  
  755. function AS:SkinTooltip(tooltip, scale)
  756. tooltip:HookScript('OnShow', function(self)
  757. AS:SkinFrame(self, nil, true)
  758. if scale then self:SetScale(AS.UIScale) end
  759. end)
  760. end
  761.  
  762. function AS:SkinTexture(frame)
  763. frame:SetTexCoord(unpack(AS.TexCoords))
  764. end
  765.  
  766. function AS:Desaturate(frame, point)
  767. for i = 1, frame:GetNumRegions() do
  768. local region = select(i, frame:GetRegions())
  769. if region:IsObjectType('Texture') then
  770. local Texture = region:GetTexture()
  771. if type(Texture) == 'string' and strlower(Texture) == 'interface\\dialogframe\\ui-dialogbox-corner' then
  772. region:SetTexture(nil)
  773. region:Kill()
  774. else
  775. region:SetDesaturated(true)
  776. end
  777. end
  778. end
  779. frame:HookScript('OnUpdate', function(self)
  780. if self:GetNormalTexture() then
  781. self:GetNormalTexture():SetDesaturated(true)
  782. end
  783. if self:GetPushedTexture() then
  784. self:GetPushedTexture():SetDesaturated(true)
  785. end
  786. if self:GetHighlightTexture() then
  787. self:GetHighlightTexture():SetDesaturated(true)
  788. end
  789. end)
  790. end
  791.  
  792. function AS:AdjustForPixelPerfect(number)
  793. if AS.PixelPerfect then
  794. number = number - 1
  795. end
  796.  
  797. return number
  798. end
  799.  
  800. local function EnumObjectsHelper(enumFuncs, yieldFunc, iobj)
  801. local depth = #enumFuncs
  802. local i = 1
  803. local obj
  804. repeat
  805. if (iobj) then
  806. obj = enumFuncs[1](iobj, i)
  807. else
  808. obj = enumFuncs[1](i)
  809. end
  810. if (obj) then
  811. if (depth == 1) then
  812. yieldFunc(obj)
  813. else
  814. local innerEnumFuncs = CopyTable(enumFuncs);
  815. tremove(innerEnumFuncs, 1);
  816. EnumObjectsHelper(innerEnumFuncs, yieldFunc, obj);
  817. end
  818. end
  819. i = i + 1
  820. until not obj
  821. end
  822.  
  823. function AS:EnumObjects(enumFuncs, yieldFunc)
  824. if (type(enumFuncs) == "function") then
  825. enumFuncs = {enumFuncs}
  826. end
  827.  
  828. EnumObjectsHelper(enumFuncs, yieldFunc)
  829. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement