mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Move all usage of GameplayClock
to IGameplayClock
This commit is contained in:
parent
6d78218142
commit
c8764cb333
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
private bool rotationTransferred;
|
private bool rotationTransferred;
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private GameplayClock gameplayClock { get; set; }
|
private IGameplayClock gameplayClock { get; set; }
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
(typeof(ScoreProcessor), actualComponentsContainer.Dependencies.Get<ScoreProcessor>()),
|
(typeof(ScoreProcessor), actualComponentsContainer.Dependencies.Get<ScoreProcessor>()),
|
||||||
(typeof(HealthProcessor), actualComponentsContainer.Dependencies.Get<HealthProcessor>()),
|
(typeof(HealthProcessor), actualComponentsContainer.Dependencies.Get<HealthProcessor>()),
|
||||||
(typeof(GameplayState), actualComponentsContainer.Dependencies.Get<GameplayState>()),
|
(typeof(GameplayState), actualComponentsContainer.Dependencies.Get<GameplayState>()),
|
||||||
(typeof(GameplayClock), actualComponentsContainer.Dependencies.Get<GameplayClock>())
|
(typeof(IGameplayClock), actualComponentsContainer.Dependencies.Get<IGameplayClock>())
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly GameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
private readonly IGameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
||||||
|
|
||||||
// best way to check without exposing.
|
// best way to check without exposing.
|
||||||
private Drawable hideTarget => hudOverlay.KeyCounter;
|
private Drawable hideTarget => hudOverlay.KeyCounter;
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly GameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
private readonly IGameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public void SetUpSteps()
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly GameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
private readonly IGameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
||||||
|
|
||||||
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
|
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
public IFrameStableClock FrameStableClock => frameStableClock;
|
public IFrameStableClock FrameStableClock => frameStableClock;
|
||||||
|
|
||||||
[Cached(typeof(GameplayClock))]
|
[Cached(typeof(IGameplayClock))]
|
||||||
private readonly FrameStabilityClock frameStableClock;
|
private readonly FrameStabilityClock frameStableClock;
|
||||||
|
|
||||||
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
|
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
|
||||||
@ -64,12 +64,12 @@ namespace osu.Game.Rulesets.UI
|
|||||||
private int direction = 1;
|
private int direction = 1;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(GameplayClock clock)
|
private void load(IGameplayClock clock)
|
||||||
{
|
{
|
||||||
if (clock != null)
|
if (clock != null)
|
||||||
{
|
{
|
||||||
parentGameplayClock = frameStableClock.ParentGameplayClock = clock;
|
parentGameplayClock = frameStableClock.ParentGameplayClock = clock;
|
||||||
frameStableClock.IsPaused.BindTo(clock.IsPaused);
|
((IBindable<bool>)frameStableClock.IsPaused).BindTo(clock.IsPaused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
private class FrameStabilityClock : GameplayClock, IFrameStableClock
|
private class FrameStabilityClock : GameplayClock, IFrameStableClock
|
||||||
{
|
{
|
||||||
public GameplayClock ParentGameplayClock;
|
public IGameplayClock ParentGameplayClock;
|
||||||
|
|
||||||
public readonly Bindable<bool> IsCatchingUp = new Bindable<bool>();
|
public readonly Bindable<bool> IsCatchingUp = new Bindable<bool>();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private ISamplePlaybackDisabler samplePlaybackDisabler { get; set; }
|
private ISamplePlaybackDisabler samplePlaybackDisabler { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameplayClock gameplayClock { get; set; }
|
private IGameplayClock gameplayClock { get; set; }
|
||||||
|
|
||||||
private void onComboChange(ValueChangedEvent<int> combo)
|
private void onComboChange(ValueChangedEvent<int> combo)
|
||||||
{
|
{
|
||||||
|
@ -19,15 +19,14 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <see cref="IFrameBasedClock"/>, as this should only be done once to ensure accuracy.
|
/// <see cref="IFrameBasedClock"/>, as this should only be done once to ensure accuracy.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameplayClock : IFrameBasedClock
|
public class GameplayClock : IGameplayClock
|
||||||
{
|
{
|
||||||
internal readonly IFrameBasedClock UnderlyingClock;
|
internal readonly IFrameBasedClock UnderlyingClock;
|
||||||
|
|
||||||
public readonly BindableBool IsPaused = new BindableBool();
|
public readonly BindableBool IsPaused = new BindableBool();
|
||||||
|
|
||||||
/// <summary>
|
IBindable<bool> IGameplayClock.IsPaused => IsPaused;
|
||||||
/// All adjustments applied to this clock which don't come from gameplay or mods.
|
|
||||||
/// </summary>
|
|
||||||
public virtual IEnumerable<Bindable<double>> NonGameplayAdjustments => Enumerable.Empty<Bindable<double>>();
|
public virtual IEnumerable<Bindable<double>> NonGameplayAdjustments => Enumerable.Empty<Bindable<double>>();
|
||||||
|
|
||||||
public GameplayClock(IFrameBasedClock underlyingClock)
|
public GameplayClock(IFrameBasedClock underlyingClock)
|
||||||
@ -35,23 +34,12 @@ namespace osu.Game.Screens.Play
|
|||||||
UnderlyingClock = underlyingClock;
|
UnderlyingClock = underlyingClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// If not set, a value of zero will be used.
|
|
||||||
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
|
|
||||||
/// </remarks>
|
|
||||||
public double? StartTime { get; internal set; }
|
public double? StartTime { get; internal set; }
|
||||||
|
|
||||||
public double CurrentTime => UnderlyingClock.CurrentTime;
|
public double CurrentTime => UnderlyingClock.CurrentTime;
|
||||||
|
|
||||||
public double Rate => UnderlyingClock.Rate;
|
public double Rate => UnderlyingClock.Rate;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The rate of gameplay when playback is at 100%.
|
|
||||||
/// This excludes any seeking / user adjustments.
|
|
||||||
/// </summary>
|
|
||||||
public double TrueGameplayRate
|
public double TrueGameplayRate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -81,7 +81,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
dependencies.CacheAs(GameplayClock = CreateGameplayClock(AdjustableSource));
|
dependencies.CacheAs<IGameplayClock>(GameplayClock = CreateGameplayClock(AdjustableSource));
|
||||||
|
|
||||||
GameplayClock.StartTime = StartTime;
|
GameplayClock.StartTime = StartTime;
|
||||||
GameplayClock.IsPaused.BindTo(IsPaused);
|
GameplayClock.IsPaused.BindTo(IsPaused);
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
public bool UsesFixedAnchor { get; set; }
|
public bool UsesFixedAnchor { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected GameplayClock GameplayClock { get; private set; } = null!;
|
protected IGameplayClock GameplayClock { get; private set; } = null!;
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private DrawableRuleset? drawableRuleset { get; set; }
|
private DrawableRuleset? drawableRuleset { get; set; }
|
||||||
|
@ -38,10 +38,10 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
set => endTime = value;
|
set => endTime = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameplayClock gameplayClock;
|
private IGameplayClock gameplayClock;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuColour colours, GameplayClock clock)
|
private void load(OsuColour colours, IGameplayClock clock)
|
||||||
{
|
{
|
||||||
if (clock != null)
|
if (clock != null)
|
||||||
gameplayClock = clock;
|
gameplayClock = clock;
|
||||||
|
34
osu.Game/Screens/Play/IGameplayClock.cs
Normal file
34
osu.Game/Screens/Play/IGameplayClock.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
public interface IGameplayClock : IFrameBasedClock
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The rate of gameplay when playback is at 100%.
|
||||||
|
/// This excludes any seeking / user adjustments.
|
||||||
|
/// </summary>
|
||||||
|
double TrueGameplayRate { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If not set, a value of zero will be used.
|
||||||
|
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
|
||||||
|
/// </remarks>
|
||||||
|
double? StartTime { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All adjustments applied to this clock which don't come from gameplay or mods.
|
||||||
|
/// </summary>
|
||||||
|
IEnumerable<Bindable<double>> NonGameplayAdjustments { get; }
|
||||||
|
|
||||||
|
IBindable<bool> IsPaused { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -41,7 +41,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private bool isClickable;
|
private bool isClickable;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameplayClock gameplayClock { get; set; }
|
private IGameplayClock gameplayClock { get; set; }
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(GameplayClock clock, CancellationToken? cancellationToken, GameHost host, RealmAccess realm)
|
private void load(IGameplayClock clock, CancellationToken? cancellationToken, GameHost host, RealmAccess realm)
|
||||||
{
|
{
|
||||||
if (clock != null)
|
if (clock != null)
|
||||||
Clock = clock;
|
Clock = clock;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user