// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Localisation; using osu.Game.Beatmaps.Drawables.Cards; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Online.MisskeyAPI; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet; using osu.Game.Resources.Localisation.Web; using osu.Game.Screens.Misskey.Components.Note.Cards.Statistics; using osu.Game.Skinning.Components; using osuTK; namespace osu.Game.Screens.Misskey.Components.Note.Cards { public partial class NoteCardNormal : NoteCard { protected override Drawable IdleContent => idleBottomContent; protected override Drawable DownloadInProgressContent => downloadProgressBar; private const float height = 100; [Cached] private readonly NoteCardContent content; private NoteCardAvatar thumbnail = null!; // private CollapsibleButtonContainer buttonContainer = null!; // private FillFlowContainer statisticsContainer = null!; private TextFlowContainer noteText = null!; private FillFlowContainer idleBottomContent = null!; private BeatmapCardDownloadProgressBar downloadProgressBar = null!; [Resolved] private IAPIProvider api { get; set; } = null!; // [Resolved] // private OverlayColourProvider colourProvider { get; set; } = null!; public NoteCardNormal(Online.MisskeyAPI.Responses.Types.Note note, bool allowExpansion = true) : base(note, allowExpansion) { content = new NoteCardContent(height); } [BackgroundDependencyLoader] private void load() { Width = WIDTH; Height = height; FillFlowContainer leftIconArea = null!; FillFlowContainer titleBadgeArea = null!; GridContainer artistContainer = null!; // LinkFlowContainer titleText = null!; LinkFlowContainer artistText = null!; Child = content.With(c => { c.MainContent = new Container { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { thumbnail = new NoteCardAvatar(Note) { Name = @"Left (icon) area", Size = new Vector2(height - 10), // Padding = new MarginPadding { Right = CORNER_RADIUS }, Child = leftIconArea = new FillFlowContainer { Margin = new MarginPadding(5), AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(1) } }, // buttonContainer = new CollapsibleButtonContainer(Note) // { // X = height - CORNER_RADIUS, // Width = WIDTH - height + CORNER_RADIUS, // // FavouriteState = { BindTarget = FavouriteState }, // ButtonsCollapsedWidth = CORNER_RADIUS, // ButtonsExpandedWidth = 30, // Children = new Drawable[] // { new FillFlowContainer { // X = height - CORNER_RADIUS, X = height, RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { new GridContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, ColumnDimensions = new[] { new Dimension(), new Dimension(GridSizeMode.AutoSize), }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new Drawable[] { new OsuSpriteText() { Text = new RomanisableString(Note.User.Name, Note.User.Username), Font = OsuFont.Default.With(size: 22.5f, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, Truncate = true // Padding = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS }, // AutoSizeAxes = Axes.Y, }, titleBadgeArea = new FillFlowContainer { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, } } } }, artistContainer = new GridContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, ColumnDimensions = new[] { new Dimension(), new Dimension(GridSizeMode.AutoSize) }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new[] { artistText = new LinkFlowContainer() { // Text = createArtistText(), // Font = OsuFont.Default.With(size: 17.5f, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, // Truncate = true AutoSizeAxes = Axes.Y, }, Empty() }, } }, noteText = new TextFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Alpha = 1, AlwaysPresent = true, }.With(flow => { flow.AddText(Note.Text, t => t.Font = OsuFont.Default.With(size: 15)); }) } }, new Container { Name = @"Bottom content", RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Children = new Drawable[] { idleBottomContent = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 3), AlwaysPresent = true, Children = new Drawable[] { // statisticsContainer = new FillFlowContainer // { // RelativeSizeAxes = Axes.X, // AutoSizeAxes = Axes.Y, // Direction = FillDirection.Horizontal, // Spacing = new Vector2(10, 0), // Alpha = 0, // AlwaysPresent = true, // ChildrenEnumerable = createStatistics() // }, } } } } // } // } } }; // c.ExpandedContent = new Container // { // RelativeSizeAxes = Axes.X, // AutoSizeAxes = Axes.Y, // Padding = new MarginPadding { Horizontal = 10, Vertical = 13 }, // Child = new BeatmapCardDifficultyList(BeatmapSet) // }; c.Expanded.BindTarget = Expanded; // titleText.AddLink(Note.User.Name, $"{api.APIEndpointUrl}@{Note.User.Username}@{Note.User.Host}"); artistText.AddLink($"@{Note.User.Username}@{Note.User.Host}", $"{api.APIEndpointUrl}/@{Note.User.Username}@{Note.User.Host}"); }); // if (BeatmapSet.HasVideo) // leftIconArea.Add(new VideoIconPill { IconSize = new Vector2(20) }); // // if (BeatmapSet.HasStoryboard) // leftIconArea.Add(new StoryboardIconPill { IconSize = new Vector2(20) }); // // if (BeatmapSet.FeaturedInSpotlight) // { // titleBadgeArea.Add(new SpotlightBeatmapBadge // { // Anchor = Anchor.BottomRight, // Origin = Anchor.BottomRight, // Margin = new MarginPadding { Left = 5 } // }); // } // if (BeatmapSet.HasExplicitContent) // { // titleBadgeArea.Add(new ExplicitContentBeatmapBadge // { // Anchor = Anchor.BottomRight, // Origin = Anchor.BottomRight, // Margin = new MarginPadding { Left = 5 } // }); // } // if (BeatmapSet.TrackId != null) // { // artistContainer.Content[0][1] = new FeaturedArtistBeatmapBadge // { // Anchor = Anchor.BottomRight, // Origin = Anchor.BottomRight, // Margin = new MarginPadding { Left = 5 } // }; // } } private LocalisableString createArtistText() { var romanisableArtist = new RomanisableString(Note.User.Username + "@" + Note.User.Host, Note.User.Username + "@" + Note.User.Host); return romanisableArtist; } // private IEnumerable createStatistics() // { // var hypesStatistic = HypesStatistic.CreateFor(BeatmapSet); // if (hypesStatistic != null) // yield return hypesStatistic; // // var nominationsStatistic = NominationsStatistic.CreateFor(BeatmapSet); // if (nominationsStatistic != null) // yield return nominationsStatistic; // // yield return new FavouritesStatistic(BeatmapSet) { Current = FavouriteState }; // yield return new PlayCountStatistic(BeatmapSet); // // var dateStatistic = BeatmapCardDateStatistic.CreateFor(BeatmapSet); // if (dateStatistic != null) // yield return dateStatistic; // } protected override void UpdateState() { base.UpdateState(); bool showDetails = IsHovered || Expanded.Value; // buttonContainer.ShowDetails.Value = showDetails; thumbnail.Dimmed.Value = showDetails; // statisticsContainer.FadeTo(showDetails ? 1 : 0, TRANSITION_DURATION, Easing.OutQuint); } } }