1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 09:22:54 +08:00

Implement MatchBeatmapPanel

This commit is contained in:
Andrei Zavatski 2019-08-08 07:08:51 +03:00
parent 94206f0aaa
commit ffed642929
3 changed files with 67 additions and 0 deletions

View File

@ -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))]

View File

@ -0,0 +1,49 @@
// 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 =>
{
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);
}
}
}

View File

@ -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);