Add virtual method for creating different DrawablePlaylistItem types

This commit is contained in:
Dan Balasescu
2021-12-09 01:47:46 +09:00
parent 3b4833ca8e
commit 273042aa16
3 changed files with 22 additions and 18 deletions

View File

@ -131,16 +131,18 @@ namespace osu.Game.Screens.OnlinePlay
Spacing = new Vector2(0, 2)
};
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => new DrawableRoomPlaylistItem(item)
protected sealed override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => CreateDrawablePlaylistItem(item).With(d =>
{
SelectedItem = { BindTarget = SelectedItem },
RequestDeletion = i => DeletionRequested?.Invoke(i),
AllowReordering = AllowReordering,
AllowDeletion = AllowDeletion,
AllowSelection = AllowSelection,
AllowShowingResults = AllowShowingResults,
ShowItemOwner = ShowItemOwners,
ShowResultsRequested = i => ShowResultsRequested?.Invoke(i)
};
d.SelectedItem.BindTarget = SelectedItem;
d.RequestDeletion = i => DeletionRequested?.Invoke(i);
d.AllowReordering = AllowReordering;
d.AllowDeletion = AllowDeletion;
d.AllowSelection = AllowSelection;
d.AllowShowingResults = AllowShowingResults;
d.ShowItemOwner = ShowItemOwners;
d.ShowResultsRequested = i => ShowResultsRequested?.Invoke(i);
});
protected virtual DrawableRoomPlaylistItem CreateDrawablePlaylistItem(PlaylistItem item) => new DrawableRoomPlaylistItem(item);
}
}

View File

@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Rooms;
using osuTK;
@ -16,14 +15,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
/// </summary>
public class MultiplayerHistoryList : DrawableRoomPlaylist
{
public MultiplayerHistoryList()
{
ShowItemOwners = true;
}
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new HistoryFillFlowContainer
{
Spacing = new Vector2(0, 2)
};
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item)
=> base.CreateOsuDrawable(item).With(d => ((DrawableRoomPlaylistItem)d).ShowItemOwner = true);
private class HistoryFillFlowContainer : FillFlowContainer<RearrangeableListItem<PlaylistItem>>
{
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.OfType<RearrangeableListItem<PlaylistItem>>().OrderByDescending(item => item.Model.PlayedAt);

View File

@ -7,7 +7,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Rooms;
using osuTK;
@ -18,14 +17,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
/// </summary>
public class MultiplayerQueueList : DrawableRoomPlaylist
{
public MultiplayerQueueList()
{
ShowItemOwners = true;
}
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new QueueFillFlowContainer
{
Spacing = new Vector2(0, 2)
};
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item)
=> base.CreateOsuDrawable(item).With(d => ((DrawableRoomPlaylistItem)d).ShowItemOwner = true);
private class QueueFillFlowContainer : FillFlowContainer<RearrangeableListItem<PlaylistItem>>
{
[Resolved(typeof(Room), nameof(Room.Playlist))]