1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 09:23:06 +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);
sendFrames();
finish(SpectatingUserState.Failed);
finish(SpectatedUserState.Failed);
checkPaused(false); // Should continue playing until out of frames
checkPaused(true); // And eventually stop after running out of frames and fail.
@ -244,7 +244,7 @@ namespace osu.Game.Tests.Visual.Gameplay
start();
sendFrames();
waitForPlayer();
AddUntilStep("state is playing", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Playing);
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
}
[Test]
@ -256,13 +256,13 @@ namespace osu.Game.Tests.Visual.Gameplay
sendFrames();
waitForPlayer();
AddStep("send passed", () => spectatorClient.EndPlay(streamingUser.Id, SpectatingUserState.Passed));
AddUntilStep("state is passed", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Passed);
AddStep("send passed", () => spectatorClient.EndPlay(streamingUser.Id, SpectatedUserState.Passed));
AddUntilStep("state is passed", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Passed);
start();
sendFrames();
waitForPlayer();
AddUntilStep("state is playing", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Playing);
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
}
[Test]
@ -275,12 +275,12 @@ namespace osu.Game.Tests.Visual.Gameplay
waitForPlayer();
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();
sendFrames();
waitForPlayer();
AddUntilStep("state is playing", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Playing);
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
}
[Test]
@ -292,13 +292,13 @@ namespace osu.Game.Tests.Visual.Gameplay
sendFrames();
waitForPlayer();
AddStep("send failed", () => spectatorClient.EndPlay(streamingUser.Id, SpectatingUserState.Failed));
AddUntilStep("state is failed", () => spectatorClient.WatchingUserStates[streamingUser.Id].State == SpectatingUserState.Failed);
AddStep("send failed", () => spectatorClient.EndPlay(streamingUser.Id, SpectatedUserState.Failed));
AddUntilStep("state is failed", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Failed);
start();
sendFrames();
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 =>
@ -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 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) =>
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]
public void TestClientSendsCorrectRuleset()
{
AddUntilStep("spectator client sending frames", () => spectatorClient.WatchingUserStates.ContainsKey(dummy_user_id));
AddAssert("spectator client sent correct ruleset", () => spectatorClient.WatchingUserStates[dummy_user_id].RulesetID == Ruleset.Value.OnlineID);
AddUntilStep("spectator client sending frames", () => spectatorClient.WatchedUserStates.ContainsKey(dummy_user_id));
AddAssert("spectator client sent correct ruleset", () => spectatorClient.WatchedUserStates[dummy_user_id].RulesetID == Ruleset.Value.OnlineID);
}
public override void TearDownSteps()

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ namespace osu.Game.Online.Spectator
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
[Key(3)]
public SpectatingUserState State { get; set; }
public SpectatedUserState State { get; set; }
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.
// 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;
RemoveUser(userId);

View File

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

View File

@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual.Spectator
/// </summary>
/// <param name="userId">The user to end play for.</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))
return;
@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual.Spectator
{
BeatmapID = userBeatmapDictionary[userId],
RulesetID = 0,
State = SpectatingUserState.Playing
State = SpectatedUserState.Playing
});
}
}