From d61e970ef4efb2e73125db9c88692ee1f91d6e04 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 29 Sep 2023 00:15:28 +0800 Subject: [PATCH 01/13] Guess it's hard to copy/paste the romaji from the time-tag. --- .../Beatmaps/Lyrics/LyricEditorClipboard.cs | 28 ++----------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs index 63a309d7b..1be1ea16d 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs @@ -199,15 +199,7 @@ private bool performCut() return true; case LyricEditorMode.EditRomaji: - var romajies = editRomajiModeState.SelectedItems; - if (!romajies.Any()) - return false; - - if (lyricRomajiTagsChangeHandler == null) - throw new NullDependencyException($"Missing {nameof(lyricRomajiTagsChangeHandler)}"); - - lyricRomajiTagsChangeHandler.RemoveRange(romajies); - return true; + return false; case LyricEditorMode.EditNote: return false; @@ -280,13 +272,7 @@ private bool performCopy(Lyric lyric) return true; case LyricEditorMode.EditRomaji: - var romajies = editRomajiModeState.SelectedItems; - if (!romajies.Any()) - return false; - - saveObjectToTheClipboardContent(romajies); - copyObjectToClipboard(romajies); - return true; + return false; case LyricEditorMode.EditNote: return false; @@ -372,15 +358,7 @@ private bool performPaste(Lyric lyric) return true; case LyricEditorMode.EditRomaji: - var pasteRomajies = getObjectFromClipboardContent(); - if (pasteRomajies == null) - return false; - - if (lyricRomajiTagsChangeHandler == null) - throw new NullDependencyException($"Missing {nameof(lyricRomajiTagsChangeHandler)}"); - - lyricRomajiTagsChangeHandler.AddRange(pasteRomajies); - return true; + return false; case LyricEditorMode.EditNote: return false; From 0eb094cc3fd9750d1a18da858655fa1d062bb73a Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 29 Sep 2023 00:14:11 +0800 Subject: [PATCH 02/13] Remove Blueprint container for the romaji tag. Should re-design it if needed. --- .../Components/Lyrics/BlueprintLayer.cs | 1 - .../Blueprints/RomajiBlueprintContainer.cs | 45 ------ .../Blueprints/RomajiTagSelectionBlueprint.cs | 38 ----- .../Blueprints/RubyBlueprintContainer.cs | 131 +++++++++++++++- .../Blueprints/RubyTagSelectionBlueprint.cs | 90 ++++++++++- .../Blueprints/TextTagBlueprintContainer.cs | 146 ------------------ .../Blueprints/TextTagSelectionBlueprint.cs | 108 ------------- 7 files changed, 211 insertions(+), 348 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RomajiBlueprintContainer.cs delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RomajiTagSelectionBlueprint.cs delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/TextTagBlueprintContainer.cs delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/TextTagSelectionBlueprint.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/BlueprintLayer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/BlueprintLayer.cs index 9cb41a9ce..991b5d051 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/BlueprintLayer.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/BlueprintLayer.cs @@ -66,7 +66,6 @@ protected void InitializeBlueprint() { LyricEditorMode.EditRuby => rubyTagEditMode == RubyTagEditMode.Create ? null : new RubyBlueprintContainer(lyric), LyricEditorMode.EditTimeTag => modeWithEditStep.EditStep is TimeTagEditStep.Adjust ? new TimeTagBlueprintContainer(lyric) : null, - LyricEditorMode.EditRomaji => new RomajiBlueprintContainer(lyric), _ => null, }; } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RomajiBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RomajiBlueprintContainer.cs deleted file mode 100644 index 29d99ba9d..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RomajiBlueprintContainer.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Game.Rulesets.Edit; -using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; -using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -using osu.Game.Screens.Edit.Compose.Components; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Blueprints; - -public partial class RomajiBlueprintContainer : TextTagBlueprintContainer -{ - public RomajiBlueprintContainer(Lyric lyric) - : base(lyric) - { - } - - protected override BindableList GetProperties(Lyric lyric) - => lyric.RomajiTagsBindable.GetBoundCopy(); - - protected override SelectionHandler CreateSelectionHandler() - => new RomajiTagSelectionHandler(); - - protected override SelectionBlueprint CreateBlueprintFor(RomajiTag item) - => new RomajiTagSelectionBlueprint(item); - - protected partial class RomajiTagSelectionHandler : TextTagSelectionHandler - { - [Resolved] - private ILyricRomajiTagsChangeHandler romajiTagsChangeHandler { get; set; } = null!; - - protected override void DeleteItems(IEnumerable items) - => romajiTagsChangeHandler.RemoveRange(items); - - protected override void SetTextTagShifting(IEnumerable textTags, int offset) - => romajiTagsChangeHandler.ShiftingIndex(textTags, offset); - - protected override void SetTextTagIndex(RomajiTag textTag, int? startPosition, int? endPosition) - => romajiTagsChangeHandler.SetIndex(textTag, startPosition, endPosition); - } -} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RomajiTagSelectionBlueprint.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RomajiTagSelectionBlueprint.cs deleted file mode 100644 index 3230c3130..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RomajiTagSelectionBlueprint.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using JetBrains.Annotations; -using osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Blueprints; - -public partial class RomajiTagSelectionBlueprint : TextTagSelectionBlueprint -{ - [UsedImplicitly] - private readonly Bindable text; - - [UsedImplicitly] - private readonly BindableNumber startIndex; - - [UsedImplicitly] - private readonly BindableNumber endIndex; - - public RomajiTagSelectionBlueprint(RomajiTag item) - : base(item) - { - text = item.TextBindable.GetBoundCopy(); - startIndex = item.StartIndexBindable.GetBoundCopy(); - endIndex = item.EndIndexBindable.GetBoundCopy(); - } - - [BackgroundDependencyLoader] - private void load() - { - UpdatePositionAndSize(); - text.BindValueChanged(_ => UpdatePositionAndSize()); - startIndex.BindValueChanged(_ => UpdatePositionAndSize()); - endIndex.BindValueChanged(_ => UpdatePositionAndSize()); - } -} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs index a71f24cda..f2a7e569f 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs @@ -1,18 +1,24 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Logging; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Objects.Utils; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; using osu.Game.Screens.Edit.Compose.Components; +using osuTK; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Blueprints; -public partial class RubyBlueprintContainer : TextTagBlueprintContainer +public partial class RubyBlueprintContainer : LyricPropertyBlueprintContainer { public RubyBlueprintContainer(Lyric lyric) : base(lyric) @@ -28,18 +34,127 @@ protected override SelectionHandler CreateSelectionHandler() protected override SelectionBlueprint CreateBlueprintFor(RubyTag item) => new RubyTagSelectionBlueprint(item); - protected partial class RubyTagSelectionHandler : TextTagSelectionHandler + protected partial class RubyTagSelectionHandler : LyricPropertySelectionHandler { [Resolved] private ILyricRubyTagsChangeHandler rubyTagsChangeHandler { get; set; } = null!; - protected override void DeleteItems(IEnumerable items) - => rubyTagsChangeHandler.RemoveRange(items); + [Resolved] + private IPreviewLyricPositionProvider previewLyricPositionProvider { get; set; } = null!; + + private float deltaScaleSize; + + protected override void OnSelectionChanged() + { + base.OnSelectionChanged(); + + // only select one ruby / romaji tag can let user drag to change start and end index. + SelectionBox.CanScaleX = SelectedItems.Count == 1; + + // should clear delta size before change start/end index. + deltaScaleSize = 0; + } + + #region User Input Handling + + // for now we always allow movement. snapping is provided by the Timeline's "distance" snap implementation + public override bool HandleMovement(MoveSelectionEvent moveEvent) + { + if (!SelectedItems.Any()) + throw new InvalidOperationException("Should have at least one selected item."); + + float deltaXPosition = moveEvent.ScreenSpaceDelta.X; + Logger.LogPrint($"position: {deltaXPosition}", LoggingTarget.Information); + + if (deltaXPosition < 0) + { + var firstTimeTag = SelectedItems.MinBy(x => x.StartIndex) ?? throw new InvalidOperationException(); + int? newStartIndex = calculateNewIndex(firstTimeTag, deltaXPosition, Anchor.CentreLeft); + int? offset = newStartIndex - firstTimeTag.StartIndex; + if (offset is null or 0) + return false; + + setRubyTagShifting(SelectedItems, -1); + } + else + { + var lastTimeTag = SelectedItems.MaxBy(x => x.EndIndex) ?? throw new InvalidOperationException(); + int? newEndIndex = calculateNewIndex(lastTimeTag, deltaXPosition, Anchor.CentreRight); + int? offset = newEndIndex - lastTimeTag.EndIndex; + if (offset is null or 0) + return false; + + setRubyTagShifting(SelectedItems, 1); + } + + return true; + + void setRubyTagShifting(IEnumerable rubyTags, int offset) + => rubyTagsChangeHandler.ShiftingIndex(rubyTags, offset); + } - protected override void SetTextTagShifting(IEnumerable textTags, int offset) - => rubyTagsChangeHandler.ShiftingIndex(textTags, offset); + public override bool HandleScale(Vector2 scale, Anchor anchor) + { + deltaScaleSize += scale.X; - protected override void SetTextTagIndex(RubyTag textTag, int? startPosition, int? endPosition) - => rubyTagsChangeHandler.SetIndex(textTag, startPosition, endPosition); + // this feature only works if only select one ruby / romaji tag. + var selectedRubyTag = SelectedItems.FirstOrDefault(); + if (selectedRubyTag == null) + return false; + + switch (anchor) + { + case Anchor.CentreLeft: + int? newStartIndex = calculateNewIndex(selectedRubyTag, deltaScaleSize, anchor); + if (newStartIndex == null || !TextTagUtils.ValidNewStartIndex(selectedRubyTag, newStartIndex.Value)) + return false; + + setRubyTagIndex(selectedRubyTag, newStartIndex, null); + return true; + + case Anchor.CentreRight: + int? newEndIndex = calculateNewIndex(selectedRubyTag, deltaScaleSize, anchor); + if (newEndIndex == null || !TextTagUtils.ValidNewEndIndex(selectedRubyTag, newEndIndex.Value)) + return false; + + setRubyTagIndex(selectedRubyTag, null, newEndIndex); + return true; + + default: + return false; + } + + void setRubyTagIndex(RubyTag rubyTag, int? startPosition, int? endPosition) + => rubyTagsChangeHandler.SetIndex(rubyTag, startPosition, endPosition); + } + + private int? calculateNewIndex(RubyTag rubyTag, float offset, Anchor anchor) + { + // get real left-side and right-side position + var rect = previewLyricPositionProvider.GetTextTagByPosition(rubyTag); + + // todo: need to think about how to handle the case if the text-tag already out of the range of the text. + if (rect == null) + throw new InvalidOperationException($"{nameof(rubyTag)} not in the range of the text."); + + switch (anchor) + { + case Anchor.CentreLeft: + float leftPosition = rect.Value.Left + offset; + return previewLyricPositionProvider.GetCharIndexByPosition(leftPosition); + + case Anchor.CentreRight: + float rightPosition = rect.Value.Right + offset; + return previewLyricPositionProvider.GetCharIndexByPosition(rightPosition); + + default: + throw new ArgumentOutOfRangeException(nameof(anchor)); + } + } + + #endregion + + protected override void DeleteItems(IEnumerable items) + => rubyTagsChangeHandler.RemoveRange(items); } } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs index 6074c5a0e..ff8311693 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs @@ -8,22 +8,29 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; using osuTK; +using osuTK.Graphics; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Blueprints; -public partial class RubyTagSelectionBlueprint : TextTagSelectionBlueprint, IHasPopover +public partial class RubyTagSelectionBlueprint : SelectionBlueprint, IHasPopover { [Resolved] private IEditRubyModeState editRubyModeState { get; set; } = null!; + [Resolved] + private IPreviewLyricPositionProvider previewLyricPositionProvider { get; set; } = null!; + [UsedImplicitly] private readonly Bindable text; @@ -33,6 +40,9 @@ public partial class RubyTagSelectionBlueprint : TextTagSelectionBlueprint endIndex; + private readonly Container previewTextArea; + private readonly Container indexRangeBackground; + public RubyTagSelectionBlueprint(RubyTag item) : base(item) { @@ -43,17 +53,93 @@ public RubyTagSelectionBlueprint(RubyTag item) text = item.TextBindable.GetBoundCopy(); startIndex = item.StartIndexBindable.GetBoundCopy(); endIndex = item.EndIndexBindable.GetBoundCopy(); + + InternalChildren = new[] + { + previewTextArea = new Container + { + Alpha = 0, + }, + indexRangeBackground = new Container + { + Masking = true, + BorderThickness = 3, + Alpha = 0, + BorderColour = Color4.White, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0f, + AlwaysPresent = true, + }, + }, + }, + }; } [BackgroundDependencyLoader] - private void load() + private void load(OsuColour colours) { + indexRangeBackground.Colour = colours.Pink; + UpdatePositionAndSize(); text.BindValueChanged(_ => UpdatePositionAndSize()); startIndex.BindValueChanged(_ => UpdatePositionAndSize()); endIndex.BindValueChanged(_ => UpdatePositionAndSize()); } + protected void UpdatePositionAndSize() + { + // wait until lyric update ruby position. + ScheduleAfterChildren(() => + { + var rubyTagRect = previewLyricPositionProvider.GetTextTagByPosition(Item); + + if (rubyTagRect == null) + { + return; + } + + var startRect = previewLyricPositionProvider.GetRectByCharIndex(Item.StartIndex); + var endRect = previewLyricPositionProvider.GetRectByCharIndex(Item.EndIndex); + + // update select position + updateDrawableRect(previewTextArea, rubyTagRect.Value); + + // update index range position. + var indexRangePosition = new Vector2(startRect.Left, rubyTagRect.Value.Y); + var indexRangeSize = new Vector2(endRect.Right - startRect.Left, rubyTagRect.Value.Height); + updateDrawableRect(indexRangeBackground, new RectangleF(indexRangePosition, indexRangeSize)); + }); + + static void updateDrawableRect(Drawable target, RectangleF rect) + { + target.X = rect.X; + target.Y = rect.Y; + target.Width = rect.Width; + target.Height = rect.Height; + } + } + + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) + => previewTextArea.ReceivePositionalInputAt(screenSpacePos); + + public override Vector2 ScreenSpaceSelectionPoint => ScreenSpaceDrawQuad.TopLeft; + + public override Quad SelectionQuad => previewTextArea.ScreenSpaceDrawQuad; + + protected override void OnSelected() + { + indexRangeBackground.FadeIn(500); + } + + protected override void OnDeselected() + { + indexRangeBackground.FadeOut(500); + } + public Popover GetPopover() => new RubyEditPopover(Item); protected override bool OnClick(ClickEvent e) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/TextTagBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/TextTagBlueprintContainer.cs deleted file mode 100644 index fb0d0c059..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/TextTagBlueprintContainer.cs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Logging; -using osu.Game.Rulesets.Edit; -using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Objects.Types; -using osu.Game.Rulesets.Karaoke.Objects.Utils; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -using osu.Game.Screens.Edit.Compose.Components; -using osuTK; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Blueprints; - -public abstract partial class TextTagBlueprintContainer : LyricPropertyBlueprintContainer where T : class, ITextTag -{ - protected TextTagBlueprintContainer(Lyric lyric) - : base(lyric) - { - } - - protected override IEnumerable> SortForMovement(IReadOnlyList> blueprints) - => blueprints.OrderBy(b => b.Item.StartIndex); - - protected abstract partial class TextTagSelectionHandler : LyricPropertySelectionHandler - where TModeState : IHasBlueprintSelection - { - [Resolved] - private IPreviewLyricPositionProvider previewLyricPositionProvider { get; set; } = null!; - - private float deltaScaleSize; - - protected override void OnSelectionChanged() - { - base.OnSelectionChanged(); - - // only select one ruby / romaji tag can let user drag to change start and end index. - SelectionBox.CanScaleX = SelectedItems.Count == 1; - - // should clear delta size before change start/end index. - deltaScaleSize = 0; - } - - #region User Input Handling - - // for now we always allow movement. snapping is provided by the Timeline's "distance" snap implementation - public override bool HandleMovement(MoveSelectionEvent moveEvent) - { - if (!SelectedItems.Any()) - throw new InvalidOperationException("Should have at least one selected item."); - - float deltaXPosition = moveEvent.ScreenSpaceDelta.X; - Logger.LogPrint($"position: {deltaXPosition}", LoggingTarget.Information); - - if (deltaXPosition < 0) - { - var firstTimeTag = SelectedItems.MinBy(x => x.StartIndex) ?? throw new InvalidOperationException(); - int? newStartIndex = calculateNewIndex(firstTimeTag, deltaXPosition, Anchor.CentreLeft); - int? offset = newStartIndex - firstTimeTag.StartIndex; - if (offset is null or 0) - return false; - - SetTextTagShifting(SelectedItems, -1); - } - else - { - var lastTimeTag = SelectedItems.MaxBy(x => x.EndIndex) ?? throw new InvalidOperationException(); - int? newEndIndex = calculateNewIndex(lastTimeTag, deltaXPosition, Anchor.CentreRight); - int? offset = newEndIndex - lastTimeTag.EndIndex; - if (offset is null or 0) - return false; - - SetTextTagShifting(SelectedItems, 1); - } - - return true; - } - - public override bool HandleScale(Vector2 scale, Anchor anchor) - { - deltaScaleSize += scale.X; - - // this feature only works if only select one ruby / romaji tag. - var selectedTextTag = SelectedItems.FirstOrDefault(); - if (selectedTextTag == null) - return false; - - switch (anchor) - { - case Anchor.CentreLeft: - int? newStartIndex = calculateNewIndex(selectedTextTag, deltaScaleSize, anchor); - if (newStartIndex == null || !TextTagUtils.ValidNewStartIndex(selectedTextTag, newStartIndex.Value)) - return false; - - SetTextTagIndex(selectedTextTag, newStartIndex, null); - return true; - - case Anchor.CentreRight: - int? newEndIndex = calculateNewIndex(selectedTextTag, deltaScaleSize, anchor); - if (newEndIndex == null || !TextTagUtils.ValidNewEndIndex(selectedTextTag, newEndIndex.Value)) - return false; - - SetTextTagIndex(selectedTextTag, null, newEndIndex); - return true; - - default: - return false; - } - } - - private int? calculateNewIndex(T textTag, float offset, Anchor anchor) - { - // get real left-side and right-side position - var rect = previewLyricPositionProvider.GetTextTagByPosition(textTag); - - // todo: need to think about how to handle the case if the text-tag already out of the range of the text. - if (rect == null) - throw new InvalidOperationException($"{nameof(textTag)} not in the range of the text."); - - switch (anchor) - { - case Anchor.CentreLeft: - float leftPosition = rect.Value.Left + offset; - return previewLyricPositionProvider.GetCharIndexByPosition(leftPosition); - - case Anchor.CentreRight: - float rightPosition = rect.Value.Right + offset; - return previewLyricPositionProvider.GetCharIndexByPosition(rightPosition); - - default: - throw new ArgumentOutOfRangeException(nameof(anchor)); - } - } - - #endregion - - protected abstract void SetTextTagShifting(IEnumerable textTags, int offset); - - protected abstract void SetTextTagIndex(T textTag, int? startPosition, int? endPosition); - } -} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/TextTagSelectionBlueprint.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/TextTagSelectionBlueprint.cs deleted file mode 100644 index 22339696c..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/TextTagSelectionBlueprint.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; -using osu.Game.Rulesets.Edit; -using osu.Game.Rulesets.Karaoke.Objects.Types; -using osuTK; -using osuTK.Graphics; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Blueprints; - -public abstract partial class TextTagSelectionBlueprint : SelectionBlueprint where T : ITextTag -{ - private readonly Container previewTextArea; - private readonly Container indexRangeBackground; - - [Resolved] - private IPreviewLyricPositionProvider previewLyricPositionProvider { get; set; } = null!; - - protected TextTagSelectionBlueprint(T item) - : base(item) - { - InternalChildren = new[] - { - previewTextArea = new Container - { - Alpha = 0, - }, - indexRangeBackground = new Container - { - Masking = true, - BorderThickness = 3, - Alpha = 0, - BorderColour = Color4.White, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0f, - AlwaysPresent = true, - }, - }, - }, - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - indexRangeBackground.Colour = colours.Pink; - } - - protected override void OnSelected() - { - indexRangeBackground.FadeIn(500); - } - - protected override void OnDeselected() - { - indexRangeBackground.FadeOut(500); - } - - protected void UpdatePositionAndSize() - { - // wait until lyric update ruby position. - ScheduleAfterChildren(() => - { - var textTagRect = previewLyricPositionProvider.GetTextTagByPosition(Item); - - if (textTagRect == null) - { - return; - } - - var startRect = previewLyricPositionProvider.GetRectByCharIndex(Item.StartIndex); - var endRect = previewLyricPositionProvider.GetRectByCharIndex(Item.EndIndex); - - // update select position - updateDrawableRect(previewTextArea, textTagRect.Value); - - // update index range position. - var indexRangePosition = new Vector2(startRect.Left, textTagRect.Value.Y); - var indexRangeSize = new Vector2(endRect.Right - startRect.Left, textTagRect.Value.Height); - updateDrawableRect(indexRangeBackground, new RectangleF(indexRangePosition, indexRangeSize)); - }); - - static void updateDrawableRect(Drawable target, RectangleF rect) - { - target.X = rect.X; - target.Y = rect.Y; - target.Width = rect.Width; - target.Height = rect.Height; - } - } - - public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) - => previewTextArea.ReceivePositionalInputAt(screenSpacePos); - - public override Vector2 ScreenSpaceSelectionPoint => previewTextArea.ScreenSpaceDrawQuad.Centre; - - public override Quad SelectionQuad => previewTextArea.ScreenSpaceDrawQuad; -} From 5d08bb9dd01d15cb05a32cf25b3e243c6813b583 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 27 Sep 2023 22:55:56 +0800 Subject: [PATCH 03/13] Move the romaji tag section into new namespace. --- .../RomajiAutoGenerateSection.cs} | 5 +++-- .../RomajiEditSection.cs} | 5 +++-- .../RomajiEditStepSection.cs} | 5 +++-- .../RomajiIssueSection.cs} | 5 +++-- .../Beatmaps/Lyrics/Settings/RomajiTagSettings.cs | 14 +++++++------- 5 files changed, 19 insertions(+), 15 deletions(-) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji/RomajiTagAutoGenerateSection.cs => Romaji/RomajiAutoGenerateSection.cs} (89%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji/RomajiTagEditSection.cs => Romaji/RomajiEditSection.cs} (95%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji/RomajiTagEditStepSection.cs => Romaji/RomajiEditStepSection.cs} (95%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji/RomajiTagIssueSection.cs => Romaji/RomajiIssueSection.cs} (85%) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagAutoGenerateSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiAutoGenerateSection.cs similarity index 89% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagAutoGenerateSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiAutoGenerateSection.cs index dd2c9ce68..89605e1ea 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagAutoGenerateSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiAutoGenerateSection.cs @@ -5,10 +5,11 @@ using System.Collections.Generic; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; -public partial class RomajiTagAutoGenerateSection : TextTagAutoGenerateSection +public partial class RomajiAutoGenerateSection : TextTagAutoGenerateSection { protected override AutoGenerateSubsection CreateAutoGenerateSubsection() => new RomajiTagAutoGenerateSubsection(); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagEditSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs similarity index 95% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagEditSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs index a8cdf0b31..5dc54895a 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs @@ -9,12 +9,13 @@ using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; -public partial class RomajiTagEditSection : TextTagEditSection +public partial class RomajiEditSection : TextTagEditSection { protected override LocalisableString Title => "Romaji"; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagEditStepSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs similarity index 95% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagEditStepSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs index 324683a1e..9608ed8c1 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagEditStepSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs @@ -5,13 +5,14 @@ using System.Collections.Generic; using osu.Framework.Localisation; using osu.Game.Graphics; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; using osuTK.Graphics; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; -public partial class RomajiTagEditStepSection : TextTagEditStepSection +public partial class RomajiEditStepSection : TextTagEditStepSection { protected override Selection CreateSelection(RomajiTagEditStep step) => step switch diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagIssueSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiIssueSection.cs similarity index 85% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagIssueSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiIssueSection.cs index bbe21e6c9..5a98e9760 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RomajiTagIssueSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiIssueSection.cs @@ -5,10 +5,11 @@ using osu.Game.Rulesets.Edit.Checks.Components; using osu.Game.Rulesets.Karaoke.Edit.Checks.Issues; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; -public partial class RomajiTagIssueSection : TextTagIssueSection +public partial class RomajiIssueSection : TextTagIssueSection { protected override LyricEditorMode EditMode => LyricEditorMode.EditRomaji; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RomajiTagSettings.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RomajiTagSettings.cs index 5e9244f92..2961bfbdc 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RomajiTagSettings.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RomajiTagSettings.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings; @@ -26,18 +26,18 @@ private void load(IEditRomajiModeState romajiModeState) { RomajiTagEditStep.Generate => new Drawable[] { - new RomajiTagEditStepSection(), - new RomajiTagAutoGenerateSection(), + new RomajiEditStepSection(), + new RomajiAutoGenerateSection(), }, RomajiTagEditStep.Edit => new Drawable[] { - new RomajiTagEditStepSection(), - new RomajiTagEditSection(), + new RomajiEditStepSection(), + new RomajiEditSection(), }, RomajiTagEditStep.Verify => new Drawable[] { - new RomajiTagEditStepSection(), - new RomajiTagIssueSection(), + new RomajiEditStepSection(), + new RomajiIssueSection(), }, _ => throw new ArgumentOutOfRangeException(), }; From b0ebdb102d295947f93616601ce18a28f480bbf1 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 27 Sep 2023 23:08:33 +0800 Subject: [PATCH 04/13] Remove the TextTagAutoGenerateSection. --- .../Romaji/RomajiAutoGenerateSection.cs | 35 +++++++++++++++-- .../RubyRomaji/RubyTagAutoGenerateSection.cs | 24 +++++++++++- .../RubyRomaji/TextTagAutoGenerateSection.cs | 38 ------------------- 3 files changed, 54 insertions(+), 43 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagAutoGenerateSection.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiAutoGenerateSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiAutoGenerateSection.cs index 89605e1ea..325b3229e 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiAutoGenerateSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiAutoGenerateSection.cs @@ -5,22 +5,51 @@ using System.Collections.Generic; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Components.Markdown; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; -public partial class RomajiAutoGenerateSection : TextTagAutoGenerateSection +public partial class RomajiAutoGenerateSection : AutoGenerateSection { protected override AutoGenerateSubsection CreateAutoGenerateSubsection() => new RomajiTagAutoGenerateSubsection(); - private partial class RomajiTagAutoGenerateSubsection : TextTagAutoGenerateSubsection + private partial class RomajiTagAutoGenerateSubsection : LyricEditorAutoGenerateSubsection { + private const string language_mode = "LANGUAGE_MODE"; + private const string time_tag_mode = "TIME_TAG_MODE"; + public RomajiTagAutoGenerateSubsection() : base(AutoGenerateType.AutoGenerateRomajiTags) { } + protected override DescriptionFormat CreateInvalidDescriptionFormat() + => new() + { + Text = $"Seems some lyric missing language or time-tag, go to [{DescriptionFormat.LINK_KEY_ACTION}]({language_mode}) to fill the language, or [{DescriptionFormat.LINK_KEY_ACTION}]({time_tag_mode}) to fill the time-tag.", + Actions = new Dictionary + { + { + language_mode, + new SwitchModeDescriptionAction + { + Text = "edit language mode", + Mode = LyricEditorMode.Language, + } + }, + { + time_tag_mode, + new SwitchModeDescriptionAction + { + Text = "edit time-tag mode", + Mode = LyricEditorMode.EditTimeTag, + } + }, + }, + }; + protected override ConfigButton CreateConfigButton() => new RomajiTagAutoGenerateConfigButton(); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagAutoGenerateSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagAutoGenerateSection.cs index 3b73c7ebd..4049e6224 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagAutoGenerateSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagAutoGenerateSection.cs @@ -5,21 +5,41 @@ using System.Collections.Generic; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Components.Markdown; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; -public partial class RubyTagAutoGenerateSection : TextTagAutoGenerateSection +public partial class RubyTagAutoGenerateSection : AutoGenerateSection { protected override AutoGenerateSubsection CreateAutoGenerateSubsection() => new RubyTagAutoGenerateSubsection(); - private partial class RubyTagAutoGenerateSubsection : TextTagAutoGenerateSubsection + private partial class RubyTagAutoGenerateSubsection : LyricEditorAutoGenerateSubsection { + private const string language_mode = "LANGUAGE_MODE"; + public RubyTagAutoGenerateSubsection() : base(AutoGenerateType.AutoGenerateRubyTags) { } + protected override DescriptionFormat CreateInvalidDescriptionFormat() + => new() + { + Text = $"Seems some lyric missing language, go to [{DescriptionFormat.LINK_KEY_ACTION}]({language_mode}) to fill the language.", + Actions = new Dictionary + { + { + language_mode, new SwitchModeDescriptionAction + { + Text = "edit language mode", + Mode = LyricEditorMode.Language, + } + }, + }, + }; + protected override ConfigButton CreateConfigButton() => new RubyTagAutoGenerateConfigButton(); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagAutoGenerateSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagAutoGenerateSection.cs deleted file mode 100644 index 976c7a4d7..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagAutoGenerateSection.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Components.Markdown; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; - -public abstract partial class TextTagAutoGenerateSection : AutoGenerateSection -{ - protected abstract partial class TextTagAutoGenerateSubsection : LyricEditorAutoGenerateSubsection - { - private const string language_mode = "LANGUAGE_MODE"; - - protected TextTagAutoGenerateSubsection(AutoGenerateType generateType) - : base(generateType) - { - } - - protected override DescriptionFormat CreateInvalidDescriptionFormat() - => new() - { - Text = $"Seems some lyric missing language, go to [{DescriptionFormat.LINK_KEY_ACTION}]({language_mode}) to fill the language.", - Actions = new Dictionary - { - { - language_mode, new SwitchModeDescriptionAction - { - Text = "edit language mode", - Mode = LyricEditorMode.Language, - } - }, - }, - }; - } -} From b4018e4e2e2afec3ed3fa0313126b39dcfcf45f4 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Thu, 28 Sep 2023 00:06:25 +0800 Subject: [PATCH 05/13] Remove TextTagEditStepSection. --- .../Settings/Romaji/RomajiEditStepSection.cs | 7 +++++-- .../RubyRomaji/RubyTagEditStepSection.cs | 6 +++++- .../RubyRomaji/TextTagEditStepSection.cs | 16 ---------------- 3 files changed, 10 insertions(+), 19 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagEditStepSection.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs index 9608ed8c1..ce21da08d 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs @@ -5,15 +5,18 @@ using System.Collections.Generic; using osu.Framework.Localisation; using osu.Game.Graphics; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +using osu.Game.Overlays; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; using osuTK.Graphics; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; -public partial class RomajiEditStepSection : TextTagEditStepSection +public partial class RomajiEditStepSection : LyricEditorEditStepSection { + protected override OverlayColourScheme CreateColourScheme() + => OverlayColourScheme.Orange; + protected override Selection CreateSelection(RomajiTagEditStep step) => step switch { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditStepSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditStepSection.cs index b57499b7c..9380fe849 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditStepSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditStepSection.cs @@ -5,14 +5,18 @@ using System.Collections.Generic; using osu.Framework.Localisation; using osu.Game.Graphics; +using osu.Game.Overlays; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; using osuTK.Graphics; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; -public partial class RubyTagEditStepSection : TextTagEditStepSection +public partial class RubyTagEditStepSection : LyricEditorEditStepSection { + protected override OverlayColourScheme CreateColourScheme() + => OverlayColourScheme.Pink; + protected override Selection CreateSelection(RubyTagEditStep step) => step switch { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagEditStepSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagEditStepSection.cs deleted file mode 100644 index 01aa0e2cc..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagEditStepSection.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Game.Overlays; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; - -public abstract partial class TextTagEditStepSection : LyricEditorEditStepSection - where TEditModeState : class, IHasEditStep - where TEditMode : struct, Enum -{ - protected override OverlayColourScheme CreateColourScheme() - => OverlayColourScheme.Pink; -} From 01b21b299018d53caf70f1ce836a9f242ef0899b Mon Sep 17 00:00:00 2001 From: andy840119 Date: Thu, 28 Sep 2023 00:13:28 +0800 Subject: [PATCH 06/13] Remove TextTagIssueSection. --- .../Settings/Romaji/RomajiIssueSection.cs | 56 ++++++++++++++-- .../RubyRomaji/RubyTagIssueSection.cs | 55 +++++++++++++++- .../RubyRomaji/TextTagIssueSection.cs | 66 ------------------- 3 files changed, 104 insertions(+), 73 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagIssueSection.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiIssueSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiIssueSection.cs index 5a98e9760..1491635c9 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiIssueSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiIssueSection.cs @@ -2,22 +2,70 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Edit.Checks.Components; using osu.Game.Rulesets.Karaoke.Edit.Checks.Issues; using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +using osu.Game.Rulesets.Karaoke.Objects.Utils; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Issues; +using osuTK; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; -public partial class RomajiIssueSection : TextTagIssueSection +public partial class RomajiIssueSection : LyricEditorIssueSection { protected override LyricEditorMode EditMode => LyricEditorMode.EditRomaji; protected override LyricsIssueTable CreateLyricsIssueTable() => new RomajiTagIssueTable(); - private partial class RomajiTagIssueTable : TextTagIssueTable + private partial class RomajiTagIssueTable : LyricsIssueTable { - protected override Tuple GetInvalidByIssue(Issue issue) + protected override TableColumn[] CreateHeaders() => new[] + { + new TableColumn(string.Empty, Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 30)), + new TableColumn("Lyric", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 40)), + new TableColumn("Position", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 60)), + new TableColumn("Message", Anchor.CentreLeft), + }; + + protected override Drawable[] CreateContent(Issue issue) + { + (var lyric, RomajiTag romajiTag) = getInvalidByIssue(issue); + + return new Drawable[] + { + new IssueIcon + { + Origin = Anchor.Centre, + Size = new Vector2(10), + Margin = new MarginPadding { Left = 10 }, + Issue = issue, + }, + new OsuSpriteText + { + Text = $"#{lyric.Order}", + Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold), + Margin = new MarginPadding { Right = 10 }, + }, + new OsuSpriteText + { + Text = TextTagUtils.PositionFormattedString(romajiTag), + Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold), + Margin = new MarginPadding { Right = 10 }, + }, + new TruncatingSpriteText + { + Text = issue.ToString(), + RelativeSizeAxes = Axes.X, + Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Medium), + }, + }; + } + + private Tuple getInvalidByIssue(Issue issue) { if (issue is not LyricRomajiTagIssue romajiTagIssue) throw new InvalidCastException(); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagIssueSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagIssueSection.cs index 5be0b220b..0ab03e300 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagIssueSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagIssueSection.cs @@ -2,21 +2,70 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Edit.Checks.Components; using osu.Game.Rulesets.Karaoke.Edit.Checks.Issues; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Objects.Utils; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Issues; +using osuTK; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; -public partial class RubyTagIssueSection : TextTagIssueSection +public partial class RubyTagIssueSection : LyricEditorIssueSection { protected override LyricEditorMode EditMode => LyricEditorMode.EditRuby; protected override LyricsIssueTable CreateLyricsIssueTable() => new RubyTagIssueTable(); - private partial class RubyTagIssueTable : TextTagIssueTable + private partial class RubyTagIssueTable : LyricsIssueTable { - protected override Tuple GetInvalidByIssue(Issue issue) + protected override TableColumn[] CreateHeaders() => new[] + { + new TableColumn(string.Empty, Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 30)), + new TableColumn("Lyric", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 40)), + new TableColumn("Position", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 60)), + new TableColumn("Message", Anchor.CentreLeft), + }; + + protected override Drawable[] CreateContent(Issue issue) + { + (var lyric, RubyTag rubyTag) = getInvalidByIssue(issue); + + return new Drawable[] + { + new IssueIcon + { + Origin = Anchor.Centre, + Size = new Vector2(10), + Margin = new MarginPadding { Left = 10 }, + Issue = issue, + }, + new OsuSpriteText + { + Text = $"#{lyric.Order}", + Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold), + Margin = new MarginPadding { Right = 10 }, + }, + new OsuSpriteText + { + Text = TextTagUtils.PositionFormattedString(rubyTag), + Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold), + Margin = new MarginPadding { Right = 10 }, + }, + new TruncatingSpriteText + { + Text = issue.ToString(), + RelativeSizeAxes = Axes.X, + Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Medium), + }, + }; + } + + private Tuple getInvalidByIssue(Issue issue) { if (issue is not LyricRubyTagIssue rubyTagIssue) throw new InvalidCastException(); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagIssueSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagIssueSection.cs deleted file mode 100644 index 1762a09e3..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagIssueSection.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Rulesets.Edit.Checks.Components; -using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Objects.Types; -using osu.Game.Rulesets.Karaoke.Objects.Utils; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Issues; -using osuTK; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; - -public abstract partial class TextTagIssueSection : LyricEditorIssueSection -{ - protected abstract partial class TextTagIssueTable : LyricsIssueTable where TTextTag : ITextTag - { - protected override TableColumn[] CreateHeaders() => new[] - { - new TableColumn(string.Empty, Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 30)), - new TableColumn("Lyric", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 40)), - new TableColumn("Position", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 60)), - new TableColumn("Message", Anchor.CentreLeft), - }; - - protected override Drawable[] CreateContent(Issue issue) - { - (var lyric, TTextTag textTag) = GetInvalidByIssue(issue); - - return new Drawable[] - { - new IssueIcon - { - Origin = Anchor.Centre, - Size = new Vector2(10), - Margin = new MarginPadding { Left = 10 }, - Issue = issue, - }, - new OsuSpriteText - { - Text = $"#{lyric.Order}", - Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold), - Margin = new MarginPadding { Right = 10 }, - }, - new OsuSpriteText - { - Text = TextTagUtils.PositionFormattedString(textTag), - Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold), - Margin = new MarginPadding { Right = 10 }, - }, - new TruncatingSpriteText - { - Text = issue.ToString(), - RelativeSizeAxes = Axes.X, - Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Medium), - }, - }; - } - - protected abstract Tuple GetInvalidByIssue(Issue issue); - } -} From d9b2bd3bf893543b64387eb981369feecf73903f Mon Sep 17 00:00:00 2001 From: andy840119 Date: Thu, 28 Sep 2023 22:49:45 +0800 Subject: [PATCH 07/13] Romaji mode state should support the edit property switch. --- .../Lyrics/Settings/Romaji/RomajiEditPropertyMode.cs | 11 +++++++++++ .../Lyrics/States/Modes/EditRomajiModeState.cs | 3 +++ .../Lyrics/States/Modes/IEditRomajiModeState.cs | 3 +++ 3 files changed, 17 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditPropertyMode.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditPropertyMode.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditPropertyMode.cs new file mode 100644 index 000000000..4a3147823 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditPropertyMode.cs @@ -0,0 +1,11 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; + +public enum RomajiEditPropertyMode +{ + Text, + + Initial, +} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRomajiModeState.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRomajiModeState.cs index b5ee8a371..d554048c7 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRomajiModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRomajiModeState.cs @@ -5,6 +5,7 @@ using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; @@ -17,6 +18,8 @@ public partial class EditRomajiModeState : ModeStateWithBlueprintContainer bindableEditMode.Value = step; + public Bindable BindableRomajiEditPropertyMode { get; } = new(); + protected override bool IsWriteLyricPropertyLocked(Lyric lyric) => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.RomajiTags)); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRomajiModeState.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRomajiModeState.cs index bbd8cef84..d891fed60 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRomajiModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRomajiModeState.cs @@ -1,10 +1,13 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; public interface IEditRomajiModeState : IHasEditStep, IHasBlueprintSelection { + Bindable BindableRomajiEditPropertyMode { get; } } From 0eb6f6d2d9b1faa20fdb09fb5ce9c8772a34feec Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 29 Sep 2023 00:16:45 +0800 Subject: [PATCH 08/13] Adjust the select blueprint type and romaji edit section should edit the romaji property from the time-tag. --- .../Settings/Romaji/RomajiEditSection.cs | 99 ++++++++++++++----- .../Settings/RubyRomaji/RubyTagEditSection.cs | 34 +++++-- .../Settings/RubyRomaji/TextTagEditSection.cs | 39 -------- .../States/Modes/EditRomajiModeState.cs | 8 +- .../States/Modes/IEditRomajiModeState.cs | 2 +- 5 files changed, 106 insertions(+), 76 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagEditSection.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs index 5dc54895a..e70646019 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs @@ -2,20 +2,20 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Edit.Utils; +using osu.Game.Rulesets.Karaoke.Extensions; using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; +using osu.Game.Screens.Edit; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; -public partial class RomajiEditSection : TextTagEditSection +public partial class RomajiEditSection : LyricPropertiesSection { protected override LocalisableString Title => "Romaji"; @@ -40,40 +40,72 @@ protected override LocalisableString GetWriteLyricPropertyLockedTooltip(LockLyri _ => throw new ArgumentOutOfRangeException(nameof(lockLyricPropertyBy), lockLyricPropertyBy, null), }; - private partial class RomajiTagsEditor : TextTagsEditor + private partial class RomajiTagsEditor : LyricPropertiesEditor { - protected override IBindableList GetItems(Lyric lyric) - => lyric.RomajiTagsBindable; + private readonly Bindable bindableRomajiEditPropertyMode = new(); - protected override LabelledTextTagTextBox CreateLabelledTextTagTextBox(Lyric lyric, RomajiTag textTag) - => new LabelledRomajiTagTextBox(lyric, textTag); + [Resolved] + private EditorBeatmap beatmap { get; set; } = null!; + + public RomajiTagsEditor() + { + bindableRomajiEditPropertyMode.BindValueChanged(e => + { + RedrewContent(); + }); + } + + [BackgroundDependencyLoader] + private void load(IEditRomajiModeState editRomajiModeState) + { + bindableRomajiEditPropertyMode.BindTo(editRomajiModeState.BindableRomajiEditPropertyMode); + } + + protected override Drawable CreateDrawable(TimeTag item) + { + int index = Items.IndexOf(item); + return bindableRomajiEditPropertyMode.Value switch + { + RomajiEditPropertyMode.Text => new LabelledRomajiTextTextBox(item) + { + Label = $"#{index + 1}", + TabbableContentContainer = this, + }, + RomajiEditPropertyMode.Initial => new LabelledInitialSwitchButton(item) + { + Label = item.RomajiText ?? string.Empty, + }, + _ => throw new ArgumentOutOfRangeException(nameof(bindableRomajiEditPropertyMode.Value)), + }; + } + + protected override EditorSectionButton? CreateCreateNewItemButton() => null; + + protected override IBindableList GetItems(Lyric lyric) + => lyric.TimeTagsBindable; } - protected partial class LabelledRomajiTagTextBox : LabelledTextTagTextBox + private partial class LabelledRomajiTextTextBox : LabelledObjectFieldTextBox { [Resolved] - private ILyricRomajiTagsChangeHandler romajiTagsChangeHandler { get; set; } = null!; + private ILyricTimeTagsChangeHandler lyricTimeTagsChangeHandler { get; set; } = null!; [Resolved] private IEditRomajiModeState editRomajiModeState { get; set; } = null!; - public LabelledRomajiTagTextBox(Lyric lyric, RomajiTag textTag) - : base(lyric, textTag) + public LabelledRomajiTextTextBox(TimeTag item) + : base(item) { - Debug.Assert(lyric.RomajiTags.Contains(textTag)); } - protected override void TriggerSelect(RomajiTag item) + protected override void TriggerSelect(TimeTag item) => editRomajiModeState.Select(item); - protected override void ApplyValue(RomajiTag item, string value) - => romajiTagsChangeHandler.SetText(item, value); - - protected override void SetIndex(RomajiTag item, int? startIndex, int? endIndex) - => romajiTagsChangeHandler.SetIndex(item, startIndex, endIndex); + protected override string GetFieldValue(TimeTag timeTag) + => timeTag.RomajiText ?? string.Empty; - protected override void RemoveTextTag(RomajiTag textTag) - => romajiTagsChangeHandler.Remove(textTag); + protected override void ApplyValue(TimeTag timeTag, string value) + => lyricTimeTagsChangeHandler.SetTimeTagRomajiText(timeTag, value); [BackgroundDependencyLoader] private void load() @@ -81,4 +113,27 @@ private void load() SelectedItems.BindTo(editRomajiModeState.SelectedItems); } } + + private partial class LabelledInitialSwitchButton : LabelledObjectFieldSwitchButton + { + [Resolved] + private ILyricTimeTagsChangeHandler lyricTimeTagsChangeHandler { get; set; } = null!; + + public LabelledInitialSwitchButton(TimeTag item) + : base(item) + { + } + + protected override bool GetFieldValue(TimeTag timeTag) + => timeTag.InitialRomaji; + + protected override void ApplyValue(TimeTag timeTag, bool value) + => lyricTimeTagsChangeHandler.SetTimeTagInitialRomaji(timeTag, value); + + [BackgroundDependencyLoader] + private void load(IEditRomajiModeState editRomajiModeState) + { + SelectedItems.BindTo(editRomajiModeState.SelectedItems); + } + } } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs index 3f28470a0..4f12f3a34 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs @@ -5,16 +5,18 @@ using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Objects.Utils; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; -public partial class RubyTagEditSection : TextTagEditSection +public partial class RubyTagEditSection : LyricPropertiesSection { protected override LocalisableString Title => "Ruby"; @@ -39,13 +41,25 @@ protected override LocalisableString GetWriteLyricPropertyLockedTooltip(LockLyri _ => throw new ArgumentOutOfRangeException(nameof(lockLyricPropertyBy), lockLyricPropertyBy, null), }; - private partial class RubyTagsEditor : TextTagsEditor + private partial class RubyTagsEditor : LyricPropertiesEditor { + protected sealed override Drawable CreateDrawable(RubyTag item) + { + string relativeToLyricText = TextTagUtils.GetTextFromLyric(item, CurrentLyric.Text); + string range = TextTagUtils.PositionFormattedString(item); + + return new LabelledRubyTagTextBox(CurrentLyric, item).With(t => + { + t.Label = relativeToLyricText; + t.Description = range; + t.TabbableContentContainer = this; + }); + } + + protected override EditorSectionButton? CreateCreateNewItemButton() => null; + protected override IBindableList GetItems(Lyric lyric) => lyric.RubyTagsBindable; - - protected override LabelledTextTagTextBox CreateLabelledTextTagTextBox(Lyric lyric, RubyTag textTag) - => new LabelledRubyTagTextBox(lyric, textTag); } protected partial class LabelledRubyTagTextBox : LabelledTextTagTextBox @@ -56,10 +70,10 @@ protected partial class LabelledRubyTagTextBox : LabelledTextTagTextBox [Resolved] private IEditRubyModeState editRubyModeState { get; set; } = null!; - public LabelledRubyTagTextBox(Lyric lyric, RubyTag textTag) - : base(lyric, textTag) + public LabelledRubyTagTextBox(Lyric lyric, RubyTag rubyTag) + : base(lyric, rubyTag) { - Debug.Assert(lyric.RubyTags.Contains(textTag)); + Debug.Assert(lyric.RubyTags.Contains(rubyTag)); } protected override void TriggerSelect(RubyTag item) @@ -71,8 +85,8 @@ protected override void ApplyValue(RubyTag item, string value) protected override void SetIndex(RubyTag item, int? startIndex, int? endIndex) => rubyTagsChangeHandler.SetIndex(item, startIndex, endIndex); - protected override void RemoveTextTag(RubyTag textTag) - => rubyTagsChangeHandler.Remove(textTag); + protected override void RemoveTextTag(RubyTag rubyTag) + => rubyTagsChangeHandler.Remove(rubyTag); [BackgroundDependencyLoader] private void load() diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagEditSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagEditSection.cs deleted file mode 100644 index b4a1c7a3c..000000000 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/TextTagEditSection.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Objects.Types; -using osu.Game.Rulesets.Karaoke.Objects.Utils; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components; - -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; - -public abstract partial class TextTagEditSection : LyricPropertiesSection where TTextTag : class, ITextTag, new() -{ - protected abstract partial class TextTagsEditor : LyricPropertiesEditor - { - protected sealed override Drawable CreateDrawable(TTextTag item) - { - string relativeToLyricText = TextTagUtils.GetTextFromLyric(item, CurrentLyric.Text); - string range = TextTagUtils.PositionFormattedString(item); - - return CreateLabelledTextTagTextBox(CurrentLyric, item).With(t => - { - t.Label = relativeToLyricText; - t.Description = range; - t.TabbableContentContainer = this; - }); - } - - protected abstract LabelledTextTagTextBox CreateLabelledTextTagTextBox(Lyric lyric, TTextTag textTag); - - protected override EditorSectionButton? CreateCreateNewItemButton() => null; - - protected override IBindableList GetItems(Lyric lyric) - { - throw new System.NotImplementedException(); - } - } -} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRomajiModeState.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRomajiModeState.cs index d554048c7..d22c44a51 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRomajiModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRomajiModeState.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -public partial class EditRomajiModeState : ModeStateWithBlueprintContainer, IEditRomajiModeState +public partial class EditRomajiModeState : ModeStateWithBlueprintContainer, IEditRomajiModeState { private readonly Bindable bindableEditMode = new(); @@ -21,11 +21,11 @@ public void ChangeEditStep(RomajiTagEditStep step) public Bindable BindableRomajiEditPropertyMode { get; } = new(); protected override bool IsWriteLyricPropertyLocked(Lyric lyric) - => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.RomajiTags)); + => HitObjectWritableUtils.IsWriteLyricPropertyLocked(lyric, nameof(Lyric.TimeTags)); protected override bool SelectFirstProperty(Lyric lyric) => BindableEditStep.Value == RomajiTagEditStep.Edit; - protected override IEnumerable SelectableProperties(Lyric lyric) - => lyric.RomajiTags; + protected override IEnumerable SelectableProperties(Lyric lyric) + => lyric.TimeTags; } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRomajiModeState.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRomajiModeState.cs index d891fed60..7ec22895b 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRomajiModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRomajiModeState.cs @@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -public interface IEditRomajiModeState : IHasEditStep, IHasBlueprintSelection +public interface IEditRomajiModeState : IHasEditStep, IHasBlueprintSelection { Bindable BindableRomajiEditPropertyMode { get; } } From dcdcba67a175a1824acf27e2e6f5c06aaa3d5b6c Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 29 Sep 2023 15:17:44 +0800 Subject: [PATCH 09/13] Implemeht the switch property section. --- .../Romaji/RomajiEditPropertyModeSection.cs | 29 +++++++++++++++++++ .../Lyrics/Settings/RomajiTagSettings.cs | 1 + 2 files changed, 30 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditPropertyModeSection.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditPropertyModeSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditPropertyModeSection.cs new file mode 100644 index 000000000..7047074a1 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditPropertyModeSection.cs @@ -0,0 +1,29 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Localisation; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; + +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Romaji; + +public partial class RomajiEditPropertyModeSection : EditorSection +{ + protected override LocalisableString Title => "Edit property"; + + [BackgroundDependencyLoader] + private void load(IEditRomajiModeState editRomajiModeState) + { + Children = new Drawable[] + { + new LabelledEnumDropdown + { + Label = "Edit property", + Description = "Batch edit text or other romaji-related properties from time-tag", + Current = editRomajiModeState.BindableRomajiEditPropertyMode, + }, + }; + } +} diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RomajiTagSettings.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RomajiTagSettings.cs index 2961bfbdc..8553b4454 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RomajiTagSettings.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RomajiTagSettings.cs @@ -32,6 +32,7 @@ private void load(IEditRomajiModeState romajiModeState) RomajiTagEditStep.Edit => new Drawable[] { new RomajiEditStepSection(), + new RomajiEditPropertyModeSection(), new RomajiEditSection(), }, RomajiTagEditStep.Verify => new Drawable[] From 2c3b1f92a6ef034ea4990a6ce55193a57ee84097 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 29 Sep 2023 10:29:33 +0800 Subject: [PATCH 10/13] Remove the public LabelledTextTagTextBox as base class. --- ...agTextBox.cs => LabelledRubyTagTextBox.cs} | 60 +++++++++++++------ .../Settings/RubyRomaji/RubyTagEditSection.cs | 37 ------------ 2 files changed, 42 insertions(+), 55 deletions(-) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/{LabelledTextTagTextBox.cs => LabelledRubyTagTextBox.cs} (82%) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledTextTagTextBox.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledRubyTagTextBox.cs similarity index 82% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledTextTagTextBox.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledRubyTagTextBox.cs index 3b9a73326..6a1f901d1 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledTextTagTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledRubyTagTextBox.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -11,23 +12,32 @@ using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; +using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Objects.Types; using osu.Game.Rulesets.Karaoke.Objects.Utils; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.UserInterface; using osuTK; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components; -public abstract partial class LabelledTextTagTextBox : LabelledObjectFieldTextBox where T : class, ITextTag +public partial class LabelledRubyTagTextBox : LabelledObjectFieldTextBox { protected const float DELETE_BUTTON_SIZE = 20f; + [Resolved] + private ILyricRubyTagsChangeHandler rubyTagsChangeHandler { get; set; } = null!; + + [Resolved] + private IEditRubyModeState editRubyModeState { get; set; } = null!; + private readonly IndexShiftingPart indexShiftingPart; - protected LabelledTextTagTextBox(Lyric lyric, T textTag) - : base(textTag) + public LabelledRubyTagTextBox(Lyric lyric, RubyTag rubyTag) + : base(rubyTag) { + Debug.Assert(lyric.RubyTags.Contains(rubyTag)); + if (InternalChildren[1] is not FillFlowContainer fillFlowContainer) throw new ArgumentNullException(nameof(fillFlowContainer)); @@ -54,13 +64,13 @@ protected LabelledTextTagTextBox(Lyric lyric, T textTag) Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Size = new Vector2(DELETE_BUTTON_SIZE), - Action = () => RemoveTextTag(textTag), + Action = () => removeRubyTag(rubyTag), Hover = hover => { if (hover) { // trigger selected if hover on delete button. - TriggerSelect(textTag); + TriggerSelect(rubyTag); } }, }, @@ -84,11 +94,11 @@ protected LabelledTextTagTextBox(Lyric lyric, T textTag) Selected = selected => { if (selected) - TriggerSelect(textTag); + TriggerSelect(rubyTag); }, Action = (indexType, action) => { - int index = getNewIndex(textTag, indexType); + int index = getNewIndex(rubyTag, indexType); int newIndex = calculateNewIndex(index, action); if (TextTagUtils.OutOfRange(lyric.Text, newIndex)) return; @@ -96,24 +106,24 @@ protected LabelledTextTagTextBox(Lyric lyric, T textTag) switch (indexType) { case AdjustIndex.Start: - if (TextTagUtils.ValidNewStartIndex(textTag, newIndex)) - SetIndex(textTag, newIndex, null); + if (TextTagUtils.ValidNewStartIndex(rubyTag, newIndex)) + setIndex(rubyTag, newIndex, null); break; case AdjustIndex.End: - if (TextTagUtils.ValidNewEndIndex(textTag, newIndex)) - SetIndex(textTag, null, newIndex); + if (TextTagUtils.ValidNewEndIndex(rubyTag, newIndex)) + setIndex(rubyTag, null, newIndex); break; default: throw new InvalidOperationException(); } - static int getNewIndex(T textTag, AdjustIndex index) => + static int getNewIndex(RubyTag rubyTag, AdjustIndex index) => index switch { - AdjustIndex.Start => textTag.StartIndex, - AdjustIndex.End => textTag.EndIndex, + AdjustIndex.Start => rubyTag.StartIndex, + AdjustIndex.End => rubyTag.EndIndex, _ => throw new InvalidOperationException(), }; @@ -129,12 +139,26 @@ static int calculateNewIndex(int index, AdjustAction action) => }); } - protected sealed override string GetFieldValue(T item) + private void setIndex(RubyTag item, int? startIndex, int? endIndex) + => rubyTagsChangeHandler.SetIndex(item, startIndex, endIndex); + + private void removeRubyTag(RubyTag rubyTag) + => rubyTagsChangeHandler.Remove(rubyTag); + + [BackgroundDependencyLoader] + private void load() + { + SelectedItems.BindTo(editRubyModeState.SelectedItems); + } + + protected sealed override string GetFieldValue(RubyTag item) => item.Text; - protected abstract void SetIndex(T item, int? startIndex, int? endIndex); + protected override void TriggerSelect(RubyTag item) + => editRubyModeState.Select(item); - protected abstract void RemoveTextTag(T item); + protected override void ApplyValue(RubyTag item, string value) + => rubyTagsChangeHandler.SetText(item, value); protected override bool IsFocused(Drawable focusedDrawable) => base.IsFocused(focusedDrawable) || focusedDrawable == indexShiftingPart; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs index 4f12f3a34..79eff8b8e 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs @@ -2,17 +2,13 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Diagnostics; -using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Localisation; -using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Utils; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; @@ -61,37 +57,4 @@ protected sealed override Drawable CreateDrawable(RubyTag item) protected override IBindableList GetItems(Lyric lyric) => lyric.RubyTagsBindable; } - - protected partial class LabelledRubyTagTextBox : LabelledTextTagTextBox - { - [Resolved] - private ILyricRubyTagsChangeHandler rubyTagsChangeHandler { get; set; } = null!; - - [Resolved] - private IEditRubyModeState editRubyModeState { get; set; } = null!; - - public LabelledRubyTagTextBox(Lyric lyric, RubyTag rubyTag) - : base(lyric, rubyTag) - { - Debug.Assert(lyric.RubyTags.Contains(rubyTag)); - } - - protected override void TriggerSelect(RubyTag item) - => editRubyModeState.Select(item); - - protected override void ApplyValue(RubyTag item, string value) - => rubyTagsChangeHandler.SetText(item, value); - - protected override void SetIndex(RubyTag item, int? startIndex, int? endIndex) - => rubyTagsChangeHandler.SetIndex(item, startIndex, endIndex); - - protected override void RemoveTextTag(RubyTag rubyTag) - => rubyTagsChangeHandler.Remove(rubyTag); - - [BackgroundDependencyLoader] - private void load() - { - SelectedItems.BindTo(editRubyModeState.SelectedItems); - } - } } From 8a7bcee1d6c5ed635c456124c696a393e04e2619 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 29 Sep 2023 15:22:55 +0800 Subject: [PATCH 11/13] Adjust the namespace. --- .../{RubyRomaji => Ruby}/Components/LabelledRubyTagTextBox.cs | 2 +- .../{RubyRomaji => Ruby}/RubyTagAutoGenerateSection.cs | 2 +- .../Settings/{RubyRomaji => Ruby}/RubyTagConfigToolSection.cs | 2 +- .../{RubyRomaji => Ruby}/RubyTagEditModeSubsection.cs | 2 +- .../Settings/{RubyRomaji => Ruby}/RubyTagEditSection.cs | 4 ++-- .../Settings/{RubyRomaji => Ruby}/RubyTagEditStepSection.cs | 2 +- .../Settings/{RubyRomaji => Ruby}/RubyTagIssueSection.cs | 2 +- .../Screens/Edit/Beatmaps/Lyrics/Settings/RubyTagSettings.cs | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji => Ruby}/Components/LabelledRubyTagTextBox.cs (99%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji => Ruby}/RubyTagAutoGenerateSection.cs (99%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji => Ruby}/RubyTagConfigToolSection.cs (97%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji => Ruby}/RubyTagEditModeSubsection.cs (98%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji => Ruby}/RubyTagEditSection.cs (98%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji => Ruby}/RubyTagEditStepSection.cs (99%) rename osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/{RubyRomaji => Ruby}/RubyTagIssueSection.cs (99%) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledRubyTagTextBox.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/Components/LabelledRubyTagTextBox.cs similarity index 99% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledRubyTagTextBox.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/Components/LabelledRubyTagTextBox.cs index 6a1f901d1..3d08eb51f 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/Components/LabelledRubyTagTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/Components/LabelledRubyTagTextBox.cs @@ -19,7 +19,7 @@ using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.UserInterface; using osuTK; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby.Components; public partial class LabelledRubyTagTextBox : LabelledObjectFieldTextBox { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagAutoGenerateSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagAutoGenerateSection.cs similarity index 99% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagAutoGenerateSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagAutoGenerateSection.cs index 4049e6224..6891b855c 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagAutoGenerateSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagAutoGenerateSection.cs @@ -8,7 +8,7 @@ using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Components.Markdown; using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby; public partial class RubyTagAutoGenerateSection : AutoGenerateSection { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagConfigToolSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagConfigToolSection.cs similarity index 97% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagConfigToolSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagConfigToolSection.cs index 6f5a93cd2..2b6ca36a7 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagConfigToolSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagConfigToolSection.cs @@ -6,7 +6,7 @@ using osu.Framework.Localisation; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby; public partial class RubyTagConfigToolSection : EditorSection { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditModeSubsection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditModeSubsection.cs similarity index 98% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditModeSubsection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditModeSubsection.cs index 904f6ae57..3fb4f71fa 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditModeSubsection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditModeSubsection.cs @@ -8,7 +8,7 @@ using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; using osuTK.Graphics; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby; public partial class RubyTagEditModeSubsection : EditModeSwitchSubsection { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditSection.cs similarity index 98% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditSection.cs index 79eff8b8e..99a574fb4 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditSection.cs @@ -8,9 +8,9 @@ using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Utils; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji.Components; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby.Components; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby; public partial class RubyTagEditSection : LyricPropertiesSection { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditStepSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditStepSection.cs similarity index 99% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditStepSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditStepSection.cs index 9380fe849..fdde79ae2 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditStepSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditStepSection.cs @@ -10,7 +10,7 @@ using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; using osuTK.Graphics; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby; public partial class RubyTagEditStepSection : LyricEditorEditStepSection { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagIssueSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagIssueSection.cs similarity index 99% rename from osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagIssueSection.cs rename to osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagIssueSection.cs index 0ab03e300..98d48e226 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagIssueSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagIssueSection.cs @@ -13,7 +13,7 @@ using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Issues; using osuTK; -namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby; public partial class RubyTagIssueSection : LyricEditorIssueSection { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyTagSettings.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyTagSettings.cs index d8c579858..443c9d1e5 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyTagSettings.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyTagSettings.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.Ruby; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings; From dff6246403cec75905ba421f7b256ef94b37dd59 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 29 Sep 2023 10:33:01 +0800 Subject: [PATCH 12/13] IPreviewLyricPositionProvider should only provide the ruby tag position now. --- .../TestScenePreviewKaraokeSpriteText.cs | 19 +------------------ .../Blueprints/RubyBlueprintContainer.cs | 2 +- .../Blueprints/RubyTagSelectionBlueprint.cs | 2 +- .../Lyrics/IPreviewLyricPositionProvider.cs | 3 +-- .../Lyrics/PreviewKaraokeSpriteText.cs | 12 +++--------- 5 files changed, 7 insertions(+), 31 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Components/TestScenePreviewKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Components/TestScenePreviewKaraokeSpriteText.cs index cd231339a..6ce3c7855 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Components/TestScenePreviewKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Components/TestScenePreviewKaraokeSpriteText.cs @@ -184,24 +184,7 @@ public void TestGetRubyPosition() { AddStep($"Show ruby-tag position: {TextTagUtils.PositionFormattedString(rubyTag)}", () => { - var position = karaokeSpriteText.GetTextTagByPosition(rubyTag); - showPosition(position); - }); - } - } - - #endregion - - #region Romaji tag - - [Test] - public void TestGetRomajiTagPosition() - { - foreach (var romajiTag in lyric.RomajiTags) - { - AddStep($"Show romaji-tag position: {TextTagUtils.PositionFormattedString(romajiTag)}", () => - { - var position = karaokeSpriteText.GetTextTagByPosition(romajiTag); + var position = karaokeSpriteText.GetRubyTagByPosition(rubyTag); showPosition(position); }); } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs index f2a7e569f..800f4fa44 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs @@ -131,7 +131,7 @@ void setRubyTagIndex(RubyTag rubyTag, int? startPosition, int? endPosition) private int? calculateNewIndex(RubyTag rubyTag, float offset, Anchor anchor) { // get real left-side and right-side position - var rect = previewLyricPositionProvider.GetTextTagByPosition(rubyTag); + var rect = previewLyricPositionProvider.GetRubyTagByPosition(rubyTag); // todo: need to think about how to handle the case if the text-tag already out of the range of the text. if (rect == null) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs index ff8311693..de3c78cc2 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs @@ -95,7 +95,7 @@ protected void UpdatePositionAndSize() // wait until lyric update ruby position. ScheduleAfterChildren(() => { - var rubyTagRect = previewLyricPositionProvider.GetTextTagByPosition(Item); + var rubyTagRect = previewLyricPositionProvider.GetRubyTagByPosition(Item); if (rubyTagRect == null) { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/IPreviewLyricPositionProvider.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/IPreviewLyricPositionProvider.cs index e97d93a95..f7a1f4d60 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/IPreviewLyricPositionProvider.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/IPreviewLyricPositionProvider.cs @@ -3,7 +3,6 @@ using osu.Framework.Graphics.Primitives; using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Objects.Types; using osuTK; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics; @@ -18,7 +17,7 @@ public interface IPreviewLyricPositionProvider RectangleF GetRectByCharIndicator(int charIndex); - RectangleF? GetTextTagByPosition(ITextTag textTag); + RectangleF? GetRubyTagByPosition(RubyTag rubyTag); TimeTag? GetTimeTagByPosition(float position); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs index 12ac4bd81..155d4d701 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Graphics.Sprites; using osu.Game.Rulesets.Karaoke.Objects; -using osu.Game.Rulesets.Karaoke.Objects.Types; using osu.Game.Rulesets.Karaoke.Objects.Utils; using osu.Game.Rulesets.Karaoke.Skinning.Elements; using osu.Game.Rulesets.Karaoke.Skinning.Tools; @@ -126,15 +125,10 @@ public RectangleF GetRectByCharIndicator(int charIndex) #endregion - #region Ruby/Romaji tag + #region Ruby tag - public RectangleF? GetTextTagByPosition(ITextTag textTag) => - textTag switch - { - RubyTag rubyTag => spriteText.GetRubyTagPosition(rubyTag), - RomajiTag romajiTag => spriteText.GetRomajiTagPosition(romajiTag), - _ => throw new ArgumentOutOfRangeException(nameof(textTag)), - }; + public RectangleF? GetRubyTagByPosition(RubyTag rubyTag) => + spriteText.GetRubyTagPosition(rubyTag); #endregion From 5e662d54a5f0891bbe3cae9d652f9033bdcd4c77 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 29 Sep 2023 10:34:45 +0800 Subject: [PATCH 13/13] Those KaraokeEditAction should for ruby only. --- .../KaraokeEditInputManager.cs | 18 +++++++++--------- osu.Game.Rulesets.Karaoke/KaraokeRuleset.cs | 8 ++++---- .../Settings/Romaji/RomajiEditStepSection.cs | 8 ++++---- .../Ruby/Components/LabelledRubyTagTextBox.cs | 8 ++++---- .../Settings/Ruby/RubyTagEditStepSection.cs | 8 ++++---- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/KaraokeEditInputManager.cs b/osu.Game.Rulesets.Karaoke/KaraokeEditInputManager.cs index e0d4f4b8a..f603efd34 100644 --- a/osu.Game.Rulesets.Karaoke/KaraokeEditInputManager.cs +++ b/osu.Game.Rulesets.Karaoke/KaraokeEditInputManager.cs @@ -68,18 +68,18 @@ public enum KaraokeEditAction [Description("Next edit mode")] NextEditMode, - // Edit Ruby / romaji tag. - [Description("Reduce start index")] - EditTextTagReduceStartIndex, + // Edit Ruby tag. + [Description("Reduce ruby-tag start index")] + EditRubyTagReduceStartIndex, - [Description("Increase start index")] - EditTextTagIncreaseStartIndex, + [Description("Increase ruby-tag start index")] + EditRubyTagIncreaseStartIndex, - [Description("Reduce end index")] - EditTextTagReduceEndIndex, + [Description("Reduce ruby-tag end index")] + EditRubyTagReduceEndIndex, - [Description("Increase end index")] - EditTextTagIncreaseEndIndex, + [Description("Increase ruby-tag end index")] + EditRubyTagIncreaseEndIndex, // Edit time-tag. [Description("Create start time-tag")] diff --git a/osu.Game.Rulesets.Karaoke/KaraokeRuleset.cs b/osu.Game.Rulesets.Karaoke/KaraokeRuleset.cs index 4d18265b8..e8f628578 100644 --- a/osu.Game.Rulesets.Karaoke/KaraokeRuleset.cs +++ b/osu.Game.Rulesets.Karaoke/KaraokeRuleset.cs @@ -109,10 +109,10 @@ public override IEnumerable GetDefaultKeyBindings(int variant = 0) = new KeyBinding(new[] { InputKey.Alt, InputKey.BracketRight }, KaraokeEditAction.NextEditMode), // Edit Ruby / romaji tag. - new KeyBinding(new[] { InputKey.Z, InputKey.Left }, KaraokeEditAction.EditTextTagReduceStartIndex), - new KeyBinding(new[] { InputKey.Z, InputKey.Right }, KaraokeEditAction.EditTextTagIncreaseStartIndex), - new KeyBinding(new[] { InputKey.X, InputKey.Left }, KaraokeEditAction.EditTextTagReduceEndIndex), - new KeyBinding(new[] { InputKey.X, InputKey.Right }, KaraokeEditAction.EditTextTagIncreaseEndIndex), + new KeyBinding(new[] { InputKey.Z, InputKey.Left }, KaraokeEditAction.EditRubyTagReduceStartIndex), + new KeyBinding(new[] { InputKey.Z, InputKey.Right }, KaraokeEditAction.EditRubyTagIncreaseStartIndex), + new KeyBinding(new[] { InputKey.X, InputKey.Left }, KaraokeEditAction.EditRubyTagReduceEndIndex), + new KeyBinding(new[] { InputKey.X, InputKey.Right }, KaraokeEditAction.EditRubyTagIncreaseEndIndex), // edit time-tag. new KeyBinding(InputKey.Q, KaraokeEditAction.CreateStartTimeTag), diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs index ce21da08d..00e31d866 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditStepSection.cs @@ -73,10 +73,10 @@ protected override DescriptionFormat GetSelectionDescription(RomajiTagEditStep s Text = "Keys", AdjustableActions = new List { - KaraokeEditAction.EditTextTagReduceStartIndex, - KaraokeEditAction.EditTextTagIncreaseStartIndex, - KaraokeEditAction.EditTextTagReduceEndIndex, - KaraokeEditAction.EditTextTagIncreaseEndIndex, + KaraokeEditAction.EditRubyTagReduceStartIndex, + KaraokeEditAction.EditRubyTagIncreaseStartIndex, + KaraokeEditAction.EditRubyTagReduceEndIndex, + KaraokeEditAction.EditRubyTagIncreaseEndIndex, }, } }, diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/Components/LabelledRubyTagTextBox.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/Components/LabelledRubyTagTextBox.cs index 3d08eb51f..f8f671a9f 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/Components/LabelledRubyTagTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/Components/LabelledRubyTagTextBox.cs @@ -275,10 +275,10 @@ public bool OnPressed(KeyBindingPressEvent e) return e.Action switch { - KaraokeEditAction.EditTextTagReduceStartIndex => reduceStartIndexButton.TriggerClick(), - KaraokeEditAction.EditTextTagIncreaseStartIndex => increaseStartIndexButton.TriggerClick(), - KaraokeEditAction.EditTextTagReduceEndIndex => reduceEndIndexButton.TriggerClick(), - KaraokeEditAction.EditTextTagIncreaseEndIndex => increaseEndIndexButton.TriggerClick(), + KaraokeEditAction.EditRubyTagReduceStartIndex => reduceStartIndexButton.TriggerClick(), + KaraokeEditAction.EditRubyTagIncreaseStartIndex => increaseStartIndexButton.TriggerClick(), + KaraokeEditAction.EditRubyTagReduceEndIndex => reduceEndIndexButton.TriggerClick(), + KaraokeEditAction.EditRubyTagIncreaseEndIndex => increaseEndIndexButton.TriggerClick(), _ => false, }; } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditStepSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditStepSection.cs index fdde79ae2..bea2d7021 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditStepSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Ruby/RubyTagEditStepSection.cs @@ -73,10 +73,10 @@ protected override DescriptionFormat GetSelectionDescription(RubyTagEditStep ste Text = "Keys", AdjustableActions = new List { - KaraokeEditAction.EditTextTagReduceStartIndex, - KaraokeEditAction.EditTextTagIncreaseStartIndex, - KaraokeEditAction.EditTextTagReduceEndIndex, - KaraokeEditAction.EditTextTagIncreaseEndIndex, + KaraokeEditAction.EditRubyTagReduceStartIndex, + KaraokeEditAction.EditRubyTagIncreaseStartIndex, + KaraokeEditAction.EditRubyTagReduceEndIndex, + KaraokeEditAction.EditRubyTagIncreaseEndIndex, }, } },