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

Stop using Drawable.Clock altogether

This commit is contained in:
Dan Balasescu 2022-06-02 15:02:44 +09:00
parent 2209a009f9
commit 4d9a77bdc0
2 changed files with 14 additions and 3 deletions

View File

@ -10,6 +10,7 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Timing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
@ -48,6 +49,17 @@ namespace osu.Game.Online.Spectator
/// </summary>
public IReadOnlyList<Mod> Mods => scoreProcessor?.Mods.Value ?? Array.Empty<Mod>();
private IClock? referenceClock;
/// <summary>
/// The clock used to determine the current score.
/// </summary>
public IClock ReferenceClock
{
get => referenceClock ?? Clock;
set => referenceClock = value;
}
[Resolved]
private SpectatorClient spectatorClient { get; set; } = null!;
@ -131,7 +143,7 @@ namespace osu.Game.Online.Spectator
Debug.Assert(spectatorState != null);
Debug.Assert(scoreProcessor != null);
int frameIndex = replayFrames.BinarySearch(new TimedFrame(Time.Current));
int frameIndex = replayFrames.BinarySearch(new TimedFrame(ReferenceClock.CurrentTime));
if (frameIndex < 0)
frameIndex = ~frameIndex;
frameIndex = Math.Clamp(frameIndex - 1, 0, replayFrames.Count - 1);

View File

@ -20,8 +20,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
if (!UserScores.TryGetValue(userId, out var data))
throw new ArgumentException(@"Provided user is not tracked by this leaderboard", nameof(userId));
data.ScoreProcessor.ProcessCustomClock = false;
data.ScoreProcessor.Clock = new FramedClock(clock);
data.ScoreProcessor.ReferenceClock = clock;
}
protected override void Update()