From 69bdd51aa2a0ceaa39ff56f7dcba019a5536003b Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 4 Sep 2022 16:32:12 +0800 Subject: [PATCH 1/4] Should not show the drag handler at default. --- .../Edit/Components/UserInterfaceV2/LyricSelector.cs | 1 - .../Graphics/UserInterface/RearrangeableTextFlowListContainer.cs | 1 + .../Graphics/UserInterfaceV2/LanguageSelector.cs | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs index 5a513f99e..c3efdb92f 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs @@ -112,7 +112,6 @@ protected class DrawableLyricListItem : DrawableTextListItem public DrawableLyricListItem(Lyric? item) : base(item) { - Padding = new MarginPadding { Left = 5 }; } public override IEnumerable FilterTerms => new[] diff --git a/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/RearrangeableTextFlowListContainer.cs b/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/RearrangeableTextFlowListContainer.cs index 8519bcb59..2a2033907 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/RearrangeableTextFlowListContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/RearrangeableTextFlowListContainer.cs @@ -66,6 +66,7 @@ public DrawableTextListItem(TModel item) : base(item) { Padding = new MarginPadding { Left = 5 }; + ShowDragHandle.Value = false; } [BackgroundDependencyLoader] diff --git a/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LanguageSelector.cs b/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LanguageSelector.cs index 749fbb8b5..82c40857b 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LanguageSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LanguageSelector.cs @@ -101,7 +101,6 @@ private class DrawableLanguageListItem : DrawableTextListItem public DrawableLanguageListItem(CultureInfo item) : base(item) { - Padding = new MarginPadding { Left = 5 }; } public override IEnumerable FilterTerms => new[] From 3377410f7d276e06907c19e30bba9b07f53b4f15 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 4 Sep 2022 17:07:55 +0800 Subject: [PATCH 2/4] Show the empty text if there's no lyric. --- .../Edit/Components/UserInterfaceV2/LyricSelector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs index c3efdb92f..0c6f4cfc0 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs @@ -123,7 +123,7 @@ protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContai { if (model == null) { - // todo: show the empty text to let user select. + textFlowContainer.AddText(""); } else { From baada9f38cc524ea0b257eba513abf3ad8bae3c0 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 4 Sep 2022 17:01:10 +0800 Subject: [PATCH 3/4] Make the class private. --- .../Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs index b5940ed68..c77059a91 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs @@ -52,7 +52,7 @@ public Popover GetPopover() => new LyricSelectorPopover(Current); } - public class LyricSelectorPopover : OsuPopover + private class LyricSelectorPopover : OsuPopover { private readonly LyricSelector lyricSelector; From 34f60d98254687b080cd3cdbaa0eca386992545d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 4 Sep 2022 17:09:11 +0800 Subject: [PATCH 4/4] Show the reference lyric amount at the end of the lyric. Also, should not allow to click if the lyric already has reference lyric. merge. --- .../UserInterfaceV2/LyricSelector.cs | 12 ++-- .../Reference/LabelledLyricSelector.cs | 71 ++++++++++++++++++- 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs index 0c6f4cfc0..6ddd46ff8 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs @@ -60,14 +60,14 @@ public LyricSelector() }, new Drawable[] { - lyricList = new RearrangeableLyricListContainer + lyricList = CreateRearrangeableLyricListContainer().With(x => { - RelativeSizeAxes = Axes.Both, - RequestSelection = item => + x.RelativeSizeAxes = Axes.Both; + x.RequestSelection = item => { Current.Value = item; - }, - } + }; + }) } } }; @@ -76,6 +76,8 @@ public LyricSelector() Current.BindValueChanged(e => lyricList.SelectedSet.Value = e.NewValue); } + protected virtual RearrangeableLyricListContainer CreateRearrangeableLyricListContainer() => new(); + [BackgroundDependencyLoader] private void load(EditorBeatmap editorBeatmap) { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs index c77059a91..c2dad451e 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs @@ -1,15 +1,23 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input.Events; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Rulesets.Karaoke.Edit.Components.UserInterfaceV2; +using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Screens.Edit; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Reference { @@ -54,11 +62,11 @@ public Popover GetPopover() private class LyricSelectorPopover : OsuPopover { - private readonly LyricSelector lyricSelector; + private readonly ReferenceLyricSelector lyricSelector; public LyricSelectorPopover(Bindable bindable) { - Child = lyricSelector = new LyricSelector + Child = lyricSelector = new ReferenceLyricSelector { Width = 400, Height = 600, @@ -73,5 +81,64 @@ protected override void LoadComplete() GetContainingInputManager().ChangeFocus(lyricSelector); } } + + protected class ReferenceLyricSelector : LyricSelector + { + protected override RearrangeableLyricListContainer CreateRearrangeableLyricListContainer() + => new RearrangeableReferenceLyricListContainer(); + + protected class RearrangeableReferenceLyricListContainer : RearrangeableLyricListContainer + { + protected override DrawableTextListItem CreateDrawable(Lyric? item) + => new DrawableReferenceLyricListItem(item); + + protected class DrawableReferenceLyricListItem : DrawableLyricListItem + { + [Resolved, AllowNull] + private OsuColour colours { get; set; } + + [Resolved, AllowNull] + private EditorBeatmap editorBeatmap { get; set; } + + public DrawableReferenceLyricListItem(Lyric? item) + : base(item) + { + } + + protected override bool OnClick(ClickEvent e) + { + // cannot select those lyric that already contains reference lyric. + if (!selectable(Model)) + return false; + + return base.OnClick(e); + } + + protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContainer, Lyric? model) + { + base.CreateDisplayContent(textFlowContainer, model); + + // should have disable style if lyric is not selectable. + textFlowContainer.Alpha = selectable(model) ? 1 : 0.5f; + + if (model == null) + return; + + Schedule(() => + { + // add reference text at the end of the text. + int referenceLyricsAmount = EditorBeatmapUtils.GetAllReferenceLyrics(editorBeatmap, model).Count(); + + if (referenceLyricsAmount > 0) + { + textFlowContainer.AddText($"({referenceLyricsAmount} reference)", x => x.Colour = colours.Red); + } + }); + } + + private static bool selectable(Lyric? lyric) => lyric?.ReferenceLyric == null; + } + } + } } }