diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs index 5a513f99e..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) { @@ -112,7 +114,6 @@ protected class DrawableLyricListItem : DrawableTextListItem public DrawableLyricListItem(Lyric? item) : base(item) { - Padding = new MarginPadding { Left = 5 }; } public override IEnumerable FilterTerms => new[] @@ -124,7 +125,7 @@ protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContai { if (model == null) { - // todo: show the empty text to let user select. + textFlowContainer.AddText(""); } else { 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..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 { @@ -52,13 +60,13 @@ public Popover GetPopover() => new LyricSelectorPopover(Current); } - public class LyricSelectorPopover : OsuPopover + 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; + } + } + } } } 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[]