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;
|
2021-08-03 17:05:43 +08:00
|
|
|
using osu.Framework.Input.Bindings;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Framework.Screens;
|
2021-08-03 17:05:43 +08:00
|
|
|
using osu.Game.Input.Bindings;
|
2020-12-20 23:04:06 +08:00
|
|
|
using osu.Game.Online.API;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
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-08-03 17:05:43 +08:00
|
|
|
public class BeatmapSelectionControl : RoomSubScreenComposite, IKeyBindingHandler<GlobalAction>
|
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,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
beatmapPanelContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y
|
|
|
|
},
|
|
|
|
selectButton = new PurpleTriangleButton
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 40,
|
|
|
|
Text = "Select beatmap",
|
2020-12-25 12:38:11 +08:00
|
|
|
Action = () => matchSubScreen.Push(new MultiplayerMatchSongSelect()),
|
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-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
|
|
|
}
|
2021-08-03 17:05:43 +08:00
|
|
|
|
|
|
|
public bool OnPressed(GlobalAction action)
|
|
|
|
{
|
|
|
|
// only handle keyboard input if there is no current selection.
|
|
|
|
if (SelectedItem.Value != null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case GlobalAction.Select:
|
|
|
|
selectButton.Click();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnReleased(GlobalAction action)
|
|
|
|
{
|
|
|
|
}
|
2020-12-20 23:04:06 +08:00
|
|
|
}
|
|
|
|
}
|