1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Expose rewinding state of IGameplayClocks

The implementation of this requires a bit of a special case
for 0, so makes sense to implement in a central place.
This commit is contained in:
Dean Herbert 2023-07-06 14:02:20 +09:00
parent 7a3a14e50d
commit 2e98ab0a48
5 changed files with 21 additions and 3 deletions

View File

@ -125,6 +125,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public IEnumerable<double> NonGameplayAdjustments => throw new NotImplementedException();
public IBindable<bool> IsPaused => throw new NotImplementedException();
public bool IsRewinding => false;
}
}
}

View File

@ -64,6 +64,8 @@ namespace osu.Game.Beatmaps
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
public bool IsRewinding { get; private set; }
public bool IsCoupled
{
get => decoupledClock.IsCoupled;
@ -133,6 +135,9 @@ namespace osu.Game.Beatmaps
}
else
finalClockSource.ProcessFrame();
if (Clock.ElapsedFrameTime != 0)
IsRewinding = Clock.ElapsedFrameTime < 0;
}
public double TotalAppliedOffset

View File

@ -171,6 +171,9 @@ namespace osu.Game.Rulesets.UI
// The manual clock time has changed in the above code. The framed clock now needs to be updated
// to ensure that the its time is valid for our children before input is processed
framedClock.ProcessFrame();
if (framedClock.ElapsedFrameTime != 0)
IsRewinding = framedClock.ElapsedFrameTime < 0;
}
/// <summary>
@ -247,6 +250,8 @@ namespace osu.Game.Rulesets.UI
public IBindable<bool> IsPaused { get; } = new BindableBool();
public bool IsRewinding { get; private set; }
public double CurrentTime => framedClock.CurrentTime;
public double Rate => framedClock.Rate;

View File

@ -19,11 +19,10 @@ namespace osu.Game.Screens.Play
[Cached(typeof(IGameplayClock))]
public partial class GameplayClockContainer : Container, IAdjustableClock, IGameplayClock
{
/// <summary>
/// Whether gameplay is paused.
/// </summary>
public IBindable<bool> IsPaused => isPaused;
public bool IsRewinding => GameplayClock.IsRewinding;
/// <summary>
/// The source clock. Should generally not be used for any timekeeping purposes.
/// </summary>

View File

@ -23,6 +23,14 @@ namespace osu.Game.Screens.Play
/// </summary>
IAdjustableAudioComponent AdjustmentsFromMods { get; }
/// <summary>
/// Whether gameplay is paused.
/// </summary>
IBindable<bool> IsPaused { get; }
/// <summary>
/// Whether the clock is currently rewinding.
/// </summary>
bool IsRewinding { get; }
}
}