mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Remove local score copying in GetScoresRequest
to allow APIScoreInfo.Beatmap
to be APIBeatmap
This commit is contained in:
@ -9,7 +9,6 @@ using osu.Game.Online.API.Requests.Responses;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
@ -32,27 +31,6 @@ namespace osu.Game.Online.API.Requests
|
|||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
this.ruleset = ruleset ?? throw new ArgumentNullException(nameof(ruleset));
|
this.ruleset = ruleset ?? throw new ArgumentNullException(nameof(ruleset));
|
||||||
this.mods = mods ?? Array.Empty<IMod>();
|
this.mods = mods ?? Array.Empty<IMod>();
|
||||||
|
|
||||||
Success += onSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onSuccess(APIScoresCollection r)
|
|
||||||
{
|
|
||||||
Debug.Assert(ruleset.OnlineID >= 0);
|
|
||||||
|
|
||||||
foreach (APIScoreInfo score in r.Scores)
|
|
||||||
{
|
|
||||||
score.Beatmap = beatmapInfo;
|
|
||||||
score.OnlineRulesetID = ruleset.OnlineID;
|
|
||||||
}
|
|
||||||
|
|
||||||
var userScore = r.UserScore;
|
|
||||||
|
|
||||||
if (userScore != null)
|
|
||||||
{
|
|
||||||
userScore.Score.Beatmap = beatmapInfo;
|
|
||||||
userScore.Score.OnlineRulesetID = ruleset.OnlineID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target => $@"beatmaps/{beatmapInfo.OnlineBeatmapID}/scores{createQueryParameters()}";
|
protected override string Target => $@"beatmaps/{beatmapInfo.OnlineBeatmapID}/scores{createQueryParameters()}";
|
||||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
public DateTimeOffset Date { get; set; }
|
public DateTimeOffset Date { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"beatmap")]
|
[JsonProperty(@"beatmap")]
|
||||||
public IBeatmapInfo Beatmap { get; set; }
|
public APIBeatmap Beatmap { get; set; }
|
||||||
|
|
||||||
[JsonProperty("accuracy")]
|
[JsonProperty("accuracy")]
|
||||||
public double Accuracy { get; set; }
|
public double Accuracy { get; set; }
|
||||||
@ -71,10 +71,8 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public ScoreRank Rank { get; set; }
|
public ScoreRank Rank { get; set; }
|
||||||
|
|
||||||
IBeatmapInfo IScoreInfo.Beatmap => Beatmap;
|
// TODO: This function will eventually be going away.
|
||||||
|
public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = null)
|
||||||
// TODO: nuke
|
|
||||||
public ScoreInfo CreateScoreInfo(RulesetStore rulesets)
|
|
||||||
{
|
{
|
||||||
var ruleset = rulesets.GetRuleset(OnlineRulesetID);
|
var ruleset = rulesets.GetRuleset(OnlineRulesetID);
|
||||||
|
|
||||||
@ -94,7 +92,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
OnlineScoreID = OnlineID,
|
OnlineScoreID = OnlineID,
|
||||||
Date = Date,
|
Date = Date,
|
||||||
PP = PP,
|
PP = PP,
|
||||||
BeatmapInfo = Beatmap.ToBeatmapInfo(rulesets),
|
|
||||||
RulesetID = OnlineRulesetID,
|
RulesetID = OnlineRulesetID,
|
||||||
Hash = Replay ? "online" : string.Empty, // todo: temporary?
|
Hash = Replay ? "online" : string.Empty, // todo: temporary?
|
||||||
Rank = Rank,
|
Rank = Rank,
|
||||||
@ -102,6 +99,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
Mods = mods,
|
Mods = mods,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (beatmap != null)
|
||||||
|
scoreInfo.BeatmapInfo = beatmap;
|
||||||
|
|
||||||
if (Statistics != null)
|
if (Statistics != null)
|
||||||
{
|
{
|
||||||
foreach (var kvp in Statistics)
|
foreach (var kvp in Statistics)
|
||||||
@ -138,19 +138,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
return scoreInfo;
|
return scoreInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty(@"beatmapset")]
|
|
||||||
public APIBeatmapSet Metadata
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// in the deserialisation case we need to ferry this data across.
|
|
||||||
if (Beatmap is APIBeatmap apiBeatmap)
|
|
||||||
apiBeatmap.BeatmapSet = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IRulesetInfo Ruleset => new RulesetInfo { ID = OnlineRulesetID };
|
public IRulesetInfo Ruleset => new RulesetInfo { ID = OnlineRulesetID };
|
||||||
|
|
||||||
|
IBeatmapInfo IScoreInfo.Beatmap => Beatmap;
|
||||||
|
|
||||||
Dictionary<HitResult, int> IScoreInfo.Statistics => new Dictionary<HitResult, int>(); // TODO: implement... maybe. hitresults have weird mappings per ruleset it would seem.
|
Dictionary<HitResult, int> IScoreInfo.Statistics => new Dictionary<HitResult, int>(); // TODO: implement... maybe. hitresults have weird mappings per ruleset it would seem.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
@ -15,10 +16,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty(@"score")]
|
[JsonProperty(@"score")]
|
||||||
public APIScoreInfo Score;
|
public APIScoreInfo Score;
|
||||||
|
|
||||||
public ScoreInfo CreateScoreInfo(RulesetStore rulesets)
|
public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = null)
|
||||||
|
|
||||||
{
|
{
|
||||||
var score = Score.CreateScoreInfo(rulesets);
|
var score = Score.CreateScoreInfo(rulesets, beatmap);
|
||||||
score.Position = Position;
|
score.Position = Position;
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
if (value?.Scores.Any() != true)
|
if (value?.Scores.Any() != true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets)).ToArray(), loadCancellationSource.Token)
|
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, Beatmap.Value)).ToArray(), loadCancellationSource.Token)
|
||||||
.ContinueWith(ordered => Schedule(() =>
|
.ContinueWith(ordered => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (loadCancellationSource.IsCancellationRequested)
|
if (loadCancellationSource.IsCancellationRequested)
|
||||||
@ -78,7 +78,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
scoreTable.Show();
|
scoreTable.Show();
|
||||||
|
|
||||||
var userScore = value.UserScore;
|
var userScore = value.UserScore;
|
||||||
var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets);
|
var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, Beatmap.Value);
|
||||||
|
|
||||||
topScoresContainer.Add(new DrawableTopScore(topScore));
|
topScoresContainer.Add(new DrawableTopScore(topScore));
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
getScoreRequest = new GetScoresRequest(Score.BeatmapInfo, Score.Ruleset);
|
getScoreRequest = new GetScoresRequest(Score.BeatmapInfo, Score.Ruleset);
|
||||||
getScoreRequest.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineID != Score.OnlineScoreID).Select(s => s.CreateScoreInfo(rulesets)));
|
getScoreRequest.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineID != Score.OnlineScoreID).Select(s => s.CreateScoreInfo(rulesets, Beatmap.Value.BeatmapInfo)));
|
||||||
return getScoreRequest;
|
return getScoreRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,14 +192,14 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
req.Success += r =>
|
req.Success += r =>
|
||||||
{
|
{
|
||||||
scoreManager.OrderByTotalScoreAsync(r.Scores.Select(s => s.CreateScoreInfo(rulesets)).ToArray(), loadCancellationSource.Token)
|
scoreManager.OrderByTotalScoreAsync(r.Scores.Select(s => s.CreateScoreInfo(rulesets, BeatmapInfo)).ToArray(), loadCancellationSource.Token)
|
||||||
.ContinueWith(ordered => Schedule(() =>
|
.ContinueWith(ordered => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (loadCancellationSource.IsCancellationRequested)
|
if (loadCancellationSource.IsCancellationRequested)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scoresCallback?.Invoke(ordered.Result);
|
scoresCallback?.Invoke(ordered.Result);
|
||||||
TopScore = r.UserScore?.CreateScoreInfo(rulesets);
|
TopScore = r.UserScore?.CreateScoreInfo(rulesets, BeatmapInfo);
|
||||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user