Tidy up clock logic using DI and a GameplayClock

This commit is contained in:
Dean Herbert
2019-03-05 13:26:54 +09:00
parent 7c54e67b6e
commit 01f1018d02
11 changed files with 127 additions and 83 deletions

View File

@ -9,7 +9,6 @@ using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Threading;
using osu.Framework.Timing;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Ranking;
@ -27,8 +26,7 @@ namespace osu.Game.Screens.Play
{
private readonly double startTime;
public IAdjustableClock AdjustableClock;
public IFrameBasedClock FramedClock;
public Action<double> RequestSeek;
private Button button;
private Box remainingTimeBox;
@ -54,16 +52,13 @@ namespace osu.Game.Screens.Play
Origin = Anchor.Centre;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, GameplayClock clock)
{
var baseClock = Clock;
if (FramedClock != null)
{
Clock = FramedClock;
ProcessCustomClock = false;
}
if (clock != null)
Clock = clock;
Children = new Drawable[]
{
@ -111,7 +106,7 @@ namespace osu.Game.Screens.Play
using (BeginAbsoluteSequence(beginFadeTime))
this.FadeOut(fade_time);
button.Action = () => AdjustableClock?.Seek(startTime - skip_required_cutoff - fade_time);
button.Action = () => RequestSeek?.Invoke(startTime - skip_required_cutoff - fade_time);
displayTime = Time.Current;