From 9d073f42283f4da57e1b219a34b22c062a14b59d Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 24 Dec 2022 11:26:09 -0800 Subject: [PATCH 1/7] Link beatmap set title and artist to listing search --- osu.Game/OsuGame.cs | 5 +++- .../BeatmapSet/BeatmapSetHeaderContent.cs | 29 ++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index de9a009f44..b55b943023 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -353,7 +353,10 @@ public void HandleLink(LinkDetails link) => Schedule(() => break; case LinkAction.SearchBeatmapSet: - SearchBeatmapSet(argString); + if (link.Argument is RomanisableString romanisable) + SearchBeatmapSet(romanisable.GetPreferred(frameworkConfig.GetBindable(FrameworkSetting.ShowUnicode).Value)); + else + SearchBeatmapSet(argString); break; case LinkAction.OpenEditorTimestamp: diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index 0318dad0e3..6977110ad4 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -16,11 +16,12 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Online.Chat; using osu.Game.Overlays.BeatmapSet.Buttons; using osuTK; @@ -41,7 +42,7 @@ public partial class BeatmapSetHeaderContent : CompositeDrawable private readonly UpdateableOnlineBeatmapSetCover cover; private readonly Box coverGradient; - private readonly OsuSpriteText title, artist; + private readonly LinkFlowContainer title, artist; private readonly AuthorInfo author; private readonly ExplicitContentBeatmapBadge explicitContent; @@ -127,9 +128,12 @@ public BeatmapSetHeaderContent() Margin = new MarginPadding { Top = 15 }, Children = new Drawable[] { - title = new OsuSpriteText + title = new LinkFlowContainer(s => { - Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true) + s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true); + }) + { + AutoSizeAxes = Axes.Both, }, externalLink = new ExternalLinkButton { @@ -160,9 +164,12 @@ public BeatmapSetHeaderContent() Margin = new MarginPadding { Bottom = 20 }, Children = new Drawable[] { - artist = new OsuSpriteText + artist = new LinkFlowContainer(s => { - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true), + s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true); + }) + { + AutoSizeAxes = Axes.Both, }, featuredArtist = new FeaturedArtistBeatmapBadge { @@ -275,8 +282,14 @@ private void load(OverlayColourProvider colourProvider) loading.Hide(); - title.Text = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title); - artist.Text = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist); + var titleText = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title); + var artistText = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist); + + title.Clear(); + artist.Clear(); + + title.AddLink(titleText, LinkAction.SearchBeatmapSet, titleText); + artist.AddLink(artistText, LinkAction.SearchBeatmapSet, artistText); explicitContent.Alpha = setInfo.NewValue.HasExplicitContent ? 1 : 0; spotlight.Alpha = setInfo.NewValue.FeaturedInSpotlight ? 1 : 0; From df645ef3cb8de16a67ac8e92831830bf10d5da16 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 24 Dec 2022 11:42:05 -0800 Subject: [PATCH 2/7] Change title/artist idle colour to white --- .../BeatmapSet/BeatmapSetHeaderContent.cs | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index 6977110ad4..357c9bc55d 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -3,6 +3,7 @@ #nullable disable +using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -12,6 +13,7 @@ using osu.Game.Graphics.Cursor; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; @@ -24,6 +26,7 @@ using osu.Game.Online.Chat; using osu.Game.Overlays.BeatmapSet.Buttons; using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet { @@ -128,7 +131,7 @@ public BeatmapSetHeaderContent() Margin = new MarginPadding { Top = 15 }, Children = new Drawable[] { - title = new LinkFlowContainer(s => + title = new MetadataFlowContainer(s => { s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true); }) @@ -164,7 +167,7 @@ public BeatmapSetHeaderContent() Margin = new MarginPadding { Bottom = 20 }, Children = new Drawable[] { - artist = new LinkFlowContainer(s => + artist = new MetadataFlowContainer(s => { s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true); }) @@ -340,5 +343,29 @@ private void updateDownloadButtons() break; } } + + public partial class MetadataFlowContainer : LinkFlowContainer + { + public MetadataFlowContainer(Action defaultCreationParameters = null) + : base(defaultCreationParameters) + { + } + + protected override DrawableLinkCompiler CreateLinkCompiler(ITextPart textPart) => new MetadataLinkCompiler(textPart); + + public partial class MetadataLinkCompiler : DrawableLinkCompiler + { + public MetadataLinkCompiler(ITextPart part) + : base(part) + { + } + + [BackgroundDependencyLoader] + private void load() + { + IdleColour = Color4.White; + } + } + } } } From 4f6b3644f3208293b1e659d79942de42a5505561 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 24 Dec 2022 12:40:32 -0800 Subject: [PATCH 3/7] Fix title/artist overflowing to right side --- .../BeatmapSet/BeatmapSetHeaderContent.cs | 121 +++++++++--------- 1 file changed, 62 insertions(+), 59 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index 357c9bc55d..b305e6ef05 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -48,9 +48,10 @@ public partial class BeatmapSetHeaderContent : CompositeDrawable private readonly LinkFlowContainer title, artist; private readonly AuthorInfo author; - private readonly ExplicitContentBeatmapBadge explicitContent; - private readonly SpotlightBeatmapBadge spotlight; - private readonly FeaturedArtistBeatmapBadge featuredArtist; + private ExplicitContentBeatmapBadge explicitContent; + private SpotlightBeatmapBadge spotlight; + private FeaturedArtistBeatmapBadge featuredArtist; + private ExternalLinkButton externalLink; private readonly FillFlowContainer downloadButtonsContainer; private readonly BeatmapAvailability beatmapAvailability; @@ -69,8 +70,6 @@ public partial class BeatmapSetHeaderContent : CompositeDrawable public BeatmapSetHeaderContent() { - ExternalLinkButton externalLink; - RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; InternalChild = new Container @@ -124,64 +123,19 @@ public BeatmapSetHeaderContent() AutoSizeAxes = Axes.Y, Child = Picker = new BeatmapPicker(), }, - new FillFlowContainer + title = new MetadataFlowContainer(s => + { + s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true); + }) { - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Top = 15 }, - Children = new Drawable[] - { - title = new MetadataFlowContainer(s => - { - s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true); - }) - { - AutoSizeAxes = Axes.Both, - }, - externalLink = new ExternalLinkButton - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Margin = new MarginPadding { Left = 5, Bottom = 4 }, // To better lineup with the font - }, - explicitContent = new ExplicitContentBeatmapBadge - { - Alpha = 0f, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Margin = new MarginPadding { Left = 10, Bottom = 4 }, - }, - spotlight = new SpotlightBeatmapBadge - { - Alpha = 0f, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Margin = new MarginPadding { Left = 10, Bottom = 4 }, - } - } }, - new FillFlowContainer + artist = new MetadataFlowContainer(s => + { + s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true); + }) { - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Bottom = 20 }, - Children = new Drawable[] - { - artist = new MetadataFlowContainer(s => - { - s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true); - }) - { - AutoSizeAxes = Axes.Both, - }, - featuredArtist = new FeaturedArtistBeatmapBadge - { - Alpha = 0f, - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Margin = new MarginPadding { Left = 10 } - } - } }, new Container { @@ -247,12 +201,17 @@ public BeatmapSetHeaderContent() Picker.Beatmap.ValueChanged += b => { Details.BeatmapInfo = b.NewValue; - externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineID}"; + updateExternalLink(); onlineStatusPill.Status = b.NewValue?.Status ?? BeatmapOnlineStatus.None; }; } + private void updateExternalLink() + { + if (externalLink != null) externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineID}#{Picker.Beatmap.Value?.Ruleset.ShortName}/{Picker.Beatmap.Value?.OnlineID}"; + } + [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider) { @@ -292,8 +251,49 @@ private void load(OverlayColourProvider colourProvider) artist.Clear(); title.AddLink(titleText, LinkAction.SearchBeatmapSet, titleText); + + title.AddArbitraryDrawable(new Container + { + AutoSizeAxes = Axes.Both, + Child = externalLink = new ExternalLinkButton + { + Margin = new MarginPadding { Left = 5 }, + } + }); + + title.AddArbitraryDrawable(new Container + { + AutoSizeAxes = Axes.Both, + Child = explicitContent = new ExplicitContentBeatmapBadge + { + Alpha = 0f, + Margin = new MarginPadding { Left = 10 }, + } + }); + + title.AddArbitraryDrawable(new Container + { + AutoSizeAxes = Axes.Both, + Child = spotlight = new SpotlightBeatmapBadge + { + Alpha = 0f, + Margin = new MarginPadding { Left = 10 }, + } + }); + artist.AddLink(artistText, LinkAction.SearchBeatmapSet, artistText); + artist.AddArbitraryDrawable(new Container + { + AutoSizeAxes = Axes.Both, + Child = featuredArtist = new FeaturedArtistBeatmapBadge + { + Alpha = 0f, + Margin = new MarginPadding { Left = 10 } + } + }); + + updateExternalLink(); explicitContent.Alpha = setInfo.NewValue.HasExplicitContent ? 1 : 0; spotlight.Alpha = setInfo.NewValue.FeaturedInSpotlight ? 1 : 0; featuredArtist.Alpha = setInfo.NewValue.TrackId != null ? 1 : 0; @@ -349,6 +349,9 @@ public partial class MetadataFlowContainer : LinkFlowContainer public MetadataFlowContainer(Action defaultCreationParameters = null) : base(defaultCreationParameters) { + TextAnchor = Anchor.CentreLeft; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; } protected override DrawableLinkCompiler CreateLinkCompiler(ITextPart textPart) => new MetadataLinkCompiler(textPart); From ae967e08b0c3cd07714d397c9bf0a58224b63b53 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 24 Dec 2022 13:27:46 -0800 Subject: [PATCH 4/7] Add badges when needed instead of using alpha --- .../BeatmapSet/BeatmapSetHeaderContent.cs | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index b305e6ef05..043844b56b 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -261,42 +261,36 @@ private void load(OverlayColourProvider colourProvider) } }); - title.AddArbitraryDrawable(new Container + if (setInfo.NewValue.HasExplicitContent) { - AutoSizeAxes = Axes.Both, - Child = explicitContent = new ExplicitContentBeatmapBadge + title.AddArbitraryDrawable(new Container { - Alpha = 0f, - Margin = new MarginPadding { Left = 10 }, - } - }); + AutoSizeAxes = Axes.Both, + Child = explicitContent = new ExplicitContentBeatmapBadge { Margin = new MarginPadding { Left = 10 } }, + }); + } - title.AddArbitraryDrawable(new Container + if (setInfo.NewValue.FeaturedInSpotlight) { - AutoSizeAxes = Axes.Both, - Child = spotlight = new SpotlightBeatmapBadge + title.AddArbitraryDrawable(new Container { - Alpha = 0f, - Margin = new MarginPadding { Left = 10 }, - } - }); + AutoSizeAxes = Axes.Both, + Child = spotlight = new SpotlightBeatmapBadge { Margin = new MarginPadding { Left = 10 } }, + }); + } artist.AddLink(artistText, LinkAction.SearchBeatmapSet, artistText); - artist.AddArbitraryDrawable(new Container + if (setInfo.NewValue.TrackId != null) { - AutoSizeAxes = Axes.Both, - Child = featuredArtist = new FeaturedArtistBeatmapBadge + artist.AddArbitraryDrawable(new Container { - Alpha = 0f, - Margin = new MarginPadding { Left = 10 } - } - }); + AutoSizeAxes = Axes.Both, + Child = featuredArtist = new FeaturedArtistBeatmapBadge { Margin = new MarginPadding { Left = 10 } } + }); + } updateExternalLink(); - explicitContent.Alpha = setInfo.NewValue.HasExplicitContent ? 1 : 0; - spotlight.Alpha = setInfo.NewValue.FeaturedInSpotlight ? 1 : 0; - featuredArtist.Alpha = setInfo.NewValue.TrackId != null ? 1 : 0; onlineStatusPill.FadeIn(500, Easing.OutQuint); From b871d6f078ebfff9eb859011693de8f439d41462 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 24 Dec 2022 13:35:17 -0800 Subject: [PATCH 5/7] Remove unused fields --- osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index 043844b56b..13506bfd1c 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -48,9 +48,6 @@ public partial class BeatmapSetHeaderContent : CompositeDrawable private readonly LinkFlowContainer title, artist; private readonly AuthorInfo author; - private ExplicitContentBeatmapBadge explicitContent; - private SpotlightBeatmapBadge spotlight; - private FeaturedArtistBeatmapBadge featuredArtist; private ExternalLinkButton externalLink; private readonly FillFlowContainer downloadButtonsContainer; @@ -266,7 +263,7 @@ private void load(OverlayColourProvider colourProvider) title.AddArbitraryDrawable(new Container { AutoSizeAxes = Axes.Both, - Child = explicitContent = new ExplicitContentBeatmapBadge { Margin = new MarginPadding { Left = 10 } }, + Child = new ExplicitContentBeatmapBadge { Margin = new MarginPadding { Left = 10 } }, }); } @@ -275,7 +272,7 @@ private void load(OverlayColourProvider colourProvider) title.AddArbitraryDrawable(new Container { AutoSizeAxes = Axes.Both, - Child = spotlight = new SpotlightBeatmapBadge { Margin = new MarginPadding { Left = 10 } }, + Child = new SpotlightBeatmapBadge { Margin = new MarginPadding { Left = 10 } }, }); } @@ -286,7 +283,7 @@ private void load(OverlayColourProvider colourProvider) artist.AddArbitraryDrawable(new Container { AutoSizeAxes = Axes.Both, - Child = featuredArtist = new FeaturedArtistBeatmapBadge { Margin = new MarginPadding { Left = 10 } } + Child = new FeaturedArtistBeatmapBadge { Margin = new MarginPadding { Left = 10 } } }); } From 8e899c2e9278db719507918405e7d2c315ae93c9 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Dec 2022 16:03:44 -0800 Subject: [PATCH 6/7] Use localisation parameters to find preferred string instead --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index b55b943023..983277135d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -354,7 +354,7 @@ public void HandleLink(LinkDetails link) => Schedule(() => case LinkAction.SearchBeatmapSet: if (link.Argument is RomanisableString romanisable) - SearchBeatmapSet(romanisable.GetPreferred(frameworkConfig.GetBindable(FrameworkSetting.ShowUnicode).Value)); + SearchBeatmapSet(romanisable.GetPreferred(Localisation.CurrentParameters.Value.PreferOriginalScript)); else SearchBeatmapSet(argString); break; From f959b02dc85d750b2d05ec13183d548e66e4252c Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Dec 2022 16:05:59 -0800 Subject: [PATCH 7/7] Use empty drawables for spacing badges instead --- .../BeatmapSet/BeatmapSetHeaderContent.cs | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index 13506bfd1c..17836b558c 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -249,42 +249,27 @@ private void load(OverlayColourProvider colourProvider) title.AddLink(titleText, LinkAction.SearchBeatmapSet, titleText); - title.AddArbitraryDrawable(new Container - { - AutoSizeAxes = Axes.Both, - Child = externalLink = new ExternalLinkButton - { - Margin = new MarginPadding { Left = 5 }, - } - }); + title.AddArbitraryDrawable(Empty().With(d => d.Width = 5)); + title.AddArbitraryDrawable(externalLink = new ExternalLinkButton()); if (setInfo.NewValue.HasExplicitContent) { - title.AddArbitraryDrawable(new Container - { - AutoSizeAxes = Axes.Both, - Child = new ExplicitContentBeatmapBadge { Margin = new MarginPadding { Left = 10 } }, - }); + title.AddArbitraryDrawable(Empty().With(d => d.Width = 10)); + title.AddArbitraryDrawable(new ExplicitContentBeatmapBadge()); } if (setInfo.NewValue.FeaturedInSpotlight) { - title.AddArbitraryDrawable(new Container - { - AutoSizeAxes = Axes.Both, - Child = new SpotlightBeatmapBadge { Margin = new MarginPadding { Left = 10 } }, - }); + title.AddArbitraryDrawable(Empty().With(d => d.Width = 10)); + title.AddArbitraryDrawable(new SpotlightBeatmapBadge()); } artist.AddLink(artistText, LinkAction.SearchBeatmapSet, artistText); if (setInfo.NewValue.TrackId != null) { - artist.AddArbitraryDrawable(new Container - { - AutoSizeAxes = Axes.Both, - Child = new FeaturedArtistBeatmapBadge { Margin = new MarginPadding { Left = 10 } } - }); + artist.AddArbitraryDrawable(Empty().With(d => d.Width = 10)); + artist.AddArbitraryDrawable(new FeaturedArtistBeatmapBadge()); } updateExternalLink();