Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions src/Modules/Build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local t_insert = table.insert
local t_sort = table.sort
local m_min = math.min
local m_max = math.max
local m_huge = math.huge
local m_floor = math.floor
local m_abs = math.abs
local s_format = string.format
Expand Down Expand Up @@ -1195,6 +1196,9 @@ function buildMode:OnFrame(inputEvents)
if main.thousandsSeparator ~= self.lastShowThousandsSeparator then
self:RefreshStatList()
end
if main.useCompactValues ~= self.lastUseCompactValues then
self:RefreshStatList()
end
if main.decimalSeparator ~= self.lastShowDecimalSeparator then
self:RefreshStatList()
end
Expand All @@ -1204,7 +1208,6 @@ function buildMode:OnFrame(inputEvents)

-- Update contents of main skill dropdowns
self:RefreshSkillSelectControls(self.controls, self.mainSocketGroup, "")

-- Draw contents of current tab
local sideBarWidth = 312
local tabViewPort = {
Expand Down Expand Up @@ -1587,11 +1590,32 @@ function buildMode:FormatStat(statData, statVal, overCapStatVal, colorOverride)
color = colorCodes.NEGATIVE
end

local valStr = s_format("%"..statData.fmt, val)
local number, suffix = valStr:match("^([%+%-]?%d+%.%d+)(%D*)$")
if number then
valStr = number:gsub("0+$", ""):gsub("%.$", "") .. suffix
end
local valStr

if val == m_huge or val == -m_huge then
valStr = s_format("%"..statData.fmt, val)
elseif statData.compactValue and main.useCompactValues then
local absVal = m_abs(val)

if absVal >= 1000000000 then
valStr = s_format("%.1fB", val / 1000000000)
elseif absVal >= 1000000 then
valStr = s_format("%.1fM", val / 1000000)
elseif absVal >= 10000 then
valStr = s_format("%.1fK", val / 1000)
else
valStr = formatNumSep(s_format("%"..statData.fmt, val))
end
else
valStr = s_format("%"..statData.fmt, val)
local number, suffix = valStr:match("^([%+%-]?%d+%.%d+)(%D*)$")
if number then
valStr = number:gsub("0+$", ""):gsub("%.$", "") .. suffix
end
valStr = formatNumSep(valStr)
end

valStr = color .. valStr
valStr = color .. formatNumSep(valStr)

if overCapStatVal and overCapStatVal > 0 then
Expand All @@ -1601,6 +1625,7 @@ function buildMode:FormatStat(statData, statVal, overCapStatVal, colorOverride)
self.lastShowThousandsSeparator = main.thousandsSeparator
self.lastShowDecimalSeparator = main.decimalSeparator
self.lastShowTitlebarName = main.showTitlebarName
self.lastUseCompactValues = main.useCompactValues
return valStr
end

Expand All @@ -1621,6 +1646,10 @@ function buildMode:AddDisplayStatList(statList, actor)
end
if statVal and ((statData.condFunc and statData.condFunc(statVal,actor.output)) or (not statData.condFunc and statVal ~= 0)) then
local overCapStatVal = actor.output[statData.overCapStat] or nil
-- Allow stats to suppress numeric overcap display in special cases, such as Chaos Inoculation.
if overCapStatVal and statData.overCapStatCondFunc and not statData.overCapStatCondFunc(statVal, actor.output) then
overCapStatVal = nil
end
if statData.stat == "SkillDPS" then
labelColor = colorCodes.CUSTOM
table.sort(actor.output.SkillDPS, function(a,b) return (a.dps * a.count) > (b.dps * b.count) end)
Expand All @@ -1636,7 +1665,7 @@ function buildMode:AddDisplayStatList(statList, actor)
t_insert(statBoxList, {
height = 16,
lhsString,
self:FormatStat({fmt = "1.f"}, skillData.dps * skillData.count, overCapStatVal),
self:FormatStat({ fmt = ".1f", compactValue = statData.compactValue }, skillData.dps * skillData.count, overCapStatVal),
})
if skillData.skillPart then
t_insert(statBoxList, {
Expand All @@ -1659,10 +1688,16 @@ function buildMode:AddDisplayStatList(statList, actor)
if actor.output[statData.stat.."Warning"] or (statData.warnFunc and statData.warnFunc(statVal, actor.output) and statData.warnColor) then
colorOverride = colorCodes.NEGATIVE
end
-- Optional gray parenthetical text after a formatted stat, e.g. "100% (Immune)" or "2,759 (Guard)".
-- condFunc controls row visibility; suffixCondFunc only controls the suffix.
local formattedStat = self:FormatStat(statData, statVal, overCapStatVal, colorOverride)
if statData.suffix and (not statData.suffixCondFunc or statData.suffixCondFunc(statVal, actor.output)) then
formattedStat = formattedStat .. "^x808080" .. " (" .. statData.suffix .. ")"
end
t_insert(statBoxList, {
height = 16,
labelColor..statData.label..":",
self:FormatStat(statData, statVal, overCapStatVal, colorOverride),
formattedStat,
})
end
end
Expand Down
Loading