PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Interface/AddOns/RayUI/modules/actionbar/actionbar.lua

https://bitbucket.org/anson0370/rayui_mirror
Lua | 744 lines | 670 code | 64 blank | 10 comment | 76 complexity | 3ef39daacdf60b3accc5b4ae6f41ed6d MD5 | raw file
  1. local R, L, P = unpack(select(2, ...)) --Inport: Engine, Locales, ProfileDB
  2. local AB = R:NewModule("ActionBar", "AceEvent-3.0", "AceHook-3.0", "AceConsole-3.0")
  3. AB.modName = L["动作条"]
  4. AB["Handled"] = {}
  5. local visibility = "[petbattle][overridebar][vehicleui][possessbar,@vehicle,exists] hide; show"
  6. local actionBarsName = {
  7. "MainMenuBarArtFrame",
  8. "MultiBarBottomRight",
  9. "MultiBarBottomLeft",
  10. "MultiBarRight",
  11. "MultiBarLeft"
  12. }
  13. local actionButtonsName = {
  14. bar1 = "ActionButton",
  15. bar2 = "MultiBarBottomRightButton",
  16. bar3 = "MultiBarBottomLeftButton",
  17. bar4 = "MultiBarRightButton",
  18. bar5 = "MultiBarLeftButton"
  19. }
  20. function AB:GetOptions()
  21. local options = {
  22. barscale = {
  23. order = 5,
  24. name = L["动作条缩放"],
  25. type = "range",
  26. min = 0.5, max = 1.5, step = 0.01,
  27. isPercent = true,
  28. },
  29. petbarscale = {
  30. order = 6,
  31. name = L["宠物动作条缩放"],
  32. type = "range",
  33. min = 0.5, max = 1.5, step = 0.01,
  34. isPercent = true,
  35. },
  36. macroname = {
  37. order = 9,
  38. name = L["显示宏名称"],
  39. type = "toggle",
  40. },
  41. itemcount = {
  42. order = 10,
  43. name = L["显示物品数量"],
  44. type = "toggle",
  45. },
  46. hotkeys = {
  47. order = 11,
  48. name = L["显示快捷键"],
  49. type = "toggle",
  50. },
  51. showgrid = {
  52. order = 12,
  53. name = L["显示空按键"],
  54. type = "toggle",
  55. },
  56. CooldownAlphaGroup = {
  57. order = 13,
  58. type = "group",
  59. name = L["根据CD淡出"],
  60. guiInline = true,
  61. args = {
  62. cooldownalpha = {
  63. type = "toggle",
  64. name = L["启用"],
  65. order = 1,
  66. },
  67. spacer = {
  68. type = "description",
  69. name = "",
  70. desc = "",
  71. order = 2,
  72. },
  73. cdalpha = {
  74. order = 3,
  75. name = L["CD时透明度"],
  76. type = "range",
  77. min = 0, max = 1, step = 0.05,
  78. disabled = function() return not self.db.cooldownalpha end,
  79. },
  80. readyalpha = {
  81. order = 4,
  82. name = L["就绪时透明度"],
  83. type = "range",
  84. min = 0, max = 1, step = 0.05,
  85. disabled = function() return not self.db.cooldownalpha end,
  86. },
  87. stancealpha = {
  88. type = "toggle",
  89. name = L["姿态条"],
  90. order = 5,
  91. disabled = function() return not self.db.cooldownalpha end,
  92. },
  93. },
  94. },
  95. PetGroup = {
  96. order = 40,
  97. type = "group",
  98. guiInline = false,
  99. name = L["宠物条"],
  100. get = function(info) return R.db.ActionBar["barpet"][ info[#info] ] end,
  101. set = function(info, value) R.db.ActionBar["barpet"][ info[#info] ] = value; AB:UpdatePetBar() end,
  102. args = {
  103. enable = {
  104. order = 1,
  105. type = "toggle",
  106. name = L["启用"],
  107. },
  108. autohide = {
  109. type = "toggle",
  110. name = L["自动隐藏"],
  111. order = 2,
  112. },
  113. mouseover = {
  114. type = "toggle",
  115. name = L["鼠标滑过显示"],
  116. order = 3,
  117. },
  118. buttonsize = {
  119. type = "range",
  120. name = L["按键大小"],
  121. min = 15, max = 40, step = 1,
  122. order = 4,
  123. },
  124. buttonspacing = {
  125. type = "range",
  126. name = L["按键间距"],
  127. min = 1, max = 10, step = 1,
  128. order = 5,
  129. },
  130. buttonsPerRow = {
  131. type = "range",
  132. name = L["每行按键数"],
  133. min = 1, max = NUM_PET_ACTION_SLOTS, step = 1,
  134. order = 6,
  135. },
  136. },
  137. },
  138. StanceGroup = {
  139. order = 41,
  140. type = "group",
  141. guiInline = false,
  142. name = L["姿态条"],
  143. args = {
  144. stancebarfade = {
  145. type = "toggle",
  146. name = L["自动隐藏"],
  147. order = 1,
  148. },
  149. stancebarmouseover = {
  150. type = "toggle",
  151. name = L["鼠标滑过显示"],
  152. order = 2,
  153. },
  154. },
  155. },
  156. }
  157. for i = 1, 5 do
  158. options["Bar"..i.."Group"] = {
  159. order = 20 + i,
  160. type = "group",
  161. name = L["动作条"..i],
  162. guiInline = false,
  163. get = function(info) return R.db.ActionBar["bar"..i][ info[#info] ] end,
  164. set = function(info, value) R.db.ActionBar["bar"..i][ info[#info] ] = value; AB:UpdatePositionAndSize("bar"..i) end,
  165. args = {
  166. enable = {
  167. order = 1,
  168. type = "toggle",
  169. name = L["启用"],
  170. },
  171. autohide = {
  172. type = "toggle",
  173. name = L["自动隐藏"],
  174. order = 2,
  175. },
  176. mouseover = {
  177. type = "toggle",
  178. name = L["鼠标滑过显示"],
  179. order = 3,
  180. },
  181. buttonsize = {
  182. type = "range",
  183. name = L["按键大小"],
  184. min = 15, max = 40, step = 1,
  185. order = 4,
  186. },
  187. buttonspacing = {
  188. type = "range",
  189. name = L["按键间距"],
  190. min = 1, max = 10, step = 1,
  191. order = 5,
  192. },
  193. buttonsPerRow = {
  194. type = "range",
  195. name = L["每行按键数"],
  196. min = 1, max = NUM_ACTIONBAR_BUTTONS, step = 1,
  197. order = 6,
  198. },
  199. },
  200. }
  201. end
  202. return options
  203. end
  204. function AB:HideBlizz()
  205. local blizzHider = CreateFrame("Frame", nil)
  206. blizzHider:Hide()
  207. MainMenuBar:SetParent(blizzHider)
  208. MainMenuBarPageNumber:SetParent(blizzHider)
  209. ActionBarDownButton:SetParent(blizzHider)
  210. ActionBarUpButton:SetParent(blizzHider)
  211. OverrideActionBarExpBar:SetParent(blizzHider)
  212. OverrideActionBarHealthBar:SetParent(blizzHider)
  213. OverrideActionBarPowerBar:SetParent(blizzHider)
  214. OverrideActionBarPitchFrame:SetParent(blizzHider)
  215. local buttonList = {
  216. CharacterMicroButton,
  217. SpellbookMicroButton,
  218. TalentMicroButton,
  219. AchievementMicroButton,
  220. QuestLogMicroButton,
  221. GuildMicroButton,
  222. PVPMicroButton,
  223. LFDMicroButton,
  224. CompanionsMicroButton,
  225. EJMicroButton,
  226. MainMenuMicroButton,
  227. HelpMicroButton,
  228. MainMenuBarBackpackButton,
  229. CharacterBag0Slot,
  230. CharacterBag1Slot,
  231. CharacterBag2Slot,
  232. CharacterBag3Slot,
  233. }
  234. for _, button in pairs(buttonList) do
  235. button:SetParent(blizzHider)
  236. end
  237. -----------------------------
  238. -- HIDE TEXTURES
  239. -----------------------------
  240. --remove some the default background textures
  241. StanceBarLeft:SetTexture(nil)
  242. StanceBarMiddle:SetTexture(nil)
  243. StanceBarRight:SetTexture(nil)
  244. SlidingActionBarTexture0:SetTexture(nil)
  245. SlidingActionBarTexture1:SetTexture(nil)
  246. PossessBackground1:SetTexture(nil)
  247. PossessBackground2:SetTexture(nil)
  248. MainMenuBarTexture0:SetTexture(nil)
  249. MainMenuBarTexture1:SetTexture(nil)
  250. MainMenuBarTexture2:SetTexture(nil)
  251. MainMenuBarTexture3:SetTexture(nil)
  252. MainMenuBarLeftEndCap:SetTexture(nil)
  253. MainMenuBarRightEndCap:SetTexture(nil)
  254. local textureList = {
  255. "_BG",
  256. "EndCapL",
  257. "EndCapR",
  258. "_Border",
  259. "Divider1",
  260. "Divider2",
  261. "Divider3",
  262. "ExitBG",
  263. "MicroBGL",
  264. "MicroBGR",
  265. "_MicroBGMid",
  266. "ButtonBGL",
  267. "ButtonBGR",
  268. "_ButtonBGMid",
  269. }
  270. for _,tex in pairs(textureList) do
  271. OverrideActionBar[tex]:SetAlpha(0)
  272. end
  273. hooksecurefunc("TalentFrame_LoadUI", function()
  274. PlayerTalentFrame:UnregisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  275. TalentMicroButtonAlert:ClearAllPoints()
  276. TalentMicroButtonAlert:SetPoint("BOTTOM", RayUIBottomInfoBar, "TOPLEFT", 30, 30)
  277. end)
  278. end
  279. function AB:CreateBar(id)
  280. local point, anchor, attachTo, x, y = string.split(",", self["DefaultPosition"]["bar"..id])
  281. local bar = CreateFrame("Frame", "RayUIActionBar"..id, UIParent, "SecureHandlerStateTemplate")
  282. bar:Point(point, anchor, attachTo, x, y)
  283. _G[actionBarsName[id]]:SetParent(bar)
  284. self["Handled"]["bar"..id] = bar
  285. self:UpdatePositionAndSize("bar"..id)
  286. R:CreateMover(bar, "ActionBar"..id.."Mover", L["动作条"..id.."锚点"], true, nil, "ALL,ACTIONBARS")
  287. end
  288. function AB:UpdatePositionAndSize(barName)
  289. local bar = self["Handled"][barName]
  290. local buttonsPerRow = self.db[barName].buttonsPerRow
  291. local buttonsize = self.db[barName].buttonsize
  292. local buttonspacing = self.db[barName].buttonspacing
  293. local numColumns = ceil(NUM_ACTIONBAR_BUTTONS / buttonsPerRow)
  294. bar:SetWidth(buttonsize*buttonsPerRow + buttonspacing*(buttonsPerRow - 1))
  295. bar:SetHeight(buttonsize*numColumns + buttonspacing*(numColumns - 1))
  296. if not self.db.bar2.enable and not self.db.bar3.enable and not ( R.db.movers and R.db.movers.ActionBar1Mover ) then
  297. local bar = ActionBar1Mover or self["Handled"]["bar1"]
  298. bar:ClearAllPoints()
  299. bar:Point("BOTTOM", UIParent, "BOTTOM", 0, 235)
  300. if RayUIVehicleBar then
  301. RayUIVehicleBar:ClearAllPoints()
  302. RayUIVehicleBar:SetPoint("LEFT", "RayUIActionBar1", "RIGHT", AB.db.buttonspacing, 0)
  303. end
  304. elseif not ( R.db.movers and R.db.movers.ActionBar1Mover ) then
  305. local bar = ActionBar1Mover or self["Handled"]["bar1"]
  306. local point, anchor, attachTo, x, y = string.split(",", self["DefaultPosition"]["bar1"])
  307. bar:Point(point, anchor, attachTo, x, y)
  308. if RayUIVehicleBar then
  309. RayUIVehicleBar:ClearAllPoints()
  310. RayUIVehicleBar:SetPoint("BOTTOMLEFT", "RayUIActionBar3", "BOTTOMRIGHT", AB.db.buttonspacing, 0)
  311. end
  312. end
  313. if self.db[barName].mouseover then
  314. self.db[barName].autohide = false
  315. bar:SetAlpha(0)
  316. bar:SetScript("OnEnter", function(self) UIFrameFadeIn(bar,0.5,bar:GetAlpha(),1) end)
  317. bar:SetScript("OnLeave", function(self) UIFrameFadeOut(bar,0.5,bar:GetAlpha(),0) end)
  318. else
  319. bar:SetAlpha(1)
  320. bar:SetScript("OnEnter", nil)
  321. bar:SetScript("OnLeave", nil)
  322. end
  323. if self.db[barName].autohide then
  324. bar:SetParent(RayUIActionBarHider)
  325. else
  326. bar:SetParent(UIParent)
  327. end
  328. local button, lastButton, lastColumnButton
  329. for i = 1, NUM_ACTIONBAR_BUTTONS do
  330. button = _G[actionButtonsName[barName]..i]
  331. lastButton = _G[actionButtonsName[barName]..(i-1)]
  332. lastColumnButton = _G[actionButtonsName[barName]..(i-buttonsPerRow)]
  333. button:SetSize(buttonsize, buttonsize)
  334. button:ClearAllPoints()
  335. if i == 1 then
  336. button:SetPoint("TOPLEFT", bar, "TOPLEFT", 0, 0)
  337. elseif (i - 1) % buttonsPerRow == 0 then
  338. button:SetPoint("TOPLEFT", lastColumnButton, "BOTTOMLEFT", 0, -buttonspacing)
  339. else
  340. button:SetPoint("LEFT", lastButton, "RIGHT", buttonspacing, 0)
  341. end
  342. if self.db[barName].mouseover then
  343. if not self.hooks[button] then
  344. self:HookScript(button, "OnEnter", function() UIFrameFadeIn(bar,0.5,bar:GetAlpha(),1) end)
  345. self:HookScript(button, "OnLeave", function() UIFrameFadeOut(bar,0.5,bar:GetAlpha(),0) end)
  346. end
  347. else
  348. if not self.hooks[button] then
  349. self:Unhook(button, "OnEnter")
  350. self:Unhook(button, "OnLeave")
  351. end
  352. end
  353. end
  354. if self.db[barName].enable then
  355. bar:Show()
  356. RegisterStateDriver(bar, "visibility", visibility)
  357. else
  358. bar:Hide()
  359. UnregisterStateDriver(bar, "visibility")
  360. end
  361. end
  362. function AB:Initialize()
  363. SetActionBarToggles(1, 1, 1, 1)
  364. InterfaceOptionsActionBarsPanelBottomRight:Kill()
  365. InterfaceOptionsActionBarsPanelBottomRight:SetScale(0.0001)
  366. InterfaceOptionsActionBarsPanelBottomLeft:Kill()
  367. InterfaceOptionsActionBarsPanelBottomLeft:SetScale(0.0001)
  368. InterfaceOptionsActionBarsPanelRightTwo:Kill()
  369. InterfaceOptionsActionBarsPanelRightTwo:SetScale(0.0001)
  370. InterfaceOptionsActionBarsPanelRight:Kill()
  371. InterfaceOptionsActionBarsPanelRight:SetScale(0.0001)
  372. self["DefaultPosition"] = {
  373. bar1 = "BOTTOM,UIParent,BOTTOM,"..(-3*AB.db.bar1.buttonsize - 3*AB.db.bar1.buttonspacing)..",235",
  374. bar2 = "BOTTOM,ActionBar1Mover,TOP,0,"..AB.db.bar2.buttonspacing,
  375. bar3 = "BOTTOMLEFT,ActionBar1Mover,BOTTOMRIGHT,"..AB.db.bar3.buttonspacing..",0",
  376. bar4 = "RIGHT,UIParent,RIGHT,-15,0",
  377. bar5 = "LEFT,UIParent,LEFT,15,0",
  378. }
  379. self:HideBlizz()
  380. for i =1, 5 do
  381. self:CreateBar(i)
  382. end
  383. if self.db.showgrid then
  384. ActionButton_HideGrid = R.dummy
  385. for i = 1, NUM_ACTIONBAR_BUTTONS do
  386. local button = _G[format("ActionButton%d", i)]
  387. button:SetAttribute("showgrid", 1)
  388. ActionButton_ShowGrid(button)
  389. button = _G[format("MultiBarRightButton%d", i)]
  390. button:SetAttribute("showgrid", 1)
  391. ActionButton_ShowGrid(button)
  392. button = _G[format("MultiBarBottomRightButton%d", i)]
  393. button:SetAttribute("showgrid", 1)
  394. ActionButton_ShowGrid(button)
  395. button = _G[format("MultiBarLeftButton%d", i)]
  396. button:SetAttribute("showgrid", 1)
  397. ActionButton_ShowGrid(button)
  398. button = _G[format("MultiBarBottomLeftButton%d", i)]
  399. button:SetAttribute("showgrid", 1)
  400. ActionButton_ShowGrid(button)
  401. button = _G[format("PetActionButton%d", i)]
  402. if button then
  403. button:SetAttribute("showgrid", 1)
  404. ActionButton_ShowGrid(button)
  405. end
  406. end
  407. SetCVar("alwaysShowActionBars", "1")
  408. end
  409. self:CreateBarPet()
  410. self:CreateStanceBar()
  411. self:CreateVehicleExit()
  412. self:CreateExtraButton()
  413. self:CreateOverrideBar()
  414. self:CreateCooldown()
  415. self:LoadKeyBinder()
  416. self:CreateRangeDisplay()
  417. self:EnableAutoHide()
  418. self:SecureHook("ActionButton_UpdateHotkeys", "UpdateHotkey")
  419. self:SecureHook("ActionButton_Update", "Style")
  420. self:SecureHook("ActionButton_UpdateFlyout", "StyleFlyout")
  421. self:SecureHook("StanceBar_Update", "StyleShift")
  422. self:SecureHook("StanceBar_UpdateState", "StyleShift")
  423. self:SecureHook("PossessBar_Update", "StylePossess")
  424. self:SecureHook("PetActionBar_Update", "StylePet")
  425. self:HookScript(SpellFlyout, "OnShow", "SetupFlyoutButton")
  426. for i = 1, NUM_ACTIONBAR_BUTTONS do
  427. self:Style(_G["ActionButton"..i])
  428. self:Style(_G["MultiBarBottomLeftButton"..i])
  429. self:Style(_G["MultiBarBottomRightButton"..i])
  430. self:Style(_G["MultiBarRightButton"..i])
  431. self:Style(_G["MultiBarLeftButton"..i])
  432. end
  433. end
  434. function AB:Info()
  435. return L["|cff7aa6d6Ray|r|cffff0000U|r|cff7aa6d6I|r动作条模块."]
  436. end
  437. function AB:UpdateHotkey(button, actionButtonType)
  438. local hotkey = _G[button:GetName() .. "HotKey"]
  439. local text = hotkey:GetText()
  440. text = string.gsub(text, "(s%-)", "S")
  441. text = string.gsub(text, "(a%-)", "A")
  442. text = string.gsub(text, "(c%-)", "C")
  443. text = string.gsub(text, "(Mouse Button )", "M")
  444. text = string.gsub(text, "(滑鼠按鍵)", "M")
  445. text = string.gsub(text, "(鼠标按键)", "M")
  446. text = string.gsub(text, KEY_BUTTON3, "M3")
  447. text = string.gsub(text, "(Num Pad )", "N")
  448. text = string.gsub(text, KEY_PAGEUP, "PU")
  449. text = string.gsub(text, KEY_PAGEDOWN, "PD")
  450. text = string.gsub(text, KEY_SPACE, "SpB")
  451. text = string.gsub(text, KEY_INSERT, "Ins")
  452. text = string.gsub(text, KEY_HOME, "Hm")
  453. text = string.gsub(text, KEY_DELETE, "Del")
  454. text = string.gsub(text, KEY_MOUSEWHEELUP, "MwU")
  455. text = string.gsub(text, KEY_MOUSEWHEELDOWN, "MwD")
  456. if hotkey:GetText() == _G["RANGE_INDICATOR"] then
  457. hotkey:SetText("")
  458. else
  459. hotkey:SetText(text)
  460. end
  461. end
  462. function AB:Style(button)
  463. local name = button:GetName()
  464. local action = button.action
  465. if name:match("MultiCast") then return end
  466. if not button.equipped then
  467. local equipped = button:CreateTexture(nil, "OVERLAY")
  468. equipped:SetTexture(0, 1, 0, .3)
  469. equipped:SetAllPoints()
  470. equipped:Hide()
  471. button.equipped = equipped
  472. end
  473. if action and IsEquippedAction(action) then
  474. if not button.equipped:IsShown() then
  475. button.equipped:Show()
  476. end
  477. else
  478. if button.equipped:IsShown() then
  479. button.equipped:Hide()
  480. end
  481. end
  482. if button.styled then return end
  483. local Icon = _G[name.."Icon"]
  484. local Count = _G[name.."Count"]
  485. local Flash = _G[name.."Flash"]
  486. local HotKey = _G[name.."HotKey"]
  487. local Border = _G[name.."Border"]
  488. local Btname = _G[name.."Name"]
  489. local Normal = _G[name.."NormalTexture"]
  490. local Normal2 = button:GetNormalTexture()
  491. local Cooldown = _G[name .. "Cooldown"]
  492. local FloatingBG = _G[name.."FloatingBG"]
  493. if Cooldown then
  494. Cooldown:ClearAllPoints()
  495. Cooldown:SetAllPoints(button)
  496. end
  497. if Flash then Flash:SetTexture(nil) end
  498. if Normal then Normal:SetTexture(nil) Normal:Hide() Normal:SetAlpha(0) end
  499. if Normal2 then Normal2:SetTexture(nil) Normal2:Hide() Normal2:SetAlpha(0) end
  500. if Border then Border:SetTexture(nil) end
  501. if Count then
  502. Count:ClearAllPoints()
  503. Count:Point("BOTTOMRIGHT", 2, 0)
  504. --Count:SetFont(R["media"].pxfont, R.mult*10, "OUTLINE,MONOCHROME")
  505. Count:SetFont(R["media"].font, R["media"].fontsize, R["media"].fontflag)
  506. end
  507. if FloatingBG then
  508. FloatingBG:Kill()
  509. end
  510. if Btname then
  511. if AB.db.macroname ~= true then
  512. Btname:SetDrawLayer("HIGHLIGHT")
  513. Btname:Width(50)
  514. Btname:SetFont(R["media"].font, R["media"].fontsize, R["media"].fontflag)
  515. Btname:ClearAllPoints()
  516. Btname:Point("BOTTOM", 0, -3)
  517. end
  518. end
  519. if not button.shadow then
  520. if not totem then
  521. if not flyout and not button.noResize then
  522. --button:SetWidth(AB.db.buttonsize)
  523. --button:SetHeight(AB.db.buttonsize)
  524. end
  525. button:CreateShadow("Background")
  526. end
  527. if Icon then
  528. Icon:SetTexCoord(.08, .92, .08, .92)
  529. Icon:SetAllPoints()
  530. end
  531. end
  532. if HotKey then
  533. HotKey:ClearAllPoints()
  534. --HotKey:SetPoint("TOPRIGHT", 0, 0)
  535. HotKey:Point("TOP", 0, 5)
  536. HotKey:SetJustifyH("CENTER")
  537. HotKey:Width(AB.db.buttonsize + 10)
  538. --HotKey:SetFont(R["media"].pxfont, R.mult*10, "OUTLINE,MONOCHROME")
  539. HotKey:SetFont(R["media"].font, R["media"].fontsize, R["media"].fontflag)
  540. if not AB.db.hotkeys == true then
  541. HotKey:SetText("")
  542. HotKey:Hide()
  543. HotKey.Show = R.dummy
  544. end
  545. end
  546. if button.style then
  547. button.style:SetDrawLayer("BACKGROUND", -7)
  548. button.border:SetFrameLevel(button:GetFrameLevel())
  549. button.shadow:SetFrameLevel(button:GetFrameLevel())
  550. end
  551. button:StyleButton(true)
  552. button.styled = true
  553. end
  554. function AB:StyleShift()
  555. for i=1, NUM_STANCE_SLOTS do
  556. local name = "StanceButton"..i
  557. local button = _G[name]
  558. local icon = _G[name.."Icon"]
  559. local normal = _G[name.."NormalTexture"]
  560. self:Style(button)
  561. end
  562. end
  563. function AB:StylePossess()
  564. for i=1, NUM_POSSESS_SLOTS do
  565. local name = "PossessButton"..i
  566. local button = _G[name]
  567. local icon = _G[name.."Icon"]
  568. local normal = _G[name.."NormalTexture"]
  569. self:Style(button)
  570. end
  571. end
  572. function AB:StylePet()
  573. for i=1, NUM_PET_ACTION_SLOTS do
  574. local name = "PetActionButton"..i
  575. local button = _G[name]
  576. local icon = _G[name.."Icon"]
  577. local normal = _G[name.."NormalTexture2"]
  578. self:Style(button)
  579. end
  580. end
  581. local buttons = 0
  582. function AB:SetupFlyoutButton()
  583. for i=1, buttons do
  584. local button = _G["SpellFlyoutButton"..i]
  585. if button then
  586. self:Style(_G["SpellFlyoutButton"..i], nil, true)
  587. _G["SpellFlyoutButton"..i]:StyleButton(true)
  588. if not AB.hooks[button] then
  589. AB:HookScript(button, "OnEnter", function(self)
  590. local bar = self:GetParent():GetParent():GetParent():GetParent()
  591. local id = bar:GetName():match("RayUIActionBar(%d)")
  592. if not id then return end
  593. if AB.db["bar"..id].mouseover then
  594. R:UIFrameFadeIn(bar,0.5,bar:GetAlpha(),1)
  595. end
  596. end)
  597. AB:HookScript(button, "OnLeave", function(self)
  598. local bar = self:GetParent():GetParent():GetParent():GetParent()
  599. local id = bar:GetName():match("RayUIActionBar(%d)")
  600. if not id then return end
  601. if AB.db["bar"..id].mouseover then
  602. R:UIFrameFadeOut(bar,0.5,bar:GetAlpha(),0)
  603. end
  604. end)
  605. end
  606. end
  607. end
  608. end
  609. function AB:StyleFlyout(button)
  610. if not button.FlyoutBorder then return end
  611. button.FlyoutBorder:SetAlpha(0)
  612. button.FlyoutBorderShadow:SetAlpha(0)
  613. SpellFlyoutHorizontalBackground:SetAlpha(0)
  614. SpellFlyoutVerticalBackground:SetAlpha(0)
  615. SpellFlyoutBackgroundEnd:SetAlpha(0)
  616. for i=1, GetNumFlyouts() do
  617. local x = GetFlyoutID(i)
  618. local _, _, numSlots, isKnown = GetFlyoutInfo(x)
  619. if isKnown and numSlots > buttons then
  620. buttons = numSlots
  621. end
  622. end
  623. --Change arrow direction depending on what bar the button is on
  624. local arrowDistance
  625. if ((SpellFlyout and SpellFlyout:IsShown() and SpellFlyout:GetParent() == button) or GetMouseFocus() == button) then
  626. arrowDistance = 5
  627. else
  628. arrowDistance = 2
  629. end
  630. if button:GetParent() and button:GetParent():GetParent() and button:GetParent():GetParent():GetName() and button:GetParent():GetParent():GetName() == "SpellBookSpellIconsFrame" then
  631. return
  632. end
  633. if button:GetAttribute("flyoutDirection") ~= nil then
  634. local layout = "HORIZONTAL"
  635. if button:GetParent() and button:GetParent():GetParent() then
  636. if button:GetParent():GetParent():GetHeight() > button:GetParent():GetParent():GetWidth() then
  637. layout = "VERTICAL"
  638. end
  639. end
  640. local point = R:GetScreenQuadrant(button)
  641. if layout == "HORIZONTAL" then
  642. if point:find("TOP") then
  643. button.FlyoutArrow:ClearAllPoints()
  644. button.FlyoutArrow:SetPoint("BOTTOM", button, "BOTTOM", 0, -arrowDistance)
  645. SetClampedTextureRotation(button.FlyoutArrow, 180)
  646. if not InCombatLockdown() then button:SetAttribute("flyoutDirection", "BOTTOM") end
  647. else
  648. button.FlyoutArrow:ClearAllPoints()
  649. button.FlyoutArrow:SetPoint("TOP", button, "TOP", 0,arrowDistance)
  650. SetClampedTextureRotation(button.FlyoutArrow, 0)
  651. if not InCombatLockdown() then button:SetAttribute("flyoutDirection", "TOP") end
  652. end
  653. else
  654. if point:find("LEFT") then
  655. button.FlyoutArrow:ClearAllPoints()
  656. button.FlyoutArrow:SetPoint("RIGHT", button, "RIGHT", arrowDistance, 0)
  657. SetClampedTextureRotation(button.FlyoutArrow, 90)
  658. if not InCombatLockdown() then button:SetAttribute("flyoutDirection", "RIGHT") end
  659. else
  660. button.FlyoutArrow:ClearAllPoints()
  661. button.FlyoutArrow:SetPoint("LEFT", button, "LEFT", -arrowDistance, 0)
  662. SetClampedTextureRotation(button.FlyoutArrow, 270)
  663. if not InCombatLockdown() then button:SetAttribute("flyoutDirection", "LEFT") end
  664. end
  665. end
  666. end
  667. end
  668. function AB:UpdateOverlayGlow(button)
  669. if button.overlay and button.shadow then
  670. button.overlay:SetParent(button)
  671. button.overlay:ClearAllPoints()
  672. button.overlay:SetAllPoints(button.shadow)
  673. button.overlay.ants:ClearAllPoints()
  674. button.overlay.ants:SetPoint("TOPLEFT", button.shadow, "TOPLEFT", -2, 2)
  675. button.overlay.ants:SetPoint("BOTTOMRIGHT", button.shadow, "BOTTOMRIGHT", 2, -2)
  676. button.overlay.outerGlow:SetPoint("TOPLEFT", button.shadow, "TOPLEFT", -2, 2)
  677. button.overlay.outerGlow:SetPoint("BOTTOMRIGHT", button.shadow, "BOTTOMRIGHT", 2, -2)
  678. end
  679. end
  680. R:RegisterModule(AB:GetName())