Skip to content

Commit

Permalink
Add support for The War Within
Browse files Browse the repository at this point in the history
  • Loading branch information
ntowle committed May 10, 2024
1 parent 9eb0e64 commit e525b18
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 61 deletions.
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ignore = {
}
globals = {
"CreateFrame",
"C_Spell",
"GetSpellInfo",
"GetActionInfo",
"hooksecurefunc",
Expand Down
13 changes: 8 additions & 5 deletions HideButtonGlow.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
local addonName, addon = ...

-- globals
local CreateFrame, GetSpellInfo, GetActionInfo, DEFAULT_CHAT_FRAME, InterfaceOptionsFrame_OpenToCategory = CreateFrame, GetSpellInfo, GetActionInfo, DEFAULT_CHAT_FRAME, InterfaceOptionsFrame_OpenToCategory
local CreateFrame, GetActionInfo, DEFAULT_CHAT_FRAME, InterfaceOptionsFrame_OpenToCategory = CreateFrame, GetActionInfo, DEFAULT_CHAT_FRAME, InterfaceOptionsFrame_OpenToCategory

-- TWW uses C_Spell, compatibility code for older clients
local GetSpellName = C_Spell and C_Spell.GetSpellName or GetSpellInfo

local eventFrame = CreateFrame('Frame')
eventFrame:SetScript('OnEvent', function(self, event, ...)
Expand Down Expand Up @@ -48,28 +51,28 @@ function addon:ShouldHideGlow(spellId)
for _, spellToAllow in ipairs(HideButtonGlowDB.allowedSpells) do
if spellId == spellToAllow then
if HideButtonGlowDB.debugMode then
addon:AddMessage(("Found in allow list, allowing spell glow for %s (ID %d)."):format(GetSpellInfo(spellId), spellId))
addon:AddMessage(("Found in allow list, allowing spell glow for %s (ID %d)."):format(GetSpellName(spellId), spellId))
end
return false
end
end
if HideButtonGlowDB.debugMode then
addon:AddMessage(("Hide All is checked, hiding spell glow for %s (ID %d)."):format(GetSpellInfo(spellId), spellId))
addon:AddMessage(("Hide All is checked, hiding spell glow for %s (ID %d)."):format(GetSpellName(spellId), spellId))
end
return true
end
-- else iterate through filter list
for _, spellToFilter in ipairs(HideButtonGlowDB.spells) do
if spellId == spellToFilter then
if HideButtonGlowDB.debugMode then
addon:AddMessage(("Filter matched, hiding spell glow for %s (ID %d)."):format(GetSpellInfo(spellId), spellId))
addon:AddMessage(("Filter matched, hiding spell glow for %s (ID %d)."):format(GetSpellName(spellId), spellId))
end
return true
end
end
-- else show the glow
if HideButtonGlowDB.debugMode then
addon:AddMessage(("No filters matched, allowing spell glow for %s (ID %d)."):format(GetSpellInfo(spellId), spellId))
addon:AddMessage(("No filters matched, allowing spell glow for %s (ID %d)."):format(GetSpellName(spellId), spellId))
end
return false
end
Expand Down
2 changes: 1 addition & 1 deletion HideButtonGlow.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface: 100207
## Interface: 40400, 100207, 110000
## Version: @project-version@
## Author: dekallo
## Title: Hide Button Glow
Expand Down
18 changes: 0 additions & 18 deletions HideButtonGlow_Cata.toc

This file was deleted.

84 changes: 47 additions & 37 deletions options.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
local addonName, addon = ...

-- globals
local GetSpellInfo, tinsert, tremove, tContains, tonumber = GetSpellInfo, tinsert, tremove, tContains, tonumber
local tinsert, tremove, tContains, tonumber = tinsert, tremove, tContains, tonumber

-- TWW uses C_Spell, compatibility code for older clients
local GetSpellName = C_Spell and C_Spell.GetSpellName or GetSpellInfo
local GetSpellInfo = C_Spell and C_Spell.GetSpellInfo or function(spellIdentifier)
local name, _, _, _, _, _, spellID = GetSpellInfo(spellIdentifier)
return {
["name"] = name,
["spellID"] = spellID,
}
end

local function GetOptions()
return {
Expand Down Expand Up @@ -67,27 +77,27 @@ local function GetOptions()
desc = "Type a spell name or spell ID to prevent it from glowing.",
get = function() return "" end,
set = function(_, value)
local spellId = tonumber(value)
if spellId ~= nil then
local name = GetSpellInfo(spellId)
local spellID = tonumber(value)
if spellID ~= nil then
local name = GetSpellName(spellID)
if name then
if tContains(HideButtonGlowDB.spells, spellId) then
addon:AddMessage(("ID %2$d already filtered as spell %1$s."):format(name, spellId))
if tContains(HideButtonGlowDB.spells, spellID) then
addon:AddMessage(("ID %2$d already filtered as spell %1$s."):format(name, spellID))
else
addon:AddMessage(("Filtering button glow for spell %s with ID %d."):format(name, spellId))
tinsert(HideButtonGlowDB.spells, spellId)
addon:AddMessage(("Filtering button glow for spell %s with ID %d."):format(name, spellID))
tinsert(HideButtonGlowDB.spells, spellID)
end
else
addon:AddMessage(("Invalid spell ID: %s"):format(value))
end
else
local name, _, _, _, _, _, spellId = GetSpellInfo(value)
if spellId then
if tContains(HideButtonGlowDB.spells, spellId) then
addon:AddMessage(("\"%3$s\" already filtered as spell %1$s with ID %2$d."):format(name, spellId, value))
local spellInfo = GetSpellInfo(value)
if spellInfo and spellInfo.spellID then
if tContains(HideButtonGlowDB.spells, spellInfo.spellID) then
addon:AddMessage(("\"%3$s\" already filtered as spell %1$s with ID %2$d."):format(spellInfo.name, spellInfo.spellID, value))
else
addon:AddMessage(("Filtering button glow for \"%3$s\" as spell %1$s with ID %2$d."):format(name, spellId, value))
tinsert(HideButtonGlowDB.spells, spellId)
addon:AddMessage(("Filtering button glow for \"%3$s\" as spell %1$s with ID %2$d."):format(spellInfo.name, spellInfo.spellID, value))
tinsert(HideButtonGlowDB.spells, spellInfo.spellID)
end
else
addon:AddMessage(("Invalid spell name: %s"):format(value))
Expand All @@ -106,15 +116,15 @@ local function GetOptions()
desc = "Delete an existing filtered spell.",
get = false,
set = function(_, index)
local spellId = HideButtonGlowDB.spells[index]
local name = GetSpellInfo(spellId)
addon:AddMessage(("Removing button glow filter for spell %s with ID %d."):format(name, spellId))
local spellID = HideButtonGlowDB.spells[index]
local name = GetSpellName(spellID)
addon:AddMessage(("Removing button glow filter for spell %s with ID %d."):format(name, spellID))
tremove(HideButtonGlowDB.spells, index)
end,
values = function()
local spellNames = {}
for _, spellId in ipairs(HideButtonGlowDB.spells) do
local name = GetSpellInfo(spellId)
for _, spellID in ipairs(HideButtonGlowDB.spells) do
local name = GetSpellName(spellID)
tinsert(spellNames, name)
end
return spellNames
Expand Down Expand Up @@ -150,27 +160,27 @@ local function GetOptions()
desc = "Type a spell name or spell ID to always allow it to glow.",
get = function() return "" end,
set = function(_, value)
local spellId = tonumber(value)
if spellId ~= nil then
local name = GetSpellInfo(spellId)
local spellID = tonumber(value)
if spellID ~= nil then
local name = GetSpellName(spellID)
if name then
if tContains(HideButtonGlowDB.allowedSpells, spellId) then
addon:AddMessage(("ID %2$d already allowed as spell %1$s."):format(name, spellId))
if tContains(HideButtonGlowDB.allowedSpells, spellID) then
addon:AddMessage(("ID %2$d already allowed as spell %1$s."):format(name, spellID))
else
addon:AddMessage(("Allowing button glow for spell %s with ID %d."):format(name, spellId))
tinsert(HideButtonGlowDB.allowedSpells, spellId)
addon:AddMessage(("Allowing button glow for spell %s with ID %d."):format(name, spellID))
tinsert(HideButtonGlowDB.allowedSpells, spellID)
end
else
addon:AddMessage(("Invalid spell ID: %s"):format(value))
end
else
local name, _, _, _, _, _, spellId = GetSpellInfo(value)
if spellId then
if tContains(HideButtonGlowDB.allowedSpells, spellId) then
addon:AddMessage(("\"%3$s\" already allowed as spell %s with ID %d."):format(name, spellId, value))
local spellInfo = GetSpellInfo(value)
if spellInfo and spellInfo.spellID then
if tContains(HideButtonGlowDB.allowedSpells, spellInfo.spellID) then
addon:AddMessage(("\"%3$s\" already allowed as spell %s with ID %d."):format(spellInfo.name, spellInfo.spellID, value))
else
addon:AddMessage(("Allowing button glow for \"%3$s\" as spell %1$s with ID %2$d."):format(name, spellId, value))
tinsert(HideButtonGlowDB.allowedSpells, spellId)
addon:AddMessage(("Allowing button glow for \"%3$s\" as spell %1$s with ID %2$d."):format(spellInfo.name, spellInfo.spellID, value))
tinsert(HideButtonGlowDB.allowedSpells, spellInfo.spellID)
end
else
addon:AddMessage(("Invalid spell name: %s"):format(value))
Expand All @@ -189,15 +199,15 @@ local function GetOptions()
desc = "Delete an existing allowed spell.",
get = false,
set = function(_, index)
local spellId = HideButtonGlowDB.allowedSpells[index]
local name = GetSpellInfo(spellId)
addon:AddMessage(("Removing allowed button glow for spell %s with ID %d."):format(name, spellId))
local spellID = HideButtonGlowDB.allowedSpells[index]
local name = GetSpellName(spellID)
addon:AddMessage(("Removing allowed button glow for spell %s with ID %d."):format(name, spellID))
tremove(HideButtonGlowDB.allowedSpells, index)
end,
values = function()
local spellNames = {}
for _, spellId in ipairs(HideButtonGlowDB.allowedSpells) do
local name = GetSpellInfo(spellId)
for _, spellID in ipairs(HideButtonGlowDB.allowedSpells) do
local name = GetSpellName(spellID)
tinsert(spellNames, name)
end
return spellNames
Expand Down

0 comments on commit e525b18

Please sign in to comment.