From 25998ff335893601e49b7c5b9091056cc81001c5 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 25 Feb 2023 11:17:03 -0800 Subject: [PATCH 1/5] Should check the reference lyric instead. --- .../Edit/ChangeHandlers/Lyrics/LyricReferenceChangeHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/Lyrics/LyricReferenceChangeHandler.cs b/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/Lyrics/LyricReferenceChangeHandler.cs index 9419759d0..b39d35e78 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/Lyrics/LyricReferenceChangeHandler.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/Lyrics/LyricReferenceChangeHandler.cs @@ -42,7 +42,7 @@ public void SwitchToReferenceLyricConfig() { PerformOnSelection(lyric => { - if (lyric == null) + if (lyric.ReferenceLyric == null) throw new InvalidOperationException($"{nameof(lyric)} must have reference lyric."); lyric.ReferenceLyricConfig = new ReferenceLyricConfig(); @@ -53,7 +53,7 @@ public void SwitchToSyncLyricConfig() { PerformOnSelection(lyric => { - if (lyric == null) + if (lyric.ReferenceLyric == null) throw new InvalidOperationException($"{nameof(lyric)} must have reference lyric."); lyric.ReferenceLyricConfig = new SyncLyricConfig(); From b94179861fa6dcbf51ef0d4ac82efd21fdd68bb0 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 25 Feb 2023 11:19:07 -0800 Subject: [PATCH 2/5] Remove un-need parentheses. --- .../Utils/ComparableUtilsTest.cs | 6 +++--- osu.Game.Rulesets.Karaoke/Objects/Lyric_Binding.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs index 604759682..dbab86816 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Utils/ComparableUtilsTest.cs @@ -42,9 +42,9 @@ public void TestCompareByProperty(string leftObjectProperty, string rightObjectP var leftObject = JsonConvert.DeserializeObject(leftObjectProperty); var rightObject = JsonConvert.DeserializeObject(rightObjectProperty); int actual = ComparableUtils.CompareByProperty(leftObject, rightObject, - (t) => t.A, - (t) => t.B, - (t) => t.C); + t => t.A, + t => t.B, + t => t.C); Assert.AreEqual(expected, actual); } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Lyric_Binding.cs b/osu.Game.Rulesets.Karaoke/Objects/Lyric_Binding.cs index 0fd0fd5c9..668935bdc 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Lyric_Binding.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Lyric_Binding.cs @@ -44,7 +44,7 @@ private void initInternalBindingEvent() void invalidate() => timeTagsVersion.Value++; }; - TimeTagsVersion.ValueChanged += (_) => + TimeTagsVersion.ValueChanged += _ => { updateLyricTime(); }; From 6d568c9914de18337993a54fec7068e8e0517789 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 25 Feb 2023 11:20:30 -0800 Subject: [PATCH 3/5] Remove un-need null check --- .../Graphics/TestSceneSingerToolTip.cs | 2 +- .../Edit/Components/ContextMenu/SingerContextMenu.cs | 2 +- .../Edit/Generator/Lyrics/Language/LanguageDetector.cs | 2 +- .../Skinning/Tools/SkinConverterTool.cs | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Graphics/TestSceneSingerToolTip.cs b/osu.Game.Rulesets.Karaoke.Tests/Graphics/TestSceneSingerToolTip.cs index 33cccf11c..0ee9a1893 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Graphics/TestSceneSingerToolTip.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Graphics/TestSceneSingerToolTip.cs @@ -71,7 +71,7 @@ private void setTooltip(string testName, Action callBack) AddStep(testName, () => { var singer = new Singer(1); - callBack?.Invoke(singer); + callBack(singer); toolTip.SetContent(singer); }); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/ContextMenu/SingerContextMenu.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/ContextMenu/SingerContextMenu.cs index 8c8e0e10a..225cb3e31 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/ContextMenu/SingerContextMenu.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/ContextMenu/SingerContextMenu.cs @@ -26,7 +26,7 @@ public SingerContextMenu(EditorBeatmap beatmap, ILyricSingerChangeHandler lyricS var karaokeBeatmap = EditorBeatmapUtils.GetPlayableBeatmap(beatmap); var singers = karaokeBeatmap.SingerInfo.GetAllSingers(); - Items = singers?.Select(singer => new OsuMenuItem(singer.Name, anySingerInLyric(singer) ? MenuItemType.Highlighted : MenuItemType.Standard, () => + Items = singers.Select(singer => new OsuMenuItem(singer.Name, anySingerInLyric(singer) ? MenuItemType.Highlighted : MenuItemType.Standard, () => { // if only one lyric if (allSingerInLyric(singer)) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Generator/Lyrics/Language/LanguageDetector.cs b/osu.Game.Rulesets.Karaoke/Edit/Generator/Lyrics/Language/LanguageDetector.cs index 8b44037d1..00ab02af4 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Generator/Lyrics/Language/LanguageDetector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Generator/Lyrics/Language/LanguageDetector.cs @@ -15,7 +15,7 @@ public class LanguageDetector : LyricPropertyDetector x != null).ToList(); + var targetLanguages = config.AcceptLanguages.ToList(); if (targetLanguages.Any()) { diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Tools/SkinConverterTool.cs b/osu.Game.Rulesets.Karaoke/Skinning/Tools/SkinConverterTool.cs index 2b7e422fd..beebbbcba 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Tools/SkinConverterTool.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/Tools/SkinConverterTool.cs @@ -49,8 +49,11 @@ private static void attachShaders(ShaderManager shaderManager, IEnumerable Date: Sat, 25 Feb 2023 11:20:40 -0800 Subject: [PATCH 4/5] Remove un-need "$". --- .../IO/Serialization/Converters/LyricConverterTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/LyricConverterTest.cs b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/LyricConverterTest.cs index 96f124f6e..02c2f233e 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/LyricConverterTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/LyricConverterTest.cs @@ -64,7 +64,7 @@ public void TestLyricConverterWithSyncConfig() }; const string expected = - $"{{\"time_preempt\":600.0,\"time_fade_in\":400.0,\"start_time_bindable\":0.0,\"samples_bindable\":[],\"sample_control_point\":{{\"sample_bank_bindable\":\"normal\",\"sample_volume_bindable\":100,\"sample_bank\":\"normal\",\"sample_volume\":100}},\"difficulty_control_point\":{{\"slider_velocity_bindable\":1.0,\"slider_velocity\":1.0}},\"reference_lyric_id\":0,\"reference_lyric_config\":{{\"$type\":\"SyncLyricConfig\"}},\"samples\":[],\"auxiliary_samples\":[]}}"; + "{\"time_preempt\":600.0,\"time_fade_in\":400.0,\"start_time_bindable\":0.0,\"samples_bindable\":[],\"sample_control_point\":{\"sample_bank_bindable\":\"normal\",\"sample_volume_bindable\":100,\"sample_bank\":\"normal\",\"sample_volume\":100},\"difficulty_control_point\":{\"slider_velocity_bindable\":1.0,\"slider_velocity\":1.0},\"reference_lyric_id\":0,\"reference_lyric_config\":{\"$type\":\"SyncLyricConfig\"},\"samples\":[],\"auxiliary_samples\":[]}"; string actual = JsonConvert.SerializeObject(lyric, CreateSettings()); Assert.AreEqual(expected, actual); } @@ -79,7 +79,7 @@ public void TestLyricConverterWithReferenceConfig() }; const string expected = - $"{{\"time_preempt\":600.0,\"time_fade_in\":400.0,\"start_time_bindable\":0.0,\"samples_bindable\":[],\"sample_control_point\":{{\"sample_bank_bindable\":\"normal\",\"sample_volume_bindable\":100,\"sample_bank\":\"normal\",\"sample_volume\":100}},\"difficulty_control_point\":{{\"slider_velocity_bindable\":1.0,\"slider_velocity\":1.0}},\"text\":\"\",\"time_tags\":[],\"ruby_tags\":[],\"romaji_tags\":[],\"singers\":[],\"translates\":{{}},\"reference_lyric_id\":0,\"reference_lyric_config\":{{\"$type\":\"ReferenceLyricConfig\"}},\"samples\":[],\"auxiliary_samples\":[]}}"; + "{\"time_preempt\":600.0,\"time_fade_in\":400.0,\"start_time_bindable\":0.0,\"samples_bindable\":[],\"sample_control_point\":{\"sample_bank_bindable\":\"normal\",\"sample_volume_bindable\":100,\"sample_bank\":\"normal\",\"sample_volume\":100},\"difficulty_control_point\":{\"slider_velocity_bindable\":1.0,\"slider_velocity\":1.0},\"text\":\"\",\"time_tags\":[],\"ruby_tags\":[],\"romaji_tags\":[],\"singers\":[],\"translates\":{},\"reference_lyric_id\":0,\"reference_lyric_config\":{\"$type\":\"ReferenceLyricConfig\"},\"samples\":[],\"auxiliary_samples\":[]}"; string actual = JsonConvert.SerializeObject(lyric, CreateSettings()); Assert.AreEqual(expected, actual); } From b40c0d890384a7a4b624681a874f5fa8cffd22d3 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 25 Feb 2023 11:25:40 -0800 Subject: [PATCH 5/5] Rename to prevent duplicated naming. --- .../BeatmapStageElementCategoryChangeHandlerTest.cs | 4 ++-- .../Beatmaps/BeatmapStageElementCategoryChangeHandler.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandlerTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandlerTest.cs index 8c76a11ba..4892deb0b 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandlerTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandlerTest.cs @@ -243,8 +243,8 @@ private static ClassicLyricLayoutCategory getStageCategory(KaraokeBeatmap beatma public partial class TestBeatmapStageElementCategoryChangeHandler : BeatmapStageElementCategoryChangeHandler { - public TestBeatmapStageElementCategoryChangeHandler(Func, StageElementCategory> action) - : base(action) + public TestBeatmapStageElementCategoryChangeHandler(Func, StageElementCategory> stageCategoryAction) + : base(stageCategoryAction) { } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandler.cs b/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandler.cs index a4e18b9e3..fa208f5c8 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandler.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ChangeHandlers/Beatmaps/BeatmapStageElementCategoryChangeHandler.cs @@ -14,11 +14,11 @@ public partial class BeatmapStageElementCategoryChangeHandler where THitObject : KaraokeHitObject, IHasPrimaryKey { - private readonly Func, StageElementCategory> action; + private readonly Func, StageElementCategory> stageCategoryAction; - public BeatmapStageElementCategoryChangeHandler(Func, StageElementCategory> action) + public BeatmapStageElementCategoryChangeHandler(Func, StageElementCategory> stageCategoryAction) { - this.action = action; + this.stageCategoryAction = stageCategoryAction; } public void AddElement(Action? action = null) @@ -104,7 +104,7 @@ private void performStageInfoChanged(Action { - var stageCategory = action(beatmap.StageInfos); + var stageCategory = stageCategoryAction(beatmap.StageInfos); stageAction(stageCategory); }); }