From 6fa34c31d0a5290dee83282205768d15111df7d8 Mon Sep 17 00:00:00 2001 From: tomasklaen Date: Wed, 13 Mar 2024 11:01:12 +0100 Subject: [PATCH] fix: chapter remaining time scaled by speed even when `destination_time` is set to `time-remaining` --- src/uosc/elements/Timeline.lua | 2 +- src/uosc/elements/TopBar.lua | 3 ++- src/uosc/main.lua | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/uosc/elements/Timeline.lua b/src/uosc/elements/Timeline.lua index 3f675b6..3bd838c 100644 --- a/src/uosc/elements/Timeline.lua +++ b/src/uosc/elements/Timeline.lua @@ -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])) diff --git a/src/uosc/elements/TopBar.lua b/src/uosc/elements/TopBar.lua index 04bd1ec..b955528 100644 --- a/src/uosc/elements/TopBar.lua +++ b/src/uosc/elements/TopBar.lua @@ -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, diff --git a/src/uosc/main.lua b/src/uosc/main.lua index 683f3d0..2102c07 100644 --- a/src/uosc/main.lua +++ b/src/uosc/main.lua @@ -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 @@ -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