Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Addon = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
- local Module = Addon:NewModule("Actionbars")
- local L = setmetatable({}, { __index = function(t,k)
- local v = tostring(k)
- rawset(t, k, v)
- return v
- end })
- local db
- local defaults = {
- profile = {
- enable = true,
- showHotKeys = false, -- Set the Alpha
- showMacronames = false, -- Set the Alpha
- auraborder = false,
- -- Button Colors
- color = {
- enable = true,
- OutOfRange = { r = 0.9, g = 0, b = 0 },
- OutOfMana = { r = 0, g = 0, b = 0.9 },
- NotUsable = { r = 0.3, g = 0.3, b = 0.3 },
- },
- }
- }
- function Module:OnInitialize()
- self.db = Addon.db:RegisterNamespace("Actionbars", defaults)
- db = self.db.profile
- self:SetEnabledState(Addon:GetModuleEnabled("Actionbars"))
- local _, class = UnitClass("player")
- classColor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
- end
- function Module:OnEnable()
- db = self.db.profile
- 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.enable then return end
- enabled = true -- since most of this stuff is non-undoable (eg. hooksecurefunc)
- local hotkeyAlpha = db.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.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 Addon.db.profile.media.classcolor then
- texture:SetVertexColor(classColor.r * 1.2, classColor.g * 1.2, classColor.b * 1.2)
- else
- local color = db.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.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.color.OutOfMana
- self.icon:SetVertexColor(color.r, color.g, color.b)
- else
- local color = db.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.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
- -- Leave this out if the module doesn't have any settings:
- function Module:Refresh()
- db = self.db.profile -- update the upvalue
- -- change stuff here
- end
- -- Leave this out if the module doesn't have any options:
- local options
- function Module:GetOptions()
- options = options or {
- type = "group",
- name = L["Actionbars"],
- desc = L["Actionbar Button Modifications."],
- childGroups = "tree",
- get = function(info) return db[ info[#info] ] end,
- set = function(info, value) db[ info[#info] ] = value; end,
- args = {
- ---------------------------
- --Option Type Seperators
- sep1 = {
- type = "description",
- order = 2,
- name = " ",
- },
- sep2 = {
- type = "description",
- order = 3,
- name = " ",
- },
- sep3 = {
- type = "description",
- order = 4,
- name = " ",
- },
- sep4 = {
- type = "description",
- order = 5,
- name = " ",
- },
- ---------------------------
- reloadUI = {
- type = "execute",
- name = "Reload UI",
- desc = " ",
- order = 0,
- func = function()
- ReloadUI()
- end,
- },
- Text = {
- type = "description",
- order = 0,
- name = "When changes are made a reload of the UI is needed.",
- width = "full",
- },
- Text1 = {
- type = "description",
- order = 1,
- name = " ",
- width = "full",
- },
- enable = {
- type = "toggle",
- order = 1,
- name = L["Enable"],
- desc = L["Enables Actionbar Button Module"],
- width = "full",
- },
- auraborder = {
- type = "toggle",
- order = 2,
- name = L["Aura Border"],
- desc = L["Make & Color Aura Borders."],
- disabled = function() return not db.enable end,
- },
- showHotKeys = {
- type = "toggle",
- order = 2,
- name = L["Show Hot Keys"],
- desc = L["If Checked Hot Keys will Show."],
- disabled = function() return not db.enable end,
- },
- showMacronames = {
- type = "toggle",
- order = 2,
- name = L["Show Macro Names"],
- desc = L["If Checked Macros Will Show."],
- disabled = function() return not db.enable end,
- },
- color = {
- type = "group",
- order = 6,
- name = L["Actionbar Button Color"],
- desc = L["Enables Actionbar Button Color Modifications."],
- guiInline = true,
- get = function(info) return db.color[ info[#info] ] end,
- set = function(info, value) db.color[ info[#info] ] = value; end,
- args = {
- ---------------------------
- --Option Type Seperators
- sep1 = {
- type = "description",
- order = 2,
- name = " ",
- },
- sep2 = {
- type = "description",
- order = 3,
- name = " ",
- },
- sep3 = {
- type = "description",
- order = 4,
- name = " ",
- },
- sep4 = {
- type = "description",
- order = 5,
- name = " ",
- },
- ---------------------------
- enable = {
- type = "toggle",
- order = 1,
- name = L["Enable"],
- desc = L["Enables Coloring"],
- width = "full",
- },
- OutOfRange = {
- type = "color",
- order = 4,
- name = L["Out of Range"],
- desc = L["Picks the Out of Range Button Fade Color."],
- disabled = function() return not db.enable or not db.color.enable end,
- get = function(info)
- local rc = db.color[ info[#info] ]
- return rc.r, rc.g, rc.b
- end,
- set = function(info, r, g, b)
- db.color[ info[#info] ] = {}
- local rc = db.color[ info[#info] ]
- rc.r, rc.g, rc.b = r, g, b
- end,
- },
- OutOfMana = {
- type = "color",
- order = 4,
- name = L["Out of Mana"],
- desc = L["Picks the Out of Mana Button Fade Color."],
- disabled = function() return not db.enable or not db.color.enable end,
- get = function(info)
- local mc = db.color[ info[#info] ]
- return mc.r, mc.g, mc.b
- end,
- set = function(info, r, g, b)
- db.color[ info[#info] ] = {}
- local mc = db.color[ info[#info] ]
- mc.r, mc.g, mc.b = r, g, b
- end,
- },
- NotUsable = {
- type = "color",
- order = 4,
- name = L["Not Usable"],
- desc = L["Picks the Not Usable Button Fade Color."],
- disabled = function() return not db.enable or not db.color.enable end,
- get = function(info)
- local nu = db.color[ info[#info] ]
- return nu.r, nu.g, nu.b
- end,
- set = function(info, r, g, b)
- db.color[ info[#info] ] = {}
- local nu = db.color[ info[#info] ]
- nu.r, nu.g, nu.b = r, g, b
- end,
- },
- },
- },
- },
- }
- return options
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement