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

Unify namings across the board

This commit is contained in:
Dan Balasescu 2022-02-09 12:09:04 +09:00
parent 4966c4e974
commit ffc4c64f7e
9 changed files with 41 additions and 41 deletions

View File

@ -157,7 +157,7 @@ namespace osu.Game.Tests.Visual.Gameplay
checkPaused(true); checkPaused(true);
sendFrames(); sendFrames();
finish(SpectatingUserState.Failed); finish(SpectatedUserState.Failed);
checkPaused(false); // Should continue playing until out of frames checkPaused(false); // Should continue playing until out of frames
checkPaused(true); // And eventually stop after running out of frames and fail. checkPaused(true); // And eventually stop after running out of frames and fail.
@ -244,7 +244,7 @@ namespace osu.Game.Tests.Visual.Gameplay
start(); start();
sendFrames(); sendFrames();
waitForPlayer(); waitForPlayer();
AddUntilStep("state is playing", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Playing); AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
} }
[Test] [Test]
@ -256,13 +256,13 @@ namespace osu.Game.Tests.Visual.Gameplay
sendFrames(); sendFrames();
waitForPlayer(); waitForPlayer();
AddStep("send passed", () => spectatorClient.EndPlay(streamingUser.Id, SpectatingUserState.Passed)); AddStep("send passed", () => spectatorClient.EndPlay(streamingUser.Id, SpectatedUserState.Passed));
AddUntilStep("state is passed", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Passed); AddUntilStep("state is passed", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Passed);
start(); start();
sendFrames(); sendFrames();
waitForPlayer(); waitForPlayer();
AddUntilStep("state is playing", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Playing); AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
} }
[Test] [Test]
@ -275,12 +275,12 @@ namespace osu.Game.Tests.Visual.Gameplay
waitForPlayer(); waitForPlayer();
AddStep("send quit", () => spectatorClient.EndPlay(streamingUser.Id)); AddStep("send quit", () => spectatorClient.EndPlay(streamingUser.Id));
AddUntilStep("state is quit", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Quit); AddUntilStep("state is quit", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Quit);
start(); start();
sendFrames(); sendFrames();
waitForPlayer(); waitForPlayer();
AddUntilStep("state is playing", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Playing); AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
} }
[Test] [Test]
@ -292,13 +292,13 @@ namespace osu.Game.Tests.Visual.Gameplay
sendFrames(); sendFrames();
waitForPlayer(); waitForPlayer();
AddStep("send failed", () => spectatorClient.EndPlay(streamingUser.Id, SpectatingUserState.Failed)); AddStep("send failed", () => spectatorClient.EndPlay(streamingUser.Id, SpectatedUserState.Failed));
AddUntilStep("state is failed", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Failed); AddUntilStep("state is failed", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Failed);
start(); start();
sendFrames(); sendFrames();
waitForPlayer(); waitForPlayer();
AddUntilStep("state is playing", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Playing); AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
} }
private OsuFramedReplayInputHandler replayHandler => private OsuFramedReplayInputHandler replayHandler =>
@ -313,7 +313,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void start(int? beatmapId = null) => AddStep("start play", () => spectatorClient.StartPlay(streamingUser.Id, beatmapId ?? importedBeatmapId)); private void start(int? beatmapId = null) => AddStep("start play", () => spectatorClient.StartPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
private void finish(SpectatingUserState state = SpectatingUserState.Quit) => AddStep("end play", () => spectatorClient.EndPlay(streamingUser.Id, state)); private void finish(SpectatedUserState state = SpectatedUserState.Quit) => AddStep("end play", () => spectatorClient.EndPlay(streamingUser.Id, state));
private void checkPaused(bool state) => private void checkPaused(bool state) =>
AddUntilStep($"game is {(state ? "paused" : "playing")}", () => player.ChildrenOfType<DrawableRuleset>().First().IsPaused.Value == state); AddUntilStep($"game is {(state ? "paused" : "playing")}", () => player.ChildrenOfType<DrawableRuleset>().First().IsPaused.Value == state);

View File

@ -37,8 +37,8 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestClientSendsCorrectRuleset() public void TestClientSendsCorrectRuleset()
{ {
AddUntilStep("spectator client sending frames", () => spectatorClient.WatchingUserStates.ContainsKey(dummy_user_id)); AddUntilStep("spectator client sending frames", () => spectatorClient.WatchedUserStates.ContainsKey(dummy_user_id));
AddAssert("spectator client sent correct ruleset", () => spectatorClient.WatchingUserStates[dummy_user_id].RulesetID == Ruleset.Value.OnlineID); AddAssert("spectator client sent correct ruleset", () => spectatorClient.WatchedUserStates[dummy_user_id].RulesetID == Ruleset.Value.OnlineID);
} }
public override void TearDownSteps() public override void TearDownSteps()

View File

@ -115,7 +115,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void RandomlyUpdateState() public void RandomlyUpdateState()
{ {
foreach ((int userId, _) in WatchingUserStates) foreach ((int userId, _) in WatchedUserStates)
{ {
if (RNG.NextBool()) if (RNG.NextBool())
continue; continue;

View File

@ -3,7 +3,7 @@
namespace osu.Game.Online.Spectator namespace osu.Game.Online.Spectator
{ {
public enum SpectatingUserState public enum SpectatedUserState
{ {
/// <summary> /// <summary>
/// The spectated user is not yet playing. /// The spectated user is not yet playing.
@ -26,7 +26,7 @@ namespace osu.Game.Online.Spectator
Passed, Passed,
/// <summary> /// <summary>
/// The spectator user has failed gameplay. /// The spectated user has failed gameplay.
/// </summary> /// </summary>
Failed, Failed,

View File

@ -38,7 +38,7 @@ namespace osu.Game.Online.Spectator
/// <summary> /// <summary>
/// The states of all users currently being watched. /// The states of all users currently being watched.
/// </summary> /// </summary>
public IBindableDictionary<int, SpectatorState> WatchingUserStates => watchingUserStates; public IBindableDictionary<int, SpectatorState> WatchedUserStates => watchedUserStates;
/// <summary> /// <summary>
/// A global list of all players currently playing. /// A global list of all players currently playing.
@ -48,9 +48,9 @@ namespace osu.Game.Online.Spectator
/// <summary> /// <summary>
/// All users currently being watched. /// All users currently being watched.
/// </summary> /// </summary>
private readonly List<int> watchingUsers = new List<int>(); private readonly List<int> watchedUsers = new List<int>();
private readonly BindableDictionary<int, SpectatorState> watchingUserStates = new BindableDictionary<int, SpectatorState>(); private readonly BindableDictionary<int, SpectatorState> watchedUserStates = new BindableDictionary<int, SpectatorState>();
private readonly BindableList<int> playingUsers = new BindableList<int>(); private readonly BindableList<int> playingUsers = new BindableList<int>();
private readonly SpectatorState currentState = new SpectatorState(); private readonly SpectatorState currentState = new SpectatorState();
@ -85,8 +85,8 @@ namespace osu.Game.Online.Spectator
if (connected.NewValue) if (connected.NewValue)
{ {
// get all the users that were previously being watched // get all the users that were previously being watched
int[] users = watchingUsers.ToArray(); int[] users = watchedUsers.ToArray();
watchingUsers.Clear(); watchedUsers.Clear();
// resubscribe to watched users. // resubscribe to watched users.
foreach (int userId in users) foreach (int userId in users)
@ -99,7 +99,7 @@ namespace osu.Game.Online.Spectator
else else
{ {
playingUsers.Clear(); playingUsers.Clear();
watchingUserStates.Clear(); watchedUserStates.Clear();
} }
}), true); }), true);
} }
@ -111,8 +111,8 @@ namespace osu.Game.Online.Spectator
if (!playingUsers.Contains(userId)) if (!playingUsers.Contains(userId))
playingUsers.Add(userId); playingUsers.Add(userId);
if (watchingUsers.Contains(userId)) if (watchedUsers.Contains(userId))
watchingUserStates[userId] = state; watchedUserStates[userId] = state;
OnUserBeganPlaying?.Invoke(userId, state); OnUserBeganPlaying?.Invoke(userId, state);
}); });
@ -126,8 +126,8 @@ namespace osu.Game.Online.Spectator
{ {
playingUsers.Remove(userId); playingUsers.Remove(userId);
if (watchingUsers.Contains(userId)) if (watchedUsers.Contains(userId))
watchingUserStates[userId] = state; watchedUserStates[userId] = state;
OnUserFinishedPlaying?.Invoke(userId, state); OnUserFinishedPlaying?.Invoke(userId, state);
}); });
@ -159,7 +159,7 @@ namespace osu.Game.Online.Spectator
currentState.BeatmapID = score.ScoreInfo.BeatmapInfo.OnlineID; currentState.BeatmapID = score.ScoreInfo.BeatmapInfo.OnlineID;
currentState.RulesetID = score.ScoreInfo.RulesetID; currentState.RulesetID = score.ScoreInfo.RulesetID;
currentState.Mods = score.ScoreInfo.Mods.Select(m => new APIMod(m)).ToArray(); currentState.Mods = score.ScoreInfo.Mods.Select(m => new APIMod(m)).ToArray();
currentState.State = SpectatingUserState.Playing; currentState.State = SpectatedUserState.Playing;
currentBeatmap = state.Beatmap; currentBeatmap = state.Beatmap;
currentScore = score; currentScore = score;
@ -186,11 +186,11 @@ namespace osu.Game.Online.Spectator
currentBeatmap = null; currentBeatmap = null;
if (state.HasPassed) if (state.HasPassed)
currentState.State = SpectatingUserState.Passed; currentState.State = SpectatedUserState.Passed;
else if (state.HasFailed) else if (state.HasFailed)
currentState.State = SpectatingUserState.Failed; currentState.State = SpectatedUserState.Failed;
else else
currentState.State = SpectatingUserState.Quit; currentState.State = SpectatedUserState.Quit;
EndPlayingInternal(currentState); EndPlayingInternal(currentState);
}); });
@ -200,10 +200,10 @@ namespace osu.Game.Online.Spectator
{ {
Debug.Assert(ThreadSafety.IsUpdateThread); Debug.Assert(ThreadSafety.IsUpdateThread);
if (watchingUsers.Contains(userId)) if (watchedUsers.Contains(userId))
return; return;
watchingUsers.Add(userId); watchedUsers.Add(userId);
WatchUserInternal(userId); WatchUserInternal(userId);
} }
@ -214,8 +214,8 @@ namespace osu.Game.Online.Spectator
// Todo: This should not be a thing, but requires framework changes. // Todo: This should not be a thing, but requires framework changes.
Schedule(() => Schedule(() =>
{ {
watchingUsers.Remove(userId); watchedUsers.Remove(userId);
watchingUserStates.Remove(userId); watchedUserStates.Remove(userId);
StopWatchingUserInternal(userId); StopWatchingUserInternal(userId);
}); });
} }

View File

@ -25,7 +25,7 @@ namespace osu.Game.Online.Spectator
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>(); public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
[Key(3)] [Key(3)]
public SpectatingUserState State { get; set; } public SpectatedUserState State { get; set; }
public bool Equals(SpectatorState other) public bool Equals(SpectatorState other)
{ {

View File

@ -218,7 +218,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{ {
// Allowed passed/failed users to complete their remaining replay frames. // Allowed passed/failed users to complete their remaining replay frames.
// The failed state isn't really possible in multiplayer (yet?) but is added here just for safety in case it starts being used. // The failed state isn't really possible in multiplayer (yet?) but is added here just for safety in case it starts being used.
if (state.State == SpectatingUserState.Passed || state.State == SpectatingUserState.Failed) if (state.State == SpectatedUserState.Passed || state.State == SpectatedUserState.Failed)
return; return;
RemoveUser(userId); RemoveUser(userId);

View File

@ -77,7 +77,7 @@ namespace osu.Game.Screens.Spectate
userMap[u.Id] = u; userMap[u.Id] = u;
} }
userStates.BindTo(spectatorClient.WatchingUserStates); userStates.BindTo(spectatorClient.WatchedUserStates);
userStates.BindCollectionChanged(onUserStatesChanged, true); userStates.BindCollectionChanged(onUserStatesChanged, true);
realmSubscription = realm.RegisterForNotifications( realmSubscription = realm.RegisterForNotifications(
@ -134,13 +134,13 @@ namespace osu.Game.Screens.Spectate
switch (newState.State) switch (newState.State)
{ {
case SpectatingUserState.Passed: case SpectatedUserState.Passed:
// Make sure that gameplay completes to the end. // Make sure that gameplay completes to the end.
if (gameplayStates.TryGetValue(userId, out var gameplayState)) if (gameplayStates.TryGetValue(userId, out var gameplayState))
gameplayState.Score.Replay.HasReceivedAllFrames = true; gameplayState.Score.Replay.HasReceivedAllFrames = true;
break; break;
case SpectatingUserState.Playing: case SpectatedUserState.Playing:
Schedule(() => OnUserStateChanged(userId, newState)); Schedule(() => OnUserStateChanged(userId, newState));
updateGameplayState(userId); updateGameplayState(userId);
break; break;

View File

@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual.Spectator
/// </summary> /// </summary>
/// <param name="userId">The user to end play for.</param> /// <param name="userId">The user to end play for.</param>
/// <param name="state">The spectator state to end play with.</param> /// <param name="state">The spectator state to end play with.</param>
public void EndPlay(int userId, SpectatingUserState state = SpectatingUserState.Quit) public void EndPlay(int userId, SpectatedUserState state = SpectatedUserState.Quit)
{ {
if (!userBeatmapDictionary.ContainsKey(userId)) if (!userBeatmapDictionary.ContainsKey(userId))
return; return;
@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual.Spectator
{ {
BeatmapID = userBeatmapDictionary[userId], BeatmapID = userBeatmapDictionary[userId],
RulesetID = 0, RulesetID = 0,
State = SpectatingUserState.Playing State = SpectatedUserState.Playing
}); });
} }
} }