Skip to content
Open
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
52 changes: 29 additions & 23 deletions NameplateSCT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -866,31 +866,38 @@ local function commaSeperate(number)
end

function NameplateSCT:truncateText(amount)
local text = ''

if self.db.global.truncateMethod == 'NONE' then
if (self.db.global.commaSeperate) then
text = commaSeperate(amount)
if self.db.global.commaSeperate then
return commaSeperate(amount)
else
text = tostring(amount)
return tostring(amount)
end
end

elseif self.db.global.truncateMethod == 'WESTERN' then
local unitLetter = ''
local unitLetter = ''
if self.db.global.truncateMethod == 'WESTERN' then
if self.db.global.truncateLetter then
unitLetter = 'k'
unitLetter = 'K'
end

if amount >= 1000000 and self.db.global.truncateLetter then
text = string.format("%.1fM", amount / 1000000)
elseif amount >= 10000 then
text = string.format("%.0f%s", amount / 1000, unitLetter)
elseif amount >= 1000 then
text = string.format("%.1f%s", amount / 1000, unitLetter)
else
text = tostring(amount)
unitLetter = 'M'
return string.format("%.1f%s", amount / 1000000, unitLetter)
end

if amount >= 10000 then
return string.format("%.0f%s", amount / 1000, unitLetter)
end

if amount >= 1000 then
return string.format("%.1f%s", amount / 1000, unitLetter)
end
elseif self.db.global.truncateMethod == 'EASTASIA' then

return tostring(amount)
end

if self.db.global.truncateMethod == 'EASTASIA' then
local unitLetter = ''
if self.db.global.truncateLetter then
unitLetter = L["Truncate Letter East Asia"]
Expand All @@ -902,15 +909,14 @@ function NameplateSCT:truncateText(amount)
end

if amount >= 100000 then
text = string.format("%.0f%s", amount / 10000, unitLetter)
elseif amount >= 10000 then
text = string.format("%.1f%s", amount / 10000, unitLetter)
else
text = tostring(amount)
return string.format("%.0f%s", amount / 10000, unitLetter)
end
else
-- Never reach
text = tostring(amount)
if amount >= 10000 then
return string.format("%.1f%s", amount / 10000, unitLetter)
end

return tostring(amount)

end

return text
Expand Down