2020-12-20 23:04:06 +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.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Game.Online.API;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
2021-08-19 18:02:05 +08:00
|
|
|
using osuTK;
|
2020-12-20 23:04:06 +08:00
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-09-29 19:52:03 +08:00
|
|
|
public class BeatmapSelectionControl : OnlinePlayComposite
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
|
|
|
[Resolved]
|
2020-12-25 12:38:11 +08:00
|
|
|
private MultiplayerMatchSubScreen matchSubScreen { get; set; }
|
2020-12-20 23:04:06 +08:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private IAPIProvider api { get; set; }
|
|
|
|
|
|
|
|
private Container beatmapPanelContainer;
|
|
|
|
private Button selectButton;
|
|
|
|
|
|
|
|
public BeatmapSelectionControl()
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
InternalChild = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
2021-08-19 18:02:05 +08:00
|
|
|
Spacing = new Vector2(5),
|
2020-12-20 23:04:06 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
beatmapPanelContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y
|
|
|
|
},
|
|
|
|
selectButton = new PurpleTriangleButton
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 40,
|
|
|
|
Text = "Select beatmap",
|
2021-08-05 13:00:16 +08:00
|
|
|
Action = () =>
|
|
|
|
{
|
|
|
|
if (matchSubScreen.IsCurrentScreen())
|
2021-08-24 12:29:19 +08:00
|
|
|
matchSubScreen.Push(new MultiplayerMatchSongSelect(matchSubScreen.Room));
|
2021-08-05 13:00:16 +08:00
|
|
|
},
|
2020-12-20 23:04:06 +08:00
|
|
|
Alpha = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-02-17 20:42:22 +08:00
|
|
|
SelectedItem.BindValueChanged(_ => updateBeatmap(), true);
|
2020-12-20 23:04:06 +08:00
|
|
|
Host.BindValueChanged(host =>
|
|
|
|
{
|
|
|
|
if (RoomID.Value == null || host.NewValue?.Equals(api.LocalUser.Value) == true)
|
|
|
|
selectButton.Show();
|
|
|
|
else
|
|
|
|
selectButton.Hide();
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
2021-08-05 13:00:35 +08:00
|
|
|
public void BeginSelection() => selectButton.TriggerClick();
|
|
|
|
|
2021-02-16 20:32:35 +08:00
|
|
|
private void updateBeatmap()
|
2020-12-20 23:04:06 +08:00
|
|
|
{
|
2021-02-17 20:42:22 +08:00
|
|
|
if (SelectedItem.Value == null)
|
2020-12-20 23:04:06 +08:00
|
|
|
beatmapPanelContainer.Clear();
|
2021-02-16 18:02:16 +08:00
|
|
|
else
|
2021-02-17 20:42:22 +08:00
|
|
|
beatmapPanelContainer.Child = new DrawableRoomPlaylistItem(SelectedItem.Value, false, false);
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|