mirror of
https://github.com/osukey/osukey.git
synced 2025-06-18 17:57:55 +09:00
Pass in master clock instead of slave clock
This commit is contained in:
parent
5b4cb71cc7
commit
6626e70c95
@ -168,6 +168,11 @@ namespace osu.Game.Tests.OnlinePlay
|
|||||||
|
|
||||||
public bool IsCatchingUp { get; set; }
|
public bool IsCatchingUp { get; set; }
|
||||||
|
|
||||||
|
public IFrameBasedClock Source
|
||||||
|
{
|
||||||
|
set => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public readonly int Id;
|
public readonly int Id;
|
||||||
|
|
||||||
public TestSpectatorPlayerClock(int id)
|
public TestSpectatorPlayerClock(int id)
|
||||||
|
@ -79,7 +79,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < UserIds.Length; i++)
|
for (int i = 0; i < UserIds.Length; i++)
|
||||||
grid.Add(instances[i] = new PlayerArea(UserIds[i], new CatchUpSpectatorPlayerClock(masterClockContainer.GameplayClock)));
|
{
|
||||||
|
grid.Add(instances[i] = new PlayerArea(UserIds[i], masterClockContainer.GameplayClock));
|
||||||
|
syncManager.AddPlayerClock(instances[i].GameplayClock);
|
||||||
|
}
|
||||||
|
|
||||||
// Todo: This is not quite correct - it should be per-user to adjust for other mod combinations.
|
// Todo: This is not quite correct - it should be per-user to adjust for other mod combinations.
|
||||||
var playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
|
var playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -38,7 +39,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
/// The <see cref="ISpectatorPlayerClock"/> used to control the gameplay running state of a loaded <see cref="Player"/>.
|
/// The <see cref="ISpectatorPlayerClock"/> used to control the gameplay running state of a loaded <see cref="Player"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public readonly ISpectatorPlayerClock GameplayClock;
|
public readonly ISpectatorPlayerClock GameplayClock = new CatchUpSpectatorPlayerClock();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The currently-loaded score.
|
/// The currently-loaded score.
|
||||||
@ -54,10 +55,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
private readonly AudioContainer audioContainer;
|
private readonly AudioContainer audioContainer;
|
||||||
private OsuScreenStack stack;
|
private OsuScreenStack stack;
|
||||||
|
|
||||||
public PlayerArea(int userId, [NotNull] ISpectatorPlayerClock gameplayClock)
|
public PlayerArea(int userId, IFrameBasedClock masterClock)
|
||||||
{
|
{
|
||||||
UserId = userId;
|
UserId = userId;
|
||||||
GameplayClock = gameplayClock;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
@ -71,6 +71,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
},
|
},
|
||||||
loadingLayer = new LoadingLayer(true) { State = { Value = Visibility.Visible } }
|
loadingLayer = new LoadingLayer(true) { State = { Value = Visibility.Visible } }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameplayClock.Source = masterClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadScore([NotNull] Score score)
|
public void LoadScore([NotNull] Score score)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
@ -17,12 +19,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const double CATCHUP_RATE = 2;
|
public const double CATCHUP_RATE = 2;
|
||||||
|
|
||||||
private readonly IFrameBasedClock masterClock;
|
/// <summary>
|
||||||
|
/// The source clock.
|
||||||
public CatchUpSpectatorPlayerClock(IFrameBasedClock masterClock)
|
/// </summary>
|
||||||
{
|
public IFrameBasedClock? Source { get; set; }
|
||||||
this.masterClock = masterClock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double CurrentTime { get; private set; }
|
public double CurrentTime { get; private set; }
|
||||||
|
|
||||||
@ -52,19 +52,22 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
|
|||||||
|
|
||||||
public void ProcessFrame()
|
public void ProcessFrame()
|
||||||
{
|
{
|
||||||
masterClock.ProcessFrame();
|
|
||||||
|
|
||||||
ElapsedFrameTime = 0;
|
ElapsedFrameTime = 0;
|
||||||
FramesPerSecond = 0;
|
FramesPerSecond = 0;
|
||||||
|
|
||||||
|
if (Source == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Source.ProcessFrame();
|
||||||
|
|
||||||
if (IsRunning)
|
if (IsRunning)
|
||||||
{
|
{
|
||||||
double elapsedSource = masterClock.ElapsedFrameTime;
|
double elapsedSource = Source.ElapsedFrameTime;
|
||||||
double elapsed = elapsedSource * Rate;
|
double elapsed = elapsedSource * Rate;
|
||||||
|
|
||||||
CurrentTime += elapsed;
|
CurrentTime += elapsed;
|
||||||
ElapsedFrameTime = elapsed;
|
ElapsedFrameTime = elapsed;
|
||||||
FramesPerSecond = masterClock.FramesPerSecond;
|
FramesPerSecond = Source.FramesPerSecond;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,5 +20,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
|
|||||||
/// Whether this clock is resynchronising to the master clock.
|
/// Whether this clock is resynchronising to the master clock.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsCatchingUp { get; set; }
|
bool IsCatchingUp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The source clock
|
||||||
|
/// </summary>
|
||||||
|
IFrameBasedClock Source { set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user