2020-02-14 14:01:45 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-02-14 14:01:45 +08:00
|
|
|
using System;
|
2020-07-10 18:37:27 +08:00
|
|
|
using System.Collections.Generic;
|
2020-02-14 14:01:45 +08:00
|
|
|
using System.Linq;
|
2021-11-25 22:15:28 +08:00
|
|
|
using System.Threading.Tasks;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2022-07-15 13:16:36 +08:00
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-11-25 22:15:28 +08:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-07-08 06:40:11 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2021-11-25 22:15:28 +08:00
|
|
|
using osu.Framework.Localisation;
|
2021-11-30 18:52:36 +08:00
|
|
|
using osu.Framework.Logging;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2022-07-08 06:40:11 +08:00
|
|
|
using osu.Game.Collections;
|
2021-11-25 22:15:28 +08:00
|
|
|
using osu.Game.Database;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-02-15 15:56:11 +08:00
|
|
|
using osu.Game.Online;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osu.Game.Online.Chat;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2022-07-14 07:45:31 +08:00
|
|
|
using osu.Game.Overlays;
|
2021-01-13 16:33:00 +08:00
|
|
|
using osu.Game.Overlays.BeatmapSet;
|
2022-01-28 12:53:48 +08:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
2021-11-25 22:15:28 +08:00
|
|
|
using osu.Game.Users.Drawables;
|
2020-02-14 14:01:45 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
2022-07-08 06:40:11 +08:00
|
|
|
public class DrawableRoomPlaylistItem : OsuRearrangeableListItem<PlaylistItem>, IHasContextMenu
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
2021-10-22 18:41:36 +08:00
|
|
|
public const float HEIGHT = 50;
|
2021-12-09 16:48:09 +08:00
|
|
|
|
|
|
|
private const float icon_height = 34;
|
2021-10-22 18:41:36 +08:00
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Invoked when this item requests to be deleted.
|
|
|
|
/// </summary>
|
2020-02-14 14:01:45 +08:00
|
|
|
public Action<PlaylistItem> RequestDeletion;
|
2021-12-09 00:29:45 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Invoked when this item requests its results to be shown.
|
|
|
|
/// </summary>
|
2021-12-09 00:52:59 +08:00
|
|
|
public Action<PlaylistItem> RequestResults;
|
2020-02-14 14:01:45 +08:00
|
|
|
|
2021-12-10 00:08:54 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Invoked when this item requests to be edited.
|
|
|
|
/// </summary>
|
|
|
|
public Action<PlaylistItem> RequestEdit;
|
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The currently-selected item, used to show a border around this item.
|
|
|
|
/// May be updated by this item if <see cref="AllowSelection"/> is <c>true</c>.
|
|
|
|
/// </summary>
|
2020-02-14 15:55:05 +08:00
|
|
|
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
public readonly PlaylistItem Item;
|
|
|
|
|
2022-05-09 16:55:40 +08:00
|
|
|
public bool IsSelectedItem => SelectedItem.Value?.ID == Item.ID;
|
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
private readonly DelayedLoadWrapper onScreenLoader = new DelayedLoadWrapper(Empty) { RelativeSizeAxes = Axes.Both };
|
|
|
|
private readonly IBindable<bool> valid = new Bindable<bool>();
|
2022-02-15 15:01:14 +08:00
|
|
|
|
2022-02-15 22:11:33 +08:00
|
|
|
private IBeatmapInfo beatmap;
|
2022-02-15 15:01:14 +08:00
|
|
|
private IRulesetInfo ruleset;
|
|
|
|
private Mod[] requiredMods;
|
2021-12-09 00:29:45 +08:00
|
|
|
|
2020-02-14 14:01:45 +08:00
|
|
|
private Container maskingContainer;
|
|
|
|
private Container difficultyIconContainer;
|
|
|
|
private LinkFlowContainer beatmapText;
|
|
|
|
private LinkFlowContainer authorText;
|
2022-05-15 01:52:38 +08:00
|
|
|
private ExplicitContentBeatmapBadge explicitContent;
|
2020-02-14 14:01:45 +08:00
|
|
|
private ModDisplay modDisplay;
|
2021-11-27 20:45:29 +08:00
|
|
|
private FillFlowContainer buttonsFlow;
|
2021-11-25 22:15:28 +08:00
|
|
|
private UpdateableAvatar ownerAvatar;
|
2021-12-09 00:17:25 +08:00
|
|
|
private Drawable showResultsButton;
|
2021-12-10 00:08:54 +08:00
|
|
|
private Drawable editButton;
|
2021-12-09 23:38:18 +08:00
|
|
|
private Drawable removeButton;
|
2021-12-09 00:29:45 +08:00
|
|
|
private PanelBackground panelBackground;
|
|
|
|
private FillFlowContainer mainFillFlow;
|
2020-07-10 18:37:27 +08:00
|
|
|
|
2022-07-27 14:59:36 +08:00
|
|
|
[Resolved]
|
|
|
|
private RealmAccess realm { get; set; }
|
|
|
|
|
2022-02-15 15:01:14 +08:00
|
|
|
[Resolved]
|
|
|
|
private RulesetStore rulesets { get; set; }
|
|
|
|
|
2022-07-15 13:16:36 +08:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
2021-11-25 22:15:28 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private UserLookupCache userLookupCache { get; set; }
|
|
|
|
|
2021-12-01 21:43:03 +08:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapLookupCache beatmapLookupCache { get; set; }
|
|
|
|
|
2022-07-14 07:45:31 +08:00
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
private BeatmapSetOverlay beatmapOverlay { get; set; }
|
|
|
|
|
2022-07-08 06:40:11 +08:00
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
|
|
|
|
2021-12-09 00:04:28 +08:00
|
|
|
protected override bool ShouldBeConsideredForInput(Drawable child) => AllowReordering || AllowDeletion || !AllowSelection || SelectedItem.Value == Model;
|
2020-02-15 15:47:55 +08:00
|
|
|
|
2021-12-09 00:04:28 +08:00
|
|
|
public DrawableRoomPlaylistItem(PlaylistItem item)
|
2020-02-14 14:01:45 +08:00
|
|
|
: base(item)
|
|
|
|
{
|
2020-07-10 18:37:27 +08:00
|
|
|
Item = item;
|
|
|
|
|
2021-11-16 16:01:24 +08:00
|
|
|
valid.BindTo(item.Valid);
|
2020-09-08 15:36:36 +08:00
|
|
|
|
2021-10-22 20:04:52 +08:00
|
|
|
if (item.Expired)
|
|
|
|
Colour = OsuColour.Gray(0.5f);
|
2020-02-14 14:01:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-11-16 16:01:24 +08:00
|
|
|
private void load()
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
2020-02-14 14:36:47 +08:00
|
|
|
maskingContainer.BorderColour = colours.Yellow;
|
2022-02-15 15:01:14 +08:00
|
|
|
|
|
|
|
ruleset = rulesets.GetRuleset(Item.RulesetID);
|
|
|
|
var rulesetInstance = ruleset?.CreateInstance();
|
|
|
|
|
|
|
|
requiredMods = Item.RequiredMods.Select(m => m.ToMod(rulesetInstance)).ToArray();
|
2020-02-14 14:36:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-11-17 10:28:43 +08:00
|
|
|
SelectedItem.BindValueChanged(selected =>
|
|
|
|
{
|
|
|
|
if (!valid.Value)
|
|
|
|
{
|
|
|
|
// Don't allow selection when not valid.
|
2022-05-09 16:55:40 +08:00
|
|
|
if (IsSelectedItem)
|
2021-11-17 10:28:43 +08:00
|
|
|
{
|
|
|
|
SelectedItem.Value = selected.OldValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't update border when not valid (the border is displaying this fact).
|
|
|
|
return;
|
|
|
|
}
|
2020-02-14 15:55:05 +08:00
|
|
|
|
2022-05-09 16:55:40 +08:00
|
|
|
maskingContainer.BorderThickness = IsSelectedItem ? 5 : 0;
|
2021-11-17 10:28:43 +08:00
|
|
|
}, true);
|
2020-02-14 14:36:47 +08:00
|
|
|
|
2021-11-16 16:01:24 +08:00
|
|
|
valid.BindValueChanged(_ => Scheduler.AddOnce(refresh));
|
2020-02-14 14:36:47 +08:00
|
|
|
|
2021-11-30 18:52:36 +08:00
|
|
|
onScreenLoader.DelayedLoadStarted += _ =>
|
|
|
|
{
|
|
|
|
Task.Run(async () =>
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2021-12-01 21:43:32 +08:00
|
|
|
if (showItemOwner)
|
|
|
|
{
|
|
|
|
var foundUser = await userLookupCache.GetUserAsync(Item.OwnerID).ConfigureAwait(false);
|
|
|
|
Schedule(() => ownerAvatar.User = foundUser);
|
|
|
|
}
|
2021-11-30 18:52:36 +08:00
|
|
|
|
2022-02-15 22:33:26 +08:00
|
|
|
beatmap = await beatmapLookupCache.GetBeatmapAsync(Item.Beatmap.OnlineID).ConfigureAwait(false);
|
2021-12-11 21:51:20 +08:00
|
|
|
|
2022-02-15 22:11:33 +08:00
|
|
|
Scheduler.AddOnce(refresh);
|
2021-11-30 18:52:36 +08:00
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Logger.Log($"Error while populating playlist item {e}");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-02-14 14:36:47 +08:00
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this item can be selected.
|
|
|
|
/// </summary>
|
2021-12-09 00:04:28 +08:00
|
|
|
public bool AllowSelection { get; set; }
|
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this item can be reordered in the playlist.
|
|
|
|
/// </summary>
|
2021-12-09 00:04:28 +08:00
|
|
|
public bool AllowReordering
|
|
|
|
{
|
|
|
|
get => ShowDragHandle.Value;
|
|
|
|
set => ShowDragHandle.Value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool allowDeletion;
|
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this item can be deleted.
|
|
|
|
/// </summary>
|
2021-12-09 00:04:28 +08:00
|
|
|
public bool AllowDeletion
|
|
|
|
{
|
|
|
|
get => allowDeletion;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
allowDeletion = value;
|
|
|
|
|
2021-12-09 23:38:18 +08:00
|
|
|
if (removeButton != null)
|
|
|
|
removeButton.Alpha = value ? 1 : 0;
|
2021-12-09 00:04:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-09 00:17:25 +08:00
|
|
|
private bool allowShowingResults;
|
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this item can have results shown.
|
|
|
|
/// </summary>
|
2021-12-09 00:17:25 +08:00
|
|
|
public bool AllowShowingResults
|
|
|
|
{
|
|
|
|
get => allowShowingResults;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
allowShowingResults = value;
|
|
|
|
|
|
|
|
if (showResultsButton != null)
|
|
|
|
showResultsButton.Alpha = value ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-10 00:08:54 +08:00
|
|
|
private bool allowEditing;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether this item can be edited.
|
|
|
|
/// </summary>
|
|
|
|
public bool AllowEditing
|
|
|
|
{
|
|
|
|
get => allowEditing;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
allowEditing = value;
|
|
|
|
|
|
|
|
if (editButton != null)
|
|
|
|
editButton.Alpha = value ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-09 00:04:28 +08:00
|
|
|
private bool showItemOwner;
|
|
|
|
|
2021-12-09 00:29:45 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether to display the avatar of the user which owns this playlist item.
|
|
|
|
/// </summary>
|
2021-12-09 00:04:28 +08:00
|
|
|
public bool ShowItemOwner
|
|
|
|
{
|
|
|
|
get => showItemOwner;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
showItemOwner = value;
|
|
|
|
|
|
|
|
if (ownerAvatar != null)
|
|
|
|
ownerAvatar.Alpha = value ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 15:55:05 +08:00
|
|
|
private void refresh()
|
|
|
|
{
|
2021-11-16 16:01:24 +08:00
|
|
|
if (!valid.Value)
|
|
|
|
{
|
|
|
|
maskingContainer.BorderThickness = 5;
|
|
|
|
maskingContainer.BorderColour = colours.Red;
|
|
|
|
}
|
|
|
|
|
2022-02-15 22:11:33 +08:00
|
|
|
if (beatmap != null)
|
2022-06-23 17:37:53 +08:00
|
|
|
difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset) { Size = new Vector2(icon_height) };
|
2021-11-27 20:45:29 +08:00
|
|
|
else
|
|
|
|
difficultyIconContainer.Clear();
|
2021-11-01 16:30:19 +08:00
|
|
|
|
2022-02-15 22:11:33 +08:00
|
|
|
panelBackground.Beatmap.Value = beatmap;
|
2020-02-14 15:55:05 +08:00
|
|
|
|
|
|
|
beatmapText.Clear();
|
2021-11-27 20:45:29 +08:00
|
|
|
|
2022-02-15 22:11:33 +08:00
|
|
|
if (beatmap != null)
|
2021-07-22 12:18:37 +08:00
|
|
|
{
|
2022-02-17 16:19:26 +08:00
|
|
|
beatmapText.AddLink(beatmap.GetDisplayTitleRomanisable(includeCreator: false),
|
2022-02-17 11:04:16 +08:00
|
|
|
LinkAction.OpenBeatmap,
|
2022-02-17 16:19:26 +08:00
|
|
|
beatmap.OnlineID.ToString(),
|
2022-02-17 11:04:16 +08:00
|
|
|
null,
|
|
|
|
text =>
|
|
|
|
{
|
|
|
|
text.Truncate = true;
|
|
|
|
});
|
2021-11-27 20:45:29 +08:00
|
|
|
}
|
2020-02-14 15:55:05 +08:00
|
|
|
|
|
|
|
authorText.Clear();
|
|
|
|
|
2022-02-15 22:11:33 +08:00
|
|
|
if (!string.IsNullOrEmpty(beatmap?.Metadata.Author.Username))
|
2020-02-14 15:55:05 +08:00
|
|
|
{
|
|
|
|
authorText.AddText("mapped by ");
|
2022-02-15 22:11:33 +08:00
|
|
|
authorText.AddUserLink(beatmap.Metadata.Author);
|
2020-02-14 15:55:05 +08:00
|
|
|
}
|
|
|
|
|
2022-02-15 22:11:33 +08:00
|
|
|
bool hasExplicitContent = (beatmap?.BeatmapSet as IBeatmapSetOnlineInfo)?.HasExplicitContent == true;
|
2022-05-15 01:52:38 +08:00
|
|
|
explicitContent.Alpha = hasExplicitContent ? 1 : 0;
|
2021-01-13 16:33:00 +08:00
|
|
|
|
2020-02-14 15:55:05 +08:00
|
|
|
modDisplay.Current.Value = requiredMods.ToArray();
|
2021-11-27 20:45:29 +08:00
|
|
|
|
|
|
|
buttonsFlow.Clear();
|
2021-12-09 00:17:25 +08:00
|
|
|
buttonsFlow.ChildrenEnumerable = createButtons();
|
2021-11-30 18:54:23 +08:00
|
|
|
|
|
|
|
difficultyIconContainer.FadeInFromZero(500, Easing.OutQuint);
|
|
|
|
mainFillFlow.FadeInFromZero(500, Easing.OutQuint);
|
2020-02-14 15:55:05 +08:00
|
|
|
}
|
|
|
|
|
2021-02-02 16:09:59 +08:00
|
|
|
protected override Drawable CreateContent()
|
2020-02-14 14:36:47 +08:00
|
|
|
{
|
2021-02-02 16:09:59 +08:00
|
|
|
Action<SpriteText> fontParameters = s => s.Font = OsuFont.Default.With(weight: FontWeight.SemiBold);
|
|
|
|
|
|
|
|
return maskingContainer = new Container
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
2021-02-02 16:09:59 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
2021-10-22 18:41:36 +08:00
|
|
|
Height = HEIGHT,
|
2021-02-02 16:09:59 +08:00
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 10,
|
|
|
|
Children = new Drawable[]
|
2020-02-14 14:36:47 +08:00
|
|
|
{
|
2021-02-02 16:09:59 +08:00
|
|
|
new Box // A transparent box that forces the border to be drawn if the panel background is opaque
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
2021-02-02 16:09:59 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true
|
|
|
|
},
|
2021-11-30 18:52:36 +08:00
|
|
|
onScreenLoader,
|
2021-11-01 16:30:19 +08:00
|
|
|
panelBackground = new PanelBackground
|
2021-02-02 16:09:59 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2021-07-22 12:18:37 +08:00
|
|
|
new GridContainer
|
2021-02-02 16:09:59 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-07-22 12:18:37 +08:00
|
|
|
ColumnDimensions = new[]
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2021-11-26 16:17:06 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize)
|
2021-07-22 12:18:37 +08:00
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
2021-02-02 16:09:59 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
difficultyIconContainer = new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2021-11-26 16:17:06 +08:00
|
|
|
Margin = new MarginPadding { Left = 8, Right = 8 },
|
2021-07-22 12:18:37 +08:00
|
|
|
},
|
2021-11-30 18:54:23 +08:00
|
|
|
mainFillFlow = new FillFlowContainer
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
beatmapText = new LinkFlowContainer(fontParameters)
|
2021-01-13 16:33:00 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
2021-11-04 01:08:12 +08:00
|
|
|
// workaround to ensure only the first line of text shows, emulating truncation (but without ellipsis at the end).
|
|
|
|
// TODO: remove when text/link flow can support truncation with ellipsis natively.
|
|
|
|
Height = OsuFont.DEFAULT_FONT_SIZE,
|
|
|
|
Masking = true
|
2021-07-22 12:18:37 +08:00
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(10f, 0),
|
|
|
|
Children = new Drawable[]
|
2021-01-13 16:33:00 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
new FillFlowContainer
|
2021-01-13 16:33:00 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(10f, 0),
|
|
|
|
Children = new Drawable[]
|
2021-02-02 16:09:59 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
authorText = new LinkFlowContainer(fontParameters) { AutoSizeAxes = Axes.Both },
|
2022-05-15 01:52:38 +08:00
|
|
|
explicitContent = new ExplicitContentBeatmapBadge
|
2021-07-22 12:18:37 +08:00
|
|
|
{
|
|
|
|
Alpha = 0f,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Margin = new MarginPadding { Top = 3f },
|
|
|
|
}
|
|
|
|
},
|
2021-02-02 16:09:59 +08:00
|
|
|
},
|
2021-07-22 12:18:37 +08:00
|
|
|
new Container
|
2021-02-02 16:09:59 +08:00
|
|
|
{
|
2021-07-22 12:18:37 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Child = modDisplay = new ModDisplay
|
|
|
|
{
|
|
|
|
Scale = new Vector2(0.4f),
|
|
|
|
ExpansionMode = ExpansionMode.AlwaysExpanded
|
|
|
|
}
|
2021-02-02 16:09:59 +08:00
|
|
|
}
|
2021-01-13 16:33:00 +08:00
|
|
|
}
|
2020-02-14 14:01:45 +08:00
|
|
|
}
|
|
|
|
}
|
2021-07-22 12:18:37 +08:00
|
|
|
},
|
2021-11-27 20:45:29 +08:00
|
|
|
buttonsFlow = new FillFlowContainer
|
2021-07-22 12:18:37 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
Direction = FillDirection.Horizontal,
|
2021-11-26 16:40:45 +08:00
|
|
|
Margin = new MarginPadding { Horizontal = 8 },
|
2021-07-22 12:18:37 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Spacing = new Vector2(5),
|
2021-12-09 00:17:25 +08:00
|
|
|
ChildrenEnumerable = createButtons().Select(button => button.With(b =>
|
2021-07-22 12:18:37 +08:00
|
|
|
{
|
|
|
|
b.Anchor = Anchor.Centre;
|
|
|
|
b.Origin = Anchor.Centre;
|
|
|
|
}))
|
2021-11-26 16:17:06 +08:00
|
|
|
},
|
|
|
|
ownerAvatar = new OwnerAvatar
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-12-09 16:48:09 +08:00
|
|
|
Size = new Vector2(icon_height),
|
2021-11-26 16:40:45 +08:00
|
|
|
Margin = new MarginPadding { Right = 8 },
|
2021-11-26 16:17:06 +08:00
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 4,
|
2021-12-09 00:04:28 +08:00
|
|
|
Alpha = ShowItemOwner ? 1 : 0
|
2021-11-26 16:17:06 +08:00
|
|
|
},
|
2020-02-14 14:01:45 +08:00
|
|
|
}
|
|
|
|
}
|
2021-02-02 16:09:59 +08:00
|
|
|
},
|
2022-07-08 06:40:11 +08:00
|
|
|
},
|
2021-02-02 16:09:59 +08:00
|
|
|
};
|
|
|
|
}
|
2020-02-14 14:01:45 +08:00
|
|
|
|
2022-02-16 14:51:18 +08:00
|
|
|
private IEnumerable<Drawable> createButtons() => new[]
|
2021-12-09 16:48:09 +08:00
|
|
|
{
|
2022-02-16 14:51:18 +08:00
|
|
|
showResultsButton = new GrayButton(FontAwesome.Solid.ChartPie)
|
2021-12-10 00:08:54 +08:00
|
|
|
{
|
2022-02-16 14:51:18 +08:00
|
|
|
Size = new Vector2(30, 30),
|
|
|
|
Action = () => RequestResults?.Invoke(Item),
|
|
|
|
Alpha = AllowShowingResults ? 1 : 0,
|
|
|
|
TooltipText = "View results"
|
|
|
|
},
|
|
|
|
beatmap == null ? Empty() : new PlaylistDownloadButton(beatmap),
|
|
|
|
editButton = new PlaylistEditButton
|
|
|
|
{
|
|
|
|
Size = new Vector2(30, 30),
|
|
|
|
Alpha = AllowEditing ? 1 : 0,
|
|
|
|
Action = () => RequestEdit?.Invoke(Item),
|
2022-01-28 12:53:48 +08:00
|
|
|
TooltipText = CommonStrings.ButtonsEdit
|
2022-02-16 14:51:18 +08:00
|
|
|
},
|
|
|
|
removeButton = new PlaylistRemoveButton
|
|
|
|
{
|
|
|
|
Size = new Vector2(30, 30),
|
|
|
|
Alpha = AllowDeletion ? 1 : 0,
|
|
|
|
Action = () => RequestDeletion?.Invoke(Item),
|
|
|
|
TooltipText = "Remove from playlist"
|
|
|
|
},
|
|
|
|
};
|
2020-07-10 18:37:27 +08:00
|
|
|
|
2020-02-14 14:01:45 +08:00
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
2021-12-09 00:04:28 +08:00
|
|
|
if (AllowSelection && valid.Value)
|
2020-02-14 15:55:05 +08:00
|
|
|
SelectedItem.Value = Model;
|
2020-02-14 14:01:45 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-07-08 06:40:11 +08:00
|
|
|
public MenuItem[] ContextMenuItems
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
List<MenuItem> items = new List<MenuItem>();
|
|
|
|
|
2022-07-14 07:45:31 +08:00
|
|
|
if (beatmapOverlay != null)
|
|
|
|
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(Item.Beatmap.OnlineID)));
|
|
|
|
|
2022-07-27 14:59:36 +08:00
|
|
|
if (beatmap != null)
|
2022-07-08 06:40:11 +08:00
|
|
|
{
|
2022-07-15 13:16:36 +08:00
|
|
|
if (beatmaps.QueryBeatmap(b => b.OnlineID == beatmap.OnlineID) is BeatmapInfo local && !local.BeatmapSet.AsNonNull().DeletePending)
|
|
|
|
{
|
2022-07-28 14:51:18 +08:00
|
|
|
var collectionItems = realm.Realm.All<BeatmapCollection>().AsEnumerable().Select(c => new CollectionToggleMenuItem(c.ToLive(realm), beatmap)).Cast<OsuMenuItem>().ToList();
|
2022-07-15 13:16:36 +08:00
|
|
|
if (manageCollectionsDialog != null)
|
|
|
|
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
|
2022-07-08 06:40:11 +08:00
|
|
|
|
2022-07-15 13:16:36 +08:00
|
|
|
items.Add(new OsuMenuItem("Collections") { Items = collectionItems });
|
|
|
|
}
|
2022-07-08 06:40:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return items.ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-10 00:08:54 +08:00
|
|
|
public class PlaylistEditButton : GrayButton
|
|
|
|
{
|
|
|
|
public PlaylistEditButton()
|
|
|
|
: base(FontAwesome.Solid.Edit)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-09 23:38:18 +08:00
|
|
|
public class PlaylistRemoveButton : GrayButton
|
|
|
|
{
|
|
|
|
public PlaylistRemoveButton()
|
|
|
|
: base(FontAwesome.Solid.MinusSquare)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-27 22:08:03 +08:00
|
|
|
private sealed class PlaylistDownloadButton : BeatmapDownloadButton
|
2020-02-15 15:56:11 +08:00
|
|
|
{
|
2022-02-15 22:11:33 +08:00
|
|
|
private readonly IBeatmapInfo beatmap;
|
2020-06-02 13:04:51 +08:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmapManager { get; set; }
|
|
|
|
|
2021-10-27 20:26:26 +08:00
|
|
|
// required for download tracking, as this button hides itself. can probably be removed with a bit of consideration.
|
|
|
|
public override bool IsPresent => true;
|
2021-01-18 00:17:14 +08:00
|
|
|
|
2021-11-01 14:10:32 +08:00
|
|
|
private const float width = 50;
|
2021-01-18 00:17:14 +08:00
|
|
|
|
2022-02-15 22:11:33 +08:00
|
|
|
public PlaylistDownloadButton(IBeatmapInfo beatmap)
|
|
|
|
: base(beatmap.BeatmapSet)
|
2020-02-15 15:56:11 +08:00
|
|
|
{
|
2022-02-15 22:11:33 +08:00
|
|
|
this.beatmap = beatmap;
|
2021-11-01 14:10:32 +08:00
|
|
|
|
|
|
|
Size = new Vector2(width, 30);
|
2020-02-15 15:56:11 +08:00
|
|
|
Alpha = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
State.BindValueChanged(stateChanged, true);
|
2021-10-29 10:59:07 +08:00
|
|
|
|
|
|
|
// base implementation calls FinishTransforms, so should be run after the above state update.
|
2020-02-15 15:56:11 +08:00
|
|
|
base.LoadComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void stateChanged(ValueChangedEvent<DownloadState> state)
|
|
|
|
{
|
2020-06-02 13:04:51 +08:00
|
|
|
switch (state.NewValue)
|
|
|
|
{
|
|
|
|
case DownloadState.LocallyAvailable:
|
|
|
|
// Perform a local query of the beatmap by beatmap checksum, and reset the state if not matching.
|
2022-02-15 22:11:33 +08:00
|
|
|
if (beatmapManager.QueryBeatmap(b => b.MD5Hash == beatmap.MD5Hash) == null)
|
2020-06-02 13:04:51 +08:00
|
|
|
State.Value = DownloadState.NotDownloaded;
|
|
|
|
else
|
2021-11-01 14:10:32 +08:00
|
|
|
{
|
|
|
|
this.FadeTo(0, 500)
|
|
|
|
.ResizeWidthTo(0, 500, Easing.OutQuint);
|
|
|
|
}
|
2020-06-02 13:04:51 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-11-01 14:10:32 +08:00
|
|
|
this.ResizeWidthTo(width, 500, Easing.OutQuint)
|
|
|
|
.FadeTo(1, 500);
|
2020-06-02 13:04:51 +08:00
|
|
|
break;
|
|
|
|
}
|
2020-02-15 15:56:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 14:01:45 +08:00
|
|
|
// For now, this is the same implementation as in PanelBackground, but supports a beatmap info rather than a working beatmap
|
|
|
|
private class PanelBackground : Container // todo: should be a buffered container (https://github.com/ppy/osu-framework/issues/3222)
|
|
|
|
{
|
2021-11-01 16:30:19 +08:00
|
|
|
public readonly Bindable<IBeatmapInfo> Beatmap = new Bindable<IBeatmapInfo>();
|
2020-02-14 14:01:45 +08:00
|
|
|
|
|
|
|
public PanelBackground()
|
|
|
|
{
|
2021-10-27 14:20:01 +08:00
|
|
|
UpdateableBeatmapBackgroundSprite backgroundSprite;
|
|
|
|
|
2020-02-14 14:01:45 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2021-10-27 14:20:01 +08:00
|
|
|
backgroundSprite = new UpdateableBeatmapBackgroundSprite
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
},
|
2020-02-27 12:32:23 +08:00
|
|
|
new FillFlowContainer
|
2020-02-14 14:01:45 +08:00
|
|
|
{
|
|
|
|
Depth = -1,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-02-27 12:32:23 +08:00
|
|
|
Direction = FillDirection.Horizontal,
|
2020-02-14 14:01:45 +08:00
|
|
|
// This makes the gradient not be perfectly horizontal, but diagonal at a ~40° angle
|
|
|
|
Shear = new Vector2(0.8f, 0),
|
|
|
|
Alpha = 0.5f,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
// The left half with no gradient applied
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
Width = 0.4f,
|
|
|
|
},
|
2021-02-03 05:05:25 +08:00
|
|
|
// Piecewise-linear gradient with 2 segments to make it appear smoother
|
2020-02-14 14:01:45 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-02-02 15:57:27 +08:00
|
|
|
Colour = ColourInfo.GradientHorizontal(Color4.Black, new Color4(0f, 0f, 0f, 0.7f)),
|
|
|
|
Width = 0.4f,
|
2020-02-14 14:01:45 +08:00
|
|
|
},
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-02-02 15:57:27 +08:00
|
|
|
Colour = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.7f), new Color4(0, 0, 0, 0.4f)),
|
|
|
|
Width = 0.4f,
|
2020-02-14 14:01:45 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2021-10-27 14:20:01 +08:00
|
|
|
|
|
|
|
// manual binding required as playlists don't expose IBeatmapInfo currently.
|
|
|
|
// may be removed in the future if this changes.
|
|
|
|
Beatmap.BindValueChanged(beatmap => backgroundSprite.Beatmap.Value = beatmap.NewValue);
|
2020-02-14 14:01:45 +08:00
|
|
|
}
|
|
|
|
}
|
2021-11-25 22:15:28 +08:00
|
|
|
|
|
|
|
private class OwnerAvatar : UpdateableAvatar, IHasTooltip
|
|
|
|
{
|
|
|
|
public OwnerAvatar()
|
|
|
|
{
|
|
|
|
AddInternal(new TooltipArea(this)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Depth = -1
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-11-26 21:54:10 +08:00
|
|
|
public LocalisableString TooltipText => User == null ? string.Empty : $"queued by {User.Username}";
|
2021-11-25 22:15:28 +08:00
|
|
|
|
|
|
|
private class TooltipArea : Component, IHasTooltip
|
|
|
|
{
|
|
|
|
private readonly OwnerAvatar avatar;
|
|
|
|
|
|
|
|
public TooltipArea(OwnerAvatar avatar)
|
|
|
|
{
|
|
|
|
this.avatar = avatar;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LocalisableString TooltipText => avatar.TooltipText;
|
|
|
|
}
|
|
|
|
}
|
2020-02-14 14:01:45 +08:00
|
|
|
}
|
|
|
|
}
|