1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Change ResultsScreen constructor boolean params to init-only properties

This commit is contained in:
Bartłomiej Dach 2024-02-22 19:15:02 +01:00
parent 083892e753
commit 0074bdc5a1
No known key found for this signature in database
14 changed files with 38 additions and 25 deletions

View File

@ -349,8 +349,9 @@ namespace osu.Game.Tests.Visual.Background
private partial class FadeAccessibleResults : ResultsScreen private partial class FadeAccessibleResults : ResultsScreen
{ {
public FadeAccessibleResults(ScoreInfo score) public FadeAccessibleResults(ScoreInfo score)
: base(score, true) : base(score)
{ {
AllowRetry = true;
} }
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);

View File

@ -420,9 +420,10 @@ namespace osu.Game.Tests.Visual.Playlists
public new LoadingSpinner RightSpinner => base.RightSpinner; public new LoadingSpinner RightSpinner => base.RightSpinner;
public new ScorePanelList ScorePanelList => base.ScorePanelList; public new ScorePanelList ScorePanelList => base.ScorePanelList;
public TestResultsScreen([CanBeNull] ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true) public TestResultsScreen([CanBeNull] ScoreInfo score, int roomId, PlaylistItem playlistItem)
: base(score, roomId, playlistItem, allowRetry) : base(score, roomId, playlistItem)
{ {
AllowRetry = true;
} }
} }
} }

View File

@ -399,8 +399,9 @@ namespace osu.Game.Tests.Visual.Ranking
public HotkeyRetryOverlay RetryOverlay; public HotkeyRetryOverlay RetryOverlay;
public TestResultsScreen(ScoreInfo score) public TestResultsScreen(ScoreInfo score)
: base(score, true) : base(score)
{ {
AllowRetry = true;
ShowUserStatistics = true; ShowUserStatistics = true;
} }
@ -470,8 +471,9 @@ namespace osu.Game.Tests.Visual.Ranking
public HotkeyRetryOverlay RetryOverlay; public HotkeyRetryOverlay RetryOverlay;
public UnrankedSoloResultsScreen(ScoreInfo score) public UnrankedSoloResultsScreen(ScoreInfo score)
: base(score, true) : base(score)
{ {
AllowRetry = true;
Score!.BeatmapInfo!.OnlineID = 0; Score!.BeatmapInfo!.OnlineID = 0;
Score.BeatmapInfo.Status = BeatmapOnlineStatus.Pending; Score.BeatmapInfo.Status = BeatmapOnlineStatus.Pending;
} }

View File

@ -768,7 +768,7 @@ namespace osu.Game
break; break;
case ScorePresentType.Results: case ScorePresentType.Results:
screen.Push(new SoloResultsScreen(databasedScore.ScoreInfo, false)); screen.Push(new SoloResultsScreen(databasedScore.ScoreInfo));
break; break;
} }
}, validScreens: validScreens); }, validScreens: validScreens);

View File

@ -10,7 +10,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public partial class MultiplayerResultsScreen : PlaylistsResultsScreen public partial class MultiplayerResultsScreen : PlaylistsResultsScreen
{ {
public MultiplayerResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem) public MultiplayerResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem)
: base(score, roomId, playlistItem, false) : base(score, roomId, playlistItem)
{ {
} }
} }

View File

@ -58,7 +58,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
protected override ResultsScreen CreateResults(ScoreInfo score) protected override ResultsScreen CreateResults(ScoreInfo score)
{ {
Debug.Assert(Room.RoomID.Value != null); Debug.Assert(Room.RoomID.Value != null);
return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, true); return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem)
{
AllowRetry = true,
};
} }
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)

View File

@ -41,8 +41,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
[Resolved] [Resolved]
private RulesetStore rulesets { get; set; } private RulesetStore rulesets { get; set; }
public PlaylistsResultsScreen([CanBeNull] ScoreInfo score, long roomId, PlaylistItem playlistItem, bool allowRetry, bool allowWatchingReplay = true) public PlaylistsResultsScreen([CanBeNull] ScoreInfo score, long roomId, PlaylistItem playlistItem)
: base(score, allowRetry, allowWatchingReplay) : base(score)
{ {
this.roomId = roomId; this.roomId = roomId;
this.playlistItem = playlistItem; this.playlistItem = playlistItem;

View File

@ -114,7 +114,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
RequestResults = item => RequestResults = item =>
{ {
Debug.Assert(RoomId.Value != null); Debug.Assert(RoomId.Value != null);
ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item, false)); ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item));
} }
} }
}, },

View File

@ -1224,9 +1224,10 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
/// <param name="score">The <see cref="ScoreInfo"/> to be displayed in the results screen.</param> /// <param name="score">The <see cref="ScoreInfo"/> to be displayed in the results screen.</param>
/// <returns>The <see cref="ResultsScreen"/>.</returns> /// <returns>The <see cref="ResultsScreen"/>.</returns>
protected virtual ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, true) protected virtual ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score)
{ {
ShowUserStatistics = true AllowRetry = true,
ShowUserStatistics = true,
}; };
private void fadeOut(bool instant = false) private void fadeOut(bool instant = false)

View File

@ -92,7 +92,7 @@ namespace osu.Game.Screens.Play
Scores = { BindTarget = LeaderboardScores } Scores = { BindTarget = LeaderboardScores }
}; };
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false); protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score);
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{ {

View File

@ -13,7 +13,7 @@ namespace osu.Game.Screens.Play
public partial class SpectatorResultsScreen : SoloResultsScreen public partial class SpectatorResultsScreen : SoloResultsScreen
{ {
public SpectatorResultsScreen(ScoreInfo score) public SpectatorResultsScreen(ScoreInfo score)
: base(score, false) : base(score)
{ {
} }

View File

@ -63,16 +63,21 @@ namespace osu.Game.Screens.Ranking
private bool lastFetchCompleted; private bool lastFetchCompleted;
private readonly bool allowRetry; /// <summary>
private readonly bool allowWatchingReplay; /// Whether the user can retry the beatmap from the results screen.
/// </summary>
public bool AllowRetry { get; init; }
/// <summary>
/// Whether the user can watch the replay of the completed play from the results screen.
/// </summary>
public bool AllowWatchingReplay { get; init; } = true;
private Sample popInSample; private Sample popInSample;
protected ResultsScreen([CanBeNull] ScoreInfo score, bool allowRetry, bool allowWatchingReplay = true) protected ResultsScreen([CanBeNull] ScoreInfo score)
{ {
Score = score; Score = score;
this.allowRetry = allowRetry;
this.allowWatchingReplay = allowWatchingReplay;
SelectedScore.Value = score; SelectedScore.Value = score;
} }
@ -162,7 +167,7 @@ namespace osu.Game.Screens.Ranking
ScorePanelList.AddScore(Score, shouldFlair); ScorePanelList.AddScore(Score, shouldFlair);
} }
if (allowWatchingReplay) if (AllowWatchingReplay)
{ {
buttons.Add(new ReplayDownloadButton(SelectedScore.Value) buttons.Add(new ReplayDownloadButton(SelectedScore.Value)
{ {
@ -171,7 +176,7 @@ namespace osu.Game.Screens.Ranking
}); });
} }
if (player != null && allowRetry) if (player != null && AllowRetry)
{ {
buttons.Add(new RetryButton { Width = 300 }); buttons.Add(new RetryButton { Width = 300 });

View File

@ -34,8 +34,8 @@ namespace osu.Game.Screens.Ranking
private IBindable<SoloStatisticsUpdate?> latestUpdate = null!; private IBindable<SoloStatisticsUpdate?> latestUpdate = null!;
private readonly Bindable<SoloStatisticsUpdate?> statisticsUpdate = new Bindable<SoloStatisticsUpdate?>(); private readonly Bindable<SoloStatisticsUpdate?> statisticsUpdate = new Bindable<SoloStatisticsUpdate?>();
public SoloResultsScreen(ScoreInfo score, bool allowRetry) public SoloResultsScreen(ScoreInfo score)
: base(score, allowRetry) : base(score)
{ {
} }

View File

@ -54,7 +54,7 @@ namespace osu.Game.Screens.Select
} }
protected void PresentScore(ScoreInfo score) => protected void PresentScore(ScoreInfo score) =>
FinaliseSelection(score.BeatmapInfo, score.Ruleset, () => this.Push(new SoloResultsScreen(score, false))); FinaliseSelection(score.BeatmapInfo, score.Ruleset, () => this.Push(new SoloResultsScreen(score)));
protected override BeatmapDetailArea CreateBeatmapDetailArea() protected override BeatmapDetailArea CreateBeatmapDetailArea()
{ {