1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 05:56:42 +08:00

Swap order of background/audio track changing methods

Mostly for quality of reviewing (restores previous order) and more
consistency overall.
This commit is contained in:
Bartłomiej Dach 2021-04-04 13:10:12 +02:00
parent a0f0ae7979
commit 0a1417bc67

View File

@ -93,6 +93,33 @@ namespace osu.Game.Screens.Edit.Setup
AutoSizeAxes = Axes.Y,
};
public bool ChangeBackgroundImage(string path)
{
var info = new FileInfo(path);
if (!info.Exists)
return false;
var set = working.Value.BeatmapSetInfo;
// remove the previous background for now.
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.BackgroundFile);
using (var stream = info.OpenRead())
{
if (oldFile != null)
beatmaps.ReplaceFile(set, oldFile, stream, info.Name);
else
beatmaps.AddFile(set, stream, info.Name);
}
working.Value.Metadata.BackgroundFile = info.Name;
header.Background.UpdateBackground();
return true;
}
public bool ChangeAudioTrack(string path)
{
var info = new FileInfo(path);
@ -122,33 +149,6 @@ namespace osu.Game.Screens.Edit.Setup
return true;
}
public bool ChangeBackgroundImage(string path)
{
var info = new FileInfo(path);
if (!info.Exists)
return false;
var set = working.Value.BeatmapSetInfo;
// remove the previous background for now.
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.BackgroundFile);
using (var stream = info.OpenRead())
{
if (oldFile != null)
beatmaps.ReplaceFile(set, oldFile, stream, info.Name);
else
beatmaps.AddFile(set, stream, info.Name);
}
working.Value.Metadata.BackgroundFile = info.Name;
header.Background.UpdateBackground();
return true;
}
private void backgroundChanged(ValueChangedEvent<string> filePath)
{
if (!ChangeBackgroundImage(filePath.NewValue))