mirror of
https://github.com/ppy/osu.git
synced 2024-11-16 13:17:26 +08:00
898d5ce88b
Previously, if a `SubmittingPlayer` instance deemed it okay to proceed with gameplay despite submission failure, it would silently log all errors and proceed, but the score would still not be submitted. This feels a bit anti-user in the cases wherein something is genuinely wrong with either the client or web, so things like token verification failures or API failures are now shown as notifications to give the user an indication that something went wrong at all. Selected cases (non-user-playable mod, logged out, beatmap is not online) are still logged silently because those are either known and expected, or someone is messing with things.
77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
// 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.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using osu.Framework.Bindables;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Extensions;
|
|
using osu.Game.Online.API;
|
|
using osu.Game.Online.Rooms;
|
|
using osu.Game.Online.Solo;
|
|
using osu.Game.Scoring;
|
|
using osu.Game.Screens.Play.HUD;
|
|
|
|
namespace osu.Game.Screens.Play
|
|
{
|
|
public partial class SoloPlayer : SubmittingPlayer
|
|
{
|
|
public SoloPlayer()
|
|
: this(null)
|
|
{
|
|
}
|
|
|
|
protected SoloPlayer(PlayerConfiguration configuration = null)
|
|
: base(configuration)
|
|
{
|
|
}
|
|
|
|
protected override APIRequest<APIScoreToken> CreateTokenRequest()
|
|
{
|
|
int beatmapId = Beatmap.Value.BeatmapInfo.OnlineID;
|
|
int rulesetId = Ruleset.Value.OnlineID;
|
|
|
|
if (beatmapId <= 0)
|
|
return null;
|
|
|
|
if (!Ruleset.Value.IsLegacyRuleset())
|
|
return null;
|
|
|
|
return new CreateSoloScoreRequest(Beatmap.Value.BeatmapInfo, rulesetId, Game.VersionHash);
|
|
}
|
|
|
|
public readonly BindableList<ScoreInfo> LeaderboardScores = new BindableList<ScoreInfo>();
|
|
|
|
protected override GameplayLeaderboard CreateGameplayLeaderboard() =>
|
|
new SoloGameplayLeaderboard(Score.ScoreInfo.User)
|
|
{
|
|
AlwaysVisible = { Value = false },
|
|
Scores = { BindTarget = LeaderboardScores }
|
|
};
|
|
|
|
protected override bool ShouldExitOnTokenRetrievalFailure(Exception exception) => false;
|
|
|
|
protected override Task ImportScore(Score score)
|
|
{
|
|
// Before importing a score, stop binding the leaderboard with its score source.
|
|
// This avoids a case where the imported score may cause a leaderboard refresh
|
|
// (if the leaderboard's source is local).
|
|
LeaderboardScores.UnbindBindings();
|
|
|
|
return base.ImportScore(score);
|
|
}
|
|
|
|
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
|
|
{
|
|
IBeatmapInfo beatmap = score.ScoreInfo.BeatmapInfo;
|
|
|
|
Debug.Assert(beatmap!.OnlineID > 0);
|
|
|
|
return new SubmitSoloScoreRequest(score.ScoreInfo, token, beatmap.OnlineID);
|
|
}
|
|
}
|
|
}
|