diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs index 6ddd46ff8..81f11bf1c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/UserInterfaceV2/LyricSelector.cs @@ -129,16 +129,13 @@ protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContai } else { - Schedule(() => - { - // display the lyric order. - textFlowContainer.AddText($"#{model.Order}", x => x.Colour = colours.Yellow); - textFlowContainer.AddText(" "); - - // main text - textFlowContainer.AddText(model.Text); - textFlowContainer.AddText(" "); - }); + // display the lyric order. + textFlowContainer.AddText($"#{model.Order}", x => x.Colour = colours.Yellow); + textFlowContainer.AddText(" "); + + // main text + textFlowContainer.AddText(model.Text); + textFlowContainer.AddText(" "); } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledReferenceLyricSelector.cs similarity index 71% rename from osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs rename to osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledReferenceLyricSelector.cs index c2dad451e..7e0651abf 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledLyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/LabelledReferenceLyricSelector.cs @@ -21,9 +21,9 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Reference { - public class LabelledLyricSelector : LabelledComponent + public class LabelledReferenceLyricSelector : LabelledComponent { - public LabelledLyricSelector() + public LabelledReferenceLyricSelector() : base(true) { } @@ -34,8 +34,17 @@ protected override SelectLyricButton CreateComponent() RelativeSizeAxes = Axes.X }; + public Lyric? IgnoredLyric + { + get => Component.IgnoredLyric; + set => Component.IgnoredLyric = value; + } + public class SelectLyricButton : OsuButton, IHasCurrentValue, IHasPopover { + [Resolved, AllowNull] + private EditorBeatmap editorBeatmap { get; set; } + private readonly BindableWithCurrent current = new(); public Bindable Current @@ -44,6 +53,20 @@ public Bindable Current set => current.Current = value; } + private Lyric? ignoredLyric; + + public Lyric? IgnoredLyric + { + get => ignoredLyric; + set + { + ignoredLyric = value; + + // should not enable the selection if current lyric is being referenced. + Enabled.Value = ignoredLyric != null && !EditorBeatmapUtils.GetAllReferenceLyrics(editorBeatmap, ignoredLyric).Any(); + } + } + public SelectLyricButton() { Action = this.ShowPopover; @@ -57,15 +80,20 @@ public SelectLyricButton() } public Popover GetPopover() - => new LyricSelectorPopover(Current); + => new LyricSelectorPopover(Current, IgnoredLyric); } private class LyricSelectorPopover : OsuPopover { private readonly ReferenceLyricSelector lyricSelector; - public LyricSelectorPopover(Bindable bindable) + [Cached] + private readonly Lyric? ignoreLyric; + + public LyricSelectorPopover(Bindable bindable, Lyric? ignoreLyric) { + this.ignoreLyric = ignoreLyric; + Child = lyricSelector = new ReferenceLyricSelector { Width = 400, @@ -100,6 +128,9 @@ protected class DrawableReferenceLyricListItem : DrawableLyricListItem [Resolved, AllowNull] private EditorBeatmap editorBeatmap { get; set; } + [Resolved] + private Lyric? ignoredLyric { get; set; } + public DrawableReferenceLyricListItem(Lyric? item) : base(item) { @@ -116,27 +147,25 @@ protected override bool OnClick(ClickEvent 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; + base.CreateDisplayContent(textFlowContainer, model); + if (model == null) return; - Schedule(() => + // add reference text at the end of the text. + int referenceLyricsAmount = EditorBeatmapUtils.GetAllReferenceLyrics(editorBeatmap, model).Count(); + + if (referenceLyricsAmount > 0) { - // 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); - } - }); + textFlowContainer.AddText($"({referenceLyricsAmount} reference)", x => x.Colour = colours.Red); + } } - private static bool selectable(Lyric? lyric) => lyric?.ReferenceLyric == null; + private bool selectable(Lyric? lyric) + => lyric != ignoredLyric && lyric?.ReferenceLyric == null; } } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/ReferenceLyricSection.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/ReferenceLyricSection.cs index ba4538810..c1be3b8dc 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/ReferenceLyricSection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Extends/Reference/ReferenceLyricSection.cs @@ -16,20 +16,20 @@ public class ReferenceLyricSection : LyricPropertySection [Resolved, AllowNull] private ILyricReferenceChangeHandler lyricReferenceChangeHandler { get; set; } - private readonly LabelledLyricSelector labelledLyricSelector; + private readonly LabelledReferenceLyricSelector labelledReferenceLyricSelector; public ReferenceLyricSection() { Children = new[] { - labelledLyricSelector = new LabelledLyricSelector + labelledReferenceLyricSelector = new LabelledReferenceLyricSelector { Label = "Referenced lyric", Description = "Select the similar lyric that want to reference or sync the property." } }; - labelledLyricSelector.Current.BindValueChanged(x => + labelledReferenceLyricSelector.Current.BindValueChanged(x => { if (!IsRebinding) lyricReferenceChangeHandler.UpdateReferenceLyric(x.NewValue); @@ -41,7 +41,8 @@ protected override void OnLyricChanged(Lyric? lyric) if (lyric == null) return; - labelledLyricSelector.Current = lyric.ReferenceLyricBindable; + labelledReferenceLyricSelector.Current = lyric.ReferenceLyricBindable; + labelledReferenceLyricSelector.IgnoredLyric = lyric; } } } diff --git a/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/RearrangeableTextFlowListContainer.cs b/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/RearrangeableTextFlowListContainer.cs index 2a2033907..0a3548725 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/RearrangeableTextFlowListContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/RearrangeableTextFlowListContainer.cs @@ -95,7 +95,14 @@ protected override void LoadComplete() { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - }.With(x => CreateDisplayContent(x, Model)); + }.With(x => + { + Schedule(() => + { + // should create the text after BDL loaded. + CreateDisplayContent(x, Model); + }); + }); protected override bool OnClick(ClickEvent e) { diff --git a/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/FontSelector.cs b/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/FontSelector.cs index fe1a3b9d5..316fdea7b 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/FontSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/FontSelector.cs @@ -271,21 +271,18 @@ public DrawableFontFamilyListItem(string item) protected override void CreateDisplayContent(OsuTextFlowContainer textFlowContainer, string model) { textFlowContainer.TextAnchor = Anchor.BottomLeft; - Schedule(() => - { - textFlowContainer.AddText(model); + textFlowContainer.AddText(model); - var matchedFormat = fontManager.Fonts - .Where(x => x.Family == Model).Select(x => x.FontFormat) - .Distinct() - .ToArray(); + var matchedFormat = fontManager.Fonts + .Where(x => x.Family == Model).Select(x => x.FontFormat) + .Distinct() + .ToArray(); - foreach (var format in matchedFormat) - { - textFlowContainer.AddText(" "); - textFlowContainer.AddArbitraryDrawable(new FontFormatBadge(format)); - } - }); + foreach (var format in matchedFormat) + { + textFlowContainer.AddText(" "); + textFlowContainer.AddArbitraryDrawable(new FontFormatBadge(format)); + } } } }