(fix) SpellCache causing BT2 auraNames icons not to display and small fixes

This commit is contained in:
NoM0Re
2025-03-14 16:49:32 +01:00
committed by GitHub
5 changed files with 21 additions and 24 deletions
-3
View File
@@ -2724,9 +2724,6 @@ function BuffTrigger.GetNameAndIconSimple(data, triggernum)
end
--- Returns the name and icon to show in the options.
--- @param data table
--- @param triggernum number
--- @return string|nil name, any icon
function BuffTrigger.GetNameAndIcon(data, triggernum)
local name, icon = BuffTrigger.GetNameAndIconSimple(data, triggernum)
if (not name or not icon and WeakAuras.spellCache) then
+1 -1
View File
@@ -9,7 +9,7 @@ WeakAuras.doubleWidth = WeakAuras.normalWidth * 2
local versionStringFromToc = GetAddOnMetadata("WeakAuras", "Version")
local versionString = "5.19.5 Beta"
local buildTime = "20250227215630"
local buildTime = "20250314121155"
local isAwesomeEnabled = C_NamePlate and C_NamePlate.GetNamePlateForUnit and true or false
WeakAuras.versionString = versionString
+2 -5
View File
@@ -116,10 +116,7 @@ local function CreateNameOptions(aura_options, data, trigger, size, isExactSpell
return GetSpellInfo(WeakAuras.SafeToNumber(trigger[optionKey] and trigger[optionKey][i] or 0))
end
aura_options[iconOption].image = function()
local icon
if trigger.auraspellids and trigger.auraspellids[i] then
icon = select(3, GetSpellInfo(trigger.auraspellids[i]))
end
local icon = select(3, GetSpellInfo(trigger[optionKey] and trigger[optionKey][i] or ""))
return icon and tostring(icon) or "", 18, 18
end
aura_options[iconOption].disabled = function()
@@ -957,7 +954,7 @@ local function GetBuffTriggerOptions(data, triggernum)
ignoreInvisible = {
type = "toggle",
name = L["Ignore out of checking range"],
desc = L["Uses UnitIsVisible() to check if in range. This is polled every second."],
desc = L["Uses UnitIsVisible() to check if game client has loaded a object for this unit. This distance is around 100 yards. This is polled every second."],
order = 69.9,
width = WeakAuras.doubleWidth,
hidden = function() return not (trigger.type == "aura2" and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party")) end
+15 -12
View File
@@ -19,7 +19,7 @@ local bestIcon = {}
-- Builds a cache of name/icon pairs from existing spell data
-- This is a rather slow operation, so it's only done once, and the result is subsequently saved
function spellCache.Build()
if not cache then
if not cache then
error("spellCache has not been loaded. Call WeakAuras.spellCache.Load(...) first.")
end
@@ -27,8 +27,8 @@ function spellCache.Build()
return
end
local holes
--[[
local holes
if WeakAuras.IsClassicEra() then
holes = {}
holes[63707] = 81743
@@ -57,7 +57,7 @@ function spellCache.Build()
id = id + 1
local name, _, icon = GetSpellInfo(id)
if(icon == 136243) then -- 136243 is the a gear icon, we can ignore those spells
if (icon and icon:lower() == "interface\\icons\\trade_engineering") then -- 136243 is the a gear icon, we can ignore those spells
misses = 0;
elseif name and name ~= "" and icon then
cache[name] = cache[name] or {}
@@ -68,9 +68,11 @@ function spellCache.Build()
cache[name].spells = cache[name].spells .. "," .. id .. "=" .. icon
end
misses = 0
--if holes and holes[id] then
-- id = holes[id]
--end
--[[
if holes and holes[id] then
id = holes[id]
end
]]
else
misses = misses + 1
end
@@ -110,7 +112,7 @@ while misses < 4000000 do
id = id + 1
local name = GetSpellInfo(id)
local icon = GetSpellTexture(id)
if icon == 136243 then -- 136243 is the a gear icon, we can ignore those spells
if (icon == "Interface\\Icons\\trade_engineering") then -- 136243 is the a gear icon, we can ignore those spells
misses = 0
elseif name and name ~= "" and icon then
if misses > 10000 then
@@ -138,11 +140,11 @@ function spellCache.GetIcon(name)
local bestMatch = nil
if (icons) then
if (icons.spells) then
for spell, icon in icons.spells:gmatch("(%d+)=(%d+)") do
for spell, icon in icons.spells:gmatch("(%d+)=([%w_\\-]+),?") do
local spellId = tonumber(spell)
if not bestMatch or (spellId and spellId ~= 0 and IsSpellKnown(spellId)) then
bestMatch = tonumber(icon)
bestMatch = icon
end
end
end
@@ -161,10 +163,11 @@ function spellCache.GetSpellsMatching(name)
if cache[name] then
if cache[name].spells then
local result = {}
for spell, icon in cache[name].spells:gmatch("(%d+)=(%d+)") do
for spell, icon in cache[name].spells:gmatch("(%d+)=([%w_\\-]+),?") do
local spellId = tonumber(spell)
local iconId = tonumber(icon)
result[spellId] = icon
if spellId then
result[spellId] = icon
end
end
return result
end
+3 -3
View File
@@ -34,7 +34,7 @@ local function CorrectSpellName(input)
local spells = spellCache.GetSpellsMatching(input)
if type(spells) == "table" then
for id in pairs(spells) do
if id and tonumber(id) and id > 0 and IsSpellKnown(tonumber(id)) then
if tonumber(id) and id ~= 0 and IsSpellKnown(id) then
return id
end
end
@@ -648,12 +648,12 @@ function OptionsPrivate.ConstructOptions(prototype, data, startorder, triggernum
local icon = spellCache.GetIcon(value);
return icon and tostring(icon) or "", 18, 18;
elseif(arg.type == "spell") then
local spellName, _, icon = GetSpellInfo(value);
local name, _, icon = GetSpellInfo(value);
if arg.noValidation then
-- GetSpellInfo and other wow apis are case insensitive, but the later matching we do
-- isn't. For validted inputs, we automatically correct the casing via GetSpellName
-- Since we don't do that for noValidation, we are extra picky on the input
if type(value) == "string" and spellName ~= value then
if type(value) == "string" and name ~= value then
return "", 18, 18
end
end