diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/KaraokeEditorScreenTestScene.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/KaraokeEditorScreenTestScene.cs index a5d15e637..8180368ef 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/KaraokeEditorScreenTestScene.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/KaraokeEditorScreenTestScene.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System; -using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -26,21 +25,15 @@ protected KaraokeEditorScreenTestScene() editorBeatmap = new EditorBeatmap(CreateBeatmap()); } - [Test] - public void TestKaraoke() => runForRuleset(new KaraokeRuleset().RulesetInfo); - - private void runForRuleset(RulesetInfo rulesetInfo) + protected override void LoadComplete() { - AddStep("create screen", () => - { - editorBeatmap.BeatmapInfo.Ruleset = rulesetInfo; + editorBeatmap.BeatmapInfo.Ruleset = new KaraokeRuleset().RulesetInfo; - Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap); + Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap); - Child = CreateEditorScreen().With(x => - { - x.State.Value = Visibility.Visible; - }); + Child = CreateEditorScreen().With(x => + { + x.State.Value = Visibility.Visible; }); } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/KaraokeSkinEditorScreenTestScene.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/KaraokeSkinEditorScreenTestScene.cs index dd889a3de..bf4d2cef4 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/KaraokeSkinEditorScreenTestScene.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/KaraokeSkinEditorScreenTestScene.cs @@ -1,7 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -29,17 +28,11 @@ private void load(SkinManager skinManager) karaokeSkin = skinManager.CurrentSkin.Value as KaraokeSkin; } - [Test] - public void TestKaraoke() => runForRuleset(new KaraokeRuleset().RulesetInfo); - - private void runForRuleset(RulesetInfo rulesetInfo) + protected override void LoadComplete() { - AddStep("create screen", () => + Child = CreateEditorScreen(karaokeSkin).With(x => { - Child = CreateEditorScreen(karaokeSkin).With(x => - { - x.State.Value = Visibility.Visible; - }); + x.State.Value = Visibility.Visible; }); } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Utils/TimeTagsUtilsTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Utils/TimeTagsUtilsTest.cs index 40ee55a74..597cefe5a 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Utils/TimeTagsUtilsTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Utils/TimeTagsUtilsTest.cs @@ -82,6 +82,7 @@ public void TestFindNoneTime(string[] timeTagTexts, string[] invalidTimeTags) [TestCase("カラオケ", new[] { "[3,end]:1000" }, false)] [TestCase("カラオケ", new[] { "[-1,start]:1000", "[3,end]:2000" }, false)] // out of range end time-tag should be count as missing. [TestCase("", new[] { "[0,start]:1000", "[0,end]:2000" }, false)] // empty lyric should always count as missing. + [TestCase("カラオケ", null, false)] // empty time-tag should always count as missing. public void TestHasStartTimeTagInLyric(string text, string[] timeTagTexts, bool actual) { var timeTags = TestCaseTagHelper.ParseTimeTags(timeTagTexts); diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditor.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditor.cs index 94491e1ac..2f6a63249 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditor.cs @@ -273,6 +273,17 @@ private void load(EditorBeatmap beatmap) lyricEditorConfigManager.BindWith(KaraokeRulesetLyricEditorSetting.CreateTimeTagMovingCaretMode, bindableCreateMovingCaretMode); lyricEditorConfigManager.BindWith(KaraokeRulesetLyricEditorSetting.RecordingTimeTagMovingCaretMode, bindableRecordingMovingCaretMode); + // if caret position changed, should add into editor beatmap selected hit objects. + lyricCaretState.BindableCaretPosition.BindValueChanged(e => + { + beatmap.SelectedHitObjects.Clear(); + + var lyric = e.NewValue?.Lyric; + + if (lyric != null) + beatmap.SelectedHitObjects.Add(lyric); + }); + // set-up divisor. beatDivisor.Value = beatmap.BeatmapInfo.BeatDivisor; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/TextTagBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/TextTagBlueprintContainer.cs index 992b1b6d4..6fde25b99 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/TextTagBlueprintContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/TextTagBlueprintContainer.cs @@ -35,7 +35,7 @@ protected TextTagBlueprintContainer(Lyric lyric) protected override bool OnMouseDown(MouseDownEvent e) { - lyricCaretState.MoveCaretToTargetPosition(new NavigateCaretPosition(Lyric)); + lyricCaretState.MoveCaretToTargetPosition(Lyric); return base.OnMouseDown(e); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/TimeTagBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/TimeTagBlueprintContainer.cs index dd2fbe1a4..ec2828bbf 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/TimeTagBlueprintContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/TimeTagBlueprintContainer.cs @@ -34,7 +34,7 @@ public TimeTagBlueprintContainer(Lyric lyric) protected override bool OnMouseDown(MouseDownEvent e) { - lyricCaretState.MoveCaretToTargetPosition(new NavigateCaretPosition(Lyric)); + lyricCaretState.MoveCaretToTargetPosition(Lyric); return base.OnMouseDown(e); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs index b84404d01..71ddd830d 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.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; using System.ComponentModel; using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.CaretPosition; @@ -79,6 +80,18 @@ public bool MoveCaret(MovingCaretAction action) return true; } + public void MoveCaretToTargetPosition(Lyric lyric) + { + if (lyric == null) + throw new ArgumentNullException(nameof(lyric)); + + if (algorithm == null) + throw new InvalidOperationException($"{nameof(algorithm)} cannot be null."); + + BindableCaretPosition.Value = algorithm.CallMethod("MoveToTarget", lyric); + BindableHoverCaretPosition.Value = null; + } + public void MoveCaretToTargetPosition(ICaretPosition position) { if (position.Lyric == null) diff --git a/osu.Game.Rulesets.Karaoke/Utils/TimeTagsUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/TimeTagsUtils.cs index 692ee8b27..141c15d4c 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/TimeTagsUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/TimeTagsUtils.cs @@ -92,7 +92,7 @@ public static TimeTag[] FindNoneTime(TimeTag[] timeTags) /// /// public static bool HasStartTimeTagInLyric(TimeTag[] timeTags, string lyric) - => !string.IsNullOrEmpty(lyric) && timeTags.Any(x => x.Index.State == TextIndex.IndexState.Start && x.Index.Index == 0); + => !string.IsNullOrEmpty(lyric) && timeTags != null && timeTags.Any(x => x.Index.State == TextIndex.IndexState.Start && x.Index.Index == 0); /// /// Check lyric has end time-tag