mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Move metrics to beatmap set
This commit is contained in:
@ -87,6 +87,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778",
|
||||
},
|
||||
},
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
@ -111,7 +112,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -138,7 +138,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -165,7 +164,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -192,7 +190,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -219,7 +216,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -258,6 +254,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Cover = @"https://assets.ppy.sh/beatmaps/625493/covers/cover.jpg?1499167472",
|
||||
},
|
||||
},
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
@ -282,7 +279,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -309,7 +305,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -336,7 +331,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -363,7 +357,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -390,7 +383,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
|
@ -32,6 +32,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
|
||||
{
|
||||
BeatmapSetInfo =
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Version = "All Metrics",
|
||||
@ -50,7 +54,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
StarDifficulty = 5.3f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -60,6 +63,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
|
||||
{
|
||||
BeatmapSetInfo =
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Version = "All Metrics",
|
||||
@ -77,7 +84,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
StarDifficulty = 5.3f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -86,6 +92,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
|
||||
{
|
||||
BeatmapSetInfo =
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Version = "Only Ratings",
|
||||
@ -101,11 +111,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
OverallDifficulty = 6,
|
||||
ApproachRate = 6,
|
||||
},
|
||||
StarDifficulty = 4.8f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
},
|
||||
StarDifficulty = 4.8f
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -23,6 +23,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("all metrics", () => details.Beatmap = new BeatmapInfo
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
Version = "All Metrics",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
@ -39,7 +43,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
StarDifficulty = 5.3f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -47,6 +50,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("all except source", () => details.Beatmap = new BeatmapInfo
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
Version = "All Metrics",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
@ -62,7 +69,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
StarDifficulty = 5.3f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
@ -70,6 +76,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("ratings", () => details.Beatmap = new BeatmapInfo
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
Version = "Only Ratings",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
@ -84,10 +94,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
ApproachRate = 6,
|
||||
},
|
||||
StarDifficulty = 4.8f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
},
|
||||
});
|
||||
|
||||
AddStep("fails retries", () => details.Beatmap = new BeatmapInfo
|
||||
@ -129,7 +135,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
ApproachRate = 6.5f,
|
||||
},
|
||||
StarDifficulty = 1.97f,
|
||||
Metrics = new BeatmapMetrics(),
|
||||
});
|
||||
|
||||
AddStep("null beatmap", () => details.Beatmap = null);
|
||||
|
@ -270,7 +270,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
|
@ -7,15 +7,10 @@ using Newtonsoft.Json;
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// Beatmap metrics based on acculumated online data from community plays.
|
||||
/// Beatmap metrics based on accumulated online data from community plays.
|
||||
/// </summary>
|
||||
public class BeatmapMetrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Total vote counts of user ratings on a scale of 0..10 where 0 is unused (probably will be fixed at API?).
|
||||
/// </summary>
|
||||
public int[] Ratings { get; set; } = Array.Empty<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Points of failure on a relative time scale (usually 0..100).
|
||||
/// </summary>
|
||||
|
@ -32,6 +32,9 @@ namespace osu.Game.Beatmaps
|
||||
[NotMapped]
|
||||
public BeatmapSetOnlineInfo OnlineInfo { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public BeatmapSetMetrics Metrics { get; set; }
|
||||
|
||||
public double MaxStarDifficulty => Beatmaps?.Max(b => b.StarDifficulty) ?? 0;
|
||||
|
||||
[NotMapped]
|
||||
|
17
osu.Game/Beatmaps/BeatmapSetMetrics.cs
Normal file
17
osu.Game/Beatmaps/BeatmapSetMetrics.cs
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public class BeatmapSetMetrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Total vote counts of user ratings on a scale of 0..10 where 0 is unused (probably will be fixed at API?).
|
||||
/// </summary>
|
||||
[JsonProperty("ratings")]
|
||||
public int[] Ratings { get; set; } = Array.Empty<int>();
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
@ -19,9 +20,12 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
}
|
||||
}
|
||||
|
||||
public int[] Ratings { get; set; } = Array.Empty<int>();
|
||||
|
||||
//and other metrics in the beatmap set.
|
||||
// Todo: What
|
||||
[JsonProperty(@"beatmapset")]
|
||||
private BeatmapMetrics beatmapSet
|
||||
private BeatmapSetMetrics beatmapSet
|
||||
{
|
||||
set => Ratings = value.Ratings;
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty(@"last_updated")]
|
||||
private DateTimeOffset lastUpdated { get; set; }
|
||||
|
||||
[JsonProperty(@"ratings")]
|
||||
private int[] ratings { get; set; }
|
||||
|
||||
[JsonProperty(@"user_id")]
|
||||
private long creatorId
|
||||
{
|
||||
@ -70,6 +73,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
OnlineBeatmapSetID = OnlineBeatmapSetID,
|
||||
Metadata = this,
|
||||
Status = Status,
|
||||
Metrics = new BeatmapSetMetrics { Ratings = ratings },
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
{
|
||||
Covers = covers,
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
ratings.Metrics = Beatmap?.Metrics;
|
||||
ratings.Metrics = Beatmap?.BeatmapSet?.Metrics;
|
||||
}
|
||||
|
||||
public Details()
|
||||
|
@ -18,6 +18,7 @@ using osu.Game.Screens.Select.Details;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -181,9 +182,10 @@ namespace osu.Game.Screens.Select
|
||||
tags.Text = Beatmap?.Metadata?.Tags;
|
||||
|
||||
// metrics may have been previously fetched
|
||||
if (Beatmap?.Metrics != null)
|
||||
// Todo:
|
||||
if (Beatmap?.BeatmapSet?.Metrics != null)
|
||||
{
|
||||
updateMetrics(Beatmap.Metrics);
|
||||
updateMetrics(new APIBeatmapMetrics { Ratings = Beatmap.BeatmapSet.Metrics.Ratings });
|
||||
return;
|
||||
}
|
||||
|
||||
@ -210,22 +212,19 @@ namespace osu.Game.Screens.Select
|
||||
updateMetrics();
|
||||
}
|
||||
|
||||
private void updateMetrics(BeatmapMetrics metrics = null)
|
||||
private void updateMetrics(APIBeatmapMetrics metrics = null)
|
||||
{
|
||||
var hasRatings = metrics?.Ratings?.Any() ?? false;
|
||||
var hasRetriesFails = (metrics?.Retries?.Any() ?? false) && (metrics.Fails?.Any() ?? false);
|
||||
|
||||
if (hasRatings)
|
||||
{
|
||||
ratings.Metrics = metrics;
|
||||
ratings.Metrics = new BeatmapSetMetrics { Ratings = metrics.Ratings };
|
||||
ratingsContainer.FadeIn(transition_duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
ratings.Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = new int[10],
|
||||
};
|
||||
ratings.Metrics = new BeatmapSetMetrics { Ratings = new int[10] };
|
||||
ratingsContainer.FadeTo(0.25f, transition_duration);
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,9 @@ namespace osu.Game.Screens.Select.Details
|
||||
private readonly Container graphContainer;
|
||||
private readonly BarGraph graph;
|
||||
|
||||
private BeatmapMetrics metrics;
|
||||
private BeatmapSetMetrics metrics;
|
||||
|
||||
public BeatmapMetrics Metrics
|
||||
public BeatmapSetMetrics Metrics
|
||||
{
|
||||
get => metrics;
|
||||
set
|
||||
|
Reference in New Issue
Block a user