From 2925c32ace1d54cc4ddae9ac1e9e0e21df3c0b29 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 19 Aug 2023 00:34:53 +0800 Subject: [PATCH 01/10] Add the edit mode for that. --- .../Beatmaps/Lyrics/States/Modes/RubyTagEditMode.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/RubyTagEditMode.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/RubyTagEditMode.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/RubyTagEditMode.cs new file mode 100644 index 000000000..6d9a45626 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/RubyTagEditMode.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.States.Modes; + +public enum RubyTagEditMode +{ + Create, + + Modify, +} From e2fa297af489a714c4b4142de49e2e47ad4f40a9 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 30 Aug 2023 23:34:06 +0800 Subject: [PATCH 02/10] And add into the mode state. --- .../Edit/Beatmaps/Lyrics/States/Modes/EditRubyModeState.cs | 2 ++ .../Edit/Beatmaps/Lyrics/States/Modes/IEditRubyModeState.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRubyModeState.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRubyModeState.cs index d2f95c6a7..cb5eab510 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRubyModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/EditRubyModeState.cs @@ -14,6 +14,8 @@ public partial class EditRubyModeState : ModeStateWithBlueprintContainer BindableEditStep => bindableEditMode; + public Bindable BindableRubyTagEditMode { get; } = new(); + public void ChangeEditStep(RubyTagEditStep step) => bindableEditMode.Value = step; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRubyModeState.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRubyModeState.cs index d7c9df9a7..b72c3c38a 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRubyModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IEditRubyModeState.cs @@ -1,10 +1,12 @@ // 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; namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; public interface IEditRubyModeState : IHasEditStep, IHasBlueprintSelection { + Bindable BindableRubyTagEditMode { get; } } From 37ac0bfd83b8393c5e23ca9671fefbaed8ae3068 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 3 Sep 2023 17:08:59 +0800 Subject: [PATCH 03/10] Implement the section for able to config the edit mode. --- .../RubyRomaji/RubyTagConfigToolSection.cs | 26 +++++++++++++ .../RubyRomaji/RubyTagEditModeSubsection.cs | 38 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagConfigToolSection.cs create mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditModeSubsection.cs 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/RubyRomaji/RubyTagConfigToolSection.cs new file mode 100644 index 000000000..06d3a0ddb --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagConfigToolSection.cs @@ -0,0 +1,26 @@ +// 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.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; + +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; + +public partial class RubyTagConfigToolSection : EditorSection +{ + protected override LocalisableString Title => "Config Tool"; + + [BackgroundDependencyLoader] + private void load(IEditRubyModeState editRubyModeState) + { + Children = new Drawable[] + { + new RubyTagEditModeSubsection() + { + Current = editRubyModeState.BindableRubyTagEditMode, + }, + }; + } +} 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/RubyRomaji/RubyTagEditModeSubsection.cs new file mode 100644 index 000000000..904f6ae57 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditModeSubsection.cs @@ -0,0 +1,38 @@ +// 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.Localisation; +using osu.Game.Graphics; +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 RubyTagEditModeSubsection : EditModeSwitchSubsection +{ + protected override LocalisableString GetButtonTitle(RubyTagEditMode mode) + => mode switch + { + RubyTagEditMode.Create => "Create", + RubyTagEditMode.Modify => "Modify", + _ => throw new InvalidOperationException(nameof(mode)), + }; + + protected override Color4 GetButtonColour(OsuColour colours, RubyTagEditMode mode, bool active) + => mode switch + { + RubyTagEditMode.Create => active ? colours.Green : colours.GreenDarker, + RubyTagEditMode.Modify => active ? colours.Pink : colours.PinkDarker, + _ => throw new InvalidOperationException(nameof(mode)), + }; + + protected override DescriptionFormat GetDescription(RubyTagEditMode mode) => + mode switch + { + RubyTagEditMode.Create => "Use mouse to select range of the lyric text to create the ruby tag.", + RubyTagEditMode.Modify => "Select ruby to change the start/end position or delete it.", + _ => throw new InvalidOperationException(nameof(mode)), + }; +} From 30f9a0c200e4fd721ea131b8b6e02ef4ce0e6e2f Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 3 Sep 2023 17:09:19 +0800 Subject: [PATCH 04/10] Add the section into every edit step. --- .../Screens/Edit/Beatmaps/Lyrics/Settings/RubyTagSettings.cs | 3 +++ 1 file changed, 3 insertions(+) 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 d10b94bb1..d8c579858 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 @@ -27,16 +27,19 @@ private void load(IEditRubyModeState editRubyModeState) RubyTagEditStep.Generate => new Drawable[] { new RubyTagEditStepSection(), + new RubyTagConfigToolSection(), new RubyTagAutoGenerateSection(), }, RubyTagEditStep.Edit => new Drawable[] { new RubyTagEditStepSection(), + new RubyTagConfigToolSection(), new RubyTagEditSection(), }, RubyTagEditStep.Verify => new Drawable[] { new RubyTagEditStepSection(), + new RubyTagConfigToolSection(), new RubyTagIssueSection(), }, _ => throw new ArgumentOutOfRangeException(), From 4c39a01d2089863c23d07df4ef652c4f4a40853d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 3 Sep 2023 23:16:59 +0800 Subject: [PATCH 05/10] Hide the blueprint container if in the create ruby tag mode. --- .../Components/Lyrics/BlueprintLayer.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 79f076919..a164c0f40 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 @@ -14,6 +14,9 @@ public partial class BlueprintLayer : BaseLayer { private readonly IBindable bindableModeWithEditStep = new Bindable(); + // todo: make better way to handle this. + private readonly IBindable bindableRubyTagEditMode = new Bindable(); + // should block all blueprint action if not editable. public override bool PropagatePositionalInputSubTree => base.PropagatePositionalInputSubTree && editable; @@ -27,12 +30,20 @@ public BlueprintLayer(Lyric lyric) // Initial blueprint container. InitializeBlueprint(); }); + + bindableRubyTagEditMode.BindValueChanged(_ => + { + // Initial blueprint container. + InitializeBlueprint(); + }); } [BackgroundDependencyLoader] - private void load(ILyricEditorState state, ITimeTagModeState timeTagModeState) + private void load(ILyricEditorState state, IEditRubyModeState editRubyModeState) { bindableModeWithEditStep.BindTo(state.BindableModeWithEditStep); + + bindableRubyTagEditMode.BindTo(editRubyModeState.BindableRubyTagEditMode); } protected void InitializeBlueprint() @@ -42,16 +53,18 @@ protected void InitializeBlueprint() // create preview and real caret var modeWithEditStep = bindableModeWithEditStep.Value; - var blueprintContainer = createBlueprintContainer(modeWithEditStep, Lyric); + var rubyTagEditMode = bindableRubyTagEditMode.Value; + + var blueprintContainer = createBlueprintContainer(modeWithEditStep, rubyTagEditMode, Lyric); if (blueprintContainer == null) return; AddInternal(blueprintContainer); - static Drawable? createBlueprintContainer(EditorModeWithEditStep modeWithEditStep, Lyric lyric) => + static Drawable? createBlueprintContainer(EditorModeWithEditStep modeWithEditStep, RubyTagEditMode rubyTagEditMode, Lyric lyric) => modeWithEditStep.Mode switch { - LyricEditorMode.EditRuby => new RubyBlueprintContainer(lyric), + LyricEditorMode.EditRuby => rubyTagEditMode == RubyTagEditMode.Create ? null : new RubyBlueprintContainer(lyric), LyricEditorMode.EditRomaji => new RomajiBlueprintContainer(lyric), LyricEditorMode.EditTimeTag => modeWithEditStep.EditStep is TimeTagEditStep.Adjust ? new TimeTagBlueprintContainer(lyric) : null, _ => null, From 224bedbe6e330b5b505373d14a4dcf898f6fdc35 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 3 Sep 2023 23:17:48 +0800 Subject: [PATCH 06/10] Should handle mouse event if need to create the ruby-tag. --- .../Edit/Beatmaps/Lyrics/Components/Lyrics/InteractableLyric.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/InteractableLyric.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/InteractableLyric.cs index b029a09e2..60b05e416 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/InteractableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/InteractableLyric.cs @@ -128,6 +128,7 @@ protected override void OnDrag(DragEvent e) CuttingCaretPosition => karaokeSpriteText.GetCharIndicatorByPosition(position), TypingCaretPosition => karaokeSpriteText.GetCharIndicatorByPosition(position), NavigateCaretPosition => null, + CreateRubyTagCaretPosition => karaokeSpriteText.GetCharIndexByPosition(position), TimeTagIndexCaretPosition => karaokeSpriteText.GetCharIndexByPosition(position), TimeTagCaretPosition => karaokeSpriteText.GetTimeTagByPosition(position), _ => null, From 093d2ba535ec692b97f09b268cd3bd9618c96a73 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 3 Sep 2023 23:18:58 +0800 Subject: [PATCH 07/10] Should have different caret position algorithm if in the create ruby mode. --- .../Lyrics/States/LyricCaretStateTest.cs | 3 ++- .../Beatmaps/Lyrics/States/LyricCaretState.cs | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/States/LyricCaretStateTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/States/LyricCaretStateTest.cs index efe7e2cb2..339e56343 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/States/LyricCaretStateTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/States/LyricCaretStateTest.cs @@ -63,6 +63,7 @@ private void load() Dependencies.Cache(new EditorClock()); Dependencies.CacheAs(state = new TestLyricEditorState()); Dependencies.CacheAs(new TextingModeState()); + Dependencies.CacheAs(new EditRubyModeState()); Dependencies.CacheAs(new TimeTagModeState()); Dependencies.Cache(new KaraokeRulesetLyricEditorConfigManager()); @@ -107,7 +108,7 @@ public void TestChangeFromEditModeToEditMode() { // change from edit mode to view mode for checking that caret position should be clear. changeMode(LyricEditorMode.Texting); - changeMode(LyricEditorMode.EditRuby); + changeMode(LyricEditorMode.EditRomaji); // get the action assertCaretPosition(Assert.IsInstanceOf); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/LyricCaretState.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/LyricCaretState.cs index 99a51fa4b..0278bdebc 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/LyricCaretState.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/LyricCaretState.cs @@ -38,6 +38,7 @@ public partial class LyricCaretState : Component, ILyricCaretState private readonly IBindable bindableModeWithEditStep = new Bindable(); // it might be special for create time-tag mode. + private readonly IBindable bindableRubyTagEditMode = new Bindable(); private readonly IBindable bindableCreateTimeTagEditMode = new Bindable(); private readonly IBindable bindableCreateMovingCaretMode = new Bindable(); private readonly IBindable bindableRecordingMovingCaretMode = new Bindable(); @@ -69,6 +70,11 @@ public LyricCaretState() Schedule(refreshAlgorithmAndCaretPosition); }); + bindableRubyTagEditMode.BindValueChanged(_ => + { + refreshAlgorithmAndCaretPosition(); + }); + bindableCreateTimeTagEditMode.BindValueChanged(_ => { refreshAlgorithmAndCaretPosition(); @@ -132,7 +138,7 @@ private void refreshAlgorithmAndCaretPosition() LyricEditorMode.Texting => getTextingModeAlgorithm(editorModeWithEditStep.GetEditStep()), LyricEditorMode.Reference => new NavigateCaretPositionAlgorithm(lyrics), LyricEditorMode.Language => new ClickingCaretPositionAlgorithm(lyrics), - LyricEditorMode.EditRuby => new NavigateCaretPositionAlgorithm(lyrics), + LyricEditorMode.EditRuby => getRubyTagModeAlgorithm(), LyricEditorMode.EditRomaji => new NavigateCaretPositionAlgorithm(lyrics), LyricEditorMode.EditTimeTag => getTimeTagModeAlgorithm(editorModeWithEditStep.GetEditStep()), LyricEditorMode.EditNote => new NavigateCaretPositionAlgorithm(lyrics), @@ -149,6 +155,14 @@ ICaretPositionAlgorithm getTextingModeAlgorithm(TextingEditStep textingEditMode) _ => throw new InvalidOperationException(nameof(textingEditMode)), }; + ICaretPositionAlgorithm getRubyTagModeAlgorithm() => + bindableRubyTagEditMode.Value switch + { + RubyTagEditMode.Create => new CreateRubyTagCaretPositionAlgorithm(lyrics), + RubyTagEditMode.Modify => new NavigateCaretPositionAlgorithm(lyrics), + _ => throw new InvalidOperationException(nameof(bindableRubyTagEditMode.Value)), + }; + ICaretPositionAlgorithm getTimeTagModeAlgorithm(TimeTagEditStep timeTagEditMode) { return timeTagEditMode switch @@ -170,7 +184,12 @@ static ICaretPositionAlgorithm getCreateTimeTagEditModeAlgorithm(Lyric[] lyrics, } [BackgroundDependencyLoader] - private void load(EditorBeatmap beatmap, ILyricsProvider lyricsProvider, ILyricEditorState state, KaraokeRulesetLyricEditorConfigManager lyricEditorConfigManager, ITimeTagModeState timeTagModeState) + private void load(EditorBeatmap beatmap, + ILyricsProvider lyricsProvider, + ILyricEditorState state, + KaraokeRulesetLyricEditorConfigManager lyricEditorConfigManager, + IEditRubyModeState editRubyModeState, + ITimeTagModeState timeTagModeState) { selectedHitObjects.BindTo(beatmap.SelectedHitObjects); @@ -178,6 +197,7 @@ private void load(EditorBeatmap beatmap, ILyricsProvider lyricsProvider, ILyricE bindableModeWithEditStep.BindTo(state.BindableModeWithEditStep); + bindableRubyTagEditMode.BindTo(editRubyModeState.BindableRubyTagEditMode); bindableCreateTimeTagEditMode.BindTo(timeTagModeState.BindableCreateTimeTagEditMode); lyricEditorConfigManager.BindWith(KaraokeRulesetLyricEditorSetting.CreateTimeTagMovingCaretMode, bindableCreateMovingCaretMode); lyricEditorConfigManager.BindWith(KaraokeRulesetLyricEditorSetting.RecordingTimeTagMovingCaretMode, bindableRecordingMovingCaretMode); From 89da506e3aedd387dec70db5a4f482f3e7df8dfd Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 3 Sep 2023 22:53:13 +0800 Subject: [PATCH 08/10] Create the drawable caret for the create ruby caret position. merge. merge. --- .../DrawableCreateRubyTagCaretPosition.cs | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaretPosition.cs diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaretPosition.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaretPosition.cs new file mode 100644 index 000000000..68f68bbf7 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaretPosition.cs @@ -0,0 +1,130 @@ +// 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.Framework.Graphics.Sprites; +using osu.Framework.Logging; +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.Screens.Edit.Beatmaps.Lyrics.CaretPosition; +using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States; +using osuTK; + +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Carets; + +public partial class DrawableCreateRubyTagCaretPosition : DrawableRangeCaret +{ + private const float border_spacing = 5; + private const float caret_move_time = 60; + private const float caret_resize_time = 60; + + [Resolved] + private ILyricRubyTagsChangeHandler lyricRubyTagsChangeHandler { get; set; } = null!; + + [Resolved] + private ILyricCaretState lyricCaretState { get; set; } = null!; + + private readonly IconButton icon; + + public DrawableCreateRubyTagCaretPosition(DrawableCaretType type) + : base(type) + { + InternalChildren = new Drawable[] + { + new Container + { + Masking = true, + BorderThickness = border_spacing, + BorderColour = Colour4.White, + RelativeSizeAxes = Axes.Both, + Alpha = GetAlpha(type), + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Colour4.White, + Alpha = 0.1f, + }, + }, + icon = new IconButton + { + Anchor = Anchor.TopRight, + Origin = Anchor.BottomLeft, + Icon = FontAwesome.Solid.PlusCircle, + Size = new Vector2(15), + Alpha = GetAlpha(type), + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + icon.IconColour = colours.Green; + icon.IconHoverColour = colours.GreenLight; + } + + protected override void ApplyCaretPosition(CreateRubyTagCaretPosition caret) + { + // should not show the hover caret if already contains the selected range. + if (Type == DrawableCaretType.HoverCaret && lyricCaretState.CaretPosition?.Lyric == caret.Lyric) + { + Hide(); + return; + } + + var rect = LyricPositionProvider.GetRectByCharIndex(caret.CharIndex); + changeTheSizeByRect(rect); + + icon.Action = () => + { + lyricRubyTagsChangeHandler.Add(new RubyTag + { + StartIndex = caret.CharIndex, + EndIndex = caret.CharIndex, + Text = "Ruby", + }); + }; + } + + protected override void ApplyRangeCaretPosition(RangeCaretPosition caret) + { + int minIndex = caret.GetRangeCaretPosition().Item1.CharIndex; + int maxIndex = caret.GetRangeCaretPosition().Item2.CharIndex; + + Logger.Log($"{minIndex}, {maxIndex}"); + + var rect = RectangleF.Union(LyricPositionProvider.GetRectByCharIndex(minIndex), LyricPositionProvider.GetRectByCharIndex(maxIndex)); + changeTheSizeByRect(rect); + + icon.Action = () => + { + lyricRubyTagsChangeHandler.Add(new RubyTag + { + StartIndex = minIndex, + EndIndex = maxIndex, + Text = "Ruby", + }); + }; + } + + private void changeTheSizeByRect(RectangleF rect) + { + var position = rect.TopLeft - new Vector2(border_spacing); + float width = rect.Width + border_spacing * 2; + + this.MoveTo(position, caret_move_time, Easing.Out); + this.ResizeWidthTo(width, caret_resize_time, Easing.Out); + Height = rect.Height + border_spacing * 2; + } + + protected override void TriggerDisallowEditEffect(OsuColour colour) + { + this.FlashColour(colour.Red, 200); + } +} From 5a7d0dc0e9dc003e44250e5ff1280c0034bff27d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 3 Sep 2023 23:19:07 +0800 Subject: [PATCH 09/10] Adjust other caret. --- .../Components/Lyrics/Carets/DrawableTimeTagIndexCaret.cs | 2 +- .../Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTimeTagIndexCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTimeTagIndexCaret.cs index 481fb3e96..67bbe9cd8 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTimeTagIndexCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTimeTagIndexCaret.cs @@ -20,7 +20,7 @@ public DrawableTimeTagIndexCaret(DrawableCaretType type) InternalChild = new Container { Masking = true, - BorderThickness = 4, + BorderThickness = border_spacing, BorderColour = Colour4.White, RelativeSizeAxes = Axes.Both, Child = new Box diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs index 2a7c17bbf..8d9c759cd 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs @@ -23,6 +23,7 @@ public partial class DrawableTypingCaret : DrawableRangeCaret Date: Sun, 3 Sep 2023 23:19:18 +0800 Subject: [PATCH 10/10] Apply the drawable caret. --- .../Edit/Beatmaps/Lyrics/Components/Lyrics/CaretLayer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/CaretLayer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/CaretLayer.cs index 72f499c28..fc423fab5 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/CaretLayer.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/CaretLayer.cs @@ -79,6 +79,8 @@ private void updateDrawableCaret(ICaretPosition? position, DrawableCaretType typ CuttingCaretPosition => new DrawableCuttingCaret(type), // typing TypingCaretPosition => new DrawableTypingCaret(type), + // creat ruby-tag + CreateRubyTagCaretPosition => new DrawableCreateRubyTagCaretPosition(type), // creat time-tag TimeTagIndexCaretPosition => new DrawableTimeTagIndexCaret(type), // record time-tag