Commit c7fea3af authored by Blazeflack's avatar Blazeflack

Fixed issue which caused tags to show decimals when they should not.

parent 37514334
......@@ -27,12 +27,12 @@ local UnitClass = UnitClass
--GLOBALS: _TAGS, Hex, _COLORS
local textFormatStyles = {
["CURRENT"] = "%.1f",
["CURRENT_MAX"] = "%.1f - %.1f",
["CURRENT_PERCENT"] = "%.1f - %.1f%%",
["CURRENT_MAX_PERCENT"] = "%.1f - %.1f | %.1f%%",
["CURRENT"] = "%s",
["CURRENT_MAX"] = "%s - %s",
["CURRENT_PERCENT"] = "%s - %.1f%%",
["CURRENT_MAX_PERCENT"] = "%s - %s | %.1f%%",
["PERCENT"] = "%.1f%%",
["DEFICIT"] = "-%.1f"
["DEFICIT"] = "-%s"
}
local textFormatStylesNoDecimal = {
......@@ -44,6 +44,40 @@ local textFormatStylesNoDecimal = {
["DEFICIT"] = "-%s"
}
local shortValueFormat
local function ShortValue(number, noDecimal)
shortValueFormat = (noDecimal and "%.0f%s" or "%.1f%s")
if E.db.general.numberPrefixStyle == "METRIC" then
if abs(number) >= 1e9 then
return format(shortValueFormat, number / 1e9, "G")
elseif abs(number) >= 1e6 then
return format(shortValueFormat, number / 1e6, "M")
elseif abs(number) >= 1e3 then
return format(shortValueFormat, number / 1e3, "k")
else
return format("%d", number)
end
elseif E.db.general.numberPrefixStyle == "CHINESE" then
if abs(number) >= 1e8 then
return format(shortValueFormat, number / 1e8, "Y")
elseif abs(number) >= 1e4 then
return format(shortValueFormat, number / 1e4, "W")
else
return format("%d", number)
end
else
if abs(number) >= 1e9 then
return format(shortValueFormat, number / 1e9, "B")
elseif abs(number) >= 1e6 then
return format(shortValueFormat, number / 1e6, "M")
elseif abs(number) >= 1e3 then
return format(shortValueFormat, number / 1e3, "K")
else
return format("%d", number)
end
end
end
local function GetFormattedText(min, max, style, noDecimal)
assert(textFormatStyles[style] or textFormatStylesNoDecimal[style], "CustomTags Invalid format style: "..style)
assert(min, "CustomTags - You need to provide a current value. Usage: GetFormattedText(min, max, style, noDecimal)")
......@@ -63,22 +97,22 @@ local function GetFormattedText(min, max, style, noDecimal)
if deficit <= 0 then
return ""
else
return format(chosenFormat, E:ShortValue(deficit))
return format(chosenFormat, ShortValue(deficit, noDecimal))
end
elseif style == "PERCENT" then
return format(chosenFormat, min / max * 100)
elseif style == "CURRENT" or ((style == "CURRENT_MAX" or style == "CURRENT_MAX_PERCENT" or style == "CURRENT_PERCENT") and min == max) then
if noDecimal then
return format(textFormatStylesNoDecimal["CURRENT"], E:ShortValue(min))
return format(textFormatStylesNoDecimal["CURRENT"], ShortValue(min, noDecimal))
else
return format(textFormatStyles["CURRENT"], E:ShortValue(min))
return format(textFormatStyles["CURRENT"], ShortValue(min, noDecimal))
end
elseif style == "CURRENT_MAX" then
return format(chosenFormat, E:ShortValue(min), E:ShortValue(max))
return format(chosenFormat, ShortValue(min, noDecimal), ShortValue(max, noDecimal))
elseif style == "CURRENT_PERCENT" then
return format(chosenFormat, E:ShortValue(min), min / max * 100)
return format(chosenFormat, ShortValue(min, noDecimal), min / max * 100)
elseif style == "CURRENT_MAX_PERCENT" then
return format(chosenFormat, E:ShortValue(min), E:ShortValue(max), min / max * 100)
return format(chosenFormat, ShortValue(min, noDecimal), ShortValue(max, noDecimal), min / max * 100)
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment