Skip to content

Commit

Permalink
Fix a small bug with the level line not showing up the real level in TW
Browse files Browse the repository at this point in the history
  • Loading branch information
iam3yal committed Feb 3, 2024
1 parent 8c8e5e7 commit 2d532bd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Scripts/Level.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ local UnitIsPlayer = UnitIsPlayer
local UnitEffectiveLevel = UnitEffectiveLevel
local UnitLevel = UnitLevel

local LEVEL1_FORMAT = "|cff%%s%%s|r"
local LEVEL2_FORMAT = "|cff%%s%%s|r (%%s)"
local LEVEL1_FORMAT = "|cff%%s%%d|r"
local LEVEL2_FORMAT = "|cff%%s%%d|r (%%d)"

local PLAYER_PATTERN = "%(%w+%)"
local PLAYER_PATTERN = "%(" .. PLAYER .. "%)"

TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Unit, function(tooltip)
if tooltip:IsForbidden() then return end
Expand All @@ -31,14 +31,15 @@ TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Unit, function(tool
local lineText = line:GetText()
if lineText and lineText:find(LEVEL) then
local levelText = level > 0 and level or "??"

if level < realLevel then
line:SetFormattedText(lineText:gsub(level, LEVEL2_FORMAT), diffHexColor, levelText, realLevel)
else
line:SetFormattedText(lineText:gsub(level, LEVEL1_FORMAT), diffHexColor, levelText)
end

-- Removes the (Player) bit from the level line.
lineText = line:GetText()
line:SetText(lineText:gsub(PLAYER_PATTERN, ""))

break
Expand Down

0 comments on commit 2d532bd

Please sign in to comment.