@@ -4,9 +4,9 @@ local oUF = ns.oUF
4
4
local VISIBLE = 1
5
5
local HIDDEN = 0
6
6
7
+ local mod = mod
7
8
local wipe = wipe
8
9
local pcall = pcall
9
- local floor = floor
10
10
local unpack = unpack
11
11
local tinsert = tinsert
12
12
local infinity = math.huge
@@ -20,18 +20,26 @@ local GameTooltip = GameTooltip
20
20
local LibDispel = LibStub (' LibDispel-1.0' )
21
21
local DebuffColors = LibDispel :GetDebuffTypeColor ()
22
22
23
- local DAY , HOUR , MINUTE = 86400 , 3600 , 60
24
- local function FormatTime (s )
25
- if s == infinity then return end
23
+ local YEAR , DAY , HOUR , MINUTE = 31557600 , 86400 , 3600 , 60
24
+ local function FormatTime (sec )
25
+ if sec == infinity then
26
+ return
27
+ end
26
28
27
- if s < MINUTE then
28
- return ' %.1fs' , s
29
- elseif s < HOUR then
30
- return ' %dm %ds' , s / 60 % 60 , s % 60
31
- elseif s < DAY then
32
- return ' %dh %dm' , s / (60 * 60 ), s / 60 % 60
29
+ if sec < MINUTE then
30
+ return ' %.1fs' , sec
31
+ elseif sec < HOUR then
32
+ local mins = mod (sec , HOUR ) / MINUTE
33
+ local secs = mod (sec , MINUTE )
34
+ return ' %dm %ds' , mins , secs
35
+ elseif sec < DAY then
36
+ local hrs = mod (sec , DAY ) / HOUR
37
+ local mins = mod (sec , HOUR ) / MINUTE
38
+ return ' %dh %dm' , hrs , mins
33
39
else
34
- return ' %dd %dh' , s / DAY , (s / HOUR ) - (floor (s / DAY ) * 24 )
40
+ local days = mod (sec , YEAR ) / DAY
41
+ local hrs = mod (sec , DAY ) / HOUR
42
+ return ' %dd %dh' , days , hrs
35
43
end
36
44
end
37
45
@@ -48,13 +56,23 @@ local function onLeave()
48
56
GameTooltip :Hide ()
49
57
end
50
58
59
+ local function updateValue (bar , start )
60
+ local remain = (bar .expiration - GetTime ()) / (bar .modRate or 1 )
61
+
62
+ if start and bar .SetValue_ then
63
+ bar :SetValue_ (remain / bar .duration )
64
+ else
65
+ bar :SetValue (remain / bar .duration )
66
+ end
67
+
68
+ bar .timeText :SetFormattedText (FormatTime (remain ))
69
+ end
70
+
51
71
local function onUpdate (bar , elapsed )
52
72
bar .elapsed = (bar .elapsed or 0 ) + elapsed
53
73
54
74
if bar .elapsed > 0.01 then
55
- local remain = (bar .expiration - GetTime ()) / (bar .modRate or 1 )
56
- bar :SetValue (remain / bar .duration )
57
- bar .timeText :SetFormattedText (FormatTime (remain ))
75
+ updateValue (bar )
58
76
59
77
bar .elapsed = 0
60
78
end
@@ -140,7 +158,7 @@ local function updateBar(element, bar)
140
158
end
141
159
end
142
160
143
- local function updateAura (element , unit , index , offset , filter , isDebuff , visible )
161
+ local function auraUpdate (element , unit , index , offset , filter , isDebuff , visible )
144
162
local name , texture , count , debuffType , duration , expiration , source , isStealable , nameplateShowPersonal , spellID , canApplyAura , isBossDebuff , castByPlayer , nameplateShowAll , modRate , effect1 , effect2 , effect3 = oUF :GetAuraData (unit , index , filter )
145
163
146
164
if not name then return end
@@ -178,7 +196,13 @@ local function updateAura(element, unit, index, offset, filter, isDebuff, visibl
178
196
canApplyAura , isBossDebuff , castByPlayer , nameplateShowAll , modRate , effect1 , effect2 , effect3 )
179
197
180
198
updateBar (element , bar )
181
- bar :SetScript (' OnUpdate' , not bar .noTime and onUpdate or nil )
199
+
200
+ if bar .noTime then
201
+ bar :SetScript (' OnUpdate' , nil )
202
+ else
203
+ updateValue (bar , true )
204
+ bar :SetScript (' OnUpdate' , onUpdate )
205
+ end
182
206
183
207
return show and VISIBLE or HIDDEN
184
208
end
@@ -210,7 +234,7 @@ local function filterBars(element, unit, filter, limit, isDebuff, offset, dontHi
210
234
local visible = 0
211
235
local hidden = 0
212
236
while (visible < limit ) do
213
- local result = updateAura (element , unit , index , offset , filter , isDebuff , visible )
237
+ local result = auraUpdate (element , unit , index , offset , filter , isDebuff , visible )
214
238
if (not result ) then
215
239
break
216
240
elseif (result == VISIBLE ) then
0 commit comments