From ffed642929e7ec23ba8e3c60c252a9d0522c9327 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 8 Aug 2019 07:08:51 +0300 Subject: [PATCH] Implement MatchBeatmapPanel --- .../Screens/Multi/Match/Components/Header.cs | 16 ++++++ .../Match/Components/MatchBeatmapPanel.cs | 49 +++++++++++++++++++ .../Screens/Multi/Match/MatchSubScreen.cs | 2 + 3 files changed, 67 insertions(+) create mode 100644 osu.Game/Screens/Multi/Match/Components/MatchBeatmapPanel.cs diff --git a/osu.Game/Screens/Multi/Match/Components/Header.cs b/osu.Game/Screens/Multi/Match/Components/Header.cs index 73994fa369..629a19e5e8 100644 --- a/osu.Game/Screens/Multi/Match/Components/Header.cs +++ b/osu.Game/Screens/Multi/Match/Components/Header.cs @@ -29,6 +29,10 @@ namespace osu.Game.Screens.Multi.Match.Components public Action RequestBeatmapSelection; + public BindableBool ShowBeatmapPanel = new BindableBool(); + + private MatchBeatmapPanel beatmapPanel; + public Header() { RelativeSizeAxes = Axes.X; @@ -55,6 +59,12 @@ namespace osu.Game.Screens.Multi.Match.Components RelativeSizeAxes = Axes.Both, Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.4f), Color4.Black.Opacity(0.6f)), }, + beatmapPanel = new MatchBeatmapPanel + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Margin = new MarginPadding { Right = 100 }, + } } }, new Box @@ -114,6 +124,12 @@ namespace osu.Game.Screens.Multi.Match.Components beatmapButton.Action = () => RequestBeatmapSelection?.Invoke(); } + protected override void LoadComplete() + { + base.LoadComplete(); + ShowBeatmapPanel.BindValueChanged(value => beatmapPanel.FadeTo(value.NewValue ? 1 : 0, 200, Easing.OutQuint), true); + } + private class BeatmapSelectButton : HeaderButton { [Resolved(typeof(Room), nameof(Room.RoomID))] diff --git a/osu.Game/Screens/Multi/Match/Components/MatchBeatmapPanel.cs b/osu.Game/Screens/Multi/Match/Components/MatchBeatmapPanel.cs new file mode 100644 index 0000000000..916115f11b --- /dev/null +++ b/osu.Game/Screens/Multi/Match/Components/MatchBeatmapPanel.cs @@ -0,0 +1,49 @@ +// Copyright (c) ppy Pty Ltd . 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 => + { + var id = item.NewValue?.Beatmap.OnlineBeatmapID ?? 0; + + if (id != 0) + { + request?.Cancel(); + request = new GetBeatmapSetRequest(id, BeatmapSetLookupType.BeatmapId); + request.Success += beatmap => + { + ClearInternal(); + AddInternal(new DirectGridPanel(beatmap.ToBeatmapSet(rulesets))); + }; + api.Queue(request); + } + }, true); + } + } +} diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index 5469d4c8c8..16c6b412fa 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -148,12 +148,14 @@ namespace osu.Game.Screens.Multi.Match if (tab.NewValue is SettingsMatchPage) { + header.ShowBeatmapPanel.Value = false; settings.Show(); info.FadeOut(fade_duration, Easing.OutQuint); bottomRow.FadeOut(fade_duration, Easing.OutQuint); } else { + header.ShowBeatmapPanel.Value = true; settings.Hide(); info.FadeIn(fade_duration, Easing.OutQuint); bottomRow.FadeIn(fade_duration, Easing.OutQuint);