Use FrameStabilityClock to denote current position on song progress

This commit is contained in:
Dean Herbert 2019-05-09 18:06:11 +09:00
parent 5942072128
commit 9248e6290c
4 changed files with 35 additions and 13 deletions

View File

@ -59,6 +59,8 @@ public abstract class DrawableRuleset<TObject> : DrawableRuleset, IProvideCursor
/// </summary>
public Container Overlays { get; private set; }
public override GameplayClock FrameStableClock => frameStabilityContainer.GameplayClock;
/// <summary>
/// Invoked when a <see cref="JudgementResult"/> has been applied by a <see cref="DrawableHitObject"/>.
/// </summary>
@ -334,6 +336,11 @@ public abstract class DrawableRuleset : CompositeDrawable
/// </summary>
public readonly BindableBool IsPaused = new BindableBool();
/// <summary>
/// The frame-stable clock which is being used for playfield display.
/// </summary>
public abstract GameplayClock FrameStableClock { get; }
/// <summary>~
/// The associated ruleset.
/// </summary>

View File

@ -20,7 +20,8 @@ public class FrameStabilityContainer : Container, IHasReplayHandler
public FrameStabilityContainer()
{
RelativeSizeAxes = Axes.Both;
gameplayClock = new GameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
GameplayClock = new GameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
}
private readonly ManualClock manualClock;
@ -28,7 +29,7 @@ public FrameStabilityContainer()
private readonly FramedClock framedClock;
[Cached]
private GameplayClock gameplayClock;
public GameplayClock GameplayClock { get; }
private IFrameBasedClock parentGameplayClock;
@ -38,7 +39,7 @@ private void load(GameplayClock clock)
if (clock != null)
{
parentGameplayClock = clock;
gameplayClock.IsPaused.BindTo(clock.IsPaused);
GameplayClock.IsPaused.BindTo(clock.IsPaused);
}
}
@ -73,7 +74,7 @@ protected override void LoadComplete()
public override bool UpdateSubTree()
{
requireMoreUpdateLoops = true;
validState = !gameplayClock.IsPaused.Value;
validState = !GameplayClock.IsPaused.Value;
int loops = 0;
@ -160,7 +161,7 @@ private void setClock()
if (parentGameplayClock == null)
parentGameplayClock = Clock;
Clock = gameplayClock;
Clock = GameplayClock;
ProcessCustomClock = false;
}

View File

@ -35,6 +35,10 @@ public class HUDOverlay : Container
public readonly HoldForMenuButton HoldToQuit;
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
private readonly ScoreProcessor scoreProcessor;
private readonly DrawableRuleset drawableRuleset;
private readonly IReadOnlyList<Mod> mods;
private Bindable<bool> showHud;
private readonly Container visibilityContainer;
private readonly BindableBool replayLoaded = new BindableBool();
@ -45,6 +49,10 @@ public class HUDOverlay : Container
public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
{
this.scoreProcessor = scoreProcessor;
this.drawableRuleset = drawableRuleset;
this.mods = mods;
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
@ -89,20 +97,21 @@ public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset
}
}
};
}
[BackgroundDependencyLoader(true)]
private void load(OsuConfigManager config, NotificationOverlay notificationOverlay)
{
BindProcessor(scoreProcessor);
BindDrawableRuleset(drawableRuleset);
Progress.Objects = drawableRuleset.Objects;
Progress.AllowSeeking = drawableRuleset.HasReplayLoaded.Value;
Progress.RequestSeek = time => RequestSeek(time);
Progress.ReferenceClock = drawableRuleset.FrameStableClock;
ModDisplay.Current.Value = mods;
}
[BackgroundDependencyLoader(true)]
private void load(OsuConfigManager config, NotificationOverlay notificationOverlay)
{
showHud = config.GetBindable<bool>(OsuSetting.ShowInterface);
showHud.ValueChanged += visible => visibilityContainer.FadeTo(visible.NewValue ? 1 : 0, duration);
showHud.TriggerChange();

View File

@ -10,6 +10,7 @@
using osu.Framework.Allocation;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Timing;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.UI;
@ -55,7 +56,9 @@ public IEnumerable<HitObject> Objects
private readonly BindableBool replayLoaded = new BindableBool();
private GameplayClock gameplayClock;
public IClock ReferenceClock;
private IClock gameplayClock;
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, GameplayClock clock)
@ -154,10 +157,12 @@ protected override void Update()
if (objects == null)
return;
double position = gameplayClock?.CurrentTime ?? Time.Current;
double progress = Math.Min(1, (position - firstHitTime) / (lastHitTime - firstHitTime));
double gameplayTime = gameplayClock?.CurrentTime ?? Time.Current;
double frameStableTime = ReferenceClock?.CurrentTime ?? gameplayTime;
bar.CurrentTime = position;
double progress = Math.Min(1, (frameStableTime - firstHitTime) / (lastHitTime - firstHitTime));
bar.CurrentTime = gameplayTime;
graph.Progress = (int)(graph.ColumnCount * progress);
}
}