From 8bcb4485edc4e8d290f22b02693645954bb256b1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 29 May 2019 19:00:20 +0300 Subject: [PATCH 01/11] implement UnderscoredLinkContainer --- .../Sections/UnderscoredLinkContainer.cs | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs new file mode 100644 index 0000000000..087bd03837 --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs @@ -0,0 +1,79 @@ +// 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.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Graphics.Sprites; +using System; +using System.Collections.Generic; + +namespace osu.Game.Overlays.Profile.Sections +{ + public class UnderscoredLinkContainer : Container + { + private const int duration = 200; + public Action ClickAction; + private readonly Container underscore; + private readonly FillFlowContainer textContent; + + public IReadOnlyList Text + { + get => textContent.Children; + set + { + textContent.Clear(); + textContent.AddRange(value); + } + } + + public UnderscoredLinkContainer() + { + AutoSizeAxes = Axes.Both; + Child = new Container + { + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + underscore = new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 1, + Alpha = 0, + AlwaysPresent = true, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + } + }, + textContent = new FillFlowContainer + { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + }, + }, + }; + } + + protected override bool OnHover(HoverEvent e) + { + underscore.FadeIn(duration, Easing.OutQuint); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + underscore.FadeOut(duration, Easing.OutQuint); + base.OnHoverLost(e); + } + + protected override bool OnClick(ClickEvent e) + { + ClickAction?.Invoke(); + return base.OnClick(e); + } + } +} From 52fad723a206ea5d86bb1384405aca64af106293 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 29 May 2019 19:51:59 +0300 Subject: [PATCH 02/11] Implement DrawableMostPlayedBeatmap --- .../Online/TestSceneHistoricalSection.cs | 2 +- .../Historical/DrawableMostPlayedBeatmap.cs | 190 ++++++++++++++++++ .../Historical/DrawableMostPlayedRow.cs | 77 ------- .../PaginatedMostPlayedBeatmapContainer.cs | 2 +- 4 files changed, 192 insertions(+), 79 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs delete mode 100644 osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneHistoricalSection.cs b/osu.Game.Tests/Visual/Online/TestSceneHistoricalSection.cs index 455807649a..f309112f0d 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneHistoricalSection.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneHistoricalSection.cs @@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.Online { typeof(HistoricalSection), typeof(PaginatedMostPlayedBeatmapContainer), - typeof(DrawableMostPlayedRow), + typeof(DrawableMostPlayedBeatmap), typeof(DrawableProfileRow) }; diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs new file mode 100644 index 0000000000..e8ce11555f --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -0,0 +1,190 @@ +// 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.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Framework.Localisation; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Profile.Sections.Historical +{ + public class DrawableMostPlayedBeatmap : Container + { + private readonly BeatmapInfo beatmap; + private readonly OsuSpriteText mapperText; + private readonly int playCount; + private readonly Box background; + private Color4 idleBackgroundColour; + private Color4 hoveredBackgroundColour; + private const int duration = 200; + private const int cover_width = 100; + private const int corner_radius = 10; + private readonly SpriteIcon icon; + private readonly OsuSpriteText playCountText; + private readonly UnderscoredLinkContainer mapper; + private readonly UnderscoredLinkContainer beatmapName; + + public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount) + { + this.beatmap = beatmap; + this.playCount = playCount; + + RelativeSizeAxes = Axes.X; + Height = 60; + Masking = true; + CornerRadius = corner_radius; + Children = new Drawable[] + { + new UpdateableBeatmapSetCover + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Y, + Width = cover_width, + BeatmapSet = beatmap.BeatmapSet, + CoverType = BeatmapSetCoverType.List, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = cover_width - corner_radius }, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = corner_radius, + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = 15, Right = 20 }, + Children = new Drawable[] + { + beatmapName = new UnderscoredLinkContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.BottomLeft, + Margin = new MarginPadding { Bottom = 2 }, + Text = new OsuSpriteText[] + { + new OsuSpriteText + { + Text = new LocalisedString(( + $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", + $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold) + }, + new OsuSpriteText + { + Text = "by " + new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular) + }, + } + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.CentreLeft, + Origin = Anchor.TopLeft, + Direction = FillDirection.Horizontal, + Margin = new MarginPadding { Top = 2 }, + Children = new Drawable[] + { + mapperText = new OsuSpriteText + { + Text = "mapped by ", + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular), + }, + mapper = new UnderscoredLinkContainer + { + Text = new OsuSpriteText[] + { + new OsuSpriteText + { + Text = beatmap.Metadata.Author.Username, + Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold), + } + } + }, + } + }, + new FillFlowContainer + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + icon = new SpriteIcon + { + Icon = FontAwesome.Solid.CaretRight, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Size = new Vector2(20), + }, + playCountText = new OsuSpriteText + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Text = playCount.ToString(), + Font = OsuFont.GetFont(size: 30, weight: FontWeight.Regular, fixedWidth: true), + }, + } + } + } + }, + } + } + } + } + }; + } + + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuColour colors, UserProfileOverlay userProfileOverlay, BeatmapSetOverlay beatmapSetOverlay) + { + idleBackgroundColour = background.Colour = colors.GreySeafoam; + hoveredBackgroundColour = colors.GreySeafoamLight; + mapperText.Colour = mapper.Colour = colors.GreySeafoamLighter; + icon.Colour = playCountText.Colour = colors.Yellow; + + mapper.ClickAction = () => userProfileOverlay.ShowUser(beatmap.Metadata.Author.Id); + beatmapName.ClickAction = () => + { + if (beatmap.OnlineBeatmapID != null) + beatmapSetOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value); + else if (beatmap.BeatmapSet?.OnlineBeatmapSetID != null) + beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmap.BeatmapSet.OnlineBeatmapSetID.Value); + }; + } + + protected override bool OnHover(HoverEvent e) + { + background.FadeColour(hoveredBackgroundColour, duration, Easing.OutQuint); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + background.FadeColour(idleBackgroundColour, duration, Easing.OutQuint); + base.OnHoverLost(e); + } + } +} diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs deleted file mode 100644 index 1b286f92d3..0000000000 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs +++ /dev/null @@ -1,77 +0,0 @@ -// 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.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Drawables; -using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; -using osuTK; - -namespace osu.Game.Overlays.Profile.Sections.Historical -{ - public class DrawableMostPlayedRow : DrawableProfileRow - { - private readonly BeatmapInfo beatmap; - private readonly int playCount; - - public DrawableMostPlayedRow(BeatmapInfo beatmap, int playCount) - { - this.beatmap = beatmap; - this.playCount = playCount; - } - - protected override Drawable CreateLeftVisual() => new UpdateableBeatmapSetCover - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Size = new Vector2(80, 50), - BeatmapSet = beatmap.BeatmapSet, - CoverType = BeatmapSetCoverType.List, - }; - - [BackgroundDependencyLoader] - private void load() - { - LeftFlowContainer.Add(new BeatmapMetadataContainer(beatmap)); - LeftFlowContainer.Add(new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 12)) - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Horizontal, - }.With(d => - { - d.AddText("mapped by "); - d.AddUserLink(beatmap.Metadata.Author); - })); - - RightFlowContainer.Add(new FillFlowContainer - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - new OsuSpriteText - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Text = playCount.ToString(), - Font = OsuFont.GetFont(size: 18, weight: FontWeight.SemiBold, italics: true) - }, - new OsuSpriteText - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Text = @"times played ", - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular, italics: true) - }, - } - }); - } - } -} diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index f2eb32c53b..13fe20d063 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical foreach (var beatmap in beatmaps) { - ItemsContainer.Add(new DrawableMostPlayedRow(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount)); + ItemsContainer.Add(new DrawableMostPlayedBeatmap(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount)); } }); From 6efa61b992a44cf4c3004ca9dc284da8952c90ba Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 29 May 2019 20:24:01 +0300 Subject: [PATCH 03/11] Split UnderscoredLinkContainer in different classes --- .../Historical/DrawableMostPlayedBeatmap.cs | 20 ++++--------- .../Sections/UnderscoredBeatmapLink.cs | 30 +++++++++++++++++++ .../Sections/UnderscoredLinkContainer.cs | 7 +++-- .../Profile/Sections/UnderscoredUserLink.cs | 23 ++++++++++++++ 4 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs create mode 100644 osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index e8ce11555f..50f419e07c 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -30,8 +30,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical private const int corner_radius = 10; private readonly SpriteIcon icon; private readonly OsuSpriteText playCountText; - private readonly UnderscoredLinkContainer mapper; - private readonly UnderscoredLinkContainer beatmapName; + private readonly UnderscoredUserLink mapper; public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount) { @@ -76,7 +75,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical Padding = new MarginPadding { Left = 15, Right = 20 }, Children = new Drawable[] { - beatmapName = new UnderscoredLinkContainer + new UnderscoredBeatmapLink(beatmap) { Anchor = Anchor.CentreLeft, Origin = Anchor.BottomLeft, @@ -111,7 +110,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical Text = "mapped by ", Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular), }, - mapper = new UnderscoredLinkContainer + mapper = new UnderscoredUserLink(beatmap.Metadata.Author.Id) { Text = new OsuSpriteText[] { @@ -157,22 +156,13 @@ namespace osu.Game.Overlays.Profile.Sections.Historical }; } - [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuColour colors, UserProfileOverlay userProfileOverlay, BeatmapSetOverlay beatmapSetOverlay) + [BackgroundDependencyLoader] + private void load(OsuColour colors) { idleBackgroundColour = background.Colour = colors.GreySeafoam; hoveredBackgroundColour = colors.GreySeafoamLight; mapperText.Colour = mapper.Colour = colors.GreySeafoamLighter; icon.Colour = playCountText.Colour = colors.Yellow; - - mapper.ClickAction = () => userProfileOverlay.ShowUser(beatmap.Metadata.Author.Id); - beatmapName.ClickAction = () => - { - if (beatmap.OnlineBeatmapID != null) - beatmapSetOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value); - else if (beatmap.BeatmapSet?.OnlineBeatmapSetID != null) - beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmap.BeatmapSet.OnlineBeatmapSetID.Value); - }; } protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs new file mode 100644 index 0000000000..370d6d84ef --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs @@ -0,0 +1,30 @@ +// 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.Allocation; +using osu.Game.Beatmaps; + +namespace osu.Game.Overlays.Profile.Sections +{ + public class UnderscoredBeatmapLink : UnderscoredLinkContainer + { + private readonly BeatmapInfo beatmap; + + public UnderscoredBeatmapLink(BeatmapInfo beatmap) + { + this.beatmap = beatmap; + } + + [BackgroundDependencyLoader(true)] + private void load(BeatmapSetOverlay beatmapSetOverlay) + { + ClickAction = () => + { + if (beatmap.OnlineBeatmapID != null) + beatmapSetOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value); + else if (beatmap.BeatmapSet?.OnlineBeatmapSetID != null) + beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmap.BeatmapSet.OnlineBeatmapSetID.Value); + }; + } + } +} diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs index 087bd03837..8daf0bd24d 100644 --- a/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs @@ -11,13 +11,14 @@ using System.Collections.Generic; namespace osu.Game.Overlays.Profile.Sections { - public class UnderscoredLinkContainer : Container + public abstract class UnderscoredLinkContainer : Container { private const int duration = 200; - public Action ClickAction; private readonly Container underscore; private readonly FillFlowContainer textContent; + protected Action ClickAction; + public IReadOnlyList Text { get => textContent.Children; @@ -28,7 +29,7 @@ namespace osu.Game.Overlays.Profile.Sections } } - public UnderscoredLinkContainer() + protected UnderscoredLinkContainer() { AutoSizeAxes = Axes.Both; Child = new Container diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs new file mode 100644 index 0000000000..f50bc7f7ba --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs @@ -0,0 +1,23 @@ +// 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.Allocation; + +namespace osu.Game.Overlays.Profile.Sections +{ + public class UnderscoredUserLink : UnderscoredLinkContainer + { + private readonly long userId; + + public UnderscoredUserLink(long userId) + { + this.userId = userId; + } + + [BackgroundDependencyLoader(true)] + private void load(UserProfileOverlay userProfileOverlay) + { + ClickAction = () => userProfileOverlay?.ShowUser(userId); + } + } +} From 1baf922f2c3dace2bfa09f12e169cf8c078cb00b Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 29 May 2019 20:36:14 +0300 Subject: [PATCH 04/11] CI fixes --- .../Sections/Historical/DrawableMostPlayedBeatmap.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index 50f419e07c..34b6884fe0 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -19,9 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical { public class DrawableMostPlayedBeatmap : Container { - private readonly BeatmapInfo beatmap; private readonly OsuSpriteText mapperText; - private readonly int playCount; private readonly Box background; private Color4 idleBackgroundColour; private Color4 hoveredBackgroundColour; @@ -34,9 +32,6 @@ namespace osu.Game.Overlays.Profile.Sections.Historical public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount) { - this.beatmap = beatmap; - this.playCount = playCount; - RelativeSizeAxes = Axes.X; Height = 60; Masking = true; @@ -80,7 +75,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical Anchor = Anchor.CentreLeft, Origin = Anchor.BottomLeft, Margin = new MarginPadding { Bottom = 2 }, - Text = new OsuSpriteText[] + Text = new[] { new OsuSpriteText { @@ -112,7 +107,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical }, mapper = new UnderscoredUserLink(beatmap.Metadata.Author.Id) { - Text = new OsuSpriteText[] + Text = new[] { new OsuSpriteText { From b32ffab58054309c25c2a86895bfce998af3b987 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 31 May 2019 02:19:09 +0300 Subject: [PATCH 05/11] Make the DrawableMostPlayedBeatmap inherit OsuHoverContainer --- .../Historical/DrawableMostPlayedBeatmap.cs | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index 34b6884fe0..98872d6141 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -6,32 +6,33 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osuTK; -using osuTK.Graphics; +using System.Collections.Generic; namespace osu.Game.Overlays.Profile.Sections.Historical { - public class DrawableMostPlayedBeatmap : Container + public class DrawableMostPlayedBeatmap : OsuHoverContainer { private readonly OsuSpriteText mapperText; private readonly Box background; - private Color4 idleBackgroundColour; - private Color4 hoveredBackgroundColour; - private const int duration = 200; private const int cover_width = 100; private const int corner_radius = 10; private readonly SpriteIcon icon; private readonly OsuSpriteText playCountText; private readonly UnderscoredUserLink mapper; + protected override IEnumerable EffectTargets => new[] { background }; + public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount) { + Enabled.Value = true; //manually enabled, because we have no action + RelativeSizeAxes = Axes.X; Height = 60; Masking = true; @@ -154,22 +155,10 @@ namespace osu.Game.Overlays.Profile.Sections.Historical [BackgroundDependencyLoader] private void load(OsuColour colors) { - idleBackgroundColour = background.Colour = colors.GreySeafoam; - hoveredBackgroundColour = colors.GreySeafoamLight; + IdleColour = colors.GreySeafoam; + HoverColour = colors.GreySeafoamLight; mapperText.Colour = mapper.Colour = colors.GreySeafoamLighter; icon.Colour = playCountText.Colour = colors.Yellow; } - - protected override bool OnHover(HoverEvent e) - { - background.FadeColour(hoveredBackgroundColour, duration, Easing.OutQuint); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - background.FadeColour(idleBackgroundColour, duration, Easing.OutQuint); - base.OnHoverLost(e); - } } } From b93b26a0366069000d99535a6f83f62e7e377726 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 14 Jul 2019 19:38:46 +0300 Subject: [PATCH 06/11] Fix link formatting --- .../Profile/Sections/UnderscoredBeatmapLink.cs | 14 +++++++------- .../Profile/Sections/UnderscoredLinkContainer.cs | 9 +++++++++ .../Profile/Sections/UnderscoredUserLink.cs | 9 ++++----- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs index 370d6d84ef..ddad99355c 100644 --- a/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs +++ b/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs @@ -1,7 +1,6 @@ // 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.Allocation; using osu.Game.Beatmaps; namespace osu.Game.Overlays.Profile.Sections @@ -15,15 +14,16 @@ namespace osu.Game.Overlays.Profile.Sections this.beatmap = beatmap; } - [BackgroundDependencyLoader(true)] - private void load(BeatmapSetOverlay beatmapSetOverlay) + protected override void LoadComplete() { + base.LoadComplete(); + ClickAction = () => { - if (beatmap.OnlineBeatmapID != null) - beatmapSetOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value); - else if (beatmap.BeatmapSet?.OnlineBeatmapSetID != null) - beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmap.BeatmapSet.OnlineBeatmapSetID.Value); + var beatmapId = beatmap.OnlineBeatmapID; + + if (beatmapId.HasValue) + Game?.ShowBeatmap(beatmapId.Value); }; } } diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs index 8daf0bd24d..09a23d2fe3 100644 --- a/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs @@ -1,6 +1,7 @@ // 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.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -17,6 +18,8 @@ namespace osu.Game.Overlays.Profile.Sections private readonly Container underscore; private readonly FillFlowContainer textContent; + protected OsuGame Game; + protected Action ClickAction; public IReadOnlyList Text @@ -59,6 +62,12 @@ namespace osu.Game.Overlays.Profile.Sections }; } + [BackgroundDependencyLoader(true)] + private void load(OsuGame game) + { + Game = game; + } + protected override bool OnHover(HoverEvent e) { underscore.FadeIn(duration, Easing.OutQuint); diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs index f50bc7f7ba..9b3e8ccdf6 100644 --- a/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs +++ b/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs @@ -1,8 +1,6 @@ // 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.Allocation; - namespace osu.Game.Overlays.Profile.Sections { public class UnderscoredUserLink : UnderscoredLinkContainer @@ -14,10 +12,11 @@ namespace osu.Game.Overlays.Profile.Sections this.userId = userId; } - [BackgroundDependencyLoader(true)] - private void load(UserProfileOverlay userProfileOverlay) + protected override void LoadComplete() { - ClickAction = () => userProfileOverlay?.ShowUser(userId); + base.LoadComplete(); + + ClickAction = () => Game?.ShowUser(userId); } } } From d62e42ba1459d5b32c3c721f9a322d9af7d7bb19 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 15 Jul 2019 13:09:21 +0300 Subject: [PATCH 07/11] Remove custom link container implementation --- .../Sections/BeatmapMetadataContainer.cs | 26 ++---- .../Historical/DrawableMostPlayedBeatmap.cs | 75 +++++++--------- .../Sections/Ranks/DrawableProfileScore.cs | 29 +++++- .../Sections/UnderscoredBeatmapLink.cs | 30 ------- .../Sections/UnderscoredLinkContainer.cs | 89 ------------------- .../Profile/Sections/UnderscoredUserLink.cs | 22 ----- 6 files changed, 67 insertions(+), 204 deletions(-) delete mode 100644 osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs delete mode 100644 osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs delete mode 100644 osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs index 16326900f1..597171cc7f 100644 --- a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs @@ -4,22 +4,19 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Localisation; using osu.Game.Beatmaps; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Profile.Sections { /// /// Display artist/title/mapper information, commonly used as the left portion of a profile or score display row (see ). /// - public class BeatmapMetadataContainer : OsuHoverContainer + public abstract class BeatmapMetadataContainer : OsuHoverContainer { private readonly BeatmapInfo beatmap; - public BeatmapMetadataContainer(BeatmapInfo beatmap) + protected BeatmapMetadataContainer(BeatmapInfo beatmap) { this.beatmap = beatmap; AutoSizeAxes = Axes.Both; @@ -40,23 +37,10 @@ namespace osu.Game.Overlays.Profile.Sections Child = new FillFlowContainer { AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new OsuSpriteText - { - Text = new LocalisedString(( - $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", - $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), - Font = OsuFont.GetFont(size: 15, weight: FontWeight.SemiBold, italics: true) - }, - new OsuSpriteText - { - Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), - Padding = new MarginPadding { Top = 3 }, - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular, italics: true) - }, - }, + Children = CreateText(beatmap), }; } + + protected abstract Drawable[] CreateText(BeatmapInfo beatmap); } } diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index 98872d6141..fc457676a8 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -19,13 +19,12 @@ namespace osu.Game.Overlays.Profile.Sections.Historical { public class DrawableMostPlayedBeatmap : OsuHoverContainer { - private readonly OsuSpriteText mapperText; private readonly Box background; private const int cover_width = 100; private const int corner_radius = 10; private readonly SpriteIcon icon; private readonly OsuSpriteText playCountText; - private readonly UnderscoredUserLink mapper; + private readonly LinkFlowContainer mapper; protected override IEnumerable EffectTargets => new[] { background }; @@ -71,54 +70,24 @@ namespace osu.Game.Overlays.Profile.Sections.Historical Padding = new MarginPadding { Left = 15, Right = 20 }, Children = new Drawable[] { - new UnderscoredBeatmapLink(beatmap) + new MostPlayedBeatmapMetadataContainer(beatmap) { Anchor = Anchor.CentreLeft, Origin = Anchor.BottomLeft, Margin = new MarginPadding { Bottom = 2 }, - Text = new[] - { - new OsuSpriteText - { - Text = new LocalisedString(( - $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", - $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold) - }, - new OsuSpriteText - { - Text = "by " + new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular) - }, - } }, - new FillFlowContainer + mapper = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular)) { - AutoSizeAxes = Axes.Both, Anchor = Anchor.CentreLeft, Origin = Anchor.TopLeft, + AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Margin = new MarginPadding { Top = 2 }, - Children = new Drawable[] - { - mapperText = new OsuSpriteText - { - Text = "mapped by ", - Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular), - }, - mapper = new UnderscoredUserLink(beatmap.Metadata.Author.Id) - { - Text = new[] - { - new OsuSpriteText - { - Text = beatmap.Metadata.Author.Username, - Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold), - } - } - }, - } - }, + }.With(d => + { + d.AddText("mapped by "); + d.AddUserLink(beatmap.Metadata.Author); + }), new FillFlowContainer { Anchor = Anchor.CentreRight, @@ -157,8 +126,32 @@ namespace osu.Game.Overlays.Profile.Sections.Historical { IdleColour = colors.GreySeafoam; HoverColour = colors.GreySeafoamLight; - mapperText.Colour = mapper.Colour = colors.GreySeafoamLighter; + mapper.Colour = colors.GreySeafoamLighter; icon.Colour = playCountText.Colour = colors.Yellow; } + + private class MostPlayedBeatmapMetadataContainer : BeatmapMetadataContainer + { + public MostPlayedBeatmapMetadataContainer(BeatmapInfo beatmap) + : base(beatmap) + { + } + + protected override Drawable[] CreateText(BeatmapInfo beatmap) => new Drawable[] + { + new OsuSpriteText + { + Text = new LocalisedString(( + $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", + $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold) + }, + new OsuSpriteText + { + Text = "by " + new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular) + }, + }; + } } } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index b77357edd8..e54ce44ca2 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -10,6 +10,8 @@ using osu.Game.Online.Leaderboards; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using osu.Game.Scoring; +using osu.Game.Beatmaps; +using osu.Framework.Localisation; namespace osu.Game.Overlays.Profile.Sections.Ranks { @@ -51,7 +53,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks RightFlowContainer.Insert(1, text); - LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap)); + LeftFlowContainer.Add(new ProfileScoreBeatmapMetadataContainer(Score.Beatmap)); LeftFlowContainer.Add(new DrawableDate(Score.Date)); foreach (Mod mod in Score.Mods) @@ -64,5 +66,30 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Width = 60, FillMode = FillMode.Fit, }; + + private class ProfileScoreBeatmapMetadataContainer : BeatmapMetadataContainer + { + public ProfileScoreBeatmapMetadataContainer(BeatmapInfo beatmap) + : base(beatmap) + { + } + + protected override Drawable[] CreateText(BeatmapInfo beatmap) => new Drawable[] + { + new OsuSpriteText + { + Text = new LocalisedString(( + $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", + $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), + Font = OsuFont.GetFont(size: 15, weight: FontWeight.SemiBold, italics: true) + }, + new OsuSpriteText + { + Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), + Padding = new MarginPadding { Top = 3 }, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular, italics: true) + }, + }; + } } } diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs deleted file mode 100644 index ddad99355c..0000000000 --- a/osu.Game/Overlays/Profile/Sections/UnderscoredBeatmapLink.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Game.Beatmaps; - -namespace osu.Game.Overlays.Profile.Sections -{ - public class UnderscoredBeatmapLink : UnderscoredLinkContainer - { - private readonly BeatmapInfo beatmap; - - public UnderscoredBeatmapLink(BeatmapInfo beatmap) - { - this.beatmap = beatmap; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - ClickAction = () => - { - var beatmapId = beatmap.OnlineBeatmapID; - - if (beatmapId.HasValue) - Game?.ShowBeatmap(beatmapId.Value); - }; - } - } -} diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs deleted file mode 100644 index 09a23d2fe3..0000000000 --- a/osu.Game/Overlays/Profile/Sections/UnderscoredLinkContainer.cs +++ /dev/null @@ -1,89 +0,0 @@ -// 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.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Input.Events; -using osu.Game.Graphics.Sprites; -using System; -using System.Collections.Generic; - -namespace osu.Game.Overlays.Profile.Sections -{ - public abstract class UnderscoredLinkContainer : Container - { - private const int duration = 200; - private readonly Container underscore; - private readonly FillFlowContainer textContent; - - protected OsuGame Game; - - protected Action ClickAction; - - public IReadOnlyList Text - { - get => textContent.Children; - set - { - textContent.Clear(); - textContent.AddRange(value); - } - } - - protected UnderscoredLinkContainer() - { - AutoSizeAxes = Axes.Both; - Child = new Container - { - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - underscore = new Container - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = 1, - Alpha = 0, - AlwaysPresent = true, - Child = new Box - { - RelativeSizeAxes = Axes.Both, - } - }, - textContent = new FillFlowContainer - { - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, - }, - }, - }; - } - - [BackgroundDependencyLoader(true)] - private void load(OsuGame game) - { - Game = game; - } - - protected override bool OnHover(HoverEvent e) - { - underscore.FadeIn(duration, Easing.OutQuint); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - underscore.FadeOut(duration, Easing.OutQuint); - base.OnHoverLost(e); - } - - protected override bool OnClick(ClickEvent e) - { - ClickAction?.Invoke(); - return base.OnClick(e); - } - } -} diff --git a/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs b/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs deleted file mode 100644 index 9b3e8ccdf6..0000000000 --- a/osu.Game/Overlays/Profile/Sections/UnderscoredUserLink.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -namespace osu.Game.Overlays.Profile.Sections -{ - public class UnderscoredUserLink : UnderscoredLinkContainer - { - private readonly long userId; - - public UnderscoredUserLink(long userId) - { - this.userId = userId; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - ClickAction = () => Game?.ShowUser(userId); - } - } -} From ca72409dc269fe0ffd0a1045f17cdcec98e48ab2 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 18 Jul 2019 20:16:10 +0900 Subject: [PATCH 08/11] More closely match osu-web styling --- .../Historical/DrawableMostPlayedBeatmap.cs | 147 +++++++++++------- 1 file changed, 87 insertions(+), 60 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index fc457676a8..a6c41cde72 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -14,34 +14,45 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osuTK; using System.Collections.Generic; +using osu.Framework.Graphics.Cursor; namespace osu.Game.Overlays.Profile.Sections.Historical { public class DrawableMostPlayedBeatmap : OsuHoverContainer { - private readonly Box background; private const int cover_width = 100; private const int corner_radius = 10; - private readonly SpriteIcon icon; - private readonly OsuSpriteText playCountText; - private readonly LinkFlowContainer mapper; + + private readonly BeatmapInfo beatmap; + private readonly int playCount; + + private Box background; protected override IEnumerable EffectTargets => new[] { background }; public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount) { + this.beatmap = beatmap; + this.playCount = playCount; Enabled.Value = true; //manually enabled, because we have no action RelativeSizeAxes = Axes.X; - Height = 60; + AutoSizeAxes = Axes.Y; + Masking = true; CornerRadius = corner_radius; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + IdleColour = colours.GreySeafoam; + HoverColour = colours.GreySeafoamLight; + Children = new Drawable[] { new UpdateableBeatmapSetCover { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, RelativeSizeAxes = Axes.Y, Width = cover_width, BeatmapSet = beatmap.BeatmapSet, @@ -49,69 +60,53 @@ namespace osu.Game.Overlays.Profile.Sections.Historical }, new Container { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Left = cover_width - corner_radius }, Children = new Drawable[] { new Container { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Masking = true, CornerRadius = corner_radius, Children = new Drawable[] { - background = new Box - { - RelativeSizeAxes = Axes.Both, - }, + background = new Box { RelativeSizeAxes = Axes.Both }, new Container { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Left = 15, Right = 20 }, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding(10), Children = new Drawable[] { - new MostPlayedBeatmapMetadataContainer(beatmap) - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.BottomLeft, - Margin = new MarginPadding { Bottom = 2 }, - }, - mapper = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular)) - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.TopLeft, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Margin = new MarginPadding { Top = 2 }, - }.With(d => - { - d.AddText("mapped by "); - d.AddUserLink(beatmap.Metadata.Author); - }), new FillFlowContainer { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, + Direction = FillDirection.Vertical, Children = new Drawable[] { - icon = new SpriteIcon + new MostPlayedBeatmapMetadataContainer(beatmap), + new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular)) { - Icon = FontAwesome.Solid.CaretRight, - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Size = new Vector2(20), - }, - playCountText = new OsuSpriteText + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Colour = colours.GreySeafoamLighter + }.With(d => { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Text = playCount.ToString(), - Font = OsuFont.GetFont(size: 30, weight: FontWeight.Regular, fixedWidth: true), - }, + d.AddText("mapped by "); + d.AddUserLink(beatmap.Metadata.Author); + }), } - } + }, + new PlayCountText(playCount) + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight + }, } }, } @@ -121,15 +116,6 @@ namespace osu.Game.Overlays.Profile.Sections.Historical }; } - [BackgroundDependencyLoader] - private void load(OsuColour colors) - { - IdleColour = colors.GreySeafoam; - HoverColour = colors.GreySeafoamLight; - mapper.Colour = colors.GreySeafoamLighter; - icon.Colour = playCountText.Colour = colors.Yellow; - } - private class MostPlayedBeatmapMetadataContainer : BeatmapMetadataContainer { public MostPlayedBeatmapMetadataContainer(BeatmapInfo beatmap) @@ -144,14 +130,55 @@ namespace osu.Game.Overlays.Profile.Sections.Historical Text = new LocalisedString(( $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold) + Font = OsuFont.GetFont(weight: FontWeight.Bold) }, new OsuSpriteText { Text = "by " + new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular) + Font = OsuFont.GetFont(weight: FontWeight.Regular) }, }; } + + private class PlayCountText : CompositeDrawable, IHasTooltip + { + public string TooltipText => "times played"; + + public PlayCountText(int playCount) + { + AutoSizeAxes = Axes.Both; + + InternalChild = new FillFlowContainer + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5, 0), + Children = new Drawable[] + { + new SpriteIcon + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Size = new Vector2(12), + Icon = FontAwesome.Solid.Play, + }, + new OsuSpriteText + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Text = playCount.ToString(), + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular), + }, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = colours.Yellow; + } + } } } From f87e9b801716136e0ad43d124bc1b312b5b6212f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 18 Jul 2019 20:17:19 +0900 Subject: [PATCH 09/11] Remove unnecessary tooltip text --- osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs index 597171cc7f..13b547eed3 100644 --- a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs @@ -19,8 +19,8 @@ namespace osu.Game.Overlays.Profile.Sections protected BeatmapMetadataContainer(BeatmapInfo beatmap) { this.beatmap = beatmap; + AutoSizeAxes = Axes.Both; - TooltipText = $"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title}"; } [BackgroundDependencyLoader(true)] From 2f111e6cf4ea5e56147a395c8bff06a3c7508b2c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 22 Jul 2019 23:57:26 +0900 Subject: [PATCH 10/11] Fix incorrect corner radius --- .../Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index a6c41cde72..0e9b534ca2 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical public class DrawableMostPlayedBeatmap : OsuHoverContainer { private const int cover_width = 100; - private const int corner_radius = 10; + private const int corner_radius = 6; private readonly BeatmapInfo beatmap; private readonly int playCount; From ee6fed5b33c219cada52a9628301d61767dabf57 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 22 Jul 2019 18:17:49 +0300 Subject: [PATCH 11/11] Use fixed height --- .../Sections/Historical/DrawableMostPlayedBeatmap.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index 0e9b534ca2..0206c4e13b 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -22,6 +22,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical { private const int cover_width = 100; private const int corner_radius = 6; + private const int height = 50; private readonly BeatmapInfo beatmap; private readonly int playCount; @@ -37,7 +38,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical Enabled.Value = true; //manually enabled, because we have no action RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; + Height = height; Masking = true; CornerRadius = corner_radius; @@ -60,15 +61,13 @@ namespace osu.Game.Overlays.Profile.Sections.Historical }, new Container { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = cover_width - corner_radius }, Children = new Drawable[] { new Container { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.Both, Masking = true, CornerRadius = corner_radius, Children = new Drawable[] @@ -76,8 +75,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical background = new Box { RelativeSizeAxes = Axes.Both }, new Container { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(10), Children = new Drawable[] {