diff --git a/HideButtonGlow.lua b/HideButtonGlow.lua index 2e5d6a5..a6d4fa3 100644 --- a/HideButtonGlow.lua +++ b/HideButtonGlow.lua @@ -1,38 +1,50 @@ -local addon = CreateFrame('Frame') -addon.name = "HideButtonGlow" -addon:SetScript('OnEvent', function(self, event, ...) +local addonName, addon = ... + +-- globals +local CreateFrame, GetSpellInfo = CreateFrame, GetSpellInfo + +local addonFrame = CreateFrame('Frame') +addonFrame:SetScript('OnEvent', function(self, event, ...) if self[event] then return self[event](...) end end) -addon:RegisterEvent('PLAYER_LOGIN') +addonFrame:RegisterEvent('PLAYER_LOGIN') -function addon:PLAYER_LOGIN() +function addonFrame:PLAYER_LOGIN() if not HideButtonGlowDB then HideButtonGlowDB = {} HideButtonGlowDB.hideAll = false + HideButtonGlowDB.debugMode = false HideButtonGlowDB.spells = {} end end +function addon:addMessage(message, debugOnly) + if not debugOnly or HideButtonGlowDB.debugMode then + DEFAULT_CHAT_FRAME:AddMessage(message) + end +end + local glowLib = LibStub("LibButtonGlow-1.0", true) local showGlow = glowLib.ShowOverlayGlow function glowLib.ShowOverlayGlow(self) + local spellId = self:GetSpellId() + local spellName = GetSpellInfo(spellId) + -- check if the 'hide all' option is set if HideButtonGlowDB.hideAll then - --print("hiding all") + addon:addMessage("Hide All is checked, hiding spell glow for "..spellName.." (ID"..spellId..").", true) return end -- else iterate through filter list for _, spellToFilter in ipairs(HideButtonGlowDB.spells) do - --print("checking filter value " .. spellToFilter) - if self:GetSpellId() == spellToFilter then - --print("filter match") + if spellId == spellToFilter then + addon:addMessage("Filter matched, hiding spell glow for "..spellName.." (ID "..spellId..").", true) return end - --print("filter didn't match spell id: " .. self:GetSpellId()) end -- else show the glow - --print("showing glow for spell id: " .. self:GetSpellId()) - showGlow(self) + addon:addMessage("No filters matched, allowing spell glow for "..spellName.." (ID "..spellId..").", true) + return showGlow(self) end diff --git a/HideButtonGlow.toc b/HideButtonGlow.toc index 814c540..5e10b4c 100644 --- a/HideButtonGlow.toc +++ b/HideButtonGlow.toc @@ -8,5 +8,5 @@ libs\AceConfig-3.0\AceConfig-3.0.xml -options.lua HideButtonGlow.lua +options.lua diff --git a/options.lua b/options.lua index 06800ba..3a8f26c 100644 --- a/options.lua +++ b/options.lua @@ -1,4 +1,7 @@ -local addonName = "HideButtonGlow" +local addonName, addon = ... + +-- globals +local GetSpellInfo, tinsert, tremove, tContains, tonumber = GetSpellInfo, tinsert, tremove, tContains, tonumber function GetOptions() return { @@ -11,7 +14,11 @@ function GetOptions() type = "group", name = "Options", args = { - spacer = {order = 1, type = "description", name = ""}, + spacer = { + order = 1, + type = "description", + name = "" + }, hideAll = { order = 2, type = "toggle", @@ -21,17 +28,28 @@ function GetOptions() return HideButtonGlowDB.hideAll end, set = function() - local hide = not HideButtonGlowDB.hideAll - HideButtonGlowDB.hideAll = hide + HideButtonGlowDB.hideAll = not HideButtonGlowDB.hideAll end }, - header = { + debugMode = { order = 3, + type = "toggle", + name = "Debug mode", + desc = "Prints all filtered/unfiltered spells to chat. Useful for finding spell IDs, or checking how your settings work.", + get = function() + return HideButtonGlowDB.debugMode + end, + set = function() + HideButtonGlowDB.debugMode = not HideButtonGlowDB.debugMode + end + }, + header = { + order = 4, type = "header", name = "Filtered Spells" }, hiddenSpellAdd = { - order = 4, + order = 5, type = "input", width = "full", name = "Add", @@ -43,31 +61,31 @@ function GetOptions() local name = GetSpellInfo(spellId) if name then if tContains(HideButtonGlowDB.spells, spellId) then - print(spellId.." already filtered as spell "..name..".") + addon:addMessage("ID "..spellId.." already filtered as spell "..name..".") else - print("Filtering button glow for spell "..name.." with ID "..spellId..".") + addon:addMessage("Filtering button glow for spell "..name.." with ID "..spellId..".") tinsert(HideButtonGlowDB.spells, spellId) end else - print("Invalid spell ID: "..value) + addon:addMessage("Invalid spell ID: "..value) end else local name, _, _, _, _, _, spellId = GetSpellInfo(value) if spellId then if tContains(HideButtonGlowDB.spells, spellId) then - print("\""..value.."\" already filtered as spell "..name.." with ID "..spellId..".") + addon:addMessage("\""..value.."\" already filtered as spell "..name.." with ID "..spellId..".") else - print("Filtering button glow for \""..value.."\" as spell "..name.." with ID "..spellId..".") + addon:addMessage("Filtering button glow for \""..value.."\" as spell "..name.." with ID "..spellId..".") tinsert(HideButtonGlowDB.spells, spellId) end else - print("Invalid spell name: "..value) + addon:addMessage("Invalid spell name: "..value) end end end }, hiddenSpellDelete = { - order = 5, + order = 6, type = "select", width = "full", name = "Delete", @@ -76,7 +94,7 @@ function GetOptions() set = function(info, index) local spellId = HideButtonGlowDB.spells[index] local name = GetSpellInfo(spellId) - print("Removing button glow filter for spell "..name.." with ID "..spellId..".") + addon:addMessage("Removing button glow filter for spell "..name.." with ID "..spellId..".") tremove(HideButtonGlowDB.spells, index) end, values = function()