From c5995acfff37684fabc9b53e3c005eb5f5184faa Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Jan 2020 12:30:25 +0800 Subject: [PATCH 01/12] linkify metadata --- osu.Game/Online/Chat/MessageFormatter.cs | 3 +- osu.Game/OsuGame.cs | 10 ++++++ osu.Game/Overlays/BeatmapSet/Info.cs | 43 +++++++++++++++++------ osu.Game/Overlays/DirectOverlay.cs | 6 ++++ osu.Game/Screens/Select/BeatmapDetails.cs | 42 +++++++++++++++++----- 5 files changed, 85 insertions(+), 19 deletions(-) diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs index 717de18c14..cfd0dcca50 100644 --- a/osu.Game/Online/Chat/MessageFormatter.cs +++ b/osu.Game/Online/Chat/MessageFormatter.cs @@ -279,7 +279,8 @@ namespace osu.Game.Online.Chat JoinMultiplayerMatch, Spectate, OpenUserProfile, - Custom + Custom, + OpenDirectWithSearch } public class Link : IComparable diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index ff46c6d849..78e033c972 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -244,6 +244,10 @@ namespace osu.Game ShowChannel(link.Argument); break; + case LinkAction.OpenDirectWithSearch: + ShowDirectWithSearch(link.Argument); + break; + case LinkAction.OpenEditorTimestamp: case LinkAction.JoinMultiplayerMatch: case LinkAction.Spectate: @@ -310,6 +314,12 @@ namespace osu.Game /// The beatmap to show. public void ShowBeatmap(int beatmapId) => waitForReady(() => beatmapSetOverlay, _ => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId)); + /// + /// Show Direct with a query. + /// + /// The query to search for.null + public void ShowDirectWithSearch(string query) => waitForReady(() => direct, _ => direct.ShowWithSearch(query)); + /// /// Present a beatmap at song select immediately. /// The user should have already requested this interactively. diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 16d6236051..b621cf1cce 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -8,10 +8,13 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Online.Chat; +using osu.Game.Screens.Select; using osuTK; using osuTK.Graphics; @@ -68,7 +71,7 @@ namespace osu.Game.Overlays.BeatmapSet Child = new Container { RelativeSizeAxes = Axes.Both, - Child = new MetadataSection("Description"), + Child = new MetadataSection(MetadataType.Description), }, }, new Container @@ -86,10 +89,10 @@ namespace osu.Game.Overlays.BeatmapSet Direction = FillDirection.Full, Children = new[] { - source = new MetadataSection("Source"), - genre = new MetadataSection("Genre") { Width = 0.5f }, - language = new MetadataSection("Language") { Width = 0.5f }, - tags = new MetadataSection("Tags"), + source = new MetadataSection(MetadataType.Source), + genre = new MetadataSection(MetadataType.Genre) { Width = 0.5f }, + language = new MetadataSection(MetadataType.Language) { Width = 0.5f }, + tags = new MetadataSection(MetadataType.Tags), }, }, }, @@ -133,8 +136,9 @@ namespace osu.Game.Overlays.BeatmapSet private class MetadataSection : FillFlowContainer { + private readonly MetadataType type; private readonly OsuSpriteText header; - private readonly TextFlowContainer textFlow; + private readonly LinkFlowContainer textFlow; public string Text { @@ -147,13 +151,32 @@ namespace osu.Game.Overlays.BeatmapSet } this.FadeIn(transition_duration); + textFlow.Clear(); - textFlow.AddText(value, s => s.Font = s.Font.With(size: 14)); + static void format(SpriteText t) => t.Font = t.Font.With(size: 14); + + switch(type) + { + case MetadataType.Tags: + foreach (string tag in value.Split(" ")) + textFlow.AddLink(tag + " ", LinkAction.OpenDirectWithSearch, tag, null, format); + break; + + case MetadataType.Source: + textFlow.AddLink(value, LinkAction.OpenDirectWithSearch, value, null, format); + break; + + default: + textFlow.AddText(value, format); + break; + } } } - public MetadataSection(string title) + public MetadataSection(MetadataType type) { + this.type = type; + RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Spacing = new Vector2(5f); @@ -162,12 +185,12 @@ namespace osu.Game.Overlays.BeatmapSet { header = new OsuSpriteText { - Text = title, + Text = this.type.ToString(), Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), Shadow = false, Margin = new MarginPadding { Top = 20 }, }, - textFlow = new OsuTextFlowContainer + textFlow = new LinkFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index e4cef319fe..c8e72cc6c9 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -154,6 +154,12 @@ namespace osu.Game.Overlays updateResultCounts(); } + public void ShowWithSearch(string query) + { + currentQuery.Value = query; + Show(); + } + [BackgroundDependencyLoader] private void load(OsuColour colours, RulesetStore rulesets, PreviewTrackManager previewTrackManager) { diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 577d999388..07a18ac5a3 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -19,6 +19,8 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.API.Requests; using osu.Game.Rulesets; +using osu.Game.Overlays; +using osu.Game.Online.Chat; namespace osu.Game.Screens.Select { @@ -127,9 +129,9 @@ namespace osu.Game.Screens.Select Margin = new MarginPadding { Top = spacing * 2 }, Children = new[] { - description = new MetadataSection("Description"), - source = new MetadataSection("Source"), - tags = new MetadataSection("Tags"), + description = new MetadataSection(MetadataType.Description), + source = new MetadataSection(MetadataType.Source), + tags = new MetadataSection(MetadataType.Tags), }, }, }, @@ -299,10 +301,11 @@ namespace osu.Game.Screens.Select private class MetadataSection : Container { private readonly FillFlowContainer textContainer; + private readonly MetadataType type; private TextFlowContainer textFlow; - - public MetadataSection(string title) + public MetadataSection(MetadataType type) { + this.type = type; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -320,7 +323,7 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Y, Child = new OsuSpriteText { - Text = title, + Text = this.type.ToString(), Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), }, }, @@ -346,15 +349,29 @@ namespace osu.Game.Screens.Select private void setTextAsync(string text) { - LoadComponentAsync(new OsuTextFlowContainer(s => s.Font = s.Font.With(size: 14)) + LoadComponentAsync(new LinkFlowContainer(s => s.Font = s.Font.With(size: 14)) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Colour = Color4.White.Opacity(0.75f), - Text = text }, loaded => { textFlow?.Expire(); + + switch(type) + { + case MetadataType.Tags: + foreach (string tag in text.Split(" ")) + loaded.AddLink(tag + " ", LinkAction.OpenDirectWithSearch, tag); + break; + case MetadataType.Source: + loaded.AddLink(text, LinkAction.OpenDirectWithSearch, text); + break; + default: + loaded.AddText(text); + break; + } + textContainer.Add(textFlow = loaded); // fade in if we haven't yet. @@ -363,4 +380,13 @@ namespace osu.Game.Screens.Select } } } + + public enum MetadataType + { + Tags, + Source, + Description, + Genre, + Language + } } From 2274d70dacbea11dbf6012eefa69cbdbeb88f860 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Jan 2020 06:41:50 +0800 Subject: [PATCH 02/12] apply suggestions --- osu.Game/Online/Chat/MessageFormatter.cs | 2 +- osu.Game/OsuGame.cs | 8 ++++---- osu.Game/Overlays/BeatmapSet/Info.cs | 12 +++++++++--- osu.Game/Screens/Select/BeatmapDetails.cs | 12 +++++++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs index cfd0dcca50..28cb57227d 100644 --- a/osu.Game/Online/Chat/MessageFormatter.cs +++ b/osu.Game/Online/Chat/MessageFormatter.cs @@ -279,8 +279,8 @@ namespace osu.Game.Online.Chat JoinMultiplayerMatch, Spectate, OpenUserProfile, + SearchBeatmapSet, Custom, - OpenDirectWithSearch } public class Link : IComparable diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 78e033c972..1aa4017665 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -244,8 +244,8 @@ namespace osu.Game ShowChannel(link.Argument); break; - case LinkAction.OpenDirectWithSearch: - ShowDirectWithSearch(link.Argument); + case LinkAction.SearchBeatmapSet: + SearchBeatmapSet(link.Argument); break; case LinkAction.OpenEditorTimestamp: @@ -317,8 +317,8 @@ namespace osu.Game /// /// Show Direct with a query. /// - /// The query to search for.null - public void ShowDirectWithSearch(string query) => waitForReady(() => direct, _ => direct.ShowWithSearch(query)); + /// The query to search for. + public void SearchBeatmapSet(string query) => waitForReady(() => direct, _ => direct.ShowWithSearch(query)); /// /// Present a beatmap at song select immediately. diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index b621cf1cce..c566cfa859 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -158,12 +158,18 @@ namespace osu.Game.Overlays.BeatmapSet switch(type) { case MetadataType.Tags: - foreach (string tag in value.Split(" ")) - textFlow.AddLink(tag + " ", LinkAction.OpenDirectWithSearch, tag, null, format); + string[] tags = value.Split(" "); + for (int i = 0; i <= tags.Length - 1; i++) + { + textFlow.AddLink(tags[i], LinkAction.SearchBeatmapSet, tags[i], null, format); + + if (i != tags.Length - 1) + textFlow.AddText(" ", format); + } break; case MetadataType.Source: - textFlow.AddLink(value, LinkAction.OpenDirectWithSearch, value, null, format); + textFlow.AddLink(value, LinkAction.SearchBeatmapSet, value, null, format); break; default: diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 07a18ac5a3..42e4c22ff1 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -361,11 +361,17 @@ namespace osu.Game.Screens.Select switch(type) { case MetadataType.Tags: - foreach (string tag in text.Split(" ")) - loaded.AddLink(tag + " ", LinkAction.OpenDirectWithSearch, tag); + string[] tags = text.Split(" "); + for (int i = 0; i <= tags.Length - 1; i++) + { + loaded.AddLink(tags[i], LinkAction.SearchBeatmapSet, tags[i]); + + if (i != tags.Length - 1) + loaded.AddText(" "); + } break; case MetadataType.Source: - loaded.AddLink(text, LinkAction.OpenDirectWithSearch, text); + loaded.AddLink(text, LinkAction.SearchBeatmapSet, text); break; default: loaded.AddText(text); From b916366536b3bd0b4f13a377237aaa6788d1d0c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Jan 2020 08:17:39 +0800 Subject: [PATCH 03/12] fix formatting --- osu.Game/Overlays/BeatmapSet/Info.cs | 2 +- osu.Game/Screens/Select/BeatmapDetails.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index c566cfa859..8be9462ffc 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -155,7 +155,7 @@ namespace osu.Game.Overlays.BeatmapSet textFlow.Clear(); static void format(SpriteText t) => t.Font = t.Font.With(size: 14); - switch(type) + switch (type) { case MetadataType.Tags: string[] tags = value.Split(" "); diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 42e4c22ff1..cd5d2e8e45 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -358,7 +358,7 @@ namespace osu.Game.Screens.Select { textFlow?.Expire(); - switch(type) + switch (type) { case MetadataType.Tags: string[] tags = text.Split(" "); From 2952fc8cc4ec21b146c1d2f6187608284bd28cae Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Jan 2020 09:05:13 +0800 Subject: [PATCH 04/12] remove unused using --- osu.Game/Screens/Select/BeatmapDetails.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index cd5d2e8e45..59f97d696e 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -19,7 +19,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.API.Requests; using osu.Game.Rulesets; -using osu.Game.Overlays; using osu.Game.Online.Chat; namespace osu.Game.Screens.Select From 4ecf2c0512ff830b69d4d62483ab664e4a42eb24 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Mar 2020 14:19:15 +0800 Subject: [PATCH 05/12] remove unused property --- osu.Game/Overlays/BeatmapSet/Info.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index c789b06dd6..c69684f314 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -142,7 +142,6 @@ namespace osu.Game.Overlays.BeatmapSet private class MetadataSection : FillFlowContainer { private readonly MetadataType type; - private readonly OsuSpriteText header; private readonly LinkFlowContainer textFlow; public string Text From 0522500a572a8125529ad399cc628fc558b407b1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 1 Jul 2021 19:45:17 +0900 Subject: [PATCH 06/12] Fix a couple of merge oversights --- osu.Game/Overlays/BeatmapListingOverlay.cs | 6 +++++- osu.Game/Screens/Select/BeatmapDetails.cs | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListingOverlay.cs b/osu.Game/Overlays/BeatmapListingOverlay.cs index 4552c8d11b..6861d17f26 100644 --- a/osu.Game/Overlays/BeatmapListingOverlay.cs +++ b/osu.Game/Overlays/BeatmapListingOverlay.cs @@ -89,7 +89,11 @@ namespace osu.Game.Overlays }; } - public void ShowWithSearch(string query) => filterControl.Search(query); + public void ShowWithSearch(string query) + { + filterControl.Search(query); + Show(); + } protected override BeatmapListingHeader CreateHeader() => new BeatmapListingHeader(); diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 38478ce461..d7dc73cb37 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -149,9 +149,6 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - description = new MetadataSection(MetadataType.Description), - source = new MetadataSection(MetadataType.Source), - tags = new MetadataSection(MetadataType.Tags), new OsuSpriteText { Text = "Points of Failure", From ecb4982281dd71c48b9e3ee0ffde5a2e5919c41b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 2 Jul 2021 17:51:54 +0900 Subject: [PATCH 07/12] Add missing blank lines --- osu.Game/Overlays/BeatmapSet/Info.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 89fcbae93d..a1adadbc47 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -163,6 +163,7 @@ namespace osu.Game.Overlays.BeatmapSet { case MetadataType.Tags: string[] tags = value.Split(" "); + for (int i = 0; i <= tags.Length - 1; i++) { textFlow.AddLink(tags[i], LinkAction.SearchBeatmapSet, tags[i], null, format); @@ -170,6 +171,7 @@ namespace osu.Game.Overlays.BeatmapSet if (i != tags.Length - 1) textFlow.AddText(" ", format); } + break; case MetadataType.Source: From eacf867073b17d204fc53feaacfb4faaa06e4507 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 2 Jul 2021 17:58:24 +0900 Subject: [PATCH 08/12] Move shared types into their own classes --- osu.Game/Overlays/BeatmapSet/Info.cs | 75 -------------- osu.Game/Screens/Select/BeatmapDetails.cs | 108 ------------------- osu.Game/Screens/Select/MetadataSection.cs | 115 +++++++++++++++++++++ osu.Game/Screens/Select/MetadataType.cs | 14 +++ 4 files changed, 129 insertions(+), 183 deletions(-) create mode 100644 osu.Game/Screens/Select/MetadataSection.cs create mode 100644 osu.Game/Screens/Select/MetadataType.cs diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index a1adadbc47..8f5d97a6d3 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -6,14 +6,10 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osu.Game.Online.Chat; using osu.Game.Screens.Select; -using osuTK; namespace osu.Game.Overlays.BeatmapSet { @@ -138,76 +134,5 @@ namespace osu.Game.Overlays.BeatmapSet successRateBackground.Colour = colourProvider.Background4; background.Colour = colourProvider.Background5; } - - private class MetadataSection : FillFlowContainer - { - private readonly MetadataType type; - private readonly LinkFlowContainer textFlow; - - public string Text - { - set - { - if (string.IsNullOrEmpty(value)) - { - Hide(); - return; - } - - this.FadeIn(transition_duration); - - textFlow.Clear(); - static void format(SpriteText t) => t.Font = t.Font.With(size: 12); - - switch (type) - { - case MetadataType.Tags: - string[] tags = value.Split(" "); - - for (int i = 0; i <= tags.Length - 1; i++) - { - textFlow.AddLink(tags[i], LinkAction.SearchBeatmapSet, tags[i], null, format); - - if (i != tags.Length - 1) - textFlow.AddText(" ", format); - } - - break; - - case MetadataType.Source: - textFlow.AddLink(value, LinkAction.SearchBeatmapSet, value, null, format); - break; - - default: - textFlow.AddText(value, format); - break; - } - } - } - - public MetadataSection(MetadataType type) - { - this.type = type; - - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Spacing = new Vector2(5f); - - InternalChildren = new Drawable[] - { - new OsuSpriteText - { - Text = this.type.ToString(), - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), - Margin = new MarginPadding { Top = 15 }, - }, - textFlow = new LinkFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - }, - }; - } - } } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index d7dc73cb37..d6c108cee0 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -15,7 +15,6 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online; using osu.Game.Online.API; using osu.Game.Online.API.Requests; -using osu.Game.Online.Chat; using osu.Game.Rulesets; using osu.Game.Screens.Select.Details; using osuTK; @@ -129,8 +128,6 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Y, LayoutDuration = transition_duration, LayoutEasing = Easing.OutQuad, - Spacing = new Vector2(spacing * 2), - Margin = new MarginPadding { Top = spacing * 2 }, Children = new[] { description = new MetadataSection(MetadataType.Description), @@ -291,110 +288,5 @@ namespace osu.Game.Screens.Select }; } } - - private class MetadataSection : Container - { - private readonly FillFlowContainer textContainer; - private readonly MetadataType type; - private TextFlowContainer textFlow; - - public MetadataSection(MetadataType type) - { - this.type = type; - - Alpha = 0; - - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - - InternalChild = textContainer = new FillFlowContainer - { - Alpha = 0, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(spacing / 2), - Children = new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Child = new OsuSpriteText - { - Text = this.type.ToString(), - Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), - }, - }, - }, - }; - } - - public string Text - { - set - { - if (string.IsNullOrEmpty(value)) - { - this.FadeOut(transition_duration); - return; - } - - this.FadeIn(transition_duration); - - setTextAsync(value); - } - } - - private void setTextAsync(string text) - { - LoadComponentAsync(new LinkFlowContainer(s => s.Font = s.Font.With(size: 14)) - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Colour = Color4.White.Opacity(0.75f), - }, loaded => - { - textFlow?.Expire(); - - switch (type) - { - case MetadataType.Tags: - string[] tags = text.Split(" "); - - for (int i = 0; i <= tags.Length - 1; i++) - { - loaded.AddLink(tags[i], LinkAction.SearchBeatmapSet, tags[i]); - - if (i != tags.Length - 1) - loaded.AddText(" "); - } - - break; - - case MetadataType.Source: - loaded.AddLink(text, LinkAction.SearchBeatmapSet, text); - break; - - default: - loaded.AddText(text); - break; - } - - textContainer.Add(textFlow = loaded); - - // fade in if we haven't yet. - textContainer.FadeIn(transition_duration); - }); - } - } - } - - public enum MetadataType - { - Tags, - Source, - Description, - Genre, - Language } } diff --git a/osu.Game/Screens/Select/MetadataSection.cs b/osu.Game/Screens/Select/MetadataSection.cs new file mode 100644 index 0000000000..989223fff2 --- /dev/null +++ b/osu.Game/Screens/Select/MetadataSection.cs @@ -0,0 +1,115 @@ +// 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.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Online.Chat; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.Select +{ + public class MetadataSection : Container + { + private readonly FillFlowContainer textContainer; + private readonly MetadataType type; + private TextFlowContainer textFlow; + + private const float transition_duration = 250; + + public MetadataSection(MetadataType type) + { + this.type = type; + + Alpha = 0; + + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChild = textContainer = new FillFlowContainer + { + Alpha = 0, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + + Margin = new MarginPadding { Top = 15 }, + Spacing = new Vector2(5), + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Child = new OsuSpriteText + { + Text = this.type.ToString(), + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), + }, + }, + }, + }; + } + + public string Text + { + set + { + if (string.IsNullOrEmpty(value)) + { + this.FadeOut(transition_duration); + return; + } + + this.FadeIn(transition_duration); + + setTextAsync(value); + } + } + + private void setTextAsync(string text) + { + LoadComponentAsync(new LinkFlowContainer(s => s.Font = s.Font.With(size: 14)) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Colour = Color4.White.Opacity(0.75f), + }, loaded => + { + textFlow?.Expire(); + + switch (type) + { + case MetadataType.Tags: + string[] tags = text.Split(" "); + + for (int i = 0; i <= tags.Length - 1; i++) + { + loaded.AddLink(tags[i], LinkAction.SearchBeatmapSet, tags[i]); + + if (i != tags.Length - 1) + loaded.AddText(" "); + } + + break; + + case MetadataType.Source: + loaded.AddLink(text, LinkAction.SearchBeatmapSet, text); + break; + + default: + loaded.AddText(text); + break; + } + + textContainer.Add(textFlow = loaded); + + // fade in if we haven't yet. + textContainer.FadeIn(transition_duration); + }); + } + } +} diff --git a/osu.Game/Screens/Select/MetadataType.cs b/osu.Game/Screens/Select/MetadataType.cs new file mode 100644 index 0000000000..b0b8f5677d --- /dev/null +++ b/osu.Game/Screens/Select/MetadataType.cs @@ -0,0 +1,14 @@ +// 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.Screens.Select +{ + public enum MetadataType + { + Tags, + Source, + Description, + Genre, + Language + } +} From 362816492fb6e70d246335ad00ed9f151d92ad9f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 2 Jul 2021 18:09:16 +0900 Subject: [PATCH 09/12] Move to more friendly namespace --- .../{Screens/Select => Overlays/BeatmapSet}/MetadataSection.cs | 3 ++- .../{Screens/Select => Overlays/BeatmapSet}/MetadataType.cs | 2 +- osu.Game/Screens/Select/BeatmapDetails.cs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) rename osu.Game/{Screens/Select => Overlays/BeatmapSet}/MetadataSection.cs (97%) rename osu.Game/{Screens/Select => Overlays/BeatmapSet}/MetadataType.cs (87%) diff --git a/osu.Game/Screens/Select/MetadataSection.cs b/osu.Game/Overlays/BeatmapSet/MetadataSection.cs similarity index 97% rename from osu.Game/Screens/Select/MetadataSection.cs rename to osu.Game/Overlays/BeatmapSet/MetadataSection.cs index 989223fff2..50e95bb04b 100644 --- a/osu.Game/Screens/Select/MetadataSection.cs +++ b/osu.Game/Overlays/BeatmapSet/MetadataSection.cs @@ -8,10 +8,11 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; +using osu.Game.Screens.Select; using osuTK; using osuTK.Graphics; -namespace osu.Game.Screens.Select +namespace osu.Game.Overlays.BeatmapSet { public class MetadataSection : Container { diff --git a/osu.Game/Screens/Select/MetadataType.cs b/osu.Game/Overlays/BeatmapSet/MetadataType.cs similarity index 87% rename from osu.Game/Screens/Select/MetadataType.cs rename to osu.Game/Overlays/BeatmapSet/MetadataType.cs index b0b8f5677d..1ab4c6887e 100644 --- a/osu.Game/Screens/Select/MetadataType.cs +++ b/osu.Game/Overlays/BeatmapSet/MetadataType.cs @@ -1,7 +1,7 @@ // 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.Screens.Select +namespace osu.Game.Overlays.BeatmapSet { public enum MetadataType { diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index d6c108cee0..973f54c038 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -15,6 +15,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Overlays.BeatmapSet; using osu.Game.Rulesets; using osu.Game.Screens.Select.Details; using osuTK; From 16d08df5e29492c679f031c3bf298c0ff64d78dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 3 Jul 2021 15:22:03 +0200 Subject: [PATCH 10/12] Remove mention of direct from xmldoc --- 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 1ac3a69233..2ab1fa3a1f 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -367,7 +367,7 @@ namespace osu.Game public void ShowBeatmap(int beatmapId) => waitForReady(() => beatmapSetOverlay, _ => beatmapSetOverlay.FetchAndShowBeatmap(beatmapId)); /// - /// Show Direct with a query. + /// Shows the beatmap listing overlay, with the given in the search box. /// /// The query to search for. public void SearchBeatmapSet(string query) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithSearch(query)); From 7dae93ad669eff61cd5fb51173dd3cfc6ca09405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 3 Jul 2021 15:23:26 +0200 Subject: [PATCH 11/12] Remove unused using directives --- osu.Game/Overlays/BeatmapSet/Info.cs | 1 - osu.Game/Overlays/BeatmapSet/MetadataSection.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 8f5d97a6d3..5a752e20fb 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Select; namespace osu.Game.Overlays.BeatmapSet { diff --git a/osu.Game/Overlays/BeatmapSet/MetadataSection.cs b/osu.Game/Overlays/BeatmapSet/MetadataSection.cs index 50e95bb04b..3648c55714 100644 --- a/osu.Game/Overlays/BeatmapSet/MetadataSection.cs +++ b/osu.Game/Overlays/BeatmapSet/MetadataSection.cs @@ -8,7 +8,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; -using osu.Game.Screens.Select; using osuTK; using osuTK.Graphics; From 6fb8ed4d070b98854102dc45aecdf622ef0836d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 3 Jul 2021 15:47:46 +0200 Subject: [PATCH 12/12] Trim no longer used constant --- osu.Game/Overlays/BeatmapSet/Info.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 5a752e20fb..f9b8de9dba 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -14,7 +14,6 @@ namespace osu.Game.Overlays.BeatmapSet { public class Info : Container { - private const float transition_duration = 250; private const float metadata_width = 175; private const float spacing = 20; private const float base_height = 220;