1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Update calculator and tests to match changes on clocks

This commit is contained in:
Ryuki 2022-08-18 18:40:02 +02:00
parent 2aa3a1b50d
commit 3de35a1518
No known key found for this signature in database
GPG Key ID: A353889EAEACBF49
2 changed files with 20 additions and 4 deletions

View File

@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual.Gameplay
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[] CachedDependencies = new (Type, object)[]
{ {
(typeof(GameplayClock), mainClock = new MockFrameStableClock(new MockFrameBasedClock())), (typeof(IGameplayClock), mainClock = new MockFrameStableClock(new MockFrameBasedClock())),
(typeof(DrawableRuleset), new MockDrawableRuleset(ruleset, mainClock)) (typeof(DrawableRuleset), new MockDrawableRuleset(ruleset, mainClock))
} }
}, },
@ -249,17 +249,33 @@ namespace osu.Game.Tests.Visual.Gameplay
public FrameTimeInfo TimeInfo { get; private set; } public FrameTimeInfo TimeInfo { get; private set; }
} }
private class MockFrameStableClock : GameplayClock, IFrameStableClock private class MockFrameStableClock : IGameplayClock, IFrameStableClock
{ {
internal readonly IFrameBasedClock UnderlyingClock;
public readonly BindableBool IsPaused = new BindableBool();
public MockFrameStableClock(MockFrameBasedClock underlyingClock) public MockFrameStableClock(MockFrameBasedClock underlyingClock)
: base(underlyingClock)
{ {
UnderlyingClock = underlyingClock;
} }
public void Seek(double time) => (UnderlyingClock as MockFrameBasedClock)?.Seek(time); public void Seek(double time) => (UnderlyingClock as MockFrameBasedClock)?.Seek(time);
public IBindable<bool> IsCatchingUp => new Bindable<bool>(); public IBindable<bool> IsCatchingUp => new Bindable<bool>();
public IBindable<bool> WaitingOnFrames => new Bindable<bool>(); public IBindable<bool> WaitingOnFrames => new Bindable<bool>();
public double CurrentTime => UnderlyingClock.CurrentTime;
public double Rate => UnderlyingClock.Rate;
public bool IsRunning => UnderlyingClock.IsRunning;
public void ProcessFrame() => UnderlyingClock.ProcessFrame();
public double ElapsedFrameTime => UnderlyingClock.ElapsedFrameTime;
public double FramesPerSecond => UnderlyingClock.FramesPerSecond;
public FrameTimeInfo TimeInfo => UnderlyingClock.TimeInfo;
public double TrueGameplayRate => UnderlyingClock.Rate;
public double? StartTime => 0;
public IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>();
IBindable<bool> IGameplayClock.IsPaused => IsPaused;
} }
private class MockDrawableRuleset : DrawableRuleset private class MockDrawableRuleset : DrawableRuleset

View File

@ -18,7 +18,7 @@ namespace osu.Game.Screens.Play.HUD.ClicksPerSecond
private InputListener? listener; private InputListener? listener;
[Resolved] [Resolved]
private GameplayClock? gameplayClock { get; set; } private IGameplayClock? gameplayClock { get; set; }
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private DrawableRuleset? drawableRuleset { get; set; } private DrawableRuleset? drawableRuleset { get; set; }