1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 18:27:26 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistWithResults.cs

70 lines
2.4 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.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
namespace osu.Game.Screens.OnlinePlay
{
public class DrawableRoomPlaylistWithResults : DrawableRoomPlaylist
{
public Action<PlaylistItem> RequestShowResults;
2021-11-26 16:40:45 +08:00
private readonly bool showItemOwner;
public DrawableRoomPlaylistWithResults(bool showItemOwner = false)
: base(false, true, showItemOwner)
{
2021-11-26 16:40:45 +08:00
this.showItemOwner = showItemOwner;
}
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) =>
2021-11-26 16:40:45 +08:00
new DrawableRoomPlaylistItemWithResults(item, false, true, showItemOwner)
{
RequestShowResults = () => RequestShowResults(item),
SelectedItem = { BindTarget = SelectedItem },
};
private class DrawableRoomPlaylistItemWithResults : DrawableRoomPlaylistItem
{
public Action RequestShowResults;
2021-11-26 16:40:45 +08:00
public DrawableRoomPlaylistItemWithResults(PlaylistItem item, bool allowEdit, bool allowSelection, bool showItemOwner)
: base(item, allowEdit, allowSelection, showItemOwner)
{
}
protected override IEnumerable<Drawable> CreateButtons() =>
base.CreateButtons().Prepend(new FilledIconButton
{
Icon = FontAwesome.Solid.ChartPie,
Action = () => RequestShowResults?.Invoke(),
TooltipText = "View results"
});
private class FilledIconButton : IconButton
{
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Add(new Box
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
Colour = colours.Gray4,
});
}
}
}
}
}