Skip to content

Commit

Permalink
RangerFader: Add C_Tooltip compat for Cataclysm Classic
Browse files Browse the repository at this point in the history
Fixes #65
  • Loading branch information
nebularg committed Jun 11, 2024
1 parent 80487ed commit eaa6569
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions Modules/RangeFader/RangeFader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -263,22 +263,42 @@ function PitBull4_RangeFader:GetOpacity(frame)
end

PitBull4_RangeFader:SetLayoutOptionsFunction(function(self)
local get_spell_range
local range_pattern = _G.SPELL_RANGE:gsub("%%s", ".-")
local function get_spell_range(spell_id)
local data = C_TooltipInfo.GetSpellByID(spell_id, true)
if not data then return end
if not wow_cata then
function get_spell_range(spell_id)
local data = C_TooltipInfo.GetSpellByID(spell_id, true)
if not data then return end

for _, line in next, data.lines do
TooltipUtil.SurfaceArgs(line)
if line.type == 0 then
if line.leftText and line.leftText:find(range_pattern) then
return line.leftText
elseif line.rightText and line.rightText:find(range_pattern) then
return line.rightText
for _, line in next, data.lines do
TooltipUtil.SurfaceArgs(line)
if line.type == 0 then
if line.leftText and line.leftText:find(range_pattern) then
return line.leftText
elseif line.rightText and line.rightText:find(range_pattern) then
return line.rightText
end
end
end
return _G.SPELL_RANGE:format("??")
end
else
local tooltip = CreateFrame("GameTooltip", "PitBull4RangeFinderTooltip", nil, "GameTooltipTemplate")
tooltip:SetOwner(UIParent, "ANCHOR_NONE")
function get_spell_range(spell_id)
tooltip:SetSpellByID(spell_id)
for i = 1, tooltip:NumLines(), 1 do
local text = _G["PitBull4RangeFinderTooltipTextLeft" .. i]:GetText()
if text and text:find(range_pattern) then
return text
end
text = _G["PitBull4RangeFinderTooltipTextRight" .. i]:GetText()
if text and text:find(range_pattern) then
return text
end
end
return _G.SPELL_RANGE:format("??")
end
return _G.SPELL_RANGE:format("??")
end

local function get_spell_info(spell)
Expand Down

0 comments on commit eaa6569

Please sign in to comment.