1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 15:43:21 +08:00

Expose GameplayStartTime in IGameplayClock

This commit is contained in:
Dean Herbert 2025-01-24 15:29:49 +09:00
parent 4ae6dfd790
commit 5cc8181bad
No known key found for this signature in database
5 changed files with 20 additions and 13 deletions

View File

@ -120,6 +120,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public double FramesPerSecond => throw new NotImplementedException(); public double FramesPerSecond => throw new NotImplementedException();
public FrameTimeInfo TimeInfo => throw new NotImplementedException(); public FrameTimeInfo TimeInfo => throw new NotImplementedException();
public double StartTime => throw new NotImplementedException(); public double StartTime => throw new NotImplementedException();
public double GameplayStartTime => throw new NotImplementedException();
public IAdjustableAudioComponent AdjustmentsFromMods => adjustableAudioComponent; public IAdjustableAudioComponent AdjustmentsFromMods => adjustableAudioComponent;

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.UI
private readonly Bindable<bool> waitingOnFrames = new Bindable<bool>(); private readonly Bindable<bool> waitingOnFrames = new Bindable<bool>();
private readonly double gameplayStartTime; public double GameplayStartTime { get; }
private IGameplayClock? parentGameplayClock; private IGameplayClock? parentGameplayClock;
@ -85,7 +85,7 @@ namespace osu.Game.Rulesets.UI
framedClock = new FramedClock(manualClock = new ManualClock()); framedClock = new FramedClock(manualClock = new ManualClock());
this.gameplayStartTime = gameplayStartTime; GameplayStartTime = gameplayStartTime;
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
@ -257,8 +257,8 @@ namespace osu.Game.Rulesets.UI
return; return;
} }
if (manualClock.CurrentTime < gameplayStartTime) if (manualClock.CurrentTime < GameplayStartTime)
manualClock.CurrentTime = proposedTime = Math.Min(gameplayStartTime, proposedTime); manualClock.CurrentTime = proposedTime = Math.Min(GameplayStartTime, proposedTime);
else if (Math.Abs(manualClock.CurrentTime - proposedTime) > sixty_frame_time * 1.2f) else if (Math.Abs(manualClock.CurrentTime - proposedTime) > sixty_frame_time * 1.2f)
{ {
proposedTime = proposedTime > manualClock.CurrentTime proposedTime = proposedTime > manualClock.CurrentTime

View File

@ -39,6 +39,8 @@ namespace osu.Game.Screens.Play
/// </remarks> /// </remarks>
public double StartTime { get; protected set; } public double StartTime { get; protected set; }
public double GameplayStartTime { get; protected set; }
public IAdjustableAudioComponent AdjustmentsFromMods { get; } = new AudioAdjustments(); public IAdjustableAudioComponent AdjustmentsFromMods { get; } = new AudioAdjustments();
private readonly BindableBool isPaused = new BindableBool(true); private readonly BindableBool isPaused = new BindableBool(true);

View File

@ -18,6 +18,11 @@ namespace osu.Game.Screens.Play
/// </remarks> /// </remarks>
double StartTime { get; } double StartTime { get; }
/// <summary>
/// The time from which actual gameplay should start. When intro time is skipped, this will be the seeked location.
/// </summary>
double GameplayStartTime { get; }
/// <summary> /// <summary>
/// All adjustments applied to this clock which come from mods. /// All adjustments applied to this clock which come from mods.
/// </summary> /// </summary>

View File

@ -57,8 +57,6 @@ namespace osu.Game.Screens.Play
private Track track; private Track track;
private readonly double skipTargetTime;
[Resolved] [Resolved]
private MusicController musicController { get; set; } = null!; private MusicController musicController { get; set; } = null!;
@ -66,16 +64,16 @@ namespace osu.Game.Screens.Play
/// Create a new master gameplay clock container. /// Create a new master gameplay clock container.
/// </summary> /// </summary>
/// <param name="beatmap">The beatmap to be used for time and metadata references.</param> /// <param name="beatmap">The beatmap to be used for time and metadata references.</param>
/// <param name="skipTargetTime">The latest time which should be used when introducing gameplay. Will be used when skipping forward.</param> /// <param name="gameplayStartTime">The latest time which should be used when introducing gameplay. Will be used when skipping forward.</param>
public MasterGameplayClockContainer(WorkingBeatmap beatmap, double skipTargetTime) public MasterGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime)
: base(beatmap.Track, applyOffsets: true, requireDecoupling: true) : base(beatmap.Track, applyOffsets: true, requireDecoupling: true)
{ {
this.beatmap = beatmap; this.beatmap = beatmap;
this.skipTargetTime = skipTargetTime;
track = beatmap.Track; track = beatmap.Track;
StartTime = findEarliestStartTime(); StartTime = findEarliestStartTime();
GameplayStartTime = gameplayStartTime;
} }
private double findEarliestStartTime() private double findEarliestStartTime()
@ -84,7 +82,7 @@ namespace osu.Game.Screens.Play
// generally this is either zero, or some point earlier than zero in the case of storyboards, lead-ins etc. // generally this is either zero, or some point earlier than zero in the case of storyboards, lead-ins etc.
// start with the originally provided latest time (if before zero). // start with the originally provided latest time (if before zero).
double time = Math.Min(0, skipTargetTime); double time = Math.Min(0, GameplayStartTime);
// if a storyboard is present, it may dictate the appropriate start time by having events in negative time space. // if a storyboard is present, it may dictate the appropriate start time by having events in negative time space.
// this is commonly used to display an intro before the audio track start. // this is commonly used to display an intro before the audio track start.
@ -119,10 +117,10 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public void Skip() public void Skip()
{ {
if (GameplayClock.CurrentTime > skipTargetTime - MINIMUM_SKIP_TIME) if (GameplayClock.CurrentTime > GameplayStartTime - MINIMUM_SKIP_TIME)
return; return;
double skipTarget = skipTargetTime - MINIMUM_SKIP_TIME; double skipTarget = GameplayStartTime - MINIMUM_SKIP_TIME;
if (StartTime < -10000 && GameplayClock.CurrentTime < 0 && skipTarget > 6000) if (StartTime < -10000 && GameplayClock.CurrentTime < 0 && skipTarget > 6000)
// double skip exception for storyboards with very long intros // double skip exception for storyboards with very long intros
@ -187,7 +185,8 @@ namespace osu.Game.Screens.Play
} }
else else
{ {
Logger.Log($"Playback discrepancy detected ({playbackDiscrepancyCount} of allowed {allowed_playback_discrepancies}): {elapsedGameplayClockTime:N1} vs {elapsedValidationTime:N1}"); Logger.Log(
$"Playback discrepancy detected ({playbackDiscrepancyCount} of allowed {allowed_playback_discrepancies}): {elapsedGameplayClockTime:N1} vs {elapsedValidationTime:N1}");
} }
elapsedValidationTime = null; elapsedValidationTime = null;