From f2b3667650410177b3161df3fae1f8f926d5acfe Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:23:16 +0800 Subject: [PATCH 01/19] Remove this. --- .../Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs index 22c7eee24..8d2135754 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LyricEditorAutoGenerateSubsection.cs @@ -17,7 +17,7 @@ public abstract partial class LyricEditorAutoGenerateSubsection : AutoGenerateSu protected LyricEditorAutoGenerateSubsection(AutoGenerateType generateType) { - this.autoGenerateType = generateType; + autoGenerateType = generateType; } protected override EditorSectionButton CreateGenerateButton() From 1ea1724dd630499c1a7a91f666c7722cb55899b9 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:23:29 +0800 Subject: [PATCH 02/19] Remove un-need ctor. --- .../Editor/TestSceneSetupScreen.cs | 19 +++++++------------ .../TestScenePreviewKaraokeSpriteText.cs | 17 ++++++----------- .../Edit/Import/TestSceneLyricImporter.cs | 7 +------ 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs index e0573f5b2..8561c7b7f 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs @@ -18,22 +18,17 @@ public partial class TestSceneSetupScreen : EditorClockTestScene { [Cached(typeof(EditorBeatmap))] [Cached(typeof(IBeatSnapProvider))] - private readonly EditorBeatmap editorBeatmap; + private readonly EditorBeatmap editorBeatmap = new(new KaraokeBeatmap + { + BeatmapInfo = + { + Ruleset = new KaraokeRuleset().RulesetInfo, + }, + }); [Cached] private readonly OverlayColourProvider colourProvider = new(OverlayColourScheme.Blue); - public TestSceneSetupScreen() - { - editorBeatmap = new EditorBeatmap(new KaraokeBeatmap - { - BeatmapInfo = - { - Ruleset = new KaraokeRuleset().RulesetInfo, - }, - }); - } - [Test] public void TestKaraoke() => runForRuleset(new KaraokeRuleset().RulesetInfo); 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 6ce3c7855..16923d804 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 @@ -27,18 +27,13 @@ public partial class TestScenePreviewKaraokeSpriteText : OsuTestScene private Action? updateAction; - private readonly Lyric lyric; - - public TestScenePreviewKaraokeSpriteText() + private readonly Lyric lyric = new() { - lyric = new Lyric - { - Text = "カラオケ", - TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }), - RubyTags = TestCaseTagHelper.ParseRubyTags(new[] { "[0]:か", "[1]:ら", "[2]:お", "[3]:け" }), - RomajiTags = TestCaseTagHelper.ParseRomajiTags(new[] { "[0]:ka", "[1]:ra", "[2]:o", "[3]:ke" }), - }; - } + Text = "カラオケ", + TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { "[0,start]:1000", "[1,start]:2000", "[2,start]:3000", "[3,start]:4000", "[3,end]:5000" }), + RubyTags = TestCaseTagHelper.ParseRubyTags(new[] { "[0]:か", "[1]:ら", "[2]:お", "[3]:け" }), + RomajiTags = TestCaseTagHelper.ParseRomajiTags(new[] { "[0]:ka", "[1]:ra", "[2]:o", "[3]:ke" }), + }; protected override void Update() { diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Import/TestSceneLyricImporter.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Import/TestSceneLyricImporter.cs index e182d3d87..59b0d42d2 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Import/TestSceneLyricImporter.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Import/TestSceneLyricImporter.cs @@ -25,7 +25,7 @@ public partial class TestSceneLyricImporter : ScreenTestScene Content { get; } = new Container { RelativeSizeAxes = Axes.Both }; @@ -37,11 +37,6 @@ protected override TestLyricImporter CreateScreen() private DialogOverlay dialogOverlay = null!; - public TestSceneLyricImporter() - { - lyricEditorConfigManager = new KaraokeRulesetLyricEditorConfigManager(); - } - [BackgroundDependencyLoader] private void load() { From 35442098910b4130acb59424c7bc2b983f5add86 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:25:37 +0800 Subject: [PATCH 03/19] Base method did not have default value. --- osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs index df9664bf8..604008c9d 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs @@ -126,7 +126,7 @@ public override SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePositio : result; } - protected override DrawableRuleset CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList? mods = null) + protected override DrawableRuleset CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods) { drawableRuleset = new DrawableKaraokeEditorRuleset(ruleset, beatmap, mods); From 3143741260accb397773266a5048086462ca47f9 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:26:16 +0800 Subject: [PATCH 04/19] Remove un-need "$". --- .../Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs index 12042430d..97009fceb 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Import/Lyrics/GenerateRuby/GenerateRubyNavigation.cs @@ -43,8 +43,8 @@ protected override LocalisableString GetNavigationText(NavigationState value) => value switch { NavigationState.Initial => $"Lazy to typing ruby? Press [{auto_generate_ruby}].", - NavigationState.Working => $"Go to next step to generate time-tag.", - NavigationState.Done => $"Go to next step to generate time-tag.", + NavigationState.Working => "Go to next step to generate time-tag.", + NavigationState.Done => "Go to next step to generate time-tag.", NavigationState.Error => "Oops, seems cause some error in here.", _ => throw new ArgumentOutOfRangeException(nameof(value)), }; From 5a20f67f92a554fdf16a8a7bf5e7207578dc38ea Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:30:55 +0800 Subject: [PATCH 05/19] Refactor the FontUtils --- osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs index 98feb8680..589bfa350 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/FontUtils.cs @@ -17,17 +17,8 @@ public static class FontUtils public static float[] DefaultFontSize() => new float[] { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }; - public static float[] DefaultFontSize(float? minSize = null, float? maxSize = null) - => DefaultFontSize().Where(x => - { - if (minSize.HasValue && x < minSize.Value) - return false; - - if (maxSize.HasValue && x > maxSize.Value) - return false; - - return true; - }).ToArray(); + public static float[] DefaultFontSize(float minSize, float maxSize) + => DefaultFontSize().Where(x => x >= minSize && x <= maxSize).ToArray(); /// /// For selecting preview size in editor. From 08823c834bbc7723dd89fb691f71b94f5a6088be Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:34:53 +0800 Subject: [PATCH 06/19] Add [JsonProperty] to let the ide knows that the property is using. --- .../Replays/TestSceneAutoGenerationBySinger.cs | 3 +++ .../Utils/ComparableUtilsTest.cs | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGenerationBySinger.cs b/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGenerationBySinger.cs index abfb7d49f..7d45607b0 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGenerationBySinger.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Replays/TestSceneAutoGenerationBySinger.cs @@ -56,10 +56,13 @@ private static IReadOnlyList getCompareResultFromName(st private struct TestKaraokeReplayFrame { + [JsonProperty] public double Time { get; set; } + [JsonProperty] public float Pitch { get; set; } + [JsonProperty] public bool Sound { get; set; } } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs index dbab86816..c657dbb77 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs @@ -50,10 +50,13 @@ public void TestCompareByProperty(string leftObjectProperty, string rightObjectP private class TestObject { - public int A { get; set; } = 0; + [JsonProperty] + public int A { get; set; } - public double B { get; set; } = 0; + [JsonProperty] + public double B { get; set; } + [JsonProperty] public string C { get; set; } = string.Empty; } } From c59cf2d422b5f918f7145b9a847f84295c0827a3 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:36:57 +0800 Subject: [PATCH 07/19] change the param and type name. --- .../Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs index 2931161c9..82b5b3185 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/States/Modes/IHasEditStep.cs @@ -6,11 +6,11 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; -public interface IHasEditStep where T : Enum +public interface IHasEditStep where TEditStep : Enum { - IBindable BindableEditStep { get; } + IBindable BindableEditStep { get; } - T EditStep => BindableEditStep.Value; + TEditStep EditStep => BindableEditStep.Value; - void ChangeEditStep(T mode); + void ChangeEditStep(TEditStep step); } From 90ba64af7aeb11cccea2b3a5b6f38ede70c57fcc Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:53:00 +0800 Subject: [PATCH 08/19] Stage info is not need to be tested. --- .../Stages/Classic/ClassicStageInfoTest.cs | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 osu.Game.Rulesets.Karaoke.Tests/Stages/Classic/ClassicStageInfoTest.cs diff --git a/osu.Game.Rulesets.Karaoke.Tests/Stages/Classic/ClassicStageInfoTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Stages/Classic/ClassicStageInfoTest.cs deleted file mode 100644 index 7e8d885ca..000000000 --- a/osu.Game.Rulesets.Karaoke.Tests/Stages/Classic/ClassicStageInfoTest.cs +++ /dev/null @@ -1,11 +0,0 @@ -// 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.Tests.Stages.Classic; - -public class ClassicStageInfoTest -{ - #region Stage element - - #endregion -} From 2cb64286ccbac3f9ed03db21dd72fd517efca990 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 22 Dec 2023 00:53:31 +0800 Subject: [PATCH 09/19] Remove empty region. --- .../Edit/Checks/CheckBeatmapClassicStageInfo.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckBeatmapClassicStageInfo.cs b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckBeatmapClassicStageInfo.cs index 9668b27cd..59fffaa3a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckBeatmapClassicStageInfo.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckBeatmapClassicStageInfo.cs @@ -143,10 +143,6 @@ public IssueTemplateInvalidRowHeight(ICheck check) public Issue Create() => new(this); } - #region stage definition - - #endregion - #region timing info public class IssueTemplateLessThanTwoTimingPoints : IssueTemplate From e6a6edde899d9d9e6562c6002e904d786071e887 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 15:36:08 +0800 Subject: [PATCH 10/19] Rename the global property name to avoid name conflict. --- .../Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs index f003a0504..100015ceb 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics; public partial class LyricEditorVerifier : EditorVerifier, ILyricEditorVerifier { [Resolved] - private EditorBeatmap beatmap { get; set; } = null!; + private EditorBeatmap editorBeatmap { get; set; } = null!; private readonly Dictionary> hitObjectIssues = new(); @@ -65,9 +65,9 @@ protected override void LoadComplete() base.LoadComplete(); // need to check is there any lyric added or removed. - beatmap.HitObjectAdded += hitObjectAdded; - beatmap.HitObjectRemoved += hitObjectRemoved; - beatmap.HitObjectUpdated += hitObjectUpdated; + editorBeatmap.HitObjectAdded += hitObjectAdded; + editorBeatmap.HitObjectRemoved += hitObjectRemoved; + editorBeatmap.HitObjectUpdated += hitObjectUpdated; recalculateIssues(); } @@ -80,7 +80,7 @@ private void load(KaraokeRulesetEditCheckerConfigManager? rulesetEditCheckerConf private void recalculateIssues() { - var hitObjects = beatmap.HitObjects.OfType().ToArray(); + var hitObjects = editorBeatmap.HitObjects.OfType().ToArray(); var listedHitObjects = hitObjectIssues.Keys.ToArray(); var newHitObjects = hitObjects.Except(listedHitObjects); @@ -182,9 +182,9 @@ protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); - beatmap.HitObjectAdded -= hitObjectAdded; - beatmap.HitObjectRemoved -= hitObjectRemoved; - beatmap.HitObjectUpdated -= hitObjectUpdated; + editorBeatmap.HitObjectAdded -= hitObjectAdded; + editorBeatmap.HitObjectRemoved -= hitObjectRemoved; + editorBeatmap.HitObjectUpdated -= hitObjectUpdated; } } From 8706f126425e71f376004b585f6b5784acf768ef Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 15:55:44 +0800 Subject: [PATCH 11/19] Use switch instead. --- osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs index b381b9656..31964e4d7 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/CharUtils.cs @@ -64,17 +64,17 @@ public static bool IsChinese(char c) /// public static bool IsLatin(char c) { - if (c >= 'A' && c <= 'Z') - return true; + switch (c) + { + case >= 'A' and <= 'Z': + case >= 'a' and <= 'z': + // another romanized characters + // see: https://www.unicode.org/charts/PDF/U1E00.pdf + case >= '\u1E00' and <= '\u1EFF': + return true; - if (c >= 'a' && c <= 'z') - return true; - - // another romanized characters - // see: https://www.unicode.org/charts/PDF/U1E00.pdf - if (c >= '\u1E00' && c <= '\u1EFF') - return true; - - return false; + default: + return false; + } } } From 6151019869fd021956953e7ec5cba4eff4fc4341 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 16:00:34 +0800 Subject: [PATCH 12/19] Prevent use recursive. --- .../Algorithms/BaseCaretPositionAlgorithmTest.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/CaretPosition/Algorithms/BaseCaretPositionAlgorithmTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/CaretPosition/Algorithms/BaseCaretPositionAlgorithmTest.cs index 37af52bb0..0d37d92ed 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/CaretPosition/Algorithms/BaseCaretPositionAlgorithmTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Screens/Edit/Beatmap/Lyrics/CaretPosition/Algorithms/BaseCaretPositionAlgorithmTest.cs @@ -106,15 +106,17 @@ protected Lyric[] GetLyricsByMethodName(string methodName) private static PropertyInfo? getMethod(Type type, string methodName) { - var theMethod = type.GetProperty(methodName, BindingFlags.NonPublic | BindingFlags.Static); + Type? targetType = type; - if (theMethod != null) - return theMethod; + while (targetType != null) + { + var theMethod = targetType.GetProperty(methodName, BindingFlags.NonPublic | BindingFlags.Static); + if (theMethod != null) + return theMethod; - var baseType = type.BaseType; - if (baseType == null) - return null; + targetType = targetType.BaseType; + } - return getMethod(baseType, methodName); + return null; } } From a1f65992f476f8cc7f4283537d72261d5fb60700 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 16:07:15 +0800 Subject: [PATCH 13/19] Convert to return statement. --- .../Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs | 9 +++------ .../Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs | 8 +++----- .../Beatmaps/KaraokeBeatmapExtension.cs | 11 +++-------- .../Difficulty/KaraokeDifficultyCalculator.cs | 13 ++++--------- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs index 52c572a31..4f43fe52d 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs @@ -48,12 +48,9 @@ protected override IList CreateProperties(Type type, MemberSeriali { var props = base.CreateProperties(type, memberSerialization); - if (type == typeof(BeatmapInfo)) - { - return props.Where(p => p.PropertyName != "ruleset_id").ToList(); - } - - return props; + return type == typeof(BeatmapInfo) + ? props.Where(p => p.PropertyName != "ruleset_id").ToList() + : props; } } } diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs index 0605d9694..c9277f66e 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs @@ -52,11 +52,9 @@ private IEnumerable encodeNote(Beatmap output) // Convert single note static string convertNote(Note note) { - if (!note.Display) - return "-"; - - // TODO : Fill if customize ruby and percentage - return convertTone(note.Tone); + return !note.Display + ? "-" + : convertTone(note.Tone); // Convert tone to string static string convertTone(Tone tone) => tone.Scale + (tone.Half ? "#" : string.Empty); diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs index f17ae952f..c581c44aa 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs @@ -12,14 +12,9 @@ public static class KaraokeBeatmapExtension { public static bool IsScorable(this IBeatmap beatmap) { - if (beatmap is not KaraokeBeatmap karaokeBeatmap) - { - // we should throw invalidate exception here but it will cause test case failed. - // because beatmap in the working beatmap in test case not always be karaoke beatmap class. - return false; - } - - return karaokeBeatmap.Scorable; + // we should throw invalidate exception here but it will cause test case failed. + // because beatmap in the working beatmap in test case not always be karaoke beatmap class. + return beatmap is KaraokeBeatmap karaokeBeatmap && karaokeBeatmap.Scorable; } public static IList AvailableTranslates(this IBeatmap beatmap) => (beatmap as KaraokeBeatmap)?.AvailableTranslates ?? new List(); diff --git a/osu.Game.Rulesets.Karaoke/Difficulty/KaraokeDifficultyCalculator.cs b/osu.Game.Rulesets.Karaoke/Difficulty/KaraokeDifficultyCalculator.cs index 7a12863cf..f620409f7 100644 --- a/osu.Game.Rulesets.Karaoke/Difficulty/KaraokeDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Karaoke/Difficulty/KaraokeDifficultyCalculator.cs @@ -79,16 +79,11 @@ protected override IEnumerable CreateDifficultyHitObjects(I private int getHitWindow300(Mod[] mods) { - if (isForCurrentRuleset) - { - double od = Math.Min(10.0, Math.Max(0, 10.0 - originalOverallDifficulty)); - return applyModAdjustments(34 + 3 * od, mods); - } - - if (Math.Round(originalOverallDifficulty) > 4) - return applyModAdjustments(34, mods); + if (!isForCurrentRuleset) + return applyModAdjustments(Math.Round(originalOverallDifficulty) > 4 ? 34 : 47, mods); - return applyModAdjustments(47, mods); + double od = Math.Min(10.0, Math.Max(0, 10.0 - originalOverallDifficulty)); + return applyModAdjustments(34 + 3 * od, mods); static int applyModAdjustments(double value, Mod[] mods) { From c96639398549b125df26e2d92fd6dcae4d7d3a5a Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 21:14:50 +0800 Subject: [PATCH 14/19] There's no need to assign the null value here. --- .../Lyrics/Components/Lyrics/PreviewKaraokeSpriteText.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 155d4d701..a9dabff5a 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 @@ -26,7 +26,7 @@ public partial class PreviewKaraokeSpriteText : DrawableKaraokeSpriteText Date: Sat, 23 Dec 2023 22:42:47 +0800 Subject: [PATCH 15/19] Make the logic easy to be maintained. --- .../Lyrics/PreviewKaraokeSpriteText.cs | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) 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 a9dabff5a..3aa6224a2 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 @@ -136,31 +136,35 @@ public RectangleF GetRectByCharIndicator(int charIndex) public TimeTag? GetTimeTagByPosition(float position) { + var hoverIndex = getHoverIndex(); + if (hoverIndex == null) + return null; + // todo: will use better way to get the time-tag - var textIndex = getHoverIndex(); - return HitObject.TimeTags.FirstOrDefault(x => x.Index == textIndex); + return HitObject.TimeTags.FirstOrDefault(x => x.Index == hoverIndex); - TextIndex getHoverIndex() + TextIndex? getHoverIndex() { for (int i = 0; i < Text.Length; i++) { - if (getTriggerPositionByTimeIndex(new TextIndex(i)) > position) - return new TextIndex(i); - - if (getTriggerPositionByTimeIndex(new TextIndex(i, TextIndex.IndexState.End)) > position) - return new TextIndex(i, TextIndex.IndexState.End); + foreach (var indexState in Enum.GetValues()) + { + var textIndex = new TextIndex(i, indexState); + var triggerRange = getTriggerRange(textIndex); + if (position >= triggerRange.Item1 && position <= triggerRange.Item2) + return textIndex; + } } - return new TextIndex(Text.Length - 1, TextIndex.IndexState.End); + // hover the last time-tag if exceed the range. + return null; - // todo : might have a better way to call spriteText.GetTimeTagPosition just once. - float getTriggerPositionByTimeIndex(TextIndex textIndex) + Tuple getTriggerRange(TextIndex textIndex) { - int charIndex = textIndex.Index; - float startPosition = spriteText.GetTimeTagPosition(new TextIndex(charIndex)).X; - float endPosition = spriteText.GetTimeTagPosition(new TextIndex(charIndex, TextIndex.IndexState.End)).X; - - return TextIndexUtils.GetValueByState(textIndex, () => startPosition + (endPosition - startPosition) / 2, () => endPosition); + var rect = spriteText.GetCharacterDrawRectangle(textIndex.Index); + return TextIndexUtils.GetValueByState(textIndex, + () => new Tuple(rect.Left, rect.Centre.X), + () => new Tuple(rect.Centre.X, rect.Right)); } } } From b36c22243e062e8e7276991af9c71414177660e2 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 22:46:42 +0800 Subject: [PATCH 16/19] Merge the property. --- .../Screens/Edit/Beatmaps/Pages/PageScreen.cs | 6 ++---- .../Screens/Edit/Beatmaps/Singers/SingerScreen.cs | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Pages/PageScreen.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Pages/PageScreen.cs index 78fcec632..afaedad43 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Pages/PageScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Pages/PageScreen.cs @@ -94,14 +94,12 @@ public void Select(Page item) private partial class FixedSectionsContainer : SectionsContainer where T : Drawable { - private readonly Container content; - // todo: check what this shit doing. - protected override Container Content => content; + protected override Container Content { get; } public FixedSectionsContainer() { - AddInternal(content = new Container + AddInternal(Content = new Container { Masking = true, RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Singers/SingerScreen.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Singers/SingerScreen.cs index 961c71232..989f7be45 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Singers/SingerScreen.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Singers/SingerScreen.cs @@ -83,14 +83,12 @@ protected override void PopOut() private partial class FixedSectionsContainer : SectionsContainer where T : Drawable { - private readonly Container content; - // todo: check what this shit doing. - protected override Container Content => content; + protected override Container Content { get; } public FixedSectionsContainer() { - AddInternal(content = new Container + AddInternal(Content = new Container { Masking = true, RelativeSizeAxes = Axes.Both, From 421c726573ad994a28389c84d3afe9e7100028c2 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 22:49:05 +0800 Subject: [PATCH 17/19] Make the CI happy. --- .../Beatmaps/TestElementId.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestElementId.cs b/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestElementId.cs index 2c80e63f9..e79d8c312 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestElementId.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestElementId.cs @@ -35,11 +35,17 @@ public void TestCreateElementId(string id, bool created) { if (created) { - Assert.DoesNotThrow(() => new ElementId(id)); + Assert.DoesNotThrow(() => + { + var _ = new ElementId(id); + }); } else { - Assert.Throws(() => new ElementId(id)); + Assert.Throws(() => + { + var _ = new ElementId(id); + }); } } From 9e3843be7d7f50a584d0c3b80aa70360ebdeefb1 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 22:57:28 +0800 Subject: [PATCH 18/19] Remove un-need DI. --- .../Edit/Setup/Components/SingerDisplay.cs | 4 ---- .../Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs | 4 ---- .../Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs | 3 --- .../Edit/Beatmaps/Lyrics/Settings/Romaji/RomajiEditSection.cs | 4 ---- 4 files changed, 15 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerDisplay.cs b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerDisplay.cs index 73d621667..1f205ede5 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerDisplay.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Setup/Components/SingerDisplay.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -79,9 +78,6 @@ private partial class SingerCircle : OsuClickableContainer, IHasContextMenu, IHa private readonly DrawableSingerAvatar singerAvatar; - [Resolved] - private OsuColour colours { get; set; } = null!; - public SingerCircle() { RelativeSizeAxes = Axes.X; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs index cf86183e7..a69468118 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/Toolbar/ToolbarButton.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Input; using osu.Game.Graphics.Containers; using osuTK; @@ -26,9 +25,6 @@ public void SetIcon(Drawable icon) [Resolved] private TextureStore textures { get; set; } = null!; - [Resolved] - private ReadableKeyCombinationProvider keyCombinationProvider { get; set; } = null!; - public void SetIcon(string texture) => SetIcon(new Sprite { 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 e6332938a..9dd360919 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorClipboard.cs @@ -44,9 +44,6 @@ public partial class LyricEditorClipboard : Component, ILyricEditorClipboard [Resolved] private ITimeTagModeState timeTagModeState { get; set; } = null!; - [Resolved] - private IEditRomajiModeState editRomajiModeState { get; set; } = null!; - [Resolved] private ILyricsChangeHandler? lyricsChangeHandler { get; set; } 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 e70646019..dffe4b520 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 @@ -11,7 +11,6 @@ using osu.Game.Rulesets.Karaoke.Extensions; using osu.Game.Rulesets.Karaoke.Objects; 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; @@ -44,9 +43,6 @@ private partial class RomajiTagsEditor : LyricPropertiesEditor { private readonly Bindable bindableRomajiEditPropertyMode = new(); - [Resolved] - private EditorBeatmap beatmap { get; set; } = null!; - public RomajiTagsEditor() { bindableRomajiEditPropertyMode.BindValueChanged(e => From 50162d11eaa0e5179f1f2760b99cea896a78ce0c Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 23 Dec 2023 23:27:59 +0800 Subject: [PATCH 19/19] Just make the code check happy. --- .../Algorithms/TimeTagCaretPositionAlgorithm.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithm.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithm.cs index 272db68cc..fe81965b4 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithm.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithm.cs @@ -81,11 +81,8 @@ protected override bool PositionMovable(TimeTagCaretPosition position) protected override TimeTagCaretPosition? MoveToFirstLyric() { var firstLyric = Lyrics.FirstOrDefault(x => x.TimeTags.Any(timeTagMovable)); - if (firstLyric == null) - return null; - - var firstTimeTag = firstLyric.TimeTags.FirstOrDefault(timeTagMovable); - if (firstTimeTag == null) + var firstTimeTag = firstLyric?.TimeTags.FirstOrDefault(timeTagMovable); + if (firstLyric == null || firstTimeTag == null) return null; return CreateCaretPosition(firstLyric, firstTimeTag); @@ -94,11 +91,8 @@ protected override bool PositionMovable(TimeTagCaretPosition position) protected override TimeTagCaretPosition? MoveToLastLyric() { var lastLyric = Lyrics.LastOrDefault(x => x.TimeTags.Any(timeTagMovable)); - if (lastLyric == null) - return null; - - var lastTimeTag = lastLyric.TimeTags.LastOrDefault(timeTagMovable); - if (lastTimeTag == null) + var lastTimeTag = lastLyric?.TimeTags.LastOrDefault(timeTagMovable); + if (lastLyric == null || lastTimeTag == null) return null; return CreateCaretPosition(lastLyric, lastTimeTag);