2019-08-08 12:08:51 +08:00
|
|
|
|
// 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.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.API.Requests;
|
|
|
|
|
using osu.Game.Overlays.Direct;
|
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Multi.Match.Components
|
|
|
|
|
{
|
|
|
|
|
public class MatchBeatmapPanel : MultiplayerComposite
|
|
|
|
|
{
|
|
|
|
|
[Resolved]
|
|
|
|
|
private IAPIProvider api { get; set; }
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private RulesetStore rulesets { get; set; }
|
|
|
|
|
|
|
|
|
|
private GetBeatmapSetRequest request;
|
|
|
|
|
|
|
|
|
|
public MatchBeatmapPanel()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
CurrentItem.BindValueChanged(item =>
|
|
|
|
|
{
|
2019-08-08 17:04:44 +08:00
|
|
|
|
var onlineId = item.NewValue?.Beatmap.OnlineBeatmapID ?? 0;
|
2019-08-08 12:08:51 +08:00
|
|
|
|
|
2019-08-08 17:04:44 +08:00
|
|
|
|
if (onlineId != 0)
|
2019-08-08 12:08:51 +08:00
|
|
|
|
{
|
|
|
|
|
request?.Cancel();
|
2019-08-08 17:04:44 +08:00
|
|
|
|
request = new GetBeatmapSetRequest(onlineId, BeatmapSetLookupType.BeatmapId);
|
2019-08-08 12:08:51 +08:00
|
|
|
|
request.Success += beatmap =>
|
|
|
|
|
{
|
|
|
|
|
ClearInternal();
|
2019-08-08 17:01:33 +08:00
|
|
|
|
var panel = new DirectGridPanel(beatmap.ToBeatmapSet(rulesets));
|
|
|
|
|
LoadComponentAsync(panel, p => { AddInternal(panel); });
|
2019-08-08 12:08:51 +08:00
|
|
|
|
};
|
|
|
|
|
api.Queue(request);
|
|
|
|
|
}
|
|
|
|
|
}, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|