From b4f179d0805c959664e33e2a5dc9b1cbdb888bf5 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 24 Aug 2024 14:16:42 +0800 Subject: [PATCH 1/5] Let the test case able to support the skin with shader. --- .../Content/TestSceneInteractableLyric.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Content/TestSceneInteractableLyric.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Content/TestSceneInteractableLyric.cs index 84d5d11b4..98578b4e7 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Content/TestSceneInteractableLyric.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/Content/TestSceneInteractableLyric.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; +using osu.Framework.IO.Stores; using osu.Framework.Testing; using osu.Game.Graphics; using osu.Game.Rulesets.Karaoke.Beatmaps; @@ -24,6 +25,7 @@ using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; using osu.Game.Rulesets.Karaoke.Tests.Helper; using osu.Game.Screens.Edit; +using osu.Game.Skinning; using osu.Game.Tests.Visual; using osuTK; @@ -170,7 +172,7 @@ public void TestBlueprintLayer() } [BackgroundDependencyLoader] - private void load() + private void load(OsuGameBase game) { Dependencies.CacheAs(new LyricsProvider().With(Add)); Dependencies.CacheAs(new LyricsChangeHandler().With(Add)); @@ -178,6 +180,8 @@ private void load() Dependencies.CacheAs(new LyricRubyTagsChangeHandler().With(Add)); Dependencies.CacheAs(new LyricTimeTagsChangeHandler().With(Add)); Dependencies.Cache(new KaraokeRulesetLyricEditorConfigManager()); + + game.Resources.AddStore(new NamespacedResourceStore(new ShaderResourceStore(), "Resources")); } #region Testing tools @@ -276,7 +280,6 @@ private void updateInteractableLyric() Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, - Scale = new Vector2(2), Children = new Drawable[] { new Box @@ -288,7 +291,15 @@ private void updateInteractableLyric() { AutoSizeAxes = Axes.Both, Padding = new MarginPadding(48), - Child = createInteractableLyric(loaders.ToArray()), + Child = new SkinProvidingContainer(new LyricEditorSkin(null) + { + FontSize = 48, + }) + { + RelativeSizeAxes = Axes.None, + AutoSizeAxes = Axes.Both, + Child = createInteractableLyric(loaders.ToArray()), + }, }, }, }); From 29250955493ddf31195522a123e6e44172e1e409 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 24 Aug 2024 14:55:11 +0800 Subject: [PATCH 2/5] Let edit lyric layer able to suppoer change the over recording time-tag index. --- .../Lyrics/Content/Components/Lyrics/EditLyricLayer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/EditLyricLayer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/EditLyricLayer.cs index 1d3c6b630..a7ad478c4 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/EditLyricLayer.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/EditLyricLayer.cs @@ -1,6 +1,7 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Input.Events; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; @@ -125,9 +126,13 @@ protected override void OnDragEnd(DragEndEvent e) TypingCaretPositionAlgorithm => previewLyricPositionProvider.GetCharIndicatorByPosition(position), NavigateCaretPositionAlgorithm => null, CreateRubyTagCaretPositionAlgorithm => previewLyricPositionProvider.GetCharIndexByPosition(position), + RecordingTimeTagCaretPositionAlgorithm => getTimeTagByIndex(Lyric, previewLyricPositionProvider.GetCharIndexByPosition(position)), CreateRemoveTimeTagCaretPositionAlgorithm => previewLyricPositionProvider.GetCharIndexByPosition(position), _ => null, }; + + TimeTag? getTimeTagByIndex(Lyric lyric, int? charIndex) + => lyric.TimeTags.FirstOrDefault(tag => tag.Index.Index == charIndex); } #region Double click From 68f92d1957436b873ce90eb2df3d276d33dd49b6 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 24 Aug 2024 14:55:50 +0800 Subject: [PATCH 3/5] Add a new role in the base range caret index: - if user is start dragging the caret, should hide the hover caret. --- .../Carets/DrawableCreateRubyTagCaret.cs | 16 ---------------- .../Lyrics/Carets/DrawableRangeCaret.cs | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs index d146c26d3..b6e9d491a 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs @@ -28,9 +28,6 @@ public partial class DrawableCreateRubyTagCaret : DrawableRangeCaret : DrawableCaret, ICanAcceptRangeIndex where TCaretPosition : struct, IIndexCaretPosition { + private readonly IBindable bindableRangeCaretPosition = new Bindable(); + protected DrawableRangeCaret(DrawableCaretState state) : base(state) { + // should auto hide the hover caret if selecting. + bindableRangeCaretPosition.BindValueChanged(x => + { + if (State != DrawableCaretState.Hover) + return; + + if (x.NewValue != null) + Hide(); + }); + } + + [BackgroundDependencyLoader] + private void load(ILyricCaretState lyricCaretState) + { + bindableRangeCaretPosition.BindTo(lyricCaretState.BindableRangeCaretPosition); } public sealed override void ApplyCaretPosition(ICaretPosition caret) From 6cd8bfdce9bae99921fdf22c0d0bd04c9f43a02f Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 24 Aug 2024 15:27:09 +0800 Subject: [PATCH 4/5] Typing caret's width should be fixed and in the center between texts. --- .../Lyrics/Carets/DrawableTypingCaret.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableTypingCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableTypingCaret.cs index 377b2973f..bb171185e 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableTypingCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableTypingCaret.cs @@ -24,7 +24,7 @@ public partial class DrawableTypingCaret : DrawableRangeCaret Date: Sat, 24 Aug 2024 15:19:41 +0800 Subject: [PATCH 5/5] Make the idol/hover caret state better. --- .../DrawableCreateRemoveTimeTagCaret.cs | 18 ++++-- .../Lyrics/Carets/DrawableCuttingCaret.cs | 6 +- .../Carets/DrawableRecordingTimeTagCaret.cs | 55 ++++++++++++------- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableCreateRemoveTimeTagCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableCreateRemoveTimeTagCaret.cs index 30bb20291..45541384f 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableCreateRemoveTimeTagCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableCreateRemoveTimeTagCaret.cs @@ -27,8 +27,8 @@ public partial class DrawableCreateRemoveTimeTagCaret : DrawableCaret { + private const float caret_width = 10; + private readonly Container splitter; private readonly SpriteIcon splitIcon; public DrawableCuttingCaret(DrawableCaretState state) : base(state) { - Width = 10; + Width = caret_width; Origin = Anchor.TopCentre; InternalChildren = new Drawable[] @@ -87,7 +89,7 @@ protected override void ApplyCaretPosition(CuttingCaretPosition caret) { var rect = LyricPositionProvider.GetRectByCharIndicator(caret.CharGap); - Position = rect.TopLeft; + Position = rect.TopLeft + new Vector2(rect.Width / 2 - caret_width / 2, 0); Height = rect.Height; } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableRecordingTimeTagCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableRecordingTimeTagCaret.cs index 4907cc91d..b26f9269a 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableRecordingTimeTagCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableRecordingTimeTagCaret.cs @@ -21,8 +21,8 @@ public partial class DrawableRecordingTimeTagCaret : DrawableCaret