mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Make GameplayClockContainer
also an IGameplayClock
and expose to remaining tests
This commit is contained in:
parent
c8764cb333
commit
f81c7644b4
@ -77,7 +77,6 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
Add(gameplayContainer = new MasterGameplayClockContainer(working, 0)
|
Add(gameplayContainer = new MasterGameplayClockContainer(working, 0)
|
||||||
{
|
{
|
||||||
IsPaused = { Value = true },
|
|
||||||
Child = new FrameStabilityContainer
|
Child = new FrameStabilityContainer
|
||||||
{
|
{
|
||||||
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||||
@ -106,7 +105,6 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
Add(gameplayContainer = new MasterGameplayClockContainer(working, start_time)
|
Add(gameplayContainer = new MasterGameplayClockContainer(working, start_time)
|
||||||
{
|
{
|
||||||
StartTime = start_time,
|
StartTime = start_time,
|
||||||
IsPaused = { Value = true },
|
|
||||||
Child = new FrameStabilityContainer
|
Child = new FrameStabilityContainer
|
||||||
{
|
{
|
||||||
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Cached]
|
[Cached]
|
||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached(typeof(IGameplayClock))]
|
||||||
private readonly IGameplayClock 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.
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Cached]
|
[Cached]
|
||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached(typeof(IGameplayClock))]
|
||||||
private readonly IGameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
private readonly IGameplayClock gameplayClock = new GameplayClock(new FramedClock());
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Cached]
|
[Cached]
|
||||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||||
|
|
||||||
[Cached]
|
[Cached(typeof(IGameplayClock))]
|
||||||
private readonly IGameplayClock 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>();
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
Add(gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time));
|
Add(gameplayClockContainer = new MasterGameplayClockContainer(Beatmap.Value, skip_target_time));
|
||||||
|
|
||||||
Dependencies.CacheAs(gameplayClockContainer);
|
Dependencies.CacheAs<IGameplayClock>(gameplayClockContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
@ -15,12 +16,14 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encapsulates gameplay timing logic and provides a <see cref="GameplayClock"/> via DI for gameplay components to use.
|
/// Encapsulates gameplay timing logic and provides a <see cref="GameplayClock"/> via DI for gameplay components to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameplayClockContainer : Container, IAdjustableClock, IFrameBasedClock
|
public class GameplayClockContainer : Container, IAdjustableClock, IGameplayClock
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether gameplay is paused.
|
/// Whether gameplay is paused.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly BindableBool IsPaused = new BindableBool(true);
|
public IBindable<bool> IsPaused => isPaused;
|
||||||
|
|
||||||
|
private readonly BindableBool isPaused = new BindableBool(true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The adjustable source clock used for gameplay. Should be used for seeks and clock control.
|
/// The adjustable source clock used for gameplay. Should be used for seeks and clock control.
|
||||||
@ -58,6 +61,8 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Bindable<double>> NonGameplayAdjustments => GameplayClock.NonGameplayAdjustments;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The final clock which is exposed to gameplay components.
|
/// The final clock which is exposed to gameplay components.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -84,7 +89,7 @@ namespace osu.Game.Screens.Play
|
|||||||
dependencies.CacheAs<IGameplayClock>(GameplayClock = CreateGameplayClock(AdjustableSource));
|
dependencies.CacheAs<IGameplayClock>(GameplayClock = CreateGameplayClock(AdjustableSource));
|
||||||
|
|
||||||
GameplayClock.StartTime = StartTime;
|
GameplayClock.StartTime = StartTime;
|
||||||
GameplayClock.IsPaused.BindTo(IsPaused);
|
GameplayClock.IsPaused.BindTo(isPaused);
|
||||||
|
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
@ -105,7 +110,7 @@ namespace osu.Game.Screens.Play
|
|||||||
AdjustableSource.Start();
|
AdjustableSource.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
IsPaused.Value = false;
|
isPaused.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -127,7 +132,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops gameplay.
|
/// Stops gameplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Stop() => IsPaused.Value = true;
|
public void Stop() => isPaused.Value = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
||||||
@ -232,5 +237,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public double FramesPerSecond => GameplayClock.FramesPerSecond;
|
public double FramesPerSecond => GameplayClock.FramesPerSecond;
|
||||||
|
|
||||||
public FrameTimeInfo TimeInfo => GameplayClock.TimeInfo;
|
public FrameTimeInfo TimeInfo => GameplayClock.TimeInfo;
|
||||||
|
|
||||||
|
public double TrueGameplayRate => GameplayClock.TrueGameplayRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ namespace osu.Game.Screens.Play
|
|||||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());
|
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());
|
||||||
|
|
||||||
// bind clock into components that require it
|
// bind clock into components that require it
|
||||||
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
((IBindable<bool>)DrawableRuleset.IsPaused).BindTo(GameplayClockContainer.IsPaused);
|
||||||
|
|
||||||
DrawableRuleset.NewResult += r =>
|
DrawableRuleset.NewResult += r =>
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public class ScreenSuspensionHandler : Component
|
public class ScreenSuspensionHandler : Component
|
||||||
{
|
{
|
||||||
private readonly GameplayClockContainer gameplayClockContainer;
|
private readonly GameplayClockContainer gameplayClockContainer;
|
||||||
private Bindable<bool> isPaused;
|
private IBindable<bool> isPaused;
|
||||||
|
|
||||||
private readonly Bindable<bool> disableSuspensionBindable = new Bindable<bool>();
|
private readonly Bindable<bool> disableSuspensionBindable = new Bindable<bool>();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user