1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:47:46 +08:00

Rename classes to reduce redundant naming

This commit is contained in:
smoogipoo 2021-04-16 22:47:52 +09:00
parent 7d5d7088cd
commit 4c5d4752b1
8 changed files with 50 additions and 50 deletions

View File

@ -12,20 +12,20 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Tests.OnlinePlay namespace osu.Game.Tests.OnlinePlay
{ {
[HeadlessTest] [HeadlessTest]
public class MultiplayerCatchUpSyncManagerTest : OsuTestScene public class TestCaseCatchUpSyncManager : OsuTestScene
{ {
private TestManualClock master; private TestManualClock master;
private SpectatorCatchUpSyncManager syncManager; private CatchUpSyncManager syncManager;
private TestSpectatorSlaveClock slave1; private TestSlaveClock slave1;
private TestSpectatorSlaveClock slave2; private TestSlaveClock slave2;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
syncManager = new SpectatorCatchUpSyncManager(master = new TestManualClock()); syncManager = new CatchUpSyncManager(master = new TestManualClock());
syncManager.AddSlave(slave1 = new TestSpectatorSlaveClock(1)); syncManager.AddSlave(slave1 = new TestSlaveClock(1));
syncManager.AddSlave(slave2 = new TestSpectatorSlaveClock(2)); syncManager.AddSlave(slave2 = new TestSlaveClock(2));
Schedule(() => Child = syncManager); Schedule(() => Child = syncManager);
} }
@ -47,7 +47,7 @@ namespace osu.Game.Tests.OnlinePlay
[Test] [Test]
public void TestMasterClockDoesNotStartWhenNoneReadyForMaximumDelayTime() public void TestMasterClockDoesNotStartWhenNoneReadyForMaximumDelayTime()
{ {
AddWaitStep($"wait {SpectatorCatchUpSyncManager.MAXIMUM_START_DELAY} milliseconds", (int)Math.Ceiling(SpectatorCatchUpSyncManager.MAXIMUM_START_DELAY / TimePerAction)); AddWaitStep($"wait {CatchUpSyncManager.MAXIMUM_START_DELAY} milliseconds", (int)Math.Ceiling(CatchUpSyncManager.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 {SpectatorCatchUpSyncManager.MAXIMUM_START_DELAY} milliseconds", (int)Math.Ceiling(SpectatorCatchUpSyncManager.MAXIMUM_START_DELAY / TimePerAction)); AddWaitStep($"wait {CatchUpSyncManager.MAXIMUM_START_DELAY} milliseconds", (int)Math.Ceiling(CatchUpSyncManager.MAXIMUM_START_DELAY / TimePerAction));
assertMasterState(true); assertMasterState(true);
} }
@ -64,7 +64,7 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setMasterTime(SpectatorCatchUpSyncManager.SYNC_TARGET + 1); setMasterTime(CatchUpSyncManager.SYNC_TARGET + 1);
assertCatchingUp(() => slave1, false); assertCatchingUp(() => slave1, false);
} }
@ -73,7 +73,7 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setMasterTime(SpectatorCatchUpSyncManager.MAX_SYNC_OFFSET + 1); setMasterTime(CatchUpSyncManager.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(SpectatorCatchUpSyncManager.MAX_SYNC_OFFSET + 1); setMasterTime(CatchUpSyncManager.MAX_SYNC_OFFSET + 1);
setSlaveTime(() => slave1, SpectatorCatchUpSyncManager.SYNC_TARGET + 1); setSlaveTime(() => slave1, CatchUpSyncManager.SYNC_TARGET + 1);
assertCatchingUp(() => slave1, true); assertCatchingUp(() => slave1, true);
} }
@ -93,8 +93,8 @@ namespace osu.Game.Tests.OnlinePlay
{ {
setAllWaiting(false); setAllWaiting(false);
setMasterTime(SpectatorCatchUpSyncManager.MAX_SYNC_OFFSET + 2); setMasterTime(CatchUpSyncManager.MAX_SYNC_OFFSET + 2);
setSlaveTime(() => slave1, SpectatorCatchUpSyncManager.SYNC_TARGET); setSlaveTime(() => slave1, CatchUpSyncManager.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, -SpectatorCatchUpSyncManager.SYNC_TARGET); setSlaveTime(() => slave1, -CatchUpSyncManager.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, -SpectatorCatchUpSyncManager.SYNC_TARGET - 1); setSlaveTime(() => slave1, -CatchUpSyncManager.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<TestSpectatorSlaveClock> slave, bool waiting) private void setWaiting(Func<TestSlaveClock> 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<TestSpectatorSlaveClock> slave, double offsetFromMaster) private void setSlaveTime(Func<TestSlaveClock> 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<TestSpectatorSlaveClock> slave, bool catchingUp) => private void assertCatchingUp(Func<TestSlaveClock> 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<TestSpectatorSlaveClock> slave, bool running) private void assertSlaveState(Func<TestSlaveClock> 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 TestSpectatorSlaveClock : TestManualClock, ISpectatorSlaveClock private class TestSlaveClock : TestManualClock, ISlaveClock
{ {
public readonly Bindable<bool> WaitingOnFrames = new Bindable<bool>(true); public readonly Bindable<bool> WaitingOnFrames = new Bindable<bool>(true);
IBindable<bool> ISpectatorSlaveClock.WaitingOnFrames => WaitingOnFrames; IBindable<bool> ISlaveClock.WaitingOnFrames => WaitingOnFrames;
public bool IsCatchingUp { get; set; } public bool IsCatchingUp { get; set; }
public readonly int Id; public readonly int Id;
public TestSpectatorSlaveClock(int id) public TestSlaveClock(int id)
{ {
Id = id; Id = id;

View File

@ -25,7 +25,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
private readonly PlayerInstance[] instances; private readonly PlayerInstance[] instances;
private MasterGameplayClockContainer masterClockContainer; private MasterGameplayClockContainer masterClockContainer;
private ISpectatorSyncManager syncManager; private ISyncManager syncManager;
private PlayerGrid grid; private PlayerGrid grid;
private MultiplayerSpectatorLeaderboard leaderboard; private MultiplayerSpectatorLeaderboard leaderboard;
@ -66,12 +66,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
InternalChildren = new[] InternalChildren = new[]
{ {
(Drawable)(syncManager = new SpectatorCatchUpSyncManager(masterClockContainer)), (Drawable)(syncManager = new CatchUpSyncManager(masterClockContainer)),
masterClockContainer masterClockContainer
}; };
for (int i = 0; i < UserIds.Length; i++) for (int i = 0; i < UserIds.Length; i++)
grid.Add(instances[i] = new PlayerInstance(UserIds[i], new SpectatorCatchUpSlaveClock(masterClockContainer.GameplayClock))); grid.Add(instances[i] = new PlayerInstance(UserIds[i], new CatchUpSlaveClock(masterClockContainer.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);

View File

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

View File

@ -18,7 +18,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
public bool PlayerLoaded => stack?.CurrentScreen is Player; public bool PlayerLoaded => stack?.CurrentScreen is Player;
public readonly int UserId; public readonly int UserId;
public readonly SpectatorCatchUpSlaveClock GameplayClock; public readonly CatchUpSlaveClock GameplayClock;
public Score Score { get; private set; } public Score Score { get; private set; }
@ -29,7 +29,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
private readonly LoadingLayer loadingLayer; private readonly LoadingLayer loadingLayer;
private OsuScreenStack stack; private OsuScreenStack stack;
public PlayerInstance(int userId, SpectatorCatchUpSlaveClock gameplayClock) public PlayerInstance(int userId, CatchUpSlaveClock gameplayClock)
{ {
UserId = userId; UserId = userId;
GameplayClock = gameplayClock; GameplayClock = gameplayClock;

View File

@ -8,9 +8,9 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
{ {
/// <summary> /// <summary>
/// A <see cref="ISpectatorSlaveClock"/> which catches up using rate adjustment. /// A <see cref="ISlaveClock"/> which catches up using rate adjustment.
/// </summary> /// </summary>
public class SpectatorCatchUpSlaveClock : ISpectatorSlaveClock public class CatchUpSlaveClock : ISlaveClock
{ {
/// <summary> /// <summary>
/// The catch up rate. /// The catch up rate.
@ -19,7 +19,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
private readonly IFrameBasedClock masterClock; private readonly IFrameBasedClock masterClock;
public SpectatorCatchUpSlaveClock(IFrameBasedClock masterClock) public CatchUpSlaveClock(IFrameBasedClock masterClock)
{ {
this.masterClock = masterClock; this.masterClock = masterClock;
} }

View File

@ -10,9 +10,9 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
{ {
/// <summary> /// <summary>
/// A <see cref="ISpectatorSyncManager"/> which synchronises de-synced slave clocks through catchup. /// A <see cref="ISyncManager"/> which synchronises de-synced slave clocks through catchup.
/// </summary> /// </summary>
public class SpectatorCatchUpSyncManager : Component, ISpectatorSyncManager public class CatchUpSyncManager : Component, ISyncManager
{ {
/// <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.
@ -37,19 +37,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
/// <summary> /// <summary>
/// The slave clocks. /// The slave clocks.
/// </summary> /// </summary>
private readonly List<ISpectatorSlaveClock> slaves = new List<ISpectatorSlaveClock>(); private readonly List<ISlaveClock> slaves = new List<ISlaveClock>();
private bool hasStarted; private bool hasStarted;
private double? firstStartAttemptTime; private double? firstStartAttemptTime;
public SpectatorCatchUpSyncManager(IAdjustableClock master) public CatchUpSyncManager(IAdjustableClock master)
{ {
Master = master; Master = master;
} }
public void AddSlave(ISpectatorSlaveClock clock) => slaves.Add(clock); public void AddSlave(ISlaveClock clock) => slaves.Add(clock);
public void RemoveSlave(ISpectatorSlaveClock clock) => slaves.Remove(clock); public void RemoveSlave(ISlaveClock clock) => slaves.Remove(clock);
protected override void Update() protected override void Update()
{ {

View File

@ -7,9 +7,9 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
{ {
/// <summary> /// <summary>
/// A clock which is used by <see cref="MultiplayerSpectatorPlayer"/>s and managed by an <see cref="ISpectatorSyncManager"/>. /// A clock which is used by <see cref="MultiplayerSpectatorPlayer"/>s and managed by an <see cref="ISyncManager"/>.
/// </summary> /// </summary>
public interface ISpectatorSlaveClock : IFrameBasedClock, IAdjustableClock public interface ISlaveClock : IFrameBasedClock, IAdjustableClock
{ {
/// <summary> /// <summary>
/// Whether this clock is waiting on frames to continue playback. /// Whether this clock is waiting on frames to continue playback.

View File

@ -6,9 +6,9 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
{ {
/// <summary> /// <summary>
/// Manages the synchronisation between one or more <see cref="ISpectatorSlaveClock"/>s in relation to a master clock. /// Manages the synchronisation between one or more <see cref="ISlaveClock"/>s in relation to a master clock.
/// </summary> /// </summary>
public interface ISpectatorSyncManager public interface ISyncManager
{ {
/// <summary> /// <summary>
/// The master clock which slaves should synchronise to. /// The master clock which slaves should synchronise to.
@ -16,15 +16,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync
IAdjustableClock Master { get; } IAdjustableClock Master { get; }
/// <summary> /// <summary>
/// Adds an <see cref="ISpectatorSlaveClock"/> to manage. /// Adds an <see cref="ISlaveClock"/> to manage.
/// </summary> /// </summary>
/// <param name="clock">The <see cref="ISpectatorSlaveClock"/> to add.</param> /// <param name="clock">The <see cref="ISlaveClock"/> to add.</param>
void AddSlave(ISpectatorSlaveClock clock); void AddSlave(ISlaveClock clock);
/// <summary> /// <summary>
/// Removes an <see cref="ISpectatorSlaveClock"/>, stopping it from being managed by this <see cref="ISpectatorSyncManager"/>. /// Removes an <see cref="ISlaveClock"/>, stopping it from being managed by this <see cref="ISyncManager"/>.
/// </summary> /// </summary>
/// <param name="clock">The <see cref="ISpectatorSlaveClock"/> to remove.</param> /// <param name="clock">The <see cref="ISlaveClock"/> to remove.</param>
void RemoveSlave(ISpectatorSlaveClock clock); void RemoveSlave(ISlaveClock clock);
} }
} }