From ce47a34991ce574265aeaf37134c3d9f6de02cee Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 1 Aug 2020 06:14:24 +0300 Subject: [PATCH] Implement DashboardNewBeatmapPanel component --- .../TestSceneDashboardBeatmapPanel.cs | 8 ++- .../Dashboard/DashboardBeatmapPanel.cs | 56 +++++++++++-------- .../Dashboard/DashboardNewBeatmapPanel.cs | 22 ++++++++ 3 files changed, 61 insertions(+), 25 deletions(-) create mode 100644 osu.Game/Overlays/Dashboard/Dashboard/DashboardNewBeatmapPanel.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneDashboardBeatmapPanel.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneDashboardBeatmapPanel.cs index a61cd37513..5f1af012db 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneDashboardBeatmapPanel.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneDashboardBeatmapPanel.cs @@ -8,6 +8,7 @@ using osu.Game.Beatmaps; using osu.Game.Overlays; using osu.Framework.Allocation; using osu.Game.Users; +using System; namespace osu.Game.Tests.Visual.UserInterface { @@ -24,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface Origin = Anchor.Centre, AutoSizeAxes = Axes.Y, Width = 300, - Child = new DashboardBeatmapPanel(beatmap_set) + Child = new DashboardNewBeatmapPanel(beatmap_set) }); } @@ -33,7 +34,7 @@ namespace osu.Game.Tests.Visual.UserInterface Metadata = new BeatmapMetadata { Title = "Very Long Title (TV size) [TATOE]", - Artist = "This artist has a really long name how is it possible", + Artist = "This artist has a really long name how is this possible", Author = new User { Username = "author", @@ -45,7 +46,8 @@ namespace osu.Game.Tests.Visual.UserInterface Covers = new BeatmapSetOnlineCovers { Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608", - } + }, + Ranked = DateTimeOffset.Now } }; } diff --git a/osu.Game/Overlays/Dashboard/Dashboard/DashboardBeatmapPanel.cs b/osu.Game/Overlays/Dashboard/Dashboard/DashboardBeatmapPanel.cs index 84cb5ae46a..30b0086b8a 100644 --- a/osu.Game/Overlays/Dashboard/Dashboard/DashboardBeatmapPanel.cs +++ b/osu.Game/Overlays/Dashboard/Dashboard/DashboardBeatmapPanel.cs @@ -16,22 +16,22 @@ using osuTK; namespace osu.Game.Overlays.Dashboard.Dashboard { - public class DashboardBeatmapPanel : OsuClickableContainer + public abstract class DashboardBeatmapPanel : OsuClickableContainer { [Resolved] - private OverlayColourProvider colourProvider { get; set; } + protected OverlayColourProvider ColourProvider { get; private set; } [Resolved(canBeNull: true)] private BeatmapSetOverlay beatmapOverlay { get; set; } - private readonly BeatmapSetInfo setInfo; + protected readonly BeatmapSetInfo SetInfo; private Box background; private SpriteIcon chevron; - public DashboardBeatmapPanel(BeatmapSetInfo setInfo) + protected DashboardBeatmapPanel(BeatmapSetInfo setInfo) { - this.setInfo = setInfo; + SetInfo = setInfo; } [BackgroundDependencyLoader] @@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard background = new Box { RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background3, + Colour = ColourProvider.Background3, Alpha = 0 }, new Container @@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - BeatmapSet = setInfo + BeatmapSet = SetInfo } }, new Container @@ -99,24 +99,34 @@ namespace osu.Game.Overlays.Dashboard.Dashboard RelativeSizeAxes = Axes.X, Truncate = true, Font = OsuFont.GetFont(weight: FontWeight.SemiBold), - Text = setInfo.Metadata.Title + Text = SetInfo.Metadata.Title }, new OsuSpriteText { RelativeSizeAxes = Axes.X, Truncate = true, Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold), - Text = setInfo.Metadata.Artist + Text = SetInfo.Metadata.Artist }, - new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold)) + new FillFlowContainer { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y - }.With(c => - { - c.AddText("by "); - c.AddUserLink(setInfo.Metadata.Author); - }) + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5, 0), + Margin = new MarginPadding { Top = 2 }, + Children = new Drawable[] + { + new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold)) + { + AutoSizeAxes = Axes.Both + }.With(c => + { + c.AddText("by "); + c.AddUserLink(SetInfo.Metadata.Author); + }), + CreateInfo() + } + } } } }, @@ -126,7 +136,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard Origin = Anchor.CentreRight, Size = new Vector2(16), Icon = FontAwesome.Solid.ChevronRight, - Colour = colourProvider.Foreground1 + Colour = ColourProvider.Foreground1 } } } @@ -136,16 +146,18 @@ namespace osu.Game.Overlays.Dashboard.Dashboard Action = () => { - if (setInfo.OnlineBeatmapSetID.HasValue) - beatmapOverlay?.FetchAndShowBeatmapSet(setInfo.OnlineBeatmapSetID.Value); + if (SetInfo.OnlineBeatmapSetID.HasValue) + beatmapOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value); }; } + protected abstract Drawable CreateInfo(); + protected override bool OnHover(HoverEvent e) { base.OnHover(e); background.FadeIn(200, Easing.OutQuint); - chevron.FadeColour(colourProvider.Light1, 200, Easing.OutQuint); + chevron.FadeColour(ColourProvider.Light1, 200, Easing.OutQuint); return true; } @@ -153,7 +165,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard { base.OnHoverLost(e); background.FadeOut(200, Easing.OutQuint); - chevron.FadeColour(colourProvider.Foreground1, 200, Easing.OutQuint); + chevron.FadeColour(ColourProvider.Foreground1, 200, Easing.OutQuint); } } } diff --git a/osu.Game/Overlays/Dashboard/Dashboard/DashboardNewBeatmapPanel.cs b/osu.Game/Overlays/Dashboard/Dashboard/DashboardNewBeatmapPanel.cs new file mode 100644 index 0000000000..6d2ec7ae37 --- /dev/null +++ b/osu.Game/Overlays/Dashboard/Dashboard/DashboardNewBeatmapPanel.cs @@ -0,0 +1,22 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Game.Beatmaps; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Dashboard.Dashboard +{ + public class DashboardNewBeatmapPanel : DashboardBeatmapPanel + { + public DashboardNewBeatmapPanel(BeatmapSetInfo setInfo) + : base(setInfo) + { + } + + protected override Drawable CreateInfo() => new DrawableDate(SetInfo.OnlineInfo.Ranked.Value, 10, false) + { + Colour = ColourProvider.Foreground1 + }; + } +}