1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 10:33:22 +08:00

Re-encode difficulties on resource change

This commit is contained in:
Salman Alshamrani 2024-12-04 04:36:00 -05:00
parent 60d91bada8
commit 8e0f6fc12d
2 changed files with 8 additions and 5 deletions

View File

@ -8,16 +8,13 @@ using System.Text;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Formats;
using osu.Game.Collections;
using osu.Game.Database;
using osu.Game.Overlays.Dialog;

View File

@ -103,6 +103,7 @@ namespace osu.Game.Screens.Edit.Setup
private void changeResource(FileInfo source, bool applyToAllDifficulties, string baseFilename, Func<BeatmapMetadata, string> readFilename, Action<BeatmapMetadata, string> writeFilename)
{
var thisBeatmap = working.Value.BeatmapInfo;
var set = working.Value.BeatmapSetInfo;
string newFilename = string.Empty;
@ -117,12 +118,17 @@ namespace osu.Game.Screens.Edit.Setup
beatmaps.DeleteFile(set, otherExistingFile);
writeFilename(beatmap.Metadata, newFilename);
if (!beatmap.Equals(thisBeatmap))
{
// save the difficulty to re-encode the .osu file, updating any reference of the old filename.
var beatmapWorking = beatmaps.GetWorkingBeatmap(beatmap);
beatmaps.Save(beatmap, beatmapWorking.Beatmap, beatmapWorking.GetSkin());
}
}
}
else
{
var thisBeatmap = working.Value.BeatmapInfo;
string[] filenames = set.Files.Select(f => f.Filename).Where(f =>
f.StartsWith(baseFilename, StringComparison.OrdinalIgnoreCase) &&
f.EndsWith(source.Extension, StringComparison.OrdinalIgnoreCase)).ToArray();