-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathGridTextFormatting.lua
More file actions
40 lines (34 loc) · 1.42 KB
/
Copy pathGridTextFormatting.lua
File metadata and controls
40 lines (34 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local Grid2 = Grid2
local strfind = strfind
Grid2.defaults.profile.formatting = {
longDecimalFormat = "%.1f",
shortDecimalFormat = "%.0f",
minutesDecimalFormat = "%.0fm",
hoursDecimalFormat = "%.0fh",
longDurationStackFormat = "%.1f:%d",
shortDurationStackFormat = "%.0f:%d",
invertDurationStack = false,
secondsElapsedFormat = "%ds",
minutesElapsedFormat = "%dm",
percentFormat = "%.0f%%",
numbersUseGameFormat = nil,
}
local formatter = C_StringUtil.CreateNumericRuleFormatter()
local breakpoints = {}
function Grid2:GetGeneralElapsedTimeFormatter()
return formatter
end
function Grid2:UpdateGeneralTextFormatting()
local fmt = Grid2.db.profile.formatting
wipe(breakpoints)
if fmt.longDecimalFormat==fmt.shortDecimalFormat then
local step = strfind(fmt.longDecimalFormat,"%%.1f") and 0.1 or 1
breakpoints[#breakpoints+1] = { threshold = 0, format = fmt.longDecimalFormat, step = step }
else
breakpoints[#breakpoints+1] = { threshold = 0, format = fmt.longDecimalFormat, step = .1 }
breakpoints[#breakpoints+1] = { threshold = 1, format = fmt.shortDecimalFormat, step = 1 }
end
breakpoints[#breakpoints+1] = { threshold = 60, format = fmt.minutesDecimalFormat, step = 1, components = {{div = 60}} }
breakpoints[#breakpoints+1] = { threshold = 3600, format = fmt.hoursDecimalFormat, step = 1, components = {{div = 3600}} }
formatter:SetBreakpoints(breakpoints)
end