Simplify HideSkipPromptAt code

This commit is contained in:
ConfusedPolarBear 2023-06-09 00:54:32 -05:00
parent b2f316856d
commit 686c978a2f

View File

@ -88,15 +88,11 @@ public class SkipIntroController : ControllerBase
var config = Plugin.Instance!.Configuration; var config = Plugin.Instance!.Configuration;
segment.ShowSkipPromptAt = Math.Max(0, segment.IntroStart - config.ShowPromptAdjustment); segment.ShowSkipPromptAt = Math.Max(0, segment.IntroStart - config.ShowPromptAdjustment);
segment.HideSkipPromptAt = segment.IntroStart + config.HidePromptAdjustment; segment.HideSkipPromptAt = Math.Min(
segment.IntroStart + config.HidePromptAdjustment,
segment.IntroEnd);
segment.IntroEnd -= config.SecondsOfIntroToPlay; segment.IntroEnd -= config.SecondsOfIntroToPlay;
// Don't show prompt after the segment has ended
if (segment.HideSkipPromptAt > segment.IntroEnd)
{
segment.HideSkipPromptAt = segment.IntroEnd;
}
return segment; return segment;
} }
catch (KeyNotFoundException) catch (KeyNotFoundException)