Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Core = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
- local Module = Core:NewModule("Actionbars", "AceEvent-3.0")
- local db, classColor
- ----------------
- -- Actionbars --
- ----------------
- function Module:OnInitialize()
- db = Core.db.profile
- local _, class = UnitClass("player")
- classColor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
- end
- function Module:OnEnable()
- if InCombatLockdown() then
- return self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnEnable")
- end
- self:UnregisterEvent("PLAYER_REGEN_ENABLED")
- if self.SetupHooks then
- self:SetupHooks()
- end
- if enabled or not db.actionbars.enable then return end
- enabled = true -- since most of this stuff is non-undoable (eg. hooksecurefunc)
- local hotkeyAlpha = db.actionbars.showHotKeys and 1 or 0
- for i = 1, 12 do
- _G["ActionButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- main bar
- _G["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom right bar
- _G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom left bar
- _G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- right bar
- _G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- left bar
- end
- local macroAlpha = db.actionbars.showMacronames and 1 or 0
- for i = 1, 12 do
- _G["ActionButton"..i.."Name"]:SetAlpha(macroAlpha) -- main bar
- _G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom right bar
- _G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom left bar
- _G["MultiBarRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- right bar
- _G["MultiBarLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- left bar
- end
- end
- function Module:SetupHooks()
- -- BetterBlizzardButtonBorder v1.1.1
- -- By Aprikot - http://aprikot.wowinterface.com
- -- Based upon functions within nMainbar by Neal, and thek: Buttonskin by thek
- local function AddRegionKeys(self)
- local name = self:GetName()
- self.__name = _G[name.."Name"]
- self.__count = _G[name.."Count"]
- self.__hotkey = _G[name.."HotKey"]
- self.__border = _G[name.."Border"]
- self.__flash = _G[name.."Flash"]
- self.__normalTexture = _G[name.."NormalTexture"]
- self.__normalTexture2 = _G[name.."NormalTexture2"]
- self.__pushedTexture = self:GetPushedTexture()
- self.__highlightTexture = self:GetHighlightTexture()
- self.__checkedTexture = self:GetCheckedTexture()
- return name
- end
- local function ColorButton(texture)
- if db.misc.classcolor then
- texture:SetVertexColor(classColor.r * 1.2, classColor.g * 1.2, classColor.b * 1.2)
- else
- local color = db.actionbars.color
- texture:SetVertexColor(color.r, color.g, color.b)
- end
- end
- local extraActionButtons = setmetatable({}, { __index = function(t, self)
- local name = AddRegionKeys(self)
- local v = not not strmatch(name, "ExtraActionButton")
- t[f] = v
- return v
- end })
- hooksecurefunc("ActionButton_Update", function(self)
- if extraActionButtons[self] then return end
- self:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
- local icon = self.icon
- icon:SetTexCoord(.05, .95, .05, .95)
- icon:ClearAllPoints()
- icon:SetPoint("TOPLEFT")
- icon:SetPoint("BOTTOMRIGHT")
- local normalTexture = self.__normalTexture
- normalTexture:ClearAllPoints()
- normalTexture:SetPoint("TOPLEFT", -14, 14)
- normalTexture:SetPoint("BOTTOMRIGHT", 14, -14)
- ColorButton(normalTexture)
- end)
- hooksecurefunc("ActionButton_UpdateUsable", function(self)
- if extraActionButtons[self] then return end
- ColorButton(self.__normalTexture)
- end)
- hooksecurefunc("ActionButton_ShowGrid", function(self)
- if extraActionButtons[self] then return end
- ColorButton(self.__normalTexture)
- end)
- local petButtons = { "PetActionButton", "PossessButton", "ShapeshiftButton" }
- hooksecurefunc("PetActionBar_Update", function()
- for i = 1, #petButtons do
- for j = 1, 12 do
- local button = _G[petButtons[i]..j]
- button:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
- AddRegionKeys(button)
- local icon = button.icon
- icon:SetTexCoord(.05, .95, .05, .95)
- icon:ClearAllPoints()
- icon:SetPoint("TOPLEFT", -1, 1)
- icon:SetPoint("BOTTOMRIGHT", 1, -1)
- local normalTexture = button.__normalTexture2 or button.__normalTexture
- normalTexture:ClearAllPoints()
- normalTexture:SetPoint("TOPLEFT", -15, 15)
- normalTexture:SetPoint("BOTTOMRIGHT",15, -15)
- ColorButton(normalTexture)
- end
- end
- end)
- hooksecurefunc("AuraButton_Update", function(buttonName, index, filter)
- if not db.actionbars.auraborder then return end
- local buffName = buttonName..index
- local self = _G[buffName]
- if not self.__border then AddRegionKeys(self) end
- local icon = self.icon
- if icon then
- icon:SetTexCoord(.07, .93, .07, .93)
- end
- local border = self.__border
- if not border then
- border = self:CreateTexture("$parentOverlay", "ARTWORK")
- self.__border = border
- end
- border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
- border:ClearAllPoints()
- border:SetPoint("TOPLEFT", bu, -12, 12)
- border:SetPoint("BOTTOMRIGHT", bu, 12, -12)
- border:SetTexCoord(0, 1, 0, 1)
- ColorButton(border)
- end)
- ---------------------------------------------------------------------
- local rangeAddons = {
- "GreenRange",
- "RangeColors",
- "RedRange",
- "tullaRange",
- }
- for i = 1, #rangeAddons do
- local _, _, _, enabled = GetAddOnInfo(rangeAddons[i])
- if enabled then
- rangeAddons = nil
- break
- end
- end
- if rangeAddons then
- hooksecurefunc("ActionButton_UpdateUsable", function(self)
- local isUsable, notEnoughMana = IsUsableAction(self.action)
- if isUsable then
- self.icon:SetVertexColor(1, 1, 1)
- elseif notEnoughMana then
- local color = db.actionbars.color.OutOfMana
- self.icon:SetVertexColor(color.r, color.g, color.b)
- else
- local color = db.actionbars.color.NotUsable
- self.icon:SetVertexColor(color.r, color.g, color.b)
- end
- end)
- hooksecurefunc("ActionButton_OnUpdate", function(self, elapsed)
- local rangeTimer = self.rangeTimer2 or 0
- rangeTimer = rangeTimer - elapsed
- if rangeTimer <= 0 then
- if IsActionInRange(self.action) == 0 then
- local color = db.actionbars.color.OutOfRange
- self.icon:SetVertexColor(color.r, color.g, color.b)
- end
- rangeTimer = TOOLTIP_UPDATE_TIME
- end
- self.rangeTimer2 = rangeTimer
- end)
- end
- self.SetupHooks = nil
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement