mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Merge pull request #15285 from peppy/move-online-beatmap-metrics
Move online metrics out of databased models
This commit is contained in:
@ -73,10 +73,10 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Ranked = DateTime.Now,
|
Ranked = DateTime.Now,
|
||||||
BPM = 111,
|
BPM = 111,
|
||||||
HasVideo = true,
|
HasVideo = true,
|
||||||
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||||
HasStoryboard = true,
|
HasStoryboard = true,
|
||||||
Covers = new BeatmapSetOnlineCovers(),
|
Covers = new BeatmapSetOnlineCovers(),
|
||||||
},
|
},
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
|
||||||
Beatmaps = new List<BeatmapInfo>
|
Beatmaps = new List<BeatmapInfo>
|
||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
@ -92,20 +92,20 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
OverallDifficulty = 4.5f,
|
OverallDifficulty = 4.5f,
|
||||||
ApproachRate = 6,
|
ApproachRate = 6,
|
||||||
},
|
},
|
||||||
OnlineInfo = new BeatmapOnlineInfo
|
OnlineInfo = new APIBeatmap
|
||||||
{
|
{
|
||||||
CircleCount = 111,
|
CircleCount = 111,
|
||||||
SliderCount = 12,
|
SliderCount = 12,
|
||||||
PlayCount = 222,
|
PlayCount = 222,
|
||||||
PassCount = 21,
|
PassCount = 21,
|
||||||
},
|
FailTimes = new APIFailTimes
|
||||||
Metrics = new BeatmapMetrics
|
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -153,8 +153,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Covers = new BeatmapSetOnlineCovers(),
|
Covers = new BeatmapSetOnlineCovers(),
|
||||||
Language = new BeatmapSetOnlineLanguage { Id = 3, Name = "English" },
|
Language = new BeatmapSetOnlineLanguage { Id = 3, Name = "English" },
|
||||||
Genre = new BeatmapSetOnlineGenre { Id = 4, Name = "Rock" },
|
Genre = new BeatmapSetOnlineGenre { Id = 4, Name = "Rock" },
|
||||||
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||||
},
|
},
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
|
||||||
Beatmaps = new List<BeatmapInfo>
|
Beatmaps = new List<BeatmapInfo>
|
||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
@ -170,20 +170,20 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
OverallDifficulty = 7,
|
OverallDifficulty = 7,
|
||||||
ApproachRate = 6,
|
ApproachRate = 6,
|
||||||
},
|
},
|
||||||
OnlineInfo = new BeatmapOnlineInfo
|
OnlineInfo = new APIBeatmap
|
||||||
{
|
{
|
||||||
CircleCount = 123,
|
CircleCount = 123,
|
||||||
SliderCount = 45,
|
SliderCount = 45,
|
||||||
PlayCount = 567,
|
PlayCount = 567,
|
||||||
PassCount = 89,
|
PassCount = 89,
|
||||||
},
|
FailTimes = new APIFailTimes
|
||||||
Metrics = new BeatmapMetrics
|
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -204,12 +204,14 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Version = ruleset.Name,
|
Version = ruleset.Name,
|
||||||
Ruleset = ruleset,
|
Ruleset = ruleset,
|
||||||
BaseDifficulty = new BeatmapDifficulty(),
|
BaseDifficulty = new BeatmapDifficulty(),
|
||||||
OnlineInfo = new BeatmapOnlineInfo(),
|
OnlineInfo = new APIBeatmap
|
||||||
Metrics = new BeatmapMetrics
|
{
|
||||||
|
FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
},
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,8 +230,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
OnlineInfo = new APIBeatmapSet
|
OnlineInfo = new APIBeatmapSet
|
||||||
{
|
{
|
||||||
Covers = new BeatmapSetOnlineCovers(),
|
Covers = new BeatmapSetOnlineCovers(),
|
||||||
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||||
},
|
},
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
|
||||||
Beatmaps = beatmaps
|
Beatmaps = beatmaps
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -288,12 +290,14 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
OverallDifficulty = 3.5f,
|
OverallDifficulty = 3.5f,
|
||||||
},
|
},
|
||||||
OnlineInfo = new BeatmapOnlineInfo(),
|
OnlineInfo = new APIBeatmap
|
||||||
Metrics = new BeatmapMetrics
|
{
|
||||||
|
FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
|
||||||
},
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,8 +320,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
HasVideo = true,
|
HasVideo = true,
|
||||||
HasStoryboard = true,
|
HasStoryboard = true,
|
||||||
Covers = new BeatmapSetOnlineCovers(),
|
Covers = new BeatmapSetOnlineCovers(),
|
||||||
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||||
},
|
},
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
|
||||||
Beatmaps = beatmaps,
|
Beatmaps = beatmaps,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -39,27 +39,30 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
var secondSet = createSet();
|
var secondSet = createSet();
|
||||||
|
|
||||||
AddStep("set first set", () => details.BeatmapSet = firstSet);
|
AddStep("set first set", () => details.BeatmapSet = firstSet);
|
||||||
AddAssert("ratings set", () => details.Ratings.Metrics == firstSet.Metrics);
|
AddAssert("ratings set", () => details.Ratings.Ratings == firstSet.Ratings);
|
||||||
|
|
||||||
AddStep("set second set", () => details.BeatmapSet = secondSet);
|
AddStep("set second set", () => details.BeatmapSet = secondSet);
|
||||||
AddAssert("ratings set", () => details.Ratings.Metrics == secondSet.Metrics);
|
AddAssert("ratings set", () => details.Ratings.Ratings == secondSet.Ratings);
|
||||||
|
|
||||||
static BeatmapSetInfo createSet() => new BeatmapSetInfo
|
static BeatmapSetInfo createSet() => new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray() },
|
|
||||||
Beatmaps = new List<BeatmapInfo>
|
Beatmaps = new List<BeatmapInfo>
|
||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapMetrics
|
OnlineInfo = new APIBeatmap
|
||||||
|
{
|
||||||
|
FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
OnlineInfo = new APIBeatmapSet
|
OnlineInfo = new APIBeatmapSet
|
||||||
{
|
{
|
||||||
|
Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray(),
|
||||||
Status = BeatmapSetOnlineStatus.Ranked
|
Status = BeatmapSetOnlineStatus.Ranked
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Testing;
|
|||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.BeatmapSet;
|
using osu.Game.Overlays.BeatmapSet;
|
||||||
using osu.Game.Screens.Select.Details;
|
using osu.Game.Screens.Select.Details;
|
||||||
@ -59,18 +60,21 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
var secondBeatmap = createBeatmap();
|
var secondBeatmap = createBeatmap();
|
||||||
|
|
||||||
AddStep("set first set", () => successRate.BeatmapInfo = firstBeatmap);
|
AddStep("set first set", () => successRate.BeatmapInfo = firstBeatmap);
|
||||||
AddAssert("ratings set", () => successRate.Graph.Metrics == firstBeatmap.Metrics);
|
AddAssert("ratings set", () => successRate.Graph.FailTimes == firstBeatmap.FailTimes);
|
||||||
|
|
||||||
AddStep("set second set", () => successRate.BeatmapInfo = secondBeatmap);
|
AddStep("set second set", () => successRate.BeatmapInfo = secondBeatmap);
|
||||||
AddAssert("ratings set", () => successRate.Graph.Metrics == secondBeatmap.Metrics);
|
AddAssert("ratings set", () => successRate.Graph.FailTimes == secondBeatmap.FailTimes);
|
||||||
|
|
||||||
static BeatmapInfo createBeatmap() => new BeatmapInfo
|
static BeatmapInfo createBeatmap() => new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapMetrics
|
OnlineInfo = new APIBeatmap
|
||||||
|
{
|
||||||
|
FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,13 +83,16 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
|
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapMetrics
|
OnlineInfo = new APIBeatmap
|
||||||
|
{
|
||||||
|
FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).ToArray(),
|
Fails = Enumerable.Range(1, 100).ToArray(),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
AddAssert("graph max values correct",
|
|
||||||
() => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 100));
|
AddAssert("graph max values correct", () => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -93,11 +100,13 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
|
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapMetrics()
|
OnlineInfo = new APIBeatmap
|
||||||
|
{
|
||||||
|
FailTimes = new APIFailTimes(),
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("graph max values correct",
|
AddAssert("graph max values correct", () => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 0));
|
||||||
() => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GraphExposingSuccessRate : SuccessRate
|
private class GraphExposingSuccessRate : SuccessRate
|
||||||
|
@ -6,6 +6,7 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.SongSelect
|
namespace osu.Game.Tests.Visual.SongSelect
|
||||||
@ -34,7 +35,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
OnlineInfo = new APIBeatmapSet
|
||||||
|
{
|
||||||
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Version = "All Metrics",
|
Version = "All Metrics",
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
@ -50,11 +54,14 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
ApproachRate = 3.5f,
|
ApproachRate = 3.5f,
|
||||||
},
|
},
|
||||||
StarDifficulty = 5.3f,
|
StarDifficulty = 5.3f,
|
||||||
Metrics = new BeatmapMetrics
|
OnlineInfo = new APIBeatmap
|
||||||
|
{
|
||||||
|
FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
},
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +72,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
OnlineInfo = new APIBeatmapSet
|
||||||
|
{
|
||||||
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Version = "All Metrics",
|
Version = "All Metrics",
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
@ -80,11 +90,14 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
ApproachRate = 3.5f,
|
ApproachRate = 3.5f,
|
||||||
},
|
},
|
||||||
StarDifficulty = 5.3f,
|
StarDifficulty = 5.3f,
|
||||||
Metrics = new BeatmapMetrics
|
OnlineInfo = new APIBeatmap
|
||||||
|
{
|
||||||
|
FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
},
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +108,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
OnlineInfo = new APIBeatmapSet
|
||||||
|
{
|
||||||
|
Ratings = Enumerable.Range(0, 11).ToArray(),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Version = "Only Ratings",
|
Version = "Only Ratings",
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
@ -133,11 +149,14 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
ApproachRate = 7,
|
ApproachRate = 7,
|
||||||
},
|
},
|
||||||
StarDifficulty = 2.91f,
|
StarDifficulty = 2.91f,
|
||||||
Metrics = new BeatmapMetrics
|
OnlineInfo = new APIBeatmap
|
||||||
|
{
|
||||||
|
FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||||
},
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Platform;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
using osu.Game.Tournament.IO;
|
using osu.Game.Tournament.IO;
|
||||||
@ -160,7 +161,7 @@ namespace osu.Game.Tournament.Tests
|
|||||||
Artist = "Test Artist",
|
Artist = "Test Artist",
|
||||||
ID = RNG.Next(0, 1000000)
|
ID = RNG.Next(0, 1000000)
|
||||||
},
|
},
|
||||||
OnlineInfo = new BeatmapOnlineInfo(),
|
OnlineInfo = new APIBeatmap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();
|
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();
|
||||||
|
@ -9,7 +9,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Beatmap metrics based on accumulated online data from community plays.
|
/// Beatmap metrics based on accumulated online data from community plays.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BeatmapMetrics
|
public class APIFailTimes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Points of failure on a relative time scale (usually 0..100).
|
/// Points of failure on a relative time scale (usually 0..100).
|
@ -9,6 +9,7 @@ using System.Linq;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey, IBeatmapInfo
|
public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey, IBeatmapInfo, IBeatmapOnlineInfo
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
@ -47,10 +48,7 @@ namespace osu.Game.Beatmaps
|
|||||||
public BeatmapDifficulty BaseDifficulty { get; set; }
|
public BeatmapDifficulty BaseDifficulty { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public BeatmapMetrics Metrics { get; set; }
|
public APIBeatmap OnlineInfo { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public BeatmapOnlineInfo OnlineInfo { get; set; }
|
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int? MaxCombo { get; set; }
|
public int? MaxCombo { get; set; }
|
||||||
@ -184,13 +182,43 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
#region Implementation of IBeatmapInfo
|
#region Implementation of IBeatmapInfo
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
string IBeatmapInfo.DifficultyName => Version;
|
string IBeatmapInfo.DifficultyName => Version;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
|
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => BaseDifficulty;
|
IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => BaseDifficulty;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
IBeatmapSetInfo IBeatmapInfo.BeatmapSet => BeatmapSet;
|
IBeatmapSetInfo IBeatmapInfo.BeatmapSet => BeatmapSet;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;
|
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
double IBeatmapInfo.StarRating => StarDifficulty;
|
double IBeatmapInfo.StarRating => StarDifficulty;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Implementation of IBeatmapOnlineInfo
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public int CircleCount => OnlineInfo.CircleCount;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public int SliderCount => OnlineInfo.SliderCount;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public int PlayCount => OnlineInfo.PlayCount;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public int PassCount => OnlineInfo.PassCount;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public APIFailTimes FailTimes => OnlineInfo.FailTimes;
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,6 @@ namespace osu.Game.Beatmaps
|
|||||||
[NotMapped]
|
[NotMapped]
|
||||||
public APIBeatmapSet OnlineInfo { get; set; }
|
public APIBeatmapSet OnlineInfo { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public BeatmapSetMetrics Metrics { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum star difficulty of all beatmaps in this set.
|
/// The maximum star difficulty of all beatmaps in this set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -172,6 +169,10 @@ namespace osu.Game.Beatmaps
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int? TrackId => OnlineInfo?.TrackId;
|
public int? TrackId => OnlineInfo?.TrackId;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
[JsonIgnore]
|
||||||
|
public int[] Ratings => OnlineInfo?.Ratings;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
// 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,31 +1,40 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Beatmap info retrieved for previewing locally without having the beatmap downloaded.
|
/// Beatmap info retrieved for previewing locally.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BeatmapOnlineInfo
|
public interface IBeatmapOnlineInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The max combo of this beatmap.
|
||||||
|
/// </summary>
|
||||||
|
int? MaxCombo { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of circles in this beatmap.
|
/// The amount of circles in this beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CircleCount { get; set; }
|
public int CircleCount { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of sliders in this beatmap.
|
/// The amount of sliders in this beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int SliderCount { get; set; }
|
public int SliderCount { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of plays this beatmap has.
|
/// The amount of plays this beatmap has.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int PlayCount { get; set; }
|
public int PlayCount { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of passes this beatmap has.
|
/// The amount of passes this beatmap has.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int PassCount { get; set; }
|
public int PassCount { get; }
|
||||||
|
|
||||||
|
APIFailTimes? FailTimes { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -97,5 +97,10 @@ namespace osu.Game.Beatmaps
|
|||||||
/// Non-null only if the track is linked to a featured artist track entry.
|
/// Non-null only if the track is linked to a featured artist track entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int? TrackId { get; }
|
int? TrackId { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Total vote counts of user ratings on a scale of 0..10 where 0 is unused (probably will be fixed at API?).
|
||||||
|
/// </summary>
|
||||||
|
int[]? Ratings { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ using osu.Game.Rulesets;
|
|||||||
|
|
||||||
namespace osu.Game.Online.API.Requests.Responses
|
namespace osu.Game.Online.API.Requests.Responses
|
||||||
{
|
{
|
||||||
public class APIBeatmap : IBeatmapInfo
|
public class APIBeatmap : IBeatmapInfo, IBeatmapOnlineInfo
|
||||||
{
|
{
|
||||||
[JsonProperty(@"id")]
|
[JsonProperty(@"id")]
|
||||||
public int OnlineID { get; set; }
|
public int OnlineID { get; set; }
|
||||||
@ -31,10 +31,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
public APIBeatmapSet? BeatmapSet { get; set; }
|
public APIBeatmapSet? BeatmapSet { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"playcount")]
|
[JsonProperty(@"playcount")]
|
||||||
private int playCount { get; set; }
|
public int PlayCount { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"passcount")]
|
[JsonProperty(@"passcount")]
|
||||||
private int passCount { get; set; }
|
public int PassCount { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"mode_int")]
|
[JsonProperty(@"mode_int")]
|
||||||
public int RulesetID { get; set; }
|
public int RulesetID { get; set; }
|
||||||
@ -60,19 +60,21 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
private double lengthInSeconds { get; set; }
|
private double lengthInSeconds { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"count_circles")]
|
[JsonProperty(@"count_circles")]
|
||||||
private int circleCount { get; set; }
|
public int CircleCount { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"count_sliders")]
|
[JsonProperty(@"count_sliders")]
|
||||||
private int sliderCount { get; set; }
|
public int SliderCount { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"version")]
|
[JsonProperty(@"version")]
|
||||||
public string DifficultyName { get; set; } = string.Empty;
|
public string DifficultyName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[JsonProperty(@"failtimes")]
|
[JsonProperty(@"failtimes")]
|
||||||
private BeatmapMetrics? metrics { get; set; }
|
public APIFailTimes? FailTimes { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"max_combo")]
|
[JsonProperty(@"max_combo")]
|
||||||
private int? maxCombo { get; set; }
|
public int? MaxCombo { get; set; }
|
||||||
|
|
||||||
|
public double BPM { get; set; }
|
||||||
|
|
||||||
public virtual BeatmapInfo ToBeatmapInfo(RulesetStore rulesets)
|
public virtual BeatmapInfo ToBeatmapInfo(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
@ -90,8 +92,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
Status = Status,
|
Status = Status,
|
||||||
MD5Hash = Checksum,
|
MD5Hash = Checksum,
|
||||||
BeatmapSet = set,
|
BeatmapSet = set,
|
||||||
Metrics = metrics,
|
MaxCombo = MaxCombo,
|
||||||
MaxCombo = maxCombo,
|
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
BaseDifficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
DrainRate = drainRate,
|
DrainRate = drainRate,
|
||||||
@ -99,13 +100,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
ApproachRate = approachRate,
|
ApproachRate = approachRate,
|
||||||
OverallDifficulty = overallDifficulty,
|
OverallDifficulty = overallDifficulty,
|
||||||
},
|
},
|
||||||
OnlineInfo = new BeatmapOnlineInfo
|
OnlineInfo = this,
|
||||||
{
|
|
||||||
PlayCount = playCount,
|
|
||||||
PassCount = passCount,
|
|
||||||
CircleCount = circleCount,
|
|
||||||
SliderCount = sliderCount,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +122,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
|
|
||||||
public IRulesetInfo Ruleset => new RulesetInfo { ID = RulesetID };
|
public IRulesetInfo Ruleset => new RulesetInfo { ID = RulesetID };
|
||||||
|
|
||||||
public double BPM => throw new NotImplementedException();
|
[JsonIgnore]
|
||||||
public string Hash => throw new NotImplementedException();
|
public string Hash => throw new NotImplementedException();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -58,8 +58,8 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty(@"last_updated")]
|
[JsonProperty(@"last_updated")]
|
||||||
public DateTimeOffset? LastUpdated { get; set; }
|
public DateTimeOffset? LastUpdated { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"ratings")]
|
[JsonProperty("ratings")]
|
||||||
private int[] ratings { get; set; } = Array.Empty<int>();
|
public int[] Ratings { get; set; } = Array.Empty<int>();
|
||||||
|
|
||||||
[JsonProperty(@"track_id")]
|
[JsonProperty(@"track_id")]
|
||||||
public int? TrackId { get; set; }
|
public int? TrackId { get; set; }
|
||||||
@ -128,7 +128,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
OnlineBeatmapSetID = OnlineID,
|
OnlineBeatmapSetID = OnlineID,
|
||||||
Metadata = metadata,
|
Metadata = metadata,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
Metrics = new BeatmapSetMetrics { Ratings = ratings },
|
|
||||||
OnlineInfo = this
|
OnlineInfo = this
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
private void updateDisplay()
|
private void updateDisplay()
|
||||||
{
|
{
|
||||||
Ratings.Metrics = BeatmapSet?.Metrics;
|
Ratings.Ratings = BeatmapSet?.Ratings;
|
||||||
ratingBox.Alpha = BeatmapSet?.OnlineInfo?.Status > 0 ? 1 : 0;
|
ratingBox.Alpha = BeatmapSet?.OnlineInfo?.Status > 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
successRate.Length = rate;
|
successRate.Length = rate;
|
||||||
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
|
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
|
||||||
|
|
||||||
Graph.Metrics = beatmapInfo?.Metrics;
|
Graph.FailTimes = beatmapInfo?.FailTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuccessRate()
|
public SuccessRate()
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Select
|
|||||||
private const float transition_duration = 250;
|
private const float transition_duration = 250;
|
||||||
|
|
||||||
private readonly AdvancedStats advanced;
|
private readonly AdvancedStats advanced;
|
||||||
private readonly UserRatings ratings;
|
private readonly UserRatings ratingsDisplay;
|
||||||
private readonly MetadataSection description, source, tags;
|
private readonly MetadataSection description, source, tags;
|
||||||
private readonly Container failRetryContainer;
|
private readonly Container failRetryContainer;
|
||||||
private readonly FailRetryGraph failRetryGraph;
|
private readonly FailRetryGraph failRetryGraph;
|
||||||
@ -43,6 +43,10 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private BeatmapInfo beatmapInfo;
|
private BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
|
private APIFailTimes failTimes;
|
||||||
|
|
||||||
|
private int[] ratings;
|
||||||
|
|
||||||
public BeatmapInfo BeatmapInfo
|
public BeatmapInfo BeatmapInfo
|
||||||
{
|
{
|
||||||
get => beatmapInfo;
|
get => beatmapInfo;
|
||||||
@ -52,6 +56,9 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
beatmapInfo = value;
|
beatmapInfo = value;
|
||||||
|
|
||||||
|
failTimes = beatmapInfo?.OnlineInfo?.FailTimes;
|
||||||
|
ratings = beatmapInfo?.BeatmapSet?.Ratings;
|
||||||
|
|
||||||
Scheduler.AddOnce(updateStatistics);
|
Scheduler.AddOnce(updateStatistics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +117,7 @@ namespace osu.Game.Screens.Select
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 134,
|
Height = 134,
|
||||||
Padding = new MarginPadding { Horizontal = spacing, Top = spacing },
|
Padding = new MarginPadding { Horizontal = spacing, Top = spacing },
|
||||||
Child = ratings = new UserRatings
|
Child = ratingsDisplay = new UserRatings
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
@ -176,7 +183,7 @@ namespace osu.Game.Screens.Select
|
|||||||
tags.Text = BeatmapInfo?.Metadata?.Tags;
|
tags.Text = BeatmapInfo?.Metadata?.Tags;
|
||||||
|
|
||||||
// metrics may have been previously fetched
|
// metrics may have been previously fetched
|
||||||
if (BeatmapInfo?.BeatmapSet?.Metrics != null && BeatmapInfo?.Metrics != null)
|
if (ratings != null && failTimes != null)
|
||||||
{
|
{
|
||||||
updateMetrics();
|
updateMetrics();
|
||||||
return;
|
return;
|
||||||
@ -201,14 +208,8 @@ namespace osu.Game.Screens.Select
|
|||||||
// the beatmap has been changed since we started the lookup.
|
// the beatmap has been changed since we started the lookup.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var b = res.ToBeatmapInfo(rulesets);
|
ratings = res.BeatmapSet?.Ratings;
|
||||||
|
failTimes = res.FailTimes;
|
||||||
if (requestedBeatmap.BeatmapSet == null)
|
|
||||||
requestedBeatmap.BeatmapSet = b.BeatmapSet;
|
|
||||||
else
|
|
||||||
requestedBeatmap.BeatmapSet.Metrics = b.BeatmapSet.Metrics;
|
|
||||||
|
|
||||||
requestedBeatmap.Metrics = b.Metrics;
|
|
||||||
|
|
||||||
updateMetrics();
|
updateMetrics();
|
||||||
});
|
});
|
||||||
@ -232,29 +233,28 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void updateMetrics()
|
private void updateMetrics()
|
||||||
{
|
{
|
||||||
var hasRatings = beatmapInfo?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false;
|
var hasMetrics = (failTimes?.Retries?.Any() ?? false) || (failTimes?.Fails?.Any() ?? false);
|
||||||
var hasRetriesFails = (beatmapInfo?.Metrics?.Retries?.Any() ?? false) || (beatmapInfo?.Metrics?.Fails?.Any() ?? false);
|
|
||||||
|
|
||||||
if (hasRatings)
|
if (ratings?.Any() ?? false)
|
||||||
{
|
{
|
||||||
ratings.Metrics = beatmapInfo.BeatmapSet.Metrics;
|
ratingsDisplay.Ratings = ratings;
|
||||||
ratings.FadeIn(transition_duration);
|
ratingsDisplay.FadeIn(transition_duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// loading or just has no data server-side.
|
// loading or just has no data server-side.
|
||||||
ratings.Metrics = new BeatmapSetMetrics { Ratings = new int[10] };
|
ratingsDisplay.Ratings = new int[10];
|
||||||
ratings.FadeTo(0.25f, transition_duration);
|
ratingsDisplay.FadeTo(0.25f, transition_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasRetriesFails)
|
if (hasMetrics)
|
||||||
{
|
{
|
||||||
failRetryGraph.Metrics = beatmapInfo.Metrics;
|
failRetryGraph.FailTimes = failTimes;
|
||||||
failRetryContainer.FadeIn(transition_duration);
|
failRetryContainer.FadeIn(transition_duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
failRetryGraph.Metrics = new BeatmapMetrics
|
failRetryGraph.FailTimes = new APIFailTimes
|
||||||
{
|
{
|
||||||
Fails = new int[100],
|
Fails = new int[100],
|
||||||
Retries = new int[100],
|
Retries = new int[100],
|
||||||
|
@ -16,19 +16,19 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
{
|
{
|
||||||
private readonly BarGraph retryGraph, failGraph;
|
private readonly BarGraph retryGraph, failGraph;
|
||||||
|
|
||||||
private BeatmapMetrics metrics;
|
private APIFailTimes failTimes;
|
||||||
|
|
||||||
public BeatmapMetrics Metrics
|
public APIFailTimes FailTimes
|
||||||
{
|
{
|
||||||
get => metrics;
|
get => failTimes;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == metrics) return;
|
if (value == failTimes) return;
|
||||||
|
|
||||||
metrics = value;
|
failTimes = value;
|
||||||
|
|
||||||
var retries = Metrics?.Retries ?? Array.Empty<int>();
|
var retries = FailTimes?.Retries ?? Array.Empty<int>();
|
||||||
var fails = Metrics?.Fails ?? Array.Empty<int>();
|
var fails = FailTimes?.Fails ?? Array.Empty<int>();
|
||||||
var retriesAndFails = sumRetriesAndFails(retries, fails);
|
var retriesAndFails = sumRetriesAndFails(retries, fails);
|
||||||
|
|
||||||
float maxValue = retriesAndFails.Any() ? retriesAndFails.Max() : 0;
|
float maxValue = retriesAndFails.Any() ? retriesAndFails.Max() : 0;
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
// 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.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Details
|
namespace osu.Game.Screens.Select.Details
|
||||||
@ -22,20 +21,20 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
private readonly Container graphContainer;
|
private readonly Container graphContainer;
|
||||||
private readonly BarGraph graph;
|
private readonly BarGraph graph;
|
||||||
|
|
||||||
private BeatmapSetMetrics metrics;
|
private int[] ratings;
|
||||||
|
|
||||||
public BeatmapSetMetrics Metrics
|
public int[] Ratings
|
||||||
{
|
{
|
||||||
get => metrics;
|
get => ratings;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == metrics) return;
|
if (value == ratings) return;
|
||||||
|
|
||||||
metrics = value;
|
ratings = value;
|
||||||
|
|
||||||
const int rating_range = 10;
|
const int rating_range = 10;
|
||||||
|
|
||||||
if (metrics == null)
|
if (ratings == null)
|
||||||
{
|
{
|
||||||
negativeRatings.Text = 0.ToLocalisableString(@"N0");
|
negativeRatings.Text = 0.ToLocalisableString(@"N0");
|
||||||
positiveRatings.Text = 0.ToLocalisableString(@"N0");
|
positiveRatings.Text = 0.ToLocalisableString(@"N0");
|
||||||
@ -44,15 +43,15 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var ratings = Metrics.Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
|
var usableRange = Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
|
||||||
|
|
||||||
var negativeCount = ratings.Take(rating_range / 2).Sum();
|
var negativeCount = usableRange.Take(rating_range / 2).Sum();
|
||||||
var totalCount = ratings.Sum();
|
var totalCount = usableRange.Sum();
|
||||||
|
|
||||||
negativeRatings.Text = negativeCount.ToLocalisableString(@"N0");
|
negativeRatings.Text = negativeCount.ToLocalisableString(@"N0");
|
||||||
positiveRatings.Text = (totalCount - negativeCount).ToLocalisableString(@"N0");
|
positiveRatings.Text = (totalCount - negativeCount).ToLocalisableString(@"N0");
|
||||||
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
|
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
|
||||||
graph.Values = ratings.Take(rating_range).Select(r => (float)r);
|
graph.Values = usableRange.Take(rating_range).Select(r => (float)r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
|
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
|
||||||
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
|
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
|
||||||
BeatmapInfo.Length = 75000;
|
BeatmapInfo.Length = 75000;
|
||||||
BeatmapInfo.OnlineInfo = new BeatmapOnlineInfo();
|
BeatmapInfo.OnlineInfo = new APIBeatmap();
|
||||||
BeatmapInfo.BeatmapSet.OnlineInfo = new APIBeatmapSet
|
BeatmapInfo.BeatmapSet.OnlineInfo = new APIBeatmapSet
|
||||||
{
|
{
|
||||||
Status = BeatmapSetOnlineStatus.Ranked,
|
Status = BeatmapSetOnlineStatus.Ranked,
|
||||||
|
Reference in New Issue
Block a user