Advertisement
Guest User

Actionbars_New

a guest
Apr 25th, 2014
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.73 KB | None | 0 0
  1. local Core = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
  2. local Module = Core:NewModule("Actionbars", "AceEvent-3.0")
  3.  
  4. ---------------
  5. -- Actionbars --
  6. ---------------
  7.  
  8. ------------------------------------------------------------------------
  9. -- Local functions
  10.  
  11. local function EnableHotKeys()
  12.  
  13. local db = Core.db.profile
  14.  
  15. if db.actionbars.showHotKeys ~= false then return end
  16.  
  17. for i=1, 12 do
  18. _G["ActionButton"..i.."HotKey"]:SetAlpha(0) -- main bar
  19. _G["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(0) -- bottom right bar
  20. _G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(0) -- bottom left bar
  21. _G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(0) -- right bar
  22. _G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(0) -- left bar
  23. end
  24. end
  25.  
  26. local function EnableMacroNames()
  27.  
  28. local db = Core.db.profile
  29.  
  30. if db.actionbars.showMacronames ~= false then return end
  31.  
  32. for i=1, 12 do
  33. _G["ActionButton"..i.."Name"]:SetAlpha(0) -- main bar
  34. _G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(0) -- bottom right bar
  35. _G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(0) -- bottom left bar
  36. _G["MultiBarRightButton"..i.."Name"]:SetAlpha(0) -- right bar
  37. _G["MultiBarLeftButton"..i.."Name"]:SetAlpha(0) -- left bar
  38. end
  39. end
  40.  
  41. ------------------------------------------------------------------------
  42. -- Module functions
  43.  
  44. function Module:OnEnable()
  45. if InCombatLockdown() then
  46. return self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnEnable")
  47. end
  48. self:UnregisterEvent("PLAYER_REGEN_ENABLED")
  49.  
  50. local db = Core.db.profile
  51.  
  52. if enabled or not db.actionbars.enable then return end
  53. enabled = true -- since most of this stuff is non-undoable (eg. hooksecurefunc)
  54.  
  55. EnableHotKeys()
  56. EnableMacroNames()
  57.  
  58. local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
  59.  
  60.  
  61. hooksecurefunc('ActionButton_UpdateUsable', function(self)
  62. if (IsAddOnLoaded('RedRange') or IsAddOnLoaded('GreenRange') or IsAddOnLoaded('tullaRange') or IsAddOnLoaded('RangeColors')) then
  63. return
  64. end
  65.  
  66. local isUsable, notEnoughMana = IsUsableAction(self.action)
  67. if (isUsable) then
  68. _G[self:GetName()..'Icon']:SetVertexColor(1, 1, 1)
  69. elseif (notEnoughMana) then
  70. _G[self:GetName()..'Icon']:SetVertexColor(db.actionbars.color.OutOfMana.r, db.actionbars.color.OutOfMana.g, db.actionbars.color.OutOfMana.b)
  71. else
  72. _G[self:GetName()..'Icon']:SetVertexColor(db.actionbars.color.NotUsable.r, db.actionbars.color.NotUsable.g, db.actionbars.color.NotUsable.b)
  73. end
  74. end)
  75.  
  76. -- BetterBlizzardButtonBorder v1.1.1
  77. -- By Aprikot - http://aprikot.wowinterface.com
  78. -- Based upon functions within nMainbar by Neal, and thek: Buttonskin by thek
  79.  
  80. -- Functions
  81. hooksecurefunc("ActionButton_Update", function(self)
  82. if self:GetName():match("ExtraActionButton") then return end
  83. local bu = _G[self:GetName()]
  84. local ic = _G[self:GetName().."Icon"]
  85. local bo = _G[self:GetName().."NormalTexture"]
  86. bu:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
  87. ic:SetTexCoord(.05, .95, .05, .95);
  88. ic:SetPoint("TOPLEFT", bu, 0, 0);
  89. ic:SetPoint("BOTTOMRIGHT", bu, 0, 0);
  90. bo:ClearAllPoints()
  91. bo:SetPoint("TOPLEFT", bu, -14, 14)
  92. bo:SetPoint("BOTTOMRIGHT", bu, 14, -14)
  93. if db.misc.classcolor ~= true then
  94. bo:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  95. else
  96. bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  97. end
  98. end);
  99.  
  100. hooksecurefunc("ActionButton_UpdateUsable", function(self)
  101. if self:GetName():match("ExtraActionButton") then return end
  102. if db.misc.classcolor ~= true then
  103. (_G[self:GetName().."NormalTexture"]):SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  104. else
  105. (_G[self:GetName().."NormalTexture"]):SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  106. end
  107. end);
  108.  
  109. hooksecurefunc("ActionButton_ShowGrid", function(self)
  110. if self:GetName():match("ExtraActionButton") then return end
  111. if db.misc.classcolor ~= true then
  112. (_G[self:GetName().."NormalTexture"]):SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  113. else
  114. (_G[self:GetName().."NormalTexture"]):SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  115. end
  116. end);
  117.  
  118. hooksecurefunc("PetActionBar_Update", function()
  119. for i, v in pairs({"PetActionButton", "ShapeshiftButton", "PossessButton"}) do
  120. for i = 1, 12 do
  121. local bu = _G[v..i]
  122. if bu then
  123. bu:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
  124. local ic = _G[v..i.."Icon"];
  125. ic:SetTexCoord(.05, .95, .05, .95);
  126. ic:SetPoint("TOPLEFT", bu, -1, 1);
  127. ic:SetPoint("BOTTOMRIGHT", bu, 1, -1);
  128. local bo = _G[v..i.."NormalTexture2"] or _G[v..i.."NormalTexture"]
  129. bo:ClearAllPoints()
  130. bo:SetPoint("TOPLEFT", bu, -15, 15)
  131. bo:SetPoint("BOTTOMRIGHT", bu, 15, -15)
  132. if db.misc.classcolor ~= true then
  133. bo:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  134. else
  135. bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  136. end
  137. end
  138. end
  139. end
  140. end);
  141.  
  142. hooksecurefunc("AuraButton_Update", function(self, index)
  143. if db.actionbars.auraborder then
  144. local bu = _G[self..index]
  145. local ic = _G[self..index.."Icon"]
  146. local bo = _G[self..index.."Border"]
  147. if ic then
  148. ic:SetTexCoord(.07, .93, .07, .93);
  149. end
  150. if bo then
  151. bo:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
  152. bo:ClearAllPoints()
  153. bo:SetPoint("TOPLEFT", bu, -12, 12)
  154. bo:SetPoint("BOTTOMRIGHT", bu, 12, -12)
  155. bo:SetTexCoord(0, 1, 0, 1)
  156. if db.misc.classcolor ~= true then
  157. bo:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  158. else
  159. bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  160. end
  161. end
  162. if bu and not bo then
  163. nbo = bu:CreateTexture("$parentOverlay", "ARTWORK")
  164. nbo:SetParent(bu)
  165. nbo:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
  166. nbo:SetPoint("TOPLEFT", bu, -12, 12)
  167. nbo:SetPoint("BOTTOMRIGHT", bu, 12, -12)
  168. if db.misc.classcolor ~= true then
  169. nbo:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  170. else
  171. nbo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  172. end
  173. end
  174. end
  175. end);
  176.  
  177. function ActionButton_OnUpdate(self, elapsed)
  178. if (IsAddOnLoaded('RedRange') or IsAddOnLoaded('GreenRange') or IsAddOnLoaded('tullaRange') or IsAddOnLoaded('RangeColors')) then
  179. return
  180. end
  181.  
  182. if (ActionButton_IsFlashing(self)) then
  183. local flashtime = self.flashtime
  184. flashtime = flashtime - elapsed
  185.  
  186. if (flashtime <= 0) then
  187. local overtime = - flashtime
  188. if (overtime >= ATTACK_BUTTON_FLASH_TIME) then
  189. overtime = 0
  190. end
  191.  
  192. flashtime = ATTACK_BUTTON_FLASH_TIME - overtime
  193.  
  194. local flashTexture = _G[self:GetName()..'Flash']
  195. if (flashTexture:IsShown()) then
  196. flashTexture:Hide()
  197. else
  198. flashTexture:Show()
  199. end
  200. end
  201.  
  202. self.flashtime = flashtime
  203. end
  204.  
  205. local rangeTimer = self.rangeTimer
  206. if (rangeTimer) then
  207. rangeTimer = rangeTimer - elapsed
  208. if (rangeTimer <= 0.1) then
  209. local isInRange = false
  210. if (ActionHasRange(self.action) and IsActionInRange(self.action) == 0) then
  211. _G[self:GetName()..'Icon']:SetVertexColor(db.actionbars.color.OutOfRange.r, db.actionbars.color.OutOfRange.g, db.actionbars.color.OutOfRange.b)
  212. isInRange = true
  213. end
  214.  
  215. if (self.isInRange ~= isInRange) then
  216. self.isInRange = isInRange
  217. ActionButton_UpdateUsable(self)
  218. end
  219.  
  220. rangeTimer = TOOLTIP_UPDATE_TIME
  221. end
  222.  
  223. self.rangeTimer = rangeTimer
  224. end
  225. end
  226.  
  227. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement