1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:42:54 +08:00

Rename classes

This commit is contained in:
smoogipoo 2021-04-15 19:16:00 +09:00
parent 1705d472b5
commit df4fce2c57
8 changed files with 43 additions and 43 deletions

View File

@ -12,22 +12,22 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Tests.OnlinePlay namespace osu.Game.Tests.OnlinePlay
{ {
[HeadlessTest] [HeadlessTest]
public class MultiplayerSyncManagerTest : OsuTestScene public class MultiplayerCatchupSyncManagerTest : OsuTestScene
{ {
private TestManualClock master; private TestManualClock master;
private MultiplayerSyncManager syncManager; private MultiplayerCatchupSyncManager catchupSyncManager;
private TestSlaveClock slave1; private TestSpectatorSlaveClock slave1;
private TestSlaveClock slave2; private TestSpectatorSlaveClock slave2;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
syncManager = new MultiplayerSyncManager(master = new TestManualClock()); catchupSyncManager = new MultiplayerCatchupSyncManager(master = new TestManualClock());
syncManager.AddSlave(slave1 = new TestSlaveClock(1)); catchupSyncManager.AddSlave(slave1 = new TestSpectatorSlaveClock(1));
syncManager.AddSlave(slave2 = new TestSlaveClock(2)); catchupSyncManager.AddSlave(slave2 = new TestSpectatorSlaveClock(2));
Schedule(() => Child = syncManager); Schedule(() => Child = catchupSyncManager);
} }
[Test] [Test]
@ -47,7 +47,7 @@ namespace osu.Game.Tests.OnlinePlay
[Test] [Test]
public void TestMasterClockDoesNotStartWhenNoneReadyForMaximumDelayTime() public void TestMasterClockDoesNotStartWhenNoneReadyForMaximumDelayTime()
{ {
AddWaitStep($"wait {MultiplayerSyncManager.MAXIMUM_START_DELAY} milliseconds", (int)Math.Ceiling(MultiplayerSyncManager.MAXIMUM_START_DELAY / TimePerAction)); AddWaitStep($"wait {MultiplayerCatchupSyncManager.MAXIMUM_START_DELAY} milliseconds", (int)Math.Ceiling(MultiplayerCatchupSyncManager.MAXIMUM_START_DELAY / TimePerAction));
assertMasterState(false); assertMasterState(false);
} }
@ -55,7 +55,7 @@ namespace osu.Game.Tests.OnlinePlay
public void TestMasterClockStartsWhenAnyReadyForMaximumDelayTime() public void TestMasterClockStartsWhenAnyReadyForMaximumDelayTime()
{ {
setWaiting(() => slave1, false); setWaiting(() => slave1, false);
AddWaitStep($"wait {MultiplayerSyncManager.MAXIMUM_START_DELAY} milliseconds", (int)Math.Ceiling(MultiplayerSyncManager.MAXIMUM_START_DELAY / TimePerAction)); AddWaitStep($"wait {MultiplayerCatchupSyncManager.MAXIMUM_START_DELAY} milliseconds", (int)Math.Ceiling(MultiplayerCatchupSyncManager.MAXIMUM_START_DELAY / TimePerAction));
assertMasterState(true); assertMasterState(true);
} }
@ -64,7 +64,7 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setMasterTime(MultiplayerSyncManager.SYNC_TARGET + 1); setMasterTime(MultiplayerCatchupSyncManager.SYNC_TARGET + 1);
assertCatchingUp(() => slave1, false); assertCatchingUp(() => slave1, false);
} }
@ -73,7 +73,7 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setMasterTime(MultiplayerSyncManager.MAX_SYNC_OFFSET + 1); setMasterTime(MultiplayerCatchupSyncManager.MAX_SYNC_OFFSET + 1);
assertCatchingUp(() => slave1, true); assertCatchingUp(() => slave1, true);
assertCatchingUp(() => slave2, true); assertCatchingUp(() => slave2, true);
} }
@ -83,8 +83,8 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setMasterTime(MultiplayerSyncManager.MAX_SYNC_OFFSET + 1); setMasterTime(MultiplayerCatchupSyncManager.MAX_SYNC_OFFSET + 1);
setSlaveTime(() => slave1, MultiplayerSyncManager.SYNC_TARGET + 1); setSlaveTime(() => slave1, MultiplayerCatchupSyncManager.SYNC_TARGET + 1);
assertCatchingUp(() => slave1, true); assertCatchingUp(() => slave1, true);
} }
@ -93,8 +93,8 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setMasterTime(MultiplayerSyncManager.MAX_SYNC_OFFSET + 2); setMasterTime(MultiplayerCatchupSyncManager.MAX_SYNC_OFFSET + 2);
setSlaveTime(() => slave1, MultiplayerSyncManager.SYNC_TARGET); setSlaveTime(() => slave1, MultiplayerCatchupSyncManager.SYNC_TARGET);
assertCatchingUp(() => slave1, false); assertCatchingUp(() => slave1, false);
assertCatchingUp(() => slave2, true); assertCatchingUp(() => slave2, true);
} }
@ -104,7 +104,7 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setSlaveTime(() => slave1, -MultiplayerSyncManager.SYNC_TARGET); setSlaveTime(() => slave1, -MultiplayerCatchupSyncManager.SYNC_TARGET);
assertCatchingUp(() => slave1, false); assertCatchingUp(() => slave1, false);
assertSlaveState(() => slave1, true); assertSlaveState(() => slave1, true);
} }
@ -114,7 +114,7 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setSlaveTime(() => slave1, -MultiplayerSyncManager.SYNC_TARGET - 1); setSlaveTime(() => slave1, -MultiplayerCatchupSyncManager.SYNC_TARGET - 1);
// This is a silent catchup, where IsCatchingUp = false but IsRunning = false also. // This is a silent catchup, where IsCatchingUp = false but IsRunning = false also.
assertCatchingUp(() => slave1, false); assertCatchingUp(() => slave1, false);
@ -135,7 +135,7 @@ namespace osu.Game.Tests.OnlinePlay
assertSlaveState(() => slave1, false); assertSlaveState(() => slave1, false);
} }
private void setWaiting(Func<TestSlaveClock> slave, bool waiting) private void setWaiting(Func<TestSpectatorSlaveClock> slave, bool waiting)
=> AddStep($"set slave {slave().Id} waiting = {waiting}", () => slave().WaitingOnFrames.Value = waiting); => AddStep($"set slave {slave().Id} waiting = {waiting}", () => slave().WaitingOnFrames.Value = waiting);
private void setAllWaiting(bool waiting) => AddStep($"set all slaves waiting = {waiting}", () => private void setAllWaiting(bool waiting) => AddStep($"set all slaves waiting = {waiting}", () =>
@ -150,28 +150,28 @@ namespace osu.Game.Tests.OnlinePlay
/// <summary> /// <summary>
/// slave.Time = master.Time - offsetFromMaster /// slave.Time = master.Time - offsetFromMaster
/// </summary> /// </summary>
private void setSlaveTime(Func<TestSlaveClock> slave, double offsetFromMaster) private void setSlaveTime(Func<TestSpectatorSlaveClock> slave, double offsetFromMaster)
=> AddStep($"set slave {slave().Id} = master - {offsetFromMaster}", () => slave().Seek(master.CurrentTime - offsetFromMaster)); => AddStep($"set slave {slave().Id} = master - {offsetFromMaster}", () => slave().Seek(master.CurrentTime - offsetFromMaster));
private void assertMasterState(bool running) private void assertMasterState(bool running)
=> AddAssert($"master clock {(running ? "is" : "is not")} running", () => master.IsRunning == running); => AddAssert($"master clock {(running ? "is" : "is not")} running", () => master.IsRunning == running);
private void assertCatchingUp(Func<TestSlaveClock> slave, bool catchingUp) => private void assertCatchingUp(Func<TestSpectatorSlaveClock> slave, bool catchingUp) =>
AddAssert($"slave {slave().Id} {(catchingUp ? "is" : "is not")} catching up", () => slave().IsCatchingUp == catchingUp); AddAssert($"slave {slave().Id} {(catchingUp ? "is" : "is not")} catching up", () => slave().IsCatchingUp == catchingUp);
private void assertSlaveState(Func<TestSlaveClock> slave, bool running) private void assertSlaveState(Func<TestSpectatorSlaveClock> slave, bool running)
=> AddAssert($"slave {slave().Id} {(running ? "is" : "is not")} running", () => slave().IsRunning == running); => AddAssert($"slave {slave().Id} {(running ? "is" : "is not")} running", () => slave().IsRunning == running);
private class TestSlaveClock : TestManualClock, IMultiplayerSlaveClock private class TestSpectatorSlaveClock : TestManualClock, IMultiplayerSpectatorSlaveClock
{ {
public readonly Bindable<bool> WaitingOnFrames = new Bindable<bool>(true); public readonly Bindable<bool> WaitingOnFrames = new Bindable<bool>(true);
IBindable<bool> IMultiplayerSlaveClock.WaitingOnFrames => WaitingOnFrames; IBindable<bool> IMultiplayerSpectatorSlaveClock.WaitingOnFrames => WaitingOnFrames;
public bool IsCatchingUp { get; set; } public bool IsCatchingUp { get; set; }
public readonly int Id; public readonly int Id;
public TestSlaveClock(int id) public TestSpectatorSlaveClock(int id)
{ {
Id = id; Id = id;

View File

@ -6,7 +6,7 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
public interface IMultiplayerSlaveClock : IAdjustableClock public interface IMultiplayerSpectatorSlaveClock : IAdjustableClock
{ {
IBindable<bool> WaitingOnFrames { get; } IBindable<bool> WaitingOnFrames { get; }

View File

@ -5,12 +5,12 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
public interface IMultiplayerSyncManager public interface IMultiplayerSpectatorSyncManager
{ {
IAdjustableClock Master { get; } IAdjustableClock Master { get; }
void AddSlave(IMultiplayerSlaveClock clock); void AddSlave(IMultiplayerSpectatorSlaveClock clock);
void RemoveSlave(IMultiplayerSlaveClock clock); void RemoveSlave(IMultiplayerSpectatorSlaveClock clock);
} }
} }

View File

@ -9,7 +9,7 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
public class MultiplayerSyncManager : Component, IMultiplayerSyncManager public class MultiplayerCatchupSyncManager : Component, IMultiplayerSpectatorSyncManager
{ {
/// <summary> /// <summary>
/// The offset from the master clock to which slaves should be synchronised to. /// The offset from the master clock to which slaves should be synchronised to.
@ -34,19 +34,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// <summary> /// <summary>
/// The slave clocks. /// The slave clocks.
/// </summary> /// </summary>
private readonly List<IMultiplayerSlaveClock> slaves = new List<IMultiplayerSlaveClock>(); private readonly List<IMultiplayerSpectatorSlaveClock> slaves = new List<IMultiplayerSpectatorSlaveClock>();
private bool hasStarted; private bool hasStarted;
private double? firstStartAttemptTime; private double? firstStartAttemptTime;
public MultiplayerSyncManager(IAdjustableClock master) public MultiplayerCatchupSyncManager(IAdjustableClock master)
{ {
Master = master; Master = master;
} }
public void AddSlave(IMultiplayerSlaveClock clock) => slaves.Add(clock); public void AddSlave(IMultiplayerSpectatorSlaveClock clock) => slaves.Add(clock);
public void RemoveSlave(IMultiplayerSlaveClock clock) => slaves.Remove(clock); public void RemoveSlave(IMultiplayerSpectatorSlaveClock clock) => slaves.Remove(clock);
protected override void Update() protected override void Update()
{ {

View File

@ -24,7 +24,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
private readonly PlayerInstance[] instances; private readonly PlayerInstance[] instances;
private MasterGameplayClockContainer masterClockContainer; private MasterGameplayClockContainer masterClockContainer;
private IMultiplayerSyncManager syncManager; private IMultiplayerSpectatorSyncManager syncManager;
private PlayerGrid grid; private PlayerGrid grid;
private MultiplayerSpectatorLeaderboard leaderboard; private MultiplayerSpectatorLeaderboard leaderboard;
@ -65,7 +65,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
InternalChildren = new[] InternalChildren = new[]
{ {
(Drawable)(syncManager = new MultiplayerSyncManager(masterClockContainer)), (Drawable)(syncManager = new MultiplayerCatchupSyncManager(masterClockContainer)),
masterClockContainer masterClockContainer
}; };
@ -101,7 +101,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
leaderboard.RemoveClock(existingInstance.User.Id); leaderboard.RemoveClock(existingInstance.User.Id);
} }
LoadComponentAsync(instances[userIndex] = new PlayerInstance(gameplayState.Score, new MultiplayerSlaveClock(masterClockContainer.GameplayClock)), d => LoadComponentAsync(instances[userIndex] = new PlayerInstance(gameplayState.Score, new MultiplayerSpectatorSlaveClock(masterClockContainer.GameplayClock)), d =>
{ {
if (instances[userIndex] == d) if (instances[userIndex] == d)
{ {

View File

@ -11,9 +11,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
public class MultiplayerSpectatorPlayer : SpectatorPlayer public class MultiplayerSpectatorPlayer : SpectatorPlayer
{ {
private readonly MultiplayerSlaveClock gameplayClock; private readonly MultiplayerSpectatorSlaveClock gameplayClock;
public MultiplayerSpectatorPlayer(Score score, MultiplayerSlaveClock gameplayClock) public MultiplayerSpectatorPlayer(Score score, MultiplayerSpectatorSlaveClock gameplayClock)
: base(score) : base(score)
{ {
this.gameplayClock = gameplayClock; this.gameplayClock = gameplayClock;

View File

@ -7,7 +7,7 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
public class MultiplayerSlaveClock : IFrameBasedClock, IMultiplayerSlaveClock public class MultiplayerSpectatorSlaveClock : IFrameBasedClock, IMultiplayerSpectatorSlaveClock
{ {
/// <summary> /// <summary>
/// The catchup rate. /// The catchup rate.
@ -16,7 +16,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
private readonly IFrameBasedClock masterClock; private readonly IFrameBasedClock masterClock;
public MultiplayerSlaveClock(IFrameBasedClock masterClock) public MultiplayerSpectatorSlaveClock(IFrameBasedClock masterClock)
{ {
this.masterClock = masterClock; this.masterClock = masterClock;
} }

View File

@ -20,11 +20,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
public WorkingBeatmap Beatmap { get; private set; } public WorkingBeatmap Beatmap { get; private set; }
public readonly Score Score; public readonly Score Score;
public readonly MultiplayerSlaveClock GameplayClock; public readonly MultiplayerSpectatorSlaveClock GameplayClock;
private OsuScreenStack stack; private OsuScreenStack stack;
public PlayerInstance(Score score, MultiplayerSlaveClock gameplayClock) public PlayerInstance(Score score, MultiplayerSpectatorSlaveClock gameplayClock)
{ {
Score = score; Score = score;
GameplayClock = gameplayClock; GameplayClock = gameplayClock;