Skip to content

Commit

Permalink
fix: chapter remaining time scaled by speed even when `destination_ti…
Browse files Browse the repository at this point in the history
…me` is set to `time-remaining`
  • Loading branch information
tomasklaen committed Mar 13, 2024
1 parent 581adf4 commit 6fa34c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/uosc/elements/Timeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function Timeline:render()
local offset = opts.size / (visibility > 0 and 24 or 28)
for _, range in ipairs(state.uncached_ranges) do
if not buffered_playtime and (range[1] > state.time or range[2] > state.time) then
buffered_playtime = (range[1] - state.time) / (state.speed or 1)
buffered_playtime = (range[1] - state.time) / state.speed
end
if options.timeline_cache then
local ax = range[1] < 0.5 and bax or math.floor(t2x(range[1]))
Expand Down
3 changes: 2 additions & 1 deletion src/uosc/elements/TopBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ function TopBar:render()
local text = '' .. state.current_chapter.index .. ': ' .. state.current_chapter.title
local next_chapter = state.chapters[state.current_chapter.index + 1]
local chapter_end = next_chapter and next_chapter.time or state.duration or 0
local remaining_time = ((state.time and state.time or 0) - chapter_end) / (state.speed or 1)
local remaining_time = ((state.time or 0) - chapter_end) /
(options.destination_time == 'time-remaining' and 1 or state.speed)
local remaining_human = format_time(remaining_time, math.abs(remaining_time))
local opts = {
size = font_size,
Expand Down
8 changes: 4 additions & 4 deletions src/uosc/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@ function update_fullormaxed()
end

function update_human_times()
state.speed = state.speed or 1
if state.time then
local max_seconds = state.duration
if state.duration then
local speed = state.speed or 1
if options.destination_time == 'playtime-remaining' then
max_seconds = speed >= 1 and state.duration or state.duration / speed
state.destination_time_human = format_time((state.time - state.duration) / speed, max_seconds)
max_seconds = state.speed >= 1 and state.duration or state.duration / state.speed
state.destination_time_human = format_time((state.time - state.duration) / state.speed, max_seconds)
elseif options.destination_time == 'total' then
state.destination_time_human = format_time(state.duration, max_seconds)
else
Expand All @@ -447,7 +447,7 @@ function update_human_times()
end
state.time_human = format_time(state.time, max_seconds)
else
state.time_human = nil
state.time_human, state.destination_time_human = nil, nil
end
end

Expand Down

0 comments on commit 6fa34c3

Please sign in to comment.