Skip to content

Commit 2a2de1c

Browse files
committed
Add GetSpellInfo compatibility method.
1 parent 78b20b6 commit 2a2de1c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

LibMagicUtil-1.0/LibMagicUtil-1.0.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ After embedding you will be able to use the following methods:
2424
]]
2525

2626
local MAJOR = "LibMagicUtil-1.0"
27-
local MINOR = 2024081801
27+
local MINOR = 2024081802
2828

2929
local lib = LibStub:NewLibrary(MAJOR, MINOR)
3030
local media = LibStub("LibSharedMedia-3.0")
@@ -35,7 +35,8 @@ if not lib then return end
3535
local embeddables = {
3636
"GetConfigTemplate", "_GetColorOpt", "_SetColorOpt", "_SetOption", "_GetOption",
3737
"_HideOption", "_DisableTiling", "FixBackdrop", "_SetBackgroundOption",
38-
"InterfaceOptions_AddCategory", "InterfaceOptionsFrame_OpenToCategory", "Dump"
38+
"InterfaceOptions_AddCategory", "InterfaceOptionsFrame_OpenToCategory", "Dump",
39+
"GetSpellInfo"
3940
}
4041

4142
lib.optionTemplates = lib.optionTemplates or {}
@@ -44,6 +45,17 @@ lib.embeddedAddons = lib.embeddedAddons or {}
4445
local optionTemplates = lib.optionTemplates
4546
local embeddedAddons = lib.embeddedAddons
4647

48+
lib.GetSpellInfo = GetSpellInfo or function(id)
49+
local spellInfo = C_Spell.GetSpellInfo(id)
50+
if spellInfo then
51+
-- Returning the values in the same order as the original GetSpellInfo
52+
return spellInfo.name, nil, spellInfo.iconID, spellInfo.castTime, spellInfo.minRange, spellInfo.maxRange, spellInfo.spellID, spellInfo.originalIconID
53+
else
54+
-- If the spell is not found, return nil
55+
return nil
56+
end
57+
end
58+
4759
function lib:GetConfigTemplate(config, get, set)
4860
assert(self ~= lib, "GetConfigTemplate can only be called when embedded.")
4961
assert(optionTemplates[config] ~= nil, "Unknown config template: "..config)

0 commit comments

Comments
 (0)