From d7e043f3d4916dd2be01b43ce7c62c824e4c6a2b Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 10 May 2023 20:54:14 +0800 Subject: [PATCH 1/5] Upgrade the package to the latest. --- osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index aed051922..6d1d5b31f 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -13,12 +13,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 4ab927d4223f42f8c268f0706a233b85a0f863c0 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 10 May 2023 23:01:59 +0800 Subject: [PATCH 2/5] Fix the broken code. --- .../Edit/Export/ExportLyricManager.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.cs index 9af753d63..6f3c68ac9 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.cs @@ -4,12 +4,14 @@ using System; using System.IO; using System.Linq; +using System.Threading; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Platform; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Extensions; +using osu.Game.Overlays.Notifications; using osu.Game.Rulesets.Karaoke.Beatmaps.Formats; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Screens.Edit; @@ -83,10 +85,16 @@ public void ExportToJsonBeatmap() // note : this is for develop testing purpose. // will be removed eventually string beatmapName = string.IsNullOrEmpty(beatmap.Name) ? "[NoName]" : beatmap.Name; + var exportStorage = storage.GetStorageForDirectory("exports"); string filename = $"{beatmapName}.osu"; - string beatmapText = generateJsonBeatmap(); - new KaraokeLegacyBeatmapExporter(storage, filename, beatmapText).Export(beatmap.BeatmapInfo.BeatmapSet); + using (var outputStream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create)) + { + string beatmapText = generateJsonBeatmap(); + new KaraokeLegacyBeatmapExporter(storage, filename, beatmapText).ExportToStream(beatmap.BeatmapInfo.BeatmapSet!, outputStream, null); + } + + exportStorage.PresentFileExternally(filename); } private string generateJsonBeatmap() @@ -125,7 +133,7 @@ public KaraokeLegacyBeatmapExporter(Storage storage, string filename, string con this.content = content; } - public override void ExportModelTo(BeatmapSetInfo model, Stream outputStream) + public override void ExportToStream(BeatmapSetInfo model, Stream outputStream, ProgressNotification? notification, CancellationToken cancellationToken = new()) { // base.ExportModelTo(model, outputStream); using var zipArchive = ZipArchive.Create(); From 03f46e264c200e133b8cc791952488f233b5e3c5 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 10 May 2023 22:37:35 +0800 Subject: [PATCH 3/5] Fix the test case failed because add the new property in the base class. --- osu.Game.Rulesets.Karaoke/Edit/Utils/HitObjectWritableUtils.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Utils/HitObjectWritableUtils.cs b/osu.Game.Rulesets.Karaoke/Edit/Utils/HitObjectWritableUtils.cs index 66e8002fc..5b8677d93 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Utils/HitObjectWritableUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Utils/HitObjectWritableUtils.cs @@ -89,6 +89,7 @@ private static bool isWriteLyricPropertyLockedByState(LockState lockState, strin nameof(Lyric.ReferenceLyricConfig) => lockState > LockState.Partial, // base class nameof(Lyric.Samples) => false, + nameof(Lyric.LegacyBpmMultiplier) => false, _ => throw new NotSupportedException() }; } @@ -116,6 +117,7 @@ private static bool isWriteLyricPropertyLockedByConfig(IReferenceLyricPropertyCo nameof(Lyric.ReferenceLyricConfig) => false, // base class nameof(Lyric.Samples) => false, + nameof(Lyric.LegacyBpmMultiplier) => false, _ => throw new NotSupportedException() }, null => false, From 87b2fcc875c557e54a0cb8303456867797dc21a3 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 10 May 2023 22:51:19 +0800 Subject: [PATCH 4/5] Fix the test case broken because sample control point has been removed in the base hit-object class. See: https://github.com/ppy/osu/pull/23308 --- .../IO/Serialization/Converters/LyricConverterTest.cs | 8 ++++---- .../KaraokeJsonSerializableExtensionsTest.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 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 bb32c75d8..ebf69edbf 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/LyricConverterTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/Converters/LyricConverterTest.cs @@ -24,7 +24,7 @@ public void TestLyricConverterWithNoConfig() var lyric = new Lyric(); 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\":[],\"singer_ids\":[],\"translates\":{},\"samples\":[],\"auxiliary_samples\":[]}"; + "{\"time_preempt\":600.0,\"time_fade_in\":400.0,\"start_time_bindable\":0.0,\"samples_bindable\":[],\"text\":\"\",\"time_tags\":[],\"ruby_tags\":[],\"romaji_tags\":[],\"singer_ids\":[],\"translates\":{},\"samples\":[],\"auxiliary_samples\":[]}"; string actual = JsonConvert.SerializeObject(lyric, CreateSettings()); Assert.AreEqual(expected, actual); } @@ -33,7 +33,7 @@ public void TestLyricConverterWithNoConfig() public void TestDeserializeWithNoConfig() { const string json = - "{\"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\":[],\"singer_ids\":[],\"translates\":{},\"samples\":[],\"auxiliary_samples\":[]}"; + "{\"time_preempt\":600.0,\"time_fade_in\":400.0,\"start_time_bindable\":0.0,\"samples_bindable\":[],\"text\":\"\",\"time_tags\":[],\"ruby_tags\":[],\"romaji_tags\":[],\"singer_ids\":[],\"translates\":{},\"samples\":[],\"auxiliary_samples\":[]}"; var expected = new Lyric(); var actual = JsonConvert.DeserializeObject(json, CreateSettings())!; @@ -66,7 +66,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\":[],\"reference_lyric_id\":0,\"reference_lyric_config\":{\"$type\":\"SyncLyricConfig\"},\"samples\":[],\"auxiliary_samples\":[]}"; string actual = JsonConvert.SerializeObject(lyric, CreateSettings()); Assert.AreEqual(expected, actual); } @@ -83,7 +83,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\":[],\"singer_ids\":[],\"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\":[],\"text\":\"\",\"time_tags\":[],\"ruby_tags\":[],\"romaji_tags\":[],\"singer_ids\":[],\"translates\":{},\"reference_lyric_id\":0,\"reference_lyric_config\":{\"$type\":\"ReferenceLyricConfig\"},\"samples\":[],\"auxiliary_samples\":[]}"; string actual = JsonConvert.SerializeObject(lyric, CreateSettings()); Assert.AreEqual(expected, actual); } diff --git a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/KaraokeJsonSerializableExtensionsTest.cs b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/KaraokeJsonSerializableExtensionsTest.cs index 6bf6f1d7c..c51108fe4 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/KaraokeJsonSerializableExtensionsTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/IO/Serialization/KaraokeJsonSerializableExtensionsTest.cs @@ -17,7 +17,7 @@ public void TestSerializeLyric() var lyric = new Lyric(); 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"":[],""singer_ids"":[],""translates"":[],""samples"":[],""auxiliary_samples"":[]}"; + @"{""time_preempt"":600.0,""time_fade_in"":400.0,""start_time_bindable"":0.0,""samples_bindable"":[],""text"":"""",""time_tags"":[],""ruby_tags"":[],""romaji_tags"":[],""singer_ids"":[],""translates"":[],""samples"":[],""auxiliary_samples"":[]}"; string actual = JsonConvert.SerializeObject(lyric, createSettings()); Assert.AreEqual(expected, actual); @@ -27,7 +27,7 @@ public void TestSerializeLyric() public void TestDeserializeLyric() { const string json = - @"{""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"":[],""singer_ids"":[],""translates"":[],""samples"":[],""auxiliary_samples"":[]}"; + @"{""time_preempt"":600.0,""time_fade_in"":400.0,""start_time_bindable"":0.0,""samples_bindable"":[],""text"":"""",""time_tags"":[],""ruby_tags"":[],""romaji_tags"":[],""singer_ids"":[],""translates"":[],""samples"":[],""auxiliary_samples"":[]}"; var expected = new Lyric(); var actual = JsonConvert.DeserializeObject(json, createSettings())!; @@ -40,7 +40,7 @@ public void TestSerializeNote() var note = new Note(); 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},""samples"":[],""auxiliary_samples"":[]}"; + @"{""time_preempt"":600.0,""time_fade_in"":400.0,""start_time_bindable"":0.0,""samples_bindable"":[],""samples"":[],""auxiliary_samples"":[]}"; string actual = JsonConvert.SerializeObject(note, createSettings()); Assert.AreEqual(expected, actual); @@ -50,7 +50,7 @@ public void TestSerializeNote() public void TestDeserializeNote() { const string json = - @"{""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},""samples"":[],""auxiliary_samples"":[]}"; + @"{""time_preempt"":600.0,""time_fade_in"":400.0,""start_time_bindable"":0.0,""samples_bindable"":[],""samples"":[],""auxiliary_samples"":[]}"; var expected = new Note(); var actual = JsonConvert.DeserializeObject(json, createSettings())!; From df5fcb01289c76733cc894b9cc4405f656a4ca77 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 10 May 2023 23:04:42 +0800 Subject: [PATCH 5/5] Upgrade the Octokit to the latest. --- osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index 6d1d5b31f..3e4abdece 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -11,7 +11,7 @@ - +