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()), + }, }, }, }); 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/DrawableRangeCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableRangeCaret.cs index 4a7ef7f8a..f12fe92db 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableRangeCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Content/Components/Lyrics/Carets/DrawableRangeCaret.cs @@ -2,6 +2,8 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.CaretPosition; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States; @@ -10,9 +12,26 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compone public abstract partial class 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) 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. 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