From 17e07ff6c7a1454fffd064350d51950c80bec3ff Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 7 Apr 2024 20:10:39 +0800 Subject: [PATCH 1/2] Export json beatmap should be the the debug part. --- .../Edit/Debugging/DebugBeatmapManager.cs | 144 ++++++++++++++++++ .../Edit/Export/ExportLyricManager.cs | 110 ------------- .../Edit/KaraokeHitObjectComposer.cs | 9 +- .../Edit/Beatmaps/KaraokeBeatmapEditor.cs | 16 +- 4 files changed, 163 insertions(+), 116 deletions(-) create mode 100644 osu.Game.Rulesets.Karaoke/Edit/Debugging/DebugBeatmapManager.cs diff --git a/osu.Game.Rulesets.Karaoke/Edit/Debugging/DebugBeatmapManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Debugging/DebugBeatmapManager.cs new file mode 100644 index 000000000..1df83c621 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Edit/Debugging/DebugBeatmapManager.cs @@ -0,0 +1,144 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +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; +using SharpCompress.Archives.Zip; + +namespace osu.Game.Rulesets.Karaoke.Edit.Debugging; + +/// +/// Save or export the beatmap for debug. +/// Beatmap will be json format and might not be the final version. +/// +public partial class DebugBeatmapManager : Component +{ + [Resolved] + private Storage storage { get; set; } = null!; + + [Resolved] + private EditorBeatmap beatmap { get; set; } = null!; + + /// + /// Export the json beatmap only. + /// + public void ExportToJson() + { + // note : this is for develop testing purpose. + // will be removed eventually + string beatmapName = string.IsNullOrEmpty(beatmap.Name) ? "[NoName]" : beatmap.Name; + var exportStorage = storage.GetStorageForDirectory("json"); + string filename = $"{beatmapName}.json"; + + using (var outputStream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create)) + using (var sw = new StreamWriter(outputStream)) + { + sw.WriteLine(generateJsonBeatmap(beatmap)); + } + + exportStorage.PresentFileExternally(filename); + } + + /// + /// Export the whole beatmap with: + /// 1. json format beatmap. + /// 2. other resource like audio, background. + /// + 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}.osz"; + + using (var outputStream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create)) + { + string beatmapText = generateJsonBeatmap(beatmap); + new KaraokeLegacyBeatmapExporter(storage, filename, beatmapText).ExportToStream(beatmap.BeatmapInfo.BeatmapSet!, outputStream, null); + } + + exportStorage.PresentFileExternally(filename); + } + + private static string generateJsonBeatmap(EditorBeatmap beatmap) + { + var encoder = new KaraokeJsonBeatmapEncoder(); + var karaokeBeatmap = EditorBeatmapUtils.GetPlayableBeatmap(beatmap); + + var encodeBeatmap = new Beatmap + { + Difficulty = karaokeBeatmap.Difficulty.Clone(), + BeatmapInfo = karaokeBeatmap.BeatmapInfo.Clone(), + ControlPointInfo = karaokeBeatmap.ControlPointInfo.DeepClone(), + Breaks = karaokeBeatmap.Breaks, + HitObjects = beatmap.HitObjects.ToList(), + }; + encodeBeatmap.BeatmapInfo.BeatmapSet = new BeatmapSetInfo(); + encodeBeatmap.BeatmapInfo.Metadata = new BeatmapMetadata + { + Title = "json beatmap", + AudioFile = karaokeBeatmap.Metadata.AudioFile, + BackgroundFile = karaokeBeatmap.Metadata.BackgroundFile, + }; + + return encoder.Encode(encodeBeatmap); + } + + private class KaraokeLegacyBeatmapExporter : LegacyBeatmapExporter + { + private readonly string filename; + private readonly string content; + + public KaraokeLegacyBeatmapExporter(Storage storage, string filename, string content) + : base(storage) + { + this.filename = filename; + this.content = content; + } + + public override void ExportToStream(BeatmapSetInfo model, Stream outputStream, ProgressNotification? notification, CancellationToken cancellationToken = new()) + { + // base.ExportModelTo(model, outputStream); + using var zipArchive = ZipArchive.Create(); + + foreach (INamedFileUsage file in model.Files) + { + // do not export other osu beatmap. + if (file.Filename.EndsWith(".osu", StringComparison.Ordinal)) + continue; + + zipArchive.AddEntry(file.Filename, UserFileStorage.GetStream(file.File.GetStoragePath())); + } + + // add the json file. + using var jsonBeatmapStream = getJsonBeatmapStream(); + zipArchive.AddEntry(filename, jsonBeatmapStream); + zipArchive.SaveTo(outputStream); + } + + private Stream getJsonBeatmapStream() + { + var memoryStream = new MemoryStream(); + var sw = new StreamWriter(memoryStream); + + sw.WriteLine(content); + sw.Flush(); + + memoryStream.Position = 0; + return memoryStream; + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.cs index 8a9592bb7..89cd8eced 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Export/ExportLyricManager.cs @@ -1,21 +1,14 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -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; -using SharpCompress.Archives.Zip; namespace osu.Game.Rulesets.Karaoke.Edit.Export; @@ -62,107 +55,4 @@ public void ExportToText() exportStorage.PresentFileExternally(filename); } - - public void ExportToJson() - { - // note : this is for develop testing purpose. - // will be removed eventually - string beatmapName = string.IsNullOrEmpty(beatmap.Name) ? "[NoName]" : beatmap.Name; - var exportStorage = storage.GetStorageForDirectory("json"); - string filename = $"{beatmapName}.json"; - - using (var outputStream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create)) - using (var sw = new StreamWriter(outputStream)) - { - sw.WriteLine(generateJsonBeatmap()); - } - - exportStorage.PresentFileExternally(filename); - } - - 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"; - - 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() - { - var encoder = new KaraokeJsonBeatmapEncoder(); - var karaokeBeatmap = EditorBeatmapUtils.GetPlayableBeatmap(beatmap); - - var encodeBeatmap = new Beatmap - { - Difficulty = karaokeBeatmap.Difficulty.Clone(), - BeatmapInfo = karaokeBeatmap.BeatmapInfo.Clone(), - ControlPointInfo = karaokeBeatmap.ControlPointInfo.DeepClone(), - Breaks = karaokeBeatmap.Breaks, - HitObjects = beatmap.HitObjects.ToList(), - }; - encodeBeatmap.BeatmapInfo.BeatmapSet = new BeatmapSetInfo(); - encodeBeatmap.BeatmapInfo.Metadata = new BeatmapMetadata - { - Title = "json beatmap", - AudioFile = karaokeBeatmap.Metadata.AudioFile, - BackgroundFile = karaokeBeatmap.Metadata.BackgroundFile, - }; - - return encoder.Encode(encodeBeatmap); - } - - private class KaraokeLegacyBeatmapExporter : LegacyBeatmapExporter - { - private readonly string filename; - private readonly string content; - - public KaraokeLegacyBeatmapExporter(Storage storage, string filename, string content) - : base(storage) - { - this.filename = filename; - this.content = content; - } - - public override void ExportToStream(BeatmapSetInfo model, Stream outputStream, ProgressNotification? notification, CancellationToken cancellationToken = new()) - { - // base.ExportModelTo(model, outputStream); - using var zipArchive = ZipArchive.Create(); - - foreach (INamedFileUsage file in model.Files) - { - // do not export other osu beatmap. - if (file.Filename.EndsWith(".osu", StringComparison.Ordinal)) - continue; - - zipArchive.AddEntry(file.Filename, UserFileStorage.GetStream(file.File.GetStoragePath())); - } - - // add the json file. - using var jsonBeatmapStream = getJsonBeatmapStream(); - zipArchive.AddEntry(filename, jsonBeatmapStream); - zipArchive.SaveTo(outputStream); - } - - private Stream getJsonBeatmapStream() - { - var memoryStream = new MemoryStream(); - var sw = new StreamWriter(memoryStream); - - sw.WriteLine(content); - sw.Flush(); - - memoryStream.Position = 0; - return memoryStream; - } - } } diff --git a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs index 806d587f4..650ddf3bb 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs @@ -17,7 +17,7 @@ using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Notes; using osu.Game.Rulesets.Karaoke.Edit.Components.Menus; -using osu.Game.Rulesets.Karaoke.Edit.Export; +using osu.Game.Rulesets.Karaoke.Edit.Debugging; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Skinning.Fonts; using osu.Game.Rulesets.Karaoke.UI; @@ -67,7 +67,7 @@ public partial class KaraokeHitObjectComposer : HitObjectComposer exportLyricManager.ExportToJsonBeatmap()), + new EditorMenuItem("Export to json", MenuItemType.Destructive, () => debugBeatmapManager.ExportToJson()), + new EditorMenuItem("Export to json beatmap", MenuItemType.Destructive, () => debugBeatmapManager.ExportToJsonBeatmap()), }, }, }; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/KaraokeBeatmapEditor.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/KaraokeBeatmapEditor.cs index 5bb3f3941..0561f4fe3 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/KaraokeBeatmapEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/KaraokeBeatmapEditor.cs @@ -10,6 +10,7 @@ using osu.Game.Rulesets.Karaoke.Beatmaps; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers; +using osu.Game.Rulesets.Karaoke.Edit.Debugging; using osu.Game.Rulesets.Karaoke.Edit.Export; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Components.Menus; using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics; @@ -53,6 +54,9 @@ public partial class KaraokeBeatmapEditor : GenericEditor bindableLyricEditorMode = new(); @@ -71,6 +75,8 @@ public KaraokeBeatmapEditor() AddInternal(lyricsProvider = new LyricsProvider()); AddInternal(importBeatmapChangeHandler = new ImportBeatmapChangeHandler()); + + AddInternal(debugBeatmapManager = new DebugBeatmapManager()); } protected override GenericEditorScreen GenerateScreen(KaraokeBeatmapEditorScreenMode screenMode) => @@ -98,8 +104,6 @@ protected override MenuItem[] GenerateMenuItems(KaraokeBeatmapEditorScreenMode s new OsuMenuItemSpacer(), new EditorMenuItem("Export to .lrc", MenuItemType.Standard, () => exportLyricManager.ExportToLrc()), new EditorMenuItem("Export to text", MenuItemType.Standard, () => exportLyricManager.ExportToText()), - new EditorMenuItem("Export to json", MenuItemType.Destructive, () => exportLyricManager.ExportToJson()), - new EditorMenuItem("Export to json beatmap", MenuItemType.Destructive, () => exportLyricManager.ExportToJsonBeatmap()), }, }, new LyricEditorModeMenuItem("Mode", bindableLyricEditorMode), @@ -116,6 +120,14 @@ protected override MenuItem[] GenerateMenuItems(KaraokeBeatmapEditorScreenMode s { Items = new MenuItem[] { new EditorMenuItem("Lyric editor"), new GeneratorConfigMenu("Auto-generator"), new LockStateMenuItem("Lock", lyricEditorConfigManager) }, }, + new("Debug") + { + Items = new MenuItem[] + { + new EditorMenuItem("Export to json", MenuItemType.Destructive, () => debugBeatmapManager.ExportToJson()), + new EditorMenuItem("Export to json beatmap", MenuItemType.Destructive, () => debugBeatmapManager.ExportToJsonBeatmap()), + }, + }, }, _ => Array.Empty(), }; From e0020ca574c614eeb46ee0110712642f256210ef Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 7 Apr 2024 20:28:32 +0800 Subject: [PATCH 2/2] Add debug utils for able to save the beatmap. --- .../Edit/Debugging/DebugBeatmapManager.cs | 165 +++++++++++++++++- .../Edit/KaraokeHitObjectComposer.cs | 3 + .../Edit/Beatmaps/KaraokeBeatmapEditor.cs | 3 + 3 files changed, 163 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Debugging/DebugBeatmapManager.cs b/osu.Game.Rulesets.Karaoke/Edit/Debugging/DebugBeatmapManager.cs index 1df83c621..ffeeceea9 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Debugging/DebugBeatmapManager.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Debugging/DebugBeatmapManager.cs @@ -2,10 +2,14 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; +using System.Text; using System.Threading; using osu.Framework.Allocation; +using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Platform; using osu.Game.Beatmaps; @@ -15,6 +19,7 @@ using osu.Game.Rulesets.Karaoke.Beatmaps.Formats; using osu.Game.Rulesets.Karaoke.Edit.Utils; using osu.Game.Screens.Edit; +using osu.Game.Utils; using SharpCompress.Archives.Zip; namespace osu.Game.Rulesets.Karaoke.Edit.Debugging; @@ -31,6 +36,151 @@ public partial class DebugBeatmapManager : Component [Resolved] private EditorBeatmap beatmap { get; set; } = null!; + [Resolved] + private BeatmapManager beatmapManager { get; set; } = null!; + + /// + /// Force save the beatmap with json format. + /// Modified from + /// + public void OverrideTheBeatmapWithJsonFormat() + { + var karaokeBeatmap = EditorBeatmapUtils.GetPlayableBeatmap(beatmap); + save(beatmap.BeatmapInfo, karaokeBeatmap); + } + + /// + /// Save the beatmap with json format to new difficulty. + /// Modified from + /// + public void SaveToNewDifficulty() + { + var referenceWorkingBeatmap = beatmap; + var targetBeatmapSet = beatmap.BeatmapInfo.BeatmapSet; + + if (targetBeatmapSet == null) + { + return; + } + + // start modifiey + var newBeatmap = EditorBeatmapUtils.GetPlayableBeatmap(beatmap); + BeatmapInfo newBeatmapInfo; + + newBeatmap.BeatmapInfo = newBeatmapInfo = referenceWorkingBeatmap.BeatmapInfo.Clone(); + // assign a new ID to the clone. + newBeatmapInfo.ID = Guid.NewGuid(); + // add "(copy)" suffix to difficulty name, and additionally ensure that it doesn't conflict with any other potentially pre-existing copies. + newBeatmapInfo.DifficultyName = NamingUtils.GetNextBestName( + targetBeatmapSet.Beatmaps.Select(b => b.DifficultyName), + $"{newBeatmapInfo.DifficultyName} (copy)"); + // clear the hash, as that's what is used to match .osu files with their corresponding realm beatmaps. + newBeatmapInfo.Hash = string.Empty; + // clear online properties. + newBeatmapInfo.ResetOnlineInfo(); + + addDifficultyToSet(targetBeatmapSet, newBeatmap); + return; + + void addDifficultyToSet(BeatmapSetInfo targetBeatmapSet, IBeatmap newBeatmap) + { + // populate circular beatmap set info <-> beatmap info references manually. + // several places like `Save()` or `GetWorkingBeatmap()` + // rely on them being freely traversable in both directions for correct operation. + targetBeatmapSet.Beatmaps.Add(newBeatmap.BeatmapInfo); + newBeatmap.BeatmapInfo.BeatmapSet = targetBeatmapSet; + + save(newBeatmap.BeatmapInfo, newBeatmap); + } + } + + /// + /// Copied from + /// + /// + /// + /// + private void save(BeatmapInfo beatmapInfo, IBeatmap beatmapContent) + { + // get realm from beatmapManager using reflection + var realm = beatmapManager.GetType().GetProperty("Realm", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(beatmapManager) as RealmAccess; + + if (realm == null) + { + throw new InvalidOperationException(); + } + + var setInfo = beatmapInfo.BeatmapSet; + Debug.Assert(setInfo != null); + + // Difficulty settings must be copied first due to the clone in `Beatmap<>.BeatmapInfo_Set`. + // This should hopefully be temporary, assuming said clone is eventually removed. + + // Warning: The directionality here is important. Changes have to be copied *from* beatmapContent (which comes from editor and is being saved) + // *to* the beatmapInfo (which is a database model and needs to receive values without the taiko slider velocity multiplier for correct operation). + // CopyTo() will undo such adjustments, while CopyFrom() will not. + beatmapContent.Difficulty.CopyTo(beatmapInfo.Difficulty); + + // All changes to metadata are made in the provided beatmapInfo, so this should be copied to the `IBeatmap` before encoding. + beatmapContent.BeatmapInfo = beatmapInfo; + + // Since now this is a locally-modified beatmap, we also set all relevant flags to indicate this. + // Importantly, the `ResetOnlineInfo()` call must happen before encoding, as online ID is encoded into the `.osu` file, + // which influences the beatmap checksums. + beatmapInfo.LastLocalUpdate = DateTimeOffset.Now; + beatmapInfo.Status = BeatmapOnlineStatus.LocallyModified; + beatmapInfo.ResetOnlineInfo(); + + realm.Write(r => + { + using var stream = new MemoryStream(); + + using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true)) + { + sw.WriteLine(generateJsonBeatmap(beatmapContent)); + } + + stream.Seek(0, SeekOrigin.Begin); + + // AddFile generally handles updating/replacing files, but this is a case where the filename may have also changed so let's delete for simplicity. + var existingFileInfo = beatmapInfo.Path != null ? setInfo.GetFile(beatmapInfo.Path) : null; + string targetFilename = createBeatmapFilenameFromMetadata(beatmapInfo); + + // ensure that two difficulties from the set don't point at the same beatmap file. + if (setInfo.Beatmaps.Any(b => b.ID != beatmapInfo.ID && string.Equals(b.Path, targetFilename, StringComparison.OrdinalIgnoreCase))) + throw new InvalidOperationException($"{setInfo.GetDisplayString()} already has a difficulty with the name of '{beatmapInfo.DifficultyName}'."); + + if (existingFileInfo != null) + beatmapManager.DeleteFile(setInfo, existingFileInfo); + + string oldMd5Hash = beatmapInfo.MD5Hash; + + beatmapInfo.MD5Hash = stream.ComputeMD5Hash(); + beatmapInfo.Hash = stream.ComputeSHA2Hash(); + + beatmapManager.AddFile(setInfo, stream, createBeatmapFilenameFromMetadata(beatmapInfo)); + + // beatmapManager.updateHashAndMarkDirty(setInfo); + var method = typeof(BeatmapManager).GetMethod("updateHashAndMarkDirty", BindingFlags.Instance | BindingFlags.NonPublic); + method?.Invoke(beatmapManager, new object?[] { setInfo }); + + var liveBeatmapSet = r.Find(setInfo.ID)!; + + setInfo.CopyChangesToRealm(liveBeatmapSet); + + liveBeatmapSet.Beatmaps.Single(b => b.ID == beatmapInfo.ID) + .UpdateLocalScores(r); + }); + + Debug.Assert(beatmapInfo.BeatmapSet != null); + + static string createBeatmapFilenameFromMetadata(BeatmapInfo beatmapInfo) + { + var metadata = beatmapInfo.Metadata; + return $"{metadata.Artist} - {metadata.Title} ({metadata.Author.Username}) [{beatmapInfo.DifficultyName}].osu".GetValidFilename(); + } + } + /// /// Export the json beatmap only. /// @@ -73,25 +223,24 @@ public void ExportToJsonBeatmap() exportStorage.PresentFileExternally(filename); } - private static string generateJsonBeatmap(EditorBeatmap beatmap) + private static string generateJsonBeatmap(IBeatmap beatmap) { var encoder = new KaraokeJsonBeatmapEncoder(); - var karaokeBeatmap = EditorBeatmapUtils.GetPlayableBeatmap(beatmap); var encodeBeatmap = new Beatmap { - Difficulty = karaokeBeatmap.Difficulty.Clone(), - BeatmapInfo = karaokeBeatmap.BeatmapInfo.Clone(), - ControlPointInfo = karaokeBeatmap.ControlPointInfo.DeepClone(), - Breaks = karaokeBeatmap.Breaks, + Difficulty = beatmap.Difficulty.Clone(), + BeatmapInfo = beatmap.BeatmapInfo.Clone(), + ControlPointInfo = beatmap.ControlPointInfo.DeepClone(), + Breaks = beatmap.Breaks, HitObjects = beatmap.HitObjects.ToList(), }; encodeBeatmap.BeatmapInfo.BeatmapSet = new BeatmapSetInfo(); encodeBeatmap.BeatmapInfo.Metadata = new BeatmapMetadata { Title = "json beatmap", - AudioFile = karaokeBeatmap.Metadata.AudioFile, - BackgroundFile = karaokeBeatmap.Metadata.BackgroundFile, + AudioFile = beatmap.Metadata.AudioFile, + BackgroundFile = beatmap.Metadata.BackgroundFile, }; return encoder.Encode(encodeBeatmap); diff --git a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs index 650ddf3bb..e60b6fb9a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs @@ -166,6 +166,9 @@ protected void CreateMenuBar() { Items = new MenuItem[] { + new EditorMenuItem("Override beatmap as json format", MenuItemType.Destructive, () => debugBeatmapManager.OverrideTheBeatmapWithJsonFormat()), + new EditorMenuItem("Save beatmap to new difficulty as json format", MenuItemType.Destructive, () => debugBeatmapManager.SaveToNewDifficulty()), + new OsuMenuItemSpacer(), new EditorMenuItem("Export to json", MenuItemType.Destructive, () => debugBeatmapManager.ExportToJson()), new EditorMenuItem("Export to json beatmap", MenuItemType.Destructive, () => debugBeatmapManager.ExportToJsonBeatmap()), }, diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/KaraokeBeatmapEditor.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/KaraokeBeatmapEditor.cs index 0561f4fe3..92b2d6179 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/KaraokeBeatmapEditor.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/KaraokeBeatmapEditor.cs @@ -124,6 +124,9 @@ protected override MenuItem[] GenerateMenuItems(KaraokeBeatmapEditorScreenMode s { Items = new MenuItem[] { + new EditorMenuItem("Override beatmap as json format", MenuItemType.Destructive, () => debugBeatmapManager.OverrideTheBeatmapWithJsonFormat()), + new EditorMenuItem("Save beatmap to new difficulty as json format", MenuItemType.Destructive, () => debugBeatmapManager.SaveToNewDifficulty()), + new OsuMenuItemSpacer(), new EditorMenuItem("Export to json", MenuItemType.Destructive, () => debugBeatmapManager.ExportToJson()), new EditorMenuItem("Export to json beatmap", MenuItemType.Destructive, () => debugBeatmapManager.ExportToJsonBeatmap()), },