Move Length out of OnlineInfo

This commit is contained in:
iiSaLMaN
2019-07-07 20:25:36 +03:00
parent 3ea9629daf
commit 729f0901f7
10 changed files with 15 additions and 22 deletions

View File

@ -108,6 +108,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
StarDifficulty = 9.99, StarDifficulty = 9.99,
Version = @"TEST", Version = @"TEST",
Length = 456000,
Ruleset = maniaRuleset, Ruleset = maniaRuleset,
BaseDifficulty = new BeatmapDifficulty BaseDifficulty = new BeatmapDifficulty
{ {
@ -118,7 +119,6 @@ namespace osu.Game.Tests.Visual.Online
}, },
OnlineInfo = new BeatmapOnlineInfo OnlineInfo = new BeatmapOnlineInfo
{ {
Length = 456000,
CircleCount = 111, CircleCount = 111,
SliderCount = 12, SliderCount = 12,
PlayCount = 222, PlayCount = 222,
@ -181,6 +181,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
StarDifficulty = 5.67, StarDifficulty = 5.67,
Version = @"ANOTHER TEST", Version = @"ANOTHER TEST",
Length = 123000,
Ruleset = taikoRuleset, Ruleset = taikoRuleset,
BaseDifficulty = new BeatmapDifficulty BaseDifficulty = new BeatmapDifficulty
{ {
@ -191,7 +192,6 @@ namespace osu.Game.Tests.Visual.Online
}, },
OnlineInfo = new BeatmapOnlineInfo OnlineInfo = new BeatmapOnlineInfo
{ {
Length = 123000,
CircleCount = 123, CircleCount = 123,
SliderCount = 45, SliderCount = 45,
PlayCount = 567, PlayCount = 567,

View File

@ -275,14 +275,11 @@ namespace osu.Game.Tests.Visual.SongSelect
OnlineBeatmapID = beatmapId, OnlineBeatmapID = beatmapId,
Path = "normal.osu", Path = "normal.osu",
Version = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss})", Version = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss})",
Length = length,
BaseDifficulty = new BeatmapDifficulty BaseDifficulty = new BeatmapDifficulty
{ {
OverallDifficulty = 3.5f, OverallDifficulty = 3.5f,
}, },
OnlineInfo = new BeatmapOnlineInfo
{
Length = length,
}
}); });
} }

View File

@ -159,7 +159,7 @@ namespace osu.Game.Tournament.Components
} }
var bpm = beatmap.BeatmapSet.BPM; var bpm = beatmap.BeatmapSet.BPM;
var length = beatmap.OnlineInfo.Length; var length = beatmap.Length;
string hardRockExtra = ""; string hardRockExtra = "";
string srExtra = ""; string srExtra = "";

View File

@ -51,6 +51,11 @@ namespace osu.Game.Beatmaps
[NotMapped] [NotMapped]
public BeatmapOnlineInfo OnlineInfo { get; set; } public BeatmapOnlineInfo OnlineInfo { get; set; }
/// <summary>
/// The length in milliseconds of this beatmap's song.
/// </summary>
public double Length { get; set; }
public string Path { get; set; } public string Path { get; set; }
[JsonProperty("file_sha2")] [JsonProperty("file_sha2")]

View File

@ -303,11 +303,7 @@ namespace osu.Game.Beatmaps
beatmap.BeatmapInfo.Ruleset = ruleset; beatmap.BeatmapInfo.Ruleset = ruleset;
// TODO: this should be done in a better place once we actually need to dynamically update it. // TODO: this should be done in a better place once we actually need to dynamically update it.
beatmap.BeatmapInfo.StarDifficulty = ruleset?.CreateInstance().CreateDifficultyCalculator(new DummyConversionBeatmap(beatmap)).Calculate().StarRating ?? 0; beatmap.BeatmapInfo.StarDifficulty = ruleset?.CreateInstance().CreateDifficultyCalculator(new DummyConversionBeatmap(beatmap)).Calculate().StarRating ?? 0;
beatmap.BeatmapInfo.Length = beatmap.CalculateLength();
beatmap.BeatmapInfo.OnlineInfo = new BeatmapOnlineInfo
{
Length = beatmap.CalculateLength(),
};
beatmapInfos.Add(beatmap.BeatmapInfo); beatmapInfos.Add(beatmap.BeatmapInfo);
} }

View File

@ -8,11 +8,6 @@ namespace osu.Game.Beatmaps
/// </summary> /// </summary>
public class BeatmapOnlineInfo public class BeatmapOnlineInfo
{ {
/// <summary>
/// The length in milliseconds of this beatmap's song.
/// </summary>
public double Length { get; set; }
/// <summary> /// <summary>
/// The amount of circles in this beatmap. /// The amount of circles in this beatmap.
/// </summary> /// </summary>

View File

@ -42,7 +42,7 @@ namespace osu.Game.Beatmaps
public double MaxStarDifficulty => Beatmaps?.Max(b => b.StarDifficulty) ?? 0; public double MaxStarDifficulty => Beatmaps?.Max(b => b.StarDifficulty) ?? 0;
public double MaxLength => Beatmaps?.Max(b => b.OnlineInfo.Length) ?? 0; public double MaxLength => Beatmaps?.Max(b => b.Length) ?? 0;
[NotMapped] [NotMapped]
public bool DeletePending { get; set; } public bool DeletePending { get; set; }

View File

@ -71,6 +71,7 @@ namespace osu.Game.Online.API.Requests.Responses
StarDifficulty = starDifficulty, StarDifficulty = starDifficulty,
OnlineBeatmapID = OnlineBeatmapID, OnlineBeatmapID = OnlineBeatmapID,
Version = version, Version = version,
Length = length,
Status = Status, Status = Status,
BeatmapSet = set, BeatmapSet = set,
Metrics = metrics, Metrics = metrics,
@ -85,7 +86,6 @@ namespace osu.Game.Online.API.Requests.Responses
{ {
PlayCount = playCount, PlayCount = playCount,
PassCount = passCount, PassCount = passCount,
Length = length,
CircleCount = circleCount, CircleCount = circleCount,
SliderCount = sliderCount, SliderCount = sliderCount,
}, },

View File

@ -60,7 +60,7 @@ namespace osu.Game.Overlays.BeatmapSet
} }
else else
{ {
length.Value = TimeSpan.FromSeconds(beatmap.OnlineInfo.Length).ToString(@"m\:ss"); length.Value = TimeSpan.FromSeconds(beatmap.Length).ToString(@"m\:ss");
circleCount.Value = beatmap.OnlineInfo.CircleCount.ToString(); circleCount.Value = beatmap.OnlineInfo.CircleCount.ToString();
sliderCount.Value = beatmap.OnlineInfo.SliderCount.ToString(); sliderCount.Value = beatmap.OnlineInfo.SliderCount.ToString();
} }

View File

@ -50,8 +50,8 @@ namespace osu.Game.Screens.Select.Carousel
case SortMode.Length: case SortMode.Length:
// Length comparing must be in seconds // Length comparing must be in seconds
if (TimeSpan.FromMilliseconds(Beatmap.OnlineInfo.Length).Seconds != TimeSpan.FromMilliseconds(otherBeatmap.Beatmap.OnlineInfo.Length).Seconds) if (TimeSpan.FromMilliseconds(Beatmap.Length).Seconds != TimeSpan.FromMilliseconds(otherBeatmap.Beatmap.Length).Seconds)
return Beatmap.OnlineInfo.Length.CompareTo(otherBeatmap.Beatmap.OnlineInfo.Length); return Beatmap.Length.CompareTo(otherBeatmap.Beatmap.Length);
goto case SortMode.Difficulty; goto case SortMode.Difficulty;
} }