Skip to content

Commit

Permalink
teach BT2 how to interpret hyperlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
emptyrivers authored and InfusOnWoW committed Oct 29, 2024
1 parent 2df256b commit 641902c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions WeakAurasOptions/BuffTrigger2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,13 @@ local function CreateNameOptions(aura_options, data, trigger, size, isExactSpell
order = baseOrder + i / 100 + 0.0003,
hidden = hiddenFunction,
get = function(info)
local rawString = trigger[optionKey] and trigger[optionKey][i] or ""
local rawString = trigger[optionKey] and trigger[optionKey][i]
if not rawString then return "" end
local spellName, _, _, _, _, _, spellID = OptionsPrivate.Private.ExecEnv.GetSpellInfo(WeakAuras.SafeToNumber(rawString))
if spellName and spellID then
return ("%s (%s)"):format(spellID, spellName) .. "\0" .. rawString
elseif WeakAuras.SafeToNumber(rawString) then
return ("%s (%s)"):format(rawString, L["Unknown Spell"]) .. "\0" .. rawString
else
return rawString .. "\0" .. rawString
end
Expand All @@ -186,10 +189,9 @@ local function CreateNameOptions(aura_options, data, trigger, size, isExactSpell
if isExactSpellId then
trigger[optionKey][i] = v
else
local spellId = tonumber(v)
local _, spellId = WeakAuras.spellCache.CorrectAuraName(v)
if spellId then
WeakAuras.spellCache.CorrectAuraName(v)
trigger[optionKey][i] = v
trigger[optionKey][i] = tostring(spellId)
else
trigger[optionKey][i] = spellCache.BestKeyMatch(v)
end
Expand Down
9 changes: 7 additions & 2 deletions WeakAurasOptions/Cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,24 @@ function spellCache.BestKeyMatch(nearkey)
return bestKey;
end

---@param input string | number
---@return string name, number? id
function spellCache.CorrectAuraName(input)
if (not cache) then
error("spellCache has not been loaded. Call WeakAuras.spellCache.Load(...) first.")
end

local spellId = WeakAuras.SafeToNumber(input);
local spellId = WeakAuras.SafeToNumber(input)
if type(input) == "string" and input:find("|", nil, true) then
spellId = WeakAuras.SafeToNumber(input:match("|Hspell:(%d+)"))
end
if(spellId) then
local name, _, icon = OptionsPrivate.Private.ExecEnv.GetSpellInfo(spellId);
if(name) then
spellCache.AddIcon(name, spellId, icon)
return name, spellId;
else
return "Invalid Spell ID";
return "Invalid Spell ID", spellId;
end
else
local ret = spellCache.BestKeyMatch(input);
Expand Down

0 comments on commit 641902c

Please sign in to comment.