mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +08:00
Remove GetBeatmapDetailsRequest
This commit is contained in:
parent
0a79b444d9
commit
583bb53f53
@ -1,20 +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 osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
|
||||||
{
|
|
||||||
public class GetBeatmapDetailsRequest : APIRequest<APIBeatmapMetrics>
|
|
||||||
{
|
|
||||||
private readonly BeatmapInfo beatmap;
|
|
||||||
|
|
||||||
public GetBeatmapDetailsRequest(BeatmapInfo beatmap)
|
|
||||||
{
|
|
||||||
this.beatmap = beatmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override string Target => $@"beatmaps/{beatmap.OnlineBeatmapID}";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +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;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests.Responses
|
|
||||||
{
|
|
||||||
public class APIBeatmapMetrics : BeatmapMetrics
|
|
||||||
{
|
|
||||||
//the online API returns some metrics as a nested object.
|
|
||||||
[JsonProperty(@"failtimes")]
|
|
||||||
private BeatmapMetrics failTimes
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Fails = value.Fails;
|
|
||||||
Retries = value.Retries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] Ratings { get; set; } = Array.Empty<int>();
|
|
||||||
|
|
||||||
//and other metrics in the beatmap set.
|
|
||||||
// Todo: What
|
|
||||||
[JsonProperty(@"beatmapset")]
|
|
||||||
private BeatmapSetMetrics beatmapSet
|
|
||||||
{
|
|
||||||
set => Ratings = value.Ratings;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,6 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -18,7 +17,8 @@ using osu.Game.Screens.Select.Details;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
@ -41,6 +41,9 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private ScheduledDelegate pendingBeatmapSwitch;
|
private ScheduledDelegate pendingBeatmapSwitch;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RulesetStore rulesets { get; set; }
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmap;
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo Beatmap
|
||||||
@ -182,10 +185,9 @@ namespace osu.Game.Screens.Select
|
|||||||
tags.Text = Beatmap?.Metadata?.Tags;
|
tags.Text = Beatmap?.Metadata?.Tags;
|
||||||
|
|
||||||
// metrics may have been previously fetched
|
// metrics may have been previously fetched
|
||||||
// Todo:
|
|
||||||
if (Beatmap?.BeatmapSet?.Metrics != null)
|
if (Beatmap?.BeatmapSet?.Metrics != null)
|
||||||
{
|
{
|
||||||
updateMetrics(new APIBeatmapMetrics { Ratings = Beatmap.BeatmapSet.Metrics.Ratings });
|
updateMetrics(Beatmap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,15 +195,19 @@ namespace osu.Game.Screens.Select
|
|||||||
if (Beatmap?.OnlineBeatmapID != null)
|
if (Beatmap?.OnlineBeatmapID != null)
|
||||||
{
|
{
|
||||||
var requestedBeatmap = Beatmap;
|
var requestedBeatmap = Beatmap;
|
||||||
var lookup = new GetBeatmapDetailsRequest(requestedBeatmap);
|
var lookup = new GetBeatmapRequest(requestedBeatmap);
|
||||||
lookup.Success += res =>
|
lookup.Success += res =>
|
||||||
{
|
{
|
||||||
if (beatmap != requestedBeatmap)
|
if (beatmap != requestedBeatmap)
|
||||||
//the beatmap has been changed since we started the lookup.
|
//the beatmap has been changed since we started the lookup.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
requestedBeatmap.Metrics = res;
|
var b = res.ToBeatmap(rulesets);
|
||||||
Schedule(() => updateMetrics(res));
|
|
||||||
|
requestedBeatmap.BeatmapSet.Metrics = b.BeatmapSet.Metrics;
|
||||||
|
requestedBeatmap.Metrics = b.Metrics;
|
||||||
|
|
||||||
|
Schedule(() => updateMetrics(requestedBeatmap));
|
||||||
};
|
};
|
||||||
lookup.Failure += e => Schedule(() => updateMetrics());
|
lookup.Failure += e => Schedule(() => updateMetrics());
|
||||||
api.Queue(lookup);
|
api.Queue(lookup);
|
||||||
@ -212,14 +218,14 @@ namespace osu.Game.Screens.Select
|
|||||||
updateMetrics();
|
updateMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMetrics(APIBeatmapMetrics metrics = null)
|
private void updateMetrics(BeatmapInfo beatmap = null)
|
||||||
{
|
{
|
||||||
var hasRatings = metrics?.Ratings?.Any() ?? false;
|
var hasRatings = beatmap?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false;
|
||||||
var hasRetriesFails = (metrics?.Retries?.Any() ?? false) && (metrics.Fails?.Any() ?? false);
|
var hasRetriesFails = (beatmap?.Metrics?.Retries?.Any() ?? false) && (beatmap.Metrics.Fails?.Any() ?? false);
|
||||||
|
|
||||||
if (hasRatings)
|
if (hasRatings)
|
||||||
{
|
{
|
||||||
ratings.Metrics = new BeatmapSetMetrics { Ratings = metrics.Ratings };
|
ratings.Metrics = beatmap.BeatmapSet.Metrics;
|
||||||
ratingsContainer.FadeIn(transition_duration);
|
ratingsContainer.FadeIn(transition_duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -230,7 +236,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
if (hasRetriesFails)
|
if (hasRetriesFails)
|
||||||
{
|
{
|
||||||
failRetryGraph.Metrics = metrics;
|
failRetryGraph.Metrics = beatmap.Metrics;
|
||||||
failRetryContainer.FadeIn(transition_duration);
|
failRetryContainer.FadeIn(transition_duration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user