mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 18:32:55 +08:00
Merge pull request #15463 from peppy/beatmap-refactor/to-model-removal-2
Remove all remaining calls to `ToBeatmapInfo`/`ToBeatmapSetInfo`
This commit is contained in:
commit
9e06da6cbb
@ -81,34 +81,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
|
|
||||||
public double BPM { get; set; }
|
public double BPM { get; set; }
|
||||||
|
|
||||||
public virtual BeatmapInfo ToBeatmapInfo(RulesetStore rulesets)
|
|
||||||
{
|
|
||||||
var set = BeatmapSet?.ToBeatmapSet(rulesets);
|
|
||||||
|
|
||||||
return new BeatmapInfo
|
|
||||||
{
|
|
||||||
Metadata = set?.Metadata ?? new BeatmapMetadata(),
|
|
||||||
Ruleset = rulesets.GetRuleset(RulesetID),
|
|
||||||
StarDifficulty = StarRating,
|
|
||||||
OnlineBeatmapID = OnlineID,
|
|
||||||
Version = DifficultyName,
|
|
||||||
// this is actually an incorrect mapping (Length is calculated as drain length in lazer's import process, see BeatmapManager.calculateLength).
|
|
||||||
Length = Length,
|
|
||||||
Status = Status,
|
|
||||||
MD5Hash = Checksum,
|
|
||||||
BeatmapSet = set,
|
|
||||||
MaxCombo = MaxCombo,
|
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
|
||||||
{
|
|
||||||
DrainRate = DrainRate,
|
|
||||||
CircleSize = CircleSize,
|
|
||||||
ApproachRate = ApproachRate,
|
|
||||||
OverallDifficulty = OverallDifficulty,
|
|
||||||
},
|
|
||||||
OnlineInfo = this,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Implementation of IBeatmapInfo
|
#region Implementation of IBeatmapInfo
|
||||||
|
|
||||||
public IBeatmapMetadataInfo Metadata => (BeatmapSet as IBeatmapSetInfo)?.Metadata ?? new BeatmapMetadata();
|
public IBeatmapMetadataInfo Metadata => (BeatmapSet as IBeatmapSetInfo)?.Metadata ?? new BeatmapMetadata();
|
||||||
|
@ -3,11 +3,9 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
@ -121,26 +119,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty(@"beatmaps")]
|
[JsonProperty(@"beatmaps")]
|
||||||
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
|
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
|
||||||
|
|
||||||
public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
|
|
||||||
{
|
|
||||||
var beatmapSet = new BeatmapSetInfo
|
|
||||||
{
|
|
||||||
OnlineBeatmapSetID = OnlineID,
|
|
||||||
Metadata = metadata,
|
|
||||||
Status = Status,
|
|
||||||
};
|
|
||||||
|
|
||||||
beatmapSet.Beatmaps = Beatmaps.Select(b =>
|
|
||||||
{
|
|
||||||
var beatmap = b.ToBeatmapInfo(rulesets);
|
|
||||||
beatmap.BeatmapSet = beatmapSet;
|
|
||||||
beatmap.Metadata = beatmapSet.Metadata;
|
|
||||||
return beatmap;
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
return beatmapSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BeatmapMetadata metadata => new BeatmapMetadata
|
private BeatmapMetadata metadata => new BeatmapMetadata
|
||||||
{
|
{
|
||||||
Title = Title,
|
Title = Title,
|
||||||
|
@ -98,7 +98,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
{
|
{
|
||||||
TotalScore = TotalScore,
|
TotalScore = TotalScore,
|
||||||
MaxCombo = MaxCombo,
|
MaxCombo = MaxCombo,
|
||||||
BeatmapInfo = Beatmap?.ToBeatmapInfo(rulesets),
|
BeatmapInfo = beatmap,
|
||||||
User = User,
|
User = User,
|
||||||
Accuracy = Accuracy,
|
Accuracy = Accuracy,
|
||||||
OnlineScoreID = OnlineID,
|
OnlineScoreID = OnlineID,
|
||||||
@ -111,9 +111,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
Mods = modInstances,
|
Mods = modInstances,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (beatmap != null)
|
|
||||||
scoreInfo.BeatmapInfo = beatmap;
|
|
||||||
|
|
||||||
if (Statistics != null)
|
if (Statistics != null)
|
||||||
{
|
{
|
||||||
foreach (var kvp in Statistics)
|
foreach (var kvp in Statistics)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -66,7 +67,18 @@ 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, Beatmap.Value.ToBeatmapInfo(rulesets))).ToArray(), loadCancellationSource.Token)
|
var apiBeatmap = Beatmap.Value;
|
||||||
|
|
||||||
|
Debug.Assert(apiBeatmap != null);
|
||||||
|
|
||||||
|
// TODO: temporary. should be removed once `OrderByTotalScore` can accept `IScoreInfo`.
|
||||||
|
var beatmapInfo = new BeatmapInfo
|
||||||
|
{
|
||||||
|
MaxCombo = apiBeatmap.MaxCombo,
|
||||||
|
Status = apiBeatmap.Status
|
||||||
|
};
|
||||||
|
|
||||||
|
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, beatmapInfo)).ToArray(), loadCancellationSource.Token)
|
||||||
.ContinueWith(ordered => Schedule(() =>
|
.ContinueWith(ordered => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (loadCancellationSource.IsCancellationRequested)
|
if (loadCancellationSource.IsCancellationRequested)
|
||||||
@ -74,11 +86,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
|
|
||||||
var topScore = ordered.Result.First();
|
var topScore = ordered.Result.First();
|
||||||
|
|
||||||
scoreTable.DisplayScores(ordered.Result, topScore.BeatmapInfo?.Status.GrantsPerformancePoints() == true);
|
scoreTable.DisplayScores(ordered.Result, apiBeatmap.Status.GrantsPerformancePoints());
|
||||||
scoreTable.Show();
|
scoreTable.Show();
|
||||||
|
|
||||||
var userScore = value.UserScore;
|
var userScore = value.UserScore;
|
||||||
var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, Beatmap.Value.ToBeatmapInfo(rulesets));
|
var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, beatmapInfo);
|
||||||
|
|
||||||
topScoresContainer.Add(new DrawableTopScore(topScore));
|
topScoresContainer.Add(new DrawableTopScore(topScore));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user