mirror of
https://github.com/ppy/osu.git
synced 2026-05-18 04:59:52 +08:00
Better default preview time based on global fade
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,6 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// Reads the correct track restart point from beatmap metadata and sets looping to enabled.
|
||||
/// </summary>
|
||||
void PrepareTrackForPreview(bool looping, double offsetFromPreviewPoint = 0);
|
||||
void PrepareTrackForPreview(bool looping, double? offsetFromPreviewPoint = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -37,6 +37,9 @@ namespace osu.Game.Overlays
|
||||
/// </summary>
|
||||
private const double restart_cutoff_point = 5000;
|
||||
|
||||
public const double TRACK_FADE_IN_TIME = 500;
|
||||
public const double TRACK_FADE_OUT_TIME = 300;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the user has requested the track to be paused. Use <see cref="IsPlaying"/> to determine whether the track is still playing.
|
||||
/// </summary>
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user