diff --git a/DiesalTools-2.0/DiesalTools-2.0.lua b/DiesalTools-2.0/DiesalTools-2.0.lua index 4f26f0c..f63f011 100644 --- a/DiesalTools-2.0/DiesalTools-2.0.lua +++ b/DiesalTools-2.0/DiesalTools-2.0.lua @@ -637,3 +637,29 @@ function DiesalTools.GetTexCoord(zoomPercent, width, height, xOffset, yOffset) return unpack(currentCoord) end + +---@param texture string|integer +function DiesalTools.CreateTextureString(texture) + if type(texture) ~= "string" then + texture = tostring(texture) + end + + return string.format("|T%s:0::0:0:64:64:4:60:4:60|t", texture) +end + +---@param spell number | Bastion.Spell +---@param text? string +---@param position? "start" | "end" +function DiesalTools.AttachSpellIcon(spell, text, position) + position = position or "start" + local icon + if type(spell) == "table" then + text = text or spell:GetName() + icon = spell:GetIcon() + elseif type(spell) == "number" then + text = text or GetSpellInfo(spell) + icon = select(3, GetSpellInfo(spell)) + end + + return string.format("%s %s", position == "start" and DiesalTools.CreateTextureString(icon) or text, position == "end" and DiesalTools.CreateTextureString(icon) or text) +end