Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.82 KB | None | 0 0
  1. local T, C, L, _ = unpack(select(2, ...))
  2. if C.actionbar.enable ~= true then return end
  3.  
  4. ----------------------------------------------------------------------------------------
  5. -- Style ActionBars buttons(by Tukz)
  6. ----------------------------------------------------------------------------------------
  7. local function StyleNormalButton(self)
  8. local name = self:GetName()
  9. local button = self
  10. local icon = _G[name.."Icon"]
  11. local count = _G[name.."Count"]
  12. local flash = _G[name.."Flash"]
  13. local hotkey = _G[name.."HotKey"]
  14. local border = _G[name.."Border"]
  15. local btname = _G[name.."Name"]
  16. local normal = _G[name.."NormalTexture"]
  17. local float = _G[name.."FloatingBG"]
  18. local highlight = button.SpellHighlightTexture
  19.  
  20. flash:SetTexture("")
  21. button:SetNormalTexture("")
  22.  
  23. if float then
  24. float:Hide()
  25. float = T.dummy
  26. end
  27.  
  28. if border then
  29. border:Hide()
  30. border = T.dummy
  31. end
  32.  
  33. count:ClearAllPoints()
  34. count:SetPoint("BOTTOMRIGHT", 0, 2)
  35. count:SetFont(C.font.action_bars_font, C.font.action_bars_font_size, C.font.action_bars_font_style)
  36. count:SetShadowOffset(C.font.action_bars_font_shadow and 1 or 0, C.font.action_bars_font_shadow and -1 or 0)
  37.  
  38. if btname then
  39. if C.actionbar.macro == true then
  40. btname:ClearAllPoints()
  41. btname:SetPoint("BOTTOM", 0, 0)
  42. btname:SetFont(C.font.action_bars_font, C.font.action_bars_font_size, C.font.action_bars_font_style)
  43. btname:SetShadowOffset(C.font.action_bars_font_shadow and 1 or 0, C.font.action_bars_font_shadow and -1 or 0)
  44. btname:SetWidth(C.actionbar.button_size - 1)
  45. else
  46. btname:Kill()
  47. end
  48. end
  49.  
  50. if C.actionbar.hotkey == true then
  51. hotkey:ClearAllPoints()
  52. hotkey:SetPoint("TOPRIGHT", 0, 0)
  53. hotkey:SetFont(C.font.action_bars_font, C.font.action_bars_font_size, C.font.action_bars_font_style)
  54. hotkey:SetShadowOffset(C.font.action_bars_font_shadow and 1 or 0, C.font.action_bars_font_shadow and -1 or 0)
  55. hotkey:SetWidth(C.actionbar.button_size - 1)
  56. hotkey.ClearAllPoints = T.dummy
  57. hotkey.SetPoint = T.dummy
  58. else
  59. hotkey:Kill()
  60. end
  61.  
  62. if not button.isSkinned then
  63. if self:GetHeight() ~= C.actionbar.button_size and not InCombatLockdown() and not name:match("ExtraAction") then
  64. self:SetSize(C.actionbar.button_size, C.actionbar.button_size)
  65. end
  66. button:CreateBackdrop("Transparent")
  67. button.backdrop:SetAllPoints()
  68. if C.actionbar.classcolor_border == true then
  69. button.backdrop:SetBackdropBorderColor(T.color.r, T.color.g, T.color.b)
  70. end
  71.  
  72. icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  73. icon:SetPoint("TOPLEFT", button, 2, -2)
  74. icon:SetPoint("BOTTOMRIGHT", button, -2, 2)
  75.  
  76. button.isSkinned = true
  77. end
  78.  
  79. if normal and button:GetChecked() then
  80. ActionButton_UpdateState(button)
  81. end
  82.  
  83. if normal then
  84. normal:ClearAllPoints()
  85. normal:SetPoint("TOPLEFT")
  86. normal:SetPoint("BOTTOMRIGHT")
  87. end
  88.  
  89. if highlight then
  90. highlight:ClearAllPoints()
  91. highlight:SetPoint("TOPLEFT", -4, 4)
  92. highlight:SetPoint("BOTTOMRIGHT", 4, -4)
  93. end
  94. end
  95.  
  96. local function StyleSmallButton(normal, button, icon, name, pet)
  97. local flash = _G[name.."Flash"]
  98. local hotkey = _G[name.."HotKey"]
  99.  
  100. button:SetNormalTexture("")
  101.  
  102. hooksecurefunc(button, "SetNormalTexture", function(self, texture)
  103. if texture and texture ~= "" then
  104. self:SetNormalTexture("")
  105. end
  106. end)
  107.  
  108. flash:SetColorTexture(0.8, 0.8, 0.8, 0.5)
  109. flash:SetPoint("TOPLEFT", button, 2, -2)
  110. flash:SetPoint("BOTTOMRIGHT", button, -2, 2)
  111.  
  112. if C.actionbar.hotkey == true then
  113. hotkey:ClearAllPoints()
  114. hotkey:SetPoint("TOPRIGHT", 0, 0)
  115. hotkey:SetFont(C.font.action_bars_font, C.font.action_bars_font_size, C.font.action_bars_font_style)
  116. hotkey:SetShadowOffset(C.font.action_bars_font_shadow and 1 or 0, C.font.action_bars_font_shadow and -1 or 0)
  117. hotkey:SetWidth(C.actionbar.button_size - 1)
  118. hotkey.ClearAllPoints = T.dummy
  119. hotkey.SetPoint = T.dummy
  120. else
  121. hotkey:Kill()
  122. end
  123.  
  124. if not button.isSkinned then
  125. button:SetSize(C.actionbar.button_size, C.actionbar.button_size)
  126. button:CreateBackdrop("Transparent")
  127. button.backdrop:SetAllPoints()
  128. if C.actionbar.classcolor_border == true then
  129. button.backdrop:SetBackdropBorderColor(T.color.r, T.color.g, T.color.b)
  130. end
  131.  
  132. icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  133. icon:ClearAllPoints()
  134. icon:SetPoint("TOPLEFT", button, 2, -2)
  135. icon:SetPoint("BOTTOMRIGHT", button, -2, 2)
  136.  
  137. if pet then
  138. local autocast = _G[name.."AutoCastable"]
  139. autocast:SetSize((C.actionbar.button_size * 2) - 10, (C.actionbar.button_size * 2) - 10)
  140. autocast:ClearAllPoints()
  141. autocast:SetPoint("CENTER", button, 0, 0)
  142.  
  143. local shine = _G[name.."Shine"]
  144. shine:SetSize(C.actionbar.button_size, C.actionbar.button_size)
  145.  
  146. local cooldown = _G[name.."Cooldown"]
  147. cooldown:SetSize(C.actionbar.button_size - 2, C.actionbar.button_size - 2)
  148. end
  149.  
  150. button.isSkinned = true
  151. end
  152.  
  153. if normal then
  154. normal:ClearAllPoints()
  155. normal:SetPoint("TOPLEFT")
  156. normal:SetPoint("BOTTOMRIGHT")
  157. end
  158. end
  159.  
  160. function T.StyleShift()
  161. for i = 1, NUM_STANCE_SLOTS do
  162. local name = "StanceButton"..i
  163. local button = _G[name]
  164. local icon = _G[name.."Icon"]
  165. local normal = _G[name.."NormalTexture"]
  166. StyleSmallButton(normal, button, icon, name)
  167. end
  168. end
  169.  
  170. function T.StylePet()
  171. for i = 1, NUM_PET_ACTION_SLOTS do
  172. local name = "PetActionButton"..i
  173. local button = _G[name]
  174. local icon = _G[name.."Icon"]
  175. local normal = _G[name.."NormalTexture2"]
  176. StyleSmallButton(normal, button, icon, name, true)
  177. end
  178. end
  179.  
  180. local function UpdateHotkey(self)
  181. local hotkey = _G[self:GetName().."HotKey"]
  182. local text = hotkey:GetText()
  183.  
  184. text = string.gsub(text, "(s%-)", "S")
  185. text = string.gsub(text, "(a%-)", "A")
  186. text = string.gsub(text, "(а%-)", "A") -- fix ruRU
  187. text = string.gsub(text, "(c%-)", "C")
  188. text = string.gsub(text, "(Mouse Button )", "M")
  189. text = string.gsub(text, "(Кнопка мыши )", "M")
  190. text = string.gsub(text, KEY_BUTTON3, "M3")
  191. text = string.gsub(text, KEY_PAGEUP, "PU")
  192. text = string.gsub(text, KEY_PAGEDOWN, "PD")
  193. text = string.gsub(text, KEY_SPACE, "SpB")
  194. text = string.gsub(text, KEY_INSERT, "Ins")
  195. text = string.gsub(text, KEY_HOME, "Hm")
  196. text = string.gsub(text, KEY_DELETE, "Del")
  197. text = string.gsub(text, KEY_NUMPADDECIMAL, "Nu.")
  198. text = string.gsub(text, KEY_NUMPADDIVIDE, "Nu/")
  199. text = string.gsub(text, KEY_NUMPADMINUS, "Nu-")
  200. text = string.gsub(text, KEY_NUMPADMULTIPLY, "Nu*")
  201. text = string.gsub(text, KEY_NUMPADPLUS, "Nu+")
  202. text = string.gsub(text, KEY_NUMLOCK, "NuL")
  203. text = string.gsub(text, KEY_MOUSEWHEELDOWN, "MWD")
  204. text = string.gsub(text, KEY_MOUSEWHEELUP, "MWU")
  205.  
  206. if hotkey:GetText() == _G["RANGE_INDICATOR"] then
  207. hotkey:SetText("")
  208. else
  209. hotkey:SetText(text)
  210. end
  211. end
  212.  
  213. local buttons = 0
  214. local function SetupFlyoutButton()
  215. for i = 1, buttons do
  216. local button = _G["SpellFlyoutButton"..i]
  217. if button and not button.IsSkinned then
  218. StyleNormalButton(button)
  219. button:StyleButton()
  220.  
  221. if button:GetChecked() then
  222. button:SetChecked(nil)
  223. end
  224.  
  225. if C.actionbar.rightbars_mouseover == true then
  226. SpellFlyout:HookScript("OnEnter", function(self) RightBarMouseOver(1) end)
  227. SpellFlyout:HookScript("OnLeave", function(self) RightBarMouseOver(0) end)
  228. button:HookScript("OnEnter", function(self) RightBarMouseOver(1) end)
  229. button:HookScript("OnLeave", function(self) RightBarMouseOver(0) end)
  230. end
  231. button.IsSkinned = true
  232. end
  233.  
  234. if button then
  235. if button:GetHeight() ~= C.actionbar.button_size and not InCombatLockdown() then
  236. button:SetSize(C.actionbar.button_size, C.actionbar.button_size)
  237. end
  238. end
  239. end
  240. end
  241. SpellFlyout:HookScript("OnShow", SetupFlyoutButton)
  242.  
  243. local function StyleFlyoutButton(self)
  244. if self.FlyoutBorder then
  245. self.FlyoutBorder:SetAlpha(0)
  246. end
  247. if self.FlyoutBorderShadow then
  248. self.FlyoutBorderShadow:SetAlpha(0)
  249. end
  250.  
  251. SpellFlyoutHorizontalBackground:SetAlpha(0)
  252. SpellFlyoutVerticalBackground:SetAlpha(0)
  253. SpellFlyoutBackgroundEnd:SetAlpha(0)
  254.  
  255. for i = 1, GetNumFlyouts() do
  256. local x = GetFlyoutID(i)
  257. local _, _, numSlots, isKnown = GetFlyoutInfo(x)
  258. if isKnown then
  259. if numSlots > buttons then
  260. buttons = numSlots
  261. end
  262. end
  263. end
  264. end
  265.  
  266. local function HideHighlightButton(self)
  267. if self.overlay then
  268. self.overlay:Hide()
  269. ActionButton_HideOverlayGlow(self)
  270. end
  271. end
  272.  
  273. do
  274. for i = 1, 12 do
  275. _G["ActionButton"..i]:StyleButton()
  276. _G["MultiBarBottomLeftButton"..i]:StyleButton()
  277. _G["MultiBarBottomRightButton"..i]:StyleButton()
  278. _G["MultiBarLeftButton"..i]:StyleButton()
  279. _G["MultiBarRightButton"..i]:StyleButton()
  280. end
  281.  
  282. for i = 1, 10 do
  283. _G["StanceButton"..i]:StyleButton()
  284. _G["PetActionButton"..i]:StyleButton()
  285. end
  286. end
  287.  
  288. hooksecurefunc("ActionButton_Update", StyleNormalButton)
  289. hooksecurefunc("ActionButton_UpdateFlyout", StyleFlyoutButton)
  290. if C.actionbar.hotkey == true then
  291. hooksecurefunc("ActionButton_OnEvent", function(self, event, ...) if event == "PLAYER_ENTERING_WORLD" then ActionButton_UpdateHotkeys(self, self.buttonType) end end)
  292. hooksecurefunc("ActionButton_UpdateHotkeys", UpdateHotkey)
  293. end
  294. if C.actionbar.hide_highlight == true then
  295. hooksecurefunc("ActionButton_ShowOverlayGlow", HideHighlightButton)
  296. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement