From b8d0dfe2edd9b06b46d2878f020084bf5cea9679 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 18 Mar 2026 13:49:53 +0900 Subject: [PATCH] Better default preview time based on global fade --- osu.Game/Beatmaps/BeatmapDifficultyCache.cs | 2 +- osu.Game/Beatmaps/IWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 +++++-- osu.Game/Overlays/MusicController.cs | 7 +++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs index 6ac8508036..d6b4063916 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs @@ -424,7 +424,7 @@ namespace osu.Game.Beatmaps Stream IWorkingBeatmap.GetStream(string storagePath) => working.GetStream(storagePath); void IWorkingBeatmap.BeginAsyncLoad() => working.BeginAsyncLoad(); void IWorkingBeatmap.CancelAsyncLoad() => working.CancelAsyncLoad(); - void IWorkingBeatmap.PrepareTrackForPreview(bool looping, double offsetFromPreviewPoint) => working.PrepareTrackForPreview(looping, offsetFromPreviewPoint); + void IWorkingBeatmap.PrepareTrackForPreview(bool looping, double? offsetFromPreviewPoint) => working.PrepareTrackForPreview(looping, offsetFromPreviewPoint); } } } diff --git a/osu.Game/Beatmaps/IWorkingBeatmap.cs b/osu.Game/Beatmaps/IWorkingBeatmap.cs index bdfa6bdf6d..297d9bcbd2 100644 --- a/osu.Game/Beatmaps/IWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/IWorkingBeatmap.cs @@ -139,6 +139,6 @@ namespace osu.Game.Beatmaps /// /// Reads the correct track restart point from beatmap metadata and sets looping to enabled. /// - void PrepareTrackForPreview(bool looping, double offsetFromPreviewPoint = 0); + void PrepareTrackForPreview(bool looping, double? offsetFromPreviewPoint = null); } } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 4ea26b46f8..58af629a63 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -16,6 +16,7 @@ using osu.Framework.Audio.Track; using osu.Framework.Extensions; using osu.Framework.Graphics.Textures; using osu.Framework.Logging; +using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; @@ -119,7 +120,7 @@ namespace osu.Game.Beatmaps return track; } - public void PrepareTrackForPreview(bool looping, double offsetFromPreviewPoint = 0) + public void PrepareTrackForPreview(bool looping, double? offsetFromPreviewPoint = null) { Track.Looping = looping; Track.RestartPoint = Metadata.PreviewTime; @@ -133,7 +134,9 @@ namespace osu.Game.Beatmaps if (Track.RestartPoint < 0 || Track.RestartPoint > Track.Length) Track.RestartPoint = 0.4f * Track.Length; - Track.RestartPoint = Math.Clamp(Track.RestartPoint + offsetFromPreviewPoint, 0, Track.Length); + offsetFromPreviewPoint ??= -MusicController.TRACK_FADE_IN_TIME; + + Track.RestartPoint = Math.Clamp(Track.RestartPoint + offsetFromPreviewPoint.Value, 0, Track.Length); } /// diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index a5550ad3d9..b4b2628a64 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -37,6 +37,9 @@ namespace osu.Game.Overlays /// private const double restart_cutoff_point = 5000; + public const double TRACK_FADE_IN_TIME = 500; + public const double TRACK_FADE_OUT_TIME = 300; + /// /// Whether the user has requested the track to be paused. Use to determine whether the track is still playing. /// @@ -523,12 +526,12 @@ namespace osu.Game.Overlays // but the mutation of the hierarchy is scheduled to avoid exceptions. Schedule(() => { - lastTrack.VolumeTo(0, 500, Easing.Out).Expire(); + lastTrack.VolumeTo(0, TRACK_FADE_OUT_TIME, Easing.Out).Expire(); if (queuedTrack == CurrentTrack) { AddInternal(queuedTrack); - queuedTrack.VolumeTo(0).Then().VolumeTo(1, 300, Easing.Out); + queuedTrack.VolumeTo(0).Then().VolumeTo(1, TRACK_FADE_IN_TIME, Easing.Out); } else {