1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylist.cs

101 lines
3.0 KiB
C#
Raw Normal View History

// 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 System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
using osuTK;
namespace osu.Game.Screens.OnlinePlay
{
public class DrawableRoomPlaylist : OsuRearrangeableListContainer<PlaylistItem>
{
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
/// <summary>
/// Invoked when an item is requested to be deleted.
/// </summary>
public Action<PlaylistItem> DeletionRequested;
private bool allowReordering;
public bool AllowReordering
{
get => allowReordering;
set
{
allowReordering = value;
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
item.AllowReordering = value;
}
}
private bool allowDeletion;
public bool AllowDeletion
{
get => allowDeletion;
set
{
allowDeletion = value;
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
item.AllowDeletion = value;
}
}
private bool allowSelection;
public bool AllowSelection
{
get => allowSelection;
set
{
allowSelection = value;
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
item.AllowSelection = value;
}
}
private bool showItemOwners;
public bool ShowItemOwners
{
get => showItemOwners;
set
{
showItemOwners = value;
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
item.ShowItemOwner = value;
}
}
protected override ScrollContainer<Drawable> CreateScrollContainer() => base.CreateScrollContainer().With(d =>
{
d.ScrollbarVisible = false;
});
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new FillFlowContainer<RearrangeableListItem<PlaylistItem>>
{
Spacing = new Vector2(0, 2)
};
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => new DrawableRoomPlaylistItem(item)
{
2020-02-14 15:55:05 +08:00
SelectedItem = { BindTarget = SelectedItem },
RequestDeletion = i => DeletionRequested?.Invoke(i),
AllowReordering = AllowReordering,
AllowDeletion = AllowDeletion,
AllowSelection = AllowSelection,
ShowItemOwner = ShowItemOwners,
};
}
}