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

Apply nullability annotations to ResultsScreen & inheritors

This commit is contained in:
Bartłomiej Dach 2024-04-25 09:52:26 +02:00
parent 6905257869
commit da953b34a7
No known key found for this signature in database
6 changed files with 43 additions and 54 deletions

View File

@ -424,7 +424,7 @@ namespace osu.Game.Tests.Visual.Ranking
scores.Add(score);
}
scoresCallback?.Invoke(scores);
scoresCallback.Invoke(scores);
return null;
}

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
@ -28,8 +26,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
private readonly SortedDictionary<int, BindableLong> teamScores;
private Container winnerBackground;
private Drawable winnerText;
private Container winnerBackground = null!;
private Drawable winnerText = null!;
public MultiplayerTeamResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem, SortedDictionary<int, BindableLong> teamScores)
: base(score, roomId, playlistItem)
@ -41,7 +39,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
}
[Resolved]
private OsuColour colours { get; set; }
private OsuColour colours { get; set; } = null!;
[BackgroundDependencyLoader]
private void load()

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using osu.Game.Online.API;
@ -25,8 +23,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
Scheduler.AddDelayed(() => StatisticsPanel.ToggleVisibility(), 1000);
}
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
protected override APIRequest? FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
protected override APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
protected override APIRequest? FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
}
}

View File

@ -1,13 +1,10 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -25,23 +22,23 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
private readonly long roomId;
private readonly PlaylistItem playlistItem;
protected LoadingSpinner LeftSpinner { get; private set; }
protected LoadingSpinner CentreSpinner { get; private set; }
protected LoadingSpinner RightSpinner { get; private set; }
protected LoadingSpinner LeftSpinner { get; private set; } = null!;
protected LoadingSpinner CentreSpinner { get; private set; } = null!;
protected LoadingSpinner RightSpinner { get; private set; } = null!;
private MultiplayerScores higherScores;
private MultiplayerScores lowerScores;
private MultiplayerScores? higherScores;
private MultiplayerScores? lowerScores;
[Resolved]
private IAPIProvider api { get; set; }
private IAPIProvider api { get; set; } = null!;
[Resolved]
private ScoreManager scoreManager { get; set; }
private ScoreManager scoreManager { get; set; } = null!;
[Resolved]
private RulesetStore rulesets { get; set; }
private RulesetStore rulesets { get; set; } = null!;
public PlaylistsResultsScreen([CanBeNull] ScoreInfo score, long roomId, PlaylistItem playlistItem)
public PlaylistsResultsScreen(ScoreInfo? score, long roomId, PlaylistItem playlistItem)
: base(score)
{
this.roomId = roomId;
@ -123,11 +120,11 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
return userScoreReq;
}
protected override APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback)
protected override APIRequest? FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback)
{
Debug.Assert(direction == 1 || direction == -1);
MultiplayerScores pivot = direction == -1 ? higherScores : lowerScores;
MultiplayerScores? pivot = direction == -1 ? higherScores : lowerScores;
if (pivot?.Cursor == null)
return null;
@ -147,7 +144,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
/// <param name="scoresCallback">The callback to perform with the resulting scores.</param>
/// <param name="pivot">An optional score pivot to retrieve scores around. Can be null to retrieve scores from the highest score.</param>
/// <returns>The indexing <see cref="APIRequest"/>.</returns>
private APIRequest createIndexRequest(Action<IEnumerable<ScoreInfo>> scoresCallback, [CanBeNull] MultiplayerScores pivot = null)
private APIRequest createIndexRequest(Action<IEnumerable<ScoreInfo>> scoresCallback, MultiplayerScores? pivot = null)
{
var indexReq = pivot != null
? new IndexPlaylistScoresRequest(roomId, playlistItem.ID, pivot.Cursor, pivot.Params)
@ -180,7 +177,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
/// <param name="callback">The callback to invoke with the final <see cref="ScoreInfo"/>s.</param>
/// <param name="scores">The <see cref="MultiplayerScore"/>s that were retrieved from <see cref="APIRequest"/>s.</param>
/// <param name="pivot">An optional pivot around which the scores were retrieved.</param>
private void performSuccessCallback([NotNull] Action<IEnumerable<ScoreInfo>> callback, [NotNull] List<MultiplayerScore> scores, [CanBeNull] MultiplayerScores pivot = null) => Schedule(() =>
private void performSuccessCallback(Action<IEnumerable<ScoreInfo>> callback, List<MultiplayerScore> scores, MultiplayerScores? pivot = null) => Schedule(() =>
{
var scoreInfos = scores.Select(s => s.CreateScoreInfo(scoreManager, rulesets, playlistItem, Beatmap.Value.BeatmapInfo)).OrderByTotalScore().ToArray();
@ -201,7 +198,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
hideLoadingSpinners(pivot);
});
private void hideLoadingSpinners([CanBeNull] MultiplayerScores pivot = null)
private void hideLoadingSpinners(MultiplayerScores? pivot = null)
{
CentreSpinner.Hide();
@ -217,7 +214,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
/// <param name="scores">The <see cref="MultiplayerScores"/> to set positions on.</param>
/// <param name="pivot">The pivot.</param>
/// <param name="increment">The amount to increment the pivot position by for each <see cref="MultiplayerScore"/> in <paramref name="scores"/>.</param>
private void setPositions([NotNull] MultiplayerScores scores, [CanBeNull] MultiplayerScores pivot, int increment)
private void setPositions(MultiplayerScores scores, MultiplayerScores? pivot, int increment)
=> setPositions(scores, pivot?.Scores[^1].Position ?? 0, increment);
/// <summary>
@ -226,7 +223,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
/// <param name="scores">The <see cref="MultiplayerScores"/> to set positions on.</param>
/// <param name="pivotPosition">The pivot position.</param>
/// <param name="increment">The amount to increment the pivot position by for each <see cref="MultiplayerScore"/> in <paramref name="scores"/>.</param>
private void setPositions([NotNull] MultiplayerScores scores, int pivotPosition, int increment)
private void setPositions(MultiplayerScores scores, int pivotPosition, int increment)
{
foreach (var s in scores.Scores)
{

View File

@ -1,12 +1,9 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -45,25 +42,24 @@ namespace osu.Game.Screens.Ranking
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered;
public readonly Bindable<ScoreInfo> SelectedScore = new Bindable<ScoreInfo>();
public readonly Bindable<ScoreInfo?> SelectedScore = new Bindable<ScoreInfo?>();
[CanBeNull]
public readonly ScoreInfo Score;
public readonly ScoreInfo? Score;
protected ScorePanelList ScorePanelList { get; private set; }
protected ScorePanelList ScorePanelList { get; private set; } = null!;
protected VerticalScrollContainer VerticalScrollContent { get; private set; }
[Resolved(CanBeNull = true)]
private Player player { get; set; }
protected VerticalScrollContainer VerticalScrollContent { get; private set; } = null!;
[Resolved]
private IAPIProvider api { get; set; }
private Player? player { get; set; }
protected StatisticsPanel StatisticsPanel { get; private set; }
[Resolved]
private IAPIProvider api { get; set; } = null!;
private Drawable bottomPanel;
private Container<ScorePanel> detachedPanelContainer;
protected StatisticsPanel StatisticsPanel { get; private set; } = null!;
private Drawable bottomPanel = null!;
private Container<ScorePanel> detachedPanelContainer = null!;
private bool lastFetchCompleted;
@ -84,9 +80,9 @@ namespace osu.Game.Screens.Ranking
/// </summary>
public bool ShowUserStatistics { get; init; }
private Sample popInSample;
private Sample? popInSample;
protected ResultsScreen([CanBeNull] ScoreInfo score)
protected ResultsScreen(ScoreInfo? score)
{
Score = score;
@ -182,11 +178,11 @@ namespace osu.Game.Screens.Ranking
Scheduler.AddDelayed(() => OverlayActivationMode.Value = OverlayActivation.All, shouldFlair ? AccuracyCircle.TOTAL_DURATION + 1000 : 0);
}
if (AllowWatchingReplay)
if (SelectedScore.Value != null && AllowWatchingReplay)
{
buttons.Add(new ReplayDownloadButton(SelectedScore.Value)
{
Score = { BindTarget = SelectedScore },
Score = { BindTarget = SelectedScore! },
Width = 300
});
}
@ -225,7 +221,7 @@ namespace osu.Game.Screens.Ranking
if (lastFetchCompleted)
{
APIRequest nextPageRequest = null;
APIRequest? nextPageRequest = null;
if (ScorePanelList.IsScrolledToStart)
nextPageRequest = FetchNextPage(-1, fetchScoresCallback);
@ -245,7 +241,7 @@ namespace osu.Game.Screens.Ranking
/// </summary>
/// <param name="scoresCallback">A callback which should be called when fetching is completed. Scheduling is not required.</param>
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
protected virtual APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
protected virtual APIRequest? FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
/// <summary>
/// Performs a fetch of the next page of scores. This is invoked every frame until a non-null <see cref="APIRequest"/> is returned.
@ -253,7 +249,7 @@ namespace osu.Game.Screens.Ranking
/// <param name="direction">The fetch direction. -1 to fetch scores greater than the current start of the list, and 1 to fetch scores lower than the current end of the list.</param>
/// <param name="scoresCallback">A callback which should be called when fetching is completed. Scheduling is not required.</param>
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
protected virtual APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
protected virtual APIRequest? FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
/// <summary>
/// Creates the <see cref="Statistics.StatisticsPanel"/> to be used to display extended information about scores.
@ -327,7 +323,7 @@ namespace osu.Game.Screens.Ranking
panel.Alpha = 0;
}
private ScorePanel detachedPanel;
private ScorePanel? detachedPanel;
private void onStatisticsStateChanged(ValueChangedEvent<Visibility> state)
{

View File

@ -27,7 +27,7 @@ namespace osu.Game.Screens.Ranking
{
}
protected override APIRequest? FetchScores(Action<IEnumerable<ScoreInfo>>? scoresCallback)
protected override APIRequest? FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
{
Debug.Assert(Score != null);
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Ranking
return null;
getScoreRequest = new GetScoresRequest(Score.BeatmapInfo, Score.Ruleset);
getScoreRequest.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => !s.MatchesOnlineID(Score)).Select(s => s.ToScoreInfo(rulesets, Beatmap.Value.BeatmapInfo)));
getScoreRequest.Success += r => scoresCallback.Invoke(r.Scores.Where(s => !s.MatchesOnlineID(Score)).Select(s => s.ToScoreInfo(rulesets, Beatmap.Value.BeatmapInfo)));
return getScoreRequest;
}