Skip to content

Commit

Permalink
Consolidated our function to check for red text
Browse files Browse the repository at this point in the history
  • Loading branch information
Slackluster committed Nov 21, 2024
1 parent 7c8908c commit 0dcac2c
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions modules/ItemOverlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ function app.TooltipInfo()
end
end

function app.GetTooltipRedText(itemLink)
local tooltip = C_TooltipInfo.GetHyperlink(itemLink)
if tooltip["lines"] then
for k, v in ipairs(tooltip["lines"]) do
if v.leftColor["r"] ~= 1 and v.leftColor["g"] ~= 1 and v.leftColor["b"] ~= 1 then
return true
end
end
return false
end
end

-- Create and set our icon and text overlay
function app.ItemOverlay(overlay, itemLink, itemLocation, containerInfo)
-- Create our overlay
local function createOverlay()
Expand Down Expand Up @@ -311,19 +324,7 @@ function app.ItemOverlay(overlay, itemLink, itemLocation, containerInfo)
end
-- Unlearned
else
-- Look for red text, which should only be when on the wrong class for this item
local red = false
local tooltip = C_TooltipInfo.GetHyperlink(itemLink)
if tooltip["lines"] then
for k, v in ipairs(tooltip["lines"]) do
if v.leftColor["r"] ~= 1 and v.leftColor["g"] ~= 1 and v.leftColor["b"] ~= 1 then
red = true
break
end
end
end

if red then
if app.GetTooltipRedText(itemLink) then
showOverlay("red")
else
showOverlay("purple")
Expand Down Expand Up @@ -413,19 +414,7 @@ function app.ItemOverlay(overlay, itemLink, itemLocation, containerInfo)
if not containerInfo then
hideOverlay()
else
-- Look for red text, which should only be when we can't open a container
local red = false
local tooltip = C_TooltipInfo.GetHyperlink(itemLink)
if tooltip["lines"] then
for k, v in ipairs(tooltip["lines"]) do
if v.leftColor["r"] ~= 1 and v.leftColor["g"] ~= 1 and v.leftColor["b"] ~= 1 then
red = true
break
end
end
end

if red then
if app.GetTooltipRedText(itemLink) then
showOverlay("red")
else
showOverlay("yellow")
Expand Down

0 comments on commit 0dcac2c

Please sign in to comment.