mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Apply NRT to SpectatorScreen
This commit is contained in:
parent
537b0ae870
commit
4c7d2bb0fb
@ -1,13 +1,10 @@
|
|||||||
// 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 disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
@ -33,22 +30,27 @@ namespace osu.Game.Screens.Spectate
|
|||||||
private readonly List<int> users = new List<int>();
|
private readonly List<int> users = new List<int>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesets { get; set; }
|
private RulesetStore rulesets { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorClient spectatorClient { get; set; }
|
private SpectatorClient spectatorClient { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private UserLookupCache userLookupCache { get; set; }
|
private UserLookupCache userLookupCache { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RealmAccess realm { get; set; } = null!;
|
||||||
|
|
||||||
private readonly IBindableDictionary<int, SpectatorState> userStates = new BindableDictionary<int, SpectatorState>();
|
private readonly IBindableDictionary<int, SpectatorState> userStates = new BindableDictionary<int, SpectatorState>();
|
||||||
|
|
||||||
private readonly Dictionary<int, APIUser> userMap = new Dictionary<int, APIUser>();
|
private readonly Dictionary<int, APIUser> userMap = new Dictionary<int, APIUser>();
|
||||||
private readonly Dictionary<int, SpectatorGameplayState> gameplayStates = new Dictionary<int, SpectatorGameplayState>();
|
private readonly Dictionary<int, SpectatorGameplayState> gameplayStates = new Dictionary<int, SpectatorGameplayState>();
|
||||||
|
|
||||||
|
private IDisposable? realmSubscription;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="SpectatorScreen"/>.
|
/// Creates a new <see cref="SpectatorScreen"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -58,11 +60,6 @@ namespace osu.Game.Screens.Spectate
|
|||||||
this.users.AddRange(users);
|
this.users.AddRange(users);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private RealmAccess realm { get; set; }
|
|
||||||
|
|
||||||
private IDisposable realmSubscription;
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -90,7 +87,7 @@ namespace osu.Game.Screens.Spectate
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void beatmapsChanged(IRealmCollection<BeatmapSetInfo> items, ChangeSet changes)
|
private void beatmapsChanged(IRealmCollection<BeatmapSetInfo> items, ChangeSet? changes)
|
||||||
{
|
{
|
||||||
if (changes?.InsertedIndices == null) return;
|
if (changes?.InsertedIndices == null) return;
|
||||||
|
|
||||||
@ -109,7 +106,7 @@ namespace osu.Game.Screens.Spectate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUserStatesChanged(object sender, NotifyDictionaryChangedEventArgs<int, SpectatorState> e)
|
private void onUserStatesChanged(object? sender, NotifyDictionaryChangedEventArgs<int, SpectatorState> e)
|
||||||
{
|
{
|
||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
@ -207,14 +204,14 @@ namespace osu.Game.Screens.Spectate
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">The user whose state has changed.</param>
|
/// <param name="userId">The user whose state has changed.</param>
|
||||||
/// <param name="spectatorState">The new state.</param>
|
/// <param name="spectatorState">The new state.</param>
|
||||||
protected abstract void OnNewPlayingUserState(int userId, [NotNull] SpectatorState spectatorState);
|
protected abstract void OnNewPlayingUserState(int userId, SpectatorState spectatorState);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts gameplay for a user.
|
/// Starts gameplay for a user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">The user to start gameplay for.</param>
|
/// <param name="userId">The user to start gameplay for.</param>
|
||||||
/// <param name="spectatorGameplayState">The gameplay state.</param>
|
/// <param name="spectatorGameplayState">The gameplay state.</param>
|
||||||
protected abstract void StartGameplay(int userId, [NotNull] SpectatorGameplayState spectatorGameplayState);
|
protected abstract void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Quits gameplay for a user.
|
/// Quits gameplay for a user.
|
||||||
@ -243,7 +240,7 @@ namespace osu.Game.Screens.Spectate
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (spectatorClient != null)
|
if (spectatorClient.IsNotNull())
|
||||||
{
|
{
|
||||||
foreach ((int userId, var _) in userMap)
|
foreach ((int userId, var _) in userMap)
|
||||||
spectatorClient.StopWatchingUser(userId);
|
spectatorClient.StopWatchingUser(userId);
|
||||||
|
Loading…
Reference in New Issue
Block a user