From d22a9df1400d8416b9ae173b517b82e7c3a8395a Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Sat, 2 Dec 2017 09:47:20 +0100 Subject: [PATCH] Added new request for getting the beatmapset from only a difficulty map ID --- .../Online/API/Requests/GetBeatmapRequest.cs | 21 +++++++++++++++++++ osu.Game/Overlays/BeatmapSetOverlay.cs | 14 +++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 osu.Game/Online/API/Requests/GetBeatmapRequest.cs diff --git a/osu.Game/Online/API/Requests/GetBeatmapRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapRequest.cs new file mode 100644 index 0000000000..7a72402c1e --- /dev/null +++ b/osu.Game/Online/API/Requests/GetBeatmapRequest.cs @@ -0,0 +1,21 @@ +using osu.Game.Beatmaps; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.Online.API.Requests +{ + public class GetBeatmapRequest : APIRequest + { + private readonly int beatmapId; + + public GetBeatmapRequest(int beatmapId) + { + this.beatmapId = beatmapId; + } + + protected override string Target => $@"beatmaps/{beatmapId}"; + } +} diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 0d658b346e..17fbe907ca 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -139,6 +139,20 @@ namespace osu.Game.Overlays return true; } + public void ShowBeatmap(int beatmapId) + { + var req = new GetBeatmapRequest(beatmapId); + req.Success += res => + { + if (!res.OnlineBeatmapSetID.HasValue) + return; + + ShowBeatmapSet(res.OnlineBeatmapSetID.Value); + }; + + api.Queue(req); + } + public void ShowBeatmapSet(int beatmapSetId) { // todo: display the overlay while we are loading here. we need to support setting BeatmapSet to null for this to work.