1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 20:32:55 +08:00

Remove BeatmapSelectionControl and inline at usage sites

This commit is contained in:
smoogipoo 2021-10-22 19:41:36 +09:00
parent db87e42d47
commit 95ab82fb58
4 changed files with 89 additions and 96 deletions

View File

@ -34,6 +34,8 @@ namespace osu.Game.Screens.OnlinePlay
{ {
public class DrawableRoomPlaylistItem : OsuRearrangeableListItem<PlaylistItem> public class DrawableRoomPlaylistItem : OsuRearrangeableListItem<PlaylistItem>
{ {
public const float HEIGHT = 50;
public Action<PlaylistItem> RequestDeletion; public Action<PlaylistItem> RequestDeletion;
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>(); public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
@ -135,7 +137,7 @@ namespace osu.Game.Screens.OnlinePlay
return maskingContainer = new Container return maskingContainer = new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = 50, Height = HEIGHT,
Masking = true, Masking = true,
CornerRadius = 10, CornerRadius = 10,
Children = new Drawable[] Children = new Drawable[]

View File

@ -1,87 +0,0 @@
// 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;
using osu.Game.Screens.OnlinePlay.Match.Components;
using osuTK;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{
public class BeatmapSelectionControl : OnlinePlayComposite
{
[Resolved]
private MultiplayerMatchSubScreen matchSubScreen { get; set; }
[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,
Spacing = new Vector2(5),
Children = new Drawable[]
{
beatmapPanelContainer = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
},
selectButton = new PurpleTriangleButton
{
RelativeSizeAxes = Axes.X,
Height = 40,
Text = "Select beatmap",
Action = () =>
{
if (matchSubScreen.IsCurrentScreen())
matchSubScreen.Push(new MultiplayerMatchSongSelect(matchSubScreen.Room));
},
Alpha = 0
}
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
SelectedItem.BindValueChanged(_ => updateBeatmap(), true);
Host.BindValueChanged(host =>
{
if (RoomID.Value == null || host.NewValue?.Equals(api.LocalUser.Value) == true)
selectButton.Show();
else
selectButton.Hide();
}, true);
}
public void BeginSelection() => selectButton.TriggerClick();
private void updateBeatmap()
{
if (SelectedItem.Value == null)
beatmapPanelContainer.Clear();
else
beatmapPanelContainer.Child = new DrawableRoomPlaylistItem(SelectedItem.Value, false, false);
}
}
}

View File

@ -11,6 +11,7 @@ using osu.Framework.Extensions.ExceptionExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
@ -68,9 +69,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
private OsuSpriteText typeLabel; private OsuSpriteText typeLabel;
private LoadingLayer loadingLayer; private LoadingLayer loadingLayer;
private BeatmapSelectionControl initialBeatmapControl;
public void SelectBeatmap() => initialBeatmapControl.BeginSelection(); public void SelectBeatmap()
{
if (matchSubScreen.IsCurrentScreen())
matchSubScreen.Push(new MultiplayerMatchSongSelect(matchSubScreen.Room));
}
[Resolved]
private MultiplayerMatchSubScreen matchSubScreen { get; set; }
[Resolved] [Resolved]
private IRoomManager manager { get; set; } private IRoomManager manager { get; set; }
@ -94,6 +101,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
private readonly Room room; private readonly Room room;
private Drawable playlistContainer;
public MatchSettings(Room room) public MatchSettings(Room room)
{ {
this.room = room; this.room = room;
@ -137,7 +146,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10), Spacing = new Vector2(0, 10),
Children = new Drawable[] Children = new[]
{ {
new Container new Container
{ {
@ -236,13 +245,32 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
} }
}, },
}, },
initialBeatmapControl = new BeatmapSelectionControl playlistContainer = new FillFlowContainer
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Width = 0.5f, Width = 0.5f,
Depth = float.MaxValue Depth = float.MaxValue,
Spacing = new Vector2(5),
Children = new Drawable[]
{
new DrawableRoomPlaylist(false, false)
{
RelativeSizeAxes = Axes.X,
Height = DrawableRoomPlaylistItem.HEIGHT,
Items = { BindTarget = Playlist },
SelectedItem = { BindTarget = SelectedItem }
},
new PurpleTriangleButton
{
RelativeSizeAxes = Axes.X,
Height = 40,
Text = "Select beatmap",
Action = SelectBeatmap
}
}
} }
} }
} }
@ -306,7 +334,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true); Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true);
Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true); Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true);
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true);
RoomID.BindValueChanged(roomId => initialBeatmapControl.Alpha = roomId.NewValue == null ? 1 : 0, true); RoomID.BindValueChanged(roomId => playlistContainer.Alpha = roomId.NewValue == null ? 1 : 0, true);
Password.BindValueChanged(password => PasswordTextBox.Text = password.NewValue ?? string.Empty, true); Password.BindValueChanged(password => PasswordTextBox.Text = password.NewValue ?? string.Empty, true);
operationInProgress.BindTo(ongoingOperationTracker.InProgress); operationInProgress.BindTo(ongoingOperationTracker.InProgress);

View File

@ -14,8 +14,10 @@ using osu.Framework.Screens;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.Queueing;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Dialog;
@ -53,6 +55,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
[CanBeNull] [CanBeNull]
private IDisposable readyClickOperation; private IDisposable readyClickOperation;
private OsuButton addOrEditPlaylistButton;
public MultiplayerMatchSubScreen(Room room) public MultiplayerMatchSubScreen(Room room)
: base(room) : base(room)
{ {
@ -128,7 +132,35 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
Content = new[] Content = new[]
{ {
new Drawable[] { new OverlinedHeader("Beatmap") }, new Drawable[] { new OverlinedHeader("Beatmap") },
new Drawable[] { new BeatmapSelectionControl { RelativeSizeAxes = Axes.X } }, new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5),
Children = new Drawable[]
{
addOrEditPlaylistButton = new PurpleTriangleButton
{
RelativeSizeAxes = Axes.X,
Height = 40,
Action = () =>
{
if (this.IsCurrentScreen())
this.Push(new MultiplayerMatchSongSelect(Room));
},
Alpha = 0
},
new DrawableRoomPlaylist(false, false)
{
RelativeSizeAxes = Axes.Both,
Items = { BindTarget = Room.Playlist },
SelectedItem = { BindTarget = SelectedItem }
},
}
}
},
new[] new[]
{ {
UserModsSection = new FillFlowContainer UserModsSection = new FillFlowContainer
@ -171,7 +203,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
RowDimensions = new[] RowDimensions = new[]
{ {
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize), new Dimension(),
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
} }
}, },
@ -354,6 +386,24 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
return; return;
} }
switch (client.Room.Settings.QueueMode)
{
case QueueModes.HostOnly:
addOrEditPlaylistButton.Text = "Edit beatmap";
addOrEditPlaylistButton.Alpha = client.Room.Host?.User?.Equals(client.LocalUser?.User) == true ? 1 : 0;
break;
case QueueModes.FreeForAll:
case QueueModes.FairRotate:
addOrEditPlaylistButton.Text = "Add beatmap";
addOrEditPlaylistButton.Alpha = 1;
break;
default:
addOrEditPlaylistButton.Alpha = 0;
break;
}
Scheduler.AddOnce(UpdateMods); Scheduler.AddOnce(UpdateMods);
} }